diff --git a/Benchmarks/Sources/Generated/BridgeJS.swift b/Benchmarks/Sources/Generated/BridgeJS.swift index 515d3a531..e4e147f5b 100644 --- a/Benchmarks/Sources/Generated/BridgeJS.swift +++ b/Benchmarks/Sources/Generated/BridgeJS.swift @@ -1762,11 +1762,7 @@ public func _bjs_ArrayRoundtrip_makeOptionalPointArray(_ _self: UnsafeMutableRaw #if arch(wasm32) let ret = ArrayRoundtrip.bridgeJSLiftParameter(_self).makeOptionalPointArray() for __bjs_elem_ret in ret { - let __bjs_isSome_ret_elem = __bjs_elem_ret != nil - if let __bjs_unwrapped_ret_elem = __bjs_elem_ret { - __bjs_unwrapped_ret_elem.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_ret_elem ? 1 : 0) + __bjs_elem_ret.bridgeJSLowerReturn() } _swift_js_push_i32(Int32(ret.count)) #else @@ -1789,11 +1785,7 @@ public func _bjs_ArrayRoundtrip_roundtripOptionalPointArray(_ _self: UnsafeMutab return __result }()) for __bjs_elem_ret in ret { - let __bjs_isSome_ret_elem = __bjs_elem_ret != nil - if let __bjs_unwrapped_ret_elem = __bjs_elem_ret { - __bjs_unwrapped_ret_elem.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_ret_elem ? 1 : 0) + __bjs_elem_ret.bridgeJSLowerReturn() } _swift_js_push_i32(Int32(ret.count)) #else @@ -1803,15 +1795,9 @@ public func _bjs_ArrayRoundtrip_roundtripOptionalPointArray(_ _self: UnsafeMutab @_expose(wasm, "bjs_ArrayRoundtrip_takeOptionalArray") @_cdecl("bjs_ArrayRoundtrip_takeOptionalArray") -public func _bjs_ArrayRoundtrip_takeOptionalArray(_ _self: UnsafeMutableRawPointer, _ values: Int32) -> Void { +public func _bjs_ArrayRoundtrip_takeOptionalArray(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - ArrayRoundtrip.bridgeJSLiftParameter(_self).takeOptionalArray(_: { - if values == 0 { - return Optional<[Int]>.none - } else { - return [Int].bridgeJSLiftParameter() - } - }()) + ArrayRoundtrip.bridgeJSLiftParameter(_self).takeOptionalArray(_: Optional<[Int]>.bridgeJSLiftParameter()) #else fatalError("Only available on WebAssembly") #endif @@ -1822,11 +1808,7 @@ public func _bjs_ArrayRoundtrip_takeOptionalArray(_ _self: UnsafeMutableRawPoint public func _bjs_ArrayRoundtrip_makeOptionalArraySome(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) let ret = ArrayRoundtrip.bridgeJSLiftParameter(_self).makeOptionalArraySome() - let __bjs_isSome_ret = ret != nil - if let __bjs_unwrapped_ret = ret { - __bjs_unwrapped_ret.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_ret ? 1 : 0) + ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -1837,11 +1819,7 @@ public func _bjs_ArrayRoundtrip_makeOptionalArraySome(_ _self: UnsafeMutableRawP public func _bjs_ArrayRoundtrip_makeOptionalArrayNone(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) let ret = ArrayRoundtrip.bridgeJSLiftParameter(_self).makeOptionalArrayNone() - let __bjs_isSome_ret = ret != nil - if let __bjs_unwrapped_ret = ret { - __bjs_unwrapped_ret.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_ret ? 1 : 0) + ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -1849,20 +1827,10 @@ public func _bjs_ArrayRoundtrip_makeOptionalArrayNone(_ _self: UnsafeMutableRawP @_expose(wasm, "bjs_ArrayRoundtrip_roundtripOptionalArray") @_cdecl("bjs_ArrayRoundtrip_roundtripOptionalArray") -public func _bjs_ArrayRoundtrip_roundtripOptionalArray(_ _self: UnsafeMutableRawPointer, _ values: Int32) -> Void { +public func _bjs_ArrayRoundtrip_roundtripOptionalArray(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = ArrayRoundtrip.bridgeJSLiftParameter(_self).roundtripOptionalArray(_: { - if values == 0 { - return Optional<[Int]>.none - } else { - return [Int].bridgeJSLiftParameter() - } - }()) - let __bjs_isSome_ret = ret != nil - if let __bjs_unwrapped_ret = ret { - __bjs_unwrapped_ret.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_ret ? 1 : 0) + let ret = ArrayRoundtrip.bridgeJSLiftParameter(_self).roundtripOptionalArray(_: Optional<[Int]>.bridgeJSLiftParameter()) + ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift index 2d31cd212..b75f9535d 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift @@ -147,27 +147,7 @@ public class ExportSwift { } else { optionalSwiftType = "JSUndefinedOr" } - if case .array(let elementType) = wrappedType { - let arrayLift = StackCodegen().liftArrayExpression(elementType: elementType) - let isSomeParam = argumentsToLift[0] - let swiftTypeName = elementType.swiftType - typeNameForIntrinsic = "\(optionalSwiftType)<[\(swiftTypeName)]>" - let absentExpr = - kind == .null - ? "\(optionalSwiftType)<[\(swiftTypeName)]>.none" - : "\(optionalSwiftType)<[\(swiftTypeName)]>.undefined" - liftingExpr = ExprSyntax( - """ - { - if \(raw: isSomeParam) == 0 { - return \(raw: absentExpr) - } else { - return \(arrayLift) - } - }() - """ - ) - } else if case .swiftProtocol(let protocolName) = wrappedType { + if case .swiftProtocol(let protocolName) = wrappedType { let wrapperName = "Any\(protocolName)" typeNameForIntrinsic = "\(optionalSwiftType)<\(wrapperName)>" liftingExpr = ExprSyntax( @@ -919,43 +899,11 @@ struct StackCodegen { let typeName = kind == .null ? "Optional" : "JSUndefinedOr" switch wrappedType { case .string, .int, .uint, .bool, .float, .double, .jsObject(nil), .jsValue, - .swiftStruct, .swiftHeapObject, .caseEnum, .associatedValueEnum, .rawValueEnum: + .swiftStruct, .swiftHeapObject, .caseEnum, .associatedValueEnum, .rawValueEnum, + .array, .dictionary: return "\(raw: typeName)<\(raw: wrappedType.swiftType)>.bridgeJSLiftParameter()" case .jsObject(let className?): return "\(raw: typeName).bridgeJSLiftParameter().map { \(raw: className)(unsafelyWrapping: $0) }" - case .array(let elementType): - let arrayLift = liftArrayExpression(elementType: elementType) - let swiftTypeName = elementType.swiftType - let absentExpr = - kind == .null - ? "\(typeName)<[\(swiftTypeName)]>.none" : "\(typeName)<[\(swiftTypeName)]>.undefined" - return """ - { - let __isSome = _swift_js_pop_i32() - if __isSome == 0 { - return \(raw: absentExpr) - } else { - return \(arrayLift) - } - }() - """ - case .dictionary(let valueType): - let dictionaryLift = liftDictionaryExpression(valueType: valueType) - let swiftTypeName = valueType.swiftType - let absentExpr = - kind == .null - ? "\(typeName)<[String: \(swiftTypeName)]>.none" - : "\(typeName)<[String: \(swiftTypeName)]>.undefined" - return """ - { - let __isSome = _swift_js_pop_i32() - if __isSome == 0 { - return \(raw: absentExpr) - } else { - return \(dictionaryLift) - } - }() - """ case .nullable, .void, .namespaceEnum, .closure, .unsafePointer, .swiftProtocol: fatalError("Invalid nullable wrapped type: \(wrappedType)") } @@ -1112,6 +1060,13 @@ struct StackCodegen { accessor: String, varPrefix: String ) -> [CodeBlockItemSyntax] { + switch wrappedType { + case .array, .dictionary, .swiftStruct: + return ["\(raw: accessor).bridgeJSLowerReturn()"] + default: + break + } + var statements: [String] = [] statements.append("let __bjs_isSome_\(varPrefix) = \(accessor) != nil") statements.append("if let __bjs_unwrapped_\(varPrefix) = \(accessor) {") @@ -1140,23 +1095,15 @@ struct StackCodegen { case .string, .int, .uint, .bool, .float, .double, .jsValue: return ["\(raw: unwrappedVar).bridgeJSLowerStackReturn()"] case .caseEnum, .rawValueEnum: - // Enums conform to _BridgedSwiftStackType return ["\(raw: unwrappedVar).bridgeJSLowerStackReturn()"] - case .swiftStruct: - return ["\(raw: unwrappedVar).bridgeJSLowerReturn()"] case .swiftHeapObject: return ["\(raw: unwrappedVar).bridgeJSLowerStackReturn()"] case .associatedValueEnum: - // Push payloads via bridgeJSLowerParameter(), then push the returned case ID return ["_swift_js_push_i32(\(raw: unwrappedVar).bridgeJSLowerParameter())"] case .jsObject(nil): return ["\(raw: unwrappedVar).bridgeJSLowerStackReturn()"] case .jsObject(_?): return ["\(raw: unwrappedVar).jsObject.bridgeJSLowerStackReturn()"] - case .array(let elementType): - return lowerArrayStatements(elementType: elementType, accessor: unwrappedVar, varPrefix: varPrefix) - case .dictionary(let valueType): - return lowerDictionaryStatements(valueType: valueType, accessor: unwrappedVar, varPrefix: varPrefix) default: return ["preconditionFailure(\"BridgeJS: unsupported optional wrapped type\")"] } @@ -1834,8 +1781,12 @@ extension BridgeType { case .swiftProtocol: return .jsObject case .void: return .void case .nullable(let wrappedType, _): + let wrappedInfo = try wrappedType.liftParameterInfo() + if wrappedInfo.parameters.isEmpty { + return LiftingIntrinsicInfo(parameters: []) + } var optionalParams: [(name: String, type: WasmCoreType)] = [("isSome", .i32)] - optionalParams.append(contentsOf: try wrappedType.liftParameterInfo().parameters) + optionalParams.append(contentsOf: wrappedInfo.parameters) return LiftingIntrinsicInfo(parameters: optionalParams) case .caseEnum: return .caseEnum case .rawValueEnum(_, let rawType): diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift index 9f1eddfdd..1e384d833 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift @@ -832,7 +832,8 @@ struct IntrinsicJSFragment: Sendable { } printer.write("}") cleanupCode.write("if (\(cleanupVar)) { \(cleanupVar)(); }") - return ["+\(isSomeVar)"] + printer.write("\(JSGlueVariableScope.reservedI32Stack).push(+\(isSomeVar));") + return [] case .string, .rawValueEnum(_, .string): let bytesVar = scope.variable("\(value)Bytes") let idVar = scope.variable("\(value)Id") @@ -895,7 +896,8 @@ struct IntrinsicJSFragment: Sendable { } printer.write("}") cleanupCode.write("for (const cleanup of \(cleanupArrayVar)) { cleanup(); }") - return ["+\(isSomeVar)"] + printer.write("\(JSGlueVariableScope.reservedI32Stack).push(+\(isSomeVar));") + return [] case .dictionary(let valueType): let cleanupArrayVar = scope.variable("\(value)Cleanups") printer.write("const \(cleanupArrayVar) = [];") @@ -915,7 +917,8 @@ struct IntrinsicJSFragment: Sendable { } printer.write("}") cleanupCode.write("for (const cleanup of \(cleanupArrayVar)) { cleanup(); }") - return ["+\(isSomeVar)"] + printer.write("\(JSGlueVariableScope.reservedI32Stack).push(+\(isSomeVar));") + return [] default: switch wrappedType { case .swiftHeapObject: diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ArrayTypes.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ArrayTypes.swift index 261c0b066..243c99b7c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ArrayTypes.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ArrayTypes.swift @@ -277,20 +277,10 @@ public func _bjs_processOptionalStringArray() -> Void { @_expose(wasm, "bjs_processOptionalArray") @_cdecl("bjs_processOptionalArray") -public func _bjs_processOptionalArray(_ values: Int32) -> Void { +public func _bjs_processOptionalArray() -> Void { #if arch(wasm32) - let ret = processOptionalArray(_: { - if values == 0 { - return Optional<[Int]>.none - } else { - return [Int].bridgeJSLiftParameter() - } - }()) - let __bjs_isSome_ret = ret != nil - if let __bjs_unwrapped_ret = ret { - __bjs_unwrapped_ret.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_ret ? 1 : 0) + let ret = processOptionalArray(_: Optional<[Int]>.bridgeJSLiftParameter()) + ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -311,11 +301,7 @@ public func _bjs_processOptionalPointArray() -> Void { return __result }()) for __bjs_elem_ret in ret { - let __bjs_isSome_ret_elem = __bjs_elem_ret != nil - if let __bjs_unwrapped_ret_elem = __bjs_elem_ret { - __bjs_unwrapped_ret_elem.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_ret_elem ? 1 : 0) + __bjs_elem_ret.bridgeJSLowerReturn() } _swift_js_push_i32(Int32(ret.count)) #else diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DefaultParameters.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DefaultParameters.swift index 4c4c69c99..16cae49e8 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DefaultParameters.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DefaultParameters.swift @@ -294,9 +294,9 @@ public func _bjs_testEmptyInit(_ greeter: UnsafeMutableRawPointer) -> UnsafeMuta @_expose(wasm, "bjs_testOptionalStructDefault") @_cdecl("bjs_testOptionalStructDefault") -public func _bjs_testOptionalStructDefault(_ point: Int32) -> Void { +public func _bjs_testOptionalStructDefault() -> Void { #if arch(wasm32) - let ret = testOptionalStructDefault(point: Optional.bridgeJSLiftParameter(point)) + let ret = testOptionalStructDefault(point: Optional.bridgeJSLiftParameter()) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") @@ -305,9 +305,9 @@ public func _bjs_testOptionalStructDefault(_ point: Int32) -> Void { @_expose(wasm, "bjs_testOptionalStructWithValueDefault") @_cdecl("bjs_testOptionalStructWithValueDefault") -public func _bjs_testOptionalStructWithValueDefault(_ point: Int32) -> Void { +public func _bjs_testOptionalStructWithValueDefault() -> Void { #if arch(wasm32) - let ret = testOptionalStructWithValueDefault(point: Optional.bridgeJSLiftParameter(point)) + let ret = testOptionalStructWithValueDefault(point: Optional.bridgeJSLiftParameter()) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DictionaryTypes.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DictionaryTypes.swift index 2a41c35a7..016a5f814 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DictionaryTypes.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DictionaryTypes.swift @@ -11,9 +11,9 @@ public func _bjs_mirrorDictionary() -> Void { @_expose(wasm, "bjs_optionalDictionary") @_cdecl("bjs_optionalDictionary") -public func _bjs_optionalDictionary(_ values: Int32) -> Void { +public func _bjs_optionalDictionary() -> Void { #if arch(wasm32) - let ret = optionalDictionary(_: Optional<[String: String]>.bridgeJSLiftParameter(values)) + let ret = optionalDictionary(_: Optional<[String: String]>.bridgeJSLiftParameter()) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAssociatedValue.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAssociatedValue.swift index f2029749c..a21c766c0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAssociatedValue.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAssociatedValue.swift @@ -617,14 +617,7 @@ extension OptionalAllTypesResult: _BridgedSwiftAssociatedValueEnum { case 3: return .optNestedEnum(Optional.bridgeJSLiftParameter()) case 4: - return .optArray({ - let __isSome = _swift_js_pop_i32() - if __isSome == 0 { - return Optional<[Int]>.none - } else { - return [Int].bridgeJSLiftParameter() - } -}()) + return .optArray(Optional<[Int]>.bridgeJSLiftParameter()) case 5: return .empty default: @@ -637,11 +630,7 @@ extension OptionalAllTypesResult: _BridgedSwiftAssociatedValueEnum { @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { switch self { case .optStruct(let param0): - let __bjs_isSome_param0 = param0 != nil - if let __bjs_unwrapped_param0 = param0 { - __bjs_unwrapped_param0.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_param0 ? 1 : 0) + param0.bridgeJSLowerReturn() return Int32(0) case .optClass(let param0): let __bjs_isSome_param0 = param0 != nil @@ -665,11 +654,7 @@ extension OptionalAllTypesResult: _BridgedSwiftAssociatedValueEnum { _swift_js_push_i32(__bjs_isSome_param0 ? 1 : 0) return Int32(3) case .optArray(let param0): - let __bjs_isSome_param0 = param0 != nil - if let __bjs_unwrapped_param0 = param0 { - __bjs_unwrapped_param0.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_param0 ? 1 : 0) + param0.bridgeJSLowerReturn() return Int32(4) case .empty: return Int32(5) @@ -689,11 +674,7 @@ extension OptionalAllTypesResult: _BridgedSwiftAssociatedValueEnum { @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() { switch self { case .optStruct(let param0): - let __bjs_isSome_param0 = param0 != nil - if let __bjs_unwrapped_param0 = param0 { - __bjs_unwrapped_param0.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_param0 ? 1 : 0) + param0.bridgeJSLowerReturn() _swift_js_push_tag(Int32(0)) case .optClass(let param0): let __bjs_isSome_param0 = param0 != nil @@ -717,11 +698,7 @@ extension OptionalAllTypesResult: _BridgedSwiftAssociatedValueEnum { _swift_js_push_i32(__bjs_isSome_param0 ? 1 : 0) _swift_js_push_tag(Int32(3)) case .optArray(let param0): - let __bjs_isSome_param0 = param0 != nil - if let __bjs_unwrapped_param0 = param0 { - __bjs_unwrapped_param0.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_param0 ? 1 : 0) + param0.bridgeJSLowerReturn() _swift_js_push_tag(Int32(4)) case .empty: _swift_js_push_tag(Int32(5)) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/JSValue.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/JSValue.swift index b4e45bbc9..931605a50 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/JSValue.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/JSValue.swift @@ -33,20 +33,10 @@ public func _bjs_roundTripJSValueArray() -> Void { @_expose(wasm, "bjs_roundTripOptionalJSValueArray") @_cdecl("bjs_roundTripOptionalJSValueArray") -public func _bjs_roundTripOptionalJSValueArray(_ values: Int32) -> Void { +public func _bjs_roundTripOptionalJSValueArray() -> Void { #if arch(wasm32) - let ret = roundTripOptionalJSValueArray(_: { - if values == 0 { - return Optional<[JSValue]>.none - } else { - return [JSValue].bridgeJSLiftParameter() - } - }()) - let __bjs_isSome_ret = ret != nil - if let __bjs_unwrapped_ret = ret { - __bjs_unwrapped_ret.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_ret ? 1 : 0) + let ret = roundTripOptionalJSValueArray(_: Optional<[JSValue]>.bridgeJSLiftParameter()) + ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js index d858d8e38..a381f5569 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js @@ -673,7 +673,8 @@ export async function createInstantiator(options, swift) { i32Stack.push(values.length); valuesCleanups.push(() => { for (const cleanup of arrayCleanups) { cleanup(); } }); } - instance.exports.bjs_processOptionalArray(+isSome); + i32Stack.push(+isSome); + instance.exports.bjs_processOptionalArray(); const isSome1 = i32Stack.pop(); let optResult; if (isSome1) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js index 079618bbf..04335c58c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js @@ -521,7 +521,8 @@ export async function createInstantiator(options, swift) { const structResult = structHelpers.Config.lower(point); pointCleanup = structResult.cleanup; } - instance.exports.bjs_testOptionalStructDefault(+isSome); + i32Stack.push(+isSome); + instance.exports.bjs_testOptionalStructDefault(); const isSome1 = i32Stack.pop(); let optResult; if (isSome1) { @@ -539,7 +540,8 @@ export async function createInstantiator(options, swift) { const structResult = structHelpers.Config.lower(point); pointCleanup = structResult.cleanup; } - instance.exports.bjs_testOptionalStructWithValueDefault(+isSome); + i32Stack.push(+isSome); + instance.exports.bjs_testOptionalStructWithValueDefault(); const isSome1 = i32Stack.pop(); let optResult; if (isSome1) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js index 54f00021d..a77407eca 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js @@ -327,7 +327,8 @@ export async function createInstantiator(options, swift) { i32Stack.push(entries.length); valuesCleanups.push(() => { for (const cleanup of arrayCleanups) { cleanup(); } }); } - instance.exports.bjs_optionalDictionary(+isSome); + i32Stack.push(+isSome); + instance.exports.bjs_optionalDictionary(); const isSome1 = i32Stack.pop(); let optResult; if (isSome1) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js index 888a11a4c..f6e4bf8aa 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js @@ -507,7 +507,8 @@ export async function createInstantiator(options, swift) { i32Stack.push(values.length); valuesCleanups.push(() => { for (const cleanup of arrayCleanups) { cleanup(); } }); } - instance.exports.bjs_roundTripOptionalJSValueArray(+isSome); + i32Stack.push(+isSome); + instance.exports.bjs_roundTripOptionalJSValueArray(); const isSome1 = i32Stack.pop(); let optResult; if (isSome1) { diff --git a/Sources/JavaScriptKit/BridgeJSIntrinsics.swift b/Sources/JavaScriptKit/BridgeJSIntrinsics.swift index 496b515c9..d1390a610 100644 --- a/Sources/JavaScriptKit/BridgeJSIntrinsics.swift +++ b/Sources/JavaScriptKit/BridgeJSIntrinsics.swift @@ -623,7 +623,7 @@ extension _BridgedSwiftAssociatedValueEnum { /// A protocol that Swift struct types conform to. /// /// The conformance is automatically synthesized by the BridgeJS code generator. -public protocol _BridgedSwiftStruct: _BridgedSwiftTypeLoweredIntoVoidType, _BridgedSwiftStackType { +public protocol _BridgedSwiftStruct: _BridgedSwiftTypeLoweredIntoVoidType, _BridgedSwiftGenericOptionalStackType { // MARK: ExportSwift @_spi(BridgeJS) static func bridgeJSLiftParameter() -> Self @_spi(BridgeJS) consuming func bridgeJSLowerReturn() -> Void @@ -1463,11 +1463,6 @@ extension Optional where Wrapped == [JSValue] { return [JSValue].bridgeJSLiftParameter() } - @_spi(BridgeJS) public static func bridgeJSLiftParameter() -> [JSValue]? { - let isSome = _swift_js_pop_i32() - return bridgeJSLiftParameter(isSome) - } - @_spi(BridgeJS) public static func bridgeJSLiftReturn() -> [JSValue]? { let isSome = _swift_js_pop_i32() if isSome == 0 { @@ -1741,17 +1736,6 @@ public protocol _BridgedSwiftTypeLoweredIntoVoidType { consuming func bridgeJSLowerReturn() -> Void } -extension Optional where Wrapped: _BridgedSwiftTypeLoweredIntoVoidType { - @_spi(BridgeJS) public consuming func bridgeJSLowerReturn() -> Void { - switch consume self { - case .none: - () - case .some(let value): - value.bridgeJSLowerReturn() - } - } -} - // MARK: Optional Raw Value Enum Support extension Optional where Wrapped: _BridgedSwiftEnumNoPayload, Wrapped: RawRepresentable, Wrapped.RawValue == String { @@ -1989,8 +1973,6 @@ extension Optional where Wrapped: _BridgedSwiftAssociatedValueEnum { // MARK: Optional Struct Support extension Optional where Wrapped: _BridgedSwiftStruct { - // MARK: ExportSwift - @_spi(BridgeJS) public static func bridgeJSLiftParameter(_ isSome: Int32) -> Wrapped? { if isSome == 0 { return nil @@ -1998,19 +1980,40 @@ extension Optional where Wrapped: _BridgedSwiftStruct { return Wrapped.bridgeJSLiftParameter() } } +} + +// MARK: - Generic Optional Stack Support + +/// Marker protocol for types whose Optional wrapper should use the generic +/// stack-based ABI (`_BridgedSwiftStackType`). Only Array, Dictionary, and +/// `_BridgedSwiftStruct` conform. Primitives and other types keep their +/// own type-specific Optional extensions. +public protocol _BridgedSwiftGenericOptionalStackType: _BridgedSwiftStackType +where StackLiftResult == Self {} + +extension Optional: _BridgedSwiftStackType +where Wrapped: _BridgedSwiftGenericOptionalStackType { + public typealias StackLiftResult = Wrapped? @_spi(BridgeJS) public static func bridgeJSLiftParameter() -> Wrapped? { let isSome = _swift_js_pop_i32() - return bridgeJSLiftParameter(isSome) + if isSome == 0 { + return nil + } + return Wrapped.bridgeJSLiftParameter() + } + + @_spi(BridgeJS) public consuming func bridgeJSLowerStackReturn() { + bridgeJSLowerReturn() } @_spi(BridgeJS) public consuming func bridgeJSLowerReturn() -> Void { switch consume self { case .none: - _swift_js_push_i32(0) // Push only isSome=0 (no struct fields) + _swift_js_push_i32(0) case .some(let value): - value.bridgeJSLowerReturn() // Push all struct fields FIRST - _swift_js_push_i32(1) // Then push isSome=1 LAST (so it's popped FIRST by JS) + value.bridgeJSLowerStackReturn() + _swift_js_push_i32(1) } } } @@ -2235,12 +2238,6 @@ extension _BridgedAsOptional where Wrapped: _BridgedSwiftCaseEnum { } } -extension _BridgedAsOptional where Wrapped: _BridgedSwiftTypeLoweredIntoVoidType { - @_spi(BridgeJS) public consuming func bridgeJSLowerReturn() -> Void { - asOptional.bridgeJSLowerReturn() - } -} - extension _BridgedAsOptional where Wrapped: _BridgedSwiftEnumNoPayload, Wrapped: RawRepresentable, Wrapped.RawValue == String { @_spi(BridgeJS) public consuming func bridgeJSLowerParameter() -> (isSome: Int32, value: Int32) { @@ -2390,6 +2387,8 @@ extension _BridgedAsOptional where Wrapped: _BridgedSwiftStruct { // MARK: - Array Support +extension Array: _BridgedSwiftGenericOptionalStackType +where Element: _BridgedSwiftStackType, Element.StackLiftResult == Element {} extension Array: _BridgedSwiftStackType where Element: _BridgedSwiftStackType, Element.StackLiftResult == Element { public typealias StackLiftResult = [Element] @@ -2427,11 +2426,15 @@ extension Array: _BridgedSwiftStackType where Element: _BridgedSwiftStackType, E // MARK: - Dictionary Support -public protocol _BridgedSwiftDictionaryStackType: _BridgedSwiftTypeLoweredIntoVoidType { +public protocol _BridgedSwiftDictionaryStackType: _BridgedSwiftTypeLoweredIntoVoidType, + _BridgedSwiftGenericOptionalStackType +{ associatedtype DictionaryValue: _BridgedSwiftStackType where DictionaryValue.StackLiftResult == DictionaryValue } +extension Dictionary: _BridgedSwiftGenericOptionalStackType +where Key == String, Value: _BridgedSwiftStackType, Value.StackLiftResult == Value {} extension Dictionary: _BridgedSwiftStackType where Key == String, Value: _BridgedSwiftStackType, Value.StackLiftResult == Value { public typealias StackLiftResult = [String: Value] @@ -2492,16 +2495,6 @@ extension Optional where Wrapped: _BridgedSwiftDictionaryStackType { } } - @_spi(BridgeJS) public consuming func bridgeJSLowerReturn() { - switch consume self { - case .none: - _swift_js_push_i32(0) - case .some(let dict): - dict.bridgeJSLowerReturn() - _swift_js_push_i32(1) - } - } - @_spi(BridgeJS) public static func bridgeJSLiftParameter(_ isSome: Int32) -> [String: Wrapped.DictionaryValue]? { if isSome == 0 { return nil @@ -2509,10 +2502,6 @@ extension Optional where Wrapped: _BridgedSwiftDictionaryStackType { return Dictionary.bridgeJSLiftParameter() } - @_spi(BridgeJS) public static func bridgeJSLiftParameter() -> [String: Wrapped.DictionaryValue]? { - bridgeJSLiftParameter(_swift_js_pop_i32()) - } - @_spi(BridgeJS) public static func bridgeJSLiftReturn() -> [String: Wrapped.DictionaryValue]? { let isSome = _swift_js_pop_i32() if isSome == 0 { @@ -2542,4 +2531,8 @@ extension _BridgedAsOptional where Wrapped: _BridgedSwiftDictionaryStackType { let value = Dictionary.bridgeJSLiftParameter() as! Wrapped return Self(optional: value) } + + @_spi(BridgeJS) public consuming func bridgeJSLowerReturn() -> Void { + asOptional.bridgeJSLowerReturn() + } } diff --git a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift index af9f15dbc..9465040a9 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift +++ b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift @@ -2814,14 +2814,7 @@ extension OptionalAllTypesResult: _BridgedSwiftAssociatedValueEnum { case 3: return .optNestedEnum(Optional.bridgeJSLiftParameter()) case 4: - return .optArray({ - let __isSome = _swift_js_pop_i32() - if __isSome == 0 { - return Optional<[Int]>.none - } else { - return [Int].bridgeJSLiftParameter() - } -}()) + return .optArray(Optional<[Int]>.bridgeJSLiftParameter()) case 5: return .optJsClass(Optional.bridgeJSLiftParameter().map { Foo(unsafelyWrapping: $0) }) case 6: @@ -2836,11 +2829,7 @@ extension OptionalAllTypesResult: _BridgedSwiftAssociatedValueEnum { @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { switch self { case .optStruct(let param0): - let __bjs_isSome_param0 = param0 != nil - if let __bjs_unwrapped_param0 = param0 { - __bjs_unwrapped_param0.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_param0 ? 1 : 0) + param0.bridgeJSLowerReturn() return Int32(0) case .optClass(let param0): let __bjs_isSome_param0 = param0 != nil @@ -2864,11 +2853,7 @@ extension OptionalAllTypesResult: _BridgedSwiftAssociatedValueEnum { _swift_js_push_i32(__bjs_isSome_param0 ? 1 : 0) return Int32(3) case .optArray(let param0): - let __bjs_isSome_param0 = param0 != nil - if let __bjs_unwrapped_param0 = param0 { - __bjs_unwrapped_param0.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_param0 ? 1 : 0) + param0.bridgeJSLowerReturn() return Int32(4) case .optJsClass(let param0): let __bjs_isSome_param0 = param0 != nil @@ -2895,11 +2880,7 @@ extension OptionalAllTypesResult: _BridgedSwiftAssociatedValueEnum { @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() { switch self { case .optStruct(let param0): - let __bjs_isSome_param0 = param0 != nil - if let __bjs_unwrapped_param0 = param0 { - __bjs_unwrapped_param0.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_param0 ? 1 : 0) + param0.bridgeJSLowerReturn() _swift_js_push_tag(Int32(0)) case .optClass(let param0): let __bjs_isSome_param0 = param0 != nil @@ -2923,11 +2904,7 @@ extension OptionalAllTypesResult: _BridgedSwiftAssociatedValueEnum { _swift_js_push_i32(__bjs_isSome_param0 ? 1 : 0) _swift_js_push_tag(Int32(3)) case .optArray(let param0): - let __bjs_isSome_param0 = param0 != nil - if let __bjs_unwrapped_param0 = param0 { - __bjs_unwrapped_param0.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_param0 ? 1 : 0) + param0.bridgeJSLowerReturn() _swift_js_push_tag(Int32(4)) case .optJsClass(let param0): let __bjs_isSome_param0 = param0 != nil @@ -3298,11 +3275,7 @@ extension Contact: _BridgedSwiftStruct { __bjs_unwrapped_email.bridgeJSLowerStackReturn() } _swift_js_push_i32(__bjs_isSome_email ? 1 : 0) - let __bjs_isSome_secondaryAddress = self.secondaryAddress != nil - if let __bjs_unwrapped_secondaryAddress = self.secondaryAddress { - __bjs_unwrapped_secondaryAddress.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_secondaryAddress ? 1 : 0) + self.secondaryAddress.bridgeJSLowerReturn() } init(unsafelyCopying jsObject: JSObject) { @@ -3532,17 +3505,9 @@ extension AdvancedConfig: _BridgedSwiftStruct { __bjs_unwrapped_metadata.bridgeJSLowerStackReturn() } _swift_js_push_i32(__bjs_isSome_metadata ? 1 : 0) - let __bjs_isSome_location = self.location != nil - if let __bjs_unwrapped_location = self.location { - __bjs_unwrapped_location.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_location ? 1 : 0) + self.location.bridgeJSLowerReturn() self.defaults.bridgeJSLowerReturn() - let __bjs_isSome_overrideDefaults = self.overrideDefaults != nil - if let __bjs_unwrapped_overrideDefaults = self.overrideDefaults { - __bjs_unwrapped_overrideDefaults.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_overrideDefaults ? 1 : 0) + self.overrideDefaults.bridgeJSLowerReturn() } init(unsafelyCopying jsObject: JSObject) { @@ -3838,11 +3803,7 @@ extension CopyableNestedCart: _BridgedSwiftStruct { @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() { self.id.bridgeJSLowerStackReturn() self.item.bridgeJSLowerReturn() - let __bjs_isSome_shippingAddress = self.shippingAddress != nil - if let __bjs_unwrapped_shippingAddress = self.shippingAddress { - __bjs_unwrapped_shippingAddress.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_shippingAddress ? 1 : 0) + self.shippingAddress.bridgeJSLowerReturn() } init(unsafelyCopying jsObject: JSObject) { @@ -4098,25 +4059,14 @@ fileprivate func _bjs_struct_lift_FooContainer() -> Int32 { extension ArrayMembers: _BridgedSwiftStruct { @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter() -> ArrayMembers { - let optStrings = { - let __isSome = _swift_js_pop_i32() - if __isSome == 0 { - return Optional<[String]>.none - } else { - return [String].bridgeJSLiftParameter() - } -}() + let optStrings = Optional<[String]>.bridgeJSLiftParameter() let ints = [Int].bridgeJSLiftParameter() return ArrayMembers(ints: ints, optStrings: optStrings) } @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() { self.ints.bridgeJSLowerReturn() - let __bjs_isSome_optStrings = self.optStrings != nil - if let __bjs_unwrapped_optStrings = self.optStrings { - __bjs_unwrapped_optStrings.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_optStrings ? 1 : 0) + self.optStrings.bridgeJSLowerReturn() } init(unsafelyCopying jsObject: JSObject) { @@ -4340,9 +4290,9 @@ public func _bjs_roundTripDictionaryExport() -> Void { @_expose(wasm, "bjs_roundTripOptionalDictionaryExport") @_cdecl("bjs_roundTripOptionalDictionaryExport") -public func _bjs_roundTripOptionalDictionaryExport(_ v: Int32) -> Void { +public func _bjs_roundTripOptionalDictionaryExport() -> Void { #if arch(wasm32) - let ret = roundTripOptionalDictionaryExport(v: Optional<[String: String]>.bridgeJSLiftParameter(v)) + let ret = roundTripOptionalDictionaryExport(v: Optional<[String: String]>.bridgeJSLiftParameter()) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") @@ -4384,20 +4334,10 @@ public func _bjs_roundTripJSValueArray() -> Void { @_expose(wasm, "bjs_roundTripOptionalJSValueArray") @_cdecl("bjs_roundTripOptionalJSValueArray") -public func _bjs_roundTripOptionalJSValueArray(_ v: Int32) -> Void { +public func _bjs_roundTripOptionalJSValueArray() -> Void { #if arch(wasm32) - let ret = roundTripOptionalJSValueArray(v: { - if v == 0 { - return Optional<[JSValue]>.none - } else { - return [JSValue].bridgeJSLiftParameter() - } - }()) - let __bjs_isSome_ret = ret != nil - if let __bjs_unwrapped_ret = ret { - __bjs_unwrapped_ret.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_ret ? 1 : 0) + let ret = roundTripOptionalJSValueArray(v: Optional<[JSValue]>.bridgeJSLiftParameter()) + ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -5413,15 +5353,9 @@ public func _bjs_arrayWithDefault() -> Int32 { @_expose(wasm, "bjs_arrayWithOptionalDefault") @_cdecl("bjs_arrayWithOptionalDefault") -public func _bjs_arrayWithOptionalDefault(_ values: Int32) -> Int32 { +public func _bjs_arrayWithOptionalDefault() -> Int32 { #if arch(wasm32) - let ret = arrayWithOptionalDefault(_: { - if values == 0 { - return Optional<[Int]>.none - } else { - return [Int].bridgeJSLiftParameter() - } - }()) + let ret = arrayWithOptionalDefault(_: Optional<[Int]>.bridgeJSLiftParameter()) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") @@ -5651,11 +5585,7 @@ public func _bjs_roundTripOptionalDataPointArray() -> Void { return __result }()) for __bjs_elem_ret in ret { - let __bjs_isSome_ret_elem = __bjs_elem_ret != nil - if let __bjs_unwrapped_ret_elem = __bjs_elem_ret { - __bjs_unwrapped_ret_elem.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_ret_elem ? 1 : 0) + __bjs_elem_ret.bridgeJSLowerReturn() } _swift_js_push_i32(Int32(ret.count)) #else @@ -5719,20 +5649,10 @@ public func _bjs_roundTripOptionalStatusArray() -> Void { @_expose(wasm, "bjs_roundTripOptionalIntArrayType") @_cdecl("bjs_roundTripOptionalIntArrayType") -public func _bjs_roundTripOptionalIntArrayType(_ values: Int32) -> Void { +public func _bjs_roundTripOptionalIntArrayType() -> Void { #if arch(wasm32) - let ret = roundTripOptionalIntArrayType(_: { - if values == 0 { - return Optional<[Int]>.none - } else { - return [Int].bridgeJSLiftParameter() - } - }()) - let __bjs_isSome_ret = ret != nil - if let __bjs_unwrapped_ret = ret { - __bjs_unwrapped_ret.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_ret ? 1 : 0) + let ret = roundTripOptionalIntArrayType(_: Optional<[Int]>.bridgeJSLiftParameter()) + ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -5740,20 +5660,10 @@ public func _bjs_roundTripOptionalIntArrayType(_ values: Int32) -> Void { @_expose(wasm, "bjs_roundTripOptionalStringArrayType") @_cdecl("bjs_roundTripOptionalStringArrayType") -public func _bjs_roundTripOptionalStringArrayType(_ values: Int32) -> Void { +public func _bjs_roundTripOptionalStringArrayType() -> Void { #if arch(wasm32) - let ret = roundTripOptionalStringArrayType(_: { - if values == 0 { - return Optional<[String]>.none - } else { - return [String].bridgeJSLiftParameter() - } - }()) - let __bjs_isSome_ret = ret != nil - if let __bjs_unwrapped_ret = ret { - __bjs_unwrapped_ret.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_ret ? 1 : 0) + let ret = roundTripOptionalStringArrayType(_: Optional<[String]>.bridgeJSLiftParameter()) + ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -5761,20 +5671,10 @@ public func _bjs_roundTripOptionalStringArrayType(_ values: Int32) -> Void { @_expose(wasm, "bjs_roundTripOptionalGreeterArrayType") @_cdecl("bjs_roundTripOptionalGreeterArrayType") -public func _bjs_roundTripOptionalGreeterArrayType(_ greeters: Int32) -> Void { +public func _bjs_roundTripOptionalGreeterArrayType() -> Void { #if arch(wasm32) - let ret = roundTripOptionalGreeterArrayType(_: { - if greeters == 0 { - return Optional<[Greeter]>.none - } else { - return [Greeter].bridgeJSLiftParameter() - } - }()) - let __bjs_isSome_ret = ret != nil - if let __bjs_unwrapped_ret = ret { - __bjs_unwrapped_ret.bridgeJSLowerReturn() - } - _swift_js_push_i32(__bjs_isSome_ret ? 1 : 0) + let ret = roundTripOptionalGreeterArrayType(_: Optional<[Greeter]>.bridgeJSLiftParameter()) + ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -9006,9 +8906,9 @@ fileprivate func _bjs_OptionalPropertyHolder_wrap(_ pointer: UnsafeMutableRawPoi @_expose(wasm, "bjs_Container_init") @_cdecl("bjs_Container_init") -public func _bjs_Container_init(_ config: Int32) -> UnsafeMutableRawPointer { +public func _bjs_Container_init() -> UnsafeMutableRawPointer { #if arch(wasm32) - let _tmp_config = Optional.bridgeJSLiftParameter(config) + let _tmp_config = Optional.bridgeJSLiftParameter() let _tmp_location = DataPoint.bridgeJSLiftParameter() let ret = Container(location: _tmp_location, config: _tmp_config) return ret.bridgeJSLowerReturn() @@ -9051,9 +8951,9 @@ public func _bjs_Container_config_get(_ _self: UnsafeMutableRawPointer) -> Void @_expose(wasm, "bjs_Container_config_set") @_cdecl("bjs_Container_config_set") -public func _bjs_Container_config_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { +public func _bjs_Container_config_set(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - Container.bridgeJSLiftParameter(_self).config = Optional.bridgeJSLiftParameter(value) + Container.bridgeJSLiftParameter(_self).config = Optional.bridgeJSLiftParameter() #else fatalError("Only available on WebAssembly") #endif