From 4c48efdb573e0a8106fb4eb360c870253db27a86 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 13 Nov 2026 11:57:58 +0000 Subject: [PATCH] Add `JSUniqueRef` for bridging to non-copyable types --- Benchmarks/README.md | 8 + Benchmarks/Sources/Benchmarks.swift | 2 + Benchmarks/Sources/Generated/BridgeJS.swift | 212 + .../Generated/JavaScript/BridgeJS.json | 268 + .../Sources/ImportedObjectBenchmarks.swift | 62 + .../NoncopyableImportedObjectBenchmarks.swift | 62 + Benchmarks/run.js | 15 +- .../Sources/PlayBridgeJS/main.swift | 10 +- .../BridgeJSCore/AvailabilityIndex.swift | 70 + .../Sources/BridgeJSCore/ClosureCodegen.swift | 26 +- .../Sources/BridgeJSCore/ExportSwift.swift | 236 +- .../Sources/BridgeJSCore/ImportTS.swift | 116 +- .../BridgeJS/Sources/BridgeJSCore/Misc.swift | 18 +- .../BridgeJSCore/SwiftToSkeleton.swift | 216 +- .../Sources/BridgeJSLink/BridgeJSLink.swift | 2 + .../Sources/BridgeJSLink/JSGlueGen.swift | 18 +- .../BridgeJSMacros/BridgeJSMacrosPlugin.swift | 1 + .../Sources/BridgeJSMacros/JSClassMacro.swift | 55 +- .../BridgeJSMacros/JSFunctionMacro.swift | 8 +- .../JSGetterFunctionMacro.swift | 35 + .../BridgeJSMacros/JSGetterMacro.swift | 2 +- .../BridgeJSMacros/JSMacroSupport.swift | 25 +- .../BridgeJSMacros/JSSetterMacro.swift | 2 +- .../BridgeJSSkeleton/BridgeJSSkeleton.swift | 49 +- .../Sources/BridgeJSTool/BridgeJSTool.swift | 12 +- .../BridgeJSToolInternal.swift | 7 +- .../Sources/TS2Swift/JavaScript/src/cli.js | 17 +- .../TS2Swift/JavaScript/src/processor.js | 168 +- .../test/__snapshots__/ts2swift.test.js.snap | 132 + .../test/fixtures/Noncopyable/Warnings.d.ts | 14 + .../fixtures/Noncopyable/WrapperArrays.d.ts | 31 + .../test/fixtures/Noncopyable/Wrappers.d.ts | 25 + .../TS2Swift/JavaScript/test/ts2swift.test.js | 71 +- .../BridgeJS/Sources/TS2Swift/TS2Swift.swift | 6 +- .../JSClassMacroTests.swift | 86 + .../JSFunctionMacroTests.swift | 45 + .../JSGetterFunctionMacroTests.swift | 176 + .../JSGetterMacroTests.swift | 24 + .../JSSetterMacroTests.swift | 22 + .../AvailabilityIndexTests.swift | 87 + .../BridgeJSCodegenTests.swift | 13 +- .../BridgeJSToolTests/DiagnosticsTests.swift | 14 +- .../ExportedTypeNameTests.swift | 14 +- .../GenericImportDiagnosticsTests.swift | 14 +- .../Inputs/MacroSwift/Availability.swift | 90 + .../MacroSwift/NoncopyableJSClass.swift | 66 + .../ProtocolConditionalCompilation.swift | 14 + .../NoncopyableJSClassDiagnosticsTests.swift | 145 + .../BridgeJSCodegenTests/Availability.json | 635 + .../BridgeJSCodegenTests/Availability.swift | 780 + .../NoncopyableJSClass.json | 827 + .../NoncopyableJSClass.swift | 928 + .../ProtocolConditionalCompilation.json | 112 + .../ProtocolConditionalCompilation.swift | 101 + .../BridgeJSLinkTests/Availability.d.ts | 104 + .../BridgeJSLinkTests/Availability.js | 1108 ++ .../BridgeJSLinkTests/NoncopyableJSClass.d.ts | 64 + .../BridgeJSLinkTests/NoncopyableJSClass.js | 1145 ++ .../ProtocolConditionalCompilation.d.ts | 24 + .../ProtocolConditionalCompilation.js | 418 + .../JavaScriptKit/BridgeJSIntrinsics.swift | 258 +- .../BridgeJS/BridgeJS-Configuration.md | 20 + .../Exporting-Swift-Protocols.md | 3 + .../Importing-JS-Class.md | 20 + .../Articles/BridgeJS/Supported-Types.md | 9 +- .../FundamentalObjects/JSObject.swift | 4 + .../FundamentalObjects/JSUniqueRef.swift | 92 + Sources/JavaScriptKit/JSBridgedType.swift | 42 + Sources/JavaScriptKit/Macros.swift | 27 +- .../ClosureSupportTests.swift | 3 +- .../Generated/BridgeJS.swift | 3125 +++- .../Generated/JavaScript/BridgeJS.json | 15256 +++++++++------- .../JavaScript/ClosureSupportTests.mjs | 7 +- .../NoncopyableJSClassSupportTests.mjs | 473 + .../NoncopyableJSClassSupportTests.swift | 613 + Tests/prelude.mjs | 2 + 76 files changed, 22476 insertions(+), 6535 deletions(-) create mode 100644 Benchmarks/Sources/ImportedObjectBenchmarks.swift create mode 100644 Benchmarks/Sources/NoncopyableImportedObjectBenchmarks.swift create mode 100644 Plugins/BridgeJS/Sources/BridgeJSCore/AvailabilityIndex.swift create mode 100644 Plugins/BridgeJS/Sources/BridgeJSMacros/JSGetterFunctionMacro.swift create mode 100644 Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/fixtures/Noncopyable/Warnings.d.ts create mode 100644 Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/fixtures/Noncopyable/WrapperArrays.d.ts create mode 100644 Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/fixtures/Noncopyable/Wrappers.d.ts create mode 100644 Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSGetterFunctionMacroTests.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/AvailabilityIndexTests.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/Availability.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/NoncopyableJSClass.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/ProtocolConditionalCompilation.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/NoncopyableJSClassDiagnosticsTests.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Availability.json create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Availability.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/NoncopyableJSClass.json create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/NoncopyableJSClass.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ProtocolConditionalCompilation.json create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ProtocolConditionalCompilation.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Availability.d.ts create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Availability.js create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NoncopyableJSClass.d.ts create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NoncopyableJSClass.js create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolConditionalCompilation.d.ts create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolConditionalCompilation.js create mode 100644 Sources/JavaScriptKit/FundamentalObjects/JSUniqueRef.swift create mode 100644 Tests/BridgeJSRuntimeTests/JavaScript/NoncopyableJSClassSupportTests.mjs create mode 100644 Tests/BridgeJSRuntimeTests/NoncopyableJSClassSupportTests.swift diff --git a/Benchmarks/README.md b/Benchmarks/README.md index 3d1a1cf22..42d45e229 100644 --- a/Benchmarks/README.md +++ b/Benchmarks/README.md @@ -52,3 +52,11 @@ node --expose-gc run.js --filter=Identity/none | `churnObjects` | Create, roundtrip, release cycle (FinalizationRegistry cleanup pressure) | | `swiftConsumesSameObject` | JS passes same object to Swift repeatedly | | `swiftCreatesObject` | Fresh object creation overhead (cache miss path) | + +## Imported Object Benchmarks + +`Imported object/copyable/...` and `Imported object/noncopyable/...` run the same loops through a copyable `@JSClass` wrapper and a `~Copyable` one. The `convert` rows build each wrapper from a `JSObject` with `init(unsafelyWrapping:)`. + +```bash +node --expose-gc run.js --filter='Imported object/' +``` diff --git a/Benchmarks/Sources/Benchmarks.swift b/Benchmarks/Sources/Benchmarks.swift index 3e24e597b..b3d0c1554 100644 --- a/Benchmarks/Sources/Benchmarks.swift +++ b/Benchmarks/Sources/Benchmarks.swift @@ -489,6 +489,8 @@ class IdentityCacheBenchmarkIdentity { } @JS func run() { + runImportedObjectBenchmarks() + runNoncopyableImportedObjectBenchmarks() let call = Benchmark("Call") diff --git a/Benchmarks/Sources/Generated/BridgeJS.swift b/Benchmarks/Sources/Generated/BridgeJS.swift index fc46623f2..b20c5ec0f 100644 --- a/Benchmarks/Sources/Generated/BridgeJS.swift +++ b/Benchmarks/Sources/Generated/BridgeJS.swift @@ -2449,6 +2449,218 @@ func _$benchmarkRunner(_ name: String, _ body: JSObject) throws(JSException) -> } } +#if arch(wasm32) +@_extern(wasm, module: "Benchmarks", name: "bjs_ImportedObject_init") +fileprivate func bjs_ImportedObject_init_extern(_ start: Int32) -> Int32 +#else +fileprivate func bjs_ImportedObject_init_extern(_ start: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ImportedObject_init(_ start: Int32) -> Int32 { + return bjs_ImportedObject_init_extern(start) +} + +#if arch(wasm32) +@_extern(wasm, module: "Benchmarks", name: "bjs_ImportedObject_value") +fileprivate func bjs_ImportedObject_value_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_ImportedObject_value_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ImportedObject_value(_ self: Int32) -> Int32 { + return bjs_ImportedObject_value_extern(self) +} + +func _$ImportedObject_init(_ start: Int) throws(JSException) -> JSObject { + let startValue = start.bridgeJSLowerParameter() + let ret = bjs_ImportedObject_init(startValue) + if let error = _swift_js_take_exception() { + throw error + } + return JSObject.bridgeJSLiftReturn(ret) +} + +func _$ImportedObject_value(_ self: JSObject) throws(JSException) -> Int { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_ImportedObject_value(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "Benchmarks", name: "bjs_ImportedObjectRoundtrip_init") +fileprivate func bjs_ImportedObjectRoundtrip_init_extern() -> Int32 +#else +fileprivate func bjs_ImportedObjectRoundtrip_init_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ImportedObjectRoundtrip_init() -> Int32 { + return bjs_ImportedObjectRoundtrip_init_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "Benchmarks", name: "bjs_ImportedObjectRoundtrip_make") +fileprivate func bjs_ImportedObjectRoundtrip_make_extern(_ self: Int32, _ start: Int32) -> Int32 +#else +fileprivate func bjs_ImportedObjectRoundtrip_make_extern(_ self: Int32, _ start: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ImportedObjectRoundtrip_make(_ self: Int32, _ start: Int32) -> Int32 { + return bjs_ImportedObjectRoundtrip_make_extern(self, start) +} + +#if arch(wasm32) +@_extern(wasm, module: "Benchmarks", name: "bjs_ImportedObjectRoundtrip_take") +fileprivate func bjs_ImportedObjectRoundtrip_take_extern(_ self: Int32, _ object: Int32) -> Int32 +#else +fileprivate func bjs_ImportedObjectRoundtrip_take_extern(_ self: Int32, _ object: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ImportedObjectRoundtrip_take(_ self: Int32, _ object: Int32) -> Int32 { + return bjs_ImportedObjectRoundtrip_take_extern(self, object) +} + +func _$ImportedObjectRoundtrip_init() throws(JSException) -> JSObject { + let ret = bjs_ImportedObjectRoundtrip_init() + if let error = _swift_js_take_exception() { + throw error + } + return JSObject.bridgeJSLiftReturn(ret) +} + +func _$ImportedObjectRoundtrip_make(_ self: JSObject, _ start: Int) throws(JSException) -> ImportedObject { + let startValue = start.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_ImportedObjectRoundtrip_make(selfValue, startValue) + if let error = _swift_js_take_exception() { + throw error + } + return ImportedObject.bridgeJSLiftReturn(ret) +} + +func _$ImportedObjectRoundtrip_take(_ self: JSObject, _ object: ImportedObject) throws(JSException) -> Int { + let objectValue = object.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_ImportedObjectRoundtrip_take(selfValue, objectValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "Benchmarks", name: "bjs_NoncopyableImportedObject_init") +fileprivate func bjs_NoncopyableImportedObject_init_extern(_ start: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableImportedObject_init_extern(_ start: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableImportedObject_init(_ start: Int32) -> Int32 { + return bjs_NoncopyableImportedObject_init_extern(start) +} + +#if arch(wasm32) +@_extern(wasm, module: "Benchmarks", name: "bjs_NoncopyableImportedObject_value") +fileprivate func bjs_NoncopyableImportedObject_value_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableImportedObject_value_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableImportedObject_value(_ self: Int32) -> Int32 { + return bjs_NoncopyableImportedObject_value_extern(self) +} + +func _$NoncopyableImportedObject_init(_ start: Int) throws(JSException) -> JSUniqueRef { + let startValue = start.bridgeJSLowerParameter() + let ret = bjs_NoncopyableImportedObject_init(startValue) + if let error = _swift_js_take_exception() { + throw error + } + return JSUniqueRef.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableImportedObject_value(_ self: borrowing JSUniqueRef) throws(JSException) -> Int { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableImportedObject_value(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "Benchmarks", name: "bjs_NoncopyableImportedObjectRoundtrip_init") +fileprivate func bjs_NoncopyableImportedObjectRoundtrip_init_extern() -> Int32 +#else +fileprivate func bjs_NoncopyableImportedObjectRoundtrip_init_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableImportedObjectRoundtrip_init() -> Int32 { + return bjs_NoncopyableImportedObjectRoundtrip_init_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "Benchmarks", name: "bjs_NoncopyableImportedObjectRoundtrip_make") +fileprivate func bjs_NoncopyableImportedObjectRoundtrip_make_extern(_ self: Int32, _ start: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableImportedObjectRoundtrip_make_extern(_ self: Int32, _ start: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableImportedObjectRoundtrip_make(_ self: Int32, _ start: Int32) -> Int32 { + return bjs_NoncopyableImportedObjectRoundtrip_make_extern(self, start) +} + +#if arch(wasm32) +@_extern(wasm, module: "Benchmarks", name: "bjs_NoncopyableImportedObjectRoundtrip_take") +fileprivate func bjs_NoncopyableImportedObjectRoundtrip_take_extern(_ self: Int32, _ object: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableImportedObjectRoundtrip_take_extern(_ self: Int32, _ object: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableImportedObjectRoundtrip_take(_ self: Int32, _ object: Int32) -> Int32 { + return bjs_NoncopyableImportedObjectRoundtrip_take_extern(self, object) +} + +func _$NoncopyableImportedObjectRoundtrip_init() throws(JSException) -> JSUniqueRef { + let ret = bjs_NoncopyableImportedObjectRoundtrip_init() + if let error = _swift_js_take_exception() { + throw error + } + return JSUniqueRef.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableImportedObjectRoundtrip_make(_ self: borrowing JSUniqueRef, _ start: Int) throws(JSException) -> NoncopyableImportedObject { + let startValue = start.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableImportedObjectRoundtrip_make(selfValue, startValue) + if let error = _swift_js_take_exception() { + throw error + } + return NoncopyableImportedObject.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableImportedObjectRoundtrip_take(_ self: borrowing JSUniqueRef, _ object: borrowing NoncopyableImportedObject) throws(JSException) -> Int { + let objectValue = object.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableImportedObjectRoundtrip_take(selfValue, objectValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + #if arch(wasm32) @_extern(wasm, module: "bjs", name: "bjs_Benchmarks_register_type_handles") fileprivate func _bjs_Benchmarks_register_type_handles_extern(_ base: UnsafePointer?, _ count: Int32) diff --git a/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json b/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json index 124e817ba..d9ee29d3c 100644 --- a/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json +++ b/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json @@ -3418,6 +3418,274 @@ "types" : [ ] + }, + { + "functions" : [ + + ], + "types" : [ + { + "accessLevel" : "internal", + "constructor" : { + "accessLevel" : "internal", + "parameters" : [ + { + "name" : "start", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "getters" : [ + + ], + "methods" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "value", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "ImportedObject", + "setters" : [ + + ], + "staticMethods" : [ + + ] + }, + { + "accessLevel" : "internal", + "constructor" : { + "accessLevel" : "internal", + "parameters" : [ + + ] + }, + "getters" : [ + + ], + "methods" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "make", + "parameters" : [ + { + "name" : "start", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "jsObject" : { + "_0" : "ImportedObject" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "take", + "parameters" : [ + { + "name" : "object", + "type" : { + "jsObject" : { + "_0" : "ImportedObject" + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "ImportedObjectRoundtrip", + "setters" : [ + + ], + "staticMethods" : [ + + ] + } + ] + }, + { + "functions" : [ + + ], + "types" : [ + { + "accessLevel" : "internal", + "constructor" : { + "accessLevel" : "internal", + "parameters" : [ + { + "name" : "start", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "getters" : [ + + ], + "isNoncopyable" : true, + "methods" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "value", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "NoncopyableImportedObject", + "setters" : [ + + ], + "staticMethods" : [ + + ] + }, + { + "accessLevel" : "internal", + "constructor" : { + "accessLevel" : "internal", + "parameters" : [ + + ] + }, + "getters" : [ + + ], + "isNoncopyable" : true, + "methods" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "make", + "parameters" : [ + { + "name" : "start", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "jsUniqueObject" : { + "_0" : "NoncopyableImportedObject" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "take", + "parameters" : [ + { + "name" : "object", + "type" : { + "jsUniqueObject" : { + "_0" : "NoncopyableImportedObject" + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "NoncopyableImportedObjectRoundtrip", + "setters" : [ + + ], + "staticMethods" : [ + + ] + } + ] } ] }, diff --git a/Benchmarks/Sources/ImportedObjectBenchmarks.swift b/Benchmarks/Sources/ImportedObjectBenchmarks.swift new file mode 100644 index 000000000..c9d44e418 --- /dev/null +++ b/Benchmarks/Sources/ImportedObjectBenchmarks.swift @@ -0,0 +1,62 @@ +import JavaScriptKit + +@JSClass struct ImportedObject { + @JSFunction init(_ start: Int) throws(JSException) + @JSFunction func value() throws(JSException) -> Int +} + +@JSClass struct ImportedObjectRoundtrip { + @JSFunction init() throws(JSException) + @JSFunction func make(_ start: Int) throws(JSException) -> ImportedObject + @JSFunction func take(_ object: ImportedObject) throws(JSException) -> Int +} + +func runImportedObjectBenchmarks() { + let suite = Benchmark("Imported object") + suite.testSuite("copyable/create and drop") { + for i in 0..<100_000 { + _ = try! ImportedObject(i) + } + } + suite.testSuite("copyable/create, call and drop") { + for i in 0..<100_000 { + _ = try! ImportedObject(i).value() + } + } + suite.testSuite("copyable/return and drop") { + let roundtrip = try! ImportedObjectRoundtrip() + for i in 0..<100_000 { + _ = try! roundtrip.make(i) + } + } + suite.testSuite("copyable/pass") { + let roundtrip = try! ImportedObjectRoundtrip() + let object = try! roundtrip.make(1) + for _ in 0..<100_000 { + _ = try! roundtrip.take(object) + } + } + suite.testSuite("copyable/return and pass") { + let roundtrip = try! ImportedObjectRoundtrip() + for i in 0..<100_000 { + _ = try! roundtrip.take(roundtrip.make(i)) + } + } + suite.testSuite("copyable/convert and drop") { + let object = try! ImportedObject(1).jsObject + for _ in 0..<100_000 { + _ = ImportedObject(unsafelyWrapping: object) + } + } + suite.testSuite("copyable/convert, call and drop") { + let object = try! ImportedObject(1).jsObject + for _ in 0..<100_000 { + _ = try! ImportedObject(unsafelyWrapping: object).value() + } + } + suite.testSuite("copyable/create object, convert and drop") { + for _ in 0..<100_000 { + _ = ImportedObject(unsafelyWrapping: JSObject()) + } + } +} diff --git a/Benchmarks/Sources/NoncopyableImportedObjectBenchmarks.swift b/Benchmarks/Sources/NoncopyableImportedObjectBenchmarks.swift new file mode 100644 index 000000000..5666c2337 --- /dev/null +++ b/Benchmarks/Sources/NoncopyableImportedObjectBenchmarks.swift @@ -0,0 +1,62 @@ +import JavaScriptKit + +@JSClass struct NoncopyableImportedObject: ~Copyable { + @JSFunction init(_ start: Int) throws(JSException) + @JSFunction func value() throws(JSException) -> Int +} + +@JSClass struct NoncopyableImportedObjectRoundtrip: ~Copyable { + @JSFunction init() throws(JSException) + @JSFunction func make(_ start: Int) throws(JSException) -> NoncopyableImportedObject + @JSFunction func take(_ object: borrowing NoncopyableImportedObject) throws(JSException) -> Int +} + +func runNoncopyableImportedObjectBenchmarks() { + let suite = Benchmark("Imported object") + suite.testSuite("noncopyable/create and drop") { + for i in 0..<100_000 { + _ = try! NoncopyableImportedObject(i) + } + } + suite.testSuite("noncopyable/create, call and drop") { + for i in 0..<100_000 { + _ = try! NoncopyableImportedObject(i).value() + } + } + suite.testSuite("noncopyable/return and drop") { + let roundtrip = try! NoncopyableImportedObjectRoundtrip() + for i in 0..<100_000 { + _ = try! roundtrip.make(i) + } + } + suite.testSuite("noncopyable/pass") { + let roundtrip = try! NoncopyableImportedObjectRoundtrip() + let object = try! roundtrip.make(1) + for _ in 0..<100_000 { + _ = try! roundtrip.take(object) + } + } + suite.testSuite("noncopyable/return and pass") { + let roundtrip = try! NoncopyableImportedObjectRoundtrip() + for i in 0..<100_000 { + _ = try! roundtrip.take(roundtrip.make(i)) + } + } + suite.testSuite("noncopyable/convert and drop") { + let object = try! ImportedObject(1).jsObject + for _ in 0..<100_000 { + _ = NoncopyableImportedObject(unsafelyWrapping: object) + } + } + suite.testSuite("noncopyable/convert, call and drop") { + let object = try! ImportedObject(1).jsObject + for _ in 0..<100_000 { + _ = try! NoncopyableImportedObject(unsafelyWrapping: object).value() + } + } + suite.testSuite("noncopyable/create object, convert and drop") { + for _ in 0..<100_000 { + _ = NoncopyableImportedObject(unsafelyWrapping: JSObject()) + } + } +} diff --git a/Benchmarks/run.js b/Benchmarks/run.js index 444a33be0..e8cac132f 100644 --- a/Benchmarks/run.js +++ b/Benchmarks/run.js @@ -5,6 +5,15 @@ import path from 'path'; import { parseArgs } from "util"; import { APIResultValues as APIResult, ComplexResultValues as ComplexResult } from "./.build/plugins/PackageToJS/outputs/Package/bridge-js.js"; +class ImportedObject { + constructor(start) { this.start = start; } + value() { return this.start; } +} +class ImportedObjectRoundtrip { + make(start) { return new ImportedObject(start); } + take(object) { return object.value(); } +} + /** * Update progress bar on the current line * @param {number} current - Current progress @@ -300,7 +309,11 @@ async function singleRun(results, nameFilter, iterations) { getImports: () => ({ benchmarkHelperNoop: () => { }, benchmarkHelperNoopWithNumber: (n) => { }, - benchmarkRunner: benchmarkRunner + benchmarkRunner: benchmarkRunner, + ImportedObject, + ImportedObjectRoundtrip, + NoncopyableImportedObject: ImportedObject, + NoncopyableImportedObjectRoundtrip: ImportedObjectRoundtrip, }) }); exports.run(); diff --git a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/main.swift b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/main.swift index 3a4063945..b46cf6946 100644 --- a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/main.swift +++ b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/main.swift @@ -62,12 +62,18 @@ import class Foundation.JSONDecoder let skeleton = try swiftToSkeleton.finalize() + let availability = AvailabilityIndex(skeletons: [skeleton]) let exportResult = try skeleton.exported.flatMap { - let exportSwift = ExportSwift(progress: .silent, moduleName: moduleName, skeleton: $0) + let exportSwift = ExportSwift( + progress: .silent, + moduleName: moduleName, + skeleton: $0, + availability: availability + ) return try exportSwift.finalize() } let importResult = try skeleton.imported.flatMap { - let importTS = ImportTS(progress: .silent, moduleName: moduleName, skeleton: $0) + let importTS = ImportTS(progress: .silent, moduleName: moduleName, skeleton: $0, availability: availability) return try importTS.finalize() } let linker = BridgeJSLink(skeletons: [skeleton]) diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/AvailabilityIndex.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/AvailabilityIndex.swift new file mode 100644 index 000000000..e59bfe7f4 --- /dev/null +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/AvailabilityIndex.swift @@ -0,0 +1,70 @@ +#if canImport(BridgeJSSkeleton) +import BridgeJSSkeleton +#endif + +/// The `@available` attributes of the `@JS` and `@JSClass` types of a module and its dependencies. +public struct AvailabilityIndex { + public static var empty: AvailabilityIndex { AvailabilityIndex(skeletons: []) } + + private static let uniqueArrayAvailability = "@available(anyAppleOS 27.0, *)" + + private var attributesByTypeName: [String: [String]] = [:] + + /// Indexes the types of `skeletons`; a type name that several of them declare keeps the first one's attributes. + public init(skeletons: [BridgeJSSkeleton]) { + func register(_ name: String, _ availability: [String]?) { + guard let availability, attributesByTypeName[name] == nil else { return } + attributesByTypeName[name] = availability + } + for skeleton in skeletons { + if let exported = skeleton.exported { + for klass in exported.classes { register(klass.swiftCallName, klass.availability) } + for structDef in exported.structs { register(structDef.swiftCallName, structDef.availability) } + for enumDef in exported.enums { register(enumDef.swiftCallName, enumDef.availability) } + for proto in exported.protocols { register(proto.name, proto.availability) } + for alias in exported.aliases { register(alias.swiftCallName, alias.availability) } + } + for file in skeleton.imported?.children ?? [] { + for type in file.types { register(type.name, type.availability) } + } + } + } + + /// The attributes a generated declaration needs when it names `types`. + func attributes(for types: [BridgeType]) -> [String] { + var attributes: [String] = [] + func add(_ name: String) { + for attribute in attributesByTypeName[name] ?? [] where !attributes.contains(attribute) { + attributes.append(attribute) + } + } + func visit(_ type: BridgeType) { + switch type { + case .swiftHeapObject(let name), .swiftStruct(let name), .swiftProtocol(let name), .caseEnum(let name), + .rawValueEnum(let name, _), .associatedValueEnum(let name), .namespaceEnum(let name), + .jsObject(let name?), .jsUniqueObject(let name?): + add(name) + case .alias(let name, let underlying): + add(name) + visit(underlying) + case .array(let element): + if element.isNoncopyable, !attributes.contains(Self.uniqueArrayAvailability) { + attributes.append(Self.uniqueArrayAvailability) + } + visit(element) + case .nullable(let wrapped, _): + visit(wrapped) + case .dictionary(let value): + visit(value) + case .closure(let signature, _): + signature.parameters.forEach(visit) + visit(signature.returnType) + case .integer, .float, .double, .string, .bool, .jsObject(nil), .jsValue, .void, .jsUniqueObject(nil), + .unsafePointer, .generic: + break + } + } + types.forEach(visit) + return attributes + } +} diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ClosureCodegen.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ClosureCodegen.swift index 7459d6058..1debe22d0 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ClosureCodegen.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ClosureCodegen.swift @@ -9,11 +9,16 @@ import BridgeJSUtilities #endif public struct ClosureCodegen { - public init() {} + private let availability: AvailabilityIndex + + public init(availability: AvailabilityIndex) { + self.availability = availability + } private func swiftClosureType(for signature: ClosureSignature) -> String { - let sendingPrefix = signature.sendingParameters ? "sending " : "" - let closureParams = signature.parameters.map { "\(sendingPrefix)\($0.closureSwiftType)" }.joined( + let closureParams = signature.parameters.map { + "\($0.closureParameterPrefix(sending: signature.sendingParameters))\($0.closureSwiftType)" + }.joined( separator: ", " ) let swiftEffects = (signature.isAsync ? " async" : "") + (signature.isThrows ? " throws(JSException)" : "") @@ -74,10 +79,10 @@ public struct ClosureCodegen { helperEnumDeclPrinter.write("let callback = JSObject.bridgeJSLiftParameter(callbackId)") let parameters: String if signature.isThrows || signature.isAsync { - let sendingPrefix = signature.sendingParameters ? "sending " : "" let typedParams = signature.parameters.enumerated().map { index, paramType in - "param\(index): \(sendingPrefix)\(paramType.closureSwiftType)" + let prefix = paramType.closureParameterPrefix(sending: signature.sendingParameters) + return "param\(index): \(prefix)\(paramType.closureSwiftType)" }.joined(separator: ", ") let returnType = signature.returnType.closureSwiftType let effects = @@ -129,9 +134,16 @@ public struct ClosureCodegen { } """ - return [ - externDecl, makeClosureExternDecl, helperEnumDecl, typedClosureExtension, + let helperAvailability = availability.attributes(for: signature.parameters + [signature.returnType]) + let decls: [(DeclSyntax, availability: [String])] = [ + (makeClosureExternDecl, []), + (helperEnumDecl, helperAvailability), + (typedClosureExtension, helperAvailability), ] + return [externDecl] + + decls.map { + SwiftCodePattern.buildAvailableDecl($0, usesUniqueArray: builder.usesUniqueArray, availability: $1) + } } func renderClosureInvokeHandler(_ signature: ClosureSignature) throws -> DeclSyntax { diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift index 3197f559c..bb8f7e9d6 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift @@ -22,13 +22,20 @@ public class ExportSwift { let moduleName: String private let exposeToGlobal: Bool private var skeleton: ExportedSkeleton + private let availability: AvailabilityIndex private var sourceFiles: [(sourceFile: SourceFileSyntax, inputFilePath: String)] = [] - public init(progress: ProgressReporting, moduleName: String, skeleton: ExportedSkeleton) { + public init( + progress: ProgressReporting, + moduleName: String, + skeleton: ExportedSkeleton, + availability: AvailabilityIndex + ) { self.progress = progress self.moduleName = moduleName self.exposeToGlobal = skeleton.exposeToGlobal self.skeleton = skeleton + self.availability = availability } /// Finalizes the export process and generates the bridge code @@ -48,7 +55,7 @@ public class ExportSwift { var decls: [DeclSyntax] = [] try withSpan("Render Protocols") { [self] in - let protocolCodegen = ProtocolCodegen() + let protocolCodegen = ProtocolCodegen(availability: availability) for proto in skeleton.protocols { decls.append(contentsOf: try protocolCodegen.renderProtocolWrapper(proto, moduleName: moduleName)) } @@ -94,7 +101,12 @@ public class ExportSwift { withSpan("Render Generic Bridgeable Conformances") { [self] in let genericConformanceCodegen = GenericConformanceCodegen() for entry in skeleton.genericBridgeableTypeEntries { - decls.append(contentsOf: genericConformanceCodegen.renderConformance(typeName: entry.swiftName)) + decls.append( + contentsOf: genericConformanceCodegen.renderConformance( + typeName: entry.swiftName, + availability: availability.attributes(for: [entry.bridgeType]) + ) + ) } } @@ -165,14 +177,20 @@ public class ExportSwift { try builder.call() try builder.liftReturnValue() - let valueParam = valueType == .void ? "" : ", _ value: \(valueType.swiftType)" - let macroDecl: DeclSyntax = - "@JSFunction func \(raw: functionName)(_ promise: JSObject\(raw: valueParam)) throws(JSException)" + let valueParam = + valueType == .void + ? "" : ", _ value: \(valueType.closureParameterPrefix(sending: false))\(valueType.swiftType)" + let macroDecl = SwiftCodePattern.buildAvailableDecl( + "@JSFunction func \(raw: functionName)(_ promise: JSObject\(raw: valueParam)) throws(JSException)", + usesUniqueArray: builder.usesUniqueArray, + availability: availability.attributes(for: [valueType]) + ) let glueDecl = builder.renderThunkDecl( name: "_$\(functionName)", parameters: parameters, returnType: .void, - effects: effects + effects: effects, + availability: availability ) return [macroDecl, builder.renderImportDecl(), glueDecl] } @@ -184,6 +202,7 @@ public class ExportSwift { var abiReturnType: WasmCoreType? var externDecls: [DeclSyntax] = [] let effects: Effects + private(set) var usesUniqueArray: Bool /// The async return type settled through `_bjs_makePromise`'s `Promise_resolve_` /// helper. Set for every `async` thunk. @@ -193,6 +212,7 @@ public class ExportSwift { init(effects: Effects, returnType: BridgeType) throws { self.effects = effects + self.usesUniqueArray = returnType.usesUniqueArray guard effects.isAsync else { return } guard returnType.isAsyncResolvable else { throw BridgeJSCoreError( @@ -212,6 +232,7 @@ public class ExportSwift { } func liftParameter(param: Parameter) throws { + usesUniqueArray = usesUniqueArray || param.type.usesUniqueArray parameters.append(param) let escapedName = param.escapedSwiftIdentifier let liftingInfo = try param.type.liftParameterInfo() @@ -319,12 +340,19 @@ public class ExportSwift { func callStaticProperty(name: String, returnType: BridgeType) { if returnType == .void { append("\(raw: name)") + } else if let retained = Self.retainingNoncopyableRead(of: name, type: returnType) { + append("let ret = \(raw: retained)") } else { let (prefix, suffix) = protocolCastSuffix(for: returnType) append("let ret = \(raw: prefix)\(raw: name)\(raw: suffix)") } } + private static func retainingNoncopyableRead(of expression: String, type: BridgeType) -> String? { + guard type.isNoncopyable else { return nil } + return "\(type.swiftType).bridgeJSRetaining(\(expression))" + } + func callMethod(methodName: String, returnType: BridgeType) { let selfExpr = removeFirstLiftedParameter() let item = renderCallStatement( @@ -338,6 +366,11 @@ public class ExportSwift { let selfExpr = removeFirstLiftedParameter() if returnType == .void { append("\(raw: selfExpr).\(raw: propertyName)") + } else if let retained = Self.retainingNoncopyableRead( + of: "\(selfExpr).\(propertyName)", + type: returnType + ) { + append("let ret = \(raw: retained)") } else { let (prefix, suffix) = protocolCastSuffix(for: returnType) append("let ret = \(raw: prefix)\(raw: selfExpr).\(raw: propertyName)\(raw: suffix)") @@ -487,7 +520,11 @@ public class ExportSwift { printer.write(multilineString: preparedBody.description) } - return DeclSyntax(funcDecl) + return SwiftCodePattern.buildAvailableDecl( + funcDecl, + usesUniqueArray: usesUniqueArray, + availability: [] + ) } private func returnPlaceholderStmt() -> String { @@ -845,15 +882,23 @@ public class ExportSwift { returnType: .i32 ) let externDecl: DeclSyntax = "\(raw: externDeclPrinter.lines.joined(separator: "\n"))" - return [extensionDecl, externDecl] + return [ + SwiftCodePattern.buildAvailableDecl( + extensionDecl, + usesUniqueArray: false, + availability: klass.availability ?? [] + ), + externDecl, + ] } } // MARK: - GenericConformanceCodegen struct GenericConformanceCodegen { - func renderConformance(typeName: String) -> [DeclSyntax] { + func renderConformance(typeName: String, availability: [String]) -> [DeclSyntax] { let printer = CodeFragmentPrinter() + printer.write(lines: availability) printer.write("extension \(typeName): BridgedSwiftGenericBridgeable {") printer.indent { printer.write( @@ -915,6 +960,8 @@ struct StackCodegen { return "\(raw: type.swiftType).bridgeJSStackPop()" case .jsObject(let className?): return "\(raw: className)(unsafelyWrapping: JSObject.bridgeJSStackPop())" + case .jsUniqueObject: + fatalError("Noncopyable @JSClass wrappers are not supported in the stack ABI") case .nullable(let wrappedType, let kind): return liftNullableExpression(wrappedType: wrappedType, kind: kind) case .closure: @@ -937,7 +984,7 @@ struct StackCodegen { 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, .generic: + case .nullable, .void, .namespaceEnum, .closure, .unsafePointer, .swiftProtocol, .generic, .jsUniqueObject: fatalError("Invalid nullable wrapped type: \(wrappedType)") } } @@ -960,6 +1007,8 @@ struct StackCodegen { return ["\(raw: accessor).bridgeJSStackPush()"] case .jsObject(_?): return ["\(raw: accessor).jsObject.bridgeJSStackPush()"] + case .jsUniqueObject: + fatalError("Noncopyable @JSClass wrappers are not supported in the stack ABI") case .swiftProtocol(let protocolName): return [ "_swift_js_push_i32(_bridgeJSUnwrapProtocolExportable(\(raw: accessor), \"\(raw: protocolName)\").bridgeJSLowerAsProtocolReturn())" @@ -1102,16 +1151,22 @@ struct EnumCodegen { private let stackCodegen = StackCodegen() func renderEnumHelpers(_ enumDef: ExportedEnum) -> DeclSyntax? { + let helpers: DeclSyntax switch enumDef.enumType { case .simple: - return renderCaseEnumHelpers(enumDef) + helpers = renderCaseEnumHelpers(enumDef) case .rawValue: - return renderRawValueEnumHelpers(enumDef) + helpers = renderRawValueEnumHelpers(enumDef) case .associatedValue: - return renderAssociatedValueEnumHelpers(enumDef) + helpers = renderAssociatedValueEnumHelpers(enumDef) case .namespace: return nil } + return SwiftCodePattern.buildAvailableDecl( + helpers, + usesUniqueArray: false, + availability: enumDef.availability ?? [] + ) } private func renderCaseEnumHelpers(_ enumDef: ExportedEnum) -> DeclSyntax { @@ -1300,6 +1355,7 @@ struct StructCodegen { let liftFunctionName = "_bjs_struct_lift_\(structDef.abiName)" let printer = CodeFragmentPrinter() + printer.write(lines: structDef.availability ?? []) printer.write("extension \(typeName): _BridgedSwiftStruct {") printer.indent { printer.write("@_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> \(typeName) {") @@ -1409,13 +1465,19 @@ struct AliasCodegen { return nil } let conformances = (["_BridgedSwiftAlias"] + protocols).joined(separator: ", ") - return "extension \(raw: alias.swiftCallName): \(raw: conformances) {}" + return SwiftCodePattern.buildAvailableDecl( + "extension \(raw: alias.swiftCallName): \(raw: conformances) {}", + usesUniqueArray: false, + availability: alias.availability ?? [] + ) } } // MARK: - ProtocolCodegen struct ProtocolCodegen { + let availability: AvailabilityIndex + func renderProtocolWrapper(_ proto: ExportedProtocol, moduleName: String) throws -> [DeclSyntax] { let wrapperName = "Any\(proto.name)" let protocolName = proto.name @@ -1445,23 +1507,19 @@ struct ProtocolCodegen { effects: method.effects ) - // Build extern declaration using helper function - let externDeclPrinter = CodeFragmentPrinter() - SwiftCodePattern.buildExternFunctionDecl( - printer: externDeclPrinter, - moduleName: moduleName, - abiName: method.abiName, - functionName: method.abiName, - abiParameters: builder.abiParameterSignatures, - returnType: builder.abiReturnType - ) - externDecls.append(DeclSyntax("\(raw: externDeclPrinter.lines.joined(separator: "\n"))")) + externDecls.append(builder.renderImportDecl()) let methodImplPrinter = CodeFragmentPrinter() - methodImplPrinter.write("func \(method.name)\(signature) {") - methodImplPrinter.indent { - methodImplPrinter.write(lines: builder.body.lines) + SwiftCodePattern.buildAvailableDecl( + printer: methodImplPrinter, + usesUniqueArray: builder.usesUniqueArray, + availability: availability.attributes(for: method.parameters.map(\.type) + [method.returnType]) + ) { printer in + printer.write("func \(method.name)\(signature) {") + printer.indent { + printer.write(lines: builder.body.lines) + } + printer.write("}") } - methodImplPrinter.write("}") methodDecls.append(methodImplPrinter) } @@ -1482,6 +1540,7 @@ struct ProtocolCodegen { var decls: [DeclSyntax] = [] if !methodDecls.isEmpty || !propertyDecls.isEmpty { let extensionPrinter = CodeFragmentPrinter() + extensionPrinter.write(lines: proto.availability ?? []) extensionPrinter.write("extension \(protocolName) where Self: _BridgedSwiftProtocolWrapper {") extensionPrinter.indent { var first = true @@ -1537,60 +1596,43 @@ struct ProtocolCodegen { try getterBuilder.call() try getterBuilder.liftReturnValue() - // Build getter extern declaration using helper function - let getterExternDeclPrinter = CodeFragmentPrinter() - SwiftCodePattern.buildExternFunctionDecl( - printer: getterExternDeclPrinter, - moduleName: moduleName, - abiName: getterAbiName, - functionName: getterAbiName, - abiParameters: getterBuilder.abiParameterSignatures, - returnType: getterBuilder.abiReturnType - ) - let getterExternDecl = DeclSyntax("\(raw: getterExternDeclPrinter.lines.joined(separator: "\n"))") - var externDecls: [DeclSyntax] = [getterExternDecl] + var externDecls: [DeclSyntax] = [getterBuilder.renderImportDecl()] - printer.write("var \(property.name): \(property.type.swiftType) {") - try printer.indent { - printer.write("get {") - printer.indent { - printer.write(lines: getterBuilder.body.lines) - } - printer.write("}") + try SwiftCodePattern.buildAvailableDecl( + printer: printer, + usesUniqueArray: getterBuilder.usesUniqueArray, + availability: availability.attributes(for: [property.type]) + ) { printer in + printer.write("var \(property.name): \(property.type.swiftType) {") + try printer.indent { + printer.write("get {") + printer.indent { + printer.write(lines: getterBuilder.body.lines) + } + printer.write("}") - if property.isReadonly { return } + if property.isReadonly { return } - let setterBuilder = try ImportTS.CallJSEmission( - moduleName: moduleName, - abiName: setterAbiName, - effects: Effects(isAsync: false, isThrows: false), - returnType: .void, - context: .exportSwift - ) - try setterBuilder.lowerParameter(param: Parameter(label: nil, name: "jsObject", type: .jsObject(nil))) - try setterBuilder.lowerParameter(param: Parameter(label: nil, name: "newValue", type: property.type)) - try setterBuilder.call() - - // Build setter extern declaration using helper function - let setterExternDeclPrinter = CodeFragmentPrinter() - SwiftCodePattern.buildExternFunctionDecl( - printer: setterExternDeclPrinter, - moduleName: moduleName, - abiName: setterAbiName, - functionName: setterAbiName, - abiParameters: setterBuilder.abiParameterSignatures, - returnType: setterBuilder.abiReturnType - ) - let setterExternDecl = DeclSyntax("\(raw: setterExternDeclPrinter.lines.joined(separator: "\n"))") - externDecls.append(setterExternDecl) + let setterBuilder = try ImportTS.CallJSEmission( + moduleName: moduleName, + abiName: setterAbiName, + effects: Effects(isAsync: false, isThrows: false), + returnType: .void, + context: .exportSwift + ) + try setterBuilder.lowerParameter(param: Parameter(label: nil, name: "jsObject", type: .jsObject(nil))) + try setterBuilder.lowerParameter(param: Parameter(label: nil, name: "newValue", type: property.type)) + try setterBuilder.call() + externDecls.append(setterBuilder.renderImportDecl()) - printer.write("set {") - printer.indent { - printer.write(lines: setterBuilder.body.lines) + printer.write("set {") + printer.indent { + printer.write(lines: setterBuilder.body.lines) + } + printer.write("}") } printer.write("}") } - printer.write("}") return externDecls } @@ -1637,7 +1679,7 @@ extension BridgeType { case .associatedValueEnum: return ["_BridgedSwiftAssociatedValueEnum"] case .rawValueEnum, .void, .unsafePointer, .namespaceEnum, - .swiftProtocol, .closure, .nullable, .array, .dictionary, .alias, .generic: + .swiftProtocol, .closure, .nullable, .array, .dictionary, .alias, .generic, .jsUniqueObject: // Not supported yet. return nil } @@ -1675,13 +1717,16 @@ extension BridgeType { case .jsValue: return "JSValue" case .jsObject(nil): return "JSObject" case .jsObject(let name?): return name + case .jsUniqueObject(nil): return "JSUniqueRef" + case .jsUniqueObject(let name?): return name case .swiftHeapObject(let name): return name case .unsafePointer(let ptr): return ptr.swiftType case .swiftProtocol(let name): return "Any\(name)" case .void: return "Void" case .nullable(let wrappedType, let kind): return kind == .null ? "Optional<\(wrappedType.swiftType)>" : "JSUndefinedOr<\(wrappedType.swiftType)>" - case .array(let elementType): return "[\(elementType.swiftType)]" + case .array(let elementType): + return elementType.isNoncopyable ? "UniqueArray<\(elementType.swiftType)>" : "[\(elementType.swiftType)]" case .dictionary(let valueType): return "[String: \(valueType.swiftType)]" case .caseEnum(let name): return name case .rawValueEnum(let name, _): return name @@ -1689,7 +1734,9 @@ extension BridgeType { case .swiftStruct(let name): return name case .namespaceEnum(let name): return name case .closure(let signature, let useJSTypedClosure): - let paramTypes = signature.parameters.map { $0.swiftType }.joined(separator: ", ") + let paramTypes = signature.parameters.map { + "\($0.closureParameterPrefix(sending: false))\($0.swiftType)" + }.joined(separator: ", ") let effectsStr = (signature.isAsync ? " async" : "") + (signature.isThrows ? " throws" : "") let closureType = "(\(paramTypes))\(effectsStr) -> \(signature.returnType.swiftType)" return useJSTypedClosure ? "JSTypedClosure<\(closureType)>" : closureType @@ -1708,6 +1755,33 @@ extension BridgeType { } } + var isNoncopyable: Bool { + switch self { + case .jsUniqueObject: return true + case .nullable(let wrappedType, _): return wrappedType.isNoncopyable + case .array(let elementType): return elementType.isNoncopyable + default: return false + } + } + + /// Whether the Swift spelling contains `UniqueArray`, which Swift 6.3's standard library lacks. + var usesUniqueArray: Bool { + switch self { + case .array(let elementType): return elementType.isNoncopyable || elementType.usesUniqueArray + case .nullable(let wrappedType, _): return wrappedType.usesUniqueArray + case .dictionary(let valueType): return valueType.usesUniqueArray + case .alias(_, let underlying): return underlying.usesUniqueArray + case .closure(let signature, _): + return signature.parameters.contains { $0.usesUniqueArray } || signature.returnType.usesUniqueArray + default: return false + } + } + + func closureParameterPrefix(sending: Bool) -> String { + if isNoncopyable { return sending ? "consuming sending " : "borrowing " } + return sending ? "sending " : "" + } + var isClosureType: Bool { if case .closure = self { return true } return false @@ -1740,6 +1814,7 @@ extension BridgeType { case .double: return .double case .string: return .string case .jsObject: return .jsObject + case .jsUniqueObject: return .jsObject case .jsValue: return .jsValue case .swiftHeapObject: return .swiftHeapObject case .unsafePointer: return .unsafePointer @@ -1804,6 +1879,7 @@ extension BridgeType { case .double: return .double case .string: return .string case .jsObject: return .jsObject + case .jsUniqueObject: return .jsObject case .jsValue: return .jsValue case .swiftHeapObject: return .swiftHeapObject case .unsafePointer: return .unsafePointer diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift index 504b955d2..bb39d70de 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift @@ -20,11 +20,18 @@ public struct ImportTS { public let progress: ProgressReporting public private(set) var skeleton: ImportedModuleSkeleton private let moduleName: String + private let availability: AvailabilityIndex - public init(progress: ProgressReporting, moduleName: String, skeleton: ImportedModuleSkeleton) { + public init( + progress: ProgressReporting, + moduleName: String, + skeleton: ImportedModuleSkeleton, + availability: AvailabilityIndex + ) { self.progress = progress self.moduleName = moduleName self.skeleton = skeleton + self.availability = availability } /// Finalizes the import process and generates Swift code @@ -81,9 +88,10 @@ public struct ImportTS { name: "_$\(getter.name)_get", parameters: [], returnType: getter.type, - effects: effects + effects: effects, + documentation: getter.documentation, + availability: availability ) - .with(\.leadingTrivia, Self.renderDocumentation(documentation: getter.documentation)) ] } @@ -114,6 +122,7 @@ public struct ImportTS { // Closures to close borrowed parameters private var borrowedArguments: [BorrowedArgument] = [] private let needsReturnVariable: Bool + private(set) var usesUniqueArray: Bool init( moduleName: String, @@ -127,6 +136,7 @@ public struct ImportTS { self.effects = effects self.returnType = returnType self.context = context + self.usesUniqueArray = returnType.usesUniqueArray let liftingInfo = try returnType.liftingReturnInfo(context: context) if effects.isAsync || returnType == .void || returnType.usesSideChannelForOptionalReturn() || liftingInfo.valueToLift == nil @@ -143,6 +153,7 @@ public struct ImportTS { } func lowerParameter(param: Parameter) throws { + usesUniqueArray = usesUniqueArray || param.type.usesUniqueArray let escapedName = param.escapedSwiftIdentifier if let genericPush = param.type.genericStackPushStatement(value: escapedName) { stackLoweringStmts.insert(genericPush, at: 0) @@ -348,8 +359,9 @@ public struct ImportTS { ) } else { let resolveSwiftType = returnType.closureSwiftType + let resolvePrefix = returnType.closureParameterPrefix(sending: true) let resolveFactory = - "makeResolveClosure: { JSTypedClosure<(sending \(resolveSwiftType)) -> Void>.sending($0) }" + "makeResolveClosure: { JSTypedClosure<(\(resolvePrefix)\(resolveSwiftType)) -> Void>.sending($0) }" body.write( "let resolved = \(tryKeyword) await _bjs_awaitPromise(\(resolveFactory), \(rejectFactory)) { resolveRef, rejectRef in" ) @@ -366,14 +378,20 @@ public struct ImportTS { func renderImportDecl() -> DeclSyntax { let printer = CodeFragmentPrinter() - SwiftCodePattern.buildExternFunctionDecl( + SwiftCodePattern.buildAvailableDecl( printer: printer, - moduleName: moduleName, - abiName: abiName, - functionName: abiName, - abiParameters: abiParameterSignatures, - returnType: abiReturnType - ) + usesUniqueArray: usesUniqueArray, + availability: [] + ) { + SwiftCodePattern.buildExternFunctionDecl( + printer: $0, + moduleName: moduleName, + abiName: abiName, + functionName: abiName, + abiParameters: abiParameterSignatures, + returnType: abiReturnType + ) + } return "\(raw: printer.lines.joined(separator: "\n"))" } @@ -382,7 +400,9 @@ public struct ImportTS { parameters: [Parameter], returnType: BridgeType, effects: Effects, - genericParameters: [GenericParameter] = [] + genericParameters: [GenericParameter] = [], + documentation: String? = nil, + availability: AvailabilityIndex ) -> DeclSyntax { let printer = CodeFragmentPrinter() let signature = SwiftSignatureBuilder.buildFunctionSignature( @@ -407,7 +427,12 @@ public struct ImportTS { printer.write(lines: body.lines) } printer.write("}") - return "\(raw: printer.lines.joined(separator: "\n"))" + let decl: DeclSyntax = "\(raw: printer.lines.joined(separator: "\n"))" + return SwiftCodePattern.buildAvailableDecl( + decl.with(\.leadingTrivia, ImportTS.renderDocumentation(documentation: documentation)), + usesUniqueArray: usesUniqueArray, + availability: availability.attributes(for: parameters.map(\.type) + [returnType]) + ) } func renderConstructorDecl(parameters: [Parameter]) -> DeclSyntax { @@ -472,14 +497,16 @@ public struct ImportTS { parameters: function.parameters, returnType: function.returnType, effects: function.effects, - genericParameters: function.genericParameters ?? [] + genericParameters: function.genericParameters ?? [], + documentation: function.documentation, + availability: availability ) - .with(\.leadingTrivia, Self.renderDocumentation(documentation: function.documentation)) ] } func renderSwiftType(_ type: ImportedTypeSkeleton, topLevelDecls: inout [DeclSyntax]) throws -> [DeclSyntax] { - let selfParameter = Parameter(label: nil, name: "self", type: .jsObject(nil)) + let selfType: BridgeType = type.isNoncopyable == true ? .jsUniqueObject(nil) : .jsObject(nil) + let selfParameter = Parameter(label: nil, name: "self", type: selfType) var decls: [DeclSyntax] = [] func renderMethod(method: ImportedFunctionSkeleton) throws -> [DeclSyntax] { @@ -503,7 +530,8 @@ public struct ImportTS { parameters: [selfParameter] + method.parameters, returnType: method.returnType, effects: method.effects, - genericParameters: method.genericParameters ?? [] + genericParameters: method.genericParameters ?? [], + availability: availability ) ] } @@ -529,7 +557,8 @@ public struct ImportTS { parameters: method.parameters, returnType: method.returnType, effects: method.effects, - genericParameters: method.genericParameters ?? [] + genericParameters: method.genericParameters ?? [], + availability: availability ) ] } @@ -540,7 +569,7 @@ public struct ImportTS { moduleName: moduleName, abiName: constructor.abiName(context: type), effects: effects, - returnType: .jsObject(nil) + returnType: selfType ) for param in constructor.parameters { try builder.lowerParameter(param: param) @@ -553,9 +582,10 @@ public struct ImportTS { builder.renderThunkDecl( name: Self.thunkName(type: type), parameters: constructor.parameters, - returnType: .jsObject(nil), + returnType: selfType, effects: effects, - genericParameters: constructor.genericParameters ?? [] + genericParameters: constructor.genericParameters ?? [], + availability: availability ) ] } @@ -577,7 +607,8 @@ public struct ImportTS { name: Self.thunkName(type: type, propertyName: getter.name, operation: "get"), parameters: [selfParameter], returnType: getter.type, - effects: effects + effects: effects, + availability: availability ) ) } @@ -608,7 +639,8 @@ public struct ImportTS { name: Self.thunkName(type: type, propertyName: propertyNameForThunk, operation: "set"), parameters: [selfParameter, newValue], returnType: .void, - effects: effects + effects: effects, + availability: availability ) } if let constructor = type.constructor { @@ -800,6 +832,8 @@ struct SwiftSignatureBuilder { switch type { case .closure(_, useJSTypedClosure: false): return "@escaping \(type.swiftType)" + case _ where type.isNoncopyable: + return "borrowing \(type.swiftType)" default: return buildTypeSyntax(from: type) } @@ -831,6 +865,33 @@ enum SwiftCodePattern { elseDecl(printer) printer.write("#endif") } + + static func buildAvailableDecl( + printer: CodeFragmentPrinter, + usesUniqueArray: Bool, + availability: [String], + body: (_ printer: CodeFragmentPrinter) throws -> Void + ) rethrows { + if usesUniqueArray { + printer.write("#if compiler(>=6.4)") + } + printer.write(lines: availability) + try body(printer) + if usesUniqueArray { + printer.write("#endif") + } + } + + static func buildAvailableDecl( + _ decl: DeclSyntax, + usesUniqueArray: Bool, + availability: [String] + ) -> DeclSyntax { + let attributes = availability.map { "\($0)\n" }.joined() + let annotated: DeclSyntax = "\(raw: decl.leadingTrivia)\(raw: attributes)\(decl.with(\.leadingTrivia, []))" + return usesUniqueArray ? "#if compiler(>=6.4)\n\(annotated)\n#endif" : annotated + } + static func buildExternFunctionDecl( printer: CodeFragmentPrinter, moduleName: String, @@ -948,7 +1009,7 @@ extension BridgeType { case .float: return .float case .double: return .double case .string: return .string - case .jsObject: return .jsObject + case .jsObject, .jsUniqueObject: return .jsObject case .jsValue: return .jsValue case .void: return .void case .closure: @@ -1017,7 +1078,7 @@ extension BridgeType { case .float: return .float case .double: return .double case .string: return .string - case .jsObject: return .jsObject + case .jsObject, .jsUniqueObject: return .jsObject case .jsValue: return .jsValue case .void: return .void case .closure: @@ -1046,8 +1107,11 @@ extension BridgeType { case .nullable(let wrappedType, _): // jsObject uses the stack ABI for optionals — the thunk returns void and the // value (plus isSome discriminator) flows through the stacks. - if case .jsObject = wrappedType { + switch wrappedType { + case .jsObject, .jsUniqueObject: return LiftingReturnInfo(valueToLift: nil) + default: + break } let wrappedInfo = try wrappedType.liftingReturnInfo(context: context) return LiftingReturnInfo(valueToLift: wrappedInfo.valueToLift) diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/Misc.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/Misc.swift index 8d7b7c902..007199081 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/Misc.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/Misc.swift @@ -361,16 +361,28 @@ public struct BridgeJSConfig: Codable { /// Default: `nil` (treated as `"none"`) public var identityMode: String? - public init(tools: [String: String]? = nil, exposeToGlobal: Bool = false, identityMode: String? = nil) { + /// Whether `ts2swift` emits `@JSClass` structs as noncopyable wrappers. + /// + /// Default: `nil` (treated as `false`) + public var noncopyableWrappers: Bool? + + public init( + tools: [String: String]? = nil, + exposeToGlobal: Bool = false, + identityMode: String? = nil, + noncopyableWrappers: Bool? = nil + ) { self.tools = tools self.exposeToGlobal = exposeToGlobal self.identityMode = identityMode + self.noncopyableWrappers = noncopyableWrappers } enum CodingKeys: String, CodingKey { case tools case exposeToGlobal case identityMode + case noncopyableWrappers } public init(from decoder: Decoder) throws { @@ -378,6 +390,7 @@ public struct BridgeJSConfig: Codable { tools = try container.decodeIfPresent([String: String].self, forKey: .tools) exposeToGlobal = try container.decodeIfPresent(Bool.self, forKey: .exposeToGlobal) ?? false identityMode = try container.decodeIfPresent(String.self, forKey: .identityMode) + noncopyableWrappers = try container.decodeIfPresent(Bool.self, forKey: .noncopyableWrappers) } /// Load the configuration file from the SwiftPM package target directory. @@ -421,7 +434,8 @@ public struct BridgeJSConfig: Codable { return BridgeJSConfig( tools: (tools ?? [:]).merging(overrides.tools ?? [:], uniquingKeysWith: { $1 }), exposeToGlobal: overrides.exposeToGlobal, - identityMode: overrides.identityMode ?? identityMode + identityMode: overrides.identityMode ?? identityMode, + noncopyableWrappers: overrides.noncopyableWrappers ?? noncopyableWrappers ) } } diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift index 7e075a8af..7101b4b73 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift @@ -431,6 +431,46 @@ public final class SwiftToSkeleton { "Float64": "JSFloat64Array", ] + private func bridgedArray( + of elementType: BridgeType, + isUniqueArray: Bool, + node: TypeSyntax, + errors: inout [DiagnosticError] + ) -> BridgeType? { + let bridgeType = BridgeType.array(elementType) + if elementType.isNoncopyable == isUniqueArray { + return bridgeType + } + errors.append( + DiagnosticError( + node: node, + message: isUniqueArray + ? "'UniqueArray' is supported only for noncopyable '@JSClass' wrapper elements" + : "An array of noncopyable '@JSClass' wrappers must be a 'UniqueArray'", + hint: "Use '\(bridgeType.swiftType)'" + ) + ) + return nil + } + + private func bridgedDictionary( + of valueType: BridgeType, + node: TypeSyntax, + errors: inout [DiagnosticError] + ) -> BridgeType? { + if !valueType.isNoncopyable { + return .dictionary(valueType) + } + errors.append( + DiagnosticError( + node: node, + message: "Dictionaries of noncopyable '@JSClass' wrappers are not supported", + hint: "Use JSObject values, or a copyable '@JSClass' wrapper" + ) + ) + return nil + } + func lookupType(for type: TypeSyntax, errors: inout [DiagnosticError]) -> BridgeType? { if let attributedType = type.as(AttributedTypeSyntax.self) { return lookupType(for: attributedType.baseType, errors: &errors) @@ -593,31 +633,33 @@ public final class SwiftToSkeleton { // [T] if let arrayType = type.as(ArrayTypeSyntax.self) { if let elementType = lookupType(for: arrayType.element, errors: &errors) { - return .array(elementType) + return bridgedArray(of: elementType, isUniqueArray: false, node: type, errors: &errors) } } - // Array + // Array, UniqueArray if let identifierType = type.as(IdentifierTypeSyntax.self), - identifierType.name.text == "Array", + identifierType.name.text == "Array" || identifierType.name.text == "UniqueArray", let genericArgs = identifierType.genericArgumentClause?.arguments, genericArgs.count == 1, let argType = TypeSyntax(genericArgs.first?.argument) { if let elementType = lookupType(for: argType, errors: &errors) { - return .array(elementType) + let isUniqueArray = identifierType.name.text == "UniqueArray" + return bridgedArray(of: elementType, isUniqueArray: isUniqueArray, node: type, errors: &errors) } } - // Swift.Array + // Swift.Array, Swift.UniqueArray if let memberType = type.as(MemberTypeSyntax.self), let baseType = memberType.baseType.as(IdentifierTypeSyntax.self), baseType.name.text == "Swift", - memberType.name.text == "Array", + memberType.name.text == "Array" || memberType.name.text == "UniqueArray", let genericArgs = memberType.genericArgumentClause?.arguments, genericArgs.count == 1, let argType = TypeSyntax(genericArgs.first?.argument) { if let elementType = lookupType(for: argType, errors: &errors) { - return .array(elementType) + let isUniqueArray = memberType.name.text == "UniqueArray" + return bridgedArray(of: elementType, isUniqueArray: isUniqueArray, node: type, errors: &errors) } } // [String: T] @@ -626,7 +668,7 @@ public final class SwiftToSkeleton { keyType == .string, let valueType = lookupType(for: dictType.value, errors: &errors) { - return .dictionary(valueType) + return bridgedDictionary(of: valueType, node: type, errors: &errors) } } // Dictionary @@ -640,7 +682,7 @@ public final class SwiftToSkeleton { keyType == .string { if let valueType = lookupType(for: valueArg, errors: &errors) { - return .dictionary(valueType) + return bridgedDictionary(of: valueType, node: type, errors: &errors) } } // Swift.Dictionary @@ -656,7 +698,7 @@ public final class SwiftToSkeleton { keyType == .string { if let valueType = lookupType(for: valueArg, errors: &errors) { - return .dictionary(valueType) + return bridgedDictionary(of: valueType, node: type, errors: &errors) } } if let aliasDecl = typeDeclResolver.resolveTypeAlias(type) { @@ -731,7 +773,7 @@ public final class SwiftToSkeleton { itemName: structDecl.name.text ) if structDecl.attributes.hasAttribute(name: "JSClass") { - return .jsObject(swiftCallName) + return structDecl.isNoncopyable ? .jsUniqueObject(swiftCallName) : .jsObject(swiftCallName) } if let jsAttribute = structDecl.attributes.firstJSAttribute, let aliasTarget = extractAliasTarget(from: jsAttribute) @@ -940,6 +982,7 @@ public final class SwiftToSkeleton { while let parent = currentNode { if let extensionDecl = parent.as(ExtensionDeclSyntax.self) { + declarations.append(parent) if let extendedDecl = typeDeclResolver.resolveExtensionTarget(extensionDecl.extendedType), visitedExtendedTypes.insert(extendedDecl.id).inserted { @@ -956,6 +999,14 @@ public final class SwiftToSkeleton { return declarations } + fileprivate func computeAvailability(for node: some WithAttributesSyntax) -> [String]? { + let enclosingAttributes = enclosingDeclarations(of: node).compactMap { + $0.asProtocol(WithAttributesSyntax.self)?.attributes + } + let availability = ([node.attributes] + enclosingAttributes).flatMap(\.availableAttributes) + return availability.isEmpty ? nil : availability + } + /// This generates the qualified name needed for Swift code generation (e.g., "Networking.API.HTTPServer") fileprivate func computeSwiftCallName(for node: some SyntaxProtocol, itemName: String) -> String { var swiftPath: [String] = [] @@ -1126,6 +1177,37 @@ extension AttributeListSyntax { return syntax.attributeNameText == name } } + + fileprivate var availableAttributes: [String] { + compactMap { attribute in + guard let syntax = attribute.as(AttributeSyntax.self), syntax.attributeNameText == "available" else { + return nil + } + return syntax.trimmedDescription + } + } +} + +extension MemberBlockItemListSyntax { + fileprivate var declsIncludingAllIfConfigClauses: [DeclSyntax] { + flatMap { member -> [DeclSyntax] in + guard let ifConfig = member.decl.as(IfConfigDeclSyntax.self) else { return [member.decl] } + return ifConfig.clauses.flatMap { clause -> [DeclSyntax] in + guard case .decls(let members) = clause.elements else { return [] } + return members.declsIncludingAllIfConfigClauses + } + } + } +} + +extension StructDeclSyntax { + fileprivate var isNoncopyable: Bool { + inheritanceClause?.inheritedTypes.contains { inherited in + guard let suppressed = inherited.type.as(SuppressedTypeSyntax.self) else { return false } + let name = suppressed.type.trimmedDescription + return name == "Copyable" || name == "Swift.Copyable" + } ?? false + } } private final class JSAttributeFinder: SyntaxVisitor { @@ -2174,7 +2256,8 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { jsNamespace: namespaceResult.jsNamespace, identityMode: classIdentityMode, documentation: extractDocumentation(from: node), - isFinal: isFinal + isFinal: isFinal, + availability: parent.computeAvailability(for: node) ) let uniqueKey = makeKey(name: name, namespace: effectiveNamespace) @@ -2246,7 +2329,7 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { } private func recordAlias( - node: some SyntaxProtocol & NamedDeclSyntax, + node: some NamedDeclSyntax & WithAttributesSyntax, jsAttribute: AttributeSyntax, aliasTarget: TypeSyntax ) { @@ -2291,7 +2374,11 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { return } exportedAliases.append( - ExportedAlias(swiftCallName: swiftCallName, underlying: underlying) + ExportedAlias( + swiftCallName: swiftCallName, + underlying: underlying, + availability: parent.computeAvailability(for: node) + ) ) } @@ -2339,7 +2426,8 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { emitStyle: emitStyle, staticMethods: [], staticProperties: [], - documentation: extractDocumentation(from: node) + documentation: extractDocumentation(from: node), + availability: parent.computeAvailability(for: node) ) let enumUniqueKey = makeKey(name: name, namespace: effectiveNamespace) @@ -2469,8 +2557,8 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { stateStack.push(state: .protocolBody(name: name, key: protocolUniqueKey)) var methods: [ExportedFunction] = [] - for member in node.memberBlock.members { - if let funcDecl = member.decl.as(FunctionDeclSyntax.self) { + for decl in node.memberBlock.members.declsIncludingAllIfConfigClauses { + if let funcDecl = decl.as(FunctionDeclSyntax.self) { if let exportedFunction = visitProtocolMethod( node: funcDecl, protocolName: name, @@ -2478,7 +2566,7 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { ) { methods.append(exportedFunction) } - } else if let varDecl = member.decl.as(VariableDeclSyntax.self) { + } else if let varDecl = decl.as(VariableDeclSyntax.self) { _ = visitProtocolProperty(node: varDecl, protocolName: name, protocolKey: protocolUniqueKey) } } @@ -2494,7 +2582,8 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { inheritedJSProtocols: inheritedJSProtocols.isEmpty ? nil : inheritedJSProtocols, isGenericBridgeable: (node.inheritanceClause?.inheritedTypes ?? []).contains { parent.inheritsGenericBridgeability(for: $0.type) - } ? true : nil + } ? true : nil, + availability: parent.computeAvailability(for: node) ) exportedProtocolByName[protocolUniqueKey] = exportedProtocol @@ -2567,6 +2656,14 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { else { continue } + if fieldType.isNoncopyable { + diagnose( + node: typeAnnotation.type, + message: "A '@JS struct' field cannot be a noncopyable '@JSClass' wrapper", + hint: "Use a JSObject field, or a copyable '@JSClass' wrapper" + ) + continue + } let property = ExportedProperty( name: fieldName, @@ -2592,7 +2689,8 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { methods: [], namespace: effectiveNamespace, jsNamespace: namespaceResult.jsNamespace, - documentation: extractDocumentation(from: node) + documentation: extractDocumentation(from: node), + availability: parent.computeAvailability(for: node) ) exportedStructByName[structUniqueKey] = exportedStruct @@ -2965,6 +3063,8 @@ private final class ImportSwiftMacrosAPICollector: SyntaxAnyVisitor { let jsName: String? let from: JSImportFrom? let accessLevel: BridgeJSAccessLevel + var isNoncopyable = false + var availability: [String]? var constructor: ImportedConstructorSkeleton? var methods: [ImportedFunctionSkeleton] var staticMethods: [ImportedFunctionSkeleton] @@ -2993,6 +3093,10 @@ private final class ImportSwiftMacrosAPICollector: SyntaxAnyVisitor { firstAttribute(attributes, named: "JSGetter") } + static func firstJSGetterFunctionAttribute(_ attributes: AttributeListSyntax?) -> AttributeSyntax? { + firstAttribute(attributes, named: "JSGetterFunction") + } + static func hasJSSetterAttribute(_ attributes: AttributeListSyntax?) -> Bool { hasAttribute(attributes, name: "JSSetter") } @@ -3389,7 +3493,9 @@ private final class ImportSwiftMacrosAPICollector: SyntaxAnyVisitor { getters: type.getters, setters: type.setters, documentation: nil, - accessLevel: type.accessLevel + accessLevel: type.accessLevel, + isNoncopyable: type.isNoncopyable ? true : nil, + availability: type.availability ) ) currentType = nil @@ -3410,6 +3516,8 @@ private final class ImportSwiftMacrosAPICollector: SyntaxAnyVisitor { from: from, accessLevel: accessLevel ) + currentType?.isNoncopyable = node.isNoncopyable + currentType?.availability = parent.computeAvailability(for: node) } return .visitChildren } @@ -3433,6 +3541,7 @@ private final class ImportSwiftMacrosAPICollector: SyntaxAnyVisitor { from: from, accessLevel: accessLevel ) + currentType?.availability = parent.computeAvailability(for: node) } return .visitChildren } @@ -3470,6 +3579,12 @@ private final class ImportSwiftMacrosAPICollector: SyntaxAnyVisitor { importedFunctions.append(function) return .skipChildren } + if let jsGetter = AttributeChecker.firstJSGetterFunctionAttribute(node.attributes) { + if let getter = parseGetterSkeleton(jsGetter, node) { + importedGlobalGetters.append(getter) + } + return .skipChildren + } // Top-level setters are not supported if AttributeChecker.hasJSSetterAttribute(node.attributes) { errors.append( @@ -3500,6 +3615,21 @@ private final class ImportSwiftMacrosAPICollector: SyntaxAnyVisitor { return true } + if let jsGetter = AttributeChecker.firstJSGetterFunctionAttribute(node.attributes) { + if isStaticMember { + errors.append( + DiagnosticError( + node: node, + message: + "@JSGetterFunction is not supported for static members. Use it only for instance members in @JSClass types." + ) + ) + } else if let getter = parseGetterSkeleton(jsGetter, node) { + type.getters.append(getter) + } + return true + } + if AttributeChecker.hasJSSetterAttribute(node.attributes) { if isStaticMember { errors.append( @@ -3787,6 +3917,35 @@ private final class ImportSwiftMacrosAPICollector: SyntaxAnyVisitor { return (identifier, typeAnnotation.type) } + private func parseGetterSkeleton( + _ jsGetter: AttributeSyntax, + _ node: FunctionDeclSyntax + ) -> ImportedGetterSkeleton? { + guard node.signature.parameterClause.parameters.isEmpty else { + errors.append(DiagnosticError(node: node, message: "@JSGetterFunction function must have no parameters.")) + return nil + } + guard let returnType = node.signature.returnClause?.type else { + errors.append(DiagnosticError(node: node, message: "@JSGetterFunction function must have a return type.")) + return nil + } + guard let propertyType = withLookupErrors({ parent.lookupType(for: returnType, errors: &$0) }) else { + return nil + } + let extractedJSName = extractJSName(from: jsGetter) + let from = extractJSImportFrom(from: jsGetter) + validateDefaultExportUsage(extractedJSName, from: from, node: node) + return ImportedGetterSkeleton( + name: SwiftToSkeleton.normalizeIdentifier(node.name.text), + jsName: extractedJSName?.memberName, + from: from, + type: propertyType, + documentation: nil, + functionName: nil, + accessLevel: Self.bridgeAccessLevel(from: node.modifiers) + ) + } + private func parseGetterSkeleton( _ jsGetter: AttributeSyntax, _ node: VariableDeclSyntax @@ -3798,6 +3957,21 @@ private final class ImportSwiftMacrosAPICollector: SyntaxAnyVisitor { return nil } let propertyName = SwiftToSkeleton.normalizeIdentifier(identifier.identifier.text) + if propertyType.isNoncopyable { + let getterFunction = jsGetter.with( + \.attributeName, + TypeSyntax(IdentifierTypeSyntax(name: .identifier("JSGetterFunction"))) + ) + errors.append( + DiagnosticError( + node: node, + message: "@JSGetter cannot read a noncopyable '@JSClass' wrapper", + hint: + "Use '\(getterFunction.trimmedDescription) func \(identifier.identifier.text)() throws(JSException) -> \(type.trimmedDescription)'" + ) + ) + return nil + } let extractedJSName = extractJSName(from: jsGetter) let from = extractJSImportFrom(from: jsGetter) validateDefaultExportUsage(extractedJSName, from: from, node: node) diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index 82150d065..dd31b5170 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -4515,6 +4515,8 @@ extension BridgeType { return tsName } return name ?? "any" + case .jsUniqueObject(let name): + return name ?? "any" case .jsValue: return "any" case .swiftHeapObject(let name): diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift index 20f231dc8..dbcdba5d7 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift @@ -1634,7 +1634,7 @@ struct IntrinsicJSFragment: Sendable { case .rawValueEnum(_, let rawType) where rawType != .string: return .identity case .string: return .stringLowerParameter - case .jsObject: return .jsObjectLowerParameter + case .jsObject, .jsUniqueObject: return .jsObjectLowerParameter case .jsValue: return .jsValueLower case .swiftHeapObject: return .swiftHeapObjectLowerParameter case .swiftProtocol: return .jsObjectLowerParameter @@ -1692,7 +1692,7 @@ struct IntrinsicJSFragment: Sendable { case .rawValueEnum(_, let rawType) where rawType != .string && rawType != .bool: return .identity case .string: return .stringLiftReturn - case .jsObject: return .jsObjectLiftReturn + case .jsObject, .jsUniqueObject: return .jsObjectLiftReturn case .jsValue: return .jsValueLift case .swiftHeapObject(let name): return .swiftHeapObjectLiftReturn(name) case .swiftProtocol: return .jsObjectLiftReturn @@ -1749,7 +1749,7 @@ struct IntrinsicJSFragment: Sendable { case .rawValueEnum(_, let rawType) where rawType != .string && rawType != .bool: return .identity case .string: return .stringLiftParameter - case .jsObject: return .jsObjectLiftParameter + case .jsObject, .jsUniqueObject: return .jsObjectLiftParameter case .jsValue: return .jsValueLiftParameter case .swiftHeapObject(let name): return .swiftHeapObjectLiftParameter(name) @@ -1820,7 +1820,7 @@ struct IntrinsicJSFragment: Sendable { case .rawValueEnum(_, let rawType) where rawType != .string && rawType != .bool: return .identity case .string: return .stringLowerReturn - case .jsObject: return .jsObjectLowerReturn + case .jsObject, .jsUniqueObject: return .jsObjectLowerReturn case .jsValue: return .jsValueLowerReturn(context: context) case .swiftHeapObject: return .swiftHeapObjectLowerReturn case .swiftProtocol: return .jsObjectLowerReturn @@ -2300,7 +2300,7 @@ struct IntrinsicJSFragment: Sendable { return [objVar] } ) - case .jsObject, .swiftProtocol: + case .jsObject, .jsUniqueObject, .swiftProtocol: return IntrinsicJSFragment( parameters: [], printCode: { arguments, context in @@ -2422,7 +2422,7 @@ struct IntrinsicJSFragment: Sendable { return [] } ) - case .jsObject, .swiftProtocol: + case .jsObject, .jsUniqueObject, .swiftProtocol: return IntrinsicJSFragment( parameters: ["value"], printCode: { arguments, context in @@ -2808,7 +2808,7 @@ private extension BridgeType { return .sideChannelReturn(.none) case .string: return .sideChannelReturn(.storage) - case .jsObject: + case .jsObject, .jsUniqueObject: return .stackABI case .jsValue: return .inlineFlag @@ -2855,7 +2855,7 @@ private extension BridgeType { /// `Optional` and exported `@JS class` parameters. var optionalParameterUsesStackABI: Bool { switch self { - case .jsObject: + case .jsObject, .jsUniqueObject: return false case .nullable(let wrapped, _): return wrapped.optionalParameterUsesStackABI @@ -2906,7 +2906,7 @@ private extension BridgeType { return [("value", .f64)] case .string: return [("bytes", .i32), ("length", .i32)] - case .jsObject: + case .jsObject, .jsUniqueObject: return [("value", .i32)] case .jsValue: return [("kind", .i32), ("payload1", .i32), ("payload2", .f64)] diff --git a/Plugins/BridgeJS/Sources/BridgeJSMacros/BridgeJSMacrosPlugin.swift b/Plugins/BridgeJS/Sources/BridgeJSMacros/BridgeJSMacrosPlugin.swift index 9a45fa0f0..10080c30b 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSMacros/BridgeJSMacrosPlugin.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSMacros/BridgeJSMacrosPlugin.swift @@ -6,6 +6,7 @@ struct BridgeJSMacrosPlugin: CompilerPlugin { var providingMacros: [Macro.Type] = [ JSFunctionMacro.self, JSGetterMacro.self, + JSGetterFunctionMacro.self, JSSetterMacro.self, JSClassMacro.self, ] diff --git a/Plugins/BridgeJS/Sources/BridgeJSMacros/JSClassMacro.swift b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSClassMacro.swift index c44655c7e..fef1b43d3 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSMacros/JSClassMacro.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSClassMacro.swift @@ -64,6 +64,44 @@ extension JSClassMacro: MemberMacro { let memberAccessModifier = synthesizedMemberAccessModifier(for: declaration).map { "\($0) " } ?? "" let existingMembers = declaration.memberBlock.members + let hasUnsafelyWrappingInit = existingMembers.contains { member in + guard let initializer = member.decl.as(InitializerDeclSyntax.self) else { return false } + let parameters = initializer.signature.parameterClause.parameters + guard let firstParam = parameters.first else { return false } + let externalName = firstParam.firstName.text + let internalName = firstParam.secondName?.text + return externalName == "unsafelyWrapping" && internalName == "jsObject" + } + + if JSMacroHelper.isNoncopyable(structDecl) { + members.append(DeclSyntax("\(raw: memberAccessModifier)let jsRef: JSUniqueRef")) + members.append( + DeclSyntax( + """ + \(raw: memberAccessModifier)init(unsafelyAdopting jsRef: consuming JSUniqueRef) { + self.jsRef = jsRef + } + """ + ) + ) + if !hasUnsafelyWrappingInit { + members.append( + DeclSyntax( + """ + \(raw: memberAccessModifier)init(unsafelyWrapping jsObject: consuming JSObject) { + self.init(unsafelyAdopting: JSUniqueRef(taking: consume jsObject)) + } + """ + ) + ) + } + members.append(DeclSyntax("\(raw: memberAccessModifier)var jsID: Int32 { jsRef.jsID }")) + members.append( + DeclSyntax("\(raw: memberAccessModifier)consuming func takeJSRef() -> JSUniqueRef { jsRef }") + ) + return members + } + let hasJSObjectProperty = existingMembers.contains { member in guard let variable = member.decl.as(VariableDeclSyntax.self) else { return false } return variable.bindings.contains { binding in @@ -75,15 +113,6 @@ extension JSClassMacro: MemberMacro { members.append(DeclSyntax("\(raw: memberAccessModifier)let jsObject: JSObject")) } - let hasUnsafelyWrappingInit = existingMembers.contains { member in - guard let initializer = member.decl.as(InitializerDeclSyntax.self) else { return false } - let parameters = initializer.signature.parameterClause.parameters - guard let firstParam = parameters.first else { return false } - let externalName = firstParam.firstName.text - let internalName = firstParam.secondName?.text - return externalName == "unsafelyWrapping" && internalName == "jsObject" - } - if !hasUnsafelyWrappingInit { members.append( DeclSyntax( @@ -123,9 +152,13 @@ extension JSClassMacro: ExtensionMacro { return [] } - let conformanceList = protocols.map { $0.trimmed.description }.joined(separator: ", ") + let wanted = JSMacroHelper.isNoncopyable(structDecl) ? "_JSUniqueBridgedClass" : "_JSBridgedClass" + let conformances = protocols.map { $0.trimmed.description }.filter { + $0 == wanted || $0.hasSuffix(".\(wanted)") + } + guard !conformances.isEmpty else { return [] } return [ - try ExtensionDeclSyntax("extension \(type.trimmed): \(raw: conformanceList) {}") + try ExtensionDeclSyntax("extension \(type.trimmed): \(raw: conformances.joined(separator: ", ")) {}") ] } diff --git a/Plugins/BridgeJS/Sources/BridgeJSMacros/JSFunctionMacro.swift b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSFunctionMacro.swift index 0fff3546a..7817b4e30 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSMacros/JSFunctionMacro.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSFunctionMacro.swift @@ -33,7 +33,7 @@ extension JSFunctionMacro: BodyMacro { var arguments: [String] = [] if isInstanceMember { - arguments.append("self.jsObject") + arguments.append(JSMacroHelper.selfArgument(in: context)) } arguments.append( contentsOf: JSMacroHelper.parameterNames(functionDecl.signature.parameterClause.parameters) @@ -86,6 +86,12 @@ extension JSFunctionMacro: BodyMacro { let isAsync = effects?.asyncSpecifier != nil let prefix = JSMacroHelper.tryAwaitPrefix(isAsync: isAsync, isThrows: true) + if JSMacroHelper.enclosingTypeIsNoncopyable(in: context) { + return [ + CodeBlockItemSyntax(stringLiteral: "let jsRef = \(prefix)\(call)"), + CodeBlockItemSyntax(stringLiteral: "self.init(unsafelyAdopting: jsRef)"), + ] + } return [ CodeBlockItemSyntax(stringLiteral: "let jsObject = \(prefix)\(call)"), CodeBlockItemSyntax(stringLiteral: "self.init(unsafelyWrapping: jsObject)"), diff --git a/Plugins/BridgeJS/Sources/BridgeJSMacros/JSGetterFunctionMacro.swift b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSGetterFunctionMacro.swift new file mode 100644 index 000000000..f956801b3 --- /dev/null +++ b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSGetterFunctionMacro.swift @@ -0,0 +1,35 @@ +import SwiftSyntax +import SwiftSyntaxBuilder +import SwiftSyntaxMacros +import SwiftDiagnostics + +public enum JSGetterFunctionMacro {} + +extension JSGetterFunctionMacro: BodyMacro { + public static func expansion( + of node: AttributeSyntax, + providingBodyFor declaration: some DeclSyntaxProtocol & WithOptionalCodeBlockSyntax, + in context: some MacroExpansionContext + ) throws -> [CodeBlockItemSyntax] { + guard let functionDecl = declaration.as(FunctionDeclSyntax.self) else { return [] } + let enclosingTypeName = JSMacroHelper.enclosingTypeName(from: context) + let isInstanceMember = enclosingTypeName != nil && !JSMacroHelper.isStatic(functionDecl.modifiers) + if enclosingTypeName != nil { + JSMacroHelper.diagnoseMissingJSClass(node: node, for: "JSGetterFunction", in: context) + } + JSMacroHelper.diagnoseThrowsRequiresJSException( + signature: functionDecl.signature, + on: Syntax(functionDecl), + in: context, + message: .jsGetterFunctionRequiresThrows, + noteMessage: JSMacroText.jsGetterFunctionExceptionPropagation + ) + let getterName = JSMacroHelper.glueName( + baseName: JSMacroHelper.stripBackticks(functionDecl.name.text), + enclosingTypeName: enclosingTypeName, + operation: "get" + ) + let argument = isInstanceMember ? JSMacroHelper.selfArgument(in: context) : "" + return [CodeBlockItemSyntax(stringLiteral: "return try \(getterName)(\(argument))")] + } +} diff --git a/Plugins/BridgeJS/Sources/BridgeJSMacros/JSGetterMacro.swift b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSGetterMacro.swift index a3b9435ea..9b9eece47 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSMacros/JSGetterMacro.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSGetterMacro.swift @@ -51,7 +51,7 @@ extension JSGetterMacro: AccessorMacro { var getterArgs: [String] = [] if isInstanceMember { - getterArgs.append("self.jsObject") + getterArgs.append(JSMacroHelper.selfArgument(in: context)) } let getterCall: CodeBlockItemSyntax = "return try \(raw: getterName)(\(raw: getterArgs.joined(separator: ", ")))" diff --git a/Plugins/BridgeJS/Sources/BridgeJSMacros/JSMacroSupport.swift b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSMacroSupport.swift index c347bfb21..708495cc4 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSMacros/JSMacroSupport.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSMacroSupport.swift @@ -13,6 +13,7 @@ enum JSMacroMessage: String, DiagnosticMessage { case setterRequiresParameter = "@JSSetter function must have at least one parameter." case setterRequiresThrows = "@JSSetter function must declare throws(JSException)." case jsFunctionRequiresThrows = "@JSFunction throws must be declared as throws(JSException)." + case jsGetterFunctionRequiresThrows = "@JSGetterFunction throws must be declared as throws(JSException)." case requiresJSClass = "JavaScript members must be declared inside a @JSClass struct." case jsClassRequiresAtLeastInternal = "@JSClass does not support private/fileprivate access level. Use internal, package, or public." @@ -36,6 +37,8 @@ struct JSMacroFixItMessage: FixItMessage { enum JSMacroText { static let jsExceptionPropagation = "@JSFunction must propagate JavaScript errors as JSException." + static let jsGetterFunctionExceptionPropagation = + "@JSGetterFunction must propagate JavaScript errors as JSException." static let jsSetterExceptionPropagation = "@JSSetter must propagate JavaScript errors as JSException." } @@ -62,6 +65,22 @@ enum JSMacroHelper { } } + static func isNoncopyable(_ structDecl: StructDeclSyntax) -> Bool { + structDecl.inheritanceClause?.inheritedTypes.contains { inherited in + guard let suppressed = inherited.type.as(SuppressedTypeSyntax.self) else { return false } + let name = suppressed.type.trimmedDescription + return name == "Copyable" || name == "Swift.Copyable" + } ?? false + } + + static func enclosingTypeIsNoncopyable(in context: some MacroExpansionContext) -> Bool { + enclosingTypeSyntax(from: context)?.as(StructDeclSyntax.self).map(isNoncopyable) ?? false + } + + static func selfArgument(in context: some MacroExpansionContext) -> String { + enclosingTypeIsNoncopyable(in: context) ? "self.jsRef" : "self.jsObject" + } + static func isVoidReturn(_ returnType: TypeSyntax?) -> Bool { guard let returnType else { return true } if let identifier = returnType.as(IdentifierTypeSyntax.self), identifier.name.text == "Void" { @@ -159,6 +178,8 @@ enum JSMacroHelper { signature: FunctionSignatureSyntax, on node: Syntax, in context: some MacroExpansionContext, + message: JSMacroMessage = .jsFunctionRequiresThrows, + noteMessage: String = JSMacroText.jsExceptionPropagation, additionalNotes: [Note] = [] ) { let throwsClause = signature.effectSpecifiers?.throwsClause @@ -195,14 +216,14 @@ enum JSMacroHelper { } var notes: [Note] = [ - jsExceptionPropagationNote(on: node) + jsExceptionPropagationNote(on: node, message: noteMessage) ] notes.append(contentsOf: additionalNotes) context.diagnose( Diagnostic( node: node, - message: JSMacroMessage.jsFunctionRequiresThrows, + message: message, notes: notes, fixIts: [fixIt] ) diff --git a/Plugins/BridgeJS/Sources/BridgeJSMacros/JSSetterMacro.swift b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSSetterMacro.swift index 4d32db449..77e839ea7 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSMacros/JSSetterMacro.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSSetterMacro.swift @@ -145,7 +145,7 @@ extension JSSetterMacro: BodyMacro { var arguments: [String] = [] if isInstanceMember { - arguments.append("self.jsObject") + arguments.append(JSMacroHelper.selfArgument(in: context)) } // Get the parameter name(s) - setters typically have one parameter diff --git a/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift index d52e9122d..0141b9062 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift @@ -286,6 +286,8 @@ public struct BridgeIntegerType: Codable, Equatable, Hashable, Sendable { public enum BridgeType: Codable, Equatable, Hashable, Sendable { case integer(BridgeIntegerType), float, double, string, bool, jsObject(String?), jsValue, swiftHeapObject(String), void + /// A noncopyable `@JSClass` wrapper, or `JSUniqueRef` when the name is `nil`. + case jsUniqueObject(String?) case unsafePointer(UnsafePointerType) indirect case nullable(BridgeType, JSOptionalKind) indirect case array(BridgeType) @@ -843,6 +845,7 @@ public struct ExportedStruct: Codable, Equatable, Sendable, NamespacedExportedTy public let namespace: [String]? public let jsNamespace: [String]? public var documentation: String? + public var availability: [String]? public init( name: String, @@ -854,7 +857,8 @@ public struct ExportedStruct: Codable, Equatable, Sendable, NamespacedExportedTy methods: [ExportedFunction] = [], namespace: [String]?, jsNamespace: [String]? = nil, - documentation: String? = nil + documentation: String? = nil, + availability: [String]? = nil ) { self.name = name self.jsName = jsName @@ -866,6 +870,7 @@ public struct ExportedStruct: Codable, Equatable, Sendable, NamespacedExportedTy self.namespace = namespace self.jsNamespace = jsNamespace self.documentation = documentation + self.availability = availability } } @@ -938,6 +943,7 @@ public struct ExportedEnum: Codable, Equatable, Sendable, NamespacedExportedType public var staticMethods: [ExportedFunction] public var staticProperties: [ExportedProperty] = [] public var documentation: String? + public var availability: [String]? public var enumType: EnumType { if cases.isEmpty { return .namespace @@ -968,7 +974,8 @@ public struct ExportedEnum: Codable, Equatable, Sendable, NamespacedExportedType emitStyle: EnumEmitStyle, staticMethods: [ExportedFunction] = [], staticProperties: [ExportedProperty] = [], - documentation: String? = nil + documentation: String? = nil, + availability: [String]? = nil ) { self.name = name self.jsName = jsName @@ -983,6 +990,7 @@ public struct ExportedEnum: Codable, Equatable, Sendable, NamespacedExportedType self.staticMethods = staticMethods self.staticProperties = staticProperties self.documentation = documentation + self.availability = availability } } @@ -1024,6 +1032,7 @@ public struct ExportedProtocol: Codable, Equatable, NamespacedExportedType { public var documentation: String? public var inheritedJSProtocols: [String]? public var isGenericBridgeable: Bool? + public var availability: [String]? public init( name: String, @@ -1034,7 +1043,8 @@ public struct ExportedProtocol: Codable, Equatable, NamespacedExportedType { jsNamespace: [String]? = nil, documentation: String? = nil, inheritedJSProtocols: [String]? = nil, - isGenericBridgeable: Bool? = nil + isGenericBridgeable: Bool? = nil, + availability: [String]? = nil ) { self.name = name self.jsName = jsName @@ -1045,6 +1055,7 @@ public struct ExportedProtocol: Codable, Equatable, NamespacedExportedType { self.documentation = documentation self.inheritedJSProtocols = inheritedJSProtocols self.isGenericBridgeable = isGenericBridgeable + self.availability = availability } } @@ -1097,6 +1108,7 @@ public struct ExportedClass: Codable, NamespacedExportedType { public var identityMode: Bool? // nil = use config default, true/false = override public var documentation: String? public var isFinal: Bool? + public var availability: [String]? public init( name: String, @@ -1110,7 +1122,8 @@ public struct ExportedClass: Codable, NamespacedExportedType { jsNamespace: [String]? = nil, identityMode: Bool? = nil, documentation: String? = nil, - isFinal: Bool? = nil + isFinal: Bool? = nil, + availability: [String]? = nil ) { self.name = name self.jsName = jsName @@ -1124,6 +1137,7 @@ public struct ExportedClass: Codable, NamespacedExportedType { self.identityMode = identityMode self.documentation = documentation self.isFinal = isFinal + self.availability = availability } } @@ -1219,10 +1233,12 @@ public struct ExportedProperty: Codable, Equatable, Sendable { public struct ExportedAlias: Codable, Equatable, Sendable { public let swiftCallName: String public let underlying: BridgeType + public var availability: [String]? - public init(swiftCallName: String, underlying: BridgeType) { + public init(swiftCallName: String, underlying: BridgeType, availability: [String]? = nil) { self.swiftCallName = swiftCallName self.underlying = underlying + self.availability = availability } } @@ -1686,6 +1702,9 @@ public struct ImportedTypeSkeleton: Codable { public let documentation: String? /// Source access level of the originating Swift `@JSClass` declaration. public let accessLevel: BridgeJSAccessLevel + /// `true` for a `~Copyable` `@JSClass` struct; `nil` otherwise. + public let isNoncopyable: Bool? + public let availability: [String]? public var resolvedJSName: String { jsName ?? name } @@ -1699,7 +1718,9 @@ public struct ImportedTypeSkeleton: Codable { getters: [ImportedGetterSkeleton] = [], setters: [ImportedSetterSkeleton] = [], documentation: String? = nil, - accessLevel: BridgeJSAccessLevel = .internal + accessLevel: BridgeJSAccessLevel = .internal, + isNoncopyable: Bool? = nil, + availability: [String]? = nil ) { self.name = name self.jsName = jsName @@ -1711,10 +1732,13 @@ public struct ImportedTypeSkeleton: Codable { self.setters = setters self.documentation = documentation self.accessLevel = accessLevel + self.isNoncopyable = isNoncopyable + self.availability = availability } private enum CodingKeys: String, CodingKey { - case name, jsName, from, constructor, methods, staticMethods, getters, setters, documentation, accessLevel + case name, jsName, from, constructor, methods, staticMethods, getters, setters, documentation, accessLevel, + isNoncopyable, availability } public init(from decoder: any Decoder) throws { @@ -1729,6 +1753,8 @@ public struct ImportedTypeSkeleton: Codable { self.setters = try container.decode([ImportedSetterSkeleton].self, forKey: .setters) self.documentation = try container.decodeIfPresent(String.self, forKey: .documentation) self.accessLevel = try container.decodeIfPresent(BridgeJSAccessLevel.self, forKey: .accessLevel) ?? .internal + self.isNoncopyable = try container.decodeIfPresent(Bool.self, forKey: .isNoncopyable) + self.availability = try container.decodeIfPresent([String].self, forKey: .availability) } } @@ -1969,6 +1995,8 @@ extension BridgeType { self = .void case "JSObject": self = .jsObject(nil) + case "JSUniqueRef": + self = .jsUniqueObject(nil) case "UnsafeRawPointer": self = .unsafePointer(.init(kind: .unsafeRawPointer)) case "UnsafeMutableRawPointer": @@ -1986,7 +2014,7 @@ extension BridgeType { 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, + case .bool, .integer, .float, .double, .string, .jsValue, .jsObject, .jsUniqueObject, .swiftHeapObject, .unsafePointer, .swiftProtocol, .void, .caseEnum, .rawValueEnum, .associatedValueEnum, .swiftStruct, .namespaceEnum, .closure, .generic: @@ -2002,7 +2030,7 @@ extension BridgeType { case .float: return .f32 case .double: return .f64 case .string: return nil - case .jsObject: return .i32 + case .jsObject, .jsUniqueObject: return .i32 case .jsValue: return nil case .swiftHeapObject: // UnsafeMutableRawPointer is returned as an i32 pointer @@ -2079,6 +2107,9 @@ extension BridgeType { case .jsObject(let name): let typeName = name ?? "JSObject" return "\(Self.mangleQualifiedName(typeName))C" + case .jsUniqueObject(let name): + let typeName = name ?? "JSUniqueRef" + return "\(Self.mangleQualifiedName(typeName))V" case .jsValue: return "7JSValueV" case .swiftHeapObject(let name): diff --git a/Plugins/BridgeJS/Sources/BridgeJSTool/BridgeJSTool.swift b/Plugins/BridgeJS/Sources/BridgeJSTool/BridgeJSTool.swift index d3d9a484e..45b96e00d 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSTool/BridgeJSTool.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSTool/BridgeJSTool.swift @@ -161,7 +161,8 @@ import BridgeJSUtilities tsconfigPath: tsconfigPath, nodePath: nodePath, progress: progress, - outputPath: bridgeJSMacrosPath.path + outputPath: bridgeJSMacrosPath.path, + noncopyableWrappers: config.noncopyableWrappers ?? false ) } generatedMacrosPath = bridgeJSMacrosPath.path @@ -221,12 +222,14 @@ import BridgeJSUtilities printStderr(diagnostic.formattedDescription(fileName: file)) } + let availability = AvailabilityIndex(skeletons: [skeleton] + dependencySkeletons.map(\.skeleton)) var exporter: ExportSwift? if let skeleton = skeleton.exported { exporter = ExportSwift( progress: progress, moduleName: moduleName, - skeleton: skeleton + skeleton: skeleton, + availability: availability ) } var importer: ImportTS? @@ -234,13 +237,14 @@ import BridgeJSUtilities importer = ImportTS( progress: progress, moduleName: moduleName, - skeleton: skeleton + skeleton: skeleton, + availability: availability ) } // Generate unified closure support for both import/export to avoid duplicate symbols when concatenating. let closureSupport = try withSpan("ClosureCodegen.renderSupport") { - return try ClosureCodegen().renderSupport(for: skeleton) + return try ClosureCodegen(availability: availability).renderSupport(for: skeleton) } let importResult = try withSpan("ImportTS.finalize") { diff --git a/Plugins/BridgeJS/Sources/BridgeJSToolInternal/BridgeJSToolInternal.swift b/Plugins/BridgeJS/Sources/BridgeJSToolInternal/BridgeJSToolInternal.swift index f57f50756..458ef2e85 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSToolInternal/BridgeJSToolInternal.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSToolInternal/BridgeJSToolInternal.swift @@ -84,18 +84,21 @@ import ArgumentParser let skeletonData = try readData(from: skeletonFile) let skeleton = try JSONDecoder().decode(BridgeJSSkeleton.self, from: skeletonData) let moduleName = "InternalModule" + let availability = AvailabilityIndex(skeletons: [skeleton]) let exported = try skeleton.exported.flatMap { try ExportSwift( progress: ProgressReporting(verbose: false), moduleName: moduleName, - skeleton: $0 + skeleton: $0, + availability: availability ).finalize() } let imported = try skeleton.imported.flatMap { try ImportTS( progress: ProgressReporting(verbose: false), moduleName: moduleName, - skeleton: $0 + skeleton: $0, + availability: availability ).finalize() } let typeRegistration = GenericTypeRegistrationCodegen().render(for: skeleton) diff --git a/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/cli.js b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/cli.js index c5e89c208..868926f29 100644 --- a/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/cli.js +++ b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/cli.js @@ -83,6 +83,7 @@ Options: -p, --project Path to tsconfig.json (default: tsconfig.json). --global Add a .d.ts as a global declaration file (repeatable). --log-level One of: verbose, info, warning, error (default: info). + --noncopyable-wrappers Emit \`@JSClass\` structs as \`~Copyable\` wrappers. -h, --help Show this help. Examples: @@ -97,12 +98,12 @@ Examples: /** * Run ts2swift for a single input file (programmatic API, no process I/O). * @param {string[]} filePaths - Paths to the .d.ts files - * @param {{ tsconfigPath: string, logLevel?: keyof typeof DiagnosticEngine.LEVELS, globalFiles?: string[], diagnosticEngine?: DiagnosticEngine }} options + * @param {{ tsconfigPath: string, logLevel?: keyof typeof DiagnosticEngine.LEVELS, globalFiles?: string[], diagnosticEngine?: DiagnosticEngine, noncopyableWrappers?: boolean }} options * @returns {string} Generated Swift source * @throws {Error} on parse/type-check errors (diagnostics are included in the message) */ export function run(filePaths, options) { - const { tsconfigPath, logLevel = 'info', globalFiles = [], diagnosticEngine } = options; + const { tsconfigPath, logLevel = 'info', globalFiles = [], diagnosticEngine, noncopyableWrappers = false } = options; const engine = diagnosticEngine ?? new DiagnosticEngine(logLevel); const configFile = ts.readConfigFile(tsconfigPath, ts.sys.readFile); @@ -167,6 +168,7 @@ export function run(filePaths, options) { for (const inputPath of [...filePaths, ...globalFiles]) { const processor = new TypeProcessor(program.getTypeChecker(), engine, { defaultImportFromGlobal: globalFileSet.has(inputPath), + noncopyableWrappers, }); const result = processor.processTypeDeclarations(program, inputPath); const body = result.content.trim(); @@ -202,6 +204,9 @@ export function main(args) { type: 'string', default: 'info', }, + "noncopyable-wrappers": { + type: 'boolean', + }, help: { type: 'boolean', short: 'h', @@ -248,7 +253,13 @@ export function main(args) { let swiftOutput; try { - swiftOutput = run(filePaths, { tsconfigPath, logLevel, globalFiles, diagnosticEngine }); + swiftOutput = run(filePaths, { + tsconfigPath, + logLevel, + globalFiles, + diagnosticEngine, + noncopyableWrappers: options.values["noncopyable-wrappers"] ?? false, + }); } catch (/** @type {unknown} */ err) { if (err instanceof Error) { diagnosticEngine.print("error", err.message); diff --git a/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/processor.js b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/processor.js index 91a42a9ef..de0d6ba55 100644 --- a/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/processor.js +++ b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/processor.js @@ -36,6 +36,7 @@ export class TypeProcessor { /** * @param {ts.TypeChecker} checker - TypeScript type checker * @param {DiagnosticEngine} diagnosticEngine - Diagnostic engine + * @param {{ defaultImportFromGlobal?: boolean, noncopyableWrappers?: boolean }} options */ constructor(checker, diagnosticEngine, options = { defaultImportFromGlobal: false, @@ -68,6 +69,11 @@ export class TypeProcessor { /** @type {boolean} */ this.defaultImportFromGlobal = options.defaultImportFromGlobal ?? false; + + /** @type {boolean} */ + this.noncopyableWrappers = options.noncopyableWrappers ?? false; + /** @type {Set} */ + this.wrapperTypeNames = new Set(); } /** @@ -118,6 +124,72 @@ export class TypeProcessor { return swiftName; } + /** + * @param {string} swiftType + * @returns {boolean} + * @private + */ + isNoncopyable(swiftType) { + if (!this.noncopyableWrappers) return false; + const optional = /^Optional<(.*)>$/.exec(swiftType); + const wrapped = optional ? optional[1] : swiftType; + return wrapped.startsWith("UniqueArray<") || this.wrapperTypeNames.has(wrapped); + } + + /** + * @param {string} swiftType + * @returns {string} + * @private + */ + copyableFallback(swiftType) { + const optional = /^Optional<(.*)>$/.exec(swiftType); + if (optional) return `Optional<${this.copyableFallback(optional[1])}>`; + const array = /^UniqueArray<(.*)>$/.exec(swiftType); + if (array) return `[${this.copyableFallback(array[1])}]`; + return this.wrapperTypeNames.has(swiftType) ? "JSObject" : swiftType; + } + + /** + * @param {string} annotation + * @param {string} typeName + * @returns {string} + * @private + */ + renderWrapperStructLine(annotation, typeName) { + const conformance = this.noncopyableWrappers ? ": ~Copyable" : ""; + return `${annotation} struct ${typeName}${conformance} {`; + } + + /** + * @param {string} swiftType + * @returns {string} + * @private + */ + renderParameterType(swiftType) { + return this.isNoncopyable(swiftType) ? `borrowing ${swiftType}` : swiftType; + } + + /** + * In noncopyable mode, replaces a container Swift cannot form around a noncopyable type, and warns. + * `JSUndefinedOr` and `Dictionary` need a copyable element. + * @param {string} swiftType - The type rendered for copyable wrappers + * @param {string} elementType + * @param {(element: string) => string} makeReplacement - Builds the replacement from the element's `copyableFallback` + * @param {ts.Node} node + * @returns {string} + * @private + */ + replaceNoncopyableContainer(swiftType, elementType, makeReplacement, node) { + if (!this.isNoncopyable(elementType)) return swiftType; + const replacement = makeReplacement(this.copyableFallback(elementType)); + this.diagnosticEngine.print( + "warning", + `${swiftType} cannot hold the noncopyable type ${elementType}; using ${replacement}`, + node + ); + return replacement; + } + /** * Render a Swift type identifier from a TypeScript type name. * @param {string} jsTypeName @@ -324,10 +396,15 @@ export class TypeProcessor { } const swiftType = this.visitType(type, decl); - const annotation = this.renderMacroAnnotation("JSGetter", args); - this.emitDocComment(decl, { indent: "" }); - this.swiftLines.push(`${annotation} var ${swiftVarName}: ${swiftType}`); + if (this.isNoncopyable(swiftType)) { + const annotation = this.renderMacroAnnotation("JSGetterFunction", args); + const effects = this.renderEffects({ isAsync: false }); + this.swiftLines.push(`${annotation} func ${swiftVarName}() ${effects} -> ${swiftType}`); + } else { + const annotation = this.renderMacroAnnotation("JSGetter", args); + this.swiftLines.push(`${annotation} var ${swiftVarName}: ${swiftType}`); + } this.swiftLines.push(""); } } @@ -827,7 +904,7 @@ export class TypeProcessor { const annotation = this.renderMacroAnnotation("JSClass", args); const className = this.renderIdentifier(swiftName); this.emitDocComment(node, { indent: "" }); - this.swiftLines.push(`${annotation} struct ${className} {`); + this.swiftLines.push(this.renderWrapperStructLine(annotation, className)); // Process members in declaration order for (const member of node.members) { @@ -899,7 +976,7 @@ export class TypeProcessor { if (docNode) { this.emitDocComment(docNode, { indent: "" }); } - this.swiftLines.push(`${annotation} struct ${typeName} {`); + this.swiftLines.push(this.renderWrapperStructLine(annotation, typeName)); // Collect all declarations with their positions to preserve order /** @type {Array<{ decl: ts.Node, symbol: ts.Symbol, position: number }>} */ @@ -953,7 +1030,7 @@ export class TypeProcessor { const typeArgs = this.checker.getTypeArguments(/** @type {ts.TypeReference} */ (type)); if (typeArgs && typeArgs.length > 0) { const elementType = this.visitType(typeArgs[0], node); - return `[${elementType}]`; + return this.isNoncopyable(elementType) ? `UniqueArray<${elementType}>` : `[${elementType}]`; } return "[JSObject]"; } @@ -963,6 +1040,11 @@ export class TypeProcessor { return recordType; } + const nullableType = this.convertNullableUnion(type, node); + if (nullableType) { + return nullableType; + } + // Treat A and A as the same type if (isTypeReference(type)) { type = type.target; @@ -977,29 +1059,8 @@ export class TypeProcessor { */ const convert = (type) => { const originalType = type; - // Handle nullable/undefined unions (e.g. T | null, T | undefined) const isUnionType = (type.flags & ts.TypeFlags.Union) !== 0; if (isUnionType) { - /** @type {ts.UnionType} */ - // @ts-ignore - const unionType = type; - const unionTypes = unionType.types; - const hasNull = unionTypes.some(t => (t.flags & ts.TypeFlags.Null) !== 0); - const hasUndefined = unionTypes.some(t => (t.flags & ts.TypeFlags.Undefined) !== 0); - const nonNullableTypes = unionTypes.filter( - t => (t.flags & ts.TypeFlags.Null) === 0 && (t.flags & ts.TypeFlags.Undefined) === 0 - ); - if (nonNullableTypes.length === 1 && (hasNull || hasUndefined)) { - const wrapped = this.visitType(nonNullableTypes[0], node); - if (hasNull && hasUndefined) { - return "JSObject"; - } - if (hasNull) { - return `Optional<${wrapped}>`; - } - return `JSUndefinedOr<${wrapped}>`; - } - const stringLiteralUnion = this.getStringLiteralUnionLiterals(type); if (stringLiteralUnion && stringLiteralUnion.length > 0) { const typeName = this.deriveTypeName(originalType) ?? this.deriveTypeName(type); @@ -1060,7 +1121,9 @@ export class TypeProcessor { return "JSObject"; } this.seenTypes.set(type, node); - return this.renderTypeIdentifier(typeName); + const wrapperName = this.renderTypeIdentifier(typeName); + this.wrapperTypeNames.add(wrapperName); + return wrapperName; } const swiftType = convert(type); this.processedTypes.set(type, swiftType); @@ -1097,7 +1160,40 @@ export class TypeProcessor { } const valueSwiftType = this.visitType(valueType, node); - return `[String: ${valueSwiftType}]`; + return this.replaceNoncopyableContainer(`[String: ${valueSwiftType}]`, valueSwiftType, (e) => `[String: ${e}]`, node); + } + + /** + * Convert a `T | null` or `T | undefined` TypeScript type into a Swift optional type. + * @param {ts.Type} type + * @param {ts.Node} node + * @returns {string | null} + * @private + */ + convertNullableUnion(type, node) { + if ((type.flags & ts.TypeFlags.Union) === 0) { + return null; + } + /** @type {ts.UnionType} */ + // @ts-ignore + const unionType = type; + const unionTypes = unionType.types; + const hasNull = unionTypes.some(t => (t.flags & ts.TypeFlags.Null) !== 0); + const hasUndefined = unionTypes.some(t => (t.flags & ts.TypeFlags.Undefined) !== 0); + const nonNullableTypes = unionTypes.filter( + t => (t.flags & ts.TypeFlags.Null) === 0 && (t.flags & ts.TypeFlags.Undefined) === 0 + ); + if (nonNullableTypes.length !== 1 || !(hasNull || hasUndefined)) { + return null; + } + const wrapped = this.visitType(nonNullableTypes[0], node); + if (hasNull && hasUndefined) { + return "JSObject"; + } + if (hasNull) { + return `Optional<${wrapped}>`; + } + return this.replaceNoncopyableContainer(`JSUndefinedOr<${wrapped}>`, wrapped, () => `Optional<${wrapped}>`, node); } /** @@ -1153,12 +1249,18 @@ export class TypeProcessor { const getterArgs = []; if (needsJSGetterName) getterArgs.push(`jsName: "${this.escapeForSwiftStringLiteral(property.jsName)}"`); if (fromArg) getterArgs.push(fromArg); - const getterAnnotation = this.renderMacroAnnotation("JSGetter", getterArgs); const staticKeyword = isStatic ? "static " : ""; // Always render getter this.emitDocComment(node, { indent: " " }); - this.swiftLines.push(` ${getterAnnotation} ${staticKeyword}var ${swiftName}: ${type}`); + if (this.isNoncopyable(type)) { + const getterAnnotation = this.renderMacroAnnotation("JSGetterFunction", getterArgs); + const effects = this.renderEffects({ isAsync: false }); + this.swiftLines.push(` ${getterAnnotation} ${staticKeyword}func ${swiftName}() ${effects} -> ${type}`); + } else { + const getterAnnotation = this.renderMacroAnnotation("JSGetter", getterArgs); + this.swiftLines.push(` ${getterAnnotation} ${staticKeyword}var ${swiftName}: ${type}`); + } // Render setter if not readonly if (!property.isReadonly) { @@ -1171,7 +1273,7 @@ export class TypeProcessor { if (needsJSNameField) setterArgs.push(`jsName: "${this.escapeForSwiftStringLiteral(property.jsName)}"`); if (fromArg) setterArgs.push(fromArg); const annotation = this.renderMacroAnnotation("JSSetter", setterArgs); - this.swiftLines.push(` ${annotation} ${staticKeyword}func ${this.renderIdentifier(setterName)}(_ value: ${type}) ${this.renderEffects({ isAsync: false })}`); + this.swiftLines.push(` ${annotation} ${staticKeyword}func ${this.renderIdentifier(setterName)}(_ value: ${this.renderParameterType(type)}) ${this.renderEffects({ isAsync: false })}`); } } @@ -1261,7 +1363,7 @@ export class TypeProcessor { const param = this.visitSignatureParameter(p, node); const paramName = this.renderIdentifier(p.name); const type = param.type; - params.push(`_ ${paramName}: ${type}`); + params.push(`_ ${paramName}: ${this.renderParameterType(type)}`); } return params.join(", "); } diff --git a/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/__snapshots__/ts2swift.test.js.snap b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/__snapshots__/ts2swift.test.js.snap index 0cb0e3206..17ebd3858 100644 --- a/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/__snapshots__/ts2swift.test.js.snap +++ b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/__snapshots__/ts2swift.test.js.snap @@ -656,3 +656,135 @@ exports[`ts2swift > snapshots Swift output for WebIDLDOMDocs.d.ts > WebIDLDOMDoc } " `; + +exports[`ts2swift noncopyable mode > snapshots Swift output for Noncopyable/Warnings.d.ts > Noncopyable/Warnings 1`] = ` +"// swift-format-ignore-file +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// \`swift package bridge-js\`. + +@_spi(BridgeJS) import JavaScriptKit + +@JSFunction func findUndefined(_ start: Double) throws(JSException) -> Optional + +@JSClass struct Item: ~Copyable { + @JSFunction func value() throws(JSException) -> Double + @JSGetterFunction func maybe() throws(JSException) -> Optional + @JSSetter func setMaybe(_ value: borrowing Optional) throws(JSException) + @JSGetterFunction func later() throws(JSException) -> Optional + @JSSetter func setLater(_ value: borrowing Optional) throws(JSException) + @JSGetter var byName: [String: JSObject] + @JSSetter func setByName(_ value: [String: JSObject]) throws(JSException) +} + +@JSFunction func useOptional(_ item: borrowing Optional) throws(JSException) -> Double + +@JSFunction func useUndefined(_ item: borrowing Optional) throws(JSException) -> Double + +@JSFunction func makeByName() throws(JSException) -> [String: JSObject] + +@JSFunction func useByName(_ items: [String: JSObject]) throws(JSException) -> Double + +@JSFunction func useNullableByName(_ items: [String: Optional]) throws(JSException) -> Double + +@JSFunction func useArraysByName(_ items: [String: [JSObject]]) throws(JSException) -> Double +" +`; + +exports[`ts2swift noncopyable mode > snapshots Swift output for Noncopyable/WrapperArrays.d.ts > Noncopyable/WrapperArrays 1`] = ` +"// swift-format-ignore-file +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// \`swift package bridge-js\`. + +@_spi(BridgeJS) import JavaScriptKit + +@JSClass struct Store: ~Copyable { + @JSFunction init(_ seed: borrowing UniqueArray) throws(JSException) + @JSFunction func take(_ items: borrowing UniqueArray) throws(JSException) -> Double + @JSFunction func takeGeneric(_ items: borrowing UniqueArray) throws(JSException) -> Double + @JSFunction func takeReadonly(_ items: borrowing UniqueArray) throws(JSException) -> Double + @JSFunction func takeSlots(_ slots: borrowing UniqueArray>) throws(JSException) -> Double + @JSFunction func takeMaybe(_ items: borrowing Optional>) throws(JSException) -> Double + @JSFunction func takeUndefined(_ items: borrowing Optional>) throws(JSException) -> Double + @JSFunction func make(_ count: Double) throws(JSException) -> UniqueArray + @JSFunction func makeSlots(_ count: Double) throws(JSException) -> UniqueArray> + @JSFunction func makeMaybe(_ count: Double) throws(JSException) -> Optional> + @JSFunction func makeGrid(_ count: Double) throws(JSException) -> UniqueArray> + @JSFunction func load(_ count: Double) async throws(JSException) -> UniqueArray + @JSFunction func each(_ callback: JSObject) throws(JSException) -> Void + @JSFunction func numbers(_ values: [Double]) throws(JSException) -> [Double] + @JSFunction func shelf() throws(JSException) -> Shelf +} + +@JSClass struct Item: ~Copyable { + @JSFunction func value() throws(JSException) -> Double +} + +@JSClass struct Shelf: ~Copyable { + @JSGetterFunction func items() throws(JSException) -> UniqueArray + @JSSetter func setItems(_ value: borrowing UniqueArray) throws(JSException) + @JSGetterFunction func fixed() throws(JSException) -> UniqueArray + @JSGetterFunction func slots() throws(JSException) -> UniqueArray> + @JSSetter func setSlots(_ value: borrowing UniqueArray>) throws(JSException) + @JSGetterFunction func maybeItems() throws(JSException) -> Optional> + @JSSetter func setMaybeItems(_ value: borrowing Optional>) throws(JSException) + @JSGetterFunction func grid() throws(JSException) -> UniqueArray> + @JSSetter func setGrid(_ value: borrowing UniqueArray>) throws(JSException) + @JSGetter var byName: [String: [JSObject]] + @JSSetter func setByName(_ value: [String: [JSObject]]) throws(JSException) +} + +@JSGetterFunction func allItems() throws(JSException) -> UniqueArray + +@JSFunction func makeItems(_ count: Double) throws(JSException) -> UniqueArray +" +`; + +exports[`ts2swift noncopyable mode > snapshots Swift output for Noncopyable/Wrappers.d.ts > Noncopyable/Wrappers 1`] = ` +"// swift-format-ignore-file +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// \`swift package bridge-js\`. + +@_spi(BridgeJS) import JavaScriptKit + +@JSClass struct Factory: ~Copyable { + @JSFunction init(_ seed: borrowing Item) throws(JSException) + @JSFunction func make(_ start: Double) throws(JSException) -> Item + @JSFunction func makeMany(_ count: Double) throws(JSException) -> UniqueArray + @JSFunction func find(_ start: Double) throws(JSException) -> Optional + @JSFunction func findUndefined(_ start: Double) throws(JSException) -> Optional + @JSFunction func load(_ start: Double) async throws(JSException) -> Item + @JSFunction func loadOptional(_ start: Double) async throws(JSException) -> Optional + @JSFunction func use(_ item: borrowing Item) throws(JSException) -> Double + @JSFunction func useMany(_ items: borrowing UniqueArray) throws(JSException) -> Double + @JSFunction func useOptional(_ item: borrowing Optional) throws(JSException) -> Double + @JSFunction func useNullable(_ item: borrowing Optional) throws(JSException) -> Double + @JSFunction func each(_ callback: JSObject) throws(JSException) -> Void +} + +@JSClass struct Item: ~Copyable { + @JSFunction func value() throws(JSException) -> Double + @JSGetterFunction func child() throws(JSException) -> Item + @JSGetterFunction func sibling() throws(JSException) -> Optional + @JSSetter func setSibling(_ value: borrowing Optional) throws(JSException) + @JSGetterFunction func maybe() throws(JSException) -> Optional + @JSSetter func setMaybe(_ value: borrowing Optional) throws(JSException) + @JSGetterFunction func items() throws(JSException) -> UniqueArray + @JSSetter func setItems(_ value: borrowing UniqueArray) throws(JSException) + @JSGetter var byName: [String: JSObject] + @JSSetter func setByName(_ value: [String: JSObject]) throws(JSException) +} + +@JSGetterFunction func defaultItem() throws(JSException) -> Item + +@JSFunction func makeItem(_ start: Double) throws(JSException) -> Item +" +`; diff --git a/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/fixtures/Noncopyable/Warnings.d.ts b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/fixtures/Noncopyable/Warnings.d.ts new file mode 100644 index 000000000..d510080f8 --- /dev/null +++ b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/fixtures/Noncopyable/Warnings.d.ts @@ -0,0 +1,14 @@ +// Positions where noncopyable mode replaces JSUndefinedOr or a Record of a wrapper +export interface Item { + value(): number; + maybe?: Item; + later: Item | undefined; + byName: Record; +} +export function findUndefined(start: number): Item | undefined; +export function useOptional(item?: Item): number; +export function useUndefined(item: Item | undefined): number; +export function makeByName(): Record; +export function useByName(items: Record): number; +export function useNullableByName(items: Record): number; +export function useArraysByName(items: Record): number; diff --git a/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/fixtures/Noncopyable/WrapperArrays.d.ts b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/fixtures/Noncopyable/WrapperArrays.d.ts new file mode 100644 index 000000000..0e16e033d --- /dev/null +++ b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/fixtures/Noncopyable/WrapperArrays.d.ts @@ -0,0 +1,31 @@ +// A wrapper type in every array position +export interface Item { + value(): number; +} +export interface Shelf { + items: Item[]; + readonly fixed: Item[]; + slots: (Item | null)[]; + maybeItems: Item[] | null; + grid: Item[][]; + byName: Record; +} +export class Store { + constructor(seed: Item[]); + take(items: Item[]): number; + takeGeneric(items: Array): number; + takeReadonly(items: readonly Item[]): number; + takeSlots(slots: (Item | null)[]): number; + takeMaybe(items: Item[] | null): number; + takeUndefined(items?: Item[]): number; + make(count: number): Item[]; + makeSlots(count: number): (Item | null)[]; + makeMaybe(count: number): Item[] | null; + makeGrid(count: number): Item[][]; + load(count: number): Promise; + each(callback: (items: Item[]) => void): void; + numbers(values: number[]): number[]; + shelf(): Shelf; +} +export const allItems: Item[]; +export function makeItems(count: number): Item[]; diff --git a/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/fixtures/Noncopyable/Wrappers.d.ts b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/fixtures/Noncopyable/Wrappers.d.ts new file mode 100644 index 000000000..6e6df160a --- /dev/null +++ b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/fixtures/Noncopyable/Wrappers.d.ts @@ -0,0 +1,25 @@ +// A wrapper type in every position ts2swift maps +export interface Item { + value(): number; + readonly child: Item; + sibling: Item | null; + maybe?: Item; + items: Item[]; + byName: Record; +} +export class Factory { + constructor(seed: Item); + make(start: number): Item; + makeMany(count: number): Item[]; + find(start: number): Item | null; + findUndefined(start: number): Item | undefined; + load(start: number): Promise; + loadOptional(start: number): Promise; + use(item: Item): number; + useMany(items: Item[]): number; + useOptional(item?: Item): number; + useNullable(item: Item | null): number; + each(callback: (item: Item) => void): void; +} +export const defaultItem: Item; +export function makeItem(start: number): Item; diff --git a/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/ts2swift.test.js b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/ts2swift.test.js index 4aefa19b5..4c96bb784 100644 --- a/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/ts2swift.test.js +++ b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/ts2swift.test.js @@ -16,8 +16,8 @@ function runTs2Swift(dtsPath) { return run([dtsPath], { tsconfigPath, logLevel: 'error' }); } -function collectDtsInputs() { - const entries = readdirSync(inputsDir, { withFileTypes: true }); +function collectDtsInputs(directory = inputsDir) { + const entries = readdirSync(directory, { withFileTypes: true }); return entries .filter((e) => e.isFile() && e.name.endsWith('.d.ts')) .map((e) => e.name) @@ -65,3 +65,70 @@ describe('ts2swift', () => { expect(occurrences).toBe(1); }); }); + +describe('ts2swift noncopyable mode', () => { + const noncopyableDir = path.join(inputsDir, 'Noncopyable'); + + /** + * @param {string} dtsFile + * @param {{ print: (level: string, message: string, node?: import('typescript').Node) => void }} [diagnosticEngine] + */ + function runNoncopyable(dtsFile, diagnosticEngine) { + return run([path.join(noncopyableDir, dtsFile)], { + tsconfigPath, + logLevel: diagnosticEngine ? 'warning' : 'error', + diagnosticEngine, + noncopyableWrappers: true, + }); + } + + for (const dtsFile of collectDtsInputs(noncopyableDir)) { + it(`snapshots Swift output for Noncopyable/${dtsFile}`, () => { + const name = dtsFile.replace(/\.d\.ts$/, ''); + expect(runNoncopyable(dtsFile)).toMatchSnapshot(`Noncopyable/${name}`); + }); + } + + it('warns once at every position whose container cannot hold a wrapper', () => { + /** @type {{ line: number, column: number, text: string }[]} */ + const diagnostics = []; + const diagnosticEngine = { + print: (level, message, node) => { + const sourceFile = node.getSourceFile(); + const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)); + diagnostics.push({ line: line + 1, column: character + 1, text: `${level} ${message}` }); + }, + }; + runNoncopyable('Warnings.d.ts', diagnosticEngine); + diagnostics.sort((a, b) => a.line - b.line || a.column - b.column); + const optional = 'warning JSUndefinedOr cannot hold the noncopyable type Item; using Optional'; + const record = 'warning [String: Item] cannot hold the noncopyable type Item; using [String: JSObject]'; + expect(diagnostics.map((d) => `${d.line}:${d.column} ${d.text}`)).toEqual([ + `4:5 ${optional}`, + `5:5 ${optional}`, + `6:5 ${record}`, + `8:1 ${optional}`, + `9:1 ${optional}`, + `10:1 ${optional}`, + `11:1 ${record}`, + `12:1 ${record}`, + '13:1 warning [String: Optional] cannot hold the noncopyable type Optional; using [String: Optional]', + '14:1 warning [String: UniqueArray] cannot hold the noncopyable type UniqueArray; using [String: [JSObject]]', + ]); + }); + + it('keeps wrappers copyable without the option', () => { + /** @type {string[]} */ + const messages = []; + const diagnosticEngine = { print: (_level, message) => messages.push(message) }; + const output = run([path.join(noncopyableDir, 'Warnings.d.ts')], { + tsconfigPath, + logLevel: 'warning', + diagnosticEngine, + }); + expect(output).toContain('@JSClass struct Item {'); + expect(output).toContain('@JSGetter var maybe: JSUndefinedOr'); + expect(output).not.toContain('~Copyable'); + expect(messages).toEqual([]); + }); +}); diff --git a/Plugins/BridgeJS/Sources/TS2Swift/TS2Swift.swift b/Plugins/BridgeJS/Sources/TS2Swift/TS2Swift.swift index 42a6775ff..52d1d8596 100644 --- a/Plugins/BridgeJS/Sources/TS2Swift/TS2Swift.swift +++ b/Plugins/BridgeJS/Sources/TS2Swift/TS2Swift.swift @@ -95,7 +95,8 @@ public func invokeTS2Swift( tsconfigPath: String, nodePath: URL, progress: ProgressReporting, - outputPath: String? = nil + outputPath: String? = nil, + noncopyableWrappers: Bool = false ) throws -> String { let ts2swiftPath = URL(fileURLWithPath: #filePath) .deletingLastPathComponent() @@ -109,6 +110,9 @@ public func invokeTS2Swift( if let outputPath = outputPath { arguments.append(contentsOf: ["--output", outputPath]) } + if noncopyableWrappers { + arguments.append("--noncopyable-wrappers") + } progress.print("Running ts2swift...") progress.print(" \(([nodePath.path] + arguments).joined(separator: " "))") diff --git a/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSClassMacroTests.swift b/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSClassMacroTests.swift index c52bc9db0..7fba2a3da 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSClassMacroTests.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSClassMacroTests.swift @@ -526,4 +526,90 @@ import BridgeJSMacros indentationWidth: indentationWidth ) } + + @Test func noncopyableStruct() { + TestSupport.assertMacroExpansion( + """ + @JSClass + struct MyClass: ~Copyable { + } + """, + expandedSource: """ + struct MyClass: ~Copyable { + + let jsRef: JSUniqueRef + + init(unsafelyAdopting jsRef: consuming JSUniqueRef) { + self.jsRef = jsRef + } + + init(unsafelyWrapping jsObject: consuming JSObject) { + self.init(unsafelyAdopting: JSUniqueRef(taking: consume jsObject)) + } + + var jsID: Int32 { + jsRef.jsID + } + + consuming func takeJSRef() -> JSUniqueRef { + jsRef + } + } + + extension MyClass: _JSUniqueBridgedClass { + } + """, + macroSpecs: [ + "JSClass": MacroSpec( + type: JSClassMacro.self, + conformances: ["_JSBridgedClass", "_JSUniqueBridgedClass"] + ) + ], + indentationWidth: indentationWidth + ) + } + + @Test func noncopyableStructWithExistingUnsafelyWrappingInit() { + TestSupport.assertMacroExpansion( + """ + @JSClass + struct MyClass: ~Copyable { + init(unsafelyWrapping jsObject: JSObject) { + self.init(unsafelyAdopting: JSUniqueRef(retaining: jsObject)) + } + } + """, + expandedSource: """ + struct MyClass: ~Copyable { + init(unsafelyWrapping jsObject: JSObject) { + self.init(unsafelyAdopting: JSUniqueRef(retaining: jsObject)) + } + + let jsRef: JSUniqueRef + + init(unsafelyAdopting jsRef: consuming JSUniqueRef) { + self.jsRef = jsRef + } + + var jsID: Int32 { + jsRef.jsID + } + + consuming func takeJSRef() -> JSUniqueRef { + jsRef + } + } + + extension MyClass: _JSUniqueBridgedClass { + } + """, + macroSpecs: [ + "JSClass": MacroSpec( + type: JSClassMacro.self, + conformances: ["_JSBridgedClass", "_JSUniqueBridgedClass"] + ) + ], + indentationWidth: indentationWidth + ) + } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSFunctionMacroTests.swift b/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSFunctionMacroTests.swift index 28eade958..f04efe925 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSFunctionMacroTests.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSFunctionMacroTests.swift @@ -297,6 +297,28 @@ import BridgeJSMacros ) } + @Test func noncopyableInstanceMethod() { + TestSupport.assertMacroExpansion( + """ + @JSClass + struct MyClass: ~Copyable { + @JSFunction + func getName() throws(JSException) -> String + } + """, + expandedSource: """ + @JSClass + struct MyClass: ~Copyable { + func getName() throws(JSException) -> String { + return try _$MyClass_getName(self.jsRef) + } + } + """, + macroSpecs: macroSpecs, + indentationWidth: indentationWidth, + ) + } + @Test func staticMethod() { TestSupport.assertMacroExpansion( """ @@ -420,6 +442,29 @@ import BridgeJSMacros ) } + @Test func noncopyableInitializer() { + TestSupport.assertMacroExpansion( + """ + @JSClass + struct MyClass: ~Copyable { + @JSFunction + init(name: String) throws(JSException) + } + """, + expandedSource: """ + @JSClass + struct MyClass: ~Copyable { + init(name: String) throws(JSException) { + let jsRef = try _$MyClass_init(name) + self.init(unsafelyAdopting: jsRef) + } + } + """, + macroSpecs: macroSpecs, + indentationWidth: indentationWidth, + ) + } + @Test func initializerWithoutEnclosingType() { TestSupport.assertMacroExpansion( """ diff --git a/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSGetterFunctionMacroTests.swift b/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSGetterFunctionMacroTests.swift new file mode 100644 index 000000000..be83ed318 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSGetterFunctionMacroTests.swift @@ -0,0 +1,176 @@ +import SwiftDiagnostics +import SwiftSyntax +import SwiftSyntaxMacroExpansion +import SwiftSyntaxMacrosGenericTestSupport +import Testing +import BridgeJSMacros + +@Suite struct JSGetterFunctionMacroTests { + private let indentationWidth: Trivia = .spaces(4) + private let macroSpecs: [String: MacroSpec] = [ + "JSGetterFunction": MacroSpec(type: JSGetterFunctionMacro.self) + ] + + @Test func topLevelFunction() { + TestSupport.assertMacroExpansion( + """ + @JSGetterFunction + func count() throws(JSException) -> Int + """, + expandedSource: """ + func count() throws(JSException) -> Int { + return try _$count_get() + } + """, + macroSpecs: macroSpecs, + indentationWidth: indentationWidth, + ) + } + + @Test func instanceFunction() { + TestSupport.assertMacroExpansion( + """ + @JSClass + struct MyClass { + @JSGetterFunction + func name() throws(JSException) -> String + } + """, + expandedSource: """ + @JSClass + struct MyClass { + func name() throws(JSException) -> String { + return try _$MyClass_name_get(self.jsObject) + } + } + """, + macroSpecs: macroSpecs, + indentationWidth: indentationWidth, + ) + } + + @Test func noncopyableInstanceFunction() { + TestSupport.assertMacroExpansion( + """ + @JSClass + struct MyClass: ~Copyable { + @JSGetterFunction + func style() throws(JSException) -> Style + } + """, + expandedSource: """ + @JSClass + struct MyClass: ~Copyable { + func style() throws(JSException) -> Style { + return try _$MyClass_style_get(self.jsRef) + } + } + """, + macroSpecs: macroSpecs, + indentationWidth: indentationWidth, + ) + } + + @Test func instanceFunctionRequiresJSClass() { + TestSupport.assertMacroExpansion( + """ + struct MyClass { + @JSGetterFunction + func name() throws(JSException) -> String + } + """, + expandedSource: """ + struct MyClass { + func name() throws(JSException) -> String { + return try _$MyClass_name_get(self.jsObject) + } + } + """, + diagnostics: [ + DiagnosticSpec( + message: "JavaScript members must be declared inside a @JSClass struct.", + line: 2, + column: 5 + ) + ], + macroSpecs: macroSpecs, + indentationWidth: indentationWidth, + ) + } + + @Test func missingThrowsClause() { + TestSupport.assertMacroExpansion( + """ + @JSGetterFunction + func count() -> Int + """, + expandedSource: """ + func count() -> Int { + return try _$count_get() + } + """, + diagnostics: [ + DiagnosticSpec( + message: "@JSGetterFunction throws must be declared as throws(JSException).", + line: 1, + column: 1, + notes: [ + NoteSpec( + message: "@JSGetterFunction must propagate JavaScript errors as JSException.", + line: 1, + column: 1 + ) + ], + fixIts: [ + FixItSpec(message: "Declare throws(JSException)") + ] + ) + ], + macroSpecs: macroSpecs, + applyFixIts: ["Declare throws(JSException)"], + fixedSource: """ + @JSGetterFunction + func count() throws(JSException) -> Int + """, + indentationWidth: indentationWidth, + ) + } + + @Test func throwsWrongType() { + TestSupport.assertMacroExpansion( + """ + @JSGetterFunction + func count() throws(CustomError) -> Int + """, + expandedSource: """ + func count() throws(CustomError) -> Int { + return try _$count_get() + } + """, + diagnostics: [ + DiagnosticSpec( + message: "@JSGetterFunction throws must be declared as throws(JSException).", + line: 1, + column: 1, + notes: [ + NoteSpec( + message: "@JSGetterFunction must propagate JavaScript errors as JSException.", + line: 1, + column: 1 + ) + ], + fixIts: [ + FixItSpec(message: "Declare throws(JSException)") + ] + ) + ], + macroSpecs: macroSpecs, + applyFixIts: ["Declare throws(JSException)"], + fixedSource: """ + @JSGetterFunction + func count() throws(JSException) -> Int + """, + indentationWidth: indentationWidth, + ) + } +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSGetterMacroTests.swift b/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSGetterMacroTests.swift index 0e4cea844..585e4cd4f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSGetterMacroTests.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSGetterMacroTests.swift @@ -71,6 +71,30 @@ import BridgeJSMacros ) } + @Test func noncopyableInstanceProperty() { + TestSupport.assertMacroExpansion( + """ + @JSClass + struct MyClass: ~Copyable { + @JSGetter + var name: String + } + """, + expandedSource: """ + @JSClass + struct MyClass: ~Copyable { + var name: String { + get throws(JSException) { + return try _$MyClass_name_get(self.jsRef) + } + } + } + """, + macroSpecs: macroSpecs, + indentationWidth: indentationWidth, + ) + } + @Test func instancePropertyRequiresJSClass() { TestSupport.assertMacroExpansion( """ diff --git a/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSSetterMacroTests.swift b/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSSetterMacroTests.swift index 00d959921..19622c295 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSSetterMacroTests.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSSetterMacroTests.swift @@ -65,6 +65,28 @@ import BridgeJSMacros ) } + @Test func noncopyableInstanceSetter() { + TestSupport.assertMacroExpansion( + """ + @JSClass + struct MyClass: ~Copyable { + @JSSetter + func setName(_ name: String) throws(JSException) + } + """, + expandedSource: """ + @JSClass + struct MyClass: ~Copyable { + func setName(_ name: String) throws(JSException) { + try _$MyClass_name_set(self.jsRef, name) + } + } + """, + macroSpecs: macroSpecs, + indentationWidth: indentationWidth, + ) + } + @Test func instanceSetterRequiresJSClass() { TestSupport.assertMacroExpansion( """ diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/AvailabilityIndexTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/AvailabilityIndexTests.swift new file mode 100644 index 000000000..8fc6be4c8 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/AvailabilityIndexTests.swift @@ -0,0 +1,87 @@ +import Testing + +@testable import BridgeJSCore +@testable import BridgeJSSkeleton + +@Suite struct AvailabilityIndexTests { + private static let core = """ + @available(macOS 14.0, *) + @JS public struct Point { + public var x: Int + } + """ + + @Test func importThunkNamingADependencyTypeCarriesItsAttributes() throws { + let core = try makeSkeleton(Self.core, moduleName: "Core") + let app = try makeSkeleton( + """ + import Core + @JSFunction func draw(_ point: Point) throws(JSException) + """, + moduleName: "App", + dependencies: [(moduleName: "Core", skeleton: core)] + ) + let importTS = ImportTS( + progress: .silent, + moduleName: "App", + skeleton: try #require(app.imported), + availability: AvailabilityIndex(skeletons: [app, core]) + ) + let output = try #require(try importTS.finalize()) + #expect(output.contains("@available(macOS 14.0, *)\nfunc _$draw(_ point: Point) throws(JSException)")) + } + + @Test func moduleTypeKeepsItsAttributesOverADependencyTypeOfTheSameName() throws { + let core = try makeSkeleton(Self.core, moduleName: "Core") + let app = try makeSkeleton( + """ + @available(macOS 15.0, *) + @JS struct Point { + var x: Int + } + """, + moduleName: "App", + dependencies: [(moduleName: "Core", skeleton: core)] + ) + let index = AvailabilityIndex(skeletons: [app, core]) + #expect(index.attributes(for: [.swiftStruct("Point")]) == ["@available(macOS 15.0, *)"]) + } + + @Test(arguments: [ + (BridgeType.array(.swiftStruct("Point")), ["@available(macOS 14.0, *)"]), + (.nullable(.swiftStruct("Point"), .null), ["@available(macOS 14.0, *)"]), + (.dictionary(.swiftStruct("Point")), ["@available(macOS 14.0, *)"]), + ( + .alias(name: "Tag", underlying: .swiftHeapObject("TagReference")), + ["@available(macOS 15.0, *)", "@available(macOS 13.0, *)"] + ), + (.array(.jsUniqueObject("Element")), ["@available(anyAppleOS 27.0, *)", "@available(macOS 14.0, *)"]), + ]) + func compositeTypeCarriesTheAttributesOfTheTypesItContains(type: BridgeType, attributes: [String]) throws { + let skeleton = try makeSkeleton( + """ + @available(macOS 14.0, *) + @JS struct Point { + var x: Int + } + + @available(macOS 15.0, *) + @JS(as: TagReference.self) struct Tag { + var name: String + } + + @available(macOS 13.0, *) + @JS final class TagReference { + @JS init(name: String) {} + } + + @available(macOS 14.0, *) + @JSClass struct Element: ~Copyable { + @JSFunction func id() throws(JSException) -> Int + } + """, + moduleName: "App" + ) + #expect(AvailabilityIndex(skeletons: [skeleton]).attributes(for: [type]) == attributes) + } +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSCodegenTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSCodegenTests.swift index 11347dc40..ee1dae135 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSCodegenTests.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSCodegenTests.swift @@ -122,21 +122,28 @@ import Testing sourceLocation: Testing.SourceLocation = #_sourceLocation ) throws { var swiftParts: [String] = [] - if let closureSupport = try ClosureCodegen().renderSupport(for: skeleton) { + let availability = AvailabilityIndex(skeletons: [skeleton]) + if let closureSupport = try ClosureCodegen(availability: availability).renderSupport(for: skeleton) { swiftParts.append(closureSupport) } if let exported = skeleton.exported { let exportSwift = ExportSwift( progress: .silent, moduleName: skeleton.moduleName, - skeleton: exported + skeleton: exported, + availability: availability ) if let s = try exportSwift.finalize() { swiftParts.append(s) } } if let imported = skeleton.imported { - let importTS = ImportTS(progress: .silent, moduleName: skeleton.moduleName, skeleton: imported) + let importTS = ImportTS( + progress: .silent, + moduleName: skeleton.moduleName, + skeleton: imported, + availability: availability + ) if let s = try importTS.finalize() { swiftParts.append(s) } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/DiagnosticsTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/DiagnosticsTests.swift index aadf04f00..733e80269 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/DiagnosticsTests.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/DiagnosticsTests.swift @@ -592,7 +592,12 @@ import Testing swiftAPI.addSourceFile(Parser.parse(source: source), inputFilePath: "test.swift") let skeleton = try swiftAPI.finalize() let exported = try #require(skeleton.exported) - let exportSwift = ExportSwift(progress: .silent, moduleName: skeleton.moduleName, skeleton: exported) + let exportSwift = ExportSwift( + progress: .silent, + moduleName: skeleton.moduleName, + skeleton: exported, + availability: AvailabilityIndex(skeletons: [skeleton]) + ) #expect(throws: BridgeJSCoreError.self) { _ = try exportSwift.finalize() } @@ -614,7 +619,12 @@ import Testing swiftAPI.addSourceFile(Parser.parse(source: source), inputFilePath: "test.swift") let skeleton = try swiftAPI.finalize() let exported = try #require(skeleton.exported) - let exportSwift = ExportSwift(progress: .silent, moduleName: skeleton.moduleName, skeleton: exported) + let exportSwift = ExportSwift( + progress: .silent, + moduleName: skeleton.moduleName, + skeleton: exported, + availability: AvailabilityIndex(skeletons: [skeleton]) + ) #expect(try exportSwift.finalize() != nil) } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/ExportedTypeNameTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/ExportedTypeNameTests.swift index 9d7c9a689..e739d3c02 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/ExportedTypeNameTests.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/ExportedTypeNameTests.swift @@ -52,8 +52,18 @@ import Testing let renamed = try parse( source.replacingOccurrences(of: "@JS(namespace:", with: "@JS(\"PublicAPI\", namespace:") ) - let originalThunks = try ExportSwift(progress: .silent, moduleName: "TestModule", skeleton: original).finalize() - let renamedThunks = try ExportSwift(progress: .silent, moduleName: "TestModule", skeleton: renamed).finalize() + let originalThunks = try ExportSwift( + progress: .silent, + moduleName: "TestModule", + skeleton: original, + availability: .empty + ).finalize() + let renamedThunks = try ExportSwift( + progress: .silent, + moduleName: "TestModule", + skeleton: renamed, + availability: .empty + ).finalize() #expect(renamedThunks == originalThunks) #expect(renamed.classes.first?.tsFullPath == "API.PublicAPI.Item") } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/GenericImportDiagnosticsTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/GenericImportDiagnosticsTests.swift index f2ff5dc81..8fd4bd6cf 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/GenericImportDiagnosticsTests.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/GenericImportDiagnosticsTests.swift @@ -40,7 +40,12 @@ import Testing ] ) let glue = try #require( - try ImportTS(progress: .silent, moduleName: skeleton.moduleName, skeleton: imported).finalize() + try ImportTS( + progress: .silent, + moduleName: skeleton.moduleName, + skeleton: imported, + availability: AvailabilityIndex(skeletons: [skeleton]) + ).finalize() ) #expect(glue.contains("T: BridgedSwiftGenericBridgeable & GraphKit.Node")) #expect(roundTrip.usedExternalModules == ["GraphKit"]) @@ -72,7 +77,12 @@ import Testing } ) let glue = try #require( - try ExportSwift(progress: .silent, moduleName: skeleton.moduleName, skeleton: exported).finalize() + try ExportSwift( + progress: .silent, + moduleName: skeleton.moduleName, + skeleton: exported, + availability: AvailabilityIndex(skeletons: [skeleton]) + ).finalize() ) #expect(glue.contains("extension Base where Self: _BridgedSwiftProtocolWrapper {")) #expect(glue.contains("extension Node where Self: _BridgedSwiftProtocolWrapper {")) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/Availability.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/Availability.swift new file mode 100644 index 000000000..3904b7a6a --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/Availability.swift @@ -0,0 +1,90 @@ +@available(macOS 14.0, *) +@JS struct Point { + var x: Int +} + +@available(macOS 14.0, iOS 17.0, *) +@JS enum Direction { + case north + case south +} + +@available(macOS 15.0, *) +@JS enum Level: String { + case low + case high +} + +@available(macOS 14.0, *) +@JS enum Shape { + case circle(Double) + case square(Int) +} + +@available(macOS 14.0, *) +@JS final class Counter { + @JS init() {} +} + +@available(macOS 14.0, *) +@JS protocol Source { + func value() -> Int +} + +@JS protocol PointSource { + @available(macOS 14.0, *) + func point() -> Point + @available(macOS 14.0, *) + var origin: Point { get } +} + +@available(macOS 14.0, *) +@JSClass struct Element { + @JSFunction func id() throws(JSException) -> Int +} + +@JSClass struct Canvas { + @available(macOS 14.0, *) + @JSFunction func element() throws(JSException) -> Element +} + +@available(macOS 15.0, *) +@JS func mix(_ point: Point, _ body: (Point, Level) -> Direction) -> Int + +@available(macOS 14.0, *) +@JS func loadPoint() async -> Point + +@available(macOS 14.0, *) +@JS enum Geometry { + @JS struct Box { + var side: Int + } +} + +@JS class Library { + @JS init() {} +} + +@available(macOS 14.0, *) +extension Library { + @JS struct Shelf { + var label: String + } +} + +@available(macOS 14.0, *) +@JS(as: TagReference.self) struct Tag { + var name: String +} + +@available(macOS 14.0, *) +@JS final class TagReference { + @JS init(name: String) {} +} + +@JSClass struct NoncopyableObject: ~Copyable { + @JSFunction func id() throws(JSException) -> Int +} + +@available(macOS 27.0, *) +@JS func countObjects(_ body: (borrowing UniqueArray, Point) -> Int) -> Int diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/NoncopyableJSClass.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/NoncopyableJSClass.swift new file mode 100644 index 000000000..a9aa70f95 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/NoncopyableJSClass.swift @@ -0,0 +1,66 @@ +@JSClass struct NoncopyableObject: ~Copyable { + @JSFunction init(_ start: Int) throws(JSException) + @JSFunction func value() throws(JSException) -> Int + @JSGetter var name: String +} + +@JSClass struct NoncopyableObjectRoundtrip: ~Copyable { + @JSFunction func take(_ object: borrowing NoncopyableObject) throws(JSException) -> Int + @JSFunction func adopt(_ object: consuming NoncopyableObject) throws(JSException) -> Int + @JSFunction func make(_ start: Int) throws(JSException) -> NoncopyableObject + @JSFunction func find(_ start: Int) throws(JSException) -> NoncopyableObject? + @JSFunction func takeOptional(_ object: borrowing NoncopyableObject?) throws(JSException) -> Int + @JSGetterFunction func child() throws(JSException) -> NoncopyableObject + @JSSetter func setChild(_ object: borrowing NoncopyableObject) throws(JSException) + @JSFunction func forEach(_ body: JSTypedClosure<(borrowing NoncopyableObject) -> Void>) throws(JSException) + @JSFunction func load(_ start: Int) async throws(JSException) -> NoncopyableObject + @JSFunction func takeAll(_ objects: borrowing UniqueArray) throws(JSException) -> Int + @JSFunction func makeAll(_ count: Int) throws(JSException) -> UniqueArray + @JSFunction func makeMaybe(_ count: Int) throws(JSException) -> UniqueArray? + @JSFunction func raw(_ start: Int) throws(JSException) -> JSUniqueRef +} + +@JSFunction func makeNoncopyableObject(_ start: Int) throws(JSException) -> NoncopyableObject + +@JS func useNoncopyableObject(_ object: borrowing NoncopyableObject) -> Int { + (try? object.value()) ?? -1 +} + +@JS func makeNoncopyableObjectInSwift(_ start: Int) -> NoncopyableObject { + try! NoncopyableObject(start) +} + +@JS func findNoncopyableObjectInSwift(_ start: Int) -> NoncopyableObject? { + nil +} + +@JS func countNoncopyableObjects(_ objects: borrowing UniqueArray) -> Int { + objects.count +} + +@JS func countNoncopyableObjectsWith(_ body: (borrowing UniqueArray) -> Int) -> Int { + 0 +} + +@JS func loadNoncopyableObject(_ start: Int) async -> NoncopyableObject { + try! NoncopyableObject(start) +} + +@JS func loadNoncopyableObjects(_ count: Int) async -> UniqueArray { + UniqueArray() +} + +@JS class NoncopyableObjectBox { + @JS var object: NoncopyableObject + + @JS init(_ start: Int) { + object = try! NoncopyableObject(start) + } +} + +@JS protocol NoncopyableObjectSource { + func name() -> String + #if compiler(>=6.4) + func makeAll(_ count: Int) -> UniqueArray + #endif +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/ProtocolConditionalCompilation.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/ProtocolConditionalCompilation.swift new file mode 100644 index 000000000..7ede58a58 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/ProtocolConditionalCompilation.swift @@ -0,0 +1,14 @@ +import JavaScriptKit + +@JS protocol Logger { + func log(_ message: String) + #if DEBUG + func trace(_ message: String) + #elseif TESTING + var verbosity: Int { get set } + #else + #if os(WASI) + func flush() + #endif + #endif +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/NoncopyableJSClassDiagnosticsTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/NoncopyableJSClassDiagnosticsTests.swift new file mode 100644 index 000000000..e9244d912 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/NoncopyableJSClassDiagnosticsTests.swift @@ -0,0 +1,145 @@ +import Testing + +@testable import BridgeJSCore +@testable import BridgeJSSkeleton + +@Suite struct NoncopyableJSClassDiagnosticsTests { + private static let objectDeclaration = """ + @JSClass struct NoncopyableObject: ~Copyable { + @JSFunction func value() throws(JSException) -> Int + } + + """ + + private func firstDiagnostic(for declaration: String) throws -> DiagnosticError { + var diagnostics: [DiagnosticError] = [] + do { + _ = try makeSkeleton(Self.objectDeclaration + declaration, moduleName: "App") + } catch let error as BridgeJSCoreDiagnosticError { + diagnostics = error.diagnostics.map(\.diagnostic) + } + return try #require(diagnostics.first, "Expected a diagnostic, but resolution succeeded") + } + + @Test(arguments: [ + "@JSClass struct NoncopyableObjectRoundtrip: ~Copyable { @JSFunction func take(_ objects: [NoncopyableObject]) throws(JSException) }", + "@JS func makeObjects() -> Array { fatalError() }", + "@JS func maybeObjects() -> [NoncopyableObject]? { fatalError() }", + ]) + func arrayOfWrappersMustBeUniqueArray(declaration: String) throws { + let diagnostic = try firstDiagnostic(for: declaration) + #expect(diagnostic.message == "An array of noncopyable '@JSClass' wrappers must be a 'UniqueArray'") + #expect(diagnostic.hint == "Use 'UniqueArray'") + } + + @Test func uniqueArrayOfCopyableElementsIsRejected() throws { + let diagnostic = try firstDiagnostic( + for: """ + @JSClass struct NoncopyableObjectRoundtrip: ~Copyable { + @JSFunction func takeAll(_ values: borrowing UniqueArray) throws(JSException) -> Int + } + """ + ) + #expect(diagnostic.message == "'UniqueArray' is supported only for noncopyable '@JSClass' wrapper elements") + #expect(diagnostic.hint == "Use '[Int]'") + } + + @Test func dictionaryOfWrappersIsRejected() throws { + let diagnostic = try firstDiagnostic( + for: "@JS func objects() -> [String: NoncopyableObject] { fatalError() }" + ) + #expect(diagnostic.message == "Dictionaries of noncopyable '@JSClass' wrappers are not supported") + #expect(diagnostic.hint == "Use JSObject values, or a copyable '@JSClass' wrapper") + } + + @Test func structFieldOfWrapperTypeIsRejected() throws { + let diagnostic = try firstDiagnostic( + for: """ + @JS struct Pair { + var name: String + var object: NoncopyableObject + } + """ + ) + #expect(diagnostic.message == "A '@JS struct' field cannot be a noncopyable '@JSClass' wrapper") + #expect(diagnostic.hint == "Use a JSObject field, or a copyable '@JSClass' wrapper") + } + + @Test func associatedValueOfWrapperTypeIsRejected() throws { + let diagnostic = try firstDiagnostic( + for: """ + @JS enum Choice { + case object(NoncopyableObject) + case nothing + } + """ + ) + #expect(diagnostic.message == "Unsupported associated value type: NoncopyableObject") + } + + @Test(arguments: [ + ( + "@JSClass struct NoncopyableObjectRoundtrip: ~Copyable { @JSGetter var child: NoncopyableObject }", + "Use '@JSGetterFunction func child() throws(JSException) -> NoncopyableObject'" + ), + ( + "@JSGetter(jsName: \"sharedObject\", from: .global) var child: NoncopyableObject", + "Use '@JSGetterFunction(jsName: \"sharedObject\", from: .global) func child() throws(JSException) -> NoncopyableObject'" + ), + ]) + func getterOfWrapperTypeIsRejected(declaration: String, hint: String) throws { + let diagnostic = try firstDiagnostic(for: declaration) + #expect(diagnostic.message == "@JSGetter cannot read a noncopyable '@JSClass' wrapper") + #expect(diagnostic.hint == hint) + } + + @Test(arguments: [ + ( + "@JSGetterFunction func child(_ index: Int) throws(JSException) -> NoncopyableObject", + "@JSGetterFunction function must have no parameters." + ), + ("@JSGetterFunction func child() throws(JSException)", "@JSGetterFunction function must have a return type."), + ]) + func getterFunctionNeedsNoParametersAndAReturnType(member: String, message: String) throws { + let diagnostic = try firstDiagnostic( + for: "@JSClass struct NoncopyableObjectRoundtrip: ~Copyable { \(member) }" + ) + #expect(diagnostic.message == message) + } + + @Test func staticGetterFunctionIsRejected() throws { + let diagnostic = try firstDiagnostic( + for: """ + @JSClass struct NoncopyableObjectRoundtrip: ~Copyable { + @JSGetterFunction static func shared() throws(JSException) -> NoncopyableObject + } + """ + ) + #expect( + diagnostic.message + == "@JSGetterFunction is not supported for static members. Use it only for instance members in @JSClass types." + ) + } + + @Test func borrowedWrappersAndUniqueArraysResolve() throws { + let skeleton = try makeSkeleton( + Self.objectDeclaration + """ + @JSClass struct NoncopyableObjectRoundtrip: ~Copyable { + @JSFunction func take(_ object: borrowing NoncopyableObject, _ objects: borrowing UniqueArray) throws(JSException) -> UniqueArray? + @JSGetterFunction func child() throws(JSException) -> NoncopyableObject + } + """, + moduleName: "App" + ) + let types = try #require(skeleton.imported?.children.first?.types) + #expect(types.map(\.name) == ["NoncopyableObject", "NoncopyableObjectRoundtrip"]) + #expect(types.map(\.isNoncopyable) == [true, true]) + let roundtrip = types[1] + let take = try #require(roundtrip.methods.first) + let objectType = BridgeType.jsUniqueObject("NoncopyableObject") + #expect(take.parameters.map(\.type) == [objectType, .array(objectType)]) + #expect(take.returnType == .nullable(.array(objectType), .null)) + #expect(roundtrip.getters.map(\.name) == ["child"]) + #expect(roundtrip.getters.map(\.type) == [objectType]) + } +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Availability.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Availability.json new file mode 100644 index 000000000..853933fbb --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Availability.json @@ -0,0 +1,635 @@ +{ + "exported" : { + "aliases" : [ + { + "availability" : [ + "@available(macOS 14.0, *)" + ], + "swiftCallName" : "Tag", + "underlying" : { + "swiftHeapObject" : { + "_0" : "TagReference" + } + } + } + ], + "classes" : [ + { + "availability" : [ + "@available(macOS 14.0, *)" + ], + "constructor" : { + "abiName" : "bjs_Counter_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "isFinal" : true, + "methods" : [ + + ], + "name" : "Counter", + "properties" : [ + + ], + "swiftCallName" : "Counter" + }, + { + "constructor" : { + "abiName" : "bjs_Library_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + + ], + "name" : "Library", + "properties" : [ + + ], + "swiftCallName" : "Library" + }, + { + "availability" : [ + "@available(macOS 14.0, *)" + ], + "constructor" : { + "abiName" : "bjs_TagReference_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "name", + "name" : "name", + "type" : { + "string" : { + + } + } + } + ] + }, + "isFinal" : true, + "methods" : [ + + ], + "name" : "TagReference", + "properties" : [ + + ], + "swiftCallName" : "TagReference" + } + ], + "enums" : [ + { + "availability" : [ + "@available(macOS 14.0, iOS 17.0, *)" + ], + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "north" + }, + { + "associatedValues" : [ + + ], + "name" : "south" + } + ], + "emitStyle" : "const", + "name" : "Direction", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Direction", + "tsFullPath" : "Direction" + }, + { + "availability" : [ + "@available(macOS 15.0, *)" + ], + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "low" + }, + { + "associatedValues" : [ + + ], + "name" : "high" + } + ], + "emitStyle" : "const", + "name" : "Level", + "rawType" : "String", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Level", + "tsFullPath" : "Level" + }, + { + "availability" : [ + "@available(macOS 14.0, *)" + ], + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "double" : { + + } + } + } + ], + "name" : "circle" + }, + { + "associatedValues" : [ + { + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "square" + } + ], + "emitStyle" : "const", + "name" : "Shape", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Shape", + "tsFullPath" : "Shape" + }, + { + "availability" : [ + "@available(macOS 14.0, *)" + ], + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "Geometry", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Geometry", + "tsFullPath" : "Geometry" + } + ], + "exposeToGlobal" : false, + "functions" : [ + { + "abiName" : "bjs_mix", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "mix", + "parameters" : [ + { + "label" : "_", + "name" : "point", + "type" : { + "swiftStruct" : { + "_0" : "Point" + } + } + }, + { + "label" : "_", + "name" : "body", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModule5PointV5LevelO_9DirectionO", + "moduleName" : "TestModule", + "parameters" : [ + { + "swiftStruct" : { + "_0" : "Point" + } + }, + { + "rawValueEnum" : { + "_0" : "Level", + "_1" : "String" + } + } + ], + "returnType" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_loadPoint", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "loadPoint", + "parameters" : [ + + ], + "returnType" : { + "swiftStruct" : { + "_0" : "Point" + } + } + }, + { + "abiName" : "bjs_countObjects", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "countObjects", + "parameters" : [ + { + "label" : "_", + "name" : "body", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModuleSa17NoncopyableObjectV5PointV_Si", + "moduleName" : "TestModule", + "parameters" : [ + { + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + }, + { + "swiftStruct" : { + "_0" : "Point" + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "protocols" : [ + { + "availability" : [ + "@available(macOS 14.0, *)" + ], + "methods" : [ + { + "abiName" : "bjs_Source_value", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "value", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "Source", + "properties" : [ + + ] + }, + { + "methods" : [ + { + "abiName" : "bjs_PointSource_point", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "point", + "parameters" : [ + + ], + "returnType" : { + "swiftStruct" : { + "_0" : "Point" + } + } + } + ], + "name" : "PointSource", + "properties" : [ + { + "isReadonly" : true, + "name" : "origin", + "type" : { + "swiftStruct" : { + "_0" : "Point" + } + } + } + ] + } + ], + "structs" : [ + { + "availability" : [ + "@available(macOS 14.0, *)" + ], + "methods" : [ + + ], + "name" : "Point", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "x", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "Point" + }, + { + "availability" : [ + "@available(macOS 14.0, *)" + ], + "methods" : [ + + ], + "name" : "Box", + "namespace" : [ + "Geometry" + ], + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "side", + "namespace" : [ + "Geometry" + ], + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "Geometry.Box" + }, + { + "availability" : [ + "@available(macOS 14.0, *)" + ], + "methods" : [ + + ], + "name" : "Shelf", + "namespace" : [ + "Library" + ], + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "label", + "namespace" : [ + "Library" + ], + "type" : { + "string" : { + + } + } + } + ], + "swiftCallName" : "Library.Shelf" + } + ] + }, + "imported" : { + "children" : [ + { + "functions" : [ + + ], + "types" : [ + { + "accessLevel" : "internal", + "availability" : [ + "@available(macOS 14.0, *)" + ], + "getters" : [ + + ], + "methods" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "id", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "Element", + "setters" : [ + + ], + "staticMethods" : [ + + ] + }, + { + "accessLevel" : "internal", + "getters" : [ + + ], + "methods" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "element", + "parameters" : [ + + ], + "returnType" : { + "jsObject" : { + "_0" : "Element" + } + } + } + ], + "name" : "Canvas", + "setters" : [ + + ], + "staticMethods" : [ + + ] + }, + { + "accessLevel" : "internal", + "getters" : [ + + ], + "isNoncopyable" : true, + "methods" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "id", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "NoncopyableObject", + "setters" : [ + + ], + "staticMethods" : [ + + ] + } + ] + } + ] + }, + "moduleName" : "TestModule", + "usedExternalModules" : [ + + ] +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Availability.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Availability.swift new file mode 100644 index 000000000..462354fae --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Availability.swift @@ -0,0 +1,780 @@ +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModule5PointV5LevelO_9DirectionO") +fileprivate func invoke_js_callback_TestModule_10TestModule5PointV5LevelO_9DirectionO_extern(_ callback: Int32, _ param1Word0: Int32, _ param1Word1: Int32, _ param1Word2: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_TestModule_10TestModule5PointV5LevelO_9DirectionO_extern(_ callback: Int32, _ param1Word0: Int32, _ param1Word1: Int32, _ param1Word2: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_TestModule_10TestModule5PointV5LevelO_9DirectionO(_ callback: Int32, _ param1Word0: Int32, _ param1Word1: Int32, _ param1Word2: Int32) -> Int32 { + return invoke_js_callback_TestModule_10TestModule5PointV5LevelO_9DirectionO_extern(callback, param1Word0, param1Word1, param1Word2) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModule5PointV5LevelO_9DirectionO") +fileprivate func make_swift_closure_TestModule_10TestModule5PointV5LevelO_9DirectionO_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModule5PointV5LevelO_9DirectionO_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_TestModule_10TestModule5PointV5LevelO_9DirectionO(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_TestModule_10TestModule5PointV5LevelO_9DirectionO_extern(boxPtr, file, line) +} + +@available(macOS 14.0, *) +@available(macOS 15.0, *) +@available(macOS 14.0, iOS 17.0, *) +private enum _BJS_Closure_10TestModule5PointV5LevelO_9DirectionO { + static func bridgeJSLift(_ callbackId: Int32) -> (Point, Level) -> Direction { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] (param0, param1) in + #if arch(wasm32) + let ret0 = param1.bridgeJSWithLoweredParameter { (param1Word0, param1Word1, param1Word2) in + let _ = param0.bridgeJSLowerParameter() + let callbackValue = callback.bridgeJSLowerParameter() + let ret = invoke_js_callback_TestModule_10TestModule5PointV5LevelO_9DirectionO(callbackValue, param1Word0, param1Word1, param1Word2) + return ret + } + let ret = ret0 + return Direction.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +@available(macOS 14.0, *) +@available(macOS 15.0, *) +@available(macOS 14.0, iOS 17.0, *) +extension JSTypedClosure where Signature == (Point, Level) -> Direction { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Point, Level) -> Direction) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModule5PointV5LevelO_9DirectionO, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModule5PointV5LevelO_9DirectionO") +@_cdecl("invoke_swift_closure_TestModule_10TestModule5PointV5LevelO_9DirectionO") +public func _invoke_swift_closure_TestModule_10TestModule5PointV5LevelO_9DirectionO(_ boxPtr: UnsafeMutableRawPointer, _ param1Bytes: Int32, _ param1Length: Int32) -> Int32 { + #if arch(wasm32) + let param1 = Level.bridgeJSLiftParameter(param1Bytes, param1Length) + let param0 = Point.bridgeJSLiftParameter() + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Point, Level) -> Direction>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let ret = closure(param0, param1) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSa17NoncopyableObjectV5PointV_Si") +fileprivate func invoke_js_callback_TestModule_10TestModuleSa17NoncopyableObjectV5PointV_Si_extern(_ callback: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_TestModule_10TestModuleSa17NoncopyableObjectV5PointV_Si_extern(_ callback: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_TestModule_10TestModuleSa17NoncopyableObjectV5PointV_Si(_ callback: Int32) -> Int32 { + return invoke_js_callback_TestModule_10TestModuleSa17NoncopyableObjectV5PointV_Si_extern(callback) +} +#endif + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV5PointV_Si") +fileprivate func make_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV5PointV_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV5PointV_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV5PointV_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV5PointV_Si_extern(boxPtr, file, line) +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +@available(macOS 14.0, *) +private enum _BJS_Closure_10TestModuleSa17NoncopyableObjectV5PointV_Si { + static func bridgeJSLift(_ callbackId: Int32) -> (borrowing UniqueArray, Point) -> Int { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] (param0, param1) in + #if arch(wasm32) + let _ = param1.bridgeJSLowerParameter() + let _ = param0.bridgeJSLowerParameter() + let callbackValue = callback.bridgeJSLowerParameter() + let ret = invoke_js_callback_TestModule_10TestModuleSa17NoncopyableObjectV5PointV_Si(callbackValue) + return Int.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +@available(macOS 14.0, *) +extension JSTypedClosure where Signature == (borrowing UniqueArray, Point) -> Int { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (borrowing UniqueArray, Point) -> Int) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV5PointV_Si, + body: body, + fileID: fileID, + line: line + ) + } +} +#endif + +#if compiler(>=6.4) +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV5PointV_Si") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV5PointV_Si") +public func _invoke_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV5PointV_Si(_ boxPtr: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let param1 = Point.bridgeJSLiftParameter() + let param0 = UniqueArray.bridgeJSStackPop() + let closure = Unmanaged<_BridgeJSTypedClosureBox<(borrowing UniqueArray, Point) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let ret = closure(param0, param1) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} +#endif + +@available(macOS 14.0, *) +extension Source where Self: _BridgedSwiftProtocolWrapper { + func value() -> Int { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = bjs_Source_value(jsObjectValue) + return Int.bridgeJSLiftReturn(ret) + } +} + +struct AnySource: Source, _BridgedSwiftProtocolWrapper { + let jsObject: JSObject + + static func bridgeJSLiftParameter(_ value: Int32) -> Self { + return AnySource(jsObject: JSObject(id: UInt32(bitPattern: value))) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_Source_value") +fileprivate func bjs_Source_value_extern(_ jsObject: Int32) -> Int32 +#else +fileprivate func bjs_Source_value_extern(_ jsObject: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Source_value(_ jsObject: Int32) -> Int32 { + return bjs_Source_value_extern(jsObject) +} + +extension PointSource where Self: _BridgedSwiftProtocolWrapper { + @available(macOS 14.0, *) + func point() -> Point { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + bjs_PointSource_point(jsObjectValue) + return Point.bridgeJSLiftReturn() + } + + @available(macOS 14.0, *) + var origin: Point { + get { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + bjs_PointSource_origin_get(jsObjectValue) + return Point.bridgeJSLiftReturn() + } + } +} + +struct AnyPointSource: PointSource, _BridgedSwiftProtocolWrapper { + let jsObject: JSObject + + static func bridgeJSLiftParameter(_ value: Int32) -> Self { + return AnyPointSource(jsObject: JSObject(id: UInt32(bitPattern: value))) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_PointSource_point") +fileprivate func bjs_PointSource_point_extern(_ jsObject: Int32) -> Void +#else +fileprivate func bjs_PointSource_point_extern(_ jsObject: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_PointSource_point(_ jsObject: Int32) -> Void { + return bjs_PointSource_point_extern(jsObject) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_PointSource_origin_get") +fileprivate func bjs_PointSource_origin_get_extern(_ jsObject: Int32) -> Void +#else +fileprivate func bjs_PointSource_origin_get_extern(_ jsObject: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_PointSource_origin_get(_ jsObject: Int32) -> Void { + return bjs_PointSource_origin_get_extern(jsObject) +} + +@available(macOS 14.0, iOS 17.0, *) +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 + default: + return nil + } + } + + @_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 { + switch self { + case .north: + return 0 + case .south: + return 1 + } + } +} + +@available(macOS 15.0, *) +extension Level: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { +} + +@available(macOS 14.0, *) +extension Shape: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> Shape { + switch caseId { + case 0: + return .circle(Double.bridgeJSStackPop()) + case 1: + return .square(Int.bridgeJSStackPop()) + default: + fatalError("Unknown Shape case ID: \(caseId)") + } + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { + switch self { + case .circle(let param0): + param0.bridgeJSStackPush() + return Int32(0) + case .square(let param0): + param0.bridgeJSStackPush() + return Int32(1) + } + } +} + +@available(macOS 14.0, *) +extension Point: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Point { + let x = Int.bridgeJSStackPop() + return Point(x: x) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.x.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() +} + +@available(macOS 14.0, *) +extension Geometry.Box: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Geometry.Box { + let side = Int.bridgeJSStackPop() + return Geometry.Box(side: side) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.side.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_Geometry_Box(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_Geometry_Box())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Geometry_Box") +fileprivate func _bjs_struct_lower_Geometry_Box_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_Geometry_Box_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_Geometry_Box(_ objectId: Int32) -> Void { + return _bjs_struct_lower_Geometry_Box_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_Geometry_Box") +fileprivate func _bjs_struct_lift_Geometry_Box_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_Geometry_Box_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_Geometry_Box() -> Int32 { + return _bjs_struct_lift_Geometry_Box_extern() +} + +@available(macOS 14.0, *) +extension Library.Shelf: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Library.Shelf { + let label = String.bridgeJSStackPop() + return Library.Shelf(label: label) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.label.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_Library_Shelf(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_Library_Shelf())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Library_Shelf") +fileprivate func _bjs_struct_lower_Library_Shelf_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_Library_Shelf_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_Library_Shelf(_ objectId: Int32) -> Void { + return _bjs_struct_lower_Library_Shelf_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_Library_Shelf") +fileprivate func _bjs_struct_lift_Library_Shelf_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_Library_Shelf_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_Library_Shelf() -> Int32 { + return _bjs_struct_lift_Library_Shelf_extern() +} + +@_expose(wasm, "bjs_mix") +@_cdecl("bjs_mix") +public func _bjs_mix(_ body: Int32) -> Int32 { + #if arch(wasm32) + let body = _BJS_Closure_10TestModule5PointV5LevelO_9DirectionO.bridgeJSLift(body) + let point = Point.bridgeJSLiftParameter() + let ret = mix(_: point, _: body) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_loadPoint") +@_cdecl("bjs_loadPoint") +public func _bjs_loadPoint() -> Int32 { + #if arch(wasm32) + return _bjs_makePromise(resolve: Promise_resolve_5PointV, reject: Promise_reject) { + return await loadPoint() + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if compiler(>=6.4) +@_expose(wasm, "bjs_countObjects") +@_cdecl("bjs_countObjects") +public func _bjs_countObjects(_ body: Int32) -> Int32 { + #if arch(wasm32) + let body = _BJS_Closure_10TestModuleSa17NoncopyableObjectV5PointV_Si.bridgeJSLift(body) + let ret = countObjects(_: body) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} +#endif + +@_expose(wasm, "bjs_Counter_init") +@_cdecl("bjs_Counter_init") +public func _bjs_Counter_init() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = Counter() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Counter_deinit") +@_cdecl("bjs_Counter_deinit") +public func _bjs_Counter_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@available(macOS 14.0, *) +extension Counter: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_Counter_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_Counter_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_Counter_wrap") +fileprivate func _bjs_Counter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_Counter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_Counter_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_Counter_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_Library_init") +@_cdecl("bjs_Library_init") +public func _bjs_Library_init() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = Library() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Library_deinit") +@_cdecl("bjs_Library_deinit") +public func _bjs_Library_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension Library: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_Library_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_Library_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_Library_wrap") +fileprivate func _bjs_Library_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_Library_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_Library_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_Library_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_TagReference_init") +@_cdecl("bjs_TagReference_init") +public func _bjs_TagReference_init(_ nameBytes: Int32, _ nameLength: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let name = String.bridgeJSLiftParameter(nameBytes, nameLength) + let ret = TagReference(name: name) + 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 +} + +@available(macOS 14.0, *) +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) +} + +@available(macOS 14.0, *) +extension Point: BridgedSwiftGenericBridgeable { + @_spi(BridgeJS) public static let bridgeJSTypeHandle = Point.bridgeJSMakeTypeHandle() +} + +@available(macOS 14.0, *) +extension Geometry.Box: BridgedSwiftGenericBridgeable { + @_spi(BridgeJS) public static let bridgeJSTypeHandle = Geometry.Box.bridgeJSMakeTypeHandle() +} + +@available(macOS 14.0, *) +extension Library.Shelf: BridgedSwiftGenericBridgeable { + @_spi(BridgeJS) public static let bridgeJSTypeHandle = Library.Shelf.bridgeJSMakeTypeHandle() +} + +@available(macOS 14.0, *) +extension Counter: BridgedSwiftGenericBridgeable { + @_spi(BridgeJS) public static let bridgeJSTypeHandle = Counter.bridgeJSMakeTypeHandle() +} + +@available(macOS 14.0, *) +extension TagReference: BridgedSwiftGenericBridgeable { + @_spi(BridgeJS) public static let bridgeJSTypeHandle = TagReference.bridgeJSMakeTypeHandle() +} + +@available(macOS 14.0, iOS 17.0, *) +extension Direction: BridgedSwiftGenericBridgeable { + @_spi(BridgeJS) public static let bridgeJSTypeHandle = Direction.bridgeJSMakeTypeHandle() +} + +@available(macOS 15.0, *) +extension Level: BridgedSwiftGenericBridgeable { + @_spi(BridgeJS) public static let bridgeJSTypeHandle = Level.bridgeJSMakeTypeHandle() +} + +@available(macOS 14.0, *) +extension Shape: BridgedSwiftGenericBridgeable { + @_spi(BridgeJS) public static let bridgeJSTypeHandle = Shape.bridgeJSMakeTypeHandle() +} + +@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 (valueKind, valuePayload1, valuePayload2) = value.bridgeJSLowerParameter() + let promiseValue = promise.bridgeJSLowerParameter() + promise_reject_TestModule(promiseValue, valueKind, valuePayload1, valuePayload2) + if let error = _swift_js_take_exception() { throw error } +} + +@available(macOS 14.0, *) +@JSFunction func Promise_resolve_5PointV(_ promise: JSObject, _ value: Point) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_TestModule_5PointV") +fileprivate func promise_resolve_TestModule_5PointV_extern(_ promise: Int32) -> Void +#else +fileprivate func promise_resolve_TestModule_5PointV_extern(_ promise: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func promise_resolve_TestModule_5PointV(_ promise: Int32) -> Void { + return promise_resolve_TestModule_5PointV_extern(promise) +} + +@available(macOS 14.0, *) +func _$Promise_resolve_5PointV(_ promise: JSObject, _ value: Point) throws(JSException) -> Void { + let _ = value.bridgeJSLowerParameter() + let promiseValue = promise.bridgeJSLowerParameter() + promise_resolve_TestModule_5PointV(promiseValue) + if let error = _swift_js_take_exception() { throw error } +} + +@available(macOS 14.0, *) +extension Tag: _BridgedSwiftAlias, _BridgedSwiftStackType {} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_Element_id") +fileprivate func bjs_Element_id_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_Element_id_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Element_id(_ self: Int32) -> Int32 { + return bjs_Element_id_extern(self) +} + +func _$Element_id(_ self: JSObject) throws(JSException) -> Int { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_Element_id(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_Canvas_element") +fileprivate func bjs_Canvas_element_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_Canvas_element_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Canvas_element(_ self: Int32) -> Int32 { + return bjs_Canvas_element_extern(self) +} + +@available(macOS 14.0, *) +func _$Canvas_element(_ self: JSObject) throws(JSException) -> Element { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_Canvas_element(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Element.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_NoncopyableObject_id") +fileprivate func bjs_NoncopyableObject_id_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObject_id_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObject_id(_ self: Int32) -> Int32 { + return bjs_NoncopyableObject_id_extern(self) +} + +func _$NoncopyableObject_id(_ self: borrowing JSUniqueRef) throws(JSException) -> Int { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObject_id(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "bjs_TestModule_register_type_handles") +fileprivate func _bjs_TestModule_register_type_handles_extern(_ base: UnsafePointer?, _ count: Int32) + +@_expose(wasm, "bjs_TestModule_register_type_handles") +public func _bjs_TestModule_register_type_handles() { + let typeIds: [Int32] = [ + Point.bridgeJSTypeID, + Geometry.Box.bridgeJSTypeID, + Library.Shelf.bridgeJSTypeID, + Counter.bridgeJSTypeID, + TagReference.bridgeJSTypeID, + Direction.bridgeJSTypeID, + Level.bridgeJSTypeID, + Shape.bridgeJSTypeID, + ] + typeIds.withUnsafeBufferPointer { buffer in + _bjs_TestModule_register_type_handles_extern(buffer.baseAddress, Int32(buffer.count)) + } +} +#endif \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/NoncopyableJSClass.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/NoncopyableJSClass.json new file mode 100644 index 000000000..37e41930c --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/NoncopyableJSClass.json @@ -0,0 +1,827 @@ +{ + "exported" : { + "aliases" : [ + + ], + "classes" : [ + { + "constructor" : { + "abiName" : "bjs_NoncopyableObjectBox_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "_", + "name" : "start", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "NoncopyableObjectBox", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "object", + "type" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + ], + "swiftCallName" : "NoncopyableObjectBox" + } + ], + "enums" : [ + + ], + "exposeToGlobal" : false, + "functions" : [ + { + "abiName" : "bjs_useNoncopyableObject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "useNoncopyableObject", + "parameters" : [ + { + "label" : "_", + "name" : "object", + "type" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_makeNoncopyableObjectInSwift", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeNoncopyableObjectInSwift", + "parameters" : [ + { + "label" : "_", + "name" : "start", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + }, + { + "abiName" : "bjs_findNoncopyableObjectInSwift", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "findNoncopyableObjectInSwift", + "parameters" : [ + { + "label" : "_", + "name" : "start", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + }, + "_1" : "null" + } + } + }, + { + "abiName" : "bjs_countNoncopyableObjects", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "countNoncopyableObjects", + "parameters" : [ + { + "label" : "_", + "name" : "objects", + "type" : { + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_countNoncopyableObjectsWith", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "countNoncopyableObjectsWith", + "parameters" : [ + { + "label" : "_", + "name" : "body", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModuleSa17NoncopyableObjectV_Si", + "moduleName" : "TestModule", + "parameters" : [ + { + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_loadNoncopyableObject", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "loadNoncopyableObject", + "parameters" : [ + { + "label" : "_", + "name" : "start", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + }, + { + "abiName" : "bjs_loadNoncopyableObjects", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "loadNoncopyableObjects", + "parameters" : [ + { + "label" : "_", + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + } + } + ], + "protocols" : [ + { + "methods" : [ + { + "abiName" : "bjs_NoncopyableObjectSource_name", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "name", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_NoncopyableObjectSource_makeAll", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAll", + "parameters" : [ + { + "label" : "_", + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + } + } + ], + "name" : "NoncopyableObjectSource", + "properties" : [ + + ] + } + ], + "structs" : [ + + ] + }, + "imported" : { + "children" : [ + { + "functions" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "makeNoncopyableObject", + "parameters" : [ + { + "name" : "start", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + ], + "types" : [ + { + "accessLevel" : "internal", + "constructor" : { + "accessLevel" : "internal", + "parameters" : [ + { + "name" : "start", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "getters" : [ + { + "accessLevel" : "internal", + "name" : "name", + "type" : { + "string" : { + + } + } + } + ], + "isNoncopyable" : true, + "methods" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "value", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "NoncopyableObject", + "setters" : [ + + ], + "staticMethods" : [ + + ] + }, + { + "accessLevel" : "internal", + "getters" : [ + { + "accessLevel" : "internal", + "name" : "child", + "type" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + ], + "isNoncopyable" : true, + "methods" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "take", + "parameters" : [ + { + "name" : "object", + "type" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "adopt", + "parameters" : [ + { + "name" : "object", + "type" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "make", + "parameters" : [ + { + "name" : "start", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "find", + "parameters" : [ + { + "name" : "start", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + }, + "_1" : "null" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "takeOptional", + "parameters" : [ + { + "name" : "object", + "type" : { + "nullable" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "forEach", + "parameters" : [ + { + "name" : "body", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModule17NoncopyableObjectV_y", + "moduleName" : "TestModule", + "parameters" : [ + { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + ], + "returnType" : { + "void" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "load", + "parameters" : [ + { + "name" : "start", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "takeAll", + "parameters" : [ + { + "name" : "objects", + "type" : { + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "makeAll", + "parameters" : [ + { + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "makeMaybe", + "parameters" : [ + { + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + }, + "_1" : "null" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "raw", + "parameters" : [ + { + "name" : "start", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "jsUniqueObject" : { + + } + } + } + ], + "name" : "NoncopyableObjectRoundtrip", + "setters" : [ + { + "accessLevel" : "internal", + "functionName" : "child_set", + "name" : "child", + "type" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + ], + "staticMethods" : [ + + ] + } + ] + } + ] + }, + "moduleName" : "TestModule", + "usedExternalModules" : [ + + ] +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/NoncopyableJSClass.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/NoncopyableJSClass.swift new file mode 100644 index 000000000..eddda0b25 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/NoncopyableJSClass.swift @@ -0,0 +1,928 @@ +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModule17NoncopyableObjectV_y") +fileprivate func invoke_js_callback_TestModule_10TestModule17NoncopyableObjectV_y_extern(_ callback: Int32, _ param0: Int32) -> Void +#else +fileprivate func invoke_js_callback_TestModule_10TestModule17NoncopyableObjectV_y_extern(_ callback: Int32, _ param0: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_TestModule_10TestModule17NoncopyableObjectV_y(_ callback: Int32, _ param0: Int32) -> Void { + return invoke_js_callback_TestModule_10TestModule17NoncopyableObjectV_y_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModule17NoncopyableObjectV_y") +fileprivate func make_swift_closure_TestModule_10TestModule17NoncopyableObjectV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModule17NoncopyableObjectV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_TestModule_10TestModule17NoncopyableObjectV_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_TestModule_10TestModule17NoncopyableObjectV_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_10TestModule17NoncopyableObjectV_y { + static func bridgeJSLift(_ callbackId: Int32) -> (borrowing NoncopyableObject) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let param0Value = param0.bridgeJSLowerParameter() + let callbackValue = callback.bridgeJSLowerParameter() + invoke_js_callback_TestModule_10TestModule17NoncopyableObjectV_y(callbackValue, param0Value) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (borrowing NoncopyableObject) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (borrowing NoncopyableObject) -> Void) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModule17NoncopyableObjectV_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModule17NoncopyableObjectV_y") +@_cdecl("invoke_swift_closure_TestModule_10TestModule17NoncopyableObjectV_y") +public func _invoke_swift_closure_TestModule_10TestModule17NoncopyableObjectV_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { + #if arch(wasm32) + let param0 = NoncopyableObject.bridgeJSLiftParameter(param0) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(borrowing NoncopyableObject) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(param0) + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSa17NoncopyableObjectV_Si") +fileprivate func invoke_js_callback_TestModule_10TestModuleSa17NoncopyableObjectV_Si_extern(_ callback: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_TestModule_10TestModuleSa17NoncopyableObjectV_Si_extern(_ callback: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_TestModule_10TestModuleSa17NoncopyableObjectV_Si(_ callback: Int32) -> Int32 { + return invoke_js_callback_TestModule_10TestModuleSa17NoncopyableObjectV_Si_extern(callback) +} +#endif + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV_Si") +fileprivate func make_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV_Si_extern(boxPtr, file, line) +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +private enum _BJS_Closure_10TestModuleSa17NoncopyableObjectV_Si { + static func bridgeJSLift(_ callbackId: Int32) -> (borrowing UniqueArray) -> Int { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let _ = param0.bridgeJSLowerParameter() + let callbackValue = callback.bridgeJSLowerParameter() + let ret = invoke_js_callback_TestModule_10TestModuleSa17NoncopyableObjectV_Si(callbackValue) + return Int.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +extension JSTypedClosure where Signature == (borrowing UniqueArray) -> Int { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (borrowing UniqueArray) -> Int) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV_Si, + body: body, + fileID: fileID, + line: line + ) + } +} +#endif + +#if compiler(>=6.4) +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV_Si") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV_Si") +public func _invoke_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV_Si(_ boxPtr: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let param0 = UniqueArray.bridgeJSStackPop() + let closure = Unmanaged<_BridgeJSTypedClosureBox<(borrowing UniqueArray) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let ret = closure(param0) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModules17NoncopyableObjectV_y") +fileprivate func invoke_js_callback_TestModule_10TestModules17NoncopyableObjectV_y_extern(_ callback: Int32, _ param0: Int32) -> Void +#else +fileprivate func invoke_js_callback_TestModule_10TestModules17NoncopyableObjectV_y_extern(_ callback: Int32, _ param0: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_TestModule_10TestModules17NoncopyableObjectV_y(_ callback: Int32, _ param0: Int32) -> Void { + return invoke_js_callback_TestModule_10TestModules17NoncopyableObjectV_y_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModules17NoncopyableObjectV_y") +fileprivate func make_swift_closure_TestModule_10TestModules17NoncopyableObjectV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModules17NoncopyableObjectV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_TestModule_10TestModules17NoncopyableObjectV_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_TestModule_10TestModules17NoncopyableObjectV_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_10TestModules17NoncopyableObjectV_y { + static func bridgeJSLift(_ callbackId: Int32) -> (consuming sending NoncopyableObject) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let param0Value = param0.bridgeJSLowerParameter() + let callbackValue = callback.bridgeJSLowerParameter() + invoke_js_callback_TestModule_10TestModules17NoncopyableObjectV_y(callbackValue, param0Value) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (consuming sending NoncopyableObject) -> Void { + static func sending(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (consuming sending NoncopyableObject) -> Void) -> Self { + Self( + makeClosure: make_swift_closure_TestModule_10TestModules17NoncopyableObjectV_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModules17NoncopyableObjectV_y") +@_cdecl("invoke_swift_closure_TestModule_10TestModules17NoncopyableObjectV_y") +public func _invoke_swift_closure_TestModule_10TestModules17NoncopyableObjectV_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { + #if arch(wasm32) + let param0 = NoncopyableObject.bridgeJSLiftParameter(param0) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(consuming sending NoncopyableObject) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(param0) + #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 (param0Kind, param0Payload1, param0Payload2) = param0.bridgeJSLowerParameter() + let callbackValue = callback.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 { + static func sending(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending JSValue) -> Void) -> Self { + Self( + 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 param0 = JSValue.bridgeJSLiftParameter(param0Kind, param0Payload1, param0Payload2) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending JSValue) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(param0) + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension NoncopyableObjectSource where Self: _BridgedSwiftProtocolWrapper { + func name() -> String { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObjectSource_name(jsObjectValue) + return String.bridgeJSLiftReturn(ret) + } + + #if compiler(>=6.4) + @available(anyAppleOS 27.0, *) + func makeAll(_ count: Int) -> UniqueArray { + let countValue = count.bridgeJSLowerParameter() + let jsObjectValue = jsObject.bridgeJSLowerParameter() + bjs_NoncopyableObjectSource_makeAll(jsObjectValue, countValue) + return UniqueArray.bridgeJSLiftReturn() + } + #endif +} + +struct AnyNoncopyableObjectSource: NoncopyableObjectSource, _BridgedSwiftProtocolWrapper { + let jsObject: JSObject + + static func bridgeJSLiftParameter(_ value: Int32) -> Self { + return AnyNoncopyableObjectSource(jsObject: JSObject(id: UInt32(bitPattern: value))) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_NoncopyableObjectSource_name") +fileprivate func bjs_NoncopyableObjectSource_name_extern(_ jsObject: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObjectSource_name_extern(_ jsObject: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectSource_name(_ jsObject: Int32) -> Int32 { + return bjs_NoncopyableObjectSource_name_extern(jsObject) +} + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_NoncopyableObjectSource_makeAll") +fileprivate func bjs_NoncopyableObjectSource_makeAll_extern(_ jsObject: Int32, _ count: Int32) -> Void +#else +fileprivate func bjs_NoncopyableObjectSource_makeAll_extern(_ jsObject: Int32, _ count: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectSource_makeAll(_ jsObject: Int32, _ count: Int32) -> Void { + return bjs_NoncopyableObjectSource_makeAll_extern(jsObject, count) +} +#endif + +@_expose(wasm, "bjs_useNoncopyableObject") +@_cdecl("bjs_useNoncopyableObject") +public func _bjs_useNoncopyableObject(_ object: Int32) -> Int32 { + #if arch(wasm32) + let object = NoncopyableObject.bridgeJSLiftParameter(object) + let ret = useNoncopyableObject(_: object) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeNoncopyableObjectInSwift") +@_cdecl("bjs_makeNoncopyableObjectInSwift") +public func _bjs_makeNoncopyableObjectInSwift(_ start: Int32) -> Int32 { + #if arch(wasm32) + let start = Int.bridgeJSLiftParameter(start) + let ret = makeNoncopyableObjectInSwift(_: start) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_findNoncopyableObjectInSwift") +@_cdecl("bjs_findNoncopyableObjectInSwift") +public func _bjs_findNoncopyableObjectInSwift(_ start: Int32) -> Void { + #if arch(wasm32) + let start = Int.bridgeJSLiftParameter(start) + let ret = findNoncopyableObjectInSwift(_: start) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if compiler(>=6.4) +@_expose(wasm, "bjs_countNoncopyableObjects") +@_cdecl("bjs_countNoncopyableObjects") +public func _bjs_countNoncopyableObjects() -> Int32 { + #if arch(wasm32) + let objects = UniqueArray.bridgeJSStackPop() + let ret = countNoncopyableObjects(_: objects) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} +#endif + +#if compiler(>=6.4) +@_expose(wasm, "bjs_countNoncopyableObjectsWith") +@_cdecl("bjs_countNoncopyableObjectsWith") +public func _bjs_countNoncopyableObjectsWith(_ body: Int32) -> Int32 { + #if arch(wasm32) + let body = _BJS_Closure_10TestModuleSa17NoncopyableObjectV_Si.bridgeJSLift(body) + let ret = countNoncopyableObjectsWith(_: body) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} +#endif + +@_expose(wasm, "bjs_loadNoncopyableObject") +@_cdecl("bjs_loadNoncopyableObject") +public func _bjs_loadNoncopyableObject(_ start: Int32) -> Int32 { + #if arch(wasm32) + let start = Int.bridgeJSLiftParameter(start) + return _bjs_makePromise(resolve: Promise_resolve_17NoncopyableObjectV, reject: Promise_reject) { + return await loadNoncopyableObject(_: start) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if compiler(>=6.4) +@_expose(wasm, "bjs_loadNoncopyableObjects") +@_cdecl("bjs_loadNoncopyableObjects") +public func _bjs_loadNoncopyableObjects(_ count: Int32) -> Int32 { + #if arch(wasm32) + let count = Int.bridgeJSLiftParameter(count) + return _bjs_makePromise(resolve: Promise_resolve_Sa17NoncopyableObjectV, reject: Promise_reject) { + return await loadNoncopyableObjects(_: count) + } + #else + fatalError("Only available on WebAssembly") + #endif +} +#endif + +@_expose(wasm, "bjs_NoncopyableObjectBox_init") +@_cdecl("bjs_NoncopyableObjectBox_init") +public func _bjs_NoncopyableObjectBox_init(_ start: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let start = Int.bridgeJSLiftParameter(start) + let ret = NoncopyableObjectBox(_: start) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_NoncopyableObjectBox_object_get") +@_cdecl("bjs_NoncopyableObjectBox_object_get") +public func _bjs_NoncopyableObjectBox_object_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let _self = NoncopyableObjectBox.bridgeJSLiftParameter(_self) + let ret = NoncopyableObject.bridgeJSRetaining(_self.object) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_NoncopyableObjectBox_object_set") +@_cdecl("bjs_NoncopyableObjectBox_object_set") +public func _bjs_NoncopyableObjectBox_object_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + let value = NoncopyableObject.bridgeJSLiftParameter(value) + let _self = NoncopyableObjectBox.bridgeJSLiftParameter(_self) + _self.object = value + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_NoncopyableObjectBox_deinit") +@_cdecl("bjs_NoncopyableObjectBox_deinit") +public func _bjs_NoncopyableObjectBox_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension NoncopyableObjectBox: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_NoncopyableObjectBox_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_NoncopyableObjectBox_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_NoncopyableObjectBox_wrap") +fileprivate func _bjs_NoncopyableObjectBox_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_NoncopyableObjectBox_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_NoncopyableObjectBox_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_NoncopyableObjectBox_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 (valueKind, valuePayload1, valuePayload2) = value.bridgeJSLowerParameter() + let promiseValue = promise.bridgeJSLowerParameter() + promise_reject_TestModule(promiseValue, valueKind, valuePayload1, valuePayload2) + if let error = _swift_js_take_exception() { throw error } +} + +@JSFunction func Promise_resolve_17NoncopyableObjectV(_ promise: JSObject, _ value: borrowing NoncopyableObject) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_TestModule_17NoncopyableObjectV") +fileprivate func promise_resolve_TestModule_17NoncopyableObjectV_extern(_ promise: Int32, _ value: Int32) -> Void +#else +fileprivate func promise_resolve_TestModule_17NoncopyableObjectV_extern(_ promise: Int32, _ value: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func promise_resolve_TestModule_17NoncopyableObjectV(_ promise: Int32, _ value: Int32) -> Void { + return promise_resolve_TestModule_17NoncopyableObjectV_extern(promise, value) +} + +func _$Promise_resolve_17NoncopyableObjectV(_ promise: JSObject, _ value: borrowing NoncopyableObject) throws(JSException) -> Void { + let valueValue = value.bridgeJSLowerParameter() + let promiseValue = promise.bridgeJSLowerParameter() + promise_resolve_TestModule_17NoncopyableObjectV(promiseValue, valueValue) + if let error = _swift_js_take_exception() { throw error } +} + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +@JSFunction func Promise_resolve_Sa17NoncopyableObjectV(_ promise: JSObject, _ value: borrowing UniqueArray) throws(JSException) +#endif + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_TestModule_Sa17NoncopyableObjectV") +fileprivate func promise_resolve_TestModule_Sa17NoncopyableObjectV_extern(_ promise: Int32) -> Void +#else +fileprivate func promise_resolve_TestModule_Sa17NoncopyableObjectV_extern(_ promise: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func promise_resolve_TestModule_Sa17NoncopyableObjectV(_ promise: Int32) -> Void { + return promise_resolve_TestModule_Sa17NoncopyableObjectV_extern(promise) +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +func _$Promise_resolve_Sa17NoncopyableObjectV(_ promise: JSObject, _ value: borrowing UniqueArray) throws(JSException) -> Void { + let _ = value.bridgeJSLowerParameter() + let promiseValue = promise.bridgeJSLowerParameter() + promise_resolve_TestModule_Sa17NoncopyableObjectV(promiseValue) + if let error = _swift_js_take_exception() { throw error } +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_makeNoncopyableObject") +fileprivate func bjs_makeNoncopyableObject_extern(_ start: Int32) -> Int32 +#else +fileprivate func bjs_makeNoncopyableObject_extern(_ start: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_makeNoncopyableObject(_ start: Int32) -> Int32 { + return bjs_makeNoncopyableObject_extern(start) +} + +func _$makeNoncopyableObject(_ start: Int) throws(JSException) -> NoncopyableObject { + let startValue = start.bridgeJSLowerParameter() + let ret = bjs_makeNoncopyableObject(startValue) + if let error = _swift_js_take_exception() { + throw error + } + return NoncopyableObject.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_NoncopyableObject_init") +fileprivate func bjs_NoncopyableObject_init_extern(_ start: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObject_init_extern(_ start: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObject_init(_ start: Int32) -> Int32 { + return bjs_NoncopyableObject_init_extern(start) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_NoncopyableObject_name_get") +fileprivate func bjs_NoncopyableObject_name_get_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObject_name_get_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObject_name_get(_ self: Int32) -> Int32 { + return bjs_NoncopyableObject_name_get_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_NoncopyableObject_value") +fileprivate func bjs_NoncopyableObject_value_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObject_value_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObject_value(_ self: Int32) -> Int32 { + return bjs_NoncopyableObject_value_extern(self) +} + +func _$NoncopyableObject_init(_ start: Int) throws(JSException) -> JSUniqueRef { + let startValue = start.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObject_init(startValue) + if let error = _swift_js_take_exception() { + throw error + } + return JSUniqueRef.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableObject_name_get(_ self: borrowing JSUniqueRef) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObject_name_get(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableObject_value(_ self: borrowing JSUniqueRef) throws(JSException) -> Int { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObject_value(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_NoncopyableObjectRoundtrip_child_get") +fileprivate func bjs_NoncopyableObjectRoundtrip_child_get_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_child_get_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_child_get(_ self: Int32) -> Int32 { + return bjs_NoncopyableObjectRoundtrip_child_get_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_NoncopyableObjectRoundtrip_child_set") +fileprivate func bjs_NoncopyableObjectRoundtrip_child_set_extern(_ self: Int32, _ newValue: Int32) -> Void +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_child_set_extern(_ self: Int32, _ newValue: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_child_set(_ self: Int32, _ newValue: Int32) -> Void { + return bjs_NoncopyableObjectRoundtrip_child_set_extern(self, newValue) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_NoncopyableObjectRoundtrip_take") +fileprivate func bjs_NoncopyableObjectRoundtrip_take_extern(_ self: Int32, _ object: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_take_extern(_ self: Int32, _ object: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_take(_ self: Int32, _ object: Int32) -> Int32 { + return bjs_NoncopyableObjectRoundtrip_take_extern(self, object) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_NoncopyableObjectRoundtrip_adopt") +fileprivate func bjs_NoncopyableObjectRoundtrip_adopt_extern(_ self: Int32, _ object: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_adopt_extern(_ self: Int32, _ object: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_adopt(_ self: Int32, _ object: Int32) -> Int32 { + return bjs_NoncopyableObjectRoundtrip_adopt_extern(self, object) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_NoncopyableObjectRoundtrip_make") +fileprivate func bjs_NoncopyableObjectRoundtrip_make_extern(_ self: Int32, _ start: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_make_extern(_ self: Int32, _ start: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_make(_ self: Int32, _ start: Int32) -> Int32 { + return bjs_NoncopyableObjectRoundtrip_make_extern(self, start) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_NoncopyableObjectRoundtrip_find") +fileprivate func bjs_NoncopyableObjectRoundtrip_find_extern(_ self: Int32, _ start: Int32) -> Void +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_find_extern(_ self: Int32, _ start: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_find(_ self: Int32, _ start: Int32) -> Void { + return bjs_NoncopyableObjectRoundtrip_find_extern(self, start) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_NoncopyableObjectRoundtrip_takeOptional") +fileprivate func bjs_NoncopyableObjectRoundtrip_takeOptional_extern(_ self: Int32, _ objectIsSome: Int32, _ objectValue: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_takeOptional_extern(_ self: Int32, _ objectIsSome: Int32, _ objectValue: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_takeOptional(_ self: Int32, _ objectIsSome: Int32, _ objectValue: Int32) -> Int32 { + return bjs_NoncopyableObjectRoundtrip_takeOptional_extern(self, objectIsSome, objectValue) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_NoncopyableObjectRoundtrip_forEach") +fileprivate func bjs_NoncopyableObjectRoundtrip_forEach_extern(_ self: Int32, _ body: Int32) -> Void +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_forEach_extern(_ self: Int32, _ body: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_forEach(_ self: Int32, _ body: Int32) -> Void { + return bjs_NoncopyableObjectRoundtrip_forEach_extern(self, body) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_NoncopyableObjectRoundtrip_load") +fileprivate func bjs_NoncopyableObjectRoundtrip_load_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32, _ start: Int32) -> Void +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_load_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32, _ start: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_load(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32, _ start: Int32) -> Void { + return bjs_NoncopyableObjectRoundtrip_load_extern(resolveRef, rejectRef, self, start) +} + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_NoncopyableObjectRoundtrip_takeAll") +fileprivate func bjs_NoncopyableObjectRoundtrip_takeAll_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_takeAll_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_takeAll(_ self: Int32) -> Int32 { + return bjs_NoncopyableObjectRoundtrip_takeAll_extern(self) +} +#endif + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_NoncopyableObjectRoundtrip_makeAll") +fileprivate func bjs_NoncopyableObjectRoundtrip_makeAll_extern(_ self: Int32, _ count: Int32) -> Void +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_makeAll_extern(_ self: Int32, _ count: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_makeAll(_ self: Int32, _ count: Int32) -> Void { + return bjs_NoncopyableObjectRoundtrip_makeAll_extern(self, count) +} +#endif + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_NoncopyableObjectRoundtrip_makeMaybe") +fileprivate func bjs_NoncopyableObjectRoundtrip_makeMaybe_extern(_ self: Int32, _ count: Int32) -> Void +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_makeMaybe_extern(_ self: Int32, _ count: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_makeMaybe(_ self: Int32, _ count: Int32) -> Void { + return bjs_NoncopyableObjectRoundtrip_makeMaybe_extern(self, count) +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_NoncopyableObjectRoundtrip_raw") +fileprivate func bjs_NoncopyableObjectRoundtrip_raw_extern(_ self: Int32, _ start: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_raw_extern(_ self: Int32, _ start: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_raw(_ self: Int32, _ start: Int32) -> Int32 { + return bjs_NoncopyableObjectRoundtrip_raw_extern(self, start) +} + +func _$NoncopyableObjectRoundtrip_child_get(_ self: borrowing JSUniqueRef) throws(JSException) -> NoncopyableObject { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObjectRoundtrip_child_get(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return NoncopyableObject.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableObjectRoundtrip_child_set(_ self: borrowing JSUniqueRef, _ newValue: borrowing NoncopyableObject) throws(JSException) -> Void { + let newValueValue = newValue.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableObjectRoundtrip_child_set(selfValue, newValueValue) + if let error = _swift_js_take_exception() { + throw error + } +} + +func _$NoncopyableObjectRoundtrip_take(_ self: borrowing JSUniqueRef, _ object: borrowing NoncopyableObject) throws(JSException) -> Int { + let objectValue = object.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObjectRoundtrip_take(selfValue, objectValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableObjectRoundtrip_adopt(_ self: borrowing JSUniqueRef, _ object: borrowing NoncopyableObject) throws(JSException) -> Int { + let objectValue = object.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObjectRoundtrip_adopt(selfValue, objectValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableObjectRoundtrip_make(_ self: borrowing JSUniqueRef, _ start: Int) throws(JSException) -> NoncopyableObject { + let startValue = start.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObjectRoundtrip_make(selfValue, startValue) + if let error = _swift_js_take_exception() { + throw error + } + return NoncopyableObject.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableObjectRoundtrip_find(_ self: borrowing JSUniqueRef, _ start: Int) throws(JSException) -> Optional { + let startValue = start.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableObjectRoundtrip_find(selfValue, startValue) + if let error = _swift_js_take_exception() { + throw error + } + return Optional.bridgeJSLiftReturn() +} + +func _$NoncopyableObjectRoundtrip_takeOptional(_ self: borrowing JSUniqueRef, _ object: borrowing Optional) throws(JSException) -> Int { + let (objectIsSome, objectValue) = object.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObjectRoundtrip_takeOptional(selfValue, objectIsSome, objectValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableObjectRoundtrip_forEach(_ self: borrowing JSUniqueRef, _ body: JSTypedClosure<(borrowing NoncopyableObject) -> Void>) throws(JSException) -> Void { + let bodyFuncRef = body.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableObjectRoundtrip_forEach(selfValue, bodyFuncRef) + if let error = _swift_js_take_exception() { + throw error + } +} + +func _$NoncopyableObjectRoundtrip_load(_ self: borrowing JSUniqueRef, _ start: Int) async throws(JSException) -> NoncopyableObject { + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(consuming sending NoncopyableObject) -> Void>.sending($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>.sending($0) + }) { resolveRef, rejectRef in + let startValue = start.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableObjectRoundtrip_load(resolveRef, rejectRef, selfValue, startValue) + } + return resolved +} + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +func _$NoncopyableObjectRoundtrip_takeAll(_ self: borrowing JSUniqueRef, _ objects: borrowing UniqueArray) throws(JSException) -> Int { + let _ = objects.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObjectRoundtrip_takeAll(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +func _$NoncopyableObjectRoundtrip_makeAll(_ self: borrowing JSUniqueRef, _ count: Int) throws(JSException) -> UniqueArray { + let countValue = count.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableObjectRoundtrip_makeAll(selfValue, countValue) + if let error = _swift_js_take_exception() { + throw error + } + return UniqueArray.bridgeJSLiftReturn() +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +func _$NoncopyableObjectRoundtrip_makeMaybe(_ self: borrowing JSUniqueRef, _ count: Int) throws(JSException) -> Optional> { + let countValue = count.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableObjectRoundtrip_makeMaybe(selfValue, countValue) + if let error = _swift_js_take_exception() { + throw error + } + return Optional>.bridgeJSLiftReturn() +} +#endif + +func _$NoncopyableObjectRoundtrip_raw(_ self: borrowing JSUniqueRef, _ start: Int) throws(JSException) -> JSUniqueRef { + let startValue = start.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObjectRoundtrip_raw(selfValue, startValue) + if let error = _swift_js_take_exception() { + throw error + } + return JSUniqueRef.bridgeJSLiftReturn(ret) +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ProtocolConditionalCompilation.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ProtocolConditionalCompilation.json new file mode 100644 index 000000000..f686585c6 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ProtocolConditionalCompilation.json @@ -0,0 +1,112 @@ +{ + "exported" : { + "aliases" : [ + + ], + "classes" : [ + + ], + "enums" : [ + + ], + "exposeToGlobal" : false, + "functions" : [ + + ], + "protocols" : [ + { + "methods" : [ + { + "abiName" : "bjs_Logger_log", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "log", + "parameters" : [ + { + "label" : "_", + "name" : "message", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_Logger_trace", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "trace", + "parameters" : [ + { + "label" : "_", + "name" : "message", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_Logger_flush", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "flush", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + } + ], + "name" : "Logger", + "properties" : [ + { + "isReadonly" : false, + "name" : "verbosity", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + } + ], + "structs" : [ + + ] + }, + "moduleName" : "TestModule", + "usedExternalModules" : [ + + ] +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ProtocolConditionalCompilation.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ProtocolConditionalCompilation.swift new file mode 100644 index 000000000..4d653d6c4 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ProtocolConditionalCompilation.swift @@ -0,0 +1,101 @@ +extension Logger where Self: _BridgedSwiftProtocolWrapper { + func log(_ message: String) -> Void { + message.bridgeJSWithLoweredParameter { (messageWord0, messageWord1, messageWord2) in + let jsObjectValue = jsObject.bridgeJSLowerParameter() + bjs_Logger_log(jsObjectValue, messageWord0, messageWord1, messageWord2) + } + } + + func trace(_ message: String) -> Void { + message.bridgeJSWithLoweredParameter { (messageWord0, messageWord1, messageWord2) in + let jsObjectValue = jsObject.bridgeJSLowerParameter() + bjs_Logger_trace(jsObjectValue, messageWord0, messageWord1, messageWord2) + } + } + + func flush() -> Void { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + bjs_Logger_flush(jsObjectValue) + } + + var verbosity: Int { + get { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = bjs_Logger_verbosity_get(jsObjectValue) + return Int.bridgeJSLiftReturn(ret) + } + set { + let newValueValue = newValue.bridgeJSLowerParameter() + let jsObjectValue = jsObject.bridgeJSLowerParameter() + bjs_Logger_verbosity_set(jsObjectValue, newValueValue) + } + } +} + +struct AnyLogger: Logger, _BridgedSwiftProtocolWrapper { + let jsObject: JSObject + + static func bridgeJSLiftParameter(_ value: Int32) -> Self { + return AnyLogger(jsObject: JSObject(id: UInt32(bitPattern: value))) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_Logger_log") +fileprivate func bjs_Logger_log_extern(_ jsObject: Int32, _ messageWord0: Int32, _ messageWord1: Int32, _ messageWord2: Int32) -> Void +#else +fileprivate func bjs_Logger_log_extern(_ jsObject: Int32, _ messageWord0: Int32, _ messageWord1: Int32, _ messageWord2: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Logger_log(_ jsObject: Int32, _ messageWord0: Int32, _ messageWord1: Int32, _ messageWord2: Int32) -> Void { + return bjs_Logger_log_extern(jsObject, messageWord0, messageWord1, messageWord2) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_Logger_trace") +fileprivate func bjs_Logger_trace_extern(_ jsObject: Int32, _ messageWord0: Int32, _ messageWord1: Int32, _ messageWord2: Int32) -> Void +#else +fileprivate func bjs_Logger_trace_extern(_ jsObject: Int32, _ messageWord0: Int32, _ messageWord1: Int32, _ messageWord2: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Logger_trace(_ jsObject: Int32, _ messageWord0: Int32, _ messageWord1: Int32, _ messageWord2: Int32) -> Void { + return bjs_Logger_trace_extern(jsObject, messageWord0, messageWord1, messageWord2) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_Logger_flush") +fileprivate func bjs_Logger_flush_extern(_ jsObject: Int32) -> Void +#else +fileprivate func bjs_Logger_flush_extern(_ jsObject: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Logger_flush(_ jsObject: Int32) -> Void { + return bjs_Logger_flush_extern(jsObject) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_Logger_verbosity_get") +fileprivate func bjs_Logger_verbosity_get_extern(_ jsObject: Int32) -> Int32 +#else +fileprivate func bjs_Logger_verbosity_get_extern(_ jsObject: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Logger_verbosity_get(_ jsObject: Int32) -> Int32 { + return bjs_Logger_verbosity_get_extern(jsObject) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_Logger_verbosity_set") +fileprivate func bjs_Logger_verbosity_set_extern(_ jsObject: Int32, _ newValue: Int32) -> Void +#else +fileprivate func bjs_Logger_verbosity_set_extern(_ jsObject: Int32, _ newValue: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Logger_verbosity_set(_ jsObject: Int32, _ newValue: Int32) -> Void { + return bjs_Logger_verbosity_set_extern(jsObject, newValue) +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Availability.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Availability.d.ts new file mode 100644 index 000000000..4fcc2aaad --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Availability.d.ts @@ -0,0 +1,104 @@ +// 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 Source { + value(): number; +} + +export interface PointSource { + point(): Point; + readonly origin: Point; +} + +export const DirectionValues: { + readonly North: 0; + readonly South: 1; +}; +export type DirectionTag = typeof DirectionValues[keyof typeof DirectionValues]; + +export const LevelValues: { + readonly Low: "low"; + readonly High: "high"; +}; +export type LevelTag = typeof LevelValues[keyof typeof LevelValues]; + +export const ShapeValues: { + readonly Tag: { + readonly Circle: 0; + readonly Square: 1; + }; +}; + +export type ShapeTag = + { tag: typeof ShapeValues.Tag.Circle; param0: number } | { tag: typeof ShapeValues.Tag.Square; param0: number } + +export interface Point { + x: number; +} +export type DirectionObject = typeof DirectionValues; + +export type LevelObject = typeof LevelValues; + +export type ShapeObject = typeof ShapeValues; + +export namespace Geometry { + export interface Box { + side: number; + } +} +export namespace Library { + export interface Shelf { + label: 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 Counter extends SwiftHeapObject { +} +export interface Library extends SwiftHeapObject { +} +export interface TagReference extends SwiftHeapObject { +} +export interface Element { + id(): number; +} +export interface Canvas { + element(): Element; +} +export interface NoncopyableObject { + id(): number; +} +export type Exports = { + mix(point: Point, body: (arg0: Point, arg1: LevelTag) => DirectionTag): number; + loadPoint(): Promise; + countObjects(body: (arg0: NoncopyableObject[], arg1: Point) => number): number; + Direction: DirectionObject + Level: LevelObject + Shape: ShapeObject + Counter: { + new(): Counter; + }, + Library: { + new(): Library; + }, + TagReference: { + new(name: string): TagReference; + }, +} +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/Availability.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Availability.js new file mode 100644 index 000000000..7cb67aa11 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Availability.js @@ -0,0 +1,1108 @@ +// 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 DirectionValues = { + North: 0, + South: 1, +}; + +export const LevelValues = { + Low: "low", + High: "high", +}; + +export const ShapeValues = { + Tag: { + Circle: 0, + Square: 1, + }, +}; +export async function createInstantiator(options, swift) { + let instance; + let memory; + let setException; + let decodeString; + let decodeUTF8; + const immortalStrings = new Map(); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); + 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_arrayCodecCache = new WeakMap(); + function __bjs_arrayCodec(elementCodec) { + let codec = __bjs_arrayCodecCache.get(elementCodec); + if (codec !== undefined) { + return codec; + } + codec = { + lower(value) { + for (let i = 0; i < value.length; i++) { + elementCodec.lower(value[i]); + } + i32Stack.push(value.length); + }, + lift() { + const count = i32Stack.pop(); + if (count === -1) { + return taStack.pop(); + } + const result = new Array(count); + for (let i = count - 1; i >= 0; i--) { + result[i] = elementCodec.lift(); + } + return result; + }, + }; + __bjs_arrayCodecCache.set(elementCodec, codec); + return codec; + } + const __bjs_optionalCodecCache = new WeakMap(); + const __bjs_optionalCodecUndefinedOrCache = new WeakMap(); + function __bjs_optionalCodec(elementCodec, isUndefinedOr = false) { + const cache = isUndefinedOr ? __bjs_optionalCodecUndefinedOrCache : __bjs_optionalCodecCache; + let codec = cache.get(elementCodec); + if (codec !== undefined) { + return codec; + } + codec = { + lower(value) { + const isSome = isUndefinedOr ? value !== undefined : value != null; + if (isSome) { + elementCodec.lower(value); + i32Stack.push(1); + } else { + i32Stack.push(0); + } + }, + lift() { + if (i32Stack.pop() === 0) { + return isUndefinedOr ? undefined : null; + } + return elementCodec.lift(); + }, + }; + cache.set(elementCodec, codec); + return codec; + } + const __bjs_dictCodecCache = new WeakMap(); + function __bjs_dictCodec(valueCodec) { + let codec = __bjs_dictCodecCache.get(valueCodec); + if (codec !== undefined) { + return codec; + } + codec = { + lower(value) { + const keys = Object.keys(value); + for (let i = 0; i < keys.length; i++) { + __bjs_stringCodec.lower(keys[i]); + valueCodec.lower(value[keys[i]]); + } + i32Stack.push(keys.length); + }, + lift() { + const count = i32Stack.pop(); + const result = {}; + for (let i = 0; i < count; i++) { + const value = valueCodec.lift(); + const key = __bjs_stringCodec.lift(); + result[key] = value; + } + return result; + }, + }; + __bjs_dictCodecCache.set(valueCodec, codec); + return codec; + } + + const __bjs_stringCodec = { + lower: (v) => { + const bytes = textEncoder.encode(v); + const id = swift.memory.retain(bytes); + i32Stack.push(bytes.length); + i32Stack.push(id); + }, + lift: () => { + const string = strStack.pop(); + return string; + }, + }; + const __bjs_primitiveCodecs = { + Bool: { + lower: (v) => { + i32Stack.push(v ? 1 : 0); + }, + lift: () => { + const bool = i32Stack.pop() !== 0; + return bool; + }, + }, + Int: { + lower: (v) => { + i32Stack.push((v | 0)); + }, + lift: () => { + const int = i32Stack.pop(); + return int; + }, + }, + Int8: { + lower: (v) => { + i32Stack.push((v | 0)); + }, + lift: () => { + const int = i32Stack.pop(); + return int; + }, + }, + UInt8: { + lower: (v) => { + i32Stack.push((v | 0)); + }, + lift: () => { + const int = i32Stack.pop() >>> 0; + return int; + }, + }, + Int16: { + lower: (v) => { + i32Stack.push((v | 0)); + }, + lift: () => { + const int = i32Stack.pop(); + return int; + }, + }, + UInt16: { + lower: (v) => { + i32Stack.push((v | 0)); + }, + lift: () => { + const int = i32Stack.pop() >>> 0; + return int; + }, + }, + Int32: { + lower: (v) => { + i32Stack.push((v | 0)); + }, + lift: () => { + const int = i32Stack.pop(); + return int; + }, + }, + UInt32: { + lower: (v) => { + i32Stack.push((v | 0)); + }, + lift: () => { + const int = i32Stack.pop() >>> 0; + return int; + }, + }, + UInt: { + lower: (v) => { + i32Stack.push((v | 0)); + }, + lift: () => { + const int = i32Stack.pop() >>> 0; + return int; + }, + }, + Int64: { + lower: (v) => { + i64Stack.push(v); + }, + lift: () => { + const int = i64Stack.pop(); + return int; + }, + }, + UInt64: { + lower: (v) => { + i64Stack.push(v); + }, + lift: () => { + const int = i64Stack.pop(); + return int; + }, + }, + Float: { + lower: (v) => { + f32Stack.push(Math.fround(v)); + }, + lift: () => { + const f32 = f32Stack.pop(); + return f32; + }, + }, + Double: { + lower: (v) => { + f64Stack.push(v); + }, + lift: () => { + const f64 = f64Stack.pop(); + return f64; + }, + }, + String: __bjs_stringCodec, + JSValue: { + lower: (v) => { + const [vKind, vPayload1, vPayload2] = __bjs_jsValueLower(v); + i32Stack.push(vKind); + i32Stack.push(vPayload1); + f64Stack.push(vPayload2); + }, + lift: () => { + const jsValuePayload2 = f64Stack.pop(); + const jsValuePayload1 = i32Stack.pop(); + const jsValueKind = i32Stack.pop(); + const jsValue = __bjs_jsValueTake(jsValueKind, jsValuePayload1, jsValuePayload2); + return jsValue; + }, + }, + }; + + 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; + } + function __bjs_jsValueTake(kind, payload1, payload2) { + const value = __bjs_jsValueLift(kind, payload1, payload2); + if (kind === 1 || kind === 3 || kind === 7 || kind === 8) { + swift.memory.release(payload1); + } + return value; + } + + 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 >>> 0); + let length = 0; + while (bytes[length] !== 0) { length += 1; } + const fileID = decodeUTF8(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); + }; + + const __bjs_codec_17NoncopyableObjectV = { + lower: (v) => { + const objId = swift.memory.retain(v); + i32Stack.push(objId); + }, + lift: () => { + const objId = i32Stack.pop(); + const obj = swift.memory.getObject(objId); + swift.memory.release(objId); + return obj; + }, + }; + const __bjs_codec_Array_17NoncopyableObjectV = __bjs_arrayCodec(__bjs_codec_17NoncopyableObjectV); + + const __bjs_createStructHelpers_M10TestModuleT5Point = () => ({ + lower: (value) => { + i32Stack.push((value.x | 0)); + }, + lift: () => { + const int = i32Stack.pop(); + return { x: int }; + } + }); + const __bjs_createStructHelpers_M10TestModuleT8GeometryT3Box = () => ({ + lower: (value) => { + i32Stack.push((value.side | 0)); + }, + lift: () => { + const int = i32Stack.pop(); + return { side: int }; + } + }); + const __bjs_createStructHelpers_M10TestModuleT7LibraryT5Shelf = () => ({ + 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_createEnumHelpers_M10TestModuleT5Shape = () => ({ + lower: (value) => { + const enumTag = value.tag; + switch (enumTag) { + case ShapeValues.Tag.Circle: { + f64Stack.push(value.param0); + return ShapeValues.Tag.Circle; + } + case ShapeValues.Tag.Square: { + i32Stack.push((value.param0 | 0)); + return ShapeValues.Tag.Square; + } + default: throw new Error("Unknown ShapeValues tag: " + String(enumTag)); + } + }, + lift: (tag) => { + tag = tag | 0; + switch (tag) { + case ShapeValues.Tag.Circle: { + const f64 = f64Stack.pop(); + return { tag: ShapeValues.Tag.Circle, param0: f64 }; + } + case ShapeValues.Tag.Square: { + const int = i32Stack.pop(); + return { tag: ShapeValues.Tag.Square, param0: int }; + } + default: throw new Error("Unknown ShapeValues tag returned from Swift: " + String(tag)); + } + } + }); + + return { + /** + * @param {WebAssembly.Imports} importObject + */ + addImports: (importObject, importsContext) => { + bjs = {}; + importObject["bjs"] = bjs; + bjs["swift_js_return_string"] = function(word0, word1, word2) { + tmpRetString = decodeString(word0, word1, word2); + } + 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(word0, word1, word2) { + return swift.memory.retain(decodeString(word0, word1, word2)); + } + 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(word0, word1, word2) { + const value = decodeString(word0, word1, word2); + 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 start = ptr >>> 0; + const copy = memory.buffer.slice(start, start + byteLen); + taStack.push(Array.from(new Ctor(copy))); + } + bjs["swift_js_struct_lower_Point"] = function(objectId) { + structHelpers.M10TestModuleT5Point.lower(swift.memory.getObject(objectId)); + } + bjs["swift_js_struct_lift_Point"] = function() { + const value = structHelpers.M10TestModuleT5Point.lift(); + return swift.memory.retain(value); + } + bjs["swift_js_struct_lower_Geometry_Box"] = function(objectId) { + structHelpers.M10TestModuleT8GeometryT3Box.lower(swift.memory.getObject(objectId)); + } + bjs["swift_js_struct_lift_Geometry_Box"] = function() { + const value = structHelpers.M10TestModuleT8GeometryT3Box.lift(); + return swift.memory.retain(value); + } + bjs["swift_js_struct_lower_Library_Shelf"] = function(objectId) { + structHelpers.M10TestModuleT7LibraryT5Shelf.lower(swift.memory.getObject(objectId)); + } + bjs["swift_js_struct_lift_Library_Shelf"] = function() { + const value = structHelpers.M10TestModuleT7LibraryT5Shelf.lift(); + return swift.memory.retain(value); + } + bjs["bjs_core_register_type_handles"] = function() {}; + bjs["bjs_TestModule_register_type_handles"] = function() {}; + 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_5PointV"] = function(promise) { + try { + const structValue = structHelpers.M10TestModuleT5Point.lift(); + swift.memory.getObject(promise)[__bjs_promiseSettlers].resolve(structValue); + } 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, word0, word1, word2) { + if (isSome === 0) { + tmpRetString = null; + } else { + tmpRetString = decodeString(word0, word1, word2); + } + } + 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_10TestModule5PointV5LevelO_9DirectionO"] = function(callbackId, param1Word0, param1Word1, param1Word2) { + try { + const callback = swift.memory.getObject(callbackId); + const structValue = structHelpers.M10TestModuleT5Point.lift(); + const string = decodeString(param1Word0, param1Word1, param1Word2); + let ret = callback(structValue, string); + return ret; + } catch (error) { + setException(error); + return 0 + } + } + bjs["make_swift_closure_TestModule_10TestModule5PointV5LevelO_9DirectionO"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModule5PointV5LevelO_9DirectionO = function(param0, param1) { + structHelpers.M10TestModuleT5Point.lower(param0); + const param1Bytes = textEncoder.encode(param1); + const param1Id = swift.memory.retain(param1Bytes); + const ret = instance.exports.invoke_swift_closure_TestModule_10TestModule5PointV5LevelO_9DirectionO(boxPtr, param1Id, param1Bytes.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_10TestModule5PointV5LevelO_9DirectionO); + } + bjs["invoke_js_callback_TestModule_10TestModuleSa17NoncopyableObjectV5PointV_Si"] = function(callbackId) { + try { + const callback = swift.memory.getObject(callbackId); + const arrayResult = __bjs_codec_Array_17NoncopyableObjectV.lift(); + const structValue = structHelpers.M10TestModuleT5Point.lift(); + let ret = callback(arrayResult, structValue); + return ret; + } catch (error) { + setException(error); + return 0 + } + } + bjs["make_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV5PointV_Si"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleSa17NoncopyableObjectV5PointV_Si = function(param0, param1) { + __bjs_codec_Array_17NoncopyableObjectV.lower(param0); + structHelpers.M10TestModuleT5Point.lower(param1); + const ret = instance.exports.invoke_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV5PointV_Si(boxPtr); + 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_10TestModuleSa17NoncopyableObjectV5PointV_Si); + } + // Wrapper functions for module: TestModule + if (!importObject["TestModule"]) { + importObject["TestModule"] = {}; + } + importObject["TestModule"]["bjs_Counter_wrap"] = function(pointer) { + const obj = _exports['Counter'].__construct(pointer); + return swift.memory.retain(obj); + }; + importObject["TestModule"]["bjs_Library_wrap"] = function(pointer) { + const obj = _exports['Library'].__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_Element_id"] = function bjs_Element_id(self) { + try { + let ret = swift.memory.getObject(self).id(); + return ret; + } catch (error) { + setException(error); + return 0 + } + } + TestModule["bjs_Canvas_element"] = function bjs_Canvas_element(self) { + try { + let ret = swift.memory.getObject(self).element(); + return swift.memory.retain(ret); + } catch (error) { + setException(error); + return 0 + } + } + TestModule["bjs_NoncopyableObject_id"] = function bjs_NoncopyableObject_id(self) { + try { + let ret = swift.memory.getObject(self).id(); + return ret; + } catch (error) { + setException(error); + return 0 + } + } + TestModule["bjs_Source_value"] = function bjs_Source_value(self) { + try { + let ret = swift.memory.getObject(self).value(); + return ret; + } catch (error) { + setException(error); + return 0 + } + } + TestModule["bjs_PointSource_origin_get"] = function bjs_PointSource_origin_get(self) { + try { + let ret = swift.memory.getObject(self).origin; + structHelpers.M10TestModuleT5Point.lower(ret); + } catch (error) { + setException(error); + } + } + TestModule["bjs_PointSource_point"] = function bjs_PointSource_point(self) { + try { + let ret = swift.memory.getObject(self).point(); + structHelpers.M10TestModuleT5Point.lower(ret); + } catch (error) { + setException(error); + } + } + }, + setInstance: (i) => { + if (memory !== i.exports.memory) immortalStrings.clear(); + instance = i; + memory = instance.exports.memory; + + decodeUTF8 = (ptr, len) => { const bytes = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); return textDecoder.decode(bytes); } + decodeString = (() => { + const byteAt = (word0, word1, byteIndex) => + byteIndex < 4 + ? (word0 >>> (byteIndex * 8)) & 255 + : (word1 >>> ((byteIndex - 4) * 8)) & 255; + // Valid small Swift strings need at most eight UTF-16 code units. + const decodeSmallUTF8 = (word0, word1, count) => { + if (count > 8) { + throw new Error(`Unsupported Swift inline String length: ${count} UTF-8 bytes (maximum 8). The Swift String layout may have changed; update JavaScriptKit and regenerate BridgeJS glue.`); + } + let byteIndex = 0, + unitCount = 0, + u0 = 0, + u1 = 0, + u2 = 0, + u3 = 0, + u4 = 0, + u5 = 0, + u6 = 0, + u7 = 0; + while (byteIndex < count) { + const b0 = byteAt(word0, word1, byteIndex++); + let codePoint; + if (b0 < 128) codePoint = b0; + else if (b0 < 224) codePoint = ((b0 & 31) << 6) | (byteAt(word0, word1, byteIndex++) & 63); + else if (b0 < 240) { + const b1 = byteAt(word0, word1, byteIndex++), + b2 = byteAt(word0, word1, byteIndex++); + codePoint = ((b0 & 15) << 12) | ((b1 & 63) << 6) | (b2 & 63); + } else { + const b1 = byteAt(word0, word1, byteIndex++), + b2 = byteAt(word0, word1, byteIndex++), + b3 = byteAt(word0, word1, byteIndex++); + codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); + } + const supplementary = codePoint > 0xffff; + const codeUnit = supplementary + ? 0xd800 + ((codePoint - 0x10000) >>> 10) + : codePoint; + switch (unitCount++) { + case 0: + u0 = codeUnit; + break; + case 1: + u1 = codeUnit; + break; + case 2: + u2 = codeUnit; + break; + case 3: + u3 = codeUnit; + break; + case 4: + u4 = codeUnit; + break; + case 5: + u5 = codeUnit; + break; + case 6: + u6 = codeUnit; + break; + case 7: + u7 = codeUnit; + break; + } + if (supplementary) { + const lowSurrogate = 0xdc00 + ((codePoint - 0x10000) & 1023); + switch (unitCount++) { + case 0: + u0 = lowSurrogate; + break; + case 1: + u1 = lowSurrogate; + break; + case 2: + u2 = lowSurrogate; + break; + case 3: + u3 = lowSurrogate; + break; + case 4: + u4 = lowSurrogate; + break; + case 5: + u5 = lowSurrogate; + break; + case 6: + u6 = lowSurrogate; + break; + case 7: + u7 = lowSurrogate; + break; + } + } + } + switch (unitCount) { + case 0: + return ""; + case 1: + return String.fromCharCode(u0); + case 2: + return String.fromCharCode(u0, u1); + case 3: + return String.fromCharCode(u0, u1, u2); + case 4: + return String.fromCharCode(u0, u1, u2, u3); + case 5: + return String.fromCharCode(u0, u1, u2, u3, u4); + case 6: + return String.fromCharCode(u0, u1, u2, u3, u4, u5); + case 7: + return String.fromCharCode(u0, u1, u2, u3, u4, u5, u6); + case 8: + return String.fromCharCode(u0, u1, u2, u3, u4, u5, u6, u7); + } + }; + const decodeSmall = (word0, word1, word2) => { + const count = (word2 >>> 8) & 0x0f; + if ((word2 & 0x4000 /* ASCII */) === 0) return decodeSmallUTF8(word0, word1, count); + const char = String.fromCharCode; + switch (count) { + case 0: return ""; + case 1: return char(word0 & 0xff); + case 2: return char(word0 & 0xff, (word0 >>> 8) & 0xff); + case 3: return char(word0 & 0xff, (word0 >>> 8) & 0xff, (word0 >>> 16) & 0xff); + case 4: return char(word0 & 0xff, (word0 >>> 8) & 0xff, (word0 >>> 16) & 0xff, word0 >>> 24); + case 5: return char(word0 & 0xff, (word0 >>> 8) & 0xff, (word0 >>> 16) & 0xff, word0 >>> 24, word1 & 0xff); + case 6: return char(word0 & 0xff, (word0 >>> 8) & 0xff, (word0 >>> 16) & 0xff, word0 >>> 24, word1 & 0xff, (word1 >>> 8) & 0xff); + case 7: return char(word0 & 0xff, (word0 >>> 8) & 0xff, (word0 >>> 16) & 0xff, word0 >>> 24, word1 & 0xff, (word1 >>> 8) & 0xff, (word1 >>> 16) & 0xff); + case 8: return char(word0 & 0xff, (word0 >>> 8) & 0xff, (word0 >>> 16) & 0xff, word0 >>> 24, word1 & 0xff, (word1 >>> 8) & 0xff, (word1 >>> 16) & 0xff, word1 >>> 24); + default: + throw new Error(`Unsupported Swift inline String length: ${count} UTF-8 bytes (maximum 8). The Swift String layout may have changed; update JavaScriptKit and regenerate BridgeJS glue.`); + } + }; + return (word0, word1, word2) => { + if (word2 & 0x2000 /* small */) return decodeSmall(word0, word1, word2); + const ptr = (word1 + 20 /* nativeBias */) >>> 0; + const len = word0 >>> 0; + if ((word2 & 0x8000 /* immortal */) === 0 || len >= 0x200000 /* 2^21 Number key */) return decodeUTF8(ptr, len); + const key = ptr + len * 0x100000000; + const cached = immortalStrings.get(key); + if (cached !== undefined) return cached; + const value = decodeUTF8(ptr, len); + immortalStrings.set(key, value); + return value; + }; + })(); + + 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 Counter extends SwiftHeapObject { + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Counter_deinit, Counter.prototype, null); + } + + constructor() { + const ret = instance.exports.bjs_Counter_init(); + return Counter.__construct(ret); + } + } + class Library extends SwiftHeapObject { + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Library_deinit, Library.prototype, null); + } + + constructor() { + const ret = instance.exports.bjs_Library_init(); + return Library.__construct(ret); + } + } + class TagReference extends SwiftHeapObject { + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_TagReference_deinit, TagReference.prototype, null); + } + + constructor(name) { + const nameBytes = textEncoder.encode(name); + const nameId = swift.memory.retain(nameBytes); + const ret = instance.exports.bjs_TagReference_init(nameId, nameBytes.length); + return TagReference.__construct(ret); + } + } + const __bjs_helpers_M10TestModuleT5Point = __bjs_createStructHelpers_M10TestModuleT5Point(); + structHelpers.M10TestModuleT5Point = __bjs_helpers_M10TestModuleT5Point; + + const __bjs_helpers_M10TestModuleT8GeometryT3Box = __bjs_createStructHelpers_M10TestModuleT8GeometryT3Box(); + structHelpers.M10TestModuleT8GeometryT3Box = __bjs_helpers_M10TestModuleT8GeometryT3Box; + + const __bjs_helpers_M10TestModuleT7LibraryT5Shelf = __bjs_createStructHelpers_M10TestModuleT7LibraryT5Shelf(); + structHelpers.M10TestModuleT7LibraryT5Shelf = __bjs_helpers_M10TestModuleT7LibraryT5Shelf; + + const __bjs_helpers_M10TestModuleT5Shape = __bjs_createEnumHelpers_M10TestModuleT5Shape(); + enumHelpers.M10TestModuleT5Shape = __bjs_helpers_M10TestModuleT5Shape; + + const exports = { + mix: function bjs_mix(point, body) { + structHelpers.M10TestModuleT5Point.lower(point); + const callbackId = swift.memory.retain(body); + const ret = instance.exports.bjs_mix(callbackId); + return ret; + }, + loadPoint: function bjs_loadPoint() { + const ret = instance.exports.bjs_loadPoint(); + const ret1 = swift.memory.getObject(ret); + swift.memory.release(ret); + return ret1; + }, + countObjects: function bjs_countObjects(body) { + const callbackId = swift.memory.retain(body); + const ret = instance.exports.bjs_countObjects(callbackId); + return ret; + }, + Direction: DirectionValues, + Level: LevelValues, + Shape: ShapeValues, + Counter, + Library, + TagReference, + }; + _exports = exports; + return exports; + }, + } +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NoncopyableJSClass.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NoncopyableJSClass.d.ts new file mode 100644 index 000000000..76b953b48 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NoncopyableJSClass.d.ts @@ -0,0 +1,64 @@ +// 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 NoncopyableObjectSource { + name(): string; + makeAll(count: number): NoncopyableObject[]; +} + +/// 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 NoncopyableObjectBox extends SwiftHeapObject { + object: NoncopyableObject; +} +export interface NoncopyableObject { + value(): number; + readonly name: string; +} +export interface NoncopyableObjectRoundtrip { + take(object: NoncopyableObject): number; + adopt(object: NoncopyableObject): number; + make(start: number): NoncopyableObject; + find(start: number): NoncopyableObject | null; + takeOptional(object: NoncopyableObject | null): number; + forEach(body: (arg0: NoncopyableObject) => void): void; + load(start: number): Promise; + takeAll(objects: NoncopyableObject[]): number; + makeAll(count: number): NoncopyableObject[]; + makeMaybe(count: number): NoncopyableObject[] | null; + raw(start: number): any; + child: NoncopyableObject; +} +export type Exports = { + useNoncopyableObject(object: NoncopyableObject): number; + makeNoncopyableObjectInSwift(start: number): NoncopyableObject; + findNoncopyableObjectInSwift(start: number): NoncopyableObject | null; + countNoncopyableObjects(objects: NoncopyableObject[]): number; + countNoncopyableObjectsWith(body: (arg0: NoncopyableObject[]) => number): number; + loadNoncopyableObject(start: number): Promise; + loadNoncopyableObjects(count: number): Promise; + NoncopyableObjectBox: { + new(start: number): NoncopyableObjectBox; + }, +} +export type Imports = { + makeNoncopyableObject(start: number): NoncopyableObject; + NoncopyableObject: { + new(start: number): NoncopyableObject; + } +} +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/NoncopyableJSClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NoncopyableJSClass.js new file mode 100644 index 000000000..5c89019fc --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NoncopyableJSClass.js @@ -0,0 +1,1145 @@ +// 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; + let decodeUTF8; + const immortalStrings = new Map(); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); + 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_arrayCodecCache = new WeakMap(); + function __bjs_arrayCodec(elementCodec) { + let codec = __bjs_arrayCodecCache.get(elementCodec); + if (codec !== undefined) { + return codec; + } + codec = { + lower(value) { + for (let i = 0; i < value.length; i++) { + elementCodec.lower(value[i]); + } + i32Stack.push(value.length); + }, + lift() { + const count = i32Stack.pop(); + if (count === -1) { + return taStack.pop(); + } + const result = new Array(count); + for (let i = count - 1; i >= 0; i--) { + result[i] = elementCodec.lift(); + } + return result; + }, + }; + __bjs_arrayCodecCache.set(elementCodec, codec); + return codec; + } + const __bjs_optionalCodecCache = new WeakMap(); + const __bjs_optionalCodecUndefinedOrCache = new WeakMap(); + function __bjs_optionalCodec(elementCodec, isUndefinedOr = false) { + const cache = isUndefinedOr ? __bjs_optionalCodecUndefinedOrCache : __bjs_optionalCodecCache; + let codec = cache.get(elementCodec); + if (codec !== undefined) { + return codec; + } + codec = { + lower(value) { + const isSome = isUndefinedOr ? value !== undefined : value != null; + if (isSome) { + elementCodec.lower(value); + i32Stack.push(1); + } else { + i32Stack.push(0); + } + }, + lift() { + if (i32Stack.pop() === 0) { + return isUndefinedOr ? undefined : null; + } + return elementCodec.lift(); + }, + }; + cache.set(elementCodec, codec); + return codec; + } + const __bjs_dictCodecCache = new WeakMap(); + function __bjs_dictCodec(valueCodec) { + let codec = __bjs_dictCodecCache.get(valueCodec); + if (codec !== undefined) { + return codec; + } + codec = { + lower(value) { + const keys = Object.keys(value); + for (let i = 0; i < keys.length; i++) { + __bjs_stringCodec.lower(keys[i]); + valueCodec.lower(value[keys[i]]); + } + i32Stack.push(keys.length); + }, + lift() { + const count = i32Stack.pop(); + const result = {}; + for (let i = 0; i < count; i++) { + const value = valueCodec.lift(); + const key = __bjs_stringCodec.lift(); + result[key] = value; + } + return result; + }, + }; + __bjs_dictCodecCache.set(valueCodec, codec); + return codec; + } + + const __bjs_stringCodec = { + lower: (v) => { + const bytes = textEncoder.encode(v); + const id = swift.memory.retain(bytes); + i32Stack.push(bytes.length); + i32Stack.push(id); + }, + lift: () => { + const string = strStack.pop(); + return string; + }, + }; + const __bjs_primitiveCodecs = { + Bool: { + lower: (v) => { + i32Stack.push(v ? 1 : 0); + }, + lift: () => { + const bool = i32Stack.pop() !== 0; + return bool; + }, + }, + Int: { + lower: (v) => { + i32Stack.push((v | 0)); + }, + lift: () => { + const int = i32Stack.pop(); + return int; + }, + }, + Int8: { + lower: (v) => { + i32Stack.push((v | 0)); + }, + lift: () => { + const int = i32Stack.pop(); + return int; + }, + }, + UInt8: { + lower: (v) => { + i32Stack.push((v | 0)); + }, + lift: () => { + const int = i32Stack.pop() >>> 0; + return int; + }, + }, + Int16: { + lower: (v) => { + i32Stack.push((v | 0)); + }, + lift: () => { + const int = i32Stack.pop(); + return int; + }, + }, + UInt16: { + lower: (v) => { + i32Stack.push((v | 0)); + }, + lift: () => { + const int = i32Stack.pop() >>> 0; + return int; + }, + }, + Int32: { + lower: (v) => { + i32Stack.push((v | 0)); + }, + lift: () => { + const int = i32Stack.pop(); + return int; + }, + }, + UInt32: { + lower: (v) => { + i32Stack.push((v | 0)); + }, + lift: () => { + const int = i32Stack.pop() >>> 0; + return int; + }, + }, + UInt: { + lower: (v) => { + i32Stack.push((v | 0)); + }, + lift: () => { + const int = i32Stack.pop() >>> 0; + return int; + }, + }, + Int64: { + lower: (v) => { + i64Stack.push(v); + }, + lift: () => { + const int = i64Stack.pop(); + return int; + }, + }, + UInt64: { + lower: (v) => { + i64Stack.push(v); + }, + lift: () => { + const int = i64Stack.pop(); + return int; + }, + }, + Float: { + lower: (v) => { + f32Stack.push(Math.fround(v)); + }, + lift: () => { + const f32 = f32Stack.pop(); + return f32; + }, + }, + Double: { + lower: (v) => { + f64Stack.push(v); + }, + lift: () => { + const f64 = f64Stack.pop(); + return f64; + }, + }, + String: __bjs_stringCodec, + JSValue: { + lower: (v) => { + const [vKind, vPayload1, vPayload2] = __bjs_jsValueLower(v); + i32Stack.push(vKind); + i32Stack.push(vPayload1); + f64Stack.push(vPayload2); + }, + lift: () => { + const jsValuePayload2 = f64Stack.pop(); + const jsValuePayload1 = i32Stack.pop(); + const jsValueKind = i32Stack.pop(); + const jsValue = __bjs_jsValueTake(jsValueKind, jsValuePayload1, jsValuePayload2); + return jsValue; + }, + }, + }; + + 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; + } + function __bjs_jsValueTake(kind, payload1, payload2) { + const value = __bjs_jsValueLift(kind, payload1, payload2); + if (kind === 1 || kind === 3 || kind === 7 || kind === 8) { + swift.memory.release(payload1); + } + return value; + } + + 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 >>> 0); + let length = 0; + while (bytes[length] !== 0) { length += 1; } + const fileID = decodeUTF8(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); + }; + + const __bjs_codec_17NoncopyableObjectV = { + lower: (v) => { + const objId = swift.memory.retain(v); + i32Stack.push(objId); + }, + lift: () => { + const objId = i32Stack.pop(); + const obj = swift.memory.getObject(objId); + swift.memory.release(objId); + return obj; + }, + }; + const __bjs_codec_Optional_17NoncopyableObjectV = __bjs_optionalCodec(__bjs_codec_17NoncopyableObjectV); + const __bjs_codec_Array_17NoncopyableObjectV = __bjs_arrayCodec(__bjs_codec_17NoncopyableObjectV); + const __bjs_codec_Optional_Array_17NoncopyableObjectV = __bjs_optionalCodec(__bjs_codec_Array_17NoncopyableObjectV); + + + return { + /** + * @param {WebAssembly.Imports} importObject + */ + addImports: (importObject, importsContext) => { + bjs = {}; + importObject["bjs"] = bjs; + const imports = options.getImports(importsContext); + bjs["swift_js_return_string"] = function(word0, word1, word2) { + tmpRetString = decodeString(word0, word1, word2); + } + 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(word0, word1, word2) { + return swift.memory.retain(decodeString(word0, word1, word2)); + } + 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(word0, word1, word2) { + const value = decodeString(word0, word1, word2); + 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 start = ptr >>> 0; + const copy = memory.buffer.slice(start, start + byteLen); + taStack.push(Array.from(new Ctor(copy))); + } + bjs["bjs_core_register_type_handles"] = function() {}; + 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_17NoncopyableObjectV"] = function(promise, value) { + try { + swift.memory.getObject(promise)[__bjs_promiseSettlers].resolve(swift.memory.getObject(value)); + } catch (error) { + setException(error); + } + } + bjs["promise_resolve_TestModule_Sa17NoncopyableObjectV"] = function(promise) { + try { + const arrayResult = __bjs_codec_Array_17NoncopyableObjectV.lift(); + swift.memory.getObject(promise)[__bjs_promiseSettlers].resolve(arrayResult); + } 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, word0, word1, word2) { + if (isSome === 0) { + tmpRetString = null; + } else { + tmpRetString = decodeString(word0, word1, word2); + } + } + 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_10TestModule17NoncopyableObjectV_y"] = function(callbackId, param0) { + try { + const callback = swift.memory.getObject(callbackId); + callback(swift.memory.getObject(param0)); + } catch (error) { + setException(error); + } + } + bjs["make_swift_closure_TestModule_10TestModule17NoncopyableObjectV_y"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModule17NoncopyableObjectV_y = function(param0) { + instance.exports.invoke_swift_closure_TestModule_10TestModule17NoncopyableObjectV_y(boxPtr, swift.memory.retain(param0)); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModule17NoncopyableObjectV_y); + } + bjs["invoke_js_callback_TestModule_10TestModuleSa17NoncopyableObjectV_Si"] = function(callbackId) { + try { + const callback = swift.memory.getObject(callbackId); + const arrayResult = __bjs_codec_Array_17NoncopyableObjectV.lift(); + let ret = callback(arrayResult); + return ret; + } catch (error) { + setException(error); + return 0 + } + } + bjs["make_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV_Si"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleSa17NoncopyableObjectV_Si = function(param0) { + __bjs_codec_Array_17NoncopyableObjectV.lower(param0); + const ret = instance.exports.invoke_swift_closure_TestModule_10TestModuleSa17NoncopyableObjectV_Si(boxPtr); + 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_10TestModuleSa17NoncopyableObjectV_Si); + } + bjs["invoke_js_callback_TestModule_10TestModules17NoncopyableObjectV_y"] = function(callbackId, param0) { + try { + const callback = swift.memory.getObject(callbackId); + callback(swift.memory.getObject(param0)); + } catch (error) { + setException(error); + } + } + bjs["make_swift_closure_TestModule_10TestModules17NoncopyableObjectV_y"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModules17NoncopyableObjectV_y = function(param0) { + instance.exports.invoke_swift_closure_TestModule_10TestModules17NoncopyableObjectV_y(boxPtr, swift.memory.retain(param0)); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModules17NoncopyableObjectV_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); + } + // Wrapper functions for module: TestModule + if (!importObject["TestModule"]) { + importObject["TestModule"] = {}; + } + importObject["TestModule"]["bjs_NoncopyableObjectBox_wrap"] = function(pointer) { + const obj = _exports['NoncopyableObjectBox'].__construct(pointer); + return swift.memory.retain(obj); + }; + const TestModule = importObject["TestModule"] = importObject["TestModule"] || {}; + TestModule["bjs_makeNoncopyableObject"] = function bjs_makeNoncopyableObject(start) { + try { + let ret = imports.makeNoncopyableObject(start); + return swift.memory.retain(ret); + } catch (error) { + setException(error); + return 0 + } + } + TestModule["bjs_NoncopyableObject_init"] = function bjs_NoncopyableObject_init(start) { + try { + return swift.memory.retain(new imports.NoncopyableObject(start)); + } catch (error) { + setException(error); + return 0 + } + } + TestModule["bjs_NoncopyableObject_name_get"] = function bjs_NoncopyableObject_name_get(self) { + try { + let ret = swift.memory.getObject(self).name; + tmpRetBytes = textEncoder.encode(ret); + return tmpRetBytes.length; + } catch (error) { + setException(error); + } + } + TestModule["bjs_NoncopyableObject_value"] = function bjs_NoncopyableObject_value(self) { + try { + let ret = swift.memory.getObject(self).value(); + return ret; + } catch (error) { + setException(error); + return 0 + } + } + TestModule["bjs_NoncopyableObjectRoundtrip_child_get"] = function bjs_NoncopyableObjectRoundtrip_child_get(self) { + try { + let ret = swift.memory.getObject(self).child; + return swift.memory.retain(ret); + } catch (error) { + setException(error); + return 0 + } + } + TestModule["bjs_NoncopyableObjectRoundtrip_child_set"] = function bjs_NoncopyableObjectRoundtrip_child_set(self, newValue) { + try { + swift.memory.getObject(self).child = swift.memory.getObject(newValue); + } catch (error) { + setException(error); + } + } + TestModule["bjs_NoncopyableObjectRoundtrip_take"] = function bjs_NoncopyableObjectRoundtrip_take(self, object) { + try { + let ret = swift.memory.getObject(self).take(swift.memory.getObject(object)); + return ret; + } catch (error) { + setException(error); + return 0 + } + } + TestModule["bjs_NoncopyableObjectRoundtrip_adopt"] = function bjs_NoncopyableObjectRoundtrip_adopt(self, object) { + try { + let ret = swift.memory.getObject(self).adopt(swift.memory.getObject(object)); + return ret; + } catch (error) { + setException(error); + return 0 + } + } + TestModule["bjs_NoncopyableObjectRoundtrip_make"] = function bjs_NoncopyableObjectRoundtrip_make(self, start) { + try { + let ret = swift.memory.getObject(self).make(start); + return swift.memory.retain(ret); + } catch (error) { + setException(error); + return 0 + } + } + TestModule["bjs_NoncopyableObjectRoundtrip_find"] = function bjs_NoncopyableObjectRoundtrip_find(self, start) { + try { + let ret = swift.memory.getObject(self).find(start); + __bjs_codec_Optional_17NoncopyableObjectV.lower(ret); + } catch (error) { + setException(error); + } + } + TestModule["bjs_NoncopyableObjectRoundtrip_takeOptional"] = function bjs_NoncopyableObjectRoundtrip_takeOptional(self, objectIsSome, objectObjectId) { + try { + let ret = swift.memory.getObject(self).takeOptional(objectIsSome ? swift.memory.getObject(objectObjectId) : null); + return ret; + } catch (error) { + setException(error); + return 0 + } + } + TestModule["bjs_NoncopyableObjectRoundtrip_forEach"] = function bjs_NoncopyableObjectRoundtrip_forEach(self, body) { + try { + swift.memory.getObject(self).forEach(swift.memory.getObject(body)); + } catch (error) { + setException(error); + } + } + TestModule["bjs_NoncopyableObjectRoundtrip_load"] = function bjs_NoncopyableObjectRoundtrip_load(resolveRef, rejectRef, self, start) { + const resolve = swift.memory.getObject(resolveRef); + const reject = swift.memory.getObject(rejectRef); + try { + Promise.resolve(swift.memory.getObject(self).load(start)).then(resolve, reject); + } catch (error) { + reject(error); + } + } + TestModule["bjs_NoncopyableObjectRoundtrip_takeAll"] = function bjs_NoncopyableObjectRoundtrip_takeAll(self) { + try { + const arrayResult = __bjs_codec_Array_17NoncopyableObjectV.lift(); + let ret = swift.memory.getObject(self).takeAll(arrayResult); + return ret; + } catch (error) { + setException(error); + return 0 + } + } + TestModule["bjs_NoncopyableObjectRoundtrip_makeAll"] = function bjs_NoncopyableObjectRoundtrip_makeAll(self, count) { + try { + let ret = swift.memory.getObject(self).makeAll(count); + __bjs_codec_Array_17NoncopyableObjectV.lower(ret); + } catch (error) { + setException(error); + } + } + TestModule["bjs_NoncopyableObjectRoundtrip_makeMaybe"] = function bjs_NoncopyableObjectRoundtrip_makeMaybe(self, count) { + try { + let ret = swift.memory.getObject(self).makeMaybe(count); + __bjs_codec_Optional_Array_17NoncopyableObjectV.lower(ret); + } catch (error) { + setException(error); + } + } + TestModule["bjs_NoncopyableObjectRoundtrip_raw"] = function bjs_NoncopyableObjectRoundtrip_raw(self, start) { + try { + let ret = swift.memory.getObject(self).raw(start); + return swift.memory.retain(ret); + } catch (error) { + setException(error); + return 0 + } + } + TestModule["bjs_NoncopyableObjectSource_name"] = function bjs_NoncopyableObjectSource_name(self) { + try { + let ret = swift.memory.getObject(self).name(); + tmpRetBytes = textEncoder.encode(ret); + return tmpRetBytes.length; + } catch (error) { + setException(error); + } + } + TestModule["bjs_NoncopyableObjectSource_makeAll"] = function bjs_NoncopyableObjectSource_makeAll(self, count) { + try { + let ret = swift.memory.getObject(self).makeAll(count); + __bjs_codec_Array_17NoncopyableObjectV.lower(ret); + } catch (error) { + setException(error); + } + } + }, + setInstance: (i) => { + if (memory !== i.exports.memory) immortalStrings.clear(); + instance = i; + memory = instance.exports.memory; + + decodeUTF8 = (ptr, len) => { const bytes = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); return textDecoder.decode(bytes); } + decodeString = (() => { + const byteAt = (word0, word1, byteIndex) => + byteIndex < 4 + ? (word0 >>> (byteIndex * 8)) & 255 + : (word1 >>> ((byteIndex - 4) * 8)) & 255; + // Valid small Swift strings need at most eight UTF-16 code units. + const decodeSmallUTF8 = (word0, word1, count) => { + if (count > 8) { + throw new Error(`Unsupported Swift inline String length: ${count} UTF-8 bytes (maximum 8). The Swift String layout may have changed; update JavaScriptKit and regenerate BridgeJS glue.`); + } + let byteIndex = 0, + unitCount = 0, + u0 = 0, + u1 = 0, + u2 = 0, + u3 = 0, + u4 = 0, + u5 = 0, + u6 = 0, + u7 = 0; + while (byteIndex < count) { + const b0 = byteAt(word0, word1, byteIndex++); + let codePoint; + if (b0 < 128) codePoint = b0; + else if (b0 < 224) codePoint = ((b0 & 31) << 6) | (byteAt(word0, word1, byteIndex++) & 63); + else if (b0 < 240) { + const b1 = byteAt(word0, word1, byteIndex++), + b2 = byteAt(word0, word1, byteIndex++); + codePoint = ((b0 & 15) << 12) | ((b1 & 63) << 6) | (b2 & 63); + } else { + const b1 = byteAt(word0, word1, byteIndex++), + b2 = byteAt(word0, word1, byteIndex++), + b3 = byteAt(word0, word1, byteIndex++); + codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); + } + const supplementary = codePoint > 0xffff; + const codeUnit = supplementary + ? 0xd800 + ((codePoint - 0x10000) >>> 10) + : codePoint; + switch (unitCount++) { + case 0: + u0 = codeUnit; + break; + case 1: + u1 = codeUnit; + break; + case 2: + u2 = codeUnit; + break; + case 3: + u3 = codeUnit; + break; + case 4: + u4 = codeUnit; + break; + case 5: + u5 = codeUnit; + break; + case 6: + u6 = codeUnit; + break; + case 7: + u7 = codeUnit; + break; + } + if (supplementary) { + const lowSurrogate = 0xdc00 + ((codePoint - 0x10000) & 1023); + switch (unitCount++) { + case 0: + u0 = lowSurrogate; + break; + case 1: + u1 = lowSurrogate; + break; + case 2: + u2 = lowSurrogate; + break; + case 3: + u3 = lowSurrogate; + break; + case 4: + u4 = lowSurrogate; + break; + case 5: + u5 = lowSurrogate; + break; + case 6: + u6 = lowSurrogate; + break; + case 7: + u7 = lowSurrogate; + break; + } + } + } + switch (unitCount) { + case 0: + return ""; + case 1: + return String.fromCharCode(u0); + case 2: + return String.fromCharCode(u0, u1); + case 3: + return String.fromCharCode(u0, u1, u2); + case 4: + return String.fromCharCode(u0, u1, u2, u3); + case 5: + return String.fromCharCode(u0, u1, u2, u3, u4); + case 6: + return String.fromCharCode(u0, u1, u2, u3, u4, u5); + case 7: + return String.fromCharCode(u0, u1, u2, u3, u4, u5, u6); + case 8: + return String.fromCharCode(u0, u1, u2, u3, u4, u5, u6, u7); + } + }; + const decodeSmall = (word0, word1, word2) => { + const count = (word2 >>> 8) & 0x0f; + if ((word2 & 0x4000 /* ASCII */) === 0) return decodeSmallUTF8(word0, word1, count); + const char = String.fromCharCode; + switch (count) { + case 0: return ""; + case 1: return char(word0 & 0xff); + case 2: return char(word0 & 0xff, (word0 >>> 8) & 0xff); + case 3: return char(word0 & 0xff, (word0 >>> 8) & 0xff, (word0 >>> 16) & 0xff); + case 4: return char(word0 & 0xff, (word0 >>> 8) & 0xff, (word0 >>> 16) & 0xff, word0 >>> 24); + case 5: return char(word0 & 0xff, (word0 >>> 8) & 0xff, (word0 >>> 16) & 0xff, word0 >>> 24, word1 & 0xff); + case 6: return char(word0 & 0xff, (word0 >>> 8) & 0xff, (word0 >>> 16) & 0xff, word0 >>> 24, word1 & 0xff, (word1 >>> 8) & 0xff); + case 7: return char(word0 & 0xff, (word0 >>> 8) & 0xff, (word0 >>> 16) & 0xff, word0 >>> 24, word1 & 0xff, (word1 >>> 8) & 0xff, (word1 >>> 16) & 0xff); + case 8: return char(word0 & 0xff, (word0 >>> 8) & 0xff, (word0 >>> 16) & 0xff, word0 >>> 24, word1 & 0xff, (word1 >>> 8) & 0xff, (word1 >>> 16) & 0xff, word1 >>> 24); + default: + throw new Error(`Unsupported Swift inline String length: ${count} UTF-8 bytes (maximum 8). The Swift String layout may have changed; update JavaScriptKit and regenerate BridgeJS glue.`); + } + }; + return (word0, word1, word2) => { + if (word2 & 0x2000 /* small */) return decodeSmall(word0, word1, word2); + const ptr = (word1 + 20 /* nativeBias */) >>> 0; + const len = word0 >>> 0; + if ((word2 & 0x8000 /* immortal */) === 0 || len >= 0x200000 /* 2^21 Number key */) return decodeUTF8(ptr, len); + const key = ptr + len * 0x100000000; + const cached = immortalStrings.get(key); + if (cached !== undefined) return cached; + const value = decodeUTF8(ptr, len); + immortalStrings.set(key, value); + return value; + }; + })(); + + 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 NoncopyableObjectBox extends SwiftHeapObject { + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_NoncopyableObjectBox_deinit, NoncopyableObjectBox.prototype, null); + } + + constructor(start) { + const ret = instance.exports.bjs_NoncopyableObjectBox_init(start); + return NoncopyableObjectBox.__construct(ret); + } + get object() { + const ret = instance.exports.bjs_NoncopyableObjectBox_object_get(this.pointer); + const ret1 = swift.memory.getObject(ret); + swift.memory.release(ret); + return ret1; + } + set object(value) { + instance.exports.bjs_NoncopyableObjectBox_object_set(this.pointer, swift.memory.retain(value)); + } + } + const exports = { + useNoncopyableObject: function bjs_useNoncopyableObject(object) { + const ret = instance.exports.bjs_useNoncopyableObject(swift.memory.retain(object)); + return ret; + }, + makeNoncopyableObjectInSwift: function bjs_makeNoncopyableObjectInSwift(start) { + const ret = instance.exports.bjs_makeNoncopyableObjectInSwift(start); + const ret1 = swift.memory.getObject(ret); + swift.memory.release(ret); + return ret1; + }, + findNoncopyableObjectInSwift: function bjs_findNoncopyableObjectInSwift(start) { + instance.exports.bjs_findNoncopyableObjectInSwift(start); + const optValue = __bjs_codec_Optional_17NoncopyableObjectV.lift(); + return optValue; + }, + countNoncopyableObjects: function bjs_countNoncopyableObjects(objects) { + __bjs_codec_Array_17NoncopyableObjectV.lower(objects); + const ret = instance.exports.bjs_countNoncopyableObjects(); + return ret; + }, + countNoncopyableObjectsWith: function bjs_countNoncopyableObjectsWith(body) { + const callbackId = swift.memory.retain(body); + const ret = instance.exports.bjs_countNoncopyableObjectsWith(callbackId); + return ret; + }, + loadNoncopyableObject: function bjs_loadNoncopyableObject(start) { + const ret = instance.exports.bjs_loadNoncopyableObject(start); + const ret1 = swift.memory.getObject(ret); + swift.memory.release(ret); + return ret1; + }, + loadNoncopyableObjects: function bjs_loadNoncopyableObjects(count) { + const ret = instance.exports.bjs_loadNoncopyableObjects(count); + const ret1 = swift.memory.getObject(ret); + swift.memory.release(ret); + return ret1; + }, + NoncopyableObjectBox, + }; + _exports = exports; + return exports; + }, + } +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolConditionalCompilation.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolConditionalCompilation.d.ts new file mode 100644 index 000000000..335665a4b --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolConditionalCompilation.d.ts @@ -0,0 +1,24 @@ +// 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 Logger { + log(message: string): void; + trace(message: string): void; + flush(): void; + verbosity: number; +} + +export type Exports = { +} +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/ProtocolConditionalCompilation.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolConditionalCompilation.js new file mode 100644 index 000000000..088c729ee --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolConditionalCompilation.js @@ -0,0 +1,418 @@ +// 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; + let decodeUTF8; + const immortalStrings = new Map(); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); + 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(word0, word1, word2) { + tmpRetString = decodeString(word0, word1, word2); + } + 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(word0, word1, word2) { + return swift.memory.retain(decodeString(word0, word1, word2)); + } + 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(word0, word1, word2) { + const value = decodeString(word0, word1, word2); + 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 start = ptr >>> 0; + const copy = memory.buffer.slice(start, start + byteLen); + taStack.push(Array.from(new Ctor(copy))); + } + bjs["bjs_core_register_type_handles"] = function() {}; + 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, word0, word1, word2) { + if (isSome === 0) { + tmpRetString = null; + } else { + tmpRetString = decodeString(word0, word1, word2); + } + } + 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_Logger_verbosity_get"] = function bjs_Logger_verbosity_get(self) { + try { + let ret = swift.memory.getObject(self).verbosity; + return ret; + } catch (error) { + setException(error); + return 0 + } + } + TestModule["bjs_Logger_verbosity_set"] = function bjs_Logger_verbosity_set(self, value) { + try { + swift.memory.getObject(self).verbosity = value; + } catch (error) { + setException(error); + } + } + TestModule["bjs_Logger_log"] = function bjs_Logger_log(self, messageWord0, messageWord1, messageWord2) { + try { + const string = decodeString(messageWord0, messageWord1, messageWord2); + swift.memory.getObject(self).log(string); + } catch (error) { + setException(error); + } + } + TestModule["bjs_Logger_trace"] = function bjs_Logger_trace(self, messageWord0, messageWord1, messageWord2) { + try { + const string = decodeString(messageWord0, messageWord1, messageWord2); + swift.memory.getObject(self).trace(string); + } catch (error) { + setException(error); + } + } + TestModule["bjs_Logger_flush"] = function bjs_Logger_flush(self) { + try { + swift.memory.getObject(self).flush(); + } catch (error) { + setException(error); + } + } + }, + setInstance: (i) => { + if (memory !== i.exports.memory) immortalStrings.clear(); + instance = i; + memory = instance.exports.memory; + + decodeUTF8 = (ptr, len) => { const bytes = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); return textDecoder.decode(bytes); } + decodeString = (() => { + const byteAt = (word0, word1, byteIndex) => + byteIndex < 4 + ? (word0 >>> (byteIndex * 8)) & 255 + : (word1 >>> ((byteIndex - 4) * 8)) & 255; + // Valid small Swift strings need at most eight UTF-16 code units. + const decodeSmallUTF8 = (word0, word1, count) => { + if (count > 8) { + throw new Error(`Unsupported Swift inline String length: ${count} UTF-8 bytes (maximum 8). The Swift String layout may have changed; update JavaScriptKit and regenerate BridgeJS glue.`); + } + let byteIndex = 0, + unitCount = 0, + u0 = 0, + u1 = 0, + u2 = 0, + u3 = 0, + u4 = 0, + u5 = 0, + u6 = 0, + u7 = 0; + while (byteIndex < count) { + const b0 = byteAt(word0, word1, byteIndex++); + let codePoint; + if (b0 < 128) codePoint = b0; + else if (b0 < 224) codePoint = ((b0 & 31) << 6) | (byteAt(word0, word1, byteIndex++) & 63); + else if (b0 < 240) { + const b1 = byteAt(word0, word1, byteIndex++), + b2 = byteAt(word0, word1, byteIndex++); + codePoint = ((b0 & 15) << 12) | ((b1 & 63) << 6) | (b2 & 63); + } else { + const b1 = byteAt(word0, word1, byteIndex++), + b2 = byteAt(word0, word1, byteIndex++), + b3 = byteAt(word0, word1, byteIndex++); + codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); + } + const supplementary = codePoint > 0xffff; + const codeUnit = supplementary + ? 0xd800 + ((codePoint - 0x10000) >>> 10) + : codePoint; + switch (unitCount++) { + case 0: + u0 = codeUnit; + break; + case 1: + u1 = codeUnit; + break; + case 2: + u2 = codeUnit; + break; + case 3: + u3 = codeUnit; + break; + case 4: + u4 = codeUnit; + break; + case 5: + u5 = codeUnit; + break; + case 6: + u6 = codeUnit; + break; + case 7: + u7 = codeUnit; + break; + } + if (supplementary) { + const lowSurrogate = 0xdc00 + ((codePoint - 0x10000) & 1023); + switch (unitCount++) { + case 0: + u0 = lowSurrogate; + break; + case 1: + u1 = lowSurrogate; + break; + case 2: + u2 = lowSurrogate; + break; + case 3: + u3 = lowSurrogate; + break; + case 4: + u4 = lowSurrogate; + break; + case 5: + u5 = lowSurrogate; + break; + case 6: + u6 = lowSurrogate; + break; + case 7: + u7 = lowSurrogate; + break; + } + } + } + switch (unitCount) { + case 0: + return ""; + case 1: + return String.fromCharCode(u0); + case 2: + return String.fromCharCode(u0, u1); + case 3: + return String.fromCharCode(u0, u1, u2); + case 4: + return String.fromCharCode(u0, u1, u2, u3); + case 5: + return String.fromCharCode(u0, u1, u2, u3, u4); + case 6: + return String.fromCharCode(u0, u1, u2, u3, u4, u5); + case 7: + return String.fromCharCode(u0, u1, u2, u3, u4, u5, u6); + case 8: + return String.fromCharCode(u0, u1, u2, u3, u4, u5, u6, u7); + } + }; + const decodeSmall = (word0, word1, word2) => { + const count = (word2 >>> 8) & 0x0f; + if ((word2 & 0x4000 /* ASCII */) === 0) return decodeSmallUTF8(word0, word1, count); + const char = String.fromCharCode; + switch (count) { + case 0: return ""; + case 1: return char(word0 & 0xff); + case 2: return char(word0 & 0xff, (word0 >>> 8) & 0xff); + case 3: return char(word0 & 0xff, (word0 >>> 8) & 0xff, (word0 >>> 16) & 0xff); + case 4: return char(word0 & 0xff, (word0 >>> 8) & 0xff, (word0 >>> 16) & 0xff, word0 >>> 24); + case 5: return char(word0 & 0xff, (word0 >>> 8) & 0xff, (word0 >>> 16) & 0xff, word0 >>> 24, word1 & 0xff); + case 6: return char(word0 & 0xff, (word0 >>> 8) & 0xff, (word0 >>> 16) & 0xff, word0 >>> 24, word1 & 0xff, (word1 >>> 8) & 0xff); + case 7: return char(word0 & 0xff, (word0 >>> 8) & 0xff, (word0 >>> 16) & 0xff, word0 >>> 24, word1 & 0xff, (word1 >>> 8) & 0xff, (word1 >>> 16) & 0xff); + case 8: return char(word0 & 0xff, (word0 >>> 8) & 0xff, (word0 >>> 16) & 0xff, word0 >>> 24, word1 & 0xff, (word1 >>> 8) & 0xff, (word1 >>> 16) & 0xff, word1 >>> 24); + default: + throw new Error(`Unsupported Swift inline String length: ${count} UTF-8 bytes (maximum 8). The Swift String layout may have changed; update JavaScriptKit and regenerate BridgeJS glue.`); + } + }; + return (word0, word1, word2) => { + if (word2 & 0x2000 /* small */) return decodeSmall(word0, word1, word2); + const ptr = (word1 + 20 /* nativeBias */) >>> 0; + const len = word0 >>> 0; + if ((word2 & 0x8000 /* immortal */) === 0 || len >= 0x200000 /* 2^21 Number key */) return decodeUTF8(ptr, len); + const key = ptr + len * 0x100000000; + const cached = immortalStrings.get(key); + if (cached !== undefined) return cached; + const value = decodeUTF8(ptr, len); + immortalStrings.set(key, value); + return value; + }; + })(); + + setException = (error) => { + instance.exports._swift_js_exception.value = swift.memory.retain(error) + } + }, + /** @param {WebAssembly.Instance} instance */ + createExports: (instance) => { + const js = swift.memory.heap; + const exports = { + }; + _exports = exports; + return exports; + }, + } +} \ No newline at end of file diff --git a/Sources/JavaScriptKit/BridgeJSIntrinsics.swift b/Sources/JavaScriptKit/BridgeJSIntrinsics.swift index 0b7fc3120..b20b257da 100644 --- a/Sources/JavaScriptKit/BridgeJSIntrinsics.swift +++ b/Sources/JavaScriptKit/BridgeJSIntrinsics.swift @@ -204,6 +204,18 @@ extension _BridgedSwiftStackType { } } +/// A noncopyable type BridgeJS can pass on the bridge stack, as an element of a `UniqueArray`. +public protocol _BridgedSwiftUniqueStackType: ~Copyable { + static func bridgeJSStackPop() -> Self + consuming func bridgeJSStackPush() + /// Pushes a reference of its own for JavaScript to release, and keeps this value's. + borrowing func bridgeJSStackPushRetained() + static func bridgeJSRetaining(_ other: borrowing Self) -> Self +} + +/// A noncopyable type BridgeJS passes only on the bridge stack, like a copyable `_BridgedSwiftTypeLoweredIntoVoidType`. +public protocol _BridgedSwiftUniqueTypeLoweredIntoVoidType: _BridgedSwiftUniqueStackType, ~Copyable {} + /// A type usable as a generic argument of an imported `@JSFunction`. public protocol BridgedSwiftGenericBridgeable: _BridgedSwiftStackType where StackLiftResult == Self { @@ -1114,6 +1126,36 @@ extension _JSBridgedClass { } } +extension _JSUniqueBridgedClass where Self: ~Copyable { + // MARK: ImportTS + @_spi(BridgeJS) @_transparent public borrowing func bridgeJSLowerParameter() -> Int32 { jsID } + @_spi(BridgeJS) public static func bridgeJSLiftReturn(_ id: Int32) -> Self { + Self(unsafelyAdopting: JSUniqueRef(adopting: id)) + } + + // MARK: ExportSwift + @_spi(BridgeJS) public static func bridgeJSLiftParameter(_ id: Int32) -> Self { + Self(unsafelyAdopting: JSUniqueRef(adopting: id)) + } + @_spi(BridgeJS) public consuming func bridgeJSLowerReturn() -> Int32 { takeJSRef().relinquish() } + + /// Returns an instance with a reference of its own to the object `other` holds. + public static func bridgeJSRetaining(_ other: borrowing Self) -> Self { + Self(unsafelyAdopting: JSUniqueRef(adopting: _swift_js_retain(other.jsID))) + } + + // MARK: Stack ABI + public static func bridgeJSStackPop() -> Self { + bridgeJSLiftParameter(_swift_js_pop_i32()) + } + public consuming func bridgeJSStackPush() { + _swift_js_push_i32(bridgeJSLowerReturn()) + } + public borrowing func bridgeJSStackPushRetained() { + _swift_js_push_i32(_swift_js_retain(jsID)) + } +} + /// A protocol that Swift protocol wrappers exposed from JavaScript must conform to. /// /// The conformance is automatically synthesized by the BridgeJS code generator. @@ -2250,8 +2292,14 @@ extension _BridgedAsOptional where Wrapped: _JSBridgedClass { // (`isSome`, object id) ABI while returns travel through the bridge stack. // // Stack push/pop is provided by the generic `Wrapped: _BridgedSwiftStackType` - // extension; only the direct parameter lift and the export return lowering need + // extension; only the direct parameter ABI and the export return lowering need // dedicated implementations here. + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> ( + isSome: Int32, value: Int32 + ) { + asOptional._bridgeJSLowerParameter(noneValue: 0, lowerWrapped: { $0.bridgeJSLowerParameter() }) + } + @_spi(BridgeJS) public static func bridgeJSLiftParameter(_ isSome: Int32, _ objectId: Int32) -> Self { Self( optional: Optional._bridgeJSLiftParameter( @@ -2267,6 +2315,91 @@ extension _BridgedAsOptional where Wrapped: _JSBridgedClass { } } +// `_BridgedAsOptional.Wrapped` must be copyable. The stack layout matches a copyable optional's. +extension Optional: _BridgedSwiftUniqueStackType where Wrapped: _BridgedSwiftUniqueStackType & ~Copyable { + @_spi(BridgeJS) public static func bridgeJSStackPop() -> Self { + if _swift_js_pop_i32() == 0 { + return nil + } + return Wrapped.bridgeJSStackPop() + } + @_spi(BridgeJS) public consuming func bridgeJSStackPush() { + switch consume self { + case .none: + _swift_js_push_i32(0) + case .some(let wrapped): + wrapped.bridgeJSStackPush() + _swift_js_push_i32(1) + } + } + @_spi(BridgeJS) public borrowing func bridgeJSStackPushRetained() { + switch self { + case .none: + _swift_js_push_i32(0) + case .some(let wrapped): + wrapped.bridgeJSStackPushRetained() + _swift_js_push_i32(1) + } + } + + /// Returns an optional with references of its own to the objects `other` holds. + @_spi(BridgeJS) public static func bridgeJSRetaining(_ other: borrowing Self) -> Self { + switch other { + case .none: + return nil + case .some(let wrapped): + return Wrapped.bridgeJSRetaining(wrapped) + } + } +} + +// The ABI matches an optional copyable wrapper's. +extension Optional where Wrapped: _JSUniqueBridgedClass & ~Copyable { + // MARK: ImportTS + @_spi(BridgeJS) public borrowing func bridgeJSLowerParameter() -> (isSome: Int32, value: Int32) { + switch self { + case .none: + return (isSome: 0, value: 0) + case .some(let wrapped): + return (isSome: 1, value: wrapped.bridgeJSLowerParameter()) + } + } + + @_spi(BridgeJS) public static func bridgeJSLiftReturn() -> Self { + bridgeJSStackPop() + } + + // MARK: ExportSwift + @_spi(BridgeJS) public static func bridgeJSLiftParameter(_ isSome: Int32, _ id: Int32) -> Self { + if isSome == 0 { + return nil + } + return Wrapped.bridgeJSLiftParameter(id) + } + + @_spi(BridgeJS) public consuming func bridgeJSLowerReturn() -> Void { + bridgeJSStackPush() + } +} + +extension Optional where Wrapped: _BridgedSwiftUniqueTypeLoweredIntoVoidType & ~Copyable { + // MARK: ImportTS + @_spi(BridgeJS) public borrowing func bridgeJSLowerParameter() { + bridgeJSStackPushRetained() + } + @_spi(BridgeJS) public static func bridgeJSLiftReturn() -> Self { + bridgeJSStackPop() + } + + // MARK: ExportSwift + @_spi(BridgeJS) public static func bridgeJSLiftParameter() -> Self { + bridgeJSStackPop() + } + @_spi(BridgeJS) public consuming func bridgeJSLowerReturn() { + bridgeJSStackPush() + } +} + extension _BridgedAsOptional where Wrapped: _BridgedSwiftProtocolWrapper { @_spi(BridgeJS) public static func bridgeJSLiftParameter(_ isSome: Int32, _ objectId: Int32) -> Self { Self( @@ -2548,6 +2681,77 @@ extension Array: _BridgedSwiftStackType where Element: _BridgedSwiftStackType, E } } +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +extension UniqueArray: _BridgedSwiftUniqueTypeLoweredIntoVoidType +where Element: _BridgedSwiftUniqueStackType & ~Copyable {} + +// The stack layout matches `Array`'s: the elements in order, then the count. +@available(anyAppleOS 27.0, *) +extension UniqueArray: _BridgedSwiftUniqueStackType where Element: _BridgedSwiftUniqueStackType & ~Copyable { + @_spi(BridgeJS) public static func bridgeJSStackPop() -> Self { + let count = Int(_swift_js_pop_i32()) + var result = UniqueArray(capacity: count) + for _ in 0.. Self { + var result = UniqueArray(capacity: other.count) + for index in other.indices { + result.append(Element.bridgeJSRetaining(other[index])) + } + return result + } + + private mutating func _bridgeJSReverse() { + var low = 0 + var high = count - 1 + while low < high { + swapAt(low, high) + low += 1 + high -= 1 + } + } + + // MARK: ImportTS + @_spi(BridgeJS) public borrowing func bridgeJSLowerParameter() { + bridgeJSStackPushRetained() + } + @_spi(BridgeJS) public static func bridgeJSLiftReturn() -> Self { + bridgeJSStackPop() + } + + // MARK: ExportSwift + @_spi(BridgeJS) public static func bridgeJSLiftParameter() -> Self { + bridgeJSStackPop() + } + @_spi(BridgeJS) public consuming func bridgeJSLowerReturn() { + bridgeJSStackPush() + } +} +#endif + // MARK: - Dictionary Support extension Dictionary: _BridgedSwiftStackType @@ -2648,6 +2852,50 @@ where Key == String, Value: _BridgedSwiftStackType, Value.StackLiftResult == Val return try result.get() } +/// Noncopyable-result overload of `_bjs_awaitPromise`. +@_spi(BridgeJS) +public func _bjs_awaitPromise< + T: ~Copyable, + R: _BridgeJSReleasableClosure, + E: _BridgeJSReleasableClosure +>( + makeResolveClosure: (@escaping (consuming sending T) -> Void) -> R, + makeRejectClosure: (@escaping (sending JSValue) -> Void) -> E, + _ body: (_ resolveRef: Int32, _ rejectRef: Int32) -> Void +) async throws(JSException) -> T { + let resolved = _BridgeJSResolvedValue() + var resolveClosure: R? + var rejectClosure: E? + let error: JSException? = await withCheckedContinuation { continuation in + let resolve = makeResolveClosure { value in + resolved.value = consume value + continuation.resume(returning: nil) + } + let reject = makeRejectClosure { value in + continuation.resume(returning: JSException(value)) + } + resolveClosure = resolve + rejectClosure = reject + body( + Int32(bitPattern: resolve.jsObject.id), + Int32(bitPattern: reject.jsObject.id) + ) + } + resolveClosure?.release() + rejectClosure?.release() + if let error { + throw error + } + guard let value = resolved.value.take() else { + fatalError("A promise resolved without a value") + } + return value +} + +private final class _BridgeJSResolvedValue { + var value: T? +} + /// Void-returning overload of `_bjs_awaitPromise`. /// /// Needed because `(Void) -> Void` is not the same as `() -> Void` in Swift (SE-0110), @@ -2690,17 +2938,17 @@ private func _swift_js_make_promise_extern() -> Int32 { _onlyAvailableOnWasm() } #endif // `@unchecked Sendable` is safe because the Wasm runtime is single-threaded. -private struct _BridgeJSMakePromiseContext: @unchecked Sendable { +private struct _BridgeJSMakePromiseContext: @unchecked Sendable { let promise: JSObject - let resolve: (JSObject, T) throws(JSException) -> Void + let resolve: (JSObject, borrowing T) throws(JSException) -> Void let reject: (JSObject, JSValue) throws(JSException) -> Void let body: () async throws(JSException) -> T } /// Returns a `Promise` synchronously and settles it from a `Task` via the generated /// `resolve` / `reject` thunks, which this library cannot name directly. -@_spi(BridgeJS) public func _bjs_makePromise( - resolve: @escaping (JSObject, T) throws(JSException) -> Void, +@_spi(BridgeJS) public func _bjs_makePromise( + resolve: @escaping (JSObject, borrowing T) throws(JSException) -> Void, reject: @escaping (JSObject, JSValue) throws(JSException) -> Void, _ body: @escaping () async throws(JSException) -> T ) -> Int32 { diff --git a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/BridgeJS-Configuration.md b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/BridgeJS-Configuration.md index b8856ac30..5cf1ddc14 100644 --- a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/BridgeJS-Configuration.md +++ b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/BridgeJS-Configuration.md @@ -105,6 +105,26 @@ console.log(a === b); // false — different JS wrapper each time For finer control, use the `@JS(identityMode:)` parameter on individual classes instead of the project-wide config. See for details. +### `noncopyableWrappers` + +Controls whether the Swift code generated from `bridge-js.d.ts` declares noncopyable `@JSClass` wrappers, described in . Default: `false`. + +```json +{ + "noncopyableWrappers": true +} +``` + +With `noncopyableWrappers: true`, the generated `BridgeJS.Macros.swift` differs from the default output in five ways: + +1. Every `@JSClass` struct is declared `~Copyable`. +2. A parameter or setter value whose type is a wrapper, an optional wrapper, or a `UniqueArray` of wrappers is `borrowing`. +3. A property or exported constant of such a type becomes `@JSGetterFunction func name() throws(JSException) -> T`, because Swift rejects a throwing getter of a noncopyable type. A writable property keeps its `@JSSetter` function. +4. `T[]` of a wrapper type `T` becomes `UniqueArray`, `(T | null)[]` becomes `UniqueArray>`, and `T[] | null` or an optional `T[]` property becomes `Optional>`. Arrays of other types stay `[T]`. +5. `T | undefined` and an optional property of a wrapper type become `Optional`, and `Record` becomes `[String: JSObject]`, because `JSUndefinedOr` and `Dictionary` cannot hold a noncopyable value. ts2swift prints a warning for each of these. + +Code that names `UniqueArray` needs Swift 6.4. Generate the bindings ahead of time with the command plugin, as describes. + ### `tools` Specify custom paths for external executables. This is particularly useful when working in environments like Xcode where the system PATH may not be inherited, or when you need to use a specific version of tools for your project. diff --git a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Protocols.md b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Protocols.md index 5bc907137..b9d954a68 100644 --- a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Protocols.md +++ b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Protocols.md @@ -229,5 +229,8 @@ struct AnyCounter: Counter, _BridgedSwiftProtocolWrapper { | Existential protocol composition: `any Protocol1 & Protocol2` | ❌ | | Generic requirements | ❌ | | Protocol-valued properties, parameters, or results in requirements | ❌ | +| Requirements inside `#if` | ✅ | > Note: For supported requirement types, see , , and . + +> Note: BridgeJS bridges the requirements of every clause of an `#if`, whichever clause is active. It wraps the members it generates for requirements that name `UniqueArray` in `#if compiler(>=6.4)`; any other requirement must name only types that exist in every build, and two clauses must not declare requirements with the same name. diff --git a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Importing-JavaScript/Importing-JS-Class.md b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Importing-JavaScript/Importing-JS-Class.md index 7c6ae5a03..5909b5214 100644 --- a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Importing-JavaScript/Importing-JS-Class.md +++ b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Importing-JavaScript/Importing-JS-Class.md @@ -83,6 +83,26 @@ const { exports } = await init({ **If you chose global or module-backed lookup:** Do not pass the class in `getImports()`; the runtime resolves it from `globalThis` or the copied module. +## Noncopyable wrappers + +A `@JSClass` struct declared `~Copyable` is a noncopyable wrapper. Each value holds its own reference to the JavaScript object, with no `JSObject` instance behind it, and releases the reference when the value is destroyed. + +```swift +@JSClass struct Element: ~Copyable { + @JSFunction func appendChild(_ child: borrowing Element) throws(JSException) + @JSFunction func removeChild(_ child: consuming Element) throws(JSException) + @JSGetterFunction func firstElementChild() throws(JSException) -> Element? +} +``` + +- A parameter of a wrapper type is `borrowing` or `consuming`. A `borrowing` parameter lends the reference for the call; a `consuming` one releases it when the call returns. +- Read a property of a wrapper type with `@JSGetterFunction func name() throws(JSException) -> T`. Swift rejects a throwing getter of a noncopyable type, so BridgeJS reports an error for `@JSGetter var` of a wrapper type. +- An array of wrappers is a `UniqueArray`, which Swift 6.4's standard library adds; `[T]` of a wrapper type is an error. If the package also builds with older Swift versions, put the declarations that name `UniqueArray` inside `#if compiler(>=6.4)`. BridgeJS wraps the code it generates for a declaration in the same `#if` only when the declaration's signature names `UniqueArray`, so keep other `@JS` and `@JSFunction` declarations outside it. +- Dictionaries of wrappers are not supported, and neither are wrapper-typed `@JS struct` fields or `@JS enum` associated values. +- A wrapper is not `Sendable`: its reference is valid only on the thread that created it. +- `init(unsafelyWrapping:)` converts a `JSObject` into a wrapper. It takes over the `JSObject`'s reference when no other Swift reference to that `JSObject` exists, and otherwise takes a reference of its own. `withView(as:_:)` lends the object to a closure as another wrapper type without taking a reference. +- `UniqueArray` is available from version 27 of Apple's operating systems. BridgeJS marks the declarations it generates that name `UniqueArray` with `@available(anyAppleOS 27.0, *)`, so a native build for an older version needs the same attribute on your declarations that name `UniqueArray`. A stored `UniqueArray` property of a `@JS class` cannot take the attribute, so such a class builds natively only for version 27 and later. WebAssembly builds are not affected. + ## Macro options For optional parameters (`jsName`, `from`, etc.), see the API reference: ``JSClass(jsName:from:)``, ``JSFunction(jsName:from:)``, ``JSGetter(jsName:from:)``, and ``JSSetter(jsName:from:)``. diff --git a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Supported-Types.md b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Supported-Types.md index 539f7ce15..fd9774213 100644 --- a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Supported-Types.md +++ b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Supported-Types.md @@ -14,7 +14,10 @@ Swift types and their JavaScript/TypeScript equivalents at the BridgeJS boundary | `[String: T]` | object | `Record` | | `Optional` | `null` or `T` | `T \| null` | | ``JSUndefinedOr`` `` | `undefined` or `T` | `T \| undefined` | -| ``JSObject`` | object | `object` | +| ``JSObject`` | object | `any` | +| ``JSUniqueRef`` | object | `any` | +| Noncopyable `@JSClass` struct | object | the struct's name | +| `UniqueArray` of a noncopyable `@JSClass` struct `T` | array | `T[]` | | ``JSValue`` | any | `any` | | ``JSTypedArray`` `` | TypedArray | `Uint8Array`, `Float32Array`, etc. | @@ -31,6 +34,10 @@ When using `JSTypedArray` (or convenience typealiases) in `@JS` signatures, t See for usage details. +## Availability + +BridgeJS copies a type's `@available` attributes, and those of the declarations and extensions that enclose it, onto the code it generates for the type and onto every other generated declaration that names the type in code a native build compiles. Generated declarations that name `UniqueArray` also get `@available(anyAppleOS 27.0, *)`. The platform versions in these attributes restrict only native builds for Apple platforms. See for noncopyable wrappers and `UniqueArray`. + ## Generic type parameters An imported `@JSFunction` can be generic over a type parameter constrained to `BridgedSwiftGenericBridgeable` (see ); exported `@JS` functions cannot yet. The constraint is satisfied by all supported primitives, `String`, `JSValue`, and any `@JS` struct, `@JS` enum, or `final @JS class`, including ones from another linked module. Do not write the conformance by hand; marking the type `@JS` is what provides it, together with the JavaScript side of the bridge. diff --git a/Sources/JavaScriptKit/FundamentalObjects/JSObject.swift b/Sources/JavaScriptKit/FundamentalObjects/JSObject.swift index 7bc799c64..4e24885e9 100644 --- a/Sources/JavaScriptKit/FundamentalObjects/JSObject.swift +++ b/Sources/JavaScriptKit/FundamentalObjects/JSObject.swift @@ -282,6 +282,10 @@ public class JSObject: Equatable, ExpressibleByDictionaryLiteral { }) deinit { + // `JSUniqueRef(taking:)` took the reference over. + if _id == 0 { + return + } #if _runtime(_multithreaded) if ownerTid != swjs_get_worker_thread_id_cached() { // If the object is not owned by the current thread diff --git a/Sources/JavaScriptKit/FundamentalObjects/JSUniqueRef.swift b/Sources/JavaScriptKit/FundamentalObjects/JSUniqueRef.swift new file mode 100644 index 000000000..2cf85eab8 --- /dev/null +++ b/Sources/JavaScriptKit/FundamentalObjects/JSUniqueRef.swift @@ -0,0 +1,92 @@ +import _CJavaScriptKit + +/// Owns one reference to a JavaScript value and releases it when destroyed. +@frozen public struct JSUniqueRef: ~Copyable { + @usableFromInline + internal let _id: Int32 + + #if _runtime(_multithreaded) + @usableFromInline + internal let ownerTid: Int32 + #endif + + @_spi(BridgeJS) + @inlinable + public var id: Int32 { + #if _runtime(_multithreaded) + precondition( + ownerTid == swjs_get_worker_thread_id_cached(), + "JSUniqueRef is being used on a thread other than the one that created it" + ) + #endif + return _id + } + + /// Takes over a reference the caller owns. + @_spi(BridgeJS) public init(adopting id: Int32) { + self._id = id + #if _runtime(_multithreaded) + self.ownerTid = swjs_get_worker_thread_id_cached() + #endif + } + + /// Takes a reference of its own to the value `object` holds. + public init(retaining object: JSObject) { + #if _runtime(_multithreaded) + precondition( + object.ownerTid == swjs_get_worker_thread_id_cached(), + "JSUniqueRef(retaining:) is called on a thread other than the one that owns the JSObject" + ) + #endif + self.init(adopting: _swift_js_retain(Int32(bitPattern: object.id))) + } + + /// Takes over `object`'s reference when no other Swift reference to `object` exists, and otherwise takes a + /// reference of its own. + public init(taking object: consuming JSObject) { + #if _runtime(_multithreaded) + precondition( + object.ownerTid == swjs_get_worker_thread_id_cached(), + "JSUniqueRef(taking:) is called on a thread other than the one that owns the JSObject" + ) + #endif + if isKnownUniquelyReferenced(&object) { + self.init(adopting: Int32(bitPattern: object._id)) + object._id = 0 + } else { + self.init(adopting: _swift_js_retain(Int32(bitPattern: object.id))) + } + } + + /// Returns the reference without releasing it. + @_spi(BridgeJS) public consuming func relinquish() -> Int32 { + let id = _id + discard self + return id + } + + deinit { + #if _runtime(_multithreaded) + if ownerTid != swjs_get_worker_thread_id_cached() { + swjs_release_remote(ownerTid, JavaScriptObjectRef(bitPattern: _id)) + return + } + #endif + swjs_release(JavaScriptObjectRef(bitPattern: _id)) + } +} + +/// The id is valid only on the thread that created it. +@available(*, unavailable) +extension JSUniqueRef: Sendable {} + +/// Lets BridgeJS bridge `JSUniqueRef`, and optionals of it, as it bridges noncopyable `@JSClass` wrappers. +extension JSUniqueRef: _JSUniqueBridgedClass { + public var jsID: Int32 { id } + + public init(unsafelyAdopting jsRef: consuming JSUniqueRef) { + self = jsRef + } + + public consuming func takeJSRef() -> JSUniqueRef { self } +} diff --git a/Sources/JavaScriptKit/JSBridgedType.swift b/Sources/JavaScriptKit/JSBridgedType.swift index 0eb282d8b..92ea9cfee 100644 --- a/Sources/JavaScriptKit/JSBridgedType.swift +++ b/Sources/JavaScriptKit/JSBridgedType.swift @@ -32,6 +32,48 @@ extension _JSBridgedClass { } } +/// A protocol that noncopyable `@JSClass` wrappers conform to. Each instance owns its JavaScript object. +/// +/// The conformance is automatically synthesized by `@JSClass` for `~Copyable` structs. +public protocol _JSUniqueBridgedClass: _BridgedSwiftUniqueStackType, ~Copyable { + /// The reference to the JavaScript object this instance owns. + var jsID: Int32 { get } + + /// Create an instance owning the given reference. + /// You may assume that the referenced object is an instance of the JavaScript class this type wraps. + init(unsafelyAdopting jsRef: consuming JSUniqueRef) + + consuming func takeJSRef() -> JSUniqueRef +} + +extension _JSUniqueBridgedClass where Self: ~Copyable { + /// Lends `body` an instance for `id` without taking ownership of the reference. + /// + /// Some other value must own `id` until `body` returns. Nothing checks that it does. + @_spi(BridgeJS) public static func withUnownedID( + _ id: Int32, + _ body: (borrowing Self) throws(E) -> R + ) throws(E) -> R { + let instance = Self(unsafelyAdopting: JSUniqueRef(adopting: id)) + do { + let result = try body(instance) + _ = instance.takeJSRef().relinquish() + return result + } catch { + _ = instance.takeJSRef().relinquish() + throw error + } + } + + /// Lends `body` an instance of `type` for the object this instance owns. + public borrowing func withView( + as type: T.Type, + _ body: (borrowing T) throws(E) -> R + ) throws(E) -> R { + try T.withUnownedID(jsID, body) + } +} + /// Conform to this protocol when your Swift class wraps a JavaScript class. public protocol JSBridgedClass: JSBridgedType, _JSBridgedClass { /// The constructor function for the JavaScript class diff --git a/Sources/JavaScriptKit/Macros.swift b/Sources/JavaScriptKit/Macros.swift index 1e1b72dfb..f535f5546 100644 --- a/Sources/JavaScriptKit/Macros.swift +++ b/Sources/JavaScriptKit/Macros.swift @@ -204,6 +204,18 @@ public macro JS( public macro JSGetter(jsName: JSName? = nil, from: JSImportFrom? = nil) = #externalMacro(module: "BridgeJSMacros", type: "JSGetterMacro") +/// A macro that reads a JavaScript property through a throwing function. +/// +/// Use it instead of ``JSGetter(jsName:from:)`` when the property's type is a noncopyable `@JSClass` wrapper: +/// Swift rejects throwing getters of noncopyable type. +/// +/// ```swift +/// @JSGetterFunction func style() throws(JSException) -> JSCSSStyleDeclaration +/// ``` +@attached(body) +public macro JSGetterFunction(jsName: JSName? = nil, from: JSImportFrom? = nil) = + #externalMacro(module: "BridgeJSMacros", type: "JSGetterFunctionMacro") + /// A macro that generates a Swift function body that writes a value to JavaScript. /// /// This macro is used by BridgeJS-generated Swift declarations. @@ -269,7 +281,18 @@ public macro JSFunction(jsName: JSName? = nil, from: JSImportFrom? = nil) = /// Use `.snippet("/path/to/module.js")` to construct a named class export from a file rooted at the Swift target, /// or `.module("@scope/package")` to construct a named class export from an external module. /// Pass `jsName: .default` to construct the module's default export. -@attached(member, names: named(jsObject), named(init(unsafelyWrapping:))) -@attached(extension, conformances: _JSBridgedClass) +/// +/// On a `~Copyable` struct, the wrapper owns a `JSUniqueRef` instead of a `JSObject` and conforms to +/// `_JSUniqueBridgedClass`. +@attached( + member, + names: named(jsObject), + named(init(unsafelyWrapping:)), + named(jsRef), + named(init(unsafelyAdopting:)), + named(jsID), + named(takeJSRef) +) +@attached(extension, conformances: _JSBridgedClass, _JSUniqueBridgedClass) public macro JSClass(jsName: JSName? = nil, from: JSImportFrom? = nil) = #externalMacro(module: "BridgeJSMacros", type: "JSClassMacro") diff --git a/Tests/BridgeJSRuntimeTests/ClosureSupportTests.swift b/Tests/BridgeJSRuntimeTests/ClosureSupportTests.swift index d6bb9c839..8653733b6 100644 --- a/Tests/BridgeJSRuntimeTests/ClosureSupportTests.swift +++ b/Tests/BridgeJSRuntimeTests/ClosureSupportTests.swift @@ -286,9 +286,8 @@ final class ClosureSupportTests: XCTestCase { _ = try? ClosureSupportImports.jsCallTwice(0, closure) } - // Trigger GC and read heap size from JS side let after = try ClosureSupportImports.jsHeapCount() - XCTAssertEqual(after, baseline, "Heap entry count should return to baseline after GC") + XCTAssertEqual(after, baseline, "References held by the runtime should return to baseline") } } diff --git a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift index 8bfe460fc..f806edda3 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift +++ b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift @@ -200,6 +200,258 @@ public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13D #endif } +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_Si") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_Si_extern(_ callback: Int32, _ param0: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_Si_extern(_ callback: Int32, _ param0: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_Si(_ callback: Int32, _ param0: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_Si_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_Si") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_Si_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTests17NoncopyableObjectV_Si { + static func bridgeJSLift(_ callbackId: Int32) -> (borrowing NoncopyableObject) -> Int { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let param0Value = param0.bridgeJSLowerParameter() + let callbackValue = callback.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_Si(callbackValue, param0Value) + return Int.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (borrowing NoncopyableObject) -> Int { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (borrowing NoncopyableObject) -> Int) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_Si, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_Si") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_Si") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_Si(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { + #if arch(wasm32) + let param0 = NoncopyableObject.bridgeJSLiftParameter(param0) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(borrowing NoncopyableObject) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let ret = closure(param0) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_y_extern(_ callback: Int32, _ param0: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_y_extern(_ callback: Int32, _ param0: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_y(_ callback: Int32, _ param0: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_y_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTests17NoncopyableObjectV_y { + static func bridgeJSLift(_ callbackId: Int32) -> (borrowing NoncopyableObject) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let param0Value = param0.bridgeJSLowerParameter() + let callbackValue = callback.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_y(callbackValue, param0Value) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (borrowing NoncopyableObject) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (borrowing NoncopyableObject) -> Void) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests17NoncopyableObjectV_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { + #if arch(wasm32) + let param0 = NoncopyableObject.bridgeJSLiftParameter(param0) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(borrowing NoncopyableObject) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(param0) + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_Si") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_Si_extern(_ callback: Int32, _ param0: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_Si_extern(_ callback: Int32, _ param0: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_Si(_ callback: Int32, _ param0: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_Si_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_Si") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_Si_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_Si { + static func bridgeJSLift(_ callbackId: Int32) -> (CopyableObjectRoundtrip) -> Int { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let param0Value = param0.bridgeJSLowerParameter() + let callbackValue = callback.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_Si(callbackValue, param0Value) + return Int.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (CopyableObjectRoundtrip) -> Int { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (CopyableObjectRoundtrip) -> Int) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_Si, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_Si") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_Si") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_Si(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { + #if arch(wasm32) + let param0 = CopyableObjectRoundtrip.bridgeJSLiftParameter(param0) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(CopyableObjectRoundtrip) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let ret = closure(param0) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_y_extern(_ callback: Int32, _ param0: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_y_extern(_ callback: Int32, _ param0: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_y(_ callback: Int32, _ param0: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_y_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_y { + static func bridgeJSLift(_ callbackId: Int32) -> (CopyableObjectRoundtrip) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let param0Value = param0.bridgeJSLowerParameter() + let callbackValue = callback.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_y(callbackValue, param0Value) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (CopyableObjectRoundtrip) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (CopyableObjectRoundtrip) -> Void) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests23CopyableObjectRoundtripC_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { + #if arch(wasm32) + let param0 = CopyableObjectRoundtrip.bridgeJSLiftParameter(param0) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(CopyableObjectRoundtrip) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(param0) + #else + fatalError("Only available on WebAssembly") + #endif +} + #if arch(wasm32) @_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS") fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS_extern(_ callback: Int32, _ param0Word0: Int32, _ param0Word1: Int32, _ param0Word2: Int32) -> Int32 @@ -1146,6 +1398,80 @@ public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_ #endif } +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSa17NoncopyableObjectV_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSa17NoncopyableObjectV_y_extern(_ callback: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSa17NoncopyableObjectV_y_extern(_ callback: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSa17NoncopyableObjectV_y(_ callback: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSa17NoncopyableObjectV_y_extern(callback) +} +#endif + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSa17NoncopyableObjectV_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSa17NoncopyableObjectV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSa17NoncopyableObjectV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSa17NoncopyableObjectV_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSa17NoncopyableObjectV_y_extern(boxPtr, file, line) +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +private enum _BJS_Closure_20BridgeJSRuntimeTestsSa17NoncopyableObjectV_y { + static func bridgeJSLift(_ callbackId: Int32) -> (borrowing UniqueArray) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let _ = param0.bridgeJSLowerParameter() + let callbackValue = callback.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSa17NoncopyableObjectV_y(callbackValue) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +extension JSTypedClosure where Signature == (borrowing UniqueArray) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (borrowing UniqueArray) -> Void) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSa17NoncopyableObjectV_y, + body: body, + fileID: fileID, + line: line + ) + } +} +#endif + +#if compiler(>=6.4) +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSa17NoncopyableObjectV_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSa17NoncopyableObjectV_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSa17NoncopyableObjectV_y(_ boxPtr: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let param0 = UniqueArray.bridgeJSStackPop() + let closure = Unmanaged<_BridgeJSTypedClosureBox<(borrowing UniqueArray) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(param0) + #else + fatalError("Only available on WebAssembly") + #endif +} +#endif + #if arch(wasm32) @_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSa7JSValueV_Sa7JSValueV") fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSa7JSValueV_Sa7JSValueV_extern(_ callback: Int32) -> Void @@ -2125,41 +2451,38 @@ public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq1 } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Word0: Int32, _ param0Word1: Int32, _ param0Word2: Int32) -> Int32 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_Si") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_Si_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 #else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Word0: Int32, _ param0Word1: Int32, _ param0Word2: Int32) -> Int32 { +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_Si_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Word0: Int32, _ param0Word1: Int32, _ param0Word2: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(callback, param0IsSome, param0Word0, param0Word1, param0Word2) +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_Si(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_Si_extern(callback, param0IsSome, param0Value) } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_Si") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 #else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(boxPtr, file, line) +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_Si_extern(boxPtr, file, line) } -private enum _BJS_Closure_20BridgeJSRuntimeTestsSq5ThemeO_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { +private enum _BJS_Closure_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_Si { + static func bridgeJSLift(_ callbackId: Int32) -> (borrowing Optional) -> Int { let callback = JSObject.bridgeJSLiftParameter(callbackId) return { [callback] param0 in #if arch(wasm32) - let ret0 = param0.bridgeJSWithLoweredParameter { (param0IsSome, param0Word0, param0Word1, param0Word2) in - let callbackValue = callback.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS(callbackValue, param0IsSome, param0Word0, param0Word1, param0Word2) - return ret - } - let ret = ret0 - return String.bridgeJSLiftReturn(ret) + let (param0IsSome, param0Value) = param0.bridgeJSLowerParameter() + let callbackValue = callback.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_Si(callbackValue, param0IsSome, param0Value) + return Int.bridgeJSLiftReturn(ret) #else fatalError("Only available on WebAssembly") #endif @@ -2167,10 +2490,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestsSq5ThemeO_SS { } } -extension JSTypedClosure where Signature == (Optional) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { +extension JSTypedClosure where Signature == (borrowing Optional) -> Int { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (borrowing Optional) -> Int) { self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_Si, body: body, fileID: fileID, line: line @@ -2178,12 +2501,12 @@ extension JSTypedClosure where Signature == (Optional) -> String { } } -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_Si") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_Si") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_Si(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 { #if arch(wasm32) - let param0 = Optional.bridgeJSLiftParameter(param0IsSome, param0Bytes, param0Length) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let param0 = Optional.bridgeJSLiftParameter(param0IsSome, param0Value) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(borrowing Optional) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure let ret = closure(param0) return ret.bridgeJSLowerReturn() #else @@ -2192,31 +2515,160 @@ public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5 } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> Int32 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Void #else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> Int32 { +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Void { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(callback, param0IsSome, param0Pointer) +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_y(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_y_extern(callback, param0IsSome, param0Value) } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 #else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(boxPtr, file, line) +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_y_extern(boxPtr, file, line) } -private enum _BJS_Closure_20BridgeJSRuntimeTestsSq7GreeterC_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { +private enum _BJS_Closure_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_y { + static func bridgeJSLift(_ callbackId: Int32) -> (borrowing Optional) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let (param0IsSome, param0Value) = param0.bridgeJSLowerParameter() + let callbackValue = callback.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_y(callbackValue, param0IsSome, param0Value) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (borrowing Optional) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (borrowing Optional) -> Void) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_y(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: Int32) -> Void { + #if arch(wasm32) + let param0 = Optional.bridgeJSLiftParameter(param0IsSome, param0Value) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(borrowing Optional) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(param0) + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Word0: Int32, _ param0Word1: Int32, _ param0Word2: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Word0: Int32, _ param0Word1: Int32, _ param0Word2: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Word0: Int32, _ param0Word1: Int32, _ param0Word2: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(callback, param0IsSome, param0Word0, param0Word1, param0Word2) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsSq5ThemeO_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let ret0 = param0.bridgeJSWithLoweredParameter { (param0IsSome, param0Word0, param0Word1, param0Word2) in + let callbackValue = callback.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS(callbackValue, param0IsSome, param0Word0, param0Word1, param0Word2) + return ret + } + let ret = ret0 + return String.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Optional) -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + #if arch(wasm32) + let param0 = Optional.bridgeJSLiftParameter(param0IsSome, param0Bytes, param0Length) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let ret = closure(param0) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(callback, param0IsSome, param0Pointer) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsSq7GreeterC_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { let callback = JSObject.bridgeJSLiftParameter(callbackId) return { [callback] param0 in #if arch(wasm32) @@ -3131,6 +3583,68 @@ public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11 #endif } +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss17NoncopyableObjectV_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss17NoncopyableObjectV_y_extern(_ callback: Int32, _ param0: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss17NoncopyableObjectV_y_extern(_ callback: Int32, _ param0: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss17NoncopyableObjectV_y(_ callback: Int32, _ param0: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss17NoncopyableObjectV_y_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss17NoncopyableObjectV_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss17NoncopyableObjectV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss17NoncopyableObjectV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss17NoncopyableObjectV_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss17NoncopyableObjectV_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestss17NoncopyableObjectV_y { + static func bridgeJSLift(_ callbackId: Int32) -> (consuming sending NoncopyableObject) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let param0Value = param0.bridgeJSLowerParameter() + let callbackValue = callback.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss17NoncopyableObjectV_y(callbackValue, param0Value) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (consuming sending NoncopyableObject) -> Void { + static func sending(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (consuming sending NoncopyableObject) -> Void) -> Self { + Self( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss17NoncopyableObjectV_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss17NoncopyableObjectV_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss17NoncopyableObjectV_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss17NoncopyableObjectV_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { + #if arch(wasm32) + let param0 = NoncopyableObject.bridgeJSLiftParameter(param0) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(consuming sending NoncopyableObject) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(param0) + #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 @@ -3193,6 +3707,68 @@ public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18 #endif } +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss23CopyableObjectRoundtripC_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss23CopyableObjectRoundtripC_y_extern(_ callback: Int32, _ param0: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss23CopyableObjectRoundtripC_y_extern(_ callback: Int32, _ param0: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss23CopyableObjectRoundtripC_y(_ callback: Int32, _ param0: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss23CopyableObjectRoundtripC_y_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss23CopyableObjectRoundtripC_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss23CopyableObjectRoundtripC_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss23CopyableObjectRoundtripC_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss23CopyableObjectRoundtripC_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss23CopyableObjectRoundtripC_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestss23CopyableObjectRoundtripC_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending CopyableObjectRoundtrip) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let param0Value = param0.bridgeJSLowerParameter() + let callbackValue = callback.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss23CopyableObjectRoundtripC_y(callbackValue, param0Value) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (sending CopyableObjectRoundtrip) -> Void { + static func sending(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending CopyableObjectRoundtrip) -> Void) -> Self { + Self( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss23CopyableObjectRoundtripC_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss23CopyableObjectRoundtripC_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss23CopyableObjectRoundtripC_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss23CopyableObjectRoundtripC_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { + #if arch(wasm32) + let param0 = CopyableObjectRoundtrip.bridgeJSLiftParameter(param0) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending CopyableObjectRoundtrip) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(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 @@ -3442,6 +4018,80 @@ public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS #endif } +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSa17NoncopyableObjectV_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSa17NoncopyableObjectV_y_extern(_ callback: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSa17NoncopyableObjectV_y_extern(_ callback: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSa17NoncopyableObjectV_y(_ callback: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSa17NoncopyableObjectV_y_extern(callback) +} +#endif + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSa17NoncopyableObjectV_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSa17NoncopyableObjectV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSa17NoncopyableObjectV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSa17NoncopyableObjectV_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSa17NoncopyableObjectV_y_extern(boxPtr, file, line) +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +private enum _BJS_Closure_20BridgeJSRuntimeTestssSa17NoncopyableObjectV_y { + static func bridgeJSLift(_ callbackId: Int32) -> (consuming sending UniqueArray) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let _ = param0.bridgeJSLowerParameter() + let callbackValue = callback.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSa17NoncopyableObjectV_y(callbackValue) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +extension JSTypedClosure where Signature == (consuming sending UniqueArray) -> Void { + static func sending(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (consuming sending UniqueArray) -> Void) -> Self { + Self( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSa17NoncopyableObjectV_y, + body: body, + fileID: fileID, + line: line + ) + } +} +#endif + +#if compiler(>=6.4) +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSa17NoncopyableObjectV_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSa17NoncopyableObjectV_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSa17NoncopyableObjectV_y(_ boxPtr: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let param0 = UniqueArray.bridgeJSStackPop() + let closure = Unmanaged<_BridgeJSTypedClosureBox<(consuming sending UniqueArray) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(param0) + #else + fatalError("Only available on WebAssembly") + #endif +} +#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 @@ -3815,22 +4465,84 @@ public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSi } #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 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq17NoncopyableObjectV_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq17NoncopyableObjectV_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Void #else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Void { +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq17NoncopyableObjectV_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: 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) +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq17NoncopyableObjectV_y(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq17NoncopyableObjectV_y_extern(callback, param0IsSome, param0Value) } #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 +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq17NoncopyableObjectV_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq17NoncopyableObjectV_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 { +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq17NoncopyableObjectV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq17NoncopyableObjectV_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq17NoncopyableObjectV_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestssSq17NoncopyableObjectV_y { + static func bridgeJSLift(_ callbackId: Int32) -> (consuming sending Optional) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let (param0IsSome, param0Value) = param0.bridgeJSLowerParameter() + let callbackValue = callback.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq17NoncopyableObjectV_y(callbackValue, param0IsSome, param0Value) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (consuming sending Optional) -> Void { + static func sending(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (consuming sending Optional) -> Void) -> Self { + Self( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq17NoncopyableObjectV_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq17NoncopyableObjectV_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq17NoncopyableObjectV_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq17NoncopyableObjectV_y(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: Int32) -> Void { + #if arch(wasm32) + let param0 = Optional.bridgeJSLiftParameter(param0IsSome, param0Value) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(consuming sending Optional) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(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 @@ -3939,6 +4651,80 @@ public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq #endif } +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSa17NoncopyableObjectV_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSa17NoncopyableObjectV_y_extern(_ callback: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSa17NoncopyableObjectV_y_extern(_ callback: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSa17NoncopyableObjectV_y(_ callback: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSa17NoncopyableObjectV_y_extern(callback) +} +#endif + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSa17NoncopyableObjectV_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSa17NoncopyableObjectV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSa17NoncopyableObjectV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSa17NoncopyableObjectV_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSa17NoncopyableObjectV_y_extern(boxPtr, file, line) +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +private enum _BJS_Closure_20BridgeJSRuntimeTestssSqSa17NoncopyableObjectV_y { + static func bridgeJSLift(_ callbackId: Int32) -> (consuming sending Optional>) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let _ = param0.bridgeJSLowerParameter() + let callbackValue = callback.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSa17NoncopyableObjectV_y(callbackValue) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +extension JSTypedClosure where Signature == (consuming sending Optional>) -> Void { + static func sending(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (consuming sending Optional>) -> Void) -> Self { + Self( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSa17NoncopyableObjectV_y, + body: body, + fileID: fileID, + line: line + ) + } +} +#endif + +#if compiler(>=6.4) +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSa17NoncopyableObjectV_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSa17NoncopyableObjectV_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSa17NoncopyableObjectV_y(_ boxPtr: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let param0 = Optional>.bridgeJSLiftParameter() + let closure = Unmanaged<_BridgeJSTypedClosureBox<(consuming sending Optional>) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(param0) + #else + fatalError("Only available on WebAssembly") + #endif +} +#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 @@ -5254,6 +6040,112 @@ fileprivate func bjs_JSNameTransformer_apply_extern(_ jsObject: Int32, _ value: return bjs_JSNameTransformer_apply_extern(jsObject, value) } +extension NoncopyableObjectVisitor where Self: _BridgedSwiftProtocolWrapper { + func visit(_ object: borrowing NoncopyableObject) -> Int { + let objectValue = object.bridgeJSLowerParameter() + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObjectVisitor_visit(jsObjectValue, objectValue) + return Int.bridgeJSLiftReturn(ret) + } + + #if compiler(>=6.4) + @available(anyAppleOS 27.0, *) + func visitAll(_ objects: borrowing UniqueArray) -> Int { + let _ = objects.bridgeJSLowerParameter() + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObjectVisitor_visitAll(jsObjectValue) + return Int.bridgeJSLiftReturn(ret) + } + #endif + + #if compiler(>=6.4) + @available(anyAppleOS 27.0, *) + func makeAll(_ count: Int) -> UniqueArray { + let countValue = count.bridgeJSLowerParameter() + let jsObjectValue = jsObject.bridgeJSLowerParameter() + bjs_NoncopyableObjectVisitor_makeAll(jsObjectValue, countValue) + return UniqueArray.bridgeJSLiftReturn() + } + #endif +} + +struct AnyNoncopyableObjectVisitor: NoncopyableObjectVisitor, _BridgedSwiftProtocolWrapper { + let jsObject: JSObject + + static func bridgeJSLiftParameter(_ value: Int32) -> Self { + return AnyNoncopyableObjectVisitor(jsObject: JSObject(id: UInt32(bitPattern: value))) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableObjectVisitor_visit") +fileprivate func bjs_NoncopyableObjectVisitor_visit_extern(_ jsObject: Int32, _ object: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObjectVisitor_visit_extern(_ jsObject: Int32, _ object: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectVisitor_visit(_ jsObject: Int32, _ object: Int32) -> Int32 { + return bjs_NoncopyableObjectVisitor_visit_extern(jsObject, object) +} + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableObjectVisitor_visitAll") +fileprivate func bjs_NoncopyableObjectVisitor_visitAll_extern(_ jsObject: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObjectVisitor_visitAll_extern(_ jsObject: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectVisitor_visitAll(_ jsObject: Int32) -> Int32 { + return bjs_NoncopyableObjectVisitor_visitAll_extern(jsObject) +} +#endif + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableObjectVisitor_makeAll") +fileprivate func bjs_NoncopyableObjectVisitor_makeAll_extern(_ jsObject: Int32, _ count: Int32) -> Void +#else +fileprivate func bjs_NoncopyableObjectVisitor_makeAll_extern(_ jsObject: Int32, _ count: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectVisitor_makeAll(_ jsObject: Int32, _ count: Int32) -> Void { + return bjs_NoncopyableObjectVisitor_makeAll_extern(jsObject, count) +} +#endif + +extension NoncopyableOptionalObjectVisitor where Self: _BridgedSwiftProtocolWrapper { + func visit(_ object: borrowing Optional) -> Int { + let (objectIsSome, objectValue) = object.bridgeJSLowerParameter() + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = bjs_NoncopyableOptionalObjectVisitor_visit(jsObjectValue, objectIsSome, objectValue) + return Int.bridgeJSLiftReturn(ret) + } +} + +struct AnyNoncopyableOptionalObjectVisitor: NoncopyableOptionalObjectVisitor, _BridgedSwiftProtocolWrapper { + let jsObject: JSObject + + static func bridgeJSLiftParameter(_ value: Int32) -> Self { + return AnyNoncopyableOptionalObjectVisitor(jsObject: JSObject(id: UInt32(bitPattern: value))) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableOptionalObjectVisitor_visit") +fileprivate func bjs_NoncopyableOptionalObjectVisitor_visit_extern(_ jsObject: Int32, _ objectIsSome: Int32, _ objectValue: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableOptionalObjectVisitor_visit_extern(_ jsObject: Int32, _ objectIsSome: Int32, _ objectValue: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableOptionalObjectVisitor_visit(_ jsObject: Int32, _ objectIsSome: Int32, _ objectValue: Int32) -> Int32 { + return bjs_NoncopyableOptionalObjectVisitor_visit_extern(jsObject, objectIsSome, objectValue) +} + extension Severity: _BridgedSwiftCaseEnum { @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { return bridgeJSRawValue @@ -11989,186 +12881,485 @@ public func _bjs_greetCount(_ count: Int32) -> Void { #endif } -@_expose(wasm, "bjs_roundTripPointerFields") -@_cdecl("bjs_roundTripPointerFields") -public func _bjs_roundTripPointerFields() -> Void { +@_expose(wasm, "bjs_noncopyableTake") +@_cdecl("bjs_noncopyableTake") +public func _bjs_noncopyableTake(_ object: Int32) -> Int32 { #if arch(wasm32) - let value = PointerFields.bridgeJSLiftParameter() - let ret = roundTripPointerFields(_: value) + let object = NoncopyableObject.bridgeJSLiftParameter(object) + let ret = noncopyableTake(_: object) 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_noncopyableConsume") +@_cdecl("bjs_noncopyableConsume") +public func _bjs_noncopyableConsume(_ object: Int32) -> Int32 { #if arch(wasm32) - let point = DataPoint.bridgeJSLiftParameter() - let ret = testStructDefault(point: point) + let object = NoncopyableObject.bridgeJSLiftParameter(object) + let ret = noncopyableConsume(_: object) 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_noncopyableMake") +@_cdecl("bjs_noncopyableMake") +public func _bjs_noncopyableMake(_ start: Int32) -> Int32 { #if arch(wasm32) - let cart = CopyableCart.bridgeJSLiftParameter() - let ret = cartToJSObject(_: cart) + let start = Int.bridgeJSLiftParameter(start) + let ret = noncopyableMake(_: start) 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_noncopyableLoad") +@_cdecl("bjs_noncopyableLoad") +public func _bjs_noncopyableLoad(_ start: Int32) -> Int32 { #if arch(wasm32) - let cart = CopyableNestedCart.bridgeJSLiftParameter() - let ret = nestedCartToJSObject(_: cart) - return ret.bridgeJSLowerReturn() + let start = Int.bridgeJSLiftParameter(start) + return _bjs_makePromise(resolve: Promise_resolve_17NoncopyableObjectV, reject: Promise_reject) { + return await noncopyableLoad(_: start) + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripDataPoint") -@_cdecl("bjs_roundTripDataPoint") -public func _bjs_roundTripDataPoint() -> Void { +@_expose(wasm, "bjs_noncopyableCallWith") +@_cdecl("bjs_noncopyableCallWith") +public func _bjs_noncopyableCallWith(_ start: Int32, _ body: Int32) -> Int32 { #if arch(wasm32) - let data = DataPoint.bridgeJSLiftParameter() - let ret = roundTripDataPoint(_: data) + let body = _BJS_Closure_20BridgeJSRuntimeTests17NoncopyableObjectV_Si.bridgeJSLift(body) + let start = Int.bridgeJSLiftParameter(start) + let ret = noncopyableCallWith(_: start, _: body) 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_noncopyableCallWithOptional") +@_cdecl("bjs_noncopyableCallWithOptional") +public func _bjs_noncopyableCallWithOptional(_ start: Int32, _ body: Int32) -> Int32 { #if arch(wasm32) - let point = PublicPoint.bridgeJSLiftParameter() - let ret = roundTripPublicPoint(_: point) + let body = _BJS_Closure_20BridgeJSRuntimeTestsSq17NoncopyableObjectV_Si.bridgeJSLift(body) + let start = Int.bridgeJSLiftParameter(start) + let ret = noncopyableCallWithOptional(_: start, _: body) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripPublicPoint") -@_cdecl("bjs_asyncRoundTripPublicPoint") -public func _bjs_asyncRoundTripPublicPoint() -> Int32 { +@_expose(wasm, "bjs_noncopyableTakeOptional") +@_cdecl("bjs_noncopyableTakeOptional") +public func _bjs_noncopyableTakeOptional(_ objectIsSome: Int32, _ objectValue: Int32) -> Int32 { #if arch(wasm32) - let point = PublicPoint.bridgeJSLiftParameter() - return _bjs_makePromise(resolve: Promise_resolve_11PublicPointV, reject: Promise_reject) { - return await asyncRoundTripPublicPoint(_: point) - } + let object = Optional.bridgeJSLiftParameter(objectIsSome, objectValue) + let ret = noncopyableTakeOptional(_: object) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripPublicPointThrows") -@_cdecl("bjs_asyncRoundTripPublicPointThrows") -public func _bjs_asyncRoundTripPublicPointThrows() -> Int32 { +@_expose(wasm, "bjs_copyableTakeOptional") +@_cdecl("bjs_copyableTakeOptional") +public func _bjs_copyableTakeOptional(_ copyableIsSome: Int32, _ copyableValue: Int32) -> Int32 { #if arch(wasm32) - let point = PublicPoint.bridgeJSLiftParameter() - return _bjs_makePromise(resolve: Promise_resolve_11PublicPointV, reject: Promise_reject) { () async throws(JSException) -> PublicPoint in - return try await asyncRoundTripPublicPointThrows(_: point) - } + let copyable = Optional.bridgeJSLiftParameter(copyableIsSome, copyableValue) + let ret = copyableTakeOptional(_: copyable) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncStructOrThrow") -@_cdecl("bjs_asyncStructOrThrow") -public func _bjs_asyncStructOrThrow(_ shouldThrow: Int32) -> Int32 { +@_expose(wasm, "bjs_noncopyableFindOptional") +@_cdecl("bjs_noncopyableFindOptional") +public func _bjs_noncopyableFindOptional(_ start: Int32) -> Void { #if arch(wasm32) - let shouldThrow = Bool.bridgeJSLiftParameter(shouldThrow) - return _bjs_makePromise(resolve: Promise_resolve_11PublicPointV, reject: Promise_reject) { () async throws(JSException) -> PublicPoint in - return try await asyncStructOrThrow(_: shouldThrow) - } + let start = Int.bridgeJSLiftParameter(start) + let ret = noncopyableFindOptional(_: start) + 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_noncopyableVisit") +@_cdecl("bjs_noncopyableVisit") +public func _bjs_noncopyableVisit(_ visitor: Int32, _ start: Int32) -> Int32 { #if arch(wasm32) - let b = PublicPoint.bridgeJSLiftParameter() - let a = PublicPoint.bridgeJSLiftParameter() - return _bjs_makePromise(resolve: Promise_resolve_11PublicPointV, reject: Promise_reject) { - return await asyncCombinePublicPoints(_: a, _: b) - } + let start = Int.bridgeJSLiftParameter(start) + let visitor = AnyNoncopyableObjectVisitor.bridgeJSLiftParameter(visitor) + let ret = noncopyableVisit(_: visitor, _: start) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripContact") -@_cdecl("bjs_asyncRoundTripContact") -public func _bjs_asyncRoundTripContact() -> Int32 { +@_expose(wasm, "bjs_noncopyableVisitOptional") +@_cdecl("bjs_noncopyableVisitOptional") +public func _bjs_noncopyableVisitOptional(_ visitor: Int32, _ start: Int32) -> Int32 { #if arch(wasm32) - let contact = Contact.bridgeJSLiftParameter() - return _bjs_makePromise(resolve: Promise_resolve_7ContactV, reject: Promise_reject) { - return await asyncRoundTripContact(_: contact) - } + let start = Int.bridgeJSLiftParameter(start) + let visitor = AnyNoncopyableOptionalObjectVisitor.bridgeJSLiftParameter(visitor) + let ret = noncopyableVisitOptional(_: visitor, _: start) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripPublicPointArray") -@_cdecl("bjs_asyncRoundTripPublicPointArray") -public func _bjs_asyncRoundTripPublicPointArray() -> Int32 { +@_expose(wasm, "bjs_noncopyableMakeReader") +@_cdecl("bjs_noncopyableMakeReader") +public func _bjs_noncopyableMakeReader() -> Int32 { #if arch(wasm32) - let points = [PublicPoint].bridgeJSStackPop() - return _bjs_makePromise(resolve: Promise_resolve_Sa11PublicPointV, reject: Promise_reject) { - return await asyncRoundTripPublicPointArray(_: points) - } + let ret = noncopyableMakeReader() + 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_copyableMakeReader") +@_cdecl("bjs_copyableMakeReader") +public func _bjs_copyableMakeReader() -> Int32 { #if arch(wasm32) - let point = Optional.bridgeJSLiftParameter() - return _bjs_makePromise(resolve: Promise_resolve_Sq11PublicPointV, reject: Promise_reject) { - return await asyncRoundTripOptionalPublicPoint(_: point) - } + let ret = copyableMakeReader() + 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_makeIntReader") +@_cdecl("bjs_makeIntReader") +public func _bjs_makeIntReader() -> Int32 { #if arch(wasm32) - let points = [String: PublicPoint].bridgeJSLiftParameter() - return _bjs_makePromise(resolve: Promise_resolve_SD11PublicPointV, reject: Promise_reject) { - return await asyncRoundTripPublicPointDict(_: points) - } + let ret = makeIntReader() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripContact") -@_cdecl("bjs_roundTripContact") -public func _bjs_roundTripContact() -> Void { +#if compiler(>=6.4) +@_expose(wasm, "bjs_noncopyableTakeAll") +@_cdecl("bjs_noncopyableTakeAll") +public func _bjs_noncopyableTakeAll() -> Void { + #if arch(wasm32) + let objects = UniqueArray.bridgeJSStackPop() + let ret = noncopyableTakeAll(_: objects) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} +#endif + +#if compiler(>=6.4) +@_expose(wasm, "bjs_noncopyableMakeAll") +@_cdecl("bjs_noncopyableMakeAll") +public func _bjs_noncopyableMakeAll(_ count: Int32) -> Void { + #if arch(wasm32) + let count = Int.bridgeJSLiftParameter(count) + let ret = noncopyableMakeAll(_: count) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} +#endif + +#if compiler(>=6.4) +@_expose(wasm, "bjs_noncopyableLoadAll") +@_cdecl("bjs_noncopyableLoadAll") +public func _bjs_noncopyableLoadAll(_ count: Int32) -> Int32 { + #if arch(wasm32) + let count = Int.bridgeJSLiftParameter(count) + return _bjs_makePromise(resolve: Promise_resolve_Sa17NoncopyableObjectV, reject: Promise_reject) { + return await noncopyableLoadAll(_: count) + } + #else + fatalError("Only available on WebAssembly") + #endif +} +#endif + +#if compiler(>=6.4) +@_expose(wasm, "bjs_noncopyablePassAll") +@_cdecl("bjs_noncopyablePassAll") +public func _bjs_noncopyablePassAll() -> Void { + #if arch(wasm32) + let objects = UniqueArray.bridgeJSStackPop() + let ret = noncopyablePassAll(_: objects) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} +#endif + +#if compiler(>=6.4) +@_expose(wasm, "bjs_noncopyableTakeAllOptional") +@_cdecl("bjs_noncopyableTakeAllOptional") +public func _bjs_noncopyableTakeAllOptional() -> Void { + #if arch(wasm32) + let objects = UniqueArray>.bridgeJSStackPop() + let ret = noncopyableTakeAllOptional(_: objects) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} +#endif + +#if compiler(>=6.4) +@_expose(wasm, "bjs_noncopyableTakeMaybe") +@_cdecl("bjs_noncopyableTakeMaybe") +public func _bjs_noncopyableTakeMaybe() -> Void { + #if arch(wasm32) + let objects = Optional>.bridgeJSLiftParameter() + let ret = noncopyableTakeMaybe(_: objects) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} +#endif + +#if compiler(>=6.4) +@_expose(wasm, "bjs_noncopyableMakeMaybe") +@_cdecl("bjs_noncopyableMakeMaybe") +public func _bjs_noncopyableMakeMaybe(_ count: Int32) -> Void { + #if arch(wasm32) + let count = Int.bridgeJSLiftParameter(count) + let ret = noncopyableMakeMaybe(_: count) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} +#endif + +#if compiler(>=6.4) +@_expose(wasm, "bjs_noncopyableVisitAll") +@_cdecl("bjs_noncopyableVisitAll") +public func _bjs_noncopyableVisitAll(_ visitor: Int32) -> Int32 { + #if arch(wasm32) + let objects = UniqueArray.bridgeJSStackPop() + let visitor = AnyNoncopyableObjectVisitor.bridgeJSLiftParameter(visitor) + let ret = noncopyableVisitAll(_: visitor, _: objects) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} +#endif + +#if compiler(>=6.4) +@_expose(wasm, "bjs_noncopyableVisitorMakeAll") +@_cdecl("bjs_noncopyableVisitorMakeAll") +public func _bjs_noncopyableVisitorMakeAll(_ visitor: Int32, _ count: Int32) -> Void { + #if arch(wasm32) + let count = Int.bridgeJSLiftParameter(count) + let visitor = AnyNoncopyableObjectVisitor.bridgeJSLiftParameter(visitor) + let ret = noncopyableVisitorMakeAll(_: visitor, _: count) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} +#endif + +@_expose(wasm, "bjs_roundTripPointerFields") +@_cdecl("bjs_roundTripPointerFields") +public func _bjs_roundTripPointerFields() -> Void { + #if arch(wasm32) + let value = PointerFields.bridgeJSLiftParameter() + let ret = roundTripPointerFields(_: value) + 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 point = DataPoint.bridgeJSLiftParameter() + let ret = testStructDefault(point: point) + 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 cart = CopyableCart.bridgeJSLiftParameter() + let ret = cartToJSObject(_: cart) + 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 cart = CopyableNestedCart.bridgeJSLiftParameter() + let ret = nestedCartToJSObject(_: cart) + 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 data = DataPoint.bridgeJSLiftParameter() + let ret = roundTripDataPoint(_: data) + 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 point = PublicPoint.bridgeJSLiftParameter() + let ret = roundTripPublicPoint(_: point) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_asyncRoundTripPublicPoint") +@_cdecl("bjs_asyncRoundTripPublicPoint") +public func _bjs_asyncRoundTripPublicPoint() -> Int32 { + #if arch(wasm32) + let point = PublicPoint.bridgeJSLiftParameter() + return _bjs_makePromise(resolve: Promise_resolve_11PublicPointV, reject: Promise_reject) { + return await asyncRoundTripPublicPoint(_: point) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_asyncRoundTripPublicPointThrows") +@_cdecl("bjs_asyncRoundTripPublicPointThrows") +public func _bjs_asyncRoundTripPublicPointThrows() -> Int32 { + #if arch(wasm32) + let point = PublicPoint.bridgeJSLiftParameter() + return _bjs_makePromise(resolve: Promise_resolve_11PublicPointV, reject: Promise_reject) { () async throws(JSException) -> PublicPoint in + return try await asyncRoundTripPublicPointThrows(_: point) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_asyncStructOrThrow") +@_cdecl("bjs_asyncStructOrThrow") +public func _bjs_asyncStructOrThrow(_ shouldThrow: Int32) -> Int32 { + #if arch(wasm32) + let shouldThrow = Bool.bridgeJSLiftParameter(shouldThrow) + return _bjs_makePromise(resolve: Promise_resolve_11PublicPointV, reject: Promise_reject) { () async throws(JSException) -> PublicPoint in + return try await asyncStructOrThrow(_: shouldThrow) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_asyncCombinePublicPoints") +@_cdecl("bjs_asyncCombinePublicPoints") +public func _bjs_asyncCombinePublicPoints() -> Int32 { + #if arch(wasm32) + let b = PublicPoint.bridgeJSLiftParameter() + let a = PublicPoint.bridgeJSLiftParameter() + return _bjs_makePromise(resolve: Promise_resolve_11PublicPointV, reject: Promise_reject) { + return await asyncCombinePublicPoints(_: a, _: b) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_asyncRoundTripContact") +@_cdecl("bjs_asyncRoundTripContact") +public func _bjs_asyncRoundTripContact() -> Int32 { + #if arch(wasm32) + let contact = Contact.bridgeJSLiftParameter() + return _bjs_makePromise(resolve: Promise_resolve_7ContactV, reject: Promise_reject) { + return await asyncRoundTripContact(_: contact) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_asyncRoundTripPublicPointArray") +@_cdecl("bjs_asyncRoundTripPublicPointArray") +public func _bjs_asyncRoundTripPublicPointArray() -> Int32 { + #if arch(wasm32) + let points = [PublicPoint].bridgeJSStackPop() + return _bjs_makePromise(resolve: Promise_resolve_Sa11PublicPointV, reject: Promise_reject) { + return await asyncRoundTripPublicPointArray(_: points) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_asyncRoundTripOptionalPublicPoint") +@_cdecl("bjs_asyncRoundTripOptionalPublicPoint") +public func _bjs_asyncRoundTripOptionalPublicPoint() -> Int32 { + #if arch(wasm32) + let point = Optional.bridgeJSLiftParameter() + return _bjs_makePromise(resolve: Promise_resolve_Sq11PublicPointV, reject: Promise_reject) { + return await asyncRoundTripOptionalPublicPoint(_: point) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_asyncRoundTripPublicPointDict") +@_cdecl("bjs_asyncRoundTripPublicPointDict") +public func _bjs_asyncRoundTripPublicPointDict() -> Int32 { + #if arch(wasm32) + let points = [String: PublicPoint].bridgeJSLiftParameter() + return _bjs_makePromise(resolve: Promise_resolve_SD11PublicPointV, reject: Promise_reject) { + return await asyncRoundTripPublicPointDict(_: points) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripContact") +@_cdecl("bjs_roundTripContact") +public func _bjs_roundTripContact() -> Void { #if arch(wasm32) let contact = Contact.bridgeJSLiftParameter() let ret = roundTripContact(_: contact) @@ -16106,6 +17297,223 @@ fileprivate func _bjs_JSNameRenamedClass_wrap_extern(_ pointer: UnsafeMutableRaw return _bjs_JSNameRenamedClass_wrap_extern(pointer) } +@_expose(wasm, "bjs_NoncopyableObjectBox_init") +@_cdecl("bjs_NoncopyableObjectBox_init") +public func _bjs_NoncopyableObjectBox_init(_ start: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let start = Int.bridgeJSLiftParameter(start) + let ret = NoncopyableObjectBox(_: start) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_NoncopyableObjectBox_value") +@_cdecl("bjs_NoncopyableObjectBox_value") +public func _bjs_NoncopyableObjectBox_value(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let _self = NoncopyableObjectBox.bridgeJSLiftParameter(_self) + let ret = _self.value() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_NoncopyableObjectBox_take") +@_cdecl("bjs_NoncopyableObjectBox_take") +public func _bjs_NoncopyableObjectBox_take(_ _self: UnsafeMutableRawPointer, _ other: Int32) -> Int32 { + #if arch(wasm32) + let other = NoncopyableObject.bridgeJSLiftParameter(other) + let _self = NoncopyableObjectBox.bridgeJSLiftParameter(_self) + let ret = _self.take(_: other) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_NoncopyableObjectBox_object_get") +@_cdecl("bjs_NoncopyableObjectBox_object_get") +public func _bjs_NoncopyableObjectBox_object_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let _self = NoncopyableObjectBox.bridgeJSLiftParameter(_self) + let ret = NoncopyableObject.bridgeJSRetaining(_self.object) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_NoncopyableObjectBox_object_set") +@_cdecl("bjs_NoncopyableObjectBox_object_set") +public func _bjs_NoncopyableObjectBox_object_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + let value = NoncopyableObject.bridgeJSLiftParameter(value) + let _self = NoncopyableObjectBox.bridgeJSLiftParameter(_self) + _self.object = value + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_NoncopyableObjectBox_made_get") +@_cdecl("bjs_NoncopyableObjectBox_made_get") +public func _bjs_NoncopyableObjectBox_made_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let _self = NoncopyableObjectBox.bridgeJSLiftParameter(_self) + let ret = NoncopyableObject.bridgeJSRetaining(_self.made) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_NoncopyableObjectBox_static_shared_get") +@_cdecl("bjs_NoncopyableObjectBox_static_shared_get") +public func _bjs_NoncopyableObjectBox_static_shared_get() -> Int32 { + #if arch(wasm32) + let ret = NoncopyableObject.bridgeJSRetaining(NoncopyableObjectBox.shared) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_NoncopyableObjectBox_static_shared_set") +@_cdecl("bjs_NoncopyableObjectBox_static_shared_set") +public func _bjs_NoncopyableObjectBox_static_shared_set(_ value: Int32) -> Void { + #if arch(wasm32) + let value = NoncopyableObject.bridgeJSLiftParameter(value) + NoncopyableObjectBox.shared = value + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_NoncopyableObjectBox_static_staticMade_get") +@_cdecl("bjs_NoncopyableObjectBox_static_staticMade_get") +public func _bjs_NoncopyableObjectBox_static_staticMade_get() -> Int32 { + #if arch(wasm32) + let ret = NoncopyableObject.bridgeJSRetaining(NoncopyableObjectBox.staticMade) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_NoncopyableObjectBox_optionalObject_get") +@_cdecl("bjs_NoncopyableObjectBox_optionalObject_get") +public func _bjs_NoncopyableObjectBox_optionalObject_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let _self = NoncopyableObjectBox.bridgeJSLiftParameter(_self) + let ret = Optional.bridgeJSRetaining(_self.optionalObject) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_NoncopyableObjectBox_optionalObject_set") +@_cdecl("bjs_NoncopyableObjectBox_optionalObject_set") +public func _bjs_NoncopyableObjectBox_optionalObject_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueValue: Int32) -> Void { + #if arch(wasm32) + let value = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) + let _self = NoncopyableObjectBox.bridgeJSLiftParameter(_self) + _self.optionalObject = value + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if compiler(>=6.4) +@_expose(wasm, "bjs_NoncopyableObjectBox_objects_get") +@_cdecl("bjs_NoncopyableObjectBox_objects_get") +public func _bjs_NoncopyableObjectBox_objects_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let _self = NoncopyableObjectBox.bridgeJSLiftParameter(_self) + let ret = UniqueArray.bridgeJSRetaining(_self.objects) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} +#endif + +#if compiler(>=6.4) +@_expose(wasm, "bjs_NoncopyableObjectBox_objects_set") +@_cdecl("bjs_NoncopyableObjectBox_objects_set") +public func _bjs_NoncopyableObjectBox_objects_set(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let value = UniqueArray.bridgeJSStackPop() + let _self = NoncopyableObjectBox.bridgeJSLiftParameter(_self) + _self.objects = value + #else + fatalError("Only available on WebAssembly") + #endif +} +#endif + +#if compiler(>=6.4) +@_expose(wasm, "bjs_NoncopyableObjectBox_maybeObjects_get") +@_cdecl("bjs_NoncopyableObjectBox_maybeObjects_get") +public func _bjs_NoncopyableObjectBox_maybeObjects_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let _self = NoncopyableObjectBox.bridgeJSLiftParameter(_self) + let ret = Optional>.bridgeJSRetaining(_self.maybeObjects) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} +#endif + +#if compiler(>=6.4) +@_expose(wasm, "bjs_NoncopyableObjectBox_maybeObjects_set") +@_cdecl("bjs_NoncopyableObjectBox_maybeObjects_set") +public func _bjs_NoncopyableObjectBox_maybeObjects_set(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let value = Optional>.bridgeJSLiftParameter() + let _self = NoncopyableObjectBox.bridgeJSLiftParameter(_self) + _self.maybeObjects = value + #else + fatalError("Only available on WebAssembly") + #endif +} +#endif + +@_expose(wasm, "bjs_NoncopyableObjectBox_deinit") +@_cdecl("bjs_NoncopyableObjectBox_deinit") +public func _bjs_NoncopyableObjectBox_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension NoncopyableObjectBox: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_NoncopyableObjectBox_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_NoncopyableObjectBox_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableObjectBox_wrap") +fileprivate func _bjs_NoncopyableObjectBox_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_NoncopyableObjectBox_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_NoncopyableObjectBox_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_NoncopyableObjectBox_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 { @@ -17194,6 +18602,56 @@ func _$Promise_resolve_Sq18AsyncPayloadResultO(_ promise: JSObject, _ value: Opt if let error = _swift_js_take_exception() { throw error } } +@JSFunction func Promise_resolve_17NoncopyableObjectV(_ promise: JSObject, _ value: borrowing NoncopyableObject) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_17NoncopyableObjectV") +fileprivate func promise_resolve_BridgeJSRuntimeTests_17NoncopyableObjectV_extern(_ promise: Int32, _ value: Int32) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_17NoncopyableObjectV_extern(_ promise: Int32, _ value: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_17NoncopyableObjectV(_ promise: Int32, _ value: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_17NoncopyableObjectV_extern(promise, value) +} + +func _$Promise_resolve_17NoncopyableObjectV(_ promise: JSObject, _ value: borrowing NoncopyableObject) throws(JSException) -> Void { + let valueValue = value.bridgeJSLowerParameter() + let promiseValue = promise.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_17NoncopyableObjectV(promiseValue, valueValue) + if let error = _swift_js_take_exception() { throw error } +} + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +@JSFunction func Promise_resolve_Sa17NoncopyableObjectV(_ promise: JSObject, _ value: borrowing UniqueArray) throws(JSException) +#endif + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sa17NoncopyableObjectV") +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sa17NoncopyableObjectV_extern(_ promise: Int32) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sa17NoncopyableObjectV_extern(_ promise: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sa17NoncopyableObjectV(_ promise: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_Sa17NoncopyableObjectV_extern(promise) +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +func _$Promise_resolve_Sa17NoncopyableObjectV(_ promise: JSObject, _ value: borrowing UniqueArray) throws(JSException) -> Void { + let _ = value.bridgeJSLowerParameter() + let promiseValue = promise.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_Sa17NoncopyableObjectV(promiseValue) + if let error = _swift_js_take_exception() { throw error } +} +#endif + @JSFunction func Promise_resolve_11PublicPointV(_ promise: JSObject, _ value: PublicPoint) throws(JSException) #if arch(wasm32) @@ -21570,6 +23028,1397 @@ func _$jsFunctionWithPrivateAccess() throws(JSException) -> Void { } } +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_noncopyableSharedObject_get") +fileprivate func bjs_noncopyableSharedObject_get_extern() -> Int32 +#else +fileprivate func bjs_noncopyableSharedObject_get_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_noncopyableSharedObject_get() -> Int32 { + return bjs_noncopyableSharedObject_get_extern() +} + +func _$noncopyableSharedObject_get() throws(JSException) -> NoncopyableObject { + let ret = bjs_noncopyableSharedObject_get() + if let error = _swift_js_take_exception() { + throw error + } + return NoncopyableObject.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_noncopyableMakeObject") +fileprivate func bjs_noncopyableMakeObject_extern(_ start: Int32) -> Int32 +#else +fileprivate func bjs_noncopyableMakeObject_extern(_ start: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_noncopyableMakeObject(_ start: Int32) -> Int32 { + return bjs_noncopyableMakeObject_extern(start) +} + +func _$noncopyableMakeObject(_ start: Int) throws(JSException) -> NoncopyableObject { + let startValue = start.bridgeJSLowerParameter() + let ret = bjs_noncopyableMakeObject(startValue) + if let error = _swift_js_take_exception() { + throw error + } + return NoncopyableObject.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_noncopyableUseObject") +fileprivate func bjs_noncopyableUseObject_extern(_ object: Int32) -> Int32 +#else +fileprivate func bjs_noncopyableUseObject_extern(_ object: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_noncopyableUseObject(_ object: Int32) -> Int32 { + return bjs_noncopyableUseObject_extern(object) +} + +func _$noncopyableUseObject(_ object: borrowing NoncopyableObject) throws(JSException) -> Int { + let objectValue = object.bridgeJSLowerParameter() + let ret = bjs_noncopyableUseObject(objectValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableObject_init") +fileprivate func bjs_NoncopyableObject_init_extern(_ start: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObject_init_extern(_ start: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObject_init(_ start: Int32) -> Int32 { + return bjs_NoncopyableObject_init_extern(start) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableObject_create_static") +fileprivate func bjs_NoncopyableObject_create_static_extern(_ start: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObject_create_static_extern(_ start: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObject_create_static(_ start: Int32) -> Int32 { + return bjs_NoncopyableObject_create_static_extern(start) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableObject_value") +fileprivate func bjs_NoncopyableObject_value_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObject_value_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObject_value(_ self: Int32) -> Int32 { + return bjs_NoncopyableObject_value_extern(self) +} + +func _$NoncopyableObject_init(_ start: Int) throws(JSException) -> JSUniqueRef { + let startValue = start.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObject_init(startValue) + if let error = _swift_js_take_exception() { + throw error + } + return JSUniqueRef.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableObject_create(_ start: Int) throws(JSException) -> NoncopyableObject { + let startValue = start.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObject_create_static(startValue) + if let error = _swift_js_take_exception() { + throw error + } + return NoncopyableObject.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableObject_value(_ self: borrowing JSUniqueRef) throws(JSException) -> Int { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObject_value(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableObjectView_value") +fileprivate func bjs_NoncopyableObjectView_value_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObjectView_value_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectView_value(_ self: Int32) -> Int32 { + return bjs_NoncopyableObjectView_value_extern(self) +} + +func _$NoncopyableObjectView_value(_ self: borrowing JSUniqueRef) throws(JSException) -> Int { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObjectView_value(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableObjectRoundtrip_init") +fileprivate func bjs_NoncopyableObjectRoundtrip_init_extern() -> Int32 +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_init_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_init() -> Int32 { + return bjs_NoncopyableObjectRoundtrip_init_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableObjectRoundtrip_child_get") +fileprivate func bjs_NoncopyableObjectRoundtrip_child_get_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_child_get_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_child_get(_ self: Int32) -> Int32 { + return bjs_NoncopyableObjectRoundtrip_child_get_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableObjectRoundtrip_child_set") +fileprivate func bjs_NoncopyableObjectRoundtrip_child_set_extern(_ self: Int32, _ newValue: Int32) -> Void +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_child_set_extern(_ self: Int32, _ newValue: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_child_set(_ self: Int32, _ newValue: Int32) -> Void { + return bjs_NoncopyableObjectRoundtrip_child_set_extern(self, newValue) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableObjectRoundtrip_take") +fileprivate func bjs_NoncopyableObjectRoundtrip_take_extern(_ self: Int32, _ object: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_take_extern(_ self: Int32, _ object: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_take(_ self: Int32, _ object: Int32) -> Int32 { + return bjs_NoncopyableObjectRoundtrip_take_extern(self, object) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableObjectRoundtrip_make") +fileprivate func bjs_NoncopyableObjectRoundtrip_make_extern(_ self: Int32, _ start: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_make_extern(_ self: Int32, _ start: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_make(_ self: Int32, _ start: Int32) -> Int32 { + return bjs_NoncopyableObjectRoundtrip_make_extern(self, start) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableObjectRoundtrip_adopt") +fileprivate func bjs_NoncopyableObjectRoundtrip_adopt_extern(_ self: Int32, _ object: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_adopt_extern(_ self: Int32, _ object: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_adopt(_ self: Int32, _ object: Int32) -> Int32 { + return bjs_NoncopyableObjectRoundtrip_adopt_extern(self, object) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableObjectRoundtrip_takeCopyable") +fileprivate func bjs_NoncopyableObjectRoundtrip_takeCopyable_extern(_ self: Int32, _ copyable: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_takeCopyable_extern(_ self: Int32, _ copyable: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_takeCopyable(_ self: Int32, _ copyable: Int32) -> Int32 { + return bjs_NoncopyableObjectRoundtrip_takeCopyable_extern(self, copyable) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableObjectRoundtrip_makeCopyable") +fileprivate func bjs_NoncopyableObjectRoundtrip_makeCopyable_extern(_ self: Int32, _ start: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_makeCopyable_extern(_ self: Int32, _ start: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_makeCopyable(_ self: Int32, _ start: Int32) -> Int32 { + return bjs_NoncopyableObjectRoundtrip_makeCopyable_extern(self, start) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableObjectRoundtrip_failTake") +fileprivate func bjs_NoncopyableObjectRoundtrip_failTake_extern(_ self: Int32, _ object: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_failTake_extern(_ self: Int32, _ object: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_failTake(_ self: Int32, _ object: Int32) -> Int32 { + return bjs_NoncopyableObjectRoundtrip_failTake_extern(self, object) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableObjectRoundtrip_failMake") +fileprivate func bjs_NoncopyableObjectRoundtrip_failMake_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableObjectRoundtrip_failMake_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableObjectRoundtrip_failMake(_ self: Int32) -> Int32 { + return bjs_NoncopyableObjectRoundtrip_failMake_extern(self) +} + +func _$NoncopyableObjectRoundtrip_init() throws(JSException) -> JSUniqueRef { + let ret = bjs_NoncopyableObjectRoundtrip_init() + if let error = _swift_js_take_exception() { + throw error + } + return JSUniqueRef.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableObjectRoundtrip_child_get(_ self: borrowing JSUniqueRef) throws(JSException) -> NoncopyableObject { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObjectRoundtrip_child_get(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return NoncopyableObject.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableObjectRoundtrip_child_set(_ self: borrowing JSUniqueRef, _ newValue: borrowing NoncopyableObject) throws(JSException) -> Void { + let newValueValue = newValue.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableObjectRoundtrip_child_set(selfValue, newValueValue) + if let error = _swift_js_take_exception() { + throw error + } +} + +func _$NoncopyableObjectRoundtrip_take(_ self: borrowing JSUniqueRef, _ object: borrowing NoncopyableObject) throws(JSException) -> Int { + let objectValue = object.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObjectRoundtrip_take(selfValue, objectValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableObjectRoundtrip_make(_ self: borrowing JSUniqueRef, _ start: Int) throws(JSException) -> NoncopyableObject { + let startValue = start.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObjectRoundtrip_make(selfValue, startValue) + if let error = _swift_js_take_exception() { + throw error + } + return NoncopyableObject.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableObjectRoundtrip_adopt(_ self: borrowing JSUniqueRef, _ object: borrowing NoncopyableObject) throws(JSException) -> Int { + let objectValue = object.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObjectRoundtrip_adopt(selfValue, objectValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableObjectRoundtrip_takeCopyable(_ self: borrowing JSUniqueRef, _ copyable: CopyableObjectRoundtrip) throws(JSException) -> Int { + let copyableValue = copyable.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObjectRoundtrip_takeCopyable(selfValue, copyableValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableObjectRoundtrip_makeCopyable(_ self: borrowing JSUniqueRef, _ start: Int) throws(JSException) -> CopyableObjectRoundtrip { + let startValue = start.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObjectRoundtrip_makeCopyable(selfValue, startValue) + if let error = _swift_js_take_exception() { + throw error + } + return CopyableObjectRoundtrip.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableObjectRoundtrip_failTake(_ self: borrowing JSUniqueRef, _ object: borrowing NoncopyableObject) throws(JSException) -> Int { + let objectValue = object.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObjectRoundtrip_failTake(selfValue, objectValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableObjectRoundtrip_failMake(_ self: borrowing JSUniqueRef) throws(JSException) -> NoncopyableObject { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableObjectRoundtrip_failMake(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return NoncopyableObject.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_CopyableObjectRoundtrip_value") +fileprivate func bjs_CopyableObjectRoundtrip_value_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_CopyableObjectRoundtrip_value_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_CopyableObjectRoundtrip_value(_ self: Int32) -> Int32 { + return bjs_CopyableObjectRoundtrip_value_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_CopyableObjectRoundtrip_take") +fileprivate func bjs_CopyableObjectRoundtrip_take_extern(_ self: Int32, _ object: Int32) -> Int32 +#else +fileprivate func bjs_CopyableObjectRoundtrip_take_extern(_ self: Int32, _ object: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_CopyableObjectRoundtrip_take(_ self: Int32, _ object: Int32) -> Int32 { + return bjs_CopyableObjectRoundtrip_take_extern(self, object) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_CopyableObjectRoundtrip_make") +fileprivate func bjs_CopyableObjectRoundtrip_make_extern(_ self: Int32, _ start: Int32) -> Int32 +#else +fileprivate func bjs_CopyableObjectRoundtrip_make_extern(_ self: Int32, _ start: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_CopyableObjectRoundtrip_make(_ self: Int32, _ start: Int32) -> Int32 { + return bjs_CopyableObjectRoundtrip_make_extern(self, start) +} + +func _$CopyableObjectRoundtrip_value(_ self: JSObject) throws(JSException) -> Int { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_CopyableObjectRoundtrip_value(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$CopyableObjectRoundtrip_take(_ self: JSObject, _ object: borrowing NoncopyableObject) throws(JSException) -> Int { + let objectValue = object.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_CopyableObjectRoundtrip_take(selfValue, objectValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$CopyableObjectRoundtrip_make(_ self: JSObject, _ start: Int) throws(JSException) -> NoncopyableObject { + let startValue = start.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_CopyableObjectRoundtrip_make(selfValue, startValue) + if let error = _swift_js_take_exception() { + throw error + } + return NoncopyableObject.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_init") +fileprivate func bjs_NoncopyableSource_init_extern() -> Int32 +#else +fileprivate func bjs_NoncopyableSource_init_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_init() -> Int32 { + return bjs_NoncopyableSource_init_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_optionalChild_get") +fileprivate func bjs_NoncopyableSource_optionalChild_get_extern(_ self: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_optionalChild_get_extern(_ self: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_optionalChild_get(_ self: Int32) -> Void { + return bjs_NoncopyableSource_optionalChild_get_extern(self) +} + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_children_get") +fileprivate func bjs_NoncopyableSource_children_get_extern(_ self: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_children_get_extern(_ self: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_children_get(_ self: Int32) -> Void { + return bjs_NoncopyableSource_children_get_extern(self) +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_optionalChild_set") +fileprivate func bjs_NoncopyableSource_optionalChild_set_extern(_ self: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_optionalChild_set_extern(_ self: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_optionalChild_set(_ self: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void { + return bjs_NoncopyableSource_optionalChild_set_extern(self, newValueIsSome, newValueValue) +} + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_children_set") +fileprivate func bjs_NoncopyableSource_children_set_extern(_ self: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_children_set_extern(_ self: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_children_set(_ self: Int32) -> Void { + return bjs_NoncopyableSource_children_set_extern(self) +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_forEachObject") +fileprivate func bjs_NoncopyableSource_forEachObject_extern(_ self: Int32, _ count: Int32, _ body: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_forEachObject_extern(_ self: Int32, _ count: Int32, _ body: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_forEachObject(_ self: Int32, _ count: Int32, _ body: Int32) -> Void { + return bjs_NoncopyableSource_forEachObject_extern(self, count, body) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_forEachObjectEscaping") +fileprivate func bjs_NoncopyableSource_forEachObjectEscaping_extern(_ self: Int32, _ count: Int32, _ body: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_forEachObjectEscaping_extern(_ self: Int32, _ count: Int32, _ body: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_forEachObjectEscaping(_ self: Int32, _ count: Int32, _ body: Int32) -> Void { + return bjs_NoncopyableSource_forEachObjectEscaping_extern(self, count, body) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_forEachCopyableEscaping") +fileprivate func bjs_NoncopyableSource_forEachCopyableEscaping_extern(_ self: Int32, _ count: Int32, _ body: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_forEachCopyableEscaping_extern(_ self: Int32, _ count: Int32, _ body: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_forEachCopyableEscaping(_ self: Int32, _ count: Int32, _ body: Int32) -> Void { + return bjs_NoncopyableSource_forEachCopyableEscaping_extern(self, count, body) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_load") +fileprivate func bjs_NoncopyableSource_load_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32, _ start: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_load_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32, _ start: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_load(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32, _ start: Int32) -> Void { + return bjs_NoncopyableSource_load_extern(resolveRef, rejectRef, self, start) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_loadCopyable") +fileprivate func bjs_NoncopyableSource_loadCopyable_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32, _ start: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_loadCopyable_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32, _ start: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_loadCopyable(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32, _ start: Int32) -> Void { + return bjs_NoncopyableSource_loadCopyable_extern(resolveRef, rejectRef, self, start) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_loadFail") +fileprivate func bjs_NoncopyableSource_loadFail_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_loadFail_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_loadFail(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32) -> Void { + return bjs_NoncopyableSource_loadFail_extern(resolveRef, rejectRef, self) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_use") +fileprivate func bjs_NoncopyableSource_use_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32, _ object: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_use_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32, _ object: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_use(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32, _ object: Int32) -> Void { + return bjs_NoncopyableSource_use_extern(resolveRef, rejectRef, self, object) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_referencesToCreated") +fileprivate func bjs_NoncopyableSource_referencesToCreated_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableSource_referencesToCreated_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_referencesToCreated(_ self: Int32) -> Int32 { + return bjs_NoncopyableSource_referencesToCreated_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_referencesTo") +fileprivate func bjs_NoncopyableSource_referencesTo_extern(_ self: Int32, _ object: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableSource_referencesTo_extern(_ self: Int32, _ object: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_referencesTo(_ self: Int32, _ object: Int32) -> Int32 { + return bjs_NoncopyableSource_referencesTo_extern(self, object) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_takeOptional") +fileprivate func bjs_NoncopyableSource_takeOptional_extern(_ self: Int32, _ objectIsSome: Int32, _ objectValue: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableSource_takeOptional_extern(_ self: Int32, _ objectIsSome: Int32, _ objectValue: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_takeOptional(_ self: Int32, _ objectIsSome: Int32, _ objectValue: Int32) -> Int32 { + return bjs_NoncopyableSource_takeOptional_extern(self, objectIsSome, objectValue) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_takeOptionalCopyable") +fileprivate func bjs_NoncopyableSource_takeOptionalCopyable_extern(_ self: Int32, _ copyableIsSome: Int32, _ copyableValue: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableSource_takeOptionalCopyable_extern(_ self: Int32, _ copyableIsSome: Int32, _ copyableValue: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_takeOptionalCopyable(_ self: Int32, _ copyableIsSome: Int32, _ copyableValue: Int32) -> Int32 { + return bjs_NoncopyableSource_takeOptionalCopyable_extern(self, copyableIsSome, copyableValue) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_findOptional") +fileprivate func bjs_NoncopyableSource_findOptional_extern(_ self: Int32, _ start: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_findOptional_extern(_ self: Int32, _ start: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_findOptional(_ self: Int32, _ start: Int32) -> Void { + return bjs_NoncopyableSource_findOptional_extern(self, start) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_findOptionalCopyable") +fileprivate func bjs_NoncopyableSource_findOptionalCopyable_extern(_ self: Int32, _ start: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_findOptionalCopyable_extern(_ self: Int32, _ start: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_findOptionalCopyable(_ self: Int32, _ start: Int32) -> Void { + return bjs_NoncopyableSource_findOptionalCopyable_extern(self, start) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_forEachOptional") +fileprivate func bjs_NoncopyableSource_forEachOptional_extern(_ self: Int32, _ count: Int32, _ body: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_forEachOptional_extern(_ self: Int32, _ count: Int32, _ body: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_forEachOptional(_ self: Int32, _ count: Int32, _ body: Int32) -> Void { + return bjs_NoncopyableSource_forEachOptional_extern(self, count, body) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_loadOptional") +fileprivate func bjs_NoncopyableSource_loadOptional_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32, _ start: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_loadOptional_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32, _ start: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_loadOptional(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32, _ start: Int32) -> Void { + return bjs_NoncopyableSource_loadOptional_extern(resolveRef, rejectRef, self, start) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_raw") +fileprivate func bjs_NoncopyableSource_raw_extern(_ self: Int32, _ start: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableSource_raw_extern(_ self: Int32, _ start: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_raw(_ self: Int32, _ start: Int32) -> Int32 { + return bjs_NoncopyableSource_raw_extern(self, start) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_rawValue") +fileprivate func bjs_NoncopyableSource_rawValue_extern(_ self: Int32, _ ref: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableSource_rawValue_extern(_ self: Int32, _ ref: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_rawValue(_ self: Int32, _ ref: Int32) -> Int32 { + return bjs_NoncopyableSource_rawValue_extern(self, ref) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_maybeRaw") +fileprivate func bjs_NoncopyableSource_maybeRaw_extern(_ self: Int32, _ start: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_maybeRaw_extern(_ self: Int32, _ start: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_maybeRaw(_ self: Int32, _ start: Int32) -> Void { + return bjs_NoncopyableSource_maybeRaw_extern(self, start) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_rawObject") +fileprivate func bjs_NoncopyableSource_rawObject_extern(_ self: Int32, _ start: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableSource_rawObject_extern(_ self: Int32, _ start: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_rawObject(_ self: Int32, _ start: Int32) -> Int32 { + return bjs_NoncopyableSource_rawObject_extern(self, start) +} + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_takeAll") +fileprivate func bjs_NoncopyableSource_takeAll_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableSource_takeAll_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_takeAll(_ self: Int32) -> Int32 { + return bjs_NoncopyableSource_takeAll_extern(self) +} +#endif + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_makeAll") +fileprivate func bjs_NoncopyableSource_makeAll_extern(_ self: Int32, _ count: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_makeAll_extern(_ self: Int32, _ count: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_makeAll(_ self: Int32, _ count: Int32) -> Void { + return bjs_NoncopyableSource_makeAll_extern(self, count) +} +#endif + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_takeAllOptional") +fileprivate func bjs_NoncopyableSource_takeAllOptional_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableSource_takeAllOptional_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_takeAllOptional(_ self: Int32) -> Int32 { + return bjs_NoncopyableSource_takeAllOptional_extern(self) +} +#endif + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_makeAllOptional") +fileprivate func bjs_NoncopyableSource_makeAllOptional_extern(_ self: Int32, _ count: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_makeAllOptional_extern(_ self: Int32, _ count: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_makeAllOptional(_ self: Int32, _ count: Int32) -> Void { + return bjs_NoncopyableSource_makeAllOptional_extern(self, count) +} +#endif + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_makeGrid") +fileprivate func bjs_NoncopyableSource_makeGrid_extern(_ self: Int32, _ count: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_makeGrid_extern(_ self: Int32, _ count: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_makeGrid(_ self: Int32, _ count: Int32) -> Void { + return bjs_NoncopyableSource_makeGrid_extern(self, count) +} +#endif + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_loadAll") +fileprivate func bjs_NoncopyableSource_loadAll_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32, _ count: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_loadAll_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32, _ count: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_loadAll(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32, _ count: Int32) -> Void { + return bjs_NoncopyableSource_loadAll_extern(resolveRef, rejectRef, self, count) +} +#endif + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_forEachBatch") +fileprivate func bjs_NoncopyableSource_forEachBatch_extern(_ self: Int32, _ count: Int32, _ body: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_forEachBatch_extern(_ self: Int32, _ count: Int32, _ body: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_forEachBatch(_ self: Int32, _ count: Int32, _ body: Int32) -> Void { + return bjs_NoncopyableSource_forEachBatch_extern(self, count, body) +} +#endif + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_takeMaybe") +fileprivate func bjs_NoncopyableSource_takeMaybe_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableSource_takeMaybe_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_takeMaybe(_ self: Int32) -> Int32 { + return bjs_NoncopyableSource_takeMaybe_extern(self) +} +#endif + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_makeMaybe") +fileprivate func bjs_NoncopyableSource_makeMaybe_extern(_ self: Int32, _ count: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_makeMaybe_extern(_ self: Int32, _ count: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_makeMaybe(_ self: Int32, _ count: Int32) -> Void { + return bjs_NoncopyableSource_makeMaybe_extern(self, count) +} +#endif + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_takeRows") +fileprivate func bjs_NoncopyableSource_takeRows_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_NoncopyableSource_takeRows_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_takeRows(_ self: Int32) -> Int32 { + return bjs_NoncopyableSource_takeRows_extern(self) +} +#endif + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_makeRows") +fileprivate func bjs_NoncopyableSource_makeRows_extern(_ self: Int32, _ count: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_makeRows_extern(_ self: Int32, _ count: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_makeRows(_ self: Int32, _ count: Int32) -> Void { + return bjs_NoncopyableSource_makeRows_extern(self, count) +} +#endif + +#if compiler(>=6.4) +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableSource_loadMaybe") +fileprivate func bjs_NoncopyableSource_loadMaybe_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32, _ count: Int32) -> Void +#else +fileprivate func bjs_NoncopyableSource_loadMaybe_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32, _ count: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableSource_loadMaybe(_ resolveRef: Int32, _ rejectRef: Int32, _ self: Int32, _ count: Int32) -> Void { + return bjs_NoncopyableSource_loadMaybe_extern(resolveRef, rejectRef, self, count) +} +#endif + +func _$NoncopyableSource_init() throws(JSException) -> JSUniqueRef { + let ret = bjs_NoncopyableSource_init() + if let error = _swift_js_take_exception() { + throw error + } + return JSUniqueRef.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableSource_optionalChild_get(_ self: borrowing JSUniqueRef) throws(JSException) -> Optional { + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_optionalChild_get(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Optional.bridgeJSLiftReturn() +} + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +func _$NoncopyableSource_children_get(_ self: borrowing JSUniqueRef) throws(JSException) -> UniqueArray { + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_children_get(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return UniqueArray.bridgeJSLiftReturn() +} +#endif + +func _$NoncopyableSource_optionalChild_set(_ self: borrowing JSUniqueRef, _ newValue: borrowing Optional) throws(JSException) -> Void { + let (newValueIsSome, newValueValue) = newValue.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_optionalChild_set(selfValue, newValueIsSome, newValueValue) + if let error = _swift_js_take_exception() { + throw error + } +} + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +func _$NoncopyableSource_children_set(_ self: borrowing JSUniqueRef, _ newValue: borrowing UniqueArray) throws(JSException) -> Void { + let _ = newValue.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_children_set(selfValue) + if let error = _swift_js_take_exception() { + throw error + } +} +#endif + +func _$NoncopyableSource_forEachObject(_ self: borrowing JSUniqueRef, _ count: Int, _ body: JSTypedClosure<(borrowing NoncopyableObject) -> Void>) throws(JSException) -> Void { + let bodyFuncRef = body.bridgeJSLowerParameter() + let countValue = count.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_forEachObject(selfValue, countValue, bodyFuncRef) + if let error = _swift_js_take_exception() { + throw error + } +} + +func _$NoncopyableSource_forEachObjectEscaping(_ self: borrowing JSUniqueRef, _ count: Int, _ body: @escaping (borrowing NoncopyableObject) -> Void) throws(JSException) -> Void { + let body = JSTypedClosure<(borrowing NoncopyableObject) -> Void>(body) + let bodyFuncRef = body.bridgeJSLowerParameter() + let countValue = count.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + withExtendedLifetime((body)) { + bjs_NoncopyableSource_forEachObjectEscaping(selfValue, countValue, bodyFuncRef) + } + if let error = _swift_js_take_exception() { + throw error + } +} + +func _$NoncopyableSource_forEachCopyableEscaping(_ self: borrowing JSUniqueRef, _ count: Int, _ body: @escaping (CopyableObjectRoundtrip) -> Void) throws(JSException) -> Void { + let body = JSTypedClosure<(CopyableObjectRoundtrip) -> Void>(body) + let bodyFuncRef = body.bridgeJSLowerParameter() + let countValue = count.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + withExtendedLifetime((body)) { + bjs_NoncopyableSource_forEachCopyableEscaping(selfValue, countValue, bodyFuncRef) + } + if let error = _swift_js_take_exception() { + throw error + } +} + +func _$NoncopyableSource_load(_ self: borrowing JSUniqueRef, _ start: Int) async throws(JSException) -> NoncopyableObject { + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(consuming sending NoncopyableObject) -> Void>.sending($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>.sending($0) + }) { resolveRef, rejectRef in + let startValue = start.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_load(resolveRef, rejectRef, selfValue, startValue) + } + return resolved +} + +func _$NoncopyableSource_loadCopyable(_ self: borrowing JSUniqueRef, _ start: Int) async throws(JSException) -> CopyableObjectRoundtrip { + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending CopyableObjectRoundtrip) -> Void>.sending($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>.sending($0) + }) { resolveRef, rejectRef in + let startValue = start.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_loadCopyable(resolveRef, rejectRef, selfValue, startValue) + } + return resolved +} + +func _$NoncopyableSource_loadFail(_ self: borrowing JSUniqueRef) async throws(JSException) -> NoncopyableObject { + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(consuming sending NoncopyableObject) -> Void>.sending($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>.sending($0) + }) { resolveRef, rejectRef in + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_loadFail(resolveRef, rejectRef, selfValue) + } + return resolved +} + +func _$NoncopyableSource_use(_ self: borrowing JSUniqueRef, _ object: borrowing NoncopyableObject) async throws(JSException) -> Int { + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending Int) -> Void>.sending($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>.sending($0) + }) { resolveRef, rejectRef in + let objectValue = object.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_use(resolveRef, rejectRef, selfValue, objectValue) + } + return resolved +} + +func _$NoncopyableSource_referencesToCreated(_ self: borrowing JSUniqueRef) throws(JSException) -> Int { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableSource_referencesToCreated(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableSource_referencesTo(_ self: borrowing JSUniqueRef, _ object: borrowing NoncopyableObject) throws(JSException) -> Int { + let objectValue = object.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableSource_referencesTo(selfValue, objectValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableSource_takeOptional(_ self: borrowing JSUniqueRef, _ object: borrowing Optional) throws(JSException) -> Int { + let (objectIsSome, objectValue) = object.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableSource_takeOptional(selfValue, objectIsSome, objectValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableSource_takeOptionalCopyable(_ self: borrowing JSUniqueRef, _ copyable: Optional) throws(JSException) -> Int { + let (copyableIsSome, copyableValue) = copyable.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableSource_takeOptionalCopyable(selfValue, copyableIsSome, copyableValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableSource_findOptional(_ self: borrowing JSUniqueRef, _ start: Int) throws(JSException) -> Optional { + let startValue = start.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_findOptional(selfValue, startValue) + if let error = _swift_js_take_exception() { + throw error + } + return Optional.bridgeJSLiftReturn() +} + +func _$NoncopyableSource_findOptionalCopyable(_ self: borrowing JSUniqueRef, _ start: Int) throws(JSException) -> Optional { + let startValue = start.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_findOptionalCopyable(selfValue, startValue) + if let error = _swift_js_take_exception() { + throw error + } + return Optional.bridgeJSLiftReturn() +} + +func _$NoncopyableSource_forEachOptional(_ self: borrowing JSUniqueRef, _ count: Int, _ body: JSTypedClosure<(borrowing Optional) -> Void>) throws(JSException) -> Void { + let bodyFuncRef = body.bridgeJSLowerParameter() + let countValue = count.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_forEachOptional(selfValue, countValue, bodyFuncRef) + if let error = _swift_js_take_exception() { + throw error + } +} + +func _$NoncopyableSource_loadOptional(_ self: borrowing JSUniqueRef, _ start: Int) async throws(JSException) -> Optional { + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(consuming sending Optional) -> Void>.sending($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>.sending($0) + }) { resolveRef, rejectRef in + let startValue = start.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_loadOptional(resolveRef, rejectRef, selfValue, startValue) + } + return resolved +} + +func _$NoncopyableSource_raw(_ self: borrowing JSUniqueRef, _ start: Int) throws(JSException) -> JSUniqueRef { + let startValue = start.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableSource_raw(selfValue, startValue) + if let error = _swift_js_take_exception() { + throw error + } + return JSUniqueRef.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableSource_rawValue(_ self: borrowing JSUniqueRef, _ ref: borrowing JSUniqueRef) throws(JSException) -> Int { + let refValue = ref.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableSource_rawValue(selfValue, refValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableSource_maybeRaw(_ self: borrowing JSUniqueRef, _ start: Int) throws(JSException) -> Optional { + let startValue = start.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_maybeRaw(selfValue, startValue) + if let error = _swift_js_take_exception() { + throw error + } + return Optional.bridgeJSLiftReturn() +} + +func _$NoncopyableSource_rawObject(_ self: borrowing JSUniqueRef, _ start: Int) throws(JSException) -> JSObject { + let startValue = start.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableSource_rawObject(selfValue, startValue) + if let error = _swift_js_take_exception() { + throw error + } + return JSObject.bridgeJSLiftReturn(ret) +} + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +func _$NoncopyableSource_takeAll(_ self: borrowing JSUniqueRef, _ objects: borrowing UniqueArray) throws(JSException) -> Int { + let _ = objects.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableSource_takeAll(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +func _$NoncopyableSource_makeAll(_ self: borrowing JSUniqueRef, _ count: Int) throws(JSException) -> UniqueArray { + let countValue = count.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_makeAll(selfValue, countValue) + if let error = _swift_js_take_exception() { + throw error + } + return UniqueArray.bridgeJSLiftReturn() +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +func _$NoncopyableSource_takeAllOptional(_ self: borrowing JSUniqueRef, _ objects: borrowing UniqueArray>) throws(JSException) -> Int { + let _ = objects.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableSource_takeAllOptional(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +func _$NoncopyableSource_makeAllOptional(_ self: borrowing JSUniqueRef, _ count: Int) throws(JSException) -> UniqueArray> { + let countValue = count.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_makeAllOptional(selfValue, countValue) + if let error = _swift_js_take_exception() { + throw error + } + return UniqueArray>.bridgeJSLiftReturn() +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +func _$NoncopyableSource_makeGrid(_ self: borrowing JSUniqueRef, _ count: Int) throws(JSException) -> UniqueArray> { + let countValue = count.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_makeGrid(selfValue, countValue) + if let error = _swift_js_take_exception() { + throw error + } + return UniqueArray>.bridgeJSLiftReturn() +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +func _$NoncopyableSource_loadAll(_ self: borrowing JSUniqueRef, _ count: Int) async throws(JSException) -> UniqueArray { + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(consuming sending UniqueArray) -> Void>.sending($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>.sending($0) + }) { resolveRef, rejectRef in + let countValue = count.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_loadAll(resolveRef, rejectRef, selfValue, countValue) + } + return resolved +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +func _$NoncopyableSource_forEachBatch(_ self: borrowing JSUniqueRef, _ count: Int, _ body: JSTypedClosure<(borrowing UniqueArray) -> Void>) throws(JSException) -> Void { + let bodyFuncRef = body.bridgeJSLowerParameter() + let countValue = count.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_forEachBatch(selfValue, countValue, bodyFuncRef) + if let error = _swift_js_take_exception() { + throw error + } +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +func _$NoncopyableSource_takeMaybe(_ self: borrowing JSUniqueRef, _ objects: borrowing Optional>) throws(JSException) -> Int { + let _ = objects.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableSource_takeMaybe(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +func _$NoncopyableSource_makeMaybe(_ self: borrowing JSUniqueRef, _ count: Int) throws(JSException) -> Optional> { + let countValue = count.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_makeMaybe(selfValue, countValue) + if let error = _swift_js_take_exception() { + throw error + } + return Optional>.bridgeJSLiftReturn() +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +func _$NoncopyableSource_takeRows(_ self: borrowing JSUniqueRef, _ rows: borrowing UniqueArray>>) throws(JSException) -> Int { + let _ = rows.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_NoncopyableSource_takeRows(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +func _$NoncopyableSource_makeRows(_ self: borrowing JSUniqueRef, _ count: Int) throws(JSException) -> UniqueArray>> { + let countValue = count.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_makeRows(selfValue, countValue) + if let error = _swift_js_take_exception() { + throw error + } + return UniqueArray>>.bridgeJSLiftReturn() +} +#endif + +#if compiler(>=6.4) +@available(anyAppleOS 27.0, *) +func _$NoncopyableSource_loadMaybe(_ self: borrowing JSUniqueRef, _ count: Int) async throws(JSException) -> Optional> { + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(consuming sending Optional>) -> Void>.sending($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>.sending($0) + }) { resolveRef, rejectRef in + let countValue = count.bridgeJSLowerParameter() + let selfValue = self.bridgeJSLowerParameter() + bjs_NoncopyableSource_loadMaybe(resolveRef, rejectRef, selfValue, countValue) + } + return resolved +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableJSClassSupportImports_liveReferenceCount_static") +fileprivate func bjs_NoncopyableJSClassSupportImports_liveReferenceCount_static_extern() -> Int32 +#else +fileprivate func bjs_NoncopyableJSClassSupportImports_liveReferenceCount_static_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableJSClassSupportImports_liveReferenceCount_static() -> Int32 { + return bjs_NoncopyableJSClassSupportImports_liveReferenceCount_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableJSClassSupportImports_retainByRefCount_static") +fileprivate func bjs_NoncopyableJSClassSupportImports_retainByRefCount_static_extern() -> Int32 +#else +fileprivate func bjs_NoncopyableJSClassSupportImports_retainByRefCount_static_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableJSClassSupportImports_retainByRefCount_static() -> Int32 { + return bjs_NoncopyableJSClassSupportImports_retainByRefCount_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableJSClassSupportImports_runNoncopyableExportedPathTests_static") +fileprivate func bjs_NoncopyableJSClassSupportImports_runNoncopyableExportedPathTests_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void +#else +fileprivate func bjs_NoncopyableJSClassSupportImports_runNoncopyableExportedPathTests_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableJSClassSupportImports_runNoncopyableExportedPathTests_static(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { + return bjs_NoncopyableJSClassSupportImports_runNoncopyableExportedPathTests_static_extern(resolveRef, rejectRef) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NoncopyableJSClassSupportImports_runNoncopyableUniqueArrayExportedPathTests_static") +fileprivate func bjs_NoncopyableJSClassSupportImports_runNoncopyableUniqueArrayExportedPathTests_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void +#else +fileprivate func bjs_NoncopyableJSClassSupportImports_runNoncopyableUniqueArrayExportedPathTests_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_NoncopyableJSClassSupportImports_runNoncopyableUniqueArrayExportedPathTests_static(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { + return bjs_NoncopyableJSClassSupportImports_runNoncopyableUniqueArrayExportedPathTests_static_extern(resolveRef, rejectRef) +} + +func _$NoncopyableJSClassSupportImports_liveReferenceCount() throws(JSException) -> Int { + let ret = bjs_NoncopyableJSClassSupportImports_liveReferenceCount_static() + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableJSClassSupportImports_retainByRefCount() throws(JSException) -> Int { + let ret = bjs_NoncopyableJSClassSupportImports_retainByRefCount_static() + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$NoncopyableJSClassSupportImports_runNoncopyableExportedPathTests() async throws(JSException) -> Void { + try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<() -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>.sending($0) + }) { resolveRef, rejectRef in + bjs_NoncopyableJSClassSupportImports_runNoncopyableExportedPathTests_static(resolveRef, rejectRef) + } +} + +func _$NoncopyableJSClassSupportImports_runNoncopyableUniqueArrayExportedPathTests() async throws(JSException) -> Void { + try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<() -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>.sending($0) + }) { resolveRef, rejectRef in + bjs_NoncopyableJSClassSupportImports_runNoncopyableUniqueArrayExportedPathTests_static(resolveRef, rejectRef) + } +} + #if arch(wasm32) @_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_jsRoundTripOptionalNumberNull_static") fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalNumberNull_static_extern(_ valueIsSome: Int32, _ valueValue: Int32) -> Void diff --git a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json b/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json index fb4d924e7..edc54df32 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json +++ b/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json @@ -5406,6 +5406,182 @@ ], "swiftCallName" : "JSNameRenamedClass" }, + { + "constructor" : { + "abiName" : "bjs_NoncopyableObjectBox_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "_", + "name" : "start", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_NoncopyableObjectBox_value", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "value", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_NoncopyableObjectBox_take", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "take", + "parameters" : [ + { + "label" : "_", + "name" : "other", + "type" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "NoncopyableObjectBox", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "object", + "type" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "made", + "type" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "shared", + "staticContext" : { + "className" : { + "_0" : "NoncopyableObjectBox" + } + }, + "type" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "staticMade", + "staticContext" : { + "className" : { + "_0" : "NoncopyableObjectBox" + } + }, + "type" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "optionalObject", + "type" : { + "nullable" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "objects", + "type" : { + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "maybeObjects", + "type" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + }, + "_1" : "null" + } + } + } + ], + "swiftCallName" : "NoncopyableObjectBox" + }, { "constructor" : { "abiName" : "bjs_OptionalHolder_init", @@ -18664,1300 +18840,1483 @@ } }, { - "abiName" : "bjs_roundTripPointerFields", + "abiName" : "bjs_noncopyableTake", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripPointerFields", + "name" : "noncopyableTake", "parameters" : [ { "label" : "_", - "name" : "value", + "name" : "object", "type" : { - "swiftStruct" : { - "_0" : "PointerFields" + "jsUniqueObject" : { + "_0" : "NoncopyableObject" } } } ], "returnType" : { - "swiftStruct" : { - "_0" : "PointerFields" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } }, { - "abiName" : "bjs_testStructDefault", + "abiName" : "bjs_noncopyableConsume", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "testStructDefault", + "name" : "noncopyableConsume", "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", + "label" : "_", + "name" : "object", "type" : { - "swiftStruct" : { - "_0" : "DataPoint" + "jsUniqueObject" : { + "_0" : "NoncopyableObject" } } } ], "returnType" : { - "string" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } }, { - "abiName" : "bjs_cartToJSObject", + "abiName" : "bjs_noncopyableMake", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "cartToJSObject", + "name" : "noncopyableMake", "parameters" : [ { "label" : "_", - "name" : "cart", + "name" : "start", "type" : { - "swiftStruct" : { - "_0" : "CopyableCart" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } ], "returnType" : { - "jsObject" : { - + "jsUniqueObject" : { + "_0" : "NoncopyableObject" } } }, { - "abiName" : "bjs_nestedCartToJSObject", + "abiName" : "bjs_noncopyableLoad", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "nestedCartToJSObject", + "name" : "noncopyableLoad", "parameters" : [ { "label" : "_", - "name" : "cart", + "name" : "start", "type" : { - "swiftStruct" : { - "_0" : "CopyableNestedCart" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } ], "returnType" : { - "jsObject" : { - + "jsUniqueObject" : { + "_0" : "NoncopyableObject" } } }, { - "abiName" : "bjs_roundTripDataPoint", + "abiName" : "bjs_noncopyableCallWith", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripDataPoint", + "name" : "noncopyableCallWith", "parameters" : [ { "label" : "_", - "name" : "data", + "name" : "start", "type" : { - "swiftStruct" : { - "_0" : "DataPoint" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "label" : "_", + "name" : "body", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests17NoncopyableObjectV_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false } } } ], "returnType" : { - "swiftStruct" : { - "_0" : "DataPoint" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } }, { - "abiName" : "bjs_roundTripPublicPoint", + "abiName" : "bjs_noncopyableCallWithOptional", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripPublicPoint", + "name" : "noncopyableCallWithOptional", "parameters" : [ { "label" : "_", - "name" : "point", + "name" : "start", "type" : { - "swiftStruct" : { - "_0" : "PublicPoint" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "label" : "_", + "name" : "body", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSq17NoncopyableObjectV_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "nullable" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false } } } ], "returnType" : { - "swiftStruct" : { - "_0" : "PublicPoint" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } }, { - "abiName" : "bjs_asyncRoundTripPublicPoint", + "abiName" : "bjs_noncopyableTakeOptional", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripPublicPoint", + "name" : "noncopyableTakeOptional", "parameters" : [ { "label" : "_", - "name" : "point", + "name" : "object", "type" : { - "swiftStruct" : { - "_0" : "PublicPoint" + "nullable" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + }, + "_1" : "null" } } } ], "returnType" : { - "swiftStruct" : { - "_0" : "PublicPoint" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } }, { - "abiName" : "bjs_asyncRoundTripPublicPointThrows", + "abiName" : "bjs_copyableTakeOptional", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "asyncRoundTripPublicPointThrows", + "name" : "copyableTakeOptional", "parameters" : [ { "label" : "_", - "name" : "point", + "name" : "copyable", "type" : { - "swiftStruct" : { - "_0" : "PublicPoint" + "nullable" : { + "_0" : { + "jsObject" : { + "_0" : "CopyableObjectRoundtrip" + } + }, + "_1" : "null" } } } ], "returnType" : { - "swiftStruct" : { - "_0" : "PublicPoint" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } }, { - "abiName" : "bjs_asyncStructOrThrow", + "abiName" : "bjs_noncopyableFindOptional", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "asyncStructOrThrow", + "name" : "noncopyableFindOptional", "parameters" : [ { "label" : "_", - "name" : "shouldThrow", + "name" : "start", "type" : { - "bool" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } ], "returnType" : { - "swiftStruct" : { - "_0" : "PublicPoint" + "nullable" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + }, + "_1" : "null" } } }, { - "abiName" : "bjs_asyncCombinePublicPoints", + "abiName" : "bjs_noncopyableVisit", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncCombinePublicPoints", + "name" : "noncopyableVisit", "parameters" : [ { "label" : "_", - "name" : "a", + "name" : "visitor", "type" : { - "swiftStruct" : { - "_0" : "PublicPoint" + "swiftProtocol" : { + "_0" : "NoncopyableObjectVisitor" } } }, { "label" : "_", - "name" : "b", + "name" : "start", "type" : { - "swiftStruct" : { - "_0" : "PublicPoint" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } ], "returnType" : { - "swiftStruct" : { - "_0" : "PublicPoint" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } }, { - "abiName" : "bjs_asyncRoundTripContact", + "abiName" : "bjs_noncopyableVisitOptional", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripContact", + "name" : "noncopyableVisitOptional", "parameters" : [ { "label" : "_", - "name" : "contact", + "name" : "visitor", "type" : { - "swiftStruct" : { - "_0" : "Contact" + "swiftProtocol" : { + "_0" : "NoncopyableOptionalObjectVisitor" } } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "Contact" - } - } - }, - { - "abiName" : "bjs_asyncRoundTripPublicPointArray", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "asyncRoundTripPublicPointArray", - "parameters" : [ + }, { "label" : "_", - "name" : "points", + "name" : "start", "type" : { - "array" : { + "integer" : { "_0" : { - "swiftStruct" : { - "_0" : "PublicPoint" - } + "isSigned" : true, + "width" : "word" } } } } ], "returnType" : { - "array" : { + "integer" : { "_0" : { - "swiftStruct" : { - "_0" : "PublicPoint" - } + "isSigned" : true, + "width" : "word" } } } }, { - "abiName" : "bjs_asyncRoundTripOptionalPublicPoint", + "abiName" : "bjs_noncopyableMakeReader", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripOptionalPublicPoint", + "name" : "noncopyableMakeReader", "parameters" : [ - { - "label" : "_", - "name" : "point", - "type" : { - "nullable" : { - "_0" : { - "swiftStruct" : { - "_0" : "PublicPoint" - } - }, - "_1" : "null" - } - } - } + ], "returnType" : { - "nullable" : { + "closure" : { "_0" : { - "swiftStruct" : { - "_0" : "PublicPoint" - } + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests17NoncopyableObjectV_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false }, - "_1" : "null" + "useJSTypedClosure" : true } } }, { - "abiName" : "bjs_asyncRoundTripPublicPointDict", + "abiName" : "bjs_copyableMakeReader", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripPublicPointDict", + "name" : "copyableMakeReader", "parameters" : [ - { - "label" : "_", - "name" : "points", - "type" : { - "dictionary" : { - "_0" : { - "swiftStruct" : { - "_0" : "PublicPoint" - } - } - } - } - } + ], "returnType" : { - "dictionary" : { + "closure" : { "_0" : { - "swiftStruct" : { - "_0" : "PublicPoint" - } - } + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests23CopyableObjectRoundtripC_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "jsObject" : { + "_0" : "CopyableObjectRoundtrip" + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true } } }, { - "abiName" : "bjs_roundTripContact", + "abiName" : "bjs_makeIntReader", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripContact", + "name" : "makeIntReader", "parameters" : [ - { - "label" : "_", - "name" : "contact", - "type" : { - "swiftStruct" : { - "_0" : "Contact" - } - } - } + ], "returnType" : { - "swiftStruct" : { - "_0" : "Contact" + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSi_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true } } }, { - "abiName" : "bjs_roundTripConfig", + "abiName" : "bjs_noncopyableTakeAll", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripConfig", + "name" : "noncopyableTakeAll", "parameters" : [ { "label" : "_", - "name" : "config", + "name" : "objects", "type" : { - "swiftStruct" : { - "_0" : "Config" + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } } } } ], "returnType" : { - "swiftStruct" : { - "_0" : "Config" + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } } } }, { - "abiName" : "bjs_roundTripSessionData", + "abiName" : "bjs_noncopyableMakeAll", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripSessionData", + "name" : "noncopyableMakeAll", "parameters" : [ { "label" : "_", - "name" : "session", + "name" : "count", "type" : { - "swiftStruct" : { - "_0" : "SessionData" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } ], "returnType" : { - "swiftStruct" : { - "_0" : "SessionData" + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } } } }, { - "abiName" : "bjs_roundTripValidationReport", + "abiName" : "bjs_noncopyableLoadAll", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripValidationReport", + "name" : "noncopyableLoadAll", "parameters" : [ { "label" : "_", - "name" : "report", + "name" : "count", "type" : { - "swiftStruct" : { - "_0" : "ValidationReport" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } ], "returnType" : { - "swiftStruct" : { - "_0" : "ValidationReport" + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } } } }, { - "abiName" : "bjs_roundTripAdvancedConfig", + "abiName" : "bjs_noncopyablePassAll", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripAdvancedConfig", + "name" : "noncopyablePassAll", "parameters" : [ { "label" : "_", - "name" : "config", + "name" : "objects", "type" : { - "swiftStruct" : { - "_0" : "AdvancedConfig" + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } } } } ], "returnType" : { - "swiftStruct" : { - "_0" : "AdvancedConfig" + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } } } }, { - "abiName" : "bjs_roundTripMeasurementConfig", + "abiName" : "bjs_noncopyableTakeAllOptional", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripMeasurementConfig", + "name" : "noncopyableTakeAllOptional", "parameters" : [ { "label" : "_", - "name" : "config", + "name" : "objects", "type" : { - "swiftStruct" : { - "_0" : "MeasurementConfig" + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + }, + "_1" : "null" + } + } } } } ], "returnType" : { - "swiftStruct" : { - "_0" : "MeasurementConfig" + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } } } }, { - "abiName" : "bjs_updateValidationReport", + "abiName" : "bjs_noncopyableTakeMaybe", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "updateValidationReport", + "name" : "noncopyableTakeMaybe", "parameters" : [ { "label" : "_", - "name" : "newResult", + "name" : "objects", "type" : { "nullable" : { "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } } }, "_1" : "null" } } - }, - { - "label" : "_", - "name" : "report", - "type" : { - "swiftStruct" : { - "_0" : "ValidationReport" - } - } } ], "returnType" : { - "swiftStruct" : { - "_0" : "ValidationReport" + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + }, + "_1" : "null" } } }, { - "abiName" : "bjs_testContainerWithStruct", + "abiName" : "bjs_noncopyableMakeMaybe", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "testContainerWithStruct", + "name" : "noncopyableMakeMaybe", "parameters" : [ { "label" : "_", - "name" : "point", + "name" : "count", "type" : { - "swiftStruct" : { - "_0" : "DataPoint" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } ], "returnType" : { - "swiftHeapObject" : { - "_0" : "Container" + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + }, + "_1" : "null" } } }, { - "abiName" : "bjs_roundTripJSObjectContainer", + "abiName" : "bjs_noncopyableVisitAll", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripJSObjectContainer", + "name" : "noncopyableVisitAll", "parameters" : [ { "label" : "_", - "name" : "container", + "name" : "visitor", "type" : { - "swiftStruct" : { - "_0" : "JSObjectContainer" + "swiftProtocol" : { + "_0" : "NoncopyableObjectVisitor" + } + } + }, + { + "label" : "_", + "name" : "objects", + "type" : { + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } } } } ], "returnType" : { - "swiftStruct" : { - "_0" : "JSObjectContainer" - } - } - }, - { - "abiName" : "bjs_roundTripFooContainer", + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_noncopyableVisitorMakeAll", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripFooContainer", + "name" : "noncopyableVisitorMakeAll", "parameters" : [ { "label" : "_", - "name" : "container", + "name" : "visitor", "type" : { - "swiftStruct" : { - "_0" : "FooContainer" + "swiftProtocol" : { + "_0" : "NoncopyableObjectVisitor" + } + } + }, + { + "label" : "_", + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } ], "returnType" : { - "swiftStruct" : { - "_0" : "FooContainer" + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } } } }, { - "abiName" : "bjs_roundTripArrayMembers", + "abiName" : "bjs_roundTripPointerFields", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripArrayMembers", + "name" : "roundTripPointerFields", "parameters" : [ { "label" : "_", "name" : "value", "type" : { "swiftStruct" : { - "_0" : "ArrayMembers" + "_0" : "PointerFields" } } } ], "returnType" : { "swiftStruct" : { - "_0" : "ArrayMembers" + "_0" : "PointerFields" } } }, { - "abiName" : "bjs_arrayMembersSum", + "abiName" : "bjs_testStructDefault", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "arrayMembersSum", + "name" : "testStructDefault", "parameters" : [ { - "label" : "_", - "name" : "value", - "type" : { - "swiftStruct" : { - "_0" : "ArrayMembers" - } - } - }, - { - "label" : "_", - "name" : "values", - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" + "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" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "string" : { + } } }, { - "abiName" : "bjs_arrayMembersFirst", + "abiName" : "bjs_cartToJSObject", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "arrayMembersFirst", + "name" : "cartToJSObject", "parameters" : [ { "label" : "_", - "name" : "value", + "name" : "cart", "type" : { "swiftStruct" : { - "_0" : "ArrayMembers" + "_0" : "CopyableCart" } } - }, + } + ], + "returnType" : { + "jsObject" : { + + } + } + }, + { + "abiName" : "bjs_nestedCartToJSObject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "nestedCartToJSObject", + "parameters" : [ { "label" : "_", - "name" : "values", + "name" : "cart", "type" : { - "array" : { - "_0" : { - "string" : { - - } - } + "swiftStruct" : { + "_0" : "CopyableNestedCart" } } } ], "returnType" : { - "nullable" : { - "_0" : { - "string" : { + "jsObject" : { - } - }, - "_1" : "null" } } - } - ], - "protocols" : [ + }, { - "methods" : [ - - ], - "name" : "ArrayElementProtocol", - "properties" : [ + "abiName" : "bjs_roundTripDataPoint", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripDataPoint", + "parameters" : [ { - "isReadonly" : false, - "name" : "value", + "label" : "_", + "name" : "data", "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "swiftStruct" : { + "_0" : "DataPoint" } } } - ] + ], + "returnType" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + } }, { - "methods" : [ + "abiName" : "bjs_roundTripPublicPoint", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripPublicPoint", + "parameters" : [ { - "abiName" : "bjs_ReservedWordDescriber_describe", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "describe", - "parameters" : [ - { - "label" : "in", - "name" : "in", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "label" : "for", - "name" : "for", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "string" : { - + "label" : "_", + "name" : "point", + "type" : { + "swiftStruct" : { + "_0" : "PublicPoint" } } } ], - "name" : "ReservedWordDescriber", - "properties" : [ - - ] + "returnType" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + } }, { - "methods" : [ + "abiName" : "bjs_asyncRoundTripPublicPoint", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripPublicPoint", + "parameters" : [ { - "abiName" : "bjs_DataProcessor_increment", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "increment", - "parameters" : [ - { - "label" : "by", - "name" : "amount", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "void" : { - + "label" : "_", + "name" : "point", + "type" : { + "swiftStruct" : { + "_0" : "PublicPoint" } } - }, + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + } + }, + { + "abiName" : "bjs_asyncRoundTripPublicPointThrows", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "asyncRoundTripPublicPointThrows", + "parameters" : [ { - "abiName" : "bjs_DataProcessor_getValue", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getValue", - "parameters" : [ - - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "label" : "_", + "name" : "point", + "type" : { + "swiftStruct" : { + "_0" : "PublicPoint" } } - }, + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + } + }, + { + "abiName" : "bjs_asyncStructOrThrow", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "asyncStructOrThrow", + "parameters" : [ { - "abiName" : "bjs_DataProcessor_setLabelElements", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setLabelElements", - "parameters" : [ - { - "label" : "_", - "name" : "labelPrefix", - "type" : { - "string" : { - - } - } - }, - { - "label" : "_", - "name" : "labelSuffix", - "type" : { - "string" : { + "label" : "_", + "name" : "shouldThrow", + "type" : { + "bool" : { - } - } } - ], - "returnType" : { - "void" : { - + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + } + }, + { + "abiName" : "bjs_asyncCombinePublicPoints", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncCombinePublicPoints", + "parameters" : [ + { + "label" : "_", + "name" : "a", + "type" : { + "swiftStruct" : { + "_0" : "PublicPoint" } } }, { - "abiName" : "bjs_DataProcessor_getLabel", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getLabel", - "parameters" : [ - - ], - "returnType" : { - "string" : { - + "label" : "_", + "name" : "b", + "type" : { + "swiftStruct" : { + "_0" : "PublicPoint" } } - }, + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + } + }, + { + "abiName" : "bjs_asyncRoundTripContact", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripContact", + "parameters" : [ { - "abiName" : "bjs_DataProcessor_isEven", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "isEven", - "parameters" : [ - - ], - "returnType" : { - "bool" : { - + "label" : "_", + "name" : "contact", + "type" : { + "swiftStruct" : { + "_0" : "Contact" } } - }, + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "Contact" + } + } + }, + { + "abiName" : "bjs_asyncRoundTripPublicPointArray", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripPublicPointArray", + "parameters" : [ { - "abiName" : "bjs_DataProcessor_processGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processGreeter", - "parameters" : [ - { - "label" : "_", - "name" : "greeter", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" + "label" : "_", + "name" : "points", + "type" : { + "array" : { + "_0" : { + "swiftStruct" : { + "_0" : "PublicPoint" } } } - ], - "returnType" : { - "string" : { - + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "swiftStruct" : { + "_0" : "PublicPoint" } } - }, - { - "abiName" : "bjs_DataProcessor_createGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "createGreeter", - "parameters" : [ - - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "abiName" : "bjs_DataProcessor_processOptionalGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processOptionalGreeter", - "parameters" : [ - { - "label" : "_", - "name" : "greeter", - "type" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, + } + } + }, + { + "abiName" : "bjs_asyncRoundTripOptionalPublicPoint", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripOptionalPublicPoint", + "parameters" : [ { - "abiName" : "bjs_DataProcessor_createOptionalGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "createOptionalGreeter", - "parameters" : [ - - ], - "returnType" : { + "label" : "_", + "name" : "point", + "type" : { "nullable" : { "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" + "swiftStruct" : { + "_0" : "PublicPoint" } }, "_1" : "null" } } - }, - { - "abiName" : "bjs_DataProcessor_handleAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } }, - "name" : "handleAPIResult", - "parameters" : [ - { - "label" : "_", - "name" : "result", - "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" + "_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" : { - "void" : { - - } } - }, - { - "abiName" : "bjs_DataProcessor_getAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getAPIResult", - "parameters" : [ - - ], - "returnType" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" + } + ], + "returnType" : { + "dictionary" : { + "_0" : { + "swiftStruct" : { + "_0" : "PublicPoint" } } - }, + } + } + }, + { + "abiName" : "bjs_roundTripContact", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripContact", + "parameters" : [ { - "abiName" : "bjs_DataProcessor_validate", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "validate", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "label" : "_", + "name" : "contact", + "type" : { + "swiftStruct" : { + "_0" : "Contact" } } - }, + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "Contact" + } + } + }, + { + "abiName" : "bjs_roundTripConfig", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripConfig", + "parameters" : [ { - "abiName" : "bjs_DataProcessor_loadLabel", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "loadLabel", - "parameters" : [ - { - "label" : "_", - "name" : "key", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessor_reset", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "reset", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessor_fetchCount", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "fetchCount", - "parameters" : [ - - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "label" : "_", + "name" : "config", + "type" : { + "swiftStruct" : { + "_0" : "Config" } } } ], - "name" : "DataProcessor", - "properties" : [ + "returnType" : { + "swiftStruct" : { + "_0" : "Config" + } + } + }, + { + "abiName" : "bjs_roundTripSessionData", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripSessionData", + "parameters" : [ { - "isReadonly" : false, - "name" : "count", + "label" : "_", + "name" : "session", "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "swiftStruct" : { + "_0" : "SessionData" } } - }, + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "SessionData" + } + } + }, + { + "abiName" : "bjs_roundTripValidationReport", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripValidationReport", + "parameters" : [ { - "isReadonly" : true, - "name" : "name", + "label" : "_", + "name" : "report", "type" : { - "string" : { - + "swiftStruct" : { + "_0" : "ValidationReport" } } - }, + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "ValidationReport" + } + } + }, + { + "abiName" : "bjs_roundTripAdvancedConfig", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripAdvancedConfig", + "parameters" : [ { - "isReadonly" : false, - "name" : "optionalTag", + "label" : "_", + "name" : "config", "type" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" + "swiftStruct" : { + "_0" : "AdvancedConfig" } } - }, + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "AdvancedConfig" + } + } + }, + { + "abiName" : "bjs_roundTripMeasurementConfig", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripMeasurementConfig", + "parameters" : [ { - "isReadonly" : false, - "name" : "optionalCount", + "label" : "_", + "name" : "config", "type" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" + "swiftStruct" : { + "_0" : "MeasurementConfig" } } - }, + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "MeasurementConfig" + } + } + }, + { + "abiName" : "bjs_updateValidationReport", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "updateValidationReport", + "parameters" : [ { - "isReadonly" : false, - "name" : "direction", + "label" : "_", + "name" : "newResult", "type" : { "nullable" : { "_0" : { - "caseEnum" : { - "_0" : "Direction" + "associatedValueEnum" : { + "_0" : "APIResult" } }, "_1" : "null" @@ -19965,156 +20324,219 @@ } }, { - "isReadonly" : false, - "name" : "optionalTheme", + "label" : "_", + "name" : "report", "type" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - }, - "_1" : "null" + "swiftStruct" : { + "_0" : "ValidationReport" } } - }, + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "ValidationReport" + } + } + }, + { + "abiName" : "bjs_testContainerWithStruct", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testContainerWithStruct", + "parameters" : [ { - "isReadonly" : false, - "name" : "httpStatus", + "label" : "_", + "name" : "point", "type" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - }, - "_1" : "null" + "swiftStruct" : { + "_0" : "DataPoint" } } - }, + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Container" + } + } + }, + { + "abiName" : "bjs_roundTripJSObjectContainer", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripJSObjectContainer", + "parameters" : [ { - "isReadonly" : false, - "name" : "apiResult", + "label" : "_", + "name" : "container", "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" + "swiftStruct" : { + "_0" : "JSObjectContainer" } } - }, - { - "isReadonly" : false, - "name" : "helper", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "JSObjectContainer" + } + } + }, + { + "abiName" : "bjs_roundTripFooContainer", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripFooContainer", + "parameters" : [ { - "isReadonly" : false, - "name" : "optionalHelper", + "label" : "_", + "name" : "container", "type" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" + "swiftStruct" : { + "_0" : "FooContainer" } } } - ] + ], + "returnType" : { + "swiftStruct" : { + "_0" : "FooContainer" + } + } }, { - "isGenericBridgeable" : true, - "methods" : [ + "abiName" : "bjs_roundTripArrayMembers", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripArrayMembers", + "parameters" : [ { - "abiName" : "bjs_GenericRTPosition_sum", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "sum", - "parameters" : [ - - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "label" : "_", + "name" : "value", + "type" : { + "swiftStruct" : { + "_0" : "ArrayMembers" } } } ], - "name" : "GenericRTPosition", - "properties" : [ + "returnType" : { + "swiftStruct" : { + "_0" : "ArrayMembers" + } + } + }, + { + "abiName" : "bjs_arrayMembersSum", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "arrayMembersSum", + "parameters" : [ { - "isReadonly" : true, - "name" : "x", + "label" : "_", + "name" : "value", "type" : { - "integer" : { + "swiftStruct" : { + "_0" : "ArrayMembers" + } + } + }, + { + "label" : "_", + "name" : "values", + "type" : { + "array" : { "_0" : { - "isSigned" : true, - "width" : "word" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } } } } } - ] + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } }, { - "inheritedJSProtocols" : [ - "GenericRTPosition" - ], - "isGenericBridgeable" : true, - "methods" : [ - - ], - "name" : "GenericRTNode", - "properties" : [ + "abiName" : "bjs_arrayMembersFirst", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "arrayMembersFirst", + "parameters" : [ { - "isReadonly" : true, - "name" : "y", + "label" : "_", + "name" : "value", "type" : { - "integer" : { + "swiftStruct" : { + "_0" : "ArrayMembers" + } + } + }, + { + "label" : "_", + "name" : "values", + "type" : { + "array" : { "_0" : { - "isSigned" : true, - "width" : "word" + "string" : { + + } } } } } - ] - }, + ], + "returnType" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + ], + "protocols" : [ { "methods" : [ ], - "name" : "RefineIdentified", + "name" : "ArrayElementProtocol", "properties" : [ - { - "isReadonly" : true, - "name" : "id", - "type" : { - "string" : { - - } - } - }, { "isReadonly" : false, - "name" : "score", + "name" : "value", "type" : { "integer" : { "_0" : { @@ -20129,15 +20551,35 @@ { "methods" : [ { - "abiName" : "bjs_RefineNamed_label", + "abiName" : "bjs_ReservedWordDescriber_describe", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "label", + "name" : "describe", "parameters" : [ + { + "label" : "in", + "name" : "in", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "label" : "for", + "name" : "for", + "type" : { + "string" : { + } + } + } ], "returnType" : { "string" : { @@ -20146,92 +20588,51 @@ } } ], - "name" : "RefineNamed", + "name" : "ReservedWordDescriber", "properties" : [ - { - "isReadonly" : true, - "name" : "name", - "type" : { - "string" : { - } - } - } ] }, { - "inheritedJSProtocols" : [ - "RefineIdentified", - "RefineNamed" - ], "methods" : [ { - "abiName" : "bjs_RefineEntity_label", + "abiName" : "bjs_DataProcessor_increment", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "label", + "name" : "increment", "parameters" : [ - + { + "label" : "by", + "name" : "amount", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } ], "returnType" : { - "string" : { + "void" : { } } - } - ], - "name" : "RefineEntity", - "properties" : [ + }, { - "isReadonly" : true, - "name" : "id", - "type" : { - "string" : { - - } - } - } - ] - }, - { - "inheritedJSProtocols" : [ - "RefineEntity" - ], - "methods" : [ - - ], - "name" : "RefineTagged", - "properties" : [ - - ] - }, - { - "jsName" : "CounterTransform", - "methods" : [ - { - "abiName" : "bjs_JSNameTransformer_apply", + "abiName" : "bjs_DataProcessor_getValue", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "apply", + "name" : "getValue", "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } + ], "returnType" : { "integer" : { @@ -20241,301 +20642,244 @@ } } } - } - ], - "name" : "JSNameTransformer", - "properties" : [ - - ] - } - ], - "structs" : [ - { - "constructor" : { - "abiName" : "bjs_JSCoordinate_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false }, - "parameters" : [ - { - "label" : "latitude", - "name" : "latitude", - "type" : { - "double" : { + { + "abiName" : "bjs_DataProcessor_setLabelElements", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setLabelElements", + "parameters" : [ + { + "label" : "_", + "name" : "labelPrefix", + "type" : { + "string" : { + } } - } - }, - { - "label" : "longitude", - "name" : "longitude", - "type" : { - "double" : { + }, + { + "label" : "_", + "name" : "labelSuffix", + "type" : { + "string" : { + } } } - } - ] - }, - "methods" : [ - - ], - "name" : "JSCoordinate", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "latitude", - "type" : { - "double" : { + ], + "returnType" : { + "void" : { } } }, { - "isReadonly" : true, - "isStatic" : false, - "name" : "longitude", - "type" : { - "double" : { - - } - } - } - ], - "swiftCallName" : "JSCoordinate" - }, - { - "methods" : [ + "abiName" : "bjs_DataProcessor_getLabel", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getLabel", + "parameters" : [ - ], - "name" : "Metadata", - "namespace" : [ - "NestedStructGroupA" - ], - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "label", - "namespace" : [ - "NestedStructGroupA" ], - "type" : { + "returnType" : { "string" : { } } }, { - "isReadonly" : true, - "isStatic" : false, - "name" : "count", - "namespace" : [ - "NestedStructGroupA" - ], - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "swiftCallName" : "NestedStructGroupA.Metadata" - }, - { - "methods" : [ + "abiName" : "bjs_DataProcessor_isEven", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "isEven", + "parameters" : [ - ], - "name" : "Metadata", - "namespace" : [ - "NestedStructGroupB" - ], - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "tag", - "namespace" : [ - "NestedStructGroupB" ], - "type" : { - "string" : { + "returnType" : { + "bool" : { } } }, { - "isReadonly" : true, - "isStatic" : false, - "name" : "value", - "namespace" : [ - "NestedStructGroupB" + "abiName" : "bjs_DataProcessor_processGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processGreeter", + "parameters" : [ + { + "label" : "_", + "name" : "greeter", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } ], - "type" : { - "double" : { + "returnType" : { + "string" : { } } - } - ], - "swiftCallName" : "NestedStructGroupB.Metadata" - }, - { - "constructor" : { - "abiName" : "bjs_NestedTypeHost_Label_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false }, - "parameters" : [ - { - "label" : "text", - "name" : "text", - "type" : { - "string" : { - - } - } - } - ] - }, - "methods" : [ { - "abiName" : "bjs_NestedTypeHost_Label_static_untitled", + "abiName" : "bjs_DataProcessor_createGreeter", "effects" : { "isAsync" : false, - "isStatic" : true, + "isStatic" : false, "isThrows" : false }, - "name" : "untitled", + "name" : "createGreeter", "parameters" : [ ], "returnType" : { - "swiftStruct" : { - "_0" : "NestedTypeHost.Label" - } - }, - "staticContext" : { - "structName" : { - "_0" : "NestedTypeHost_Label" + "swiftHeapObject" : { + "_0" : "Greeter" } } - } - ], - "name" : "Label", - "namespace" : [ - "NestedTypeHost" - ], - "properties" : [ + }, { - "isReadonly" : true, - "isStatic" : false, - "name" : "text", - "namespace" : [ - "NestedTypeHost" + "abiName" : "bjs_DataProcessor_processOptionalGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processOptionalGreeter", + "parameters" : [ + { + "label" : "_", + "name" : "greeter", + "type" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + } ], - "type" : { + "returnType" : { "string" : { } } }, { - "isReadonly" : true, - "isStatic" : true, - "name" : "maxLength", - "staticContext" : { - "structName" : { - "_0" : "NestedTypeHost_Label" - } + "abiName" : "bjs_DataProcessor_createOptionalGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false }, - "type" : { - "integer" : { + "name" : "createOptionalGreeter", + "parameters" : [ + + ], + "returnType" : { + "nullable" : { "_0" : { - "isSigned" : true, - "width" : "word" - } + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" } } - } - ], - "swiftCallName" : "NestedTypeHost.Label" - }, - { - "constructor" : { - "abiName" : "bjs_Library_Shelf_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false }, - "parameters" : [ - { - "label" : "label", - "name" : "label", - "type" : { - "string" : { - - } - } - } - ] - }, - "methods" : [ { - "abiName" : "bjs_Library_Shelf_describeShelf", + "abiName" : "bjs_DataProcessor_handleAPIResult", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "describeShelf", + "name" : "handleAPIResult", "parameters" : [ - + { + "label" : "_", + "name" : "result", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + } ], "returnType" : { - "string" : { + "void" : { } } - } - ], - "name" : "Shelf", - "namespace" : [ - "Library" - ], - "properties" : [ + }, { - "isReadonly" : true, - "isStatic" : false, - "name" : "label", - "namespace" : [ - "Library" - ], - "type" : { - "string" : { + "abiName" : "bjs_DataProcessor_getAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getAPIResult", + "parameters" : [ + ], + "returnType" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" } } }, { - "isReadonly" : true, - "isStatic" : true, - "name" : "capacity", - "staticContext" : { - "structName" : { - "_0" : "Library_Shelf" - } + "abiName" : "bjs_DataProcessor_validate", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true }, - "type" : { + "name" : "validate", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { "integer" : { "_0" : { "isSigned" : true, @@ -20543,72 +20887,57 @@ } } } - } - ], - "swiftCallName" : "Library.Shelf" - }, - { - "constructor" : { - "abiName" : "bjs_Library_Shelf_Divider_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false }, - "parameters" : [ - { - "label" : "slot", - "name" : "slot", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" + { + "abiName" : "bjs_DataProcessor_loadLabel", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "loadLabel", + "parameters" : [ + { + "label" : "_", + "name" : "key", + "type" : { + "string" : { + } } } - } - ] - }, - "methods" : [ + ], + "returnType" : { + "string" : { - ], - "name" : "Divider", - "namespace" : [ - "Library", - "Shelf" - ], - "properties" : [ + } + } + }, { - "isReadonly" : true, - "isStatic" : false, - "name" : "slot", - "namespace" : [ - "Library", - "Shelf" + "abiName" : "bjs_DataProcessor_reset", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "reset", + "parameters" : [ + ], - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "returnType" : { + "void" : { + } } - } - ], - "swiftCallName" : "Library.Shelf.Divider" - }, - { - "methods" : [ + }, { - "abiName" : "bjs_GenericRTPoint_sum", + "abiName" : "bjs_DataProcessor_fetchCount", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "sum", + "name" : "fetchCount", "parameters" : [ ], @@ -20622,12 +20951,11 @@ } } ], - "name" : "GenericRTPoint", + "name" : "DataProcessor", "properties" : [ { - "isReadonly" : true, - "isStatic" : false, - "name" : "x", + "isReadonly" : false, + "name" : "count", "type" : { "integer" : { "_0" : { @@ -20639,70 +20967,155 @@ }, { "isReadonly" : true, - "isStatic" : false, - "name" : "y", + "name" : "name", "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "string" : { + } } - } - ], - "swiftCallName" : "GenericRTPoint" - }, - { - "methods" : [ - - ], - "name" : "Metadata", - "namespace" : [ - "GenericRTNamespace" - ], - "properties" : [ + }, { - "isReadonly" : true, - "isStatic" : false, - "name" : "label", - "namespace" : [ - "GenericRTNamespace" - ], + "isReadonly" : false, + "name" : "optionalTag", "type" : { - "string" : { + "nullable" : { + "_0" : { + "string" : { + } + }, + "_1" : "null" } } }, { - "isReadonly" : true, - "isStatic" : false, - "name" : "count", - "namespace" : [ - "GenericRTNamespace" - ], + "isReadonly" : false, + "name" : "optionalCount", "type" : { - "integer" : { + "nullable" : { "_0" : { - "isSigned" : true, - "width" : "word" - } + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "name" : "direction", + "type" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "name" : "optionalTheme", + "type" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "name" : "httpStatus", + "type" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "name" : "apiResult", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "name" : "helper", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "isReadonly" : false, + "name" : "optionalHelper", + "type" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" } } } - ], - "swiftCallName" : "GenericRTNamespace.Metadata" + ] }, { + "isGenericBridgeable" : true, "methods" : [ + { + "abiName" : "bjs_GenericRTPosition_sum", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "sum", + "parameters" : [ + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } ], - "name" : "Point", + "name" : "GenericRTPosition", "properties" : [ { "isReadonly" : true, - "isStatic" : false, "name" : "x", "type" : { "integer" : { @@ -20712,10 +21125,21 @@ } } } - }, + } + ] + }, + { + "inheritedJSProtocols" : [ + "GenericRTPosition" + ], + "isGenericBridgeable" : true, + "methods" : [ + + ], + "name" : "GenericRTNode", + "properties" : [ { "isReadonly" : true, - "isStatic" : false, "name" : "y", "type" : { "integer" : { @@ -20726,42 +21150,26 @@ } } } - ], - "swiftCallName" : "Point" + ] }, { - "constructor" : { - "abiName" : "bjs_JSNameSnapshot_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ] - }, - "jsName" : "CounterSnapshot", "methods" : [ ], - "name" : "JSNameSnapshot", + "name" : "RefineIdentified", "properties" : [ { "isReadonly" : true, - "isStatic" : false, - "name" : "value", + "name" : "id", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "name" : "score", "type" : { "integer" : { "_0" : { @@ -20771,315 +21179,257 @@ } } } - ], - "swiftCallName" : "JSNameSnapshot" + ] }, { - "constructor" : { - "abiName" : "bjs_PointerFields_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "raw", - "name" : "raw", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeRawPointer" - } - } - } + "methods" : [ + { + "abiName" : "bjs_RefineNamed_label", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false }, - { - "label" : "mutRaw", - "name" : "mutRaw", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutableRawPointer" - } - } - } - }, - { - "label" : "opaque", - "name" : "opaque", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "opaquePointer" - } - } - } - }, - { - "label" : "ptr", - "name" : "ptr", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafePointer", - "pointee" : "UInt8" - } - } - } - }, - { - "label" : "mutPtr", - "name" : "mutPtr", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutablePointer", - "pointee" : "UInt8" - } - } + "name" : "label", + "parameters" : [ + + ], + "returnType" : { + "string" : { + } } - ] - }, - "methods" : [ - + } ], - "name" : "PointerFields", + "name" : "RefineNamed", "properties" : [ { "isReadonly" : true, - "isStatic" : false, - "name" : "raw", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeRawPointer" - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "mutRaw", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutableRawPointer" - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "opaque", + "name" : "name", "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "opaquePointer" - } + "string" : { + } } - }, + } + ] + }, + { + "inheritedJSProtocols" : [ + "RefineIdentified", + "RefineNamed" + ], + "methods" : [ { - "isReadonly" : true, - "isStatic" : false, - "name" : "ptr", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafePointer", - "pointee" : "UInt8" - } + "abiName" : "bjs_RefineEntity_label", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "label", + "parameters" : [ + + ], + "returnType" : { + "string" : { + } } - }, + } + ], + "name" : "RefineEntity", + "properties" : [ { "isReadonly" : true, - "isStatic" : false, - "name" : "mutPtr", + "name" : "id", "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutablePointer", - "pointee" : "UInt8" - } + "string" : { + } } } - ], - "swiftCallName" : "PointerFields" + ] }, { - "constructor" : { - "abiName" : "bjs_DataPoint_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "x", - "name" : "x", - "type" : { - "double" : { - - } - } - }, - { - "label" : "y", - "name" : "y", - "type" : { - "double" : { + "inheritedJSProtocols" : [ + "RefineEntity" + ], + "methods" : [ - } - } - }, - { - "label" : "label", - "name" : "label", - "type" : { - "string" : { + ], + "name" : "RefineTagged", + "properties" : [ - } - } + ] + }, + { + "jsName" : "CounterTransform", + "methods" : [ + { + "abiName" : "bjs_JSNameTransformer_apply", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false }, - { - "label" : "optCount", - "name" : "optCount", - "type" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "name" : "apply", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" } - }, - "_1" : "null" + } } } - }, - { - "label" : "optFlag", - "name" : "optFlag", - "type" : { - "nullable" : { - "_0" : { - "bool" : { - - } - }, - "_1" : "null" + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" } } } - ] - }, + } + ], + "name" : "JSNameTransformer", + "properties" : [ + + ] + }, + { "methods" : [ { - "abiName" : "bjs_DataPoint_static_origin", + "abiName" : "bjs_NoncopyableObjectVisitor_visit", "effects" : { "isAsync" : false, - "isStatic" : true, + "isStatic" : false, "isThrows" : false }, - "name" : "origin", + "name" : "visit", "parameters" : [ - + { + "label" : "_", + "name" : "object", + "type" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } ], "returnType" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - }, - "staticContext" : { - "structName" : { - "_0" : "DataPoint" - } - } - } - ], - "name" : "DataPoint", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "x", - "type" : { - "double" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } }, { - "isReadonly" : true, - "isStatic" : false, - "name" : "y", - "type" : { - "double" : { - + "abiName" : "bjs_NoncopyableObjectVisitor_visitAll", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "visitAll", + "parameters" : [ + { + "label" : "_", + "name" : "objects", + "type" : { + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + } } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "label", - "type" : { - "string" : { - + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } }, { - "isReadonly" : true, - "isStatic" : false, - "name" : "optCount", - "type" : { - "nullable" : { - "_0" : { + "abiName" : "bjs_NoncopyableObjectVisitor_makeAll", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAll", + "parameters" : [ + { + "label" : "_", + "name" : "count", + "type" : { "integer" : { "_0" : { "isSigned" : true, "width" : "word" } } - }, - "_1" : "null" + } } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "optFlag", - "type" : { - "nullable" : { + ], + "returnType" : { + "array" : { "_0" : { - "bool" : { - + "jsUniqueObject" : { + "_0" : "NoncopyableObject" } - }, - "_1" : "null" + } } } - }, + } + ], + "name" : "NoncopyableObjectVisitor", + "properties" : [ + + ] + }, + { + "methods" : [ { - "isReadonly" : true, - "isStatic" : true, - "name" : "dimensions", - "staticContext" : { - "structName" : { - "_0" : "DataPoint" - } + "abiName" : "bjs_NoncopyableOptionalObjectVisitor_visit", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false }, - "type" : { + "name" : "visit", + "parameters" : [ + { + "label" : "_", + "name" : "object", + "type" : { + "nullable" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { "integer" : { "_0" : { "isSigned" : true, @@ -21089,11 +21439,16 @@ } } ], - "swiftCallName" : "DataPoint" - }, + "name" : "NoncopyableOptionalObjectVisitor", + "properties" : [ + + ] + } + ], + "structs" : [ { "constructor" : { - "abiName" : "bjs_PublicPoint_init", + "abiName" : "bjs_JSCoordinate_init", "effects" : { "isAsync" : false, "isStatic" : false, @@ -21101,86 +21456,69 @@ }, "parameters" : [ { - "label" : "x", - "name" : "x", + "label" : "latitude", + "name" : "latitude", "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "double" : { + } } }, { - "label" : "y", - "name" : "y", + "label" : "longitude", + "name" : "longitude", "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "double" : { + } } } ] }, - "explicitAccessControl" : "public", "methods" : [ ], - "name" : "PublicPoint", + "name" : "JSCoordinate", "properties" : [ { "isReadonly" : true, "isStatic" : false, - "name" : "x", + "name" : "latitude", "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "double" : { + } } }, { "isReadonly" : true, "isStatic" : false, - "name" : "y", + "name" : "longitude", "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "double" : { + } } } ], - "swiftCallName" : "PublicPoint" + "swiftCallName" : "JSCoordinate" }, { "methods" : [ ], - "name" : "Address", + "name" : "Metadata", + "namespace" : [ + "NestedStructGroupA" + ], "properties" : [ { "isReadonly" : true, "isStatic" : false, - "name" : "street", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "city", + "name" : "label", + "namespace" : [ + "NestedStructGroupA" + ], "type" : { "string" : { @@ -21190,34 +21528,38 @@ { "isReadonly" : true, "isStatic" : false, - "name" : "zipCode", + "name" : "count", + "namespace" : [ + "NestedStructGroupA" + ], "type" : { - "nullable" : { + "integer" : { "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" + "isSigned" : true, + "width" : "word" + } } } } ], - "swiftCallName" : "Address" + "swiftCallName" : "NestedStructGroupA.Metadata" }, { "methods" : [ ], - "name" : "Contact", + "name" : "Metadata", + "namespace" : [ + "NestedStructGroupB" + ], "properties" : [ { "isReadonly" : true, "isStatic" : false, - "name" : "name", + "name" : "tag", + "namespace" : [ + "NestedStructGroupB" + ], "type" : { "string" : { @@ -21227,69 +21569,153 @@ { "isReadonly" : true, "isStatic" : false, - "name" : "age", + "name" : "value", + "namespace" : [ + "NestedStructGroupB" + ], "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "double" : { + } } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "address", - "type" : { - "swiftStruct" : { - "_0" : "Address" + } + ], + "swiftCallName" : "NestedStructGroupB.Metadata" + }, + { + "constructor" : { + "abiName" : "bjs_NestedTypeHost_Label_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "text", + "name" : "text", + "type" : { + "string" : { + + } } } - }, + ] + }, + "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" : [ + "NestedTypeHost" + ], + "properties" : [ { "isReadonly" : true, "isStatic" : false, - "name" : "email", + "name" : "text", + "namespace" : [ + "NestedTypeHost" + ], "type" : { - "nullable" : { - "_0" : { - "string" : { + "string" : { - } - }, - "_1" : "null" } } }, { "isReadonly" : true, - "isStatic" : false, - "name" : "secondaryAddress", + "isStatic" : true, + "name" : "maxLength", + "staticContext" : { + "structName" : { + "_0" : "NestedTypeHost_Label" + } + }, "type" : { - "nullable" : { + "integer" : { "_0" : { - "swiftStruct" : { - "_0" : "Address" - } - }, - "_1" : "null" + "isSigned" : true, + "width" : "word" + } } } } ], - "swiftCallName" : "Contact" + "swiftCallName" : "NestedTypeHost.Label" }, { + "constructor" : { + "abiName" : "bjs_Library_Shelf_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "label", + "name" : "label", + "type" : { + "string" : { + + } + } + } + ] + }, "methods" : [ + { + "abiName" : "bjs_Library_Shelf_describeShelf", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "describeShelf", + "parameters" : [ + + ], + "returnType" : { + "string" : { + } + } + } + ], + "name" : "Shelf", + "namespace" : [ + "Library" ], - "name" : "Config", "properties" : [ { "isReadonly" : true, "isStatic" : false, - "name" : "name", + "name" : "label", + "namespace" : [ + "Library" + ], "type" : { "string" : { @@ -21298,58 +21724,106 @@ }, { "isReadonly" : true, - "isStatic" : false, - "name" : "theme", + "isStatic" : true, + "name" : "capacity", + "staticContext" : { + "structName" : { + "_0" : "Library_Shelf" + } + }, "type" : { - "nullable" : { + "integer" : { "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - }, - "_1" : "null" + "isSigned" : true, + "width" : "word" + } } } - }, - { - "isReadonly" : true, + } + ], + "swiftCallName" : "Library.Shelf" + }, + { + "constructor" : { + "abiName" : "bjs_Library_Shelf_Divider_init", + "effects" : { + "isAsync" : false, "isStatic" : false, - "name" : "direction", - "type" : { - "nullable" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" + "isThrows" : false + }, + "parameters" : [ + { + "label" : "slot", + "name" : "slot", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" } - }, - "_1" : "null" + } } } - }, + ] + }, + "methods" : [ + + ], + "name" : "Divider", + "namespace" : [ + "Library", + "Shelf" + ], + "properties" : [ { "isReadonly" : true, "isStatic" : false, - "name" : "status", + "name" : "slot", + "namespace" : [ + "Library", + "Shelf" + ], "type" : { - "caseEnum" : { - "_0" : "Status" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } ], - "swiftCallName" : "Config" + "swiftCallName" : "Library.Shelf.Divider" }, { "methods" : [ + { + "abiName" : "bjs_GenericRTPoint_sum", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "sum", + "parameters" : [ + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } ], - "name" : "SessionData", + "name" : "GenericRTPoint", "properties" : [ { "isReadonly" : true, "isStatic" : false, - "name" : "id", + "name" : "x", "type" : { "integer" : { "_0" : { @@ -21362,93 +21836,70 @@ { "isReadonly" : true, "isStatic" : false, - "name" : "owner", + "name" : "y", "type" : { - "nullable" : { + "integer" : { "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" + "isSigned" : true, + "width" : "word" + } } } } ], - "swiftCallName" : "SessionData" + "swiftCallName" : "GenericRTPoint" }, { "methods" : [ ], - "name" : "ValidationReport", + "name" : "Metadata", + "namespace" : [ + "GenericRTNamespace" + ], "properties" : [ { "isReadonly" : true, "isStatic" : false, - "name" : "id", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "result", - "type" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "status", + "name" : "label", + "namespace" : [ + "GenericRTNamespace" + ], "type" : { - "nullable" : { - "_0" : { - "caseEnum" : { - "_0" : "Status" - } - }, - "_1" : "null" + "string" : { + } } }, { "isReadonly" : true, "isStatic" : false, - "name" : "outcome", + "name" : "count", + "namespace" : [ + "GenericRTNamespace" + ], "type" : { - "nullable" : { + "integer" : { "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" + "isSigned" : true, + "width" : "word" + } } } } ], - "swiftCallName" : "ValidationReport" + "swiftCallName" : "GenericRTNamespace.Metadata" }, { "methods" : [ ], - "name" : "AdvancedConfig", + "name" : "Point", "properties" : [ { "isReadonly" : true, "isStatic" : false, - "name" : "id", + "name" : "x", "type" : { "integer" : { "_0" : { @@ -21461,155 +21912,339 @@ { "isReadonly" : true, "isStatic" : false, - "name" : "title", + "name" : "y", "type" : { - "string" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } - }, - { - "isReadonly" : true, + } + ], + "swiftCallName" : "Point" + }, + { + "constructor" : { + "abiName" : "bjs_JSNameSnapshot_init", + "effects" : { + "isAsync" : false, "isStatic" : false, - "name" : "enabled", - "type" : { - "bool" : { - + "isThrows" : false + }, + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } } } - }, + ] + }, + "jsName" : "CounterSnapshot", + "methods" : [ + + ], + "name" : "JSNameSnapshot", + "properties" : [ { "isReadonly" : true, "isStatic" : false, - "name" : "theme", + "name" : "value", "type" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } - }, - { - "isReadonly" : true, + } + ], + "swiftCallName" : "JSNameSnapshot" + }, + { + "constructor" : { + "abiName" : "bjs_PointerFields_init", + "effects" : { + "isAsync" : false, "isStatic" : false, - "name" : "status", - "type" : { - "caseEnum" : { - "_0" : "Status" + "isThrows" : false + }, + "parameters" : [ + { + "label" : "raw", + "name" : "raw", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeRawPointer" + } + } + } + }, + { + "label" : "mutRaw", + "name" : "mutRaw", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeMutableRawPointer" + } + } + } + }, + { + "label" : "opaque", + "name" : "opaque", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "opaquePointer" + } + } + } + }, + { + "label" : "ptr", + "name" : "ptr", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafePointer", + "pointee" : "UInt8" + } + } + } + }, + { + "label" : "mutPtr", + "name" : "mutPtr", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeMutablePointer", + "pointee" : "UInt8" + } + } } } - }, + ] + }, + "methods" : [ + + ], + "name" : "PointerFields", + "properties" : [ { "isReadonly" : true, "isStatic" : false, - "name" : "result", + "name" : "raw", "type" : { - "nullable" : { + "unsafePointer" : { "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" + "kind" : "unsafeRawPointer" + } } } }, { "isReadonly" : true, "isStatic" : false, - "name" : "metadata", + "name" : "mutRaw", "type" : { - "nullable" : { + "unsafePointer" : { "_0" : { - "jsObject" : { - - } - }, - "_1" : "null" + "kind" : "unsafeMutableRawPointer" + } } } }, { "isReadonly" : true, "isStatic" : false, - "name" : "location", + "name" : "opaque", "type" : { - "nullable" : { + "unsafePointer" : { "_0" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - }, - "_1" : "null" + "kind" : "opaquePointer" + } } } }, { "isReadonly" : true, "isStatic" : false, - "name" : "defaults", + "name" : "ptr", "type" : { - "swiftStruct" : { - "_0" : "ConfigStruct" + "unsafePointer" : { + "_0" : { + "kind" : "unsafePointer", + "pointee" : "UInt8" + } } } }, { "isReadonly" : true, "isStatic" : false, - "name" : "overrideDefaults", + "name" : "mutPtr", "type" : { - "nullable" : { + "unsafePointer" : { "_0" : { - "swiftStruct" : { - "_0" : "ConfigStruct" - } - }, - "_1" : "null" + "kind" : "unsafeMutablePointer", + "pointee" : "UInt8" + } } } } ], - "swiftCallName" : "AdvancedConfig" + "swiftCallName" : "PointerFields" }, { - "methods" : [ - - ], - "name" : "MeasurementConfig", - "properties" : [ - { - "isReadonly" : true, + "constructor" : { + "abiName" : "bjs_DataPoint_init", + "effects" : { + "isAsync" : false, "isStatic" : false, - "name" : "precision", + "isThrows" : false + }, + "parameters" : [ + { + "label" : "x", + "name" : "x", + "type" : { + "double" : { + + } + } + }, + { + "label" : "y", + "name" : "y", + "type" : { + "double" : { + + } + } + }, + { + "label" : "label", + "name" : "label", + "type" : { + "string" : { + + } + } + }, + { + "label" : "optCount", + "name" : "optCount", + "type" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + }, + { + "label" : "optFlag", + "name" : "optFlag", + "type" : { + "nullable" : { + "_0" : { + "bool" : { + + } + }, + "_1" : "null" + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_DataPoint_static_origin", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "origin", + "parameters" : [ + + ], + "returnType" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + }, + "staticContext" : { + "structName" : { + "_0" : "DataPoint" + } + } + } + ], + "name" : "DataPoint", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "x", "type" : { - "rawValueEnum" : { - "_0" : "Precision", - "_1" : "Float" + "double" : { + } } }, { "isReadonly" : true, "isStatic" : false, - "name" : "ratio", + "name" : "y", "type" : { - "rawValueEnum" : { - "_0" : "Ratio", - "_1" : "Double" + "double" : { + } } }, { "isReadonly" : true, "isStatic" : false, - "name" : "optionalPrecision", + "name" : "label", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "optCount", "type" : { "nullable" : { "_0" : { - "rawValueEnum" : { - "_0" : "Precision", - "_1" : "Float" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } }, "_1" : "null" @@ -21619,25 +22254,42 @@ { "isReadonly" : true, "isStatic" : false, - "name" : "optionalRatio", + "name" : "optFlag", "type" : { "nullable" : { "_0" : { - "rawValueEnum" : { - "_0" : "Ratio", - "_1" : "Double" + "bool" : { + } }, "_1" : "null" } } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "dimensions", + "staticContext" : { + "structName" : { + "_0" : "DataPoint" + } + }, + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } } ], - "swiftCallName" : "MeasurementConfig" + "swiftCallName" : "DataPoint" }, { "constructor" : { - "abiName" : "bjs_MathOperations_init", + "abiName" : "bjs_PublicPoint_init", "effects" : { "isAsync" : false, "isStatic" : false, @@ -21645,212 +22297,104 @@ }, "parameters" : [ { - "defaultValue" : { - "double" : { - "_0" : 0 + "label" : "x", + "name" : "x", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } - }, - "label" : "baseValue", - "name" : "baseValue", + } + }, + { + "label" : "y", + "name" : "y", "type" : { - "double" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } ] }, + "explicitAccessControl" : "public", "methods" : [ - { - "abiName" : "bjs_MathOperations_add", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "add", - "parameters" : [ - { - "label" : "a", - "name" : "a", - "type" : { - "double" : { - - } - } - }, - { - "defaultValue" : { - "double" : { - "_0" : 10 - } - }, - "label" : "b", - "name" : "b", - "type" : { - "double" : { - } + ], + "name" : "PublicPoint", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "x", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" } } - ], - "returnType" : { - "double" : { - - } } }, { - "abiName" : "bjs_MathOperations_multiply", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "multiply", - "parameters" : [ - { - "label" : "a", - "name" : "a", - "type" : { - "double" : { - - } + "isReadonly" : true, + "isStatic" : false, + "name" : "y", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" } - }, - { - "label" : "b", - "name" : "b", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "double" : { - - } - } - }, - { - "abiName" : "bjs_MathOperations_static_subtract", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "subtract", - "parameters" : [ - { - "label" : "a", - "name" : "a", - "type" : { - "double" : { - - } - } - }, - { - "defaultValue" : { - "double" : { - "_0" : 5 - } - }, - "label" : "b", - "name" : "b", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "double" : { - - } - }, - "staticContext" : { - "structName" : { - "_0" : "MathOperations" } } } ], - "name" : "MathOperations", + "swiftCallName" : "PublicPoint" + }, + { + "methods" : [ + + ], + "name" : "Address", "properties" : [ { "isReadonly" : true, "isStatic" : false, - "name" : "baseValue", + "name" : "street", "type" : { - "double" : { - - } - } - } - ], - "swiftCallName" : "MathOperations" - }, - { - "methods" : [ - { - "abiName" : "bjs_CopyableCart_static_fromJSObject", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "fromJSObject", - "parameters" : [ - { - "label" : "_", - "name" : "object", - "type" : { - "jsObject" : { + "string" : { - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "CopyableCart" - } - }, - "staticContext" : { - "structName" : { - "_0" : "CopyableCart" } } - } - ], - "name" : "CopyableCart", - "properties" : [ + }, { "isReadonly" : true, "isStatic" : false, - "name" : "x", + "name" : "city", "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "string" : { + } } }, { "isReadonly" : true, "isStatic" : false, - "name" : "note", + "name" : "zipCode", "type" : { "nullable" : { "_0" : { - "string" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } }, "_1" : "null" @@ -21858,18 +22402,18 @@ } } ], - "swiftCallName" : "CopyableCart" + "swiftCallName" : "Address" }, { "methods" : [ ], - "name" : "CopyableCartItem", + "name" : "Contact", "properties" : [ { "isReadonly" : true, "isStatic" : false, - "name" : "sku", + "name" : "name", "type" : { "string" : { @@ -21879,7 +22423,7 @@ { "isReadonly" : true, "isStatic" : false, - "name" : "quantity", + "name" : "age", "type" : { "integer" : { "_0" : { @@ -21888,72 +22432,36 @@ } } } - } - ], - "swiftCallName" : "CopyableCartItem" - }, - { - "methods" : [ - { - "abiName" : "bjs_CopyableNestedCart_static_fromJSObject", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "fromJSObject", - "parameters" : [ - { - "label" : "_", - "name" : "object", - "type" : { - "jsObject" : { - - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "CopyableNestedCart" - } - }, - "staticContext" : { - "structName" : { - "_0" : "CopyableNestedCart" - } - } - } - ], - "name" : "CopyableNestedCart", - "properties" : [ + }, { "isReadonly" : true, "isStatic" : false, - "name" : "id", + "name" : "address", "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "swiftStruct" : { + "_0" : "Address" } } }, { "isReadonly" : true, "isStatic" : false, - "name" : "item", + "name" : "email", "type" : { - "swiftStruct" : { - "_0" : "CopyableCartItem" + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" } } }, { "isReadonly" : true, "isStatic" : false, - "name" : "shippingAddress", + "name" : "secondaryAddress", "type" : { "nullable" : { "_0" : { @@ -21966,13 +22474,13 @@ } } ], - "swiftCallName" : "CopyableNestedCart" + "swiftCallName" : "Contact" }, { "methods" : [ ], - "name" : "ConfigStruct", + "name" : "Config", "properties" : [ { "isReadonly" : true, @@ -21987,209 +22495,181 @@ { "isReadonly" : true, "isStatic" : false, - "name" : "value", + "name" : "theme", "type" : { - "integer" : { + "nullable" : { "_0" : { - "isSigned" : true, - "width" : "word" - } + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + }, + "_1" : "null" } } }, { - "isReadonly" : false, - "isStatic" : true, - "name" : "defaultConfig", - "staticContext" : { - "structName" : { - "_0" : "ConfigStruct" - } - }, + "isReadonly" : true, + "isStatic" : false, + "name" : "direction", "type" : { - "string" : { - + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" } } }, { "isReadonly" : true, - "isStatic" : true, - "name" : "maxRetries", - "staticContext" : { - "structName" : { - "_0" : "ConfigStruct" - } - }, + "isStatic" : false, + "name" : "status", "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "caseEnum" : { + "_0" : "Status" } } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "timeout", - "staticContext" : { - "structName" : { - "_0" : "ConfigStruct" - } - }, - "type" : { - "double" : { + } + ], + "swiftCallName" : "Config" + }, + { + "methods" : [ + ], + "name" : "SessionData", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "id", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } }, { "isReadonly" : true, - "isStatic" : true, - "name" : "computedSetting", - "staticContext" : { - "structName" : { - "_0" : "ConfigStruct" - } - }, + "isStatic" : false, + "name" : "owner", "type" : { - "string" : { - + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" } } } ], - "swiftCallName" : "ConfigStruct" + "swiftCallName" : "SessionData" }, { - "constructor" : { - "abiName" : "bjs_Vector2D_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "dx", - "name" : "dx", - "type" : { - "double" : { - - } - } - }, - { - "label" : "dy", - "name" : "dy", - "type" : { - "double" : { + "methods" : [ + ], + "name" : "ValidationReport", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "id", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" } } } - ] - }, - "methods" : [ + }, { - "abiName" : "bjs_Vector2D_magnitude", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "magnitude", - "parameters" : [ - - ], - "returnType" : { - "double" : { - + "isReadonly" : true, + "isStatic" : false, + "name" : "result", + "type" : { + "associatedValueEnum" : { + "_0" : "APIResult" } } }, { - "abiName" : "bjs_Vector2D_scaled", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "scaled", - "parameters" : [ - { - "label" : "by", - "name" : "factor", - "type" : { - "double" : { - + "isReadonly" : true, + "isStatic" : false, + "name" : "status", + "type" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Status" } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "Vector2D" + }, + "_1" : "null" } } }, { - "abiName" : "bjs_Vector2D_describe", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "describe", - "parameters" : [ - - ], - "returnType" : { - "string" : { - + "isReadonly" : true, + "isStatic" : false, + "name" : "outcome", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" } } } ], - "name" : "Vector2D", + "swiftCallName" : "ValidationReport" + }, + { + "methods" : [ + + ], + "name" : "AdvancedConfig", "properties" : [ { "isReadonly" : true, "isStatic" : false, - "name" : "dx", + "name" : "id", "type" : { - "double" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } }, { "isReadonly" : true, "isStatic" : false, - "name" : "dy", + "name" : "title", "type" : { - "double" : { + "string" : { } } - } - ], - "swiftCallName" : "Vector2D" - }, - { - "methods" : [ - - ], - "name" : "JSObjectContainer", - "properties" : [ + }, { "isReadonly" : true, "isStatic" : false, - "name" : "object", + "name" : "enabled", "type" : { - "jsObject" : { + "bool" : { } } @@ -22197,253 +22677,376 @@ { "isReadonly" : true, "isStatic" : false, - "name" : "optionalObject", + "name" : "theme", + "type" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "status", + "type" : { + "caseEnum" : { + "_0" : "Status" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "result", "type" : { "nullable" : { "_0" : { - "jsObject" : { - + "associatedValueEnum" : { + "_0" : "APIResult" } }, "_1" : "null" } } - } - ], - "swiftCallName" : "JSObjectContainer" - }, - { - "methods" : [ - - ], - "name" : "FooContainer", - "properties" : [ + }, { "isReadonly" : true, "isStatic" : false, - "name" : "foo", + "name" : "metadata", "type" : { - "jsObject" : { - "_0" : "Foo" + "nullable" : { + "_0" : { + "jsObject" : { + + } + }, + "_1" : "null" } } }, { "isReadonly" : true, "isStatic" : false, - "name" : "optionalFoo", + "name" : "location", "type" : { "nullable" : { "_0" : { - "jsObject" : { - "_0" : "Foo" + "swiftStruct" : { + "_0" : "DataPoint" } }, "_1" : "null" } } - } - ], - "swiftCallName" : "FooContainer" - }, - { - "methods" : [ + }, { - "abiName" : "bjs_ArrayMembers_sumValues", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "sumValues", - "parameters" : [ - { - "label" : "_", - "name" : "values", - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } + "isReadonly" : true, + "isStatic" : false, + "name" : "defaults", + "type" : { + "swiftStruct" : { + "_0" : "ConfigStruct" } - ], - "returnType" : { - "integer" : { + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "overrideDefaults", + "type" : { + "nullable" : { "_0" : { - "isSigned" : true, - "width" : "word" - } + "swiftStruct" : { + "_0" : "ConfigStruct" + } + }, + "_1" : "null" + } + } + } + ], + "swiftCallName" : "AdvancedConfig" + }, + { + "methods" : [ + + ], + "name" : "MeasurementConfig", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "precision", + "type" : { + "rawValueEnum" : { + "_0" : "Precision", + "_1" : "Float" } } }, { - "abiName" : "bjs_ArrayMembers_firstString", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "firstString", - "parameters" : [ - { - "label" : "_", - "name" : "values", - "type" : { - "array" : { - "_0" : { - "string" : { - - } - } + "isReadonly" : true, + "isStatic" : false, + "name" : "ratio", + "type" : { + "rawValueEnum" : { + "_0" : "Ratio", + "_1" : "Double" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "optionalPrecision", + "type" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Precision", + "_1" : "Float" } - } + }, + "_1" : "null" } - ], - "returnType" : { + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "optionalRatio", + "type" : { "nullable" : { "_0" : { - "string" : { - + "rawValueEnum" : { + "_0" : "Ratio", + "_1" : "Double" } }, "_1" : "null" } } + } + ], + "swiftCallName" : "MeasurementConfig" + }, + { + "constructor" : { + "abiName" : "bjs_MathOperations_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false }, + "parameters" : [ + { + "defaultValue" : { + "double" : { + "_0" : 0 + } + }, + "label" : "baseValue", + "name" : "baseValue", + "type" : { + "double" : { + + } + } + } + ] + }, + "methods" : [ { - "abiName" : "bjs_ArrayMembers_ownSumAsync", + "abiName" : "bjs_MathOperations_add", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "ownSumAsync", + "name" : "add", "parameters" : [ + { + "label" : "a", + "name" : "a", + "type" : { + "double" : { + + } + } + }, + { + "defaultValue" : { + "double" : { + "_0" : 10 + } + }, + "label" : "b", + "name" : "b", + "type" : { + "double" : { + } + } + } ], "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "double" : { + } } }, { - "abiName" : "bjs_ArrayMembers_sumAsync", + "abiName" : "bjs_MathOperations_multiply", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "sumAsync", + "name" : "multiply", "parameters" : [ { - "label" : "_", - "name" : "values", + "label" : "a", + "name" : "a", "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } + "double" : { + + } + } + }, + { + "label" : "b", + "name" : "b", + "type" : { + "double" : { + } } } ], "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "double" : { + } } }, { - "abiName" : "bjs_ArrayMembers_requireValues", + "abiName" : "bjs_MathOperations_static_subtract", "effects" : { "isAsync" : false, - "isStatic" : false, - "isThrows" : true + "isStatic" : true, + "isThrows" : false }, - "name" : "requireValues", + "name" : "subtract", "parameters" : [ { - "label" : "_", - "name" : "values", + "label" : "a", + "name" : "a", "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } + "double" : { + } } - } - ], - "returnType" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + }, + { + "defaultValue" : { + "double" : { + "_0" : 5 + } + }, + "label" : "b", + "name" : "b", + "type" : { + "double" : { + } } } + ], + "returnType" : { + "double" : { + + } + }, + "staticContext" : { + "structName" : { + "_0" : "MathOperations" + } } } ], - "name" : "ArrayMembers", + "name" : "MathOperations", "properties" : [ { "isReadonly" : true, "isStatic" : false, - "name" : "ints", + "name" : "baseValue", "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "double" : { + + } + } + } + ], + "swiftCallName" : "MathOperations" + }, + { + "methods" : [ + { + "abiName" : "bjs_CopyableCart_static_fromJSObject", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "fromJSObject", + "parameters" : [ + { + "label" : "_", + "name" : "object", + "type" : { + "jsObject" : { + } } } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "CopyableCart" + } + }, + "staticContext" : { + "structName" : { + "_0" : "CopyableCart" + } + } + } + ], + "name" : "CopyableCart", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "x", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } } }, { "isReadonly" : true, "isStatic" : false, - "name" : "optStrings", + "name" : "note", "type" : { "nullable" : { "_0" : { - "array" : { - "_0" : { - "string" : { + "string" : { - } - } } }, "_1" : "null" @@ -22451,99 +23054,2999 @@ } } ], - "swiftCallName" : "ArrayMembers" - } - ] - }, - "imported" : { - "children" : [ + "swiftCallName" : "CopyableCart" + }, { - "functions" : [ + "methods" : [ ], - "types" : [ + "name" : "CopyableCartItem", + "properties" : [ { - "accessLevel" : "internal", - "constructor" : { - "accessLevel" : "internal", - "parameters" : [ - { - "name" : "label", - "type" : { - "string" : { + "isReadonly" : true, + "isStatic" : false, + "name" : "sku", + "type" : { + "string" : { - } - } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "quantity", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" } - ] + } + } + } + ], + "swiftCallName" : "CopyableCartItem" + }, + { + "methods" : [ + { + "abiName" : "bjs_CopyableNestedCart_static_fromJSObject", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false }, - "getters" : [ + "name" : "fromJSObject", + "parameters" : [ { - "accessLevel" : "internal", - "name" : "label", + "label" : "_", + "name" : "object", "type" : { - "string" : { + "jsObject" : { } } } ], - "methods" : [ - - ], - "name" : "Surface", - "setters" : [ - - ], - "staticMethods" : [ - - ] + "returnType" : { + "swiftStruct" : { + "_0" : "CopyableNestedCart" + } + }, + "staticContext" : { + "structName" : { + "_0" : "CopyableNestedCart" + } + } + } + ], + "name" : "CopyableNestedCart", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "id", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } }, { - "accessLevel" : "internal", - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "AliasImports", - "setters" : [ - - ], - "staticMethods" : [ - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true + "isReadonly" : true, + "isStatic" : false, + "name" : "item", + "type" : { + "swiftStruct" : { + "_0" : "CopyableCartItem" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "shippingAddress", + "type" : { + "nullable" : { + "_0" : { + "swiftStruct" : { + "_0" : "Address" + } }, - "name" : "jsRoundTripTagged", - "parameters" : [ - { - "name" : "value", - "type" : { - "alias" : { - "name" : "Tagged", - "underlying" : { - "string" : { + "_1" : "null" + } + } + } + ], + "swiftCallName" : "CopyableNestedCart" + }, + { + "methods" : [ - } - } - } - } - } - ], - "returnType" : { - "alias" : { - "name" : "Tagged", + ], + "name" : "ConfigStruct", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "defaultConfig", + "staticContext" : { + "structName" : { + "_0" : "ConfigStruct" + } + }, + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "maxRetries", + "staticContext" : { + "structName" : { + "_0" : "ConfigStruct" + } + }, + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "timeout", + "staticContext" : { + "structName" : { + "_0" : "ConfigStruct" + } + }, + "type" : { + "double" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "computedSetting", + "staticContext" : { + "structName" : { + "_0" : "ConfigStruct" + } + }, + "type" : { + "string" : { + + } + } + } + ], + "swiftCallName" : "ConfigStruct" + }, + { + "constructor" : { + "abiName" : "bjs_Vector2D_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "dx", + "name" : "dx", + "type" : { + "double" : { + + } + } + }, + { + "label" : "dy", + "name" : "dy", + "type" : { + "double" : { + + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_Vector2D_magnitude", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "magnitude", + "parameters" : [ + + ], + "returnType" : { + "double" : { + + } + } + }, + { + "abiName" : "bjs_Vector2D_scaled", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "scaled", + "parameters" : [ + { + "label" : "by", + "name" : "factor", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "Vector2D" + } + } + }, + { + "abiName" : "bjs_Vector2D_describe", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "describe", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + } + ], + "name" : "Vector2D", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "dx", + "type" : { + "double" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "dy", + "type" : { + "double" : { + + } + } + } + ], + "swiftCallName" : "Vector2D" + }, + { + "methods" : [ + + ], + "name" : "JSObjectContainer", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "object", + "type" : { + "jsObject" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "optionalObject", + "type" : { + "nullable" : { + "_0" : { + "jsObject" : { + + } + }, + "_1" : "null" + } + } + } + ], + "swiftCallName" : "JSObjectContainer" + }, + { + "methods" : [ + + ], + "name" : "FooContainer", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "foo", + "type" : { + "jsObject" : { + "_0" : "Foo" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "optionalFoo", + "type" : { + "nullable" : { + "_0" : { + "jsObject" : { + "_0" : "Foo" + } + }, + "_1" : "null" + } + } + } + ], + "swiftCallName" : "FooContainer" + }, + { + "methods" : [ + { + "abiName" : "bjs_ArrayMembers_sumValues", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "sumValues", + "parameters" : [ + { + "label" : "_", + "name" : "values", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_ArrayMembers_firstString", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "firstString", + "parameters" : [ + { + "label" : "_", + "name" : "values", + "type" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + }, + { + "abiName" : "bjs_ArrayMembers_ownSumAsync", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "ownSumAsync", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_ArrayMembers_sumAsync", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "sumAsync", + "parameters" : [ + { + "label" : "_", + "name" : "values", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_ArrayMembers_requireValues", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "requireValues", + "parameters" : [ + { + "label" : "_", + "name" : "values", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + } + ], + "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" + } + } + }, + { + "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" : { + "nullable" : { + "_0" : { + "alias" : { + "name" : "AliasedTag", + "underlying" : { + "associatedValueEnum" : { + "_0" : "InnerTag" + } + } + } + }, + "_1" : "null" + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripPolygon", + "parameters" : [ + { + "name" : "value", + "type" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + } + } + ], + "returnType" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripCoordinate", + "parameters" : [ + { + "name" : "value", + "type" : { + "alias" : { + "name" : "Coordinate", + "underlying" : { + "swiftStruct" : { + "_0" : "JSCoordinate" + } + } + } + } + } + ], + "returnType" : { + "alias" : { + "name" : "Coordinate", + "underlying" : { + "swiftStruct" : { + "_0" : "JSCoordinate" + } + } + } + } + }, + { + "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" + } + } + } + ] + } + ] + }, + { + "functions" : [ + + ], + "types" : [ + { + "accessLevel" : "internal", + "constructor" : { + "accessLevel" : "internal", + "parameters" : [ + { + "name" : "id", + "type" : { + "string" : { + + } + } + } + ] + }, + "getters" : [ + { + "accessLevel" : "internal", + "name" : "id", + "type" : { + "string" : { + + } + } + } + ], + "methods" : [ + + ], + "name" : "ArrayElementObject", + "setters" : [ + + ], + "staticMethods" : [ + + ] + }, + { + "accessLevel" : "internal", + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "ArraySupportImports", + "setters" : [ + + ], + "staticMethods" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsIntArrayLength", + "parameters" : [ + { + "name" : "items", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripIntArray", + "parameters" : [ + { + "name" : "items", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripNumberArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripStringArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripBoolArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "bool" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "bool" : { + + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripJSValueArray", + "parameters" : [ + { + "name" : "v", + "type" : { + "array" : { + "_0" : { + "jsValue" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "jsValue" : { + + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripJSObjectArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "jsObject" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "jsObject" : { + + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripJSClassArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "jsObject" : { + "_0" : "ArrayElementObject" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "jsObject" : { + "_0" : "ArrayElementObject" + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalIntArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalStringArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalBoolArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "bool" : { + + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "bool" : { + + } + }, + "_1" : "null" + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalJSValueArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "jsValue" : { + + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "jsValue" : { + + } + }, + "_1" : "null" + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalJSObjectArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "jsObject" : { + + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "jsObject" : { + + } + }, + "_1" : "null" + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalJSClassArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "jsObject" : { + "_0" : "ArrayElementObject" + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "jsObject" : { + "_0" : "ArrayElementObject" + } + }, + "_1" : "null" + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsSumNumberArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsCreateNumberArray", + "parameters" : [ + + ], + "returnType" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "runJsArraySupportTests", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + } + ] + } + ] + }, + { + "functions" : [ + + ], + "types" : [ + { + "accessLevel" : "internal", + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "AsyncImportImports", + "setters" : [ + + ], + "staticMethods" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripVoid", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripNumber", + "parameters" : [ + { + "name" : "v", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripBool", + "parameters" : [ + { + "name" : "v", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripString", + "parameters" : [ + { + "name" : "v", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripOptionalString", + "parameters" : [ + { + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripOptionalNumber", + "parameters" : [ + { + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "double" : { + + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "double" : { + + } + }, + "_1" : "null" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripBoolArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "bool" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "bool" : { + + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripIntArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "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", + "parameters" : [ + { + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "AsyncImportedPayloadResult" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "AsyncImportedPayloadResult" + } + }, + "_1" : "null" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncThrowSynchronously", + "parameters" : [ + { + "name" : "message", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncReturnNonPromise", + "parameters" : [ + { + "name" : "v", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "double" : { + + } + } + } + ] + } + ] + }, + { + "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" : [ + { + "accessLevel" : "internal", + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "ClosureSupportImports", + "setters" : [ + + ], + "staticMethods" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsApplyVoid", + "parameters" : [ + { + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsy_y", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsApplyBool", + "parameters" : [ + { + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsy_Sb", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + + ], + "returnType" : { + "bool" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsApplyInt", + "parameters" : [ + { + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "name" : "transform", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSi_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsApplyDouble", + "parameters" : [ + { + "name" : "value", + "type" : { + "double" : { + + } + } + }, + { + "name" : "transform", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSd_Sd", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "double" : { + + } + } + ], + "returnType" : { + "double" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsApplyString", + "parameters" : [ + { + "name" : "value", + "type" : { + "string" : { + + } + } + }, + { + "name" : "transform", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsApplyJSObject", + "parameters" : [ + { + "name" : "value", + "type" : { + "jsObject" : { + + } + } + }, + { + "name" : "transform", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests8JSObjectC_8JSObjectC", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "jsObject" : { + + } + } + ], + "returnType" : { + "jsObject" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "jsObject" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsApplyArrayInt", + "parameters" : [ + { + "name" : "value", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + }, + { + "name" : "transform", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSaSi_SaSi", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsApplyArrayDouble", + "parameters" : [ + { + "name" : "value", + "type" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + } + }, + { + "name" : "transform", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSaSd_SaSd", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "array" : { + "_0" : { + "double" : { + + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsApplyArrayString", + "parameters" : [ + { + "name" : "value", + "type" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + }, + { + "name" : "transform", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSaSS_SaSS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsApplyArrayJSValue", + "parameters" : [ + { + "name" : "value", + "type" : { + "array" : { + "_0" : { + "jsValue" : { + + } + } + } + } + }, + { + "name" : "transform", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSa7JSValueV_Sa7JSValueV", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "array" : { + "_0" : { + "jsValue" : { + + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "jsValue" : { + + } + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "jsValue" : { + + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsApplyArrayJSObject", + "parameters" : [ + { + "name" : "value", + "type" : { + "array" : { + "_0" : { + "jsObject" : { + + } + } + } + } + }, + { + "name" : "transform", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSa8JSObjectC_Sa8JSObjectC", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "array" : { + "_0" : { + "jsObject" : { + + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "jsObject" : { + + } + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "jsObject" : { + + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsMakeIntToInt", + "parameters" : [ + { + "name" : "base", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSi_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsMakeDoubleToDouble", + "parameters" : [ + { + "name" : "base", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSd_Sd", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "double" : { + + } + } + ], + "returnType" : { + "double" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsMakeStringToString", + "parameters" : [ + { + "name" : "prefix", + "type" : { "string" : { } } } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsCallTwice", + "parameters" : [ + { + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSi_y", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + ], + "returnType" : { + "void" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsCallBinary", + "parameters" : [ + { + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSiSi_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } } }, { @@ -22553,40 +26056,64 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripOptionalTagged", + "name" : "jsCallTriple", "parameters" : [ { - "name" : "value", + "name" : "callback", "type" : { - "nullable" : { + "closure" : { "_0" : { - "alias" : { - "name" : "Tagged", - "underlying" : { - "string" : { - + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSiSiSi_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } - } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false }, - "_1" : "null" + "useJSTypedClosure" : true } } } ], "returnType" : { - "nullable" : { + "integer" : { "_0" : { - "alias" : { - "name" : "Tagged", - "underlying" : { - "string" : { - - } - } - } - }, - "_1" : "null" + "isSigned" : true, + "width" : "word" + } } } }, @@ -22597,35 +26124,35 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsProduceOptionalCanvas", + "name" : "jsCallAfterRelease", "parameters" : [ { - "name" : "label", + "name" : "callback", "type" : { - "nullable" : { + "closure" : { "_0" : { - "string" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsy_y", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ - } + ], + "returnType" : { + "void" : { + + } + }, + "sendingParameters" : false }, - "_1" : "null" + "useJSTypedClosure" : true } } } ], "returnType" : { - "nullable" : { - "_0" : { - "alias" : { - "name" : "Canvas", - "underlying" : { - "jsObject" : { - "_0" : "Surface" - } - } - } - }, - "_1" : "null" + "string" : { + } } }, @@ -22636,48 +26163,40 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripAliasedTags", + "name" : "jsOptionalInvoke", "parameters" : [ { - "name" : "values", + "name" : "callback", "type" : { - "array" : { + "nullable" : { "_0" : { - "nullable" : { + "closure" : { "_0" : { - "alias" : { - "name" : "AliasedTag", - "underlying" : { - "associatedValueEnum" : { - "_0" : "InnerTag" - } + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsy_Sb", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + + ], + "returnType" : { + "bool" : { + } - } + }, + "sendingParameters" : false }, - "_1" : "null" + "useJSTypedClosure" : true } - } + }, + "_1" : "null" } } } ], "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "alias" : { - "name" : "AliasedTag", - "underlying" : { - "associatedValueEnum" : { - "_0" : "InnerTag" - } - } - } - }, - "_1" : "null" - } - } + "bool" : { + } } }, @@ -22688,30 +26207,35 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripPolygon", + "name" : "jsStoreClosure", "parameters" : [ { - "name" : "value", + "name" : "callback", "type" : { - "alias" : { - "name" : "Polygon", - "underlying" : { - "swiftHeapObject" : { - "_0" : "PolygonReference" - } - } + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsy_y", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true } } } ], "returnType" : { - "alias" : { - "name" : "Polygon", - "underlying" : { - "swiftHeapObject" : { - "_0" : "PolygonReference" - } - } + "void" : { + } } }, @@ -22722,30 +26246,13 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripCoordinate", + "name" : "jsCallStoredClosure", "parameters" : [ - { - "name" : "value", - "type" : { - "alias" : { - "name" : "Coordinate", - "underlying" : { - "swiftStruct" : { - "_0" : "JSCoordinate" - } - } - } - } - } + ], "returnType" : { - "alias" : { - "name" : "Coordinate", - "underlying" : { - "swiftStruct" : { - "_0" : "JSCoordinate" - } - } + "void" : { + } } }, @@ -22754,37 +26261,17 @@ "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripUserId", - "parameters" : [ - { - "name" : "value", - "type" : { - "alias" : { - "name" : "UserId", - "underlying" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - } + "isThrows" : true + }, + "name" : "jsHeapCount", + "parameters" : [ + ], "returnType" : { - "alias" : { - "name" : "UserId", - "underlying" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" } } } @@ -22796,46 +26283,13 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripOptionalUserId", + "name" : "runJsClosureSupportTests", "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" + "void" : { + } } } @@ -22850,41 +26304,43 @@ "types" : [ { "accessLevel" : "internal", - "constructor" : { - "accessLevel" : "internal", - "parameters" : [ - { - "name" : "id", - "type" : { - "string" : { - - } - } - } - ] - }, "getters" : [ - { - "accessLevel" : "internal", - "name" : "id", - "type" : { - "string" : { - } - } - } ], "methods" : [ ], - "name" : "ArrayElementObject", + "name" : "ClosureThrowsImports", "setters" : [ ], "staticMethods" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "runJsClosureThrowsTests", + "parameters" : [ + + ], + "returnType" : { + "void" : { + } + } + } ] - }, + } + ] + }, + { + "functions" : [ + + ], + "types" : [ { "accessLevel" : "internal", "getters" : [ @@ -22893,7 +26349,7 @@ "methods" : [ ], - "name" : "ArraySupportImports", + "name" : "DefaultArgumentImports", "setters" : [ ], @@ -22905,33 +26361,38 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsIntArrayLength", + "name" : "runJsDefaultArgumentTests", "parameters" : [ - { - "name" : "items", - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - } + ], "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "void" : { + } } - }, + } + ] + } + ] + }, + { + "functions" : [ + + ], + "types" : [ + { + "accessLevel" : "internal", + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "DictionarySupportImports", + "setters" : [ + + ], + "staticMethods" : [ { "accessLevel" : "internal", "effects" : { @@ -22939,12 +26400,12 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripIntArray", + "name" : "jsRoundTripDictionaryInt", "parameters" : [ { - "name" : "items", + "name" : "values", "type" : { - "array" : { + "dictionary" : { "_0" : { "integer" : { "_0" : { @@ -22958,7 +26419,7 @@ } ], "returnType" : { - "array" : { + "dictionary" : { "_0" : { "integer" : { "_0" : { @@ -22977,76 +26438,12 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripNumberArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "double" : { - - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "double" : { - - } - } - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripStringArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripBoolArray", + "name" : "jsRoundTripDictionaryBool", "parameters" : [ { "name" : "values", "type" : { - "array" : { + "dictionary" : { "_0" : { "bool" : { @@ -23057,7 +26454,7 @@ } ], "returnType" : { - "array" : { + "dictionary" : { "_0" : { "bool" : { @@ -23073,14 +26470,14 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripJSValueArray", + "name" : "jsRoundTripDictionaryDouble", "parameters" : [ { - "name" : "v", + "name" : "values", "type" : { - "array" : { + "dictionary" : { "_0" : { - "jsValue" : { + "double" : { } } @@ -23089,9 +26486,9 @@ } ], "returnType" : { - "array" : { + "dictionary" : { "_0" : { - "jsValue" : { + "double" : { } } @@ -23105,12 +26502,12 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripJSObjectArray", + "name" : "jsRoundTripDictionaryJSObject", "parameters" : [ { "name" : "values", "type" : { - "array" : { + "dictionary" : { "_0" : { "jsObject" : { @@ -23121,7 +26518,7 @@ } ], "returnType" : { - "array" : { + "dictionary" : { "_0" : { "jsObject" : { @@ -23137,15 +26534,15 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripJSClassArray", + "name" : "jsRoundTripDictionaryJSValue", "parameters" : [ { "name" : "values", "type" : { - "array" : { + "dictionary" : { "_0" : { - "jsObject" : { - "_0" : "ArrayElementObject" + "jsValue" : { + } } } @@ -23153,10 +26550,10 @@ } ], "returnType" : { - "array" : { + "dictionary" : { "_0" : { - "jsObject" : { - "_0" : "ArrayElementObject" + "jsValue" : { + } } } @@ -23169,23 +26566,19 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripOptionalIntArray", + "name" : "jsRoundTripDictionaryDoubleArray", "parameters" : [ { "name" : "values", "type" : { - "array" : { + "dictionary" : { "_0" : { - "nullable" : { + "array" : { "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "double" : { + } - }, - "_1" : "null" + } } } } @@ -23193,149 +26586,446 @@ } ], "returnType" : { - "array" : { + "dictionary" : { "_0" : { - "nullable" : { + "array" : { "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "double" : { + } - }, - "_1" : "null" + } } } } } - }, + } + ] + } + ] + }, + { + "functions" : [ + + ], + "types" : [ + { + "accessLevel" : "internal", + "constructor" : { + "accessLevel" : "internal", + "parameters" : [ + { + "name" : "value", + "type" : { + "string" : { + + } + } + } + ] + }, + "getters" : [ + { + "accessLevel" : "internal", + "name" : "value", + "type" : { + "string" : { + + } + } + } + ], + "methods" : [ + + ], + "name" : "Foo", + "setters" : [ + + ], + "staticMethods" : [ + + ] + } + ] + }, + { + "functions" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripVoid", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripNumber", + "parameters" : [ + { + "name" : "v", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripBool", + "parameters" : [ + { + "name" : "v", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripString", + "parameters" : [ + { + "name" : "v", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripJSValue", + "parameters" : [ + { + "name" : "v", + "type" : { + "jsValue" : { + + } + } + } + ], + "returnType" : { + "jsValue" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsThrowOrVoid", + "parameters" : [ + { + "name" : "shouldThrow", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsThrowOrNumber", + "parameters" : [ + { + "name" : "shouldThrow", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsThrowOrBool", + "parameters" : [ + { + "name" : "shouldThrow", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsThrowOrString", + "parameters" : [ { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalStringArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "string" : { + "name" : "shouldThrow", + "type" : { + "bool" : { - } - }, - "_1" : "null" - } - } - } - } } - ], - "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "string" : { + } + } + ], + "returnType" : { + "string" : { - } - }, - "_1" : "null" - } - } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripFeatureFlag", + "parameters" : [ + { + "name" : "flag", + "type" : { + "rawValueEnum" : { + "_0" : "FeatureFlag", + "_1" : "String" } } - }, + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "FeatureFlag", + "_1" : "String" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "runAsyncWorks", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "fetchWeatherData", + "parameters" : [ { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalBoolArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "bool" : { + "name" : "city", + "type" : { + "string" : { - } - }, - "_1" : "null" - } - } - } - } } - ], - "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "bool" : { + } + } + ], + "returnType" : { + "jsObject" : { + "_0" : "WeatherData" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "jsName" : "$jsWeirdFunction", + "name" : "_jsWeirdFunction", + "parameters" : [ + + ], + "returnType" : { + "double" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "from" : "global", + "name" : "parseInt", + "parameters" : [ + { + "name" : "string", + "type" : { + "string" : { - } - }, - "_1" : "null" - } - } } } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalJSValueArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "jsValue" : { + } + ], + "returnType" : { + "double" : { + + } + } + } + ], + "globalGetters" : [ + { + "accessLevel" : "internal", + "from" : "global", + "name" : "globalObject1", + "type" : { + "jsValue" : { + + } + } + } + ], + "types" : [ + { + "accessLevel" : "internal", + "constructor" : { + "accessLevel" : "internal", + "parameters" : [ + { + "name" : "name", + "type" : { + "string" : { - } - }, - "_1" : "null" - } - } - } } } - ], - "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "jsValue" : { + }, + { + "name" : "prefix", + "type" : { + "string" : { - } - }, - "_1" : "null" - } } } } + ] + }, + "getters" : [ + { + "accessLevel" : "internal", + "name" : "name", + "type" : { + "string" : { + + } + } }, + { + "accessLevel" : "internal", + "name" : "prefix", + "type" : { + "string" : { + + } + } + } + ], + "methods" : [ { "accessLevel" : "internal", "effects" : { @@ -23343,38 +27033,13 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripOptionalJSObjectArray", + "name" : "greet", "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "jsObject" : { - } - }, - "_1" : "null" - } - } - } - } - } ], "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "jsObject" : { + "string" : { - } - }, - "_1" : "null" - } - } } } }, @@ -23385,64 +27050,48 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripOptionalJSClassArray", + "name" : "changeName", "parameters" : [ { - "name" : "values", + "name" : "name", "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "jsObject" : { - "_0" : "ArrayElementObject" - } - }, - "_1" : "null" - } - } + "string" : { + } } } ], "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "jsObject" : { - "_0" : "ArrayElementObject" - } - }, - "_1" : "null" - } - } + "void" : { + } } - }, + } + ], + "name" : "JsGreeter", + "setters" : [ { "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsSumNumberArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "double" : { + "functionName" : "name_set", + "name" : "name", + "type" : { + "string" : { - } - } - } - } } - ], - "returnType" : { + } + } + ], + "staticMethods" : [ + + ] + }, + { + "accessLevel" : "internal", + "getters" : [ + { + "accessLevel" : "internal", + "name" : "temperature", + "type" : { "double" : { } @@ -23450,421 +27099,298 @@ }, { "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsCreateNumberArray", - "parameters" : [ - - ], - "returnType" : { - "array" : { - "_0" : { - "double" : { + "name" : "description", + "type" : { + "string" : { - } - } } } }, { "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "runJsArraySupportTests", - "parameters" : [ - - ], - "returnType" : { - "void" : { + "name" : "humidity", + "type" : { + "double" : { } } } - ] - } - ] - }, - { - "functions" : [ - - ], - "types" : [ - { - "accessLevel" : "internal", - "getters" : [ - ], "methods" : [ ], - "name" : "AsyncImportImports", + "name" : "WeatherData", "setters" : [ - - ], - "staticMethods" : [ { "accessLevel" : "internal", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsAsyncRoundTripVoid", - "parameters" : [ - - ], - "returnType" : { - "void" : { + "functionName" : "temperature_set", + "name" : "temperature", + "type" : { + "double" : { } } }, { "accessLevel" : "internal", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsAsyncRoundTripNumber", - "parameters" : [ - { - "name" : "v", - "type" : { - "double" : { + "functionName" : "description_set", + "name" : "description", + "type" : { + "string" : { - } - } } - ], - "returnType" : { + } + }, + { + "accessLevel" : "internal", + "functionName" : "humidity_set", + "name" : "humidity", + "type" : { "double" : { } } - }, + } + ], + "staticMethods" : [ + + ] + }, + { + "accessLevel" : "internal", + "constructor" : { + "accessLevel" : "internal", + "parameters" : [ + + ] + }, + "getters" : [ + + ], + "jsName" : "$WeirdClass", + "methods" : [ { "accessLevel" : "internal", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : true }, - "name" : "jsAsyncRoundTripBool", + "jsName" : "method-with-dashes", + "name" : "method_with_dashes", "parameters" : [ - { - "name" : "v", - "type" : { - "bool" : { - } - } - } ], "returnType" : { - "bool" : { + "string" : { } } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsAsyncRoundTripString", - "parameters" : [ - { - "name" : "v", - "type" : { - "string" : { + } + ], + "name" : "_WeirdClass", + "setters" : [ - } - } - } - ], - "returnType" : { - "string" : { + ], + "staticMethods" : [ + + ] + }, + { + "accessLevel" : "internal", + "constructor" : { + "accessLevel" : "internal", + "parameters" : [ + { + "name" : "value", + "type" : { + "double" : { + } } } - }, + ] + }, + "getters" : [ + + ], + "methods" : [ { "accessLevel" : "internal", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : true }, - "name" : "jsAsyncRoundTripOptionalString", + "name" : "value", "parameters" : [ - { - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "string" : { - } - }, - "_1" : "null" - } - } - } ], "returnType" : { - "nullable" : { - "_0" : { - "string" : { + "double" : { - } - }, - "_1" : "null" } } - }, + } + ], + "name" : "StaticBox", + "setters" : [ + + ], + "staticMethods" : [ { "accessLevel" : "internal", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : true }, - "name" : "jsAsyncRoundTripOptionalNumber", + "name" : "create", "parameters" : [ { - "name" : "v", + "name" : "value", "type" : { - "nullable" : { - "_0" : { - "double" : { + "double" : { - } - }, - "_1" : "null" } } } ], "returnType" : { - "nullable" : { - "_0" : { - "double" : { - - } - }, - "_1" : "null" + "jsObject" : { + "_0" : "StaticBox" } } }, { "accessLevel" : "internal", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : true }, - "name" : "jsAsyncRoundTripBoolArray", + "name" : "value", "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "bool" : { - } - } - } - } - } ], "returnType" : { - "array" : { - "_0" : { - "bool" : { + "double" : { - } - } } } }, { "accessLevel" : "internal", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : true }, - "name" : "jsAsyncRoundTripIntArray", + "name" : "makeDefault", "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "double" : { - } - } - } - } - } ], "returnType" : { - "array" : { - "_0" : { - "double" : { - - } - } + "jsObject" : { + "_0" : "StaticBox" } } }, { "accessLevel" : "internal", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : true }, - "name" : "jsAsyncRoundTripStringArray", + "jsName" : "with-dashes", + "name" : "with_dashes", "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "string" : { - } - } - } - } - } ], "returnType" : { - "array" : { - "_0" : { - "string" : { + "jsObject" : { + "_0" : "StaticBox" + } + } + } + ] + }, + { + "accessLevel" : "internal", + "constructor" : { + "accessLevel" : "internal", + "parameters" : [ + { + "name" : "name", + "type" : { + "string" : { - } } } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true }, - "name" : "jsAsyncRoundTripFeatureFlag", - "parameters" : [ - { - "name" : "v", - "type" : { - "rawValueEnum" : { - "_0" : "FeatureFlag", - "_1" : "String" - } + { + "name" : "age", + "type" : { + "double" : { + } } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "FeatureFlag", - "_1" : "String" + }, + { + "name" : "isCat", + "type" : { + "bool" : { + + } } } - }, + ] + }, + "from" : "global", + "getters" : [ { "accessLevel" : "internal", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsAsyncRoundTripAssociatedValueEnum", - "parameters" : [ - { - "name" : "v", - "type" : { - "associatedValueEnum" : { - "_0" : "AsyncImportedPayloadResult" - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "AsyncImportedPayloadResult" + "name" : "name", + "type" : { + "string" : { + } } }, { "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" + "name" : "age", + "type" : { + "double" : { + } } }, + { + "accessLevel" : "internal", + "name" : "isCat", + "type" : { + "bool" : { + + } + } + } + ], + "methods" : [ { "accessLevel" : "internal", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : true }, - "name" : "jsAsyncThrowSynchronously", + "name" : "bark", "parameters" : [ - { - "name" : "message", - "type" : { - "string" : { - } - } - } ], "returnType" : { - "double" : { + "string" : { } } @@ -23872,178 +27398,261 @@ { "accessLevel" : "internal", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : true }, - "name" : "jsAsyncReturnNonPromise", + "name" : "getIsCat", "parameters" : [ - { - "name" : "v", - "type" : { - "double" : { - } - } - } ], "returnType" : { - "double" : { + "bool" : { } } } - ] - } - ] - }, - { - "functions" : [ - - ], - "types" : [ - { - "accessLevel" : "internal", - "getters" : [ - - ], - "methods" : [ - ], - "name" : "ClosureAsyncImports", + "name" : "Animal", "setters" : [ + { + "accessLevel" : "internal", + "functionName" : "name_set", + "name" : "name", + "type" : { + "string" : { - ], - "staticMethods" : [ + } + } + }, { "accessLevel" : "internal", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "runJsClosureAsyncTests", - "parameters" : [ + "functionName" : "age_set", + "name" : "age", + "type" : { + "double" : { - ], - "returnType" : { - "void" : { + } + } + }, + { + "accessLevel" : "internal", + "functionName" : "isCat_set", + "name" : "isCat", + "type" : { + "bool" : { } } } + ], + "staticMethods" : [ + ] } ] }, { "functions" : [ - - ], - "types" : [ { "accessLevel" : "internal", - "getters" : [ - - ], - "methods" : [ - + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripLightColor", + "parameters" : [ + { + "name" : "value", + "type" : { + "caseEnum" : { + "_0" : "LightColor" + } + } + } ], - "name" : "ClosureSupportImports", - "setters" : [ - + "returnType" : { + "caseEnum" : { + "_0" : "LightColor" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripImportedPayloadSignal", + "parameters" : [ + { + "name" : "value", + "type" : { + "associatedValueEnum" : { + "_0" : "ImportedPayloadSignal" + } + } + } ], - "staticMethods" : [ + "returnType" : { + "associatedValueEnum" : { + "_0" : "ImportedPayloadSignal" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalImportedPayloadSignal", + "parameters" : [ { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true + "name" : "value", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "ImportedPayloadSignal" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "ImportedPayloadSignal" + } }, - "name" : "jsApplyVoid", - "parameters" : [ - { - "name" : "callback", - "type" : { - "closure" : { + "_1" : "null" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsJoinOptionalArrayThenArray", + "parameters" : [ + { + "name" : "a", + "type" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + }, + "_1" : "null" + } + } + }, + { + "name" : "b", + "type" : { + "array" : { + "_0" : { + "integer" : { "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsy_y", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true + "isSigned" : true, + "width" : "word" + } } } } - ], - "returnType" : { - "void" : { + } + } + ], + "returnType" : { + "string" : { + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsJoinOptionalStructThenArray", + "parameters" : [ + { + "name" : "a", + "type" : { + "nullable" : { + "_0" : { + "swiftStruct" : { + "_0" : "Point" + } + }, + "_1" : "null" } } }, { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsApplyBool", - "parameters" : [ - { - "name" : "callback", - "type" : { - "closure" : { + "name" : "b", + "type" : { + "array" : { + "_0" : { + "integer" : { "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsy_Sb", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - - ], - "returnType" : { - "bool" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true + "isSigned" : true, + "width" : "word" + } } } } - ], - "returnType" : { - "bool" : { + } + } + ], + "returnType" : { + "string" : { + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsJoinEnumThenArray", + "parameters" : [ + { + "name" : "a", + "type" : { + "associatedValueEnum" : { + "_0" : "ImportedPayloadSignal" } } }, { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsApplyInt", - "parameters" : [ - { - "name" : "value", - "type" : { + "name" : "b", + "type" : { + "array" : { + "_0" : { "integer" : { "_0" : { "isSigned" : true, @@ -24051,483 +27660,582 @@ } } } - }, - { - "name" : "transform", - "type" : { - "closure" : { + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsJoinStringThenStackParams", + "parameters" : [ + { + "name" : "s", + "type" : { + "string" : { + + } + } + }, + { + "name" : "a", + "type" : { + "nullable" : { + "_0" : { + "array" : { "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSi_Si", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true + } + } } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + }, + "_1" : "null" } } }, { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsApplyDouble", - "parameters" : [ - { - "name" : "value", - "type" : { - "double" : { - - } - } - }, - { - "name" : "transform", - "type" : { - "closure" : { + "name" : "b", + "type" : { + "array" : { + "_0" : { + "integer" : { "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSd_Sd", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "double" : { - - } - } - ], - "returnType" : { - "double" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true + "isSigned" : true, + "width" : "word" + } } } } - ], - "returnType" : { - "double" : { + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsDescribeReservedWordParameters", + "parameters" : [ + { + "name" : "in", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "name" : "for", + "type" : { + "string" : { } } }, { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsApplyString", - "parameters" : [ - { - "name" : "value", - "type" : { - "string" : { + "name" : "default", + "type" : { + "bool" : { - } - } - }, - { - "name" : "transform", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { + } + } + } + ], + "returnType" : { + "string" : { - } - } - ], - "returnType" : { - "string" : { + } + } + } + ], + "types" : [ - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - } + ] + }, + { + "functions" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "genericParameters" : [ + { + "name" : "T" + } + ], + "name" : "jsGenericRoundTrip", + "parameters" : [ + { + "name" : "value", + "type" : { + "generic" : { + "_0" : "T" } - ], - "returnType" : { + } + } + ], + "returnType" : { + "generic" : { + "_0" : "T" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "genericParameters" : [ + { + "name" : "T" + } + ], + "name" : "jsGenericRoundTripClass", + "parameters" : [ + { + "name" : "value", + "type" : { + "generic" : { + "_0" : "T" + } + } + } + ], + "returnType" : { + "generic" : { + "_0" : "T" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "genericParameters" : [ + { + "name" : "T" + } + ], + "name" : "jsGenericParsePoint", + "parameters" : [ + { + "name" : "json", + "type" : { "string" : { } } + } + ], + "returnType" : { + "generic" : { + "_0" : "T" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "genericParameters" : [ + { + "name" : "T" + } + ], + "name" : "jsImportPickFirst", + "parameters" : [ + { + "name" : "a", + "type" : { + "generic" : { + "_0" : "T" + } + } }, { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsApplyJSObject", - "parameters" : [ - { - "name" : "value", - "type" : { - "jsObject" : { - - } - } - }, - { - "name" : "transform", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests8JSObjectC_8JSObjectC", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "jsObject" : { - - } - } - ], - "returnType" : { - "jsObject" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - } + "name" : "b", + "type" : { + "generic" : { + "_0" : "T" } - ], - "returnType" : { - "jsObject" : { + } + } + ], + "returnType" : { + "generic" : { + "_0" : "T" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "genericParameters" : [ + { + "name" : "T" + } + ], + "name" : "jsImportMakeInt", + "parameters" : [ + ], + "returnType" : { + "generic" : { + "_0" : "T" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "genericParameters" : [ + { + "name" : "T" + }, + { + "name" : "U" + } + ], + "name" : "jsImportCombineSecond", + "parameters" : [ + { + "name" : "a", + "type" : { + "generic" : { + "_0" : "T" } } }, { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsApplyArrayInt", - "parameters" : [ - { - "name" : "value", - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - }, - { - "name" : "transform", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSaSi_SaSi", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - } + "name" : "b", + "type" : { + "generic" : { + "_0" : "U" } - ], - "returnType" : { + } + } + ], + "returnType" : { + "generic" : { + "_0" : "U" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "genericParameters" : [ + { + "name" : "T" + } + ], + "name" : "jsGenericArrayRoundTrip", + "parameters" : [ + { + "name" : "values", + "type" : { "array" : { "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "generic" : { + "_0" : "T" } } } } - }, + } + ], + "returnType" : { + "array" : { + "_0" : { + "generic" : { + "_0" : "T" + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "genericParameters" : [ { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsApplyArrayDouble", - "parameters" : [ - { - "name" : "value", - "type" : { - "array" : { - "_0" : { - "double" : { - - } - } - } - } - }, - { - "name" : "transform", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSaSd_SaSd", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "array" : { - "_0" : { - "double" : { - - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "double" : { - - } - } - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true + "name" : "T" + } + ], + "name" : "jsGenericOptionalRoundTrip", + "parameters" : [ + { + "name" : "value", + "type" : { + "nullable" : { + "_0" : { + "generic" : { + "_0" : "T" } - } + }, + "_1" : "null" } - ], - "returnType" : { - "array" : { + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "generic" : { + "_0" : "T" + } + }, + "_1" : "null" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "genericParameters" : [ + { + "name" : "T" + } + ], + "name" : "jsGenericDictRoundTrip", + "parameters" : [ + { + "name" : "values", + "type" : { + "dictionary" : { "_0" : { - "double" : { - + "generic" : { + "_0" : "T" } } } } - }, + } + ], + "returnType" : { + "dictionary" : { + "_0" : { + "generic" : { + "_0" : "T" + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "genericParameters" : [ { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsApplyArrayString", - "parameters" : [ - { - "name" : "value", - "type" : { + "name" : "T" + } + ], + "name" : "jsGenericAfterOptionalArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "nullable" : { + "_0" : { "array" : { "_0" : { - "string" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } - } - }, - { - "name" : "transform", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSaSS_SaSS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "array" : { - "_0" : { - "string" : { + }, + "_1" : "null" + } + } + }, + { + "name" : "value", + "type" : { + "generic" : { + "_0" : "T" + } + } + } + ], + "returnType" : { + "string" : { - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "string" : { + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "genericParameters" : [ + { + "name" : "T" + } + ], + "name" : "jsGenericThrowOrRoundTrip", + "parameters" : [ + { + "name" : "shouldThrow", + "type" : { + "bool" : { - } - } - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - } } + } + }, + { + "name" : "value", + "type" : { + "generic" : { + "_0" : "T" + } + } + } + ], + "returnType" : { + "generic" : { + "_0" : "T" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "genericParameters" : [ + { + "constraints" : [ + "GenericRTNode" ], - "returnType" : { - "array" : { - "_0" : { - "string" : { - - } - } + "name" : "T" + } + ], + "name" : "jsGenericNodeRoundTrip", + "parameters" : [ + { + "name" : "value", + "type" : { + "generic" : { + "_0" : "T" } } - }, + } + ], + "returnType" : { + "generic" : { + "_0" : "T" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "genericParameters" : [ { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsApplyArrayJSValue", - "parameters" : [ - { - "name" : "value", - "type" : { - "array" : { - "_0" : { - "jsValue" : { - - } - } - } - } - }, - { - "name" : "transform", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSa7JSValueV_Sa7JSValueV", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "array" : { - "_0" : { - "jsValue" : { + "constraints" : [ + "GenericRTPosition", + "GenericRTNode" + ], + "name" : "T" + } + ], + "name" : "jsGenericMakeNode", + "parameters" : [ - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "jsValue" : { + ], + "returnType" : { + "generic" : { + "_0" : "T" + } + } + } + ], + "types" : [ + { + "accessLevel" : "internal", + "constructor" : { + "accessLevel" : "internal", + "parameters" : [ - } - } - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "jsValue" : { + ] + }, + "getters" : [ - } - } - } - } - }, + ], + "methods" : [ { "accessLevel" : "internal", "effects" : { @@ -24535,66 +28243,34 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsApplyArrayJSObject", + "genericParameters" : [ + { + "name" : "T" + } + ], + "name" : "identity", "parameters" : [ { "name" : "value", "type" : { - "array" : { - "_0" : { - "jsObject" : { - - } - } - } - } - }, - { - "name" : "transform", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSa8JSObjectC_Sa8JSObjectC", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "array" : { - "_0" : { - "jsObject" : { - - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "jsObject" : { - - } - } - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true + "generic" : { + "_0" : "T" } } } ], "returnType" : { - "array" : { - "_0" : { - "jsObject" : { - - } - } + "generic" : { + "_0" : "T" } } - }, + } + ], + "name" : "ImportGenericConsumer", + "setters" : [ + + ], + "staticMethods" : [ { "accessLevel" : "internal", "effects" : { @@ -24602,51 +28278,54 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsMakeIntToInt", + "genericParameters" : [ + { + "name" : "T" + } + ], + "name" : "box", "parameters" : [ { - "name" : "base", + "name" : "value", "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "generic" : { + "_0" : "T" } } } ], "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSi_Si", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false + "generic" : { + "_0" : "T" } } - }, + } + ] + }, + { + "accessLevel" : "internal", + "constructor" : { + "accessLevel" : "internal", + "genericParameters" : [ + { + "name" : "T" + } + ], + "parameters" : [ + { + "name" : "value", + "type" : { + "generic" : { + "_0" : "T" + } + } + } + ] + }, + "getters" : [ + + ], + "methods" : [ { "accessLevel" : "internal", "effects" : { @@ -24654,42 +28333,137 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsMakeDoubleToDouble", - "parameters" : [ + "genericParameters" : [ { - "name" : "base", - "type" : { - "double" : { - - } - } + "name" : "T" } + ], + "name" : "unwrap", + "parameters" : [ + ], "returnType" : { - "closure" : { + "generic" : { + "_0" : "T" + } + } + } + ], + "name" : "ImportGenericBoxed", + "setters" : [ + + ], + "staticMethods" : [ + + ] + } + ] + }, + { + "functions" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsTranslatePoint", + "parameters" : [ + { + "name" : "point", + "type" : { + "swiftStruct" : { + "_0" : "Point" + } + } + }, + { + "name" : "dx", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "name" : "dy", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "Point" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalPoint", + "parameters" : [ + { + "name" : "point", + "type" : { + "nullable" : { "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSd_Sd", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "double" : { - - } - } - ], - "returnType" : { - "double" : { - - } - }, - "sendingParameters" : false + "swiftStruct" : { + "_0" : "Point" + } }, - "useJSTypedClosure" : false + "_1" : "null" } } - }, + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "swiftStruct" : { + "_0" : "Point" + } + }, + "_1" : "null" + } + } + } + ], + "types" : [ + + ] + }, + { + "functions" : [ + + ], + "types" : [ + { + "accessLevel" : "internal", + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "IntegerTypesSupportImports", + "setters" : [ + + ], + "staticMethods" : [ { "accessLevel" : "internal", "effects" : { @@ -24697,39 +28471,26 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsMakeStringToString", + "name" : "jsRoundTripInt", "parameters" : [ { - "name" : "prefix", + "name" : "v", "type" : { - "string" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } ], "returnType" : { - "closure" : { + "integer" : { "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false + "isSigned" : true, + "width" : "word" + } } } }, @@ -24740,54 +28501,24 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsCallTwice", + "name" : "jsRoundTripUInt", "parameters" : [ { - "name" : "value", + "name" : "v", "type" : { "integer" : { "_0" : { - "isSigned" : true, + "isSigned" : false, "width" : "word" } } } - }, - { - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSi_y", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - ], - "returnType" : { - "void" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - } } ], "returnType" : { "integer" : { "_0" : { - "isSigned" : true, + "isSigned" : false, "width" : "word" } } @@ -24800,46 +28531,16 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsCallBinary", + "name" : "jsRoundTripInt8", "parameters" : [ { - "name" : "callback", + "name" : "v", "type" : { - "closure" : { + "integer" : { "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSiSi_Si", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true + "isSigned" : true, + "width" : "w8" + } } } } @@ -24848,7 +28549,7 @@ "integer" : { "_0" : { "isSigned" : true, - "width" : "word" + "width" : "w8" } } } @@ -24860,54 +28561,16 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsCallTriple", + "name" : "jsRoundTripUInt8", "parameters" : [ { - "name" : "callback", + "name" : "v", "type" : { - "closure" : { + "integer" : { "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSiSiSi_Si", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true + "isSigned" : false, + "width" : "w8" + } } } } @@ -24915,8 +28578,8 @@ "returnType" : { "integer" : { "_0" : { - "isSigned" : true, - "width" : "word" + "isSigned" : false, + "width" : "w8" } } } @@ -24928,35 +28591,26 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsCallAfterRelease", + "name" : "jsRoundTripInt16", "parameters" : [ { - "name" : "callback", + "name" : "v", "type" : { - "closure" : { + "integer" : { "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsy_y", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true + "isSigned" : true, + "width" : "w16" + } } } } ], "returnType" : { - "string" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "w16" + } } } }, @@ -24967,40 +28621,26 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsOptionalInvoke", + "name" : "jsRoundTripUInt16", "parameters" : [ { - "name" : "callback", + "name" : "v", "type" : { - "nullable" : { + "integer" : { "_0" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsy_Sb", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - - ], - "returnType" : { - "bool" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - }, - "_1" : "null" + "isSigned" : false, + "width" : "w16" + } } } } ], "returnType" : { - "bool" : { - + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "w16" + } } } }, @@ -25011,35 +28651,26 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsStoreClosure", + "name" : "jsRoundTripInt32", "parameters" : [ { - "name" : "callback", + "name" : "v", "type" : { - "closure" : { + "integer" : { "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsy_y", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true + "isSigned" : true, + "width" : "w32" + } } } } ], "returnType" : { - "void" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "w32" + } } } }, @@ -25050,13 +28681,26 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsCallStoredClosure", + "name" : "jsRoundTripUInt32", "parameters" : [ - + { + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "w32" + } + } + } + } ], "returnType" : { - "void" : { - + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "w32" + } } } }, @@ -25067,15 +28711,25 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsHeapCount", + "name" : "jsRoundTripInt64", "parameters" : [ - + { + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "w64" + } + } + } + } ], "returnType" : { "integer" : { "_0" : { "isSigned" : true, - "width" : "word" + "width" : "w64" } } } @@ -25087,38 +28741,29 @@ "isStatic" : false, "isThrows" : true }, - "name" : "runJsClosureSupportTests", + "name" : "jsRoundTripUInt64", "parameters" : [ - + { + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "w64" + } + } + } + } ], "returnType" : { - "void" : { - + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "w64" + } } } - } - ] - } - ] - }, - { - "functions" : [ - - ], - "types" : [ - { - "accessLevel" : "internal", - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "ClosureThrowsImports", - "setters" : [ - - ], - "staticMethods" : [ + }, { "accessLevel" : "internal", "effects" : { @@ -25126,7 +28771,7 @@ "isStatic" : false, "isThrows" : true }, - "name" : "runJsClosureThrowsTests", + "name" : "runJsIntegerTypesSupportTests", "parameters" : [ ], @@ -25147,56 +28792,70 @@ "types" : [ { "accessLevel" : "internal", - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "DefaultArgumentImports", - "setters" : [ - - ], - "staticMethods" : [ - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true + "constructor" : { + "accessLevel" : "internal", + "parameters" : [ + { + "name" : "numbers", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } }, - "name" : "runJsDefaultArgumentTests", - "parameters" : [ - - ], - "returnType" : { - "void" : { + { + "name" : "labels", + "type" : { + "array" : { + "_0" : { + "string" : { + } + } + } } } - } - ] - } - ] - }, - { - "functions" : [ - - ], - "types" : [ - { - "accessLevel" : "internal", + ] + }, "getters" : [ + { + "accessLevel" : "internal", + "name" : "numbers", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + }, + { + "accessLevel" : "internal", + "name" : "labels", + "type" : { + "array" : { + "_0" : { + "string" : { + } + } + } + } + } ], - "methods" : [ - - ], - "name" : "DictionarySupportImports", - "setters" : [ - - ], - "staticMethods" : [ + "methods" : [ { "accessLevel" : "internal", "effects" : { @@ -25204,12 +28863,12 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripDictionaryInt", + "name" : "concatNumbers", "parameters" : [ { "name" : "values", "type" : { - "dictionary" : { + "array" : { "_0" : { "integer" : { "_0" : { @@ -25223,7 +28882,7 @@ } ], "returnType" : { - "dictionary" : { + "array" : { "_0" : { "integer" : { "_0" : { @@ -25242,14 +28901,14 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripDictionaryBool", + "name" : "concatLabels", "parameters" : [ { "name" : "values", "type" : { - "dictionary" : { + "array" : { "_0" : { - "bool" : { + "string" : { } } @@ -25258,9 +28917,9 @@ } ], "returnType" : { - "dictionary" : { + "array" : { "_0" : { - "bool" : { + "string" : { } } @@ -25274,14 +28933,14 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripDictionaryDouble", + "name" : "firstLabel", "parameters" : [ { "name" : "values", "type" : { - "dictionary" : { + "array" : { "_0" : { - "double" : { + "string" : { } } @@ -25290,79 +28949,63 @@ } ], "returnType" : { - "dictionary" : { - "_0" : { - "double" : { + "string" : { - } - } } } - }, + } + ], + "name" : "JSClassWithArrayMembers", + "setters" : [ { "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripDictionaryJSObject", - "parameters" : [ - { - "name" : "values", - "type" : { - "dictionary" : { + "functionName" : "numbers_set", + "name" : "numbers", + "type" : { + "array" : { + "_0" : { + "integer" : { "_0" : { - "jsObject" : { - - } + "isSigned" : true, + "width" : "word" } } } } - ], - "returnType" : { - "dictionary" : { - "_0" : { - "jsObject" : { - - } - } - } } }, { "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripDictionaryJSValue", - "parameters" : [ - { - "name" : "values", - "type" : { - "dictionary" : { - "_0" : { - "jsValue" : { - - } - } - } - } - } - ], - "returnType" : { - "dictionary" : { + "functionName" : "labels_set", + "name" : "labels", + "type" : { + "array" : { "_0" : { - "jsValue" : { + "string" : { } } } } - }, + } + ], + "staticMethods" : [ + + ] + }, + { + "accessLevel" : "internal", + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "JSClassSupportImports", + "setters" : [ + + ], + "staticMethods" : [ { "accessLevel" : "internal", "effects" : { @@ -25370,154 +29013,48 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripDictionaryDoubleArray", + "name" : "makeJSClassWithArrayMembers", "parameters" : [ { - "name" : "values", + "name" : "numbers", "type" : { - "dictionary" : { + "array" : { "_0" : { - "array" : { + "integer" : { "_0" : { - "double" : { - - } + "isSigned" : true, + "width" : "word" } } } } } - } - ], - "returnType" : { - "dictionary" : { - "_0" : { + }, + { + "name" : "labels", + "type" : { "array" : { "_0" : { - "double" : { + "string" : { } } } } } - } - } - ] - } - ] - }, - { - "functions" : [ - - ], - "types" : [ - { - "accessLevel" : "internal", - "constructor" : { - "accessLevel" : "internal", - "parameters" : [ - { - "name" : "value", - "type" : { - "string" : { - - } - } - } - ] - }, - "getters" : [ - { - "accessLevel" : "internal", - "name" : "value", - "type" : { - "string" : { - - } - } - } - ], - "methods" : [ - - ], - "name" : "Foo", - "setters" : [ - - ], - "staticMethods" : [ - - ] - } - ] - }, - { - "functions" : [ - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripVoid", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripNumber", - "parameters" : [ - { - "name" : "v", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "double" : { - - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripBool", - "parameters" : [ - { - "name" : "v", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "bool" : { - + ], + "returnType" : { + "jsObject" : { + "_0" : "JSClassWithArrayMembers" + } + } } - } - }, + ] + } + ] + }, + { + "functions" : [ { "accessLevel" : "internal", "effects" : { @@ -25525,10 +29062,15 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripString", + "from" : { + "kind" : "module", + "specifier" : "node:path" + }, + "jsName" : "basename", + "name" : "nodeBasename", "parameters" : [ { - "name" : "v", + "name" : "path", "type" : { "string" : { @@ -25549,119 +29091,103 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripJSValue", + "from" : { + "kind" : "module", + "specifier" : "node:path" + }, + "jsName" : "join", + "name" : "nodeJoin", "parameters" : [ { - "name" : "v", + "name" : "lhs", "type" : { - "jsValue" : { + "string" : { } } - } - ], - "returnType" : { - "jsValue" : { - - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsThrowOrVoid", - "parameters" : [ + }, { - "name" : "shouldThrow", + "name" : "rhs", "type" : { - "bool" : { + "string" : { } } } ], "returnType" : { - "void" : { + "string" : { } } - }, + } + ], + "globalGetters" : [ { "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true + "from" : { + "kind" : "snippet", + "path" : "\/Modules\/DefaultExport.mjs" }, - "name" : "jsThrowOrNumber", - "parameters" : [ - { - "name" : "shouldThrow", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "double" : { + "jsName" : "default", + "name" : "defaultExport", + "type" : { + "jsObject" : { } } - }, + } + ], + "types" : [ { "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsThrowOrBool", - "parameters" : [ - { - "name" : "shouldThrow", - "type" : { - "bool" : { + "constructor" : { + "accessLevel" : "internal", + "parameters" : [ + { + "name" : "data", + "type" : { + "jsObject" : { + } } } - } - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true + ] }, - "name" : "jsThrowOrString", - "parameters" : [ + "from" : { + "kind" : "module", + "specifier" : "@bjorn3\/browser_wasi_shim" + }, + "getters" : [ { - "name" : "shouldThrow", + "accessLevel" : "internal", + "name" : "size", "type" : { - "bool" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "w64" + } } } } ], - "returnType" : { - "string" : { + "jsName" : "File", + "methods" : [ - } - } - }, + ], + "name" : "WasiFile", + "setters" : [ + + ], + "staticMethods" : [ + + ] + } + ] + }, + { + "functions" : [ { "accessLevel" : "internal", "effects" : { @@ -25669,63 +29195,41 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripFeatureFlag", + "from" : { + "kind" : "snippet", + "path" : "\/Modules\/JSImportModule.mjs" + }, + "name" : "moduleAdd", "parameters" : [ { - "name" : "flag", + "name" : "lhs", "type" : { - "rawValueEnum" : { - "_0" : "FeatureFlag", - "_1" : "String" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "FeatureFlag", - "_1" : "String" - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "runAsyncWorks", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "fetchWeatherData", - "parameters" : [ + }, { - "name" : "city", + "name" : "rhs", "type" : { - "string" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } ], "returnType" : { - "jsObject" : { - "_0" : "WeatherData" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } }, @@ -25736,13 +29240,17 @@ "isStatic" : false, "isThrows" : true }, - "jsName" : "$jsWeirdFunction", - "name" : "_jsWeirdFunction", + "from" : { + "kind" : "snippet", + "path" : "\/Modules\/JSImportModule.mjs" + }, + "jsName" : "renamedFunction", + "name" : "moduleRenamed", "parameters" : [ ], "returnType" : { - "double" : { + "string" : { } } @@ -25754,20 +29262,16 @@ "isStatic" : false, "isThrows" : true }, - "from" : "global", - "name" : "parseInt", + "from" : { + "kind" : "snippet", + "path" : "\/Modules\/JSImportModule.mjs" + }, + "name" : "moduleThrow", "parameters" : [ - { - "name" : "string", - "type" : { - "string" : { - } - } - } ], "returnType" : { - "double" : { + "void" : { } } @@ -25775,11 +29279,15 @@ ], "globalGetters" : [ { - "accessLevel" : "internal", - "from" : "global", - "name" : "globalObject1", + "accessLevel" : "internal", + "from" : { + "kind" : "snippet", + "path" : "\/Modules\/JSImportModule.mjs" + }, + "jsName" : "version", + "name" : "moduleVersion", "type" : { - "jsValue" : { + "string" : { } } @@ -25792,39 +29300,32 @@ "accessLevel" : "internal", "parameters" : [ { - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "name" : "prefix", + "name" : "value", "type" : { - "string" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } ] }, + "from" : { + "kind" : "snippet", + "path" : "\/Modules\/ModuleCounter.mjs" + }, "getters" : [ { "accessLevel" : "internal", - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "accessLevel" : "internal", - "name" : "prefix", + "name" : "value", "type" : { - "string" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } @@ -25837,16 +29338,37 @@ "isStatic" : false, "isThrows" : true }, - "name" : "greet", + "name" : "increment", "parameters" : [ ], "returnType" : { - "string" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } - }, + } + ], + "name" : "ModuleCounter", + "setters" : [ + { + "accessLevel" : "internal", + "functionName" : "value_set", + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "staticMethods" : [ { "accessLevel" : "internal", "effects" : { @@ -25854,125 +29376,48 @@ "isStatic" : false, "isThrows" : true }, - "name" : "changeName", + "name" : "create", "parameters" : [ { - "name" : "name", + "name" : "value", "type" : { - "string" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } ], "returnType" : { - "void" : { - - } - } - } - ], - "name" : "JsGreeter", - "setters" : [ - { - "accessLevel" : "internal", - "functionName" : "name_set", - "name" : "name", - "type" : { - "string" : { - + "jsObject" : { + "_0" : "ModuleCounter" } } } - ], - "staticMethods" : [ - ] - }, + } + ] + }, + { + "functions" : [ + + ], + "types" : [ { "accessLevel" : "internal", "getters" : [ - { - "accessLevel" : "internal", - "name" : "temperature", - "type" : { - "double" : { - - } - } - }, - { - "accessLevel" : "internal", - "name" : "description", - "type" : { - "string" : { - - } - } - }, - { - "accessLevel" : "internal", - "name" : "humidity", - "type" : { - "double" : { - } - } - } ], "methods" : [ ], - "name" : "WeatherData", + "name" : "JSTypedArrayImports", "setters" : [ - { - "accessLevel" : "internal", - "functionName" : "temperature_set", - "name" : "temperature", - "type" : { - "double" : { - - } - } - }, - { - "accessLevel" : "internal", - "functionName" : "description_set", - "name" : "description", - "type" : { - "string" : { - - } - } - }, - { - "accessLevel" : "internal", - "functionName" : "humidity_set", - "name" : "humidity", - "type" : { - "double" : { - } - } - } ], "staticMethods" : [ - - ] - }, - { - "accessLevel" : "internal", - "constructor" : { - "accessLevel" : "internal", - "parameters" : [ - - ] - }, - "getters" : [ - - ], - "jsName" : "$WeirdClass", - "methods" : [ { "accessLevel" : "internal", "effects" : { @@ -25980,45 +29425,16 @@ "isStatic" : false, "isThrows" : true }, - "jsName" : "method-with-dashes", - "name" : "method_with_dashes", + "name" : "jsCreateUint8Array", "parameters" : [ ], "returnType" : { - "string" : { - - } - } - } - ], - "name" : "_WeirdClass", - "setters" : [ - - ], - "staticMethods" : [ - - ] - }, - { - "accessLevel" : "internal", - "constructor" : { - "accessLevel" : "internal", - "parameters" : [ - { - "name" : "value", - "type" : { - "double" : { - - } + "jsObject" : { + "_0" : "JSUint8Array" } } - ] - }, - "getters" : [ - - ], - "methods" : [ + }, { "accessLevel" : "internal", "effects" : { @@ -26026,22 +29442,23 @@ "isStatic" : false, "isThrows" : true }, - "name" : "value", + "name" : "jsRoundTripUint8Array", "parameters" : [ - + { + "name" : "v", + "type" : { + "jsObject" : { + "_0" : "JSUint8Array" + } + } + } ], "returnType" : { - "double" : { - + "jsObject" : { + "_0" : "JSUint8Array" } } - } - ], - "name" : "StaticBox", - "setters" : [ - - ], - "staticMethods" : [ + }, { "accessLevel" : "internal", "effects" : { @@ -26049,20 +29466,20 @@ "isStatic" : false, "isThrows" : true }, - "name" : "create", + "name" : "jsRoundTripFloat32Array", "parameters" : [ { - "name" : "value", + "name" : "v", "type" : { - "double" : { - + "jsObject" : { + "_0" : "JSFloat32Array" } } } ], "returnType" : { "jsObject" : { - "_0" : "StaticBox" + "_0" : "JSFloat32Array" } } }, @@ -26073,13 +29490,20 @@ "isStatic" : false, "isThrows" : true }, - "name" : "value", + "name" : "jsRoundTripFloat64Array", "parameters" : [ - + { + "name" : "v", + "type" : { + "jsObject" : { + "_0" : "JSFloat64Array" + } + } + } ], "returnType" : { - "double" : { - + "jsObject" : { + "_0" : "JSFloat64Array" } } }, @@ -26090,13 +29514,20 @@ "isStatic" : false, "isThrows" : true }, - "name" : "makeDefault", + "name" : "jsRoundTripInt32Array", "parameters" : [ - + { + "name" : "v", + "type" : { + "jsObject" : { + "_0" : "JSInt32Array" + } + } + } ], "returnType" : { "jsObject" : { - "_0" : "StaticBox" + "_0" : "JSInt32Array" } } }, @@ -26107,148 +29538,89 @@ "isStatic" : false, "isThrows" : true }, - "jsName" : "with-dashes", - "name" : "with_dashes", + "name" : "runJsTypedArrayTests", "parameters" : [ ], "returnType" : { - "jsObject" : { - "_0" : "StaticBox" + "void" : { + } } } ] - }, + } + ] + }, + { + "functions" : [ + + ], + "types" : [ { "accessLevel" : "internal", "constructor" : { "accessLevel" : "internal", "parameters" : [ - { - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "name" : "age", - "type" : { - "double" : { - - } - } - }, - { - "name" : "isCat", - "type" : { - "bool" : { - } - } - } ] }, "from" : "global", "getters" : [ - { - "accessLevel" : "internal", - "name" : "name", - "type" : { - "string" : { - } - } - }, - { - "accessLevel" : "internal", - "name" : "age", - "type" : { - "double" : { + ], + "methods" : [ - } - } - }, - { - "accessLevel" : "internal", - "name" : "isCat", - "type" : { - "bool" : { + ], + "name" : "MyJSClassInternal", + "setters" : [ - } - } - } ], - "methods" : [ - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "bark", - "parameters" : [ + "staticMethods" : [ - ], - "returnType" : { - "string" : { + ] + }, + { + "accessLevel" : "public", + "constructor" : { + "accessLevel" : "public", + "parameters" : [ - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "getIsCat", - "parameters" : [ + ] + }, + "from" : "global", + "getters" : [ - ], - "returnType" : { - "bool" : { + ], + "methods" : [ - } - } - } ], - "name" : "Animal", + "name" : "MyJSClassPublic", "setters" : [ - { - "accessLevel" : "internal", - "functionName" : "name_set", - "name" : "name", - "type" : { - "string" : { - } - } - }, - { - "accessLevel" : "internal", - "functionName" : "age_set", - "name" : "age", - "type" : { - "double" : { + ], + "staticMethods" : [ - } - } - }, - { - "accessLevel" : "internal", - "functionName" : "isCat_set", - "name" : "isCat", - "type" : { - "bool" : { + ] + }, + { + "accessLevel" : "package", + "constructor" : { + "accessLevel" : "package", + "parameters" : [ + + ] + }, + "from" : "global", + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "MyJSClassPackage", + "setters" : [ - } - } - } ], "staticMethods" : [ @@ -26259,26 +29631,36 @@ { "functions" : [ { - "accessLevel" : "internal", + "accessLevel" : "package", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripLightColor", + "name" : "jsFunctionWithPackageAccess", "parameters" : [ - { - "name" : "value", - "type" : { - "caseEnum" : { - "_0" : "LightColor" - } - } + + ], + "returnType" : { + "void" : { + } + } + }, + { + "accessLevel" : "public", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsFunctionWithPublicAccess", + "parameters" : [ + ], "returnType" : { - "caseEnum" : { - "_0" : "LightColor" + "void" : { + } } }, @@ -26289,20 +29671,30 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripImportedPayloadSignal", + "name" : "jsFunctionWithInternalAccess", "parameters" : [ - { - "name" : "value", - "type" : { - "associatedValueEnum" : { - "_0" : "ImportedPayloadSignal" - } - } - } + ], "returnType" : { - "associatedValueEnum" : { - "_0" : "ImportedPayloadSignal" + "void" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsFunctionWithFilePrivateAccess", + "parameters" : [ + + ], + "returnType" : { + "void" : { + } } }, @@ -26313,33 +29705,23 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripOptionalImportedPayloadSignal", + "name" : "jsFunctionWithPrivateAccess", "parameters" : [ - { - "name" : "value", - "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "ImportedPayloadSignal" - } - }, - "_1" : "null" - } - } - } + ], "returnType" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "ImportedPayloadSignal" - } - }, - "_1" : "null" + "void" : { + } } - }, + } + ], + "types" : [ + + ] + }, + { + "functions" : [ { "accessLevel" : "internal", "effects" : { @@ -26347,47 +29729,23 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsJoinOptionalArrayThenArray", + "name" : "noncopyableMakeObject", "parameters" : [ { - "name" : "a", - "type" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - }, - "_1" : "null" - } - } - }, - { - "name" : "b", + "name" : "start", "type" : { - "array" : { + "integer" : { "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } + "isSigned" : true, + "width" : "word" } } } } ], "returnType" : { - "string" : { - + "jsUniqueObject" : { + "_0" : "NoncopyableObject" } } }, @@ -26398,65 +29756,102 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsJoinOptionalStructThenArray", + "name" : "noncopyableUseObject", "parameters" : [ { - "name" : "a", - "type" : { - "nullable" : { - "_0" : { - "swiftStruct" : { - "_0" : "Point" - } - }, - "_1" : "null" - } - } - }, - { - "name" : "b", + "name" : "object", "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } + "jsUniqueObject" : { + "_0" : "NoncopyableObject" } } } ], "returnType" : { - "string" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } - }, + } + ], + "globalGetters" : [ { "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true + "from" : "global", + "jsName" : "noncopyableSharedObject", + "name" : "noncopyableSharedObject", + "type" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + ], + "types" : [ + { + "accessLevel" : "internal", + "constructor" : { + "accessLevel" : "internal", + "parameters" : [ + { + "name" : "start", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] }, - "name" : "jsJoinEnumThenArray", - "parameters" : [ + "getters" : [ + + ], + "isNoncopyable" : true, + "methods" : [ { - "name" : "a", - "type" : { - "associatedValueEnum" : { - "_0" : "ImportedPayloadSignal" + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "value", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } - }, + } + ], + "name" : "NoncopyableObject", + "setters" : [ + + ], + "staticMethods" : [ { - "name" : "b", - "type" : { - "array" : { - "_0" : { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "create", + "parameters" : [ + { + "name" : "start", + "type" : { "integer" : { "_0" : { "isSigned" : true, @@ -26465,57 +29860,111 @@ } } } + ], + "returnType" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } } } + ] + }, + { + "accessLevel" : "internal", + "getters" : [ + ], - "returnType" : { - "string" : { + "isNoncopyable" : true, + "methods" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "value", + "parameters" : [ + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } } - } + ], + "name" : "NoncopyableObjectView", + "setters" : [ + + ], + "staticMethods" : [ + + ] }, { "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true + "constructor" : { + "accessLevel" : "internal", + "parameters" : [ + + ] }, - "name" : "jsJoinStringThenStackParams", - "parameters" : [ + "getters" : [ { - "name" : "s", + "accessLevel" : "internal", + "name" : "child", "type" : { - "string" : { - + "jsUniqueObject" : { + "_0" : "NoncopyableObject" } } - }, + } + ], + "isNoncopyable" : true, + "methods" : [ { - "name" : "a", - "type" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "take", + "parameters" : [ + { + "name" : "object", + "type" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" } - }, - "_1" : "null" + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } }, { - "name" : "b", - "type" : { - "array" : { - "_0" : { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "make", + "parameters" : [ + { + "name" : "start", + "type" : { "integer" : { "_0" : { "isSigned" : true, @@ -26524,27 +29973,32 @@ } } } + ], + "returnType" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsDescribeReservedWordParameters", - "parameters" : [ + }, { - "name" : "in", - "type" : { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "adopt", + "parameters" : [ + { + "name" : "object", + "type" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + ], + "returnType" : { "integer" : { "_0" : { "isSigned" : true, @@ -26554,582 +30008,509 @@ } }, { - "name" : "for", - "type" : { - "string" : { - + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "takeCopyable", + "parameters" : [ + { + "name" : "copyable", + "type" : { + "jsObject" : { + "_0" : "CopyableObjectRoundtrip" + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } }, { - "name" : "default", - "type" : { - "bool" : { - + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "makeCopyable", + "parameters" : [ + { + "name" : "start", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } } - } - } - ], - "returnType" : { - "string" : { - - } - } - } - ], - "types" : [ - - ] - }, - { - "functions" : [ - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "genericParameters" : [ - { - "name" : "T" - } - ], - "name" : "jsGenericRoundTrip", - "parameters" : [ - { - "name" : "value", - "type" : { - "generic" : { - "_0" : "T" + ], + "returnType" : { + "jsObject" : { + "_0" : "CopyableObjectRoundtrip" } } - } - ], - "returnType" : { - "generic" : { - "_0" : "T" - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "genericParameters" : [ - { - "name" : "T" - } - ], - "name" : "jsGenericRoundTripClass", - "parameters" : [ + }, { - "name" : "value", - "type" : { - "generic" : { - "_0" : "T" + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "failTake", + "parameters" : [ + { + "name" : "object", + "type" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } } - } - } - ], - "returnType" : { - "generic" : { - "_0" : "T" - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "genericParameters" : [ - { - "name" : "T" - } - ], - "name" : "jsGenericParsePoint", - "parameters" : [ - { - "name" : "json", - "type" : { - "string" : { - + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } - } - ], - "returnType" : { - "generic" : { - "_0" : "T" - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "genericParameters" : [ - { - "name" : "T" - } - ], - "name" : "jsImportPickFirst", - "parameters" : [ + }, { - "name" : "a", - "type" : { - "generic" : { - "_0" : "T" + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "failMake", + "parameters" : [ + + ], + "returnType" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" } } - }, + } + ], + "name" : "NoncopyableObjectRoundtrip", + "setters" : [ { - "name" : "b", + "accessLevel" : "internal", + "functionName" : "child_set", + "name" : "child", "type" : { - "generic" : { - "_0" : "T" + "jsUniqueObject" : { + "_0" : "NoncopyableObject" } } } ], - "returnType" : { - "generic" : { - "_0" : "T" - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "genericParameters" : [ - { - "name" : "T" - } - ], - "name" : "jsImportMakeInt", - "parameters" : [ + "staticMethods" : [ - ], - "returnType" : { - "generic" : { - "_0" : "T" - } - } + ] }, { "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "genericParameters" : [ - { - "name" : "T" - }, - { - "name" : "U" - } + "getters" : [ + ], - "name" : "jsImportCombineSecond", - "parameters" : [ + "methods" : [ { - "name" : "a", - "type" : { - "generic" : { - "_0" : "T" + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "value", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } }, { - "name" : "b", - "type" : { - "generic" : { - "_0" : "U" + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "take", + "parameters" : [ + { + "name" : "object", + "type" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } - } - ], - "returnType" : { - "generic" : { - "_0" : "U" - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "genericParameters" : [ - { - "name" : "T" - } - ], - "name" : "jsGenericArrayRoundTrip", - "parameters" : [ + }, { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "generic" : { - "_0" : "T" + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "make", + "parameters" : [ + { + "name" : "start", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "generic" : { - "_0" : "T" + ], + "returnType" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" } } } - } + ], + "name" : "CopyableObjectRoundtrip", + "setters" : [ + + ], + "staticMethods" : [ + + ] }, { "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true + "constructor" : { + "accessLevel" : "internal", + "parameters" : [ + + ] }, - "genericParameters" : [ - { - "name" : "T" - } - ], - "name" : "jsGenericOptionalRoundTrip", - "parameters" : [ + "getters" : [ { - "name" : "value", + "accessLevel" : "internal", + "name" : "optionalChild", "type" : { "nullable" : { "_0" : { - "generic" : { - "_0" : "T" + "jsUniqueObject" : { + "_0" : "NoncopyableObject" } }, "_1" : "null" } } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "generic" : { - "_0" : "T" - } - }, - "_1" : "null" - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "genericParameters" : [ + }, { - "name" : "T" + "accessLevel" : "internal", + "name" : "children", + "type" : { + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + } } ], - "name" : "jsGenericDictRoundTrip", - "parameters" : [ + "isNoncopyable" : true, + "methods" : [ { - "name" : "values", - "type" : { - "dictionary" : { - "_0" : { - "generic" : { - "_0" : "T" + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "forEachObject", + "parameters" : [ + { + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "name" : "body", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests17NoncopyableObjectV_y", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + ], + "returnType" : { + "void" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true } } } - } - } - ], - "returnType" : { - "dictionary" : { - "_0" : { - "generic" : { - "_0" : "T" + ], + "returnType" : { + "void" : { + } } - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "genericParameters" : [ - { - "name" : "T" - } - ], - "name" : "jsGenericAfterOptionalArray", - "parameters" : [ + }, { - "name" : "values", - "type" : { - "nullable" : { - "_0" : { - "array" : { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "forEachObjectEscaping", + "parameters" : [ + { + "name" : "count", + "type" : { + "integer" : { "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } + "isSigned" : true, + "width" : "word" } } - }, - "_1" : "null" + } + }, + { + "name" : "body", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests17NoncopyableObjectV_y", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + ], + "returnType" : { + "void" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "void" : { + } } }, { - "name" : "value", - "type" : { - "generic" : { - "_0" : "T" - } - } - } - ], - "returnType" : { - "string" : { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "forEachCopyableEscaping", + "parameters" : [ + { + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "name" : "body", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests23CopyableObjectRoundtripC_y", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "jsObject" : { + "_0" : "CopyableObjectRoundtrip" + } + } + ], + "returnType" : { + "void" : { - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "genericParameters" : [ - { - "name" : "T" - } - ], - "name" : "jsGenericThrowOrRoundTrip", - "parameters" : [ - { - "name" : "shouldThrow", - "type" : { - "bool" : { + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "void" : { } } }, { - "name" : "value", - "type" : { - "generic" : { - "_0" : "T" + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "load", + "parameters" : [ + { + "name" : "start", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } } - } - } - ], - "returnType" : { - "generic" : { - "_0" : "T" - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "genericParameters" : [ - { - "constraints" : [ - "GenericRTNode" ], - "name" : "T" - } - ], - "name" : "jsGenericNodeRoundTrip", - "parameters" : [ - { - "name" : "value", - "type" : { - "generic" : { - "_0" : "T" + "returnType" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" } } - } - ], - "returnType" : { - "generic" : { - "_0" : "T" - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "genericParameters" : [ - { - "constraints" : [ - "GenericRTPosition", - "GenericRTNode" - ], - "name" : "T" - } - ], - "name" : "jsGenericMakeNode", - "parameters" : [ - - ], - "returnType" : { - "generic" : { - "_0" : "T" - } - } - } - ], - "types" : [ - { - "accessLevel" : "internal", - "constructor" : { - "accessLevel" : "internal", - "parameters" : [ - - ] - }, - "getters" : [ - - ], - "methods" : [ + }, { "accessLevel" : "internal", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : true }, - "genericParameters" : [ - { - "name" : "T" - } - ], - "name" : "identity", + "name" : "loadCopyable", "parameters" : [ { - "name" : "value", + "name" : "start", "type" : { - "generic" : { - "_0" : "T" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } ], "returnType" : { - "generic" : { - "_0" : "T" + "jsObject" : { + "_0" : "CopyableObjectRoundtrip" } } - } - ], - "name" : "ImportGenericConsumer", - "setters" : [ - - ], - "staticMethods" : [ + }, { "accessLevel" : "internal", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : true }, - "genericParameters" : [ - { - "name" : "T" - } + "name" : "loadFail", + "parameters" : [ + ], - "name" : "box", + "returnType" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "use", "parameters" : [ { - "name" : "value", + "name" : "object", "type" : { - "generic" : { - "_0" : "T" + "jsUniqueObject" : { + "_0" : "NoncopyableObject" } } } ], "returnType" : { - "generic" : { - "_0" : "T" - } - } - } - ] - }, - { - "accessLevel" : "internal", - "constructor" : { - "accessLevel" : "internal", - "genericParameters" : [ - { - "name" : "T" - } - ], - "parameters" : [ - { - "name" : "value", - "type" : { - "generic" : { - "_0" : "T" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" } } } - ] - }, - "getters" : [ - - ], - "methods" : [ + }, { "accessLevel" : "internal", "effects" : { @@ -27137,54 +30518,11 @@ "isStatic" : false, "isThrows" : true }, - "genericParameters" : [ - { - "name" : "T" - } - ], - "name" : "unwrap", + "name" : "referencesToCreated", "parameters" : [ ], "returnType" : { - "generic" : { - "_0" : "T" - } - } - } - ], - "name" : "ImportGenericBoxed", - "setters" : [ - - ], - "staticMethods" : [ - - ] - } - ] - }, - { - "functions" : [ - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsTranslatePoint", - "parameters" : [ - { - "name" : "point", - "type" : { - "swiftStruct" : { - "_0" : "Point" - } - } - }, - { - "name" : "dx", - "type" : { "integer" : { "_0" : { "isSigned" : true, @@ -27194,8 +30532,24 @@ } }, { - "name" : "dy", - "type" : { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "referencesTo", + "parameters" : [ + { + "name" : "object", + "type" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + ], + "returnType" : { "integer" : { "_0" : { "isSigned" : true, @@ -27203,71 +30557,39 @@ } } } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "Point" - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalPoint", - "parameters" : [ + }, { - "name" : "point", - "type" : { - "nullable" : { - "_0" : { - "swiftStruct" : { - "_0" : "Point" + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "takeOptional", + "parameters" : [ + { + "name" : "object", + "type" : { + "nullable" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + }, + "_1" : "null" } - }, - "_1" : "null" + } } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "swiftStruct" : { - "_0" : "Point" + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } - }, - "_1" : "null" - } - } - } - ], - "types" : [ - - ] - }, - { - "functions" : [ - - ], - "types" : [ - { - "accessLevel" : "internal", - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "IntegerTypesSupportImports", - "setters" : [ - - ], - "staticMethods" : [ + } + }, { "accessLevel" : "internal", "effects" : { @@ -27275,16 +30597,18 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripInt", + "name" : "takeOptionalCopyable", "parameters" : [ { - "name" : "v", + "name" : "copyable", "type" : { - "integer" : { + "nullable" : { "_0" : { - "isSigned" : true, - "width" : "word" - } + "jsObject" : { + "_0" : "CopyableObjectRoundtrip" + } + }, + "_1" : "null" } } } @@ -27305,14 +30629,14 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripUInt", + "name" : "findOptional", "parameters" : [ { - "name" : "v", + "name" : "start", "type" : { "integer" : { "_0" : { - "isSigned" : false, + "isSigned" : true, "width" : "word" } } @@ -27320,11 +30644,13 @@ } ], "returnType" : { - "integer" : { + "nullable" : { "_0" : { - "isSigned" : false, - "width" : "word" - } + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + }, + "_1" : "null" } } }, @@ -27335,26 +30661,28 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripInt8", + "name" : "findOptionalCopyable", "parameters" : [ { - "name" : "v", + "name" : "start", "type" : { "integer" : { "_0" : { "isSigned" : true, - "width" : "w8" + "width" : "word" } } } } ], "returnType" : { - "integer" : { + "nullable" : { "_0" : { - "isSigned" : true, - "width" : "w8" - } + "jsObject" : { + "_0" : "CopyableObjectRoundtrip" + } + }, + "_1" : "null" } } }, @@ -27365,56 +30693,87 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripUInt8", + "name" : "forEachOptional", "parameters" : [ { - "name" : "v", + "name" : "count", "type" : { "integer" : { "_0" : { - "isSigned" : false, - "width" : "w8" + "isSigned" : true, + "width" : "word" } } } + }, + { + "name" : "body", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSq17NoncopyableObjectV_y", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "nullable" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "void" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } } ], "returnType" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "w8" - } + "void" : { + } } }, { "accessLevel" : "internal", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripInt16", + "name" : "loadOptional", "parameters" : [ { - "name" : "v", + "name" : "start", "type" : { "integer" : { "_0" : { "isSigned" : true, - "width" : "w16" + "width" : "word" } } } } ], "returnType" : { - "integer" : { + "nullable" : { "_0" : { - "isSigned" : true, - "width" : "w16" - } + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + }, + "_1" : "null" } } }, @@ -27425,26 +30784,23 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripUInt16", + "name" : "raw", "parameters" : [ { - "name" : "v", + "name" : "start", "type" : { "integer" : { "_0" : { - "isSigned" : false, - "width" : "w16" + "isSigned" : true, + "width" : "word" } } } } ], "returnType" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "w16" - } + "jsUniqueObject" : { + } } }, @@ -27455,16 +30811,13 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripInt32", + "name" : "rawValue", "parameters" : [ { - "name" : "v", + "name" : "ref", "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "w32" - } + "jsUniqueObject" : { + } } } @@ -27473,7 +30826,7 @@ "integer" : { "_0" : { "isSigned" : true, - "width" : "w32" + "width" : "word" } } } @@ -27485,26 +30838,28 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripUInt32", + "name" : "maybeRaw", "parameters" : [ { - "name" : "v", + "name" : "start", "type" : { "integer" : { "_0" : { - "isSigned" : false, - "width" : "w32" + "isSigned" : true, + "width" : "word" } } } } ], "returnType" : { - "integer" : { + "nullable" : { "_0" : { - "isSigned" : false, - "width" : "w32" - } + "jsUniqueObject" : { + + } + }, + "_1" : "null" } } }, @@ -27515,26 +30870,23 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripInt64", + "name" : "rawObject", "parameters" : [ { - "name" : "v", + "name" : "start", "type" : { "integer" : { "_0" : { "isSigned" : true, - "width" : "w64" + "width" : "word" } } } } ], "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "w64" - } + "jsObject" : { + } } }, @@ -27545,15 +30897,16 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripUInt64", + "name" : "takeAll", "parameters" : [ { - "name" : "v", + "name" : "objects", "type" : { - "integer" : { + "array" : { "_0" : { - "isSigned" : false, - "width" : "w64" + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } } } } @@ -27562,8 +30915,8 @@ "returnType" : { "integer" : { "_0" : { - "isSigned" : false, - "width" : "w64" + "isSigned" : true, + "width" : "word" } } } @@ -27575,66 +30928,11 @@ "isStatic" : false, "isThrows" : true }, - "name" : "runJsIntegerTypesSupportTests", + "name" : "makeAll", "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - } - ] - } - ] - }, - { - "functions" : [ - - ], - "types" : [ - { - "accessLevel" : "internal", - "constructor" : { - "accessLevel" : "internal", - "parameters" : [ - { - "name" : "numbers", - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - }, - { - "name" : "labels", - "type" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - } - ] - }, - "getters" : [ - { - "accessLevel" : "internal", - "name" : "numbers", - "type" : { - "array" : { - "_0" : { + { + "name" : "count", + "type" : { "integer" : { "_0" : { "isSigned" : true, @@ -27643,23 +30941,17 @@ } } } - } - }, - { - "accessLevel" : "internal", - "name" : "labels", - "type" : { + ], + "returnType" : { "array" : { "_0" : { - "string" : { - + "jsUniqueObject" : { + "_0" : "NoncopyableObject" } } } } - } - ], - "methods" : [ + }, { "accessLevel" : "internal", "effects" : { @@ -27667,18 +30959,20 @@ "isStatic" : false, "isThrows" : true }, - "name" : "concatNumbers", + "name" : "takeAllOptional", "parameters" : [ { - "name" : "values", + "name" : "objects", "type" : { "array" : { "_0" : { - "integer" : { + "nullable" : { "_0" : { - "isSigned" : true, - "width" : "word" - } + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + }, + "_1" : "null" } } } @@ -27686,14 +30980,10 @@ } ], "returnType" : { - "array" : { + "integer" : { "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } + "isSigned" : true, + "width" : "word" } } } @@ -27705,16 +30995,15 @@ "isStatic" : false, "isThrows" : true }, - "name" : "concatLabels", + "name" : "makeAllOptional", "parameters" : [ { - "name" : "values", + "name" : "count", "type" : { - "array" : { + "integer" : { "_0" : { - "string" : { - - } + "isSigned" : true, + "width" : "word" } } } @@ -27723,8 +31012,13 @@ "returnType" : { "array" : { "_0" : { - "string" : { - + "nullable" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + }, + "_1" : "null" } } } @@ -27737,37 +31031,46 @@ "isStatic" : false, "isThrows" : true }, - "name" : "firstLabel", + "name" : "makeGrid", "parameters" : [ { - "name" : "values", + "name" : "count", "type" : { - "array" : { + "integer" : { "_0" : { - "string" : { - - } + "isSigned" : true, + "width" : "word" } } } } ], "returnType" : { - "string" : { - + "array" : { + "_0" : { + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + } } - } - } - ], - "name" : "JSClassWithArrayMembers", - "setters" : [ + } + }, { "accessLevel" : "internal", - "functionName" : "numbers_set", - "name" : "numbers", - "type" : { - "array" : { - "_0" : { + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "loadAll", + "parameters" : [ + { + "name" : "count", + "type" : { "integer" : { "_0" : { "isSigned" : true, @@ -27776,40 +31079,17 @@ } } } - } - }, - { - "accessLevel" : "internal", - "functionName" : "labels_set", - "name" : "labels", - "type" : { + ], + "returnType" : { "array" : { "_0" : { - "string" : { - + "jsUniqueObject" : { + "_0" : "NoncopyableObject" } } } } - } - ], - "staticMethods" : [ - - ] - }, - { - "accessLevel" : "internal", - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "JSClassSupportImports", - "setters" : [ - - ], - "staticMethods" : [ + }, { "accessLevel" : "internal", "effects" : { @@ -27817,208 +31097,85 @@ "isStatic" : false, "isThrows" : true }, - "name" : "makeJSClassWithArrayMembers", + "name" : "forEachBatch", "parameters" : [ { - "name" : "numbers", + "name" : "count", "type" : { - "array" : { + "integer" : { "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } + "isSigned" : true, + "width" : "word" } } } }, { - "name" : "labels", + "name" : "body", "type" : { - "array" : { + "closure" : { "_0" : { - "string" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSa17NoncopyableObjectV_y", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + } + ], + "returnType" : { + "void" : { - } - } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true } } } ], "returnType" : { - "jsObject" : { - "_0" : "JSClassWithArrayMembers" - } - } - } - ] - } - ] - }, - { - "functions" : [ - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "from" : { - "kind" : "module", - "specifier" : "node:path" - }, - "jsName" : "basename", - "name" : "nodeBasename", - "parameters" : [ - { - "name" : "path", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "from" : { - "kind" : "module", - "specifier" : "node:path" - }, - "jsName" : "join", - "name" : "nodeJoin", - "parameters" : [ - { - "name" : "lhs", - "type" : { - "string" : { + "void" : { } } }, - { - "name" : "rhs", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - } - } - ], - "globalGetters" : [ - { - "accessLevel" : "internal", - "from" : { - "kind" : "snippet", - "path" : "\/Modules\/DefaultExport.mjs" - }, - "jsName" : "default", - "name" : "defaultExport", - "type" : { - "jsObject" : { - - } - } - } - ], - "types" : [ - { - "accessLevel" : "internal", - "constructor" : { - "accessLevel" : "internal", - "parameters" : [ - { - "name" : "data", - "type" : { - "jsObject" : { - - } - } - } - ] - }, - "from" : { - "kind" : "module", - "specifier" : "@bjorn3\/browser_wasi_shim" - }, - "getters" : [ { "accessLevel" : "internal", - "name" : "size", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "w64" - } - } - } - } - ], - "jsName" : "File", - "methods" : [ - - ], - "name" : "WasiFile", - "setters" : [ - - ], - "staticMethods" : [ - - ] - } - ] - }, - { - "functions" : [ - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "from" : { - "kind" : "snippet", - "path" : "\/Modules\/JSImportModule.mjs" - }, - "name" : "moduleAdd", - "parameters" : [ - { - "name" : "lhs", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "takeMaybe", + "parameters" : [ + { + "name" : "objects", + "type" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + }, + "_1" : "null" + } } } - } - }, - { - "name" : "rhs", - "type" : { + ], + "returnType" : { "integer" : { "_0" : { "isSigned" : true, @@ -28026,115 +31183,43 @@ } } } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "from" : { - "kind" : "snippet", - "path" : "\/Modules\/JSImportModule.mjs" - }, - "jsName" : "renamedFunction", - "name" : "moduleRenamed", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "from" : { - "kind" : "snippet", - "path" : "\/Modules\/JSImportModule.mjs" - }, - "name" : "moduleThrow", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - } - ], - "globalGetters" : [ - { - "accessLevel" : "internal", - "from" : { - "kind" : "snippet", - "path" : "\/Modules\/JSImportModule.mjs" - }, - "jsName" : "version", - "name" : "moduleVersion", - "type" : { - "string" : { - - } - } - } - ], - "types" : [ - { - "accessLevel" : "internal", - "constructor" : { - "accessLevel" : "internal", - "parameters" : [ - { - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "makeMaybe", + "parameters" : [ + { + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } - } - ] - }, - "from" : { - "kind" : "snippet", - "path" : "\/Modules\/ModuleCounter.mjs" - }, - "getters" : [ - { - "accessLevel" : "internal", - "name" : "value", - "type" : { - "integer" : { + ], + "returnType" : { + "nullable" : { "_0" : { - "isSigned" : true, - "width" : "word" - } + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + }, + "_1" : "null" } } - } - ], - "methods" : [ + }, { "accessLevel" : "internal", "effects" : { @@ -28142,9 +31227,29 @@ "isStatic" : false, "isThrows" : true }, - "name" : "increment", + "name" : "takeRows", "parameters" : [ - + { + "name" : "rows", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + }, + "_1" : "null" + } + } + } + } + } ], "returnType" : { "integer" : { @@ -28154,36 +31259,58 @@ } } } - } - ], - "name" : "ModuleCounter", - "setters" : [ + }, { "accessLevel" : "internal", - "functionName" : "value_set", - "name" : "value", - "type" : { - "integer" : { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "makeRows", + "parameters" : [ + { + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "array" : { "_0" : { - "isSigned" : true, - "width" : "word" + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + }, + "_1" : "null" + } } } } - } - ], - "staticMethods" : [ + }, { "accessLevel" : "internal", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : true }, - "name" : "create", + "name" : "loadMaybe", "parameters" : [ { - "name" : "value", + "name" : "count", "type" : { "integer" : { "_0" : { @@ -28195,20 +31322,57 @@ } ], "returnType" : { - "jsObject" : { - "_0" : "ModuleCounter" + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + }, + "_1" : "null" } } } - ] - } - ] - }, - { - "functions" : [ + ], + "name" : "NoncopyableSource", + "setters" : [ + { + "accessLevel" : "internal", + "functionName" : "optionalChild_set", + "name" : "optionalChild", + "type" : { + "nullable" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + }, + "_1" : "null" + } + } + }, + { + "accessLevel" : "internal", + "functionName" : "children_set", + "name" : "children", + "type" : { + "array" : { + "_0" : { + "jsUniqueObject" : { + "_0" : "NoncopyableObject" + } + } + } + } + } + ], + "staticMethods" : [ - ], - "types" : [ + ] + }, { "accessLevel" : "internal", "getters" : [ @@ -28217,7 +31381,7 @@ "methods" : [ ], - "name" : "JSTypedArrayImports", + "name" : "NoncopyableJSClassSupportImports", "setters" : [ ], @@ -28229,38 +31393,17 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsCreateUint8Array", + "name" : "liveReferenceCount", "parameters" : [ ], "returnType" : { - "jsObject" : { - "_0" : "JSUint8Array" - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripUint8Array", - "parameters" : [ - { - "name" : "v", - "type" : { - "jsObject" : { - "_0" : "JSUint8Array" - } + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" } } - ], - "returnType" : { - "jsObject" : { - "_0" : "JSUint8Array" - } } }, { @@ -28270,79 +31413,44 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripFloat32Array", + "name" : "retainByRefCount", "parameters" : [ - { - "name" : "v", - "type" : { - "jsObject" : { - "_0" : "JSFloat32Array" - } - } - } + ], "returnType" : { - "jsObject" : { - "_0" : "JSFloat32Array" - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripFloat64Array", - "parameters" : [ - { - "name" : "v", - "type" : { - "jsObject" : { - "_0" : "JSFloat64Array" - } + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" } } - ], - "returnType" : { - "jsObject" : { - "_0" : "JSFloat64Array" - } } }, { "accessLevel" : "internal", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripInt32Array", + "name" : "runNoncopyableExportedPathTests", "parameters" : [ - { - "name" : "v", - "type" : { - "jsObject" : { - "_0" : "JSInt32Array" - } - } - } + ], "returnType" : { - "jsObject" : { - "_0" : "JSInt32Array" + "void" : { + } } }, { "accessLevel" : "internal", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : true }, - "name" : "runJsTypedArrayTests", + "name" : "runNoncopyableUniqueArrayExportedPathTests", "parameters" : [ ], @@ -28359,174 +31467,6 @@ { "functions" : [ - ], - "types" : [ - { - "accessLevel" : "internal", - "constructor" : { - "accessLevel" : "internal", - "parameters" : [ - - ] - }, - "from" : "global", - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "MyJSClassInternal", - "setters" : [ - - ], - "staticMethods" : [ - - ] - }, - { - "accessLevel" : "public", - "constructor" : { - "accessLevel" : "public", - "parameters" : [ - - ] - }, - "from" : "global", - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "MyJSClassPublic", - "setters" : [ - - ], - "staticMethods" : [ - - ] - }, - { - "accessLevel" : "package", - "constructor" : { - "accessLevel" : "package", - "parameters" : [ - - ] - }, - "from" : "global", - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "MyJSClassPackage", - "setters" : [ - - ], - "staticMethods" : [ - - ] - } - ] - }, - { - "functions" : [ - { - "accessLevel" : "package", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsFunctionWithPackageAccess", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "accessLevel" : "public", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsFunctionWithPublicAccess", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsFunctionWithInternalAccess", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsFunctionWithFilePrivateAccess", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsFunctionWithPrivateAccess", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - } - ], - "types" : [ - - ] - }, - { - "functions" : [ - ], "types" : [ { diff --git a/Tests/BridgeJSRuntimeTests/JavaScript/ClosureSupportTests.mjs b/Tests/BridgeJSRuntimeTests/JavaScript/ClosureSupportTests.mjs index 2ddc8c866..a7a9a4087 100644 --- a/Tests/BridgeJSRuntimeTests/JavaScript/ClosureSupportTests.mjs +++ b/Tests/BridgeJSRuntimeTests/JavaScript/ClosureSupportTests.mjs @@ -64,8 +64,11 @@ export function getImports(importsContext) { fn(); }, jsHeapCount: () => { - globalThis.gc?.(); - return globalThis.swift?.memory?._heapValueById?.size ?? -1; + let count = 0; + for (const state of importsContext._swift.memory._stateBySlot) { + count += (state ?? 0) & 0xffffff; + } + return count; }, jsCallAfterRelease: (fn) => { try { diff --git a/Tests/BridgeJSRuntimeTests/JavaScript/NoncopyableJSClassSupportTests.mjs b/Tests/BridgeJSRuntimeTests/JavaScript/NoncopyableJSClassSupportTests.mjs new file mode 100644 index 000000000..ab08eecf9 --- /dev/null +++ b/Tests/BridgeJSRuntimeTests/JavaScript/NoncopyableJSClassSupportTests.mjs @@ -0,0 +1,473 @@ +// @ts-check + +import assert from "node:assert"; + +/** + * Sums the reference counts of every slot in the runtime's `JSObjectSpace`, `globalThis` included. + * Other Swift tests change it while a test awaits, so compare two counts only within a synchronous loop. + * @param {any} swift The `SwiftRuntime` instance. + */ +function liveReferenceCount(swift) { + let count = 0; + for (const state of swift.memory._stateBySlot) { + count += (state ?? 0) & 0xffffff; + } + return count; +} + +/** + * @param {any} swift The `SwiftRuntime` instance. + * @param {any[]} values + */ +function referenceCountOf(swift, values) { + let count = 0; + for (const value of values) { + const slot = swift.memory._slotByValue.get(value); + if (slot !== undefined) count += swift.memory._stateBySlot[slot] & 0xffffff; + } + return count; +} + +class NoncopyableObject { + /** @param {number} start */ + constructor(start) { + this.start = start; + } + /** @param {number} start */ + static create(start) { + return new NoncopyableObject(start); + } + value() { + return this.start; + } +} + +/** @param {number} start */ +const makeCopyableObjectRoundtrip = (start) => ({ + value: () => start, + take: (object) => object.value(), + make: (value) => new NoncopyableObject(value), +}); + +class NoncopyableObjectRoundtrip { + constructor() { + this.stored = null; + } + take(object) { + return object.value(); + } + make(start) { + return new NoncopyableObject(start); + } + get child() { + return new NoncopyableObject(42); + } + set child(object) { + this.stored = object; + } + adopt(object) { + return object.value(); + } + takeCopyable(copyable) { + return copyable.value(); + } + makeCopyable(start) { + return makeCopyableObjectRoundtrip(start); + } + failTake(_object) { + throw new Error("failTake"); + } + failMake() { + throw new Error("failMake"); + } +} + +/** @param {() => any} getSwift */ +function makeSourceClass(getSwift) { + return class NoncopyableSource { + created = []; + optionalChild = null; + children = []; + + forEachObject(count, body) { + for (let i = 0; i < count; i++) body(new NoncopyableObject(i)); + } + forEachObjectEscaping(count, body) { + for (let i = 0; i < count; i++) body(new NoncopyableObject(i)); + } + forEachCopyableEscaping(count, body) { + for (let i = 0; i < count; i++) body(makeCopyableObjectRoundtrip(i)); + } + /** @param {Promise} promise */ + recordSettlers(promise) { + const then = promise.then.bind(promise); + promise.then = (resolve, reject) => { + this.created.push(resolve, reject); + return then(resolve, reject); + }; + return promise; + } + load(start) { + const object = new NoncopyableObject(start); + this.created.push(object); + return this.recordSettlers(Promise.resolve(object)); + } + loadCopyable(start) { + const copyable = makeCopyableObjectRoundtrip(start); + this.created.push(copyable); + return this.recordSettlers(Promise.resolve(copyable)); + } + loadFail() { + const error = new Error("loadFail"); + this.created.push(error); + return this.recordSettlers(Promise.reject(error)); + } + use(object) { + return this.recordSettlers(Promise.resolve(object.value())); + } + referencesToCreated() { + const count = referenceCountOf(getSwift(), this.created); + this.created = []; + return count; + } + referencesTo(object) { + return referenceCountOf(getSwift(), [object]); + } + takeOptional(object) { + return object == null ? -2 : object.value(); + } + takeOptionalCopyable(copyable) { + return copyable == null ? -2 : copyable.value(); + } + findOptional(start) { + return start < 0 ? null : new NoncopyableObject(start); + } + findOptionalCopyable(start) { + return start < 0 ? null : makeCopyableObjectRoundtrip(start); + } + forEachOptional(count, body) { + for (let i = 0; i < count; i++) body(i % 2 === 0 ? new NoncopyableObject(i) : null); + } + loadOptional(start) { + if (start >= 0) return this.load(start); + return this.recordSettlers(Promise.resolve(null)); + } + raw(start) { + return new NoncopyableObject(start); + } + rawValue(ref) { + return ref.value(); + } + maybeRaw(start) { + return this.findOptional(start); + } + rawObject(start) { + return new NoncopyableObject(start); + } + takeAll(objects) { + return objects.reduce((sum, object, index) => sum + object.value() * (index + 1), 0); + } + makeAll(count) { + return Array.from({ length: count }, (_, i) => new NoncopyableObject(i)); + } + takeAllOptional(objects) { + return objects.reduce((sum, object) => sum + (object == null ? -2 : object.value()), 0); + } + makeAllOptional(count) { + return Array.from({ length: count }, (_, i) => (i % 2 === 0 ? new NoncopyableObject(i) : null)); + } + makeGrid(count) { + return Array.from({ length: count }, (_, row) => this.makeAll(row)); + } + loadAll(count) { + const objects = this.makeAll(count); + this.created.push(...objects); + return this.recordSettlers(Promise.resolve(objects)); + } + forEachBatch(count, body) { + for (let i = 0; i < count; i++) body(this.makeAll(i)); + } + takeMaybe(objects) { + return objects == null ? -2 : this.takeAll(objects); + } + makeMaybe(count) { + return count < 0 ? null : this.makeAll(count); + } + takeRows(rows) { + return rows.reduce((sum, row, index) => sum + (row == null ? -2 : this.takeAll(row)) * (index + 1), 0); + } + makeRows(count) { + return Array.from({ length: count }, (_, row) => (row % 2 === 0 ? this.makeAll(row) : null)); + } + loadMaybe(count) { + const objects = this.makeMaybe(count); + if (objects !== null) this.created.push(...objects); + return this.recordSettlers(Promise.resolve(objects)); + } + }; +} + +/** @param {number} i */ +const optionalObject = (i) => (i % 2 === 0 ? new NoncopyableObject(i) : null); +/** @param {number} i */ +const optionalValue = (i) => (i % 2 === 0 ? i : -2); +/** @param {number} count */ +const makeObjects = (count) => Array.from({ length: count }, (_, j) => new NoncopyableObject(j)); +/** @param {number} count */ +const range = (count) => Array.from({ length: count }, (_, j) => j); + +/** + * @param {any} swift The `SwiftRuntime` instance. + * @param {Record void>} paths + */ +function referencesKept(swift, paths) { + /** @type {Record} */ + const kept = {}; + for (const [name, body] of Object.entries(paths)) { + const before = liveReferenceCount(swift); + for (let i = 0; i < 100; i++) body(i); + kept[name] = liveReferenceCount(swift) - before; + } + return kept; +} + +/** @param {string[]} names */ +const zeros = (names) => Object.fromEntries(names.map((name) => [name, 0])); + +/** + * @param {any} exports + * @param {any} swift The `SwiftRuntime` instance. + */ +async function runExportedPathTests(exports, swift) { + const Box = exports.NoncopyableObjectBox; + const paths = { + "exported function, borrowing parameter": (i) => + assert.equal(exports.noncopyableTake(new NoncopyableObject(i)), i), + "exported function, consuming parameter": (i) => + assert.equal(exports.noncopyableConsume(new NoncopyableObject(i)), i), + "exported function, return": (i) => assert.equal(exports.noncopyableMake(i).value(), i), + "exported function, return passed back": (i) => + assert.equal(exports.noncopyableTake(exports.noncopyableMake(i)), i), + "exported function, closure parameter": (i) => + assert.equal( + exports.noncopyableCallWith(i, (object) => object.value()), + i, + ), + "exported function, optional parameter": (i) => + assert.equal(exports.noncopyableTakeOptional(optionalObject(i)), optionalValue(i)), + "exported function, optional parameter, copyable control": (i) => + assert.equal(exports.copyableTakeOptional(optionalObject(i)), optionalValue(i)), + "exported function, optional return": (i) => { + const object = exports.noncopyableFindOptional(i % 2 === 0 ? i : -1); + assert.equal(object === null ? -2 : object.value(), optionalValue(i)); + }, + "exported function, optional return passed back": (i) => + assert.equal( + exports.noncopyableTakeOptional(exports.noncopyableFindOptional(i % 2 === 0 ? i : -1)), + optionalValue(i), + ), + "exported function, optional closure parameter": (i) => + assert.equal( + exports.noncopyableCallWithOptional(i % 2 === 0 ? i : -1, (object) => + object === null ? -2 : object.value(), + ), + optionalValue(i), + ), + "exported protocol, borrowing parameter": (i) => + assert.equal(exports.noncopyableVisit({ visit: (object) => object.value() }, i), i), + "exported protocol, optional parameter": (i) => + assert.equal( + exports.noncopyableVisitOptional( + { visit: (object) => (object === null ? -2 : object.value()) }, + i % 2 === 0 ? i : -1, + ), + optionalValue(i), + ), + "exported closure return, called with a wrapper": (i) => + assert.equal(exports.noncopyableMakeReader()(new NoncopyableObject(i)), i), + "exported closure return, called with a wrapper, copyable control": (i) => + assert.equal(exports.copyableMakeReader()(new NoncopyableObject(i)), i), + "exported closure return, called with an Int, control": (i) => + assert.equal(exports.makeIntReader()(i), i), + "exported class, init and method": (i) => { + const box = new Box(i); + assert.equal(box.value(), i); + box.release(); + }, + "exported class, property getter": (i) => { + const box = new Box(i); + assert.equal(box.object.value(), i); + box.release(); + }, + "exported class, property setter": (i) => { + const box = new Box(0); + box.object = new NoncopyableObject(i); + assert.equal(box.value(), i); + box.release(); + }, + "exported class, method parameter": (i) => { + const box = new Box(0); + assert.equal(box.take(new NoncopyableObject(i)), i); + box.release(); + }, + "exported class, computed property getter": () => { + const box = new Box(0); + assert.equal(box.made.value(), 9); + box.release(); + }, + "exported class, optional property getter and setter": (i) => { + const box = new Box(0); + box.optionalObject = optionalObject(i); + const object = box.optionalObject; + assert.equal(object === null ? -2 : object.value(), optionalValue(i)); + box.release(); + }, + "exported class, static property getter": () => assert.equal(Box.shared.value(), 7), + "exported class, static property setter": (i) => { + Box.shared = new NoncopyableObject(i); + assert.equal(Box.shared.value(), i); + }, + "exported class, computed static property getter": () => assert.equal(Box.staticMade.value(), 8), + }; + // Swift creates the stored static on the first read and keeps it. + assert.equal(Box.shared.value(), 7); + const kept = referencesKept(swift, paths); + // A closure returned from an export keeps one reference per call whatever its parameter type. + const closureReturn = "exported closure return, called with a wrapper"; + assert.equal(kept[closureReturn], kept["exported closure return, called with an Int, control"]); + assert.equal(kept[`${closureReturn}, copyable control`], kept[closureReturn]); + const others = Object.keys(paths).filter((name) => !name.startsWith("exported closure return")); + assert.deepEqual(Object.fromEntries(others.map((name) => [name, kept[name]])), zeros(others)); + + const loaded = []; + for (let i = 0; i < 100; i++) { + const promise = exports.noncopyableLoad(i); + const object = await promise; + assert.equal(object.value(), i); + loaded.push(promise, object); + } + assert.equal(referenceCountOf(swift, loaded), 0); +} + +/** + * @param {any} exports + * @param {any} swift The `SwiftRuntime` instance. + */ +async function runUniqueArrayExportedPathTests(exports, swift) { + const Box = exports.NoncopyableObjectBox; + const paths = { + "exported function, UniqueArray parameter": (i) => + assert.deepEqual(exports.noncopyableTakeAll(makeObjects(i % 5)), range(i % 5)), + "exported function, UniqueArray return": (i) => + assert.deepEqual( + exports.noncopyableMakeAll(i % 5).map((object) => object.value()), + range(i % 5), + ), + "exported function, UniqueArray passed through": (i) => + assert.deepEqual( + exports.noncopyablePassAll(makeObjects(i % 5)).map((object) => object.value()), + range(i % 5), + ), + "exported function, UniqueArray optional elements": (i) => { + const objects = Array.from({ length: i % 5 }, (_, j) => optionalObject(j)); + assert.deepEqual(exports.noncopyableTakeAllOptional(objects), objects.map((_, j) => optionalValue(j))); + }, + "exported function, optional UniqueArray parameter": (i) => + assert.deepEqual( + exports.noncopyableTakeMaybe(i % 2 === 0 ? makeObjects(i % 5) : null), + i % 2 === 0 ? range(i % 5) : null, + ), + "exported function, optional UniqueArray return": (i) => { + const objects = exports.noncopyableMakeMaybe(i % 2 === 0 ? i % 5 : -1); + assert.deepEqual( + objects === null ? null : objects.map((object) => object.value()), + i % 2 === 0 ? range(i % 5) : null, + ); + }, + "exported protocol, UniqueArray parameter": (i) => { + const visitor = { + visit: (object) => object.value(), + visitAll: (objects) => objects.reduce((sum, object, index) => sum + object.value() * (index + 1), 0), + makeAll: makeObjects, + }; + const weightedSum = range(i % 5).reduce((sum, j) => sum + j * (j + 1), 0); + assert.equal(exports.noncopyableVisitAll(visitor, makeObjects(i % 5)), weightedSum); + }, + "exported protocol, UniqueArray return": (i) => { + const visitor = { visit: (object) => object.value(), visitAll: () => -1, makeAll: makeObjects }; + assert.deepEqual( + exports.noncopyableVisitorMakeAll(visitor, i % 5).map((object) => object.value()), + range(i % 5), + ); + }, + "exported class, UniqueArray property getter and setter": (i) => { + const box = new Box(0); + box.objects = makeObjects(i % 5); + assert.deepEqual( + box.objects.map((object) => object.value()), + range(i % 5), + ); + box.release(); + }, + "exported class, optional UniqueArray property getter and setter": (i) => { + const box = new Box(0); + box.maybeObjects = i % 2 === 0 ? makeObjects(i % 5) : null; + const objects = box.maybeObjects; + assert.deepEqual( + objects === null ? null : objects.map((object) => object.value()), + i % 2 === 0 ? range(i % 5) : null, + ); + box.release(); + }, + }; + assert.deepEqual(referencesKept(swift, paths), zeros(Object.keys(paths))); + + const loaded = []; + for (let i = 0; i < 100; i++) { + const promise = exports.noncopyableLoadAll(i % 4); + const objects = await promise; + assert.deepEqual( + objects.map((object) => object.value()), + range(i % 4), + ); + loaded.push(promise, ...objects); + } + assert.equal(referenceCountOf(swift, loaded), 0); +} + +export function getImports(importsContext) { + globalThis.noncopyableSharedObject = new NoncopyableObject(7); + const getSwift = () => importsContext._swift; + const getExports = () => { + const exports = importsContext.getExports(); + if (!exports) { + throw new Error("No exports!?"); + } + return exports; + }; + const retainByRef = { calls: 0, counting: false }; + return { + NoncopyableObject, + NoncopyableObjectRoundtrip, + NoncopyableSource: makeSourceClass(getSwift), + noncopyableMakeObject: (start) => new NoncopyableObject(start), + noncopyableUseObject: (object) => object.value(), + NoncopyableJSClassSupportImports: { + liveReferenceCount: () => liveReferenceCount(getSwift()), + retainByRefCount: () => { + if (!retainByRef.counting) { + const memory = getSwift().memory; + const original = memory.retainByRef.bind(memory); + memory.retainByRef = (reference) => { + retainByRef.calls++; + return original(reference); + }; + retainByRef.counting = true; + } + return retainByRef.calls; + }, + runNoncopyableExportedPathTests: () => runExportedPathTests(getExports(), getSwift()), + runNoncopyableUniqueArrayExportedPathTests: () => runUniqueArrayExportedPathTests(getExports(), getSwift()), + }, + }; +} diff --git a/Tests/BridgeJSRuntimeTests/NoncopyableJSClassSupportTests.swift b/Tests/BridgeJSRuntimeTests/NoncopyableJSClassSupportTests.swift new file mode 100644 index 000000000..f78b69784 --- /dev/null +++ b/Tests/BridgeJSRuntimeTests/NoncopyableJSClassSupportTests.swift @@ -0,0 +1,613 @@ +import Testing +import JavaScriptKit + +@JSClass struct NoncopyableObject: ~Copyable { + @JSFunction init(_ start: Int) throws(JSException) + @JSFunction static func create(_ start: Int) throws(JSException) -> NoncopyableObject + @JSFunction func value() throws(JSException) -> Int +} + +@JSClass struct NoncopyableObjectView: ~Copyable { + @JSFunction func value() throws(JSException) -> Int +} + +@JSClass struct NoncopyableObjectRoundtrip: ~Copyable { + @JSFunction init() throws(JSException) + @JSFunction func take(_ object: borrowing NoncopyableObject) throws(JSException) -> Int + @JSFunction func make(_ start: Int) throws(JSException) -> NoncopyableObject + @JSGetterFunction func child() throws(JSException) -> NoncopyableObject + @JSSetter func setChild(_ object: borrowing NoncopyableObject) throws(JSException) + @JSFunction func adopt(_ object: consuming NoncopyableObject) throws(JSException) -> Int + @JSFunction func takeCopyable(_ copyable: CopyableObjectRoundtrip) throws(JSException) -> Int + @JSFunction func makeCopyable(_ start: Int) throws(JSException) -> CopyableObjectRoundtrip + @JSFunction func failTake(_ object: borrowing NoncopyableObject) throws(JSException) -> Int + @JSFunction func failMake() throws(JSException) -> NoncopyableObject +} + +@JSClass struct CopyableObjectRoundtrip { + @JSFunction func value() throws(JSException) -> Int + @JSFunction func take(_ object: borrowing NoncopyableObject) throws(JSException) -> Int + @JSFunction func make(_ start: Int) throws(JSException) -> NoncopyableObject +} + +@JSClass struct NoncopyableSource: ~Copyable { + @JSFunction init() throws(JSException) + @JSFunction func forEachObject( + _ count: Int, + _ body: JSTypedClosure<(borrowing NoncopyableObject) -> Void> + ) throws(JSException) + @JSFunction func forEachObjectEscaping( + _ count: Int, + _ body: @escaping (borrowing NoncopyableObject) -> Void + ) throws(JSException) + @JSFunction func forEachCopyableEscaping( + _ count: Int, + _ body: @escaping (CopyableObjectRoundtrip) -> Void + ) throws(JSException) + @JSFunction func load(_ start: Int) async throws(JSException) -> NoncopyableObject + @JSFunction func loadCopyable(_ start: Int) async throws(JSException) -> CopyableObjectRoundtrip + @JSFunction func loadFail() async throws(JSException) -> NoncopyableObject + @JSFunction func use(_ object: borrowing NoncopyableObject) async throws(JSException) -> Int + @JSFunction func referencesToCreated() throws(JSException) -> Int + @JSFunction func referencesTo(_ object: borrowing NoncopyableObject) throws(JSException) -> Int + @JSFunction func takeOptional(_ object: borrowing NoncopyableObject?) throws(JSException) -> Int + @JSFunction func takeOptionalCopyable(_ copyable: CopyableObjectRoundtrip?) throws(JSException) -> Int + @JSFunction func findOptional(_ start: Int) throws(JSException) -> NoncopyableObject? + @JSFunction func findOptionalCopyable(_ start: Int) throws(JSException) -> CopyableObjectRoundtrip? + @JSFunction func forEachOptional( + _ count: Int, + _ body: JSTypedClosure<(borrowing NoncopyableObject?) -> Void> + ) throws(JSException) + @JSFunction func loadOptional(_ start: Int) async throws(JSException) -> NoncopyableObject? + @JSGetterFunction func optionalChild() throws(JSException) -> NoncopyableObject? + @JSSetter func setOptionalChild(_ object: borrowing NoncopyableObject?) throws(JSException) + @JSFunction func raw(_ start: Int) throws(JSException) -> JSUniqueRef + @JSFunction func rawValue(_ ref: borrowing JSUniqueRef) throws(JSException) -> Int + @JSFunction func maybeRaw(_ start: Int) throws(JSException) -> JSUniqueRef? + @JSFunction func rawObject(_ start: Int) throws(JSException) -> JSObject + #if compiler(>=6.4) + @JSFunction func takeAll(_ objects: borrowing UniqueArray) throws(JSException) -> Int + @JSFunction func makeAll(_ count: Int) throws(JSException) -> UniqueArray + @JSFunction func takeAllOptional(_ objects: borrowing UniqueArray) throws(JSException) -> Int + @JSFunction func makeAllOptional(_ count: Int) throws(JSException) -> UniqueArray + @JSFunction func makeGrid(_ count: Int) throws(JSException) -> UniqueArray> + @JSFunction func loadAll(_ count: Int) async throws(JSException) -> UniqueArray + @JSGetterFunction func children() throws(JSException) -> UniqueArray + @JSSetter func setChildren(_ objects: borrowing UniqueArray) throws(JSException) + @JSFunction func forEachBatch( + _ count: Int, + _ body: JSTypedClosure<(borrowing UniqueArray) -> Void> + ) throws(JSException) + @JSFunction func takeMaybe(_ objects: borrowing UniqueArray?) throws(JSException) -> Int + @JSFunction func makeMaybe(_ count: Int) throws(JSException) -> UniqueArray? + @JSFunction func takeRows( + _ rows: borrowing UniqueArray?> + ) throws(JSException) -> Int + @JSFunction func makeRows(_ count: Int) throws(JSException) -> UniqueArray?> + @JSFunction func loadMaybe(_ count: Int) async throws(JSException) -> UniqueArray? + #endif +} + +@JSFunction func noncopyableMakeObject(_ start: Int) throws(JSException) -> NoncopyableObject +@JSFunction func noncopyableUseObject(_ object: borrowing NoncopyableObject) throws(JSException) -> Int +@JSGetterFunction(jsName: "noncopyableSharedObject", from: .global) +func noncopyableSharedObject() throws(JSException) -> NoncopyableObject + +@JSClass struct NoncopyableJSClassSupportImports { + @JSFunction static func liveReferenceCount() throws(JSException) -> Int + @JSFunction static func retainByRefCount() throws(JSException) -> Int + @JSFunction static func runNoncopyableExportedPathTests() async throws(JSException) + #if compiler(>=6.4) + @JSFunction static func runNoncopyableUniqueArrayExportedPathTests() async throws(JSException) + #endif +} + +@JS protocol NoncopyableObjectVisitor { + func visit(_ object: borrowing NoncopyableObject) -> Int + #if compiler(>=6.4) + func visitAll(_ objects: borrowing UniqueArray) -> Int + func makeAll(_ count: Int) -> UniqueArray + #endif +} + +@JS protocol NoncopyableOptionalObjectVisitor { + func visit(_ object: borrowing NoncopyableObject?) -> Int +} + +@JS class NoncopyableObjectBox { + @JS var object: NoncopyableObject + @JS init(_ start: Int) { object = try! NoncopyableObject(start) } + @JS func value() -> Int { (try? object.value()) ?? -1 } + @JS func take(_ other: borrowing NoncopyableObject) -> Int { (try? other.value()) ?? -1 } + @JS var made: NoncopyableObject { try! NoncopyableObject(9) } + @JS nonisolated(unsafe) static var shared: NoncopyableObject = try! NoncopyableObject(7) + @JS static var staticMade: NoncopyableObject { try! NoncopyableObject(8) } + @JS var optionalObject: NoncopyableObject? = nil + #if compiler(>=6.4) + @JS var objects: UniqueArray = UniqueArray() + @JS var maybeObjects: UniqueArray? = nil + #endif +} + +@JS func noncopyableTake(_ object: borrowing NoncopyableObject) -> Int { + (try? object.value()) ?? -1 +} + +@JS func noncopyableConsume(_ object: consuming NoncopyableObject) -> Int { + (try? object.value()) ?? -1 +} + +@JS func noncopyableMake(_ start: Int) -> NoncopyableObject { + try! NoncopyableObject(start) +} + +@JS func noncopyableLoad(_ start: Int) async -> NoncopyableObject { + try! NoncopyableObject(start) +} + +@JS func noncopyableCallWith(_ start: Int, _ body: (borrowing NoncopyableObject) -> Int) -> Int { + let object = try! NoncopyableObject(start) + return body(object) +} + +@JS func noncopyableCallWithOptional(_ start: Int, _ body: (borrowing NoncopyableObject?) -> Int) -> Int { + let object: NoncopyableObject? = start < 0 ? nil : try! NoncopyableObject(start) + return body(object) +} + +@JS func noncopyableTakeOptional(_ object: borrowing NoncopyableObject?) -> Int { + switch object { + case .some(let object): (try? object.value()) ?? -1 + case .none: -2 + } +} + +@JS func copyableTakeOptional(_ copyable: CopyableObjectRoundtrip?) -> Int { + guard let copyable else { return -2 } + return (try? copyable.value()) ?? -1 +} + +@JS func noncopyableFindOptional(_ start: Int) -> NoncopyableObject? { + start < 0 ? nil : try! NoncopyableObject(start) +} + +@JS func noncopyableVisit(_ visitor: any NoncopyableObjectVisitor, _ start: Int) -> Int { + let object = try! NoncopyableObject(start) + return visitor.visit(object) +} + +@JS func noncopyableVisitOptional(_ visitor: any NoncopyableOptionalObjectVisitor, _ start: Int) -> Int { + let object: NoncopyableObject? = start < 0 ? nil : try! NoncopyableObject(start) + return visitor.visit(object) +} + +@JS func noncopyableMakeReader() -> JSTypedClosure<(borrowing NoncopyableObject) -> Int> { + JSTypedClosure { object in (try? object.value()) ?? -1 } +} + +@JS func copyableMakeReader() -> JSTypedClosure<(CopyableObjectRoundtrip) -> Int> { + JSTypedClosure { copyable in (try? copyable.value()) ?? -1 } +} + +@JS func makeIntReader() -> JSTypedClosure<(Int) -> Int> { + JSTypedClosure { $0 } +} + +#if compiler(>=6.4) +@JS func noncopyableTakeAll(_ objects: borrowing UniqueArray) -> [Int] { + values(of: objects) +} + +@JS func noncopyableMakeAll(_ count: Int) -> UniqueArray { + try! makeObjects(count) +} + +@JS func noncopyableLoadAll(_ count: Int) async -> UniqueArray { + try! makeObjects(count) +} + +@JS func noncopyablePassAll(_ objects: consuming UniqueArray) -> UniqueArray { + objects +} + +@JS func noncopyableTakeAllOptional(_ objects: borrowing UniqueArray) -> [Int] { + values(of: objects) +} + +@JS func noncopyableTakeMaybe(_ objects: borrowing UniqueArray?) -> [Int]? { + maybeValues(of: objects) +} + +@JS func noncopyableMakeMaybe(_ count: Int) -> UniqueArray? { + count < 0 ? nil : try! makeObjects(count) +} + +@JS func noncopyableVisitAll( + _ visitor: any NoncopyableObjectVisitor, + _ objects: borrowing UniqueArray +) -> Int { + visitor.visitAll(objects) +} + +@JS func noncopyableVisitorMakeAll( + _ visitor: any NoncopyableObjectVisitor, + _ count: Int +) -> UniqueArray { + visitor.makeAll(count) +} + +private func makeObjects(_ count: Int) throws(JSException) -> UniqueArray { + var objects = UniqueArray(capacity: count) + for i in 0..) -> [Int] { + objects.indices.map { (try? objects[$0].value()) ?? -1000 } +} + +private func values(of objects: borrowing UniqueArray) -> [Int] { + objects.indices.map { index in + switch objects[index] { + case .some(let object): (try? object.value()) ?? -1000 + case .none: -2 + } + } +} + +private func maybeValues(of objects: borrowing UniqueArray?) -> [Int]? { + switch objects { + case .some(let objects): values(of: objects) + case .none: nil + } +} + +/// The value `NoncopyableSource.takeAll` returns for objects with the values `0.. Int { + (0.. NoncopyableObject? { + if i % 2 == 0 { + return try NoncopyableObject(i) + } + return nil +} + +/// The value `NoncopyableSource.takeOptional` returns for `optionalObject(i)`. +private func optionalValue(_ i: Int) -> Int { + i % 2 == 0 ? i : -2 +} + +private final class Total { + var value = 0 +} + +@Suite struct NoncopyableJSClassSupportTests { + private func referencesKept(_ body: (Int) throws -> (Int, Int)) throws -> Int { + let before = try NoncopyableJSClassSupportImports.liveReferenceCount() + for i in 0..<100 { + let (actual, expected) = try body(i) + #expect(actual == expected) + } + return try NoncopyableJSClassSupportImports.liveReferenceCount() - before + } + + private func retainsMade(_ body: (Int) throws -> (Int, Int)) throws -> Int { + let before = try NoncopyableJSClassSupportImports.retainByRefCount() + for i in 0..<100 { + let (actual, expected) = try body(i) + #expect(actual == expected) + } + return try NoncopyableJSClassSupportImports.retainByRefCount() - before + } + + @Test func importedPositionsKeepNoReferences() throws { + let roundtrip = try NoncopyableObjectRoundtrip() + let copyable = try roundtrip.makeCopyable(3) + let object = try roundtrip.make(1) + var kept: [String: Int] = [:] + kept["borrowing parameter"] = try referencesKept { _ in (try roundtrip.take(object), 1) } + kept["return"] = try referencesKept { i in (try roundtrip.make(i).value(), i) } + kept["global function return"] = try referencesKept { i in (try noncopyableMakeObject(i).value(), i) } + kept["global function parameter"] = try referencesKept { _ in (try noncopyableUseObject(object), 1) } + kept["init"] = try referencesKept { i in (try NoncopyableObject(i).value(), i) } + kept["static method"] = try referencesKept { i in (try NoncopyableObject.create(i).value(), i) } + kept["getter function"] = try referencesKept { _ in (try roundtrip.child().value(), 42) } + kept["setter"] = try referencesKept { _ in + try roundtrip.setChild(object) + return (0, 0) + } + kept["consuming parameter"] = try referencesKept { i in (try roundtrip.adopt(try roundtrip.make(i)), i) } + kept["copyable class, noncopyable parameter"] = try referencesKept { _ in (try copyable.take(object), 1) } + kept["copyable class, noncopyable return"] = try referencesKept { i in (try copyable.make(i).value(), i) } + kept["noncopyable class, copyable parameter"] = try referencesKept { _ in + (try roundtrip.takeCopyable(copyable), 3) + } + kept["noncopyable class, copyable return"] = try referencesKept { i in + (try roundtrip.makeCopyable(i).value(), i) + } + kept["global getter function"] = try referencesKept { _ in (try noncopyableSharedObject().value(), 7) } + kept["withView"] = try referencesKept { _ in + let value = try object.withView(as: NoncopyableObjectView.self) { + (view: borrowing NoncopyableObjectView) throws(JSException) -> Int in try view.value() + } + return (value, 1) + } + kept["throwing call, borrowing parameter"] = try referencesKept { _ in + do { + return (try roundtrip.failTake(object), -1) + } catch { + return (0, 0) + } + } + kept["throwing call, noncopyable return"] = try referencesKept { _ in + do { + return (try roundtrip.failMake().value(), -1) + } catch { + return (0, 0) + } + } + #expect(kept.filter { $0.value != 0 } == [:]) + } + + @Test func importedClosureParametersKeepNoReferences() throws { + let source = try NoncopyableSource() + let total = Total() + var kept: [String: Int] = [:] + + let typed = JSTypedClosure<(borrowing NoncopyableObject) -> Void> { object in + total.value += (try? object.value()) ?? -1000 + } + kept["typed closure parameter"] = try referencesKept { _ in + try source.forEachObject(3, typed) + return (0, 0) + } + typed.release() + #expect(total.value == 300) + + total.value = 0 + kept["escaping closure parameter"] = try referencesKept { _ in + try source.forEachObjectEscaping(3) { object in total.value += (try? object.value()) ?? -1000 } + return (0, 0) + } + #expect(total.value == 300) + + total.value = 0 + kept["escaping closure parameter, copyable control"] = try referencesKept { _ in + try source.forEachCopyableEscaping(3) { copyable in total.value += (try? copyable.value()) ?? -1000 } + return (0, 0) + } + #expect(total.value == 300) + + #expect(kept.filter { $0.value != 0 } == [:]) + } + + /// Other tests change the global reference count while this one awaits. + @Test func importedAsyncPositionsKeepNoReferences() async throws { + let source = try NoncopyableSource() + let object = try NoncopyableObject(1) + var kept: [String: Int] = [:] + + for i in 0..<100 { + #expect(try await source.load(i).value() == i) + } + kept["async return"] = try source.referencesToCreated() + + for i in 0..<100 { + #expect(try await source.loadCopyable(i).value() == i) + } + kept["async return, copyable control"] = try source.referencesToCreated() + + for _ in 0..<100 { + await #expect(throws: JSException.self) { _ = try await source.loadFail() } + } + kept["async return, rejected"] = try source.referencesToCreated() + + let before = try source.referencesTo(object) + for _ in 0..<100 { + #expect(try await source.use(object) == 1) + } + kept["async borrowing parameter"] = try source.referencesTo(object) - before + kept["async borrowing parameter, resolve and reject"] = try source.referencesToCreated() + + for i in 0..<100 { + let start = i % 2 == 0 ? i : -1 + let value: Int? = + switch try await source.loadOptional(start) { + case .some(let object): try object.value() + case .none: nil + } + #expect(value == (start < 0 ? nil : i)) + } + kept["async optional return"] = try source.referencesToCreated() + + #expect(kept.filter { $0.value != 0 } == [:]) + } + + @Test func importedOptionalPositionsKeepNoReferences() throws { + let source = try NoncopyableSource() + var kept: [String: Int] = [:] + + kept["optional parameter"] = try referencesKept { i in + (try source.takeOptional(try optionalObject(i)), optionalValue(i)) + } + kept["optional return"] = try referencesKept { i in + switch try source.findOptional(i % 2 == 0 ? i : -1) { + case .some(let object): (try object.value(), optionalValue(i)) + case .none: (-2, optionalValue(i)) + } + } + kept["optional return passed back"] = try referencesKept { i in + let object = try source.findOptional(i % 2 == 0 ? i : -1) + return (try source.takeOptional(object), optionalValue(i)) + } + kept["optional return passed back, copyable control"] = try referencesKept { i in + let copyable = try source.findOptionalCopyable(i % 2 == 0 ? i : -1) + return (try source.takeOptionalCopyable(copyable), optionalValue(i)) + } + + let total = Total() + let typed = JSTypedClosure<(borrowing NoncopyableObject?) -> Void> { object in + switch object { + case .some(let object): total.value += (try? object.value()) ?? -1000 + case .none: total.value += 100 + } + } + kept["typed closure optional parameter"] = try referencesKept { _ in + try source.forEachOptional(3, typed) + return (0, 0) + } + typed.release() + #expect(total.value == 100 * (0 + 100 + 2)) + + kept["optional property getter and setter"] = try referencesKept { i in + try source.setOptionalChild(try optionalObject(i)) + switch try source.optionalChild() { + case .some(let child): return (try child.value(), optionalValue(i)) + case .none: return (-2, optionalValue(i)) + } + } + + kept["JSUniqueRef return, parameter and optional return"] = try referencesKept { i in + let ref = try source.raw(i) + #expect(try source.rawValue(ref) == i) + switch try source.maybeRaw(i % 2 == 0 ? i : -1) { + case .some(let ref): return (try source.rawValue(ref), optionalValue(i)) + case .none: return (-2, optionalValue(i)) + } + } + + #expect(kept.filter { $0.value != 0 } == [:]) + } + + @Test func conversionsFromJSObjectKeepNoReferences() throws { + let source = try NoncopyableSource() + let object = try source.rawObject(5) + var kept: [String: Int] = [:] + kept["init(unsafelyWrapping:)"] = try referencesKept { i in + (try NoncopyableObject(unsafelyWrapping: try source.rawObject(i)).value(), i) + } + kept["JSUniqueRef(retaining:) of a kept JSObject"] = try referencesKept { _ in + (try NoncopyableObject(unsafelyAdopting: JSUniqueRef(retaining: object)).value(), 5) + } + #expect(kept.filter { $0.value != 0 } == [:]) + } + + @Test func conversionsTakeOverUnsharedJSObjects() throws { + let source = try NoncopyableSource() + let kept = try source.rawObject(5) + var retains: [String: Int] = [:] + retains["temporary"] = try retainsMade { i in + (try NoncopyableObject(unsafelyWrapping: try source.rawObject(i)).value(), i) + } + retains["consumed local"] = try retainsMade { i in + let object = try source.rawObject(i) + return (try NoncopyableObject(unsafelyWrapping: consume object).value(), i) + } + retains["kept JSObject"] = try retainsMade { _ in + (try NoncopyableObject(unsafelyWrapping: kept).value(), 5) + } + #expect(retains == ["temporary": 0, "consumed local": 0, "kept JSObject": 100]) + } + + @Test func exportedPathsKeepNoReferences() async throws { + try await NoncopyableJSClassSupportImports.runNoncopyableExportedPathTests() + } + + #if compiler(>=6.4) + @Test func importedUniqueArrayPositionsKeepNoReferences() throws { + let source = try NoncopyableSource() + var kept: [String: Int] = [:] + + kept["parameter"] = try referencesKept { i in + let objects = try makeObjects(i % 5) + #expect(values(of: objects) == Array(0..<(i % 5))) + return (try source.takeAll(objects), weightedSum(i % 5)) + } + kept["return"] = try referencesKept { i in + let objects = try source.makeAll(i % 5) + #expect(values(of: objects) == Array(0..<(i % 5))) + return (objects.count, i % 5) + } + kept["return passed back"] = try referencesKept { i in + (try source.takeAll(try source.makeAll(i % 5)), weightedSum(i % 5)) + } + kept["optional elements, return and parameter"] = try referencesKept { i in + let objects = try source.makeAllOptional(i % 5) + let values = values(of: objects) + #expect(values == (0..<(i % 5)).map(optionalValue)) + return (try source.takeAllOptional(objects), values.reduce(0, +)) + } + kept["nested return"] = try referencesKept { i in + let grid = try source.makeGrid(i % 4) + for row in grid.indices { + #expect(values(of: grid[row]) == Array(0..) -> Void> { objects in + total.value += values(of: objects).reduce(0, +) + } + kept["typed closure parameter"] = try referencesKept { _ in + try source.forEachBatch(4, batch) + return (0, 0) + } + batch.release() + #expect(total.value == 100 * (0 + 0 + 1 + 0 + 1 + 2)) + + #expect(kept.filter { $0.value != 0 } == [:]) + } + + /// Other tests change the global reference count while this one awaits. + @Test func importedAsyncUniqueArrayPositionsKeepNoReferences() async throws { + let source = try NoncopyableSource() + var kept: [String: Int] = [:] + + for i in 0..<100 { + let objects = try await source.loadAll(i % 4) + #expect(values(of: objects) == Array(0..<(i % 4))) + } + kept["async UniqueArray return"] = try source.referencesToCreated() + + for i in 0..<100 { + let count = i % 2 == 0 ? i % 4 : -1 + let objects = try await source.loadMaybe(count) + #expect(maybeValues(of: objects) == (count < 0 ? nil : Array(0.. { return { + ...getNoncopyableJSClassSupportImports(importsContext), "jsRoundTripVoid": () => { return; },