diff --git a/Generator/Sources/ProjectionModel/ParamProjection.swift b/Generator/Sources/ProjectionModel/ParamBinding.swift similarity index 70% rename from Generator/Sources/ProjectionModel/ParamProjection.swift rename to Generator/Sources/ProjectionModel/ParamBinding.swift index 6ebd75a5..f8f07a94 100644 --- a/Generator/Sources/ProjectionModel/ParamProjection.swift +++ b/Generator/Sources/ProjectionModel/ParamBinding.swift @@ -1,7 +1,8 @@ import CodeWriters import DotNetMetadata -public struct ParamProjection { +/// Describes how a WinMD function parameter gets mapped to a Swift function parameter and vice-versa. +public struct ParamBinding { public enum PassBy: Equatable { case value case reference(in: Bool, out: Bool, optional: Bool) @@ -9,36 +10,36 @@ public struct ParamProjection { } public let name: String - public let typeProjection: TypeProjection + public let typeBinding: TypeBinding public let passBy: PassBy - public init(name: String, typeProjection: TypeProjection, passBy: PassBy) { + public init(name: String, typeBinding: TypeBinding, passBy: PassBy) { self.name = name - self.typeProjection = typeProjection + self.typeBinding = typeBinding self.passBy = passBy } - public var bindingType: SwiftType { typeProjection.bindingType } + public var bindingType: SwiftType { typeBinding.bindingType } public var swiftType: SwiftType { - if case .return(nullAsError: true) = passBy { return typeProjection.swiftType.unwrapOptional() } - return typeProjection.swiftType + if case .return(nullAsError: true) = passBy { return typeBinding.swiftType.unwrapOptional() } + return typeBinding.swiftType } public var abiBindingName: String { name + "_abi" } public var swiftBindingName: String { name + "_swift" } - public var isArray: Bool { typeProjection.kind == .array } + public var isArray: Bool { typeBinding.kind == .array } public var arrayLengthName: String { precondition(isArray) return name + "Length" } public func toSwiftParam(label: String = "_") -> SwiftParam { - SwiftParam(label: label, name: name, `inout`: passBy.isOutput, type: typeProjection.swiftType) + SwiftParam(label: label, name: name, `inout`: passBy.isOutput, type: typeBinding.swiftType) } } -extension ParamProjection.PassBy { +extension ParamBinding.PassBy { public var isInput: Bool { switch self { case .value, .reference(in: true, out: _, optional: _): return true diff --git a/Generator/Sources/ProjectionModel/Projection+params.swift b/Generator/Sources/ProjectionModel/Projection+params.swift index a6776fe1..99eea7e0 100644 --- a/Generator/Sources/ProjectionModel/Projection+params.swift +++ b/Generator/Sources/ProjectionModel/Projection+params.swift @@ -15,8 +15,8 @@ extension Projection { type: try toTypeExpression(genericTypeArgs.isEmpty ? param.type : param.type.bindGenericParams(typeArgs: genericTypeArgs))) } - public func getParamBinding(_ param: ParamBase, genericTypeArgs: [TypeNode] = []) throws -> ParamProjection { - let passBy: ParamProjection.PassBy = switch param { + public func getParamBinding(_ param: ParamBase, genericTypeArgs: [TypeNode] = []) throws -> ParamBinding { + let passBy: ParamBinding.PassBy = switch param { case is ReturnParam: .return(nullAsError: isNullAsErrorEligible(try param.type)) case let param as Param: param.isByRef @@ -25,14 +25,14 @@ extension Projection { default: fatalError("Unexpected parameter class") } - return ParamProjection( + return ParamBinding( name: toParamName(param), - typeProjection: try getTypeBinding( + typeBinding: try getTypeBinding( param.type.bindGenericParams(typeArgs: genericTypeArgs)), passBy: passBy) } - public func getParamBindings(method: Method, genericTypeArgs: [TypeNode], abiKind: ABIMethodKind? = nil) throws -> (params: [ParamProjection], return: ParamProjection?) { + public func getParamBindings(method: Method, genericTypeArgs: [TypeNode], abiKind: ABIMethodKind? = nil) throws -> (params: [ParamBinding], return: ParamBinding?) { let abiKind = try abiKind ?? ABIMethodKind.forABITypeMethods(definition: method.definingType) var paramBindings = try method.params.map { try getParamBinding($0, genericTypeArgs: genericTypeArgs) } @@ -41,22 +41,22 @@ extension Projection { // The last two parameters are the outer and inner objects, // which should not be projected to Swift. for i in paramBindings.count-2.. TypeProjection { + public func getTypeBinding(_ type: TypeNode) throws -> TypeBinding { switch type { case let .bound(type): return try getTypeBinding(type) @@ -83,7 +83,7 @@ extension Projection { case let .array(of: element): let elementBinding = try getTypeBinding(element) let swiftType = SwiftType.array(element: elementBinding.swiftType) - return TypeProjection( + return TypeBinding( abiType: SupportModules.COM.comArray(of: elementBinding.abiType), abiDefaultValue: .defaultInitializer, swiftType: swiftType, @@ -96,7 +96,7 @@ extension Projection { } } - private func getTypeBinding(_ type: BoundType) throws -> TypeProjection { + private func getTypeBinding(_ type: BoundType) throws -> TypeBinding { if let specialTypeBinding = try getSpecialTypeBinding(type) { return specialTypeBinding } @@ -117,7 +117,7 @@ extension Projection { abiType = .unsafeMutablePointer(pointee: abiType).optional() } - return TypeProjection( + return TypeBinding( abiType: abiType, abiDefaultValue: type.definition.isReferenceType ? "nil" : .defaultInitializer, swiftType: try toTypeExpression(type.asNode), @@ -126,23 +126,23 @@ extension Projection { kind: try isPODBinding(type.definition) ? .pod : .allocating) } - private func getSpecialTypeBinding(_ type: BoundType) throws -> TypeProjection? { + private func getSpecialTypeBinding(_ type: BoundType) throws -> TypeBinding? { if type.definition.namespace == "System" { - guard let typeProjection = try getCoreLibraryTypeBinding(type) else { + guard let typeBinding = try getCoreLibraryTypeBinding(type) else { throw UnexpectedTypeError(type.description, context: "Not a valid WinRT System type.") } - return typeProjection + return typeBinding } else if type.definition.namespace == "Windows.Foundation", - let typeProjection = try getWindowsFoundationTypeBinding(type) { - return typeProjection + let typeBinding = try getWindowsFoundationTypeBinding(type) { + return typeBinding } else { return nil } } - private func getCoreLibraryTypeBinding(_ type: BoundType) throws -> TypeProjection? { + private func getCoreLibraryTypeBinding(_ type: BoundType) throws -> TypeBinding? { guard type.definition.namespace == "System" else { return nil } if type.definition.name == "Object" { @@ -163,7 +163,7 @@ extension Projection { let swiftType: SwiftType = primitiveType == .boolean ? .bool : primitiveType == .float(double: false) ? .float : .swift(primitiveType.name) - return TypeProjection( + return TypeBinding( abiType: swiftType, abiDefaultValue: primitiveType == .boolean ? .`false` : .zero, swiftType: swiftType, @@ -171,7 +171,7 @@ extension Projection { bindingType: SupportModules.WinRT.primitiveBinding(of: primitiveType), kind: .identity) case .char16: - return TypeProjection( + return TypeBinding( abiType: .swift("UInt16"), abiDefaultValue: .zero, swiftType: SupportModules.WinRT.char16, @@ -179,7 +179,7 @@ extension Projection { bindingType: SupportModules.WinRT.primitiveBinding(of: primitiveType), kind: .pod) case .guid: - return TypeProjection( + return TypeBinding( abiType: .named(CAbi.guidName), abiDefaultValue: .defaultInitializer, swiftType: SupportModules.COM.guid, @@ -197,7 +197,7 @@ extension Projection { } } - private func getWindowsFoundationTypeBinding(_ type: BoundType) throws -> TypeProjection? { + private func getWindowsFoundationTypeBinding(_ type: BoundType) throws -> TypeBinding? { guard type.definition.namespace == "Windows.Foundation" else { return nil } switch type.definition.name { case "IReference`1": @@ -205,7 +205,7 @@ extension Projection { return try getIReferenceTypeBinding(of: type) case "EventRegistrationToken": - return TypeProjection( + return TypeBinding( abiType: .named(CAbi.eventRegistrationTokenName), abiDefaultValue: .defaultInitializer, swiftType: SupportModules.WinRT.eventRegistrationToken, @@ -214,7 +214,7 @@ extension Projection { kind: .pod) case "HResult": - return TypeProjection( + return TypeBinding( abiType: .named(CAbi.hresultName), abiDefaultValue: .zero, swiftType: SupportModules.COM.hresult, @@ -227,24 +227,24 @@ extension Projection { } } - private func getIReferenceTypeBinding(of type: BoundType) throws -> TypeProjection? { - let typeProjection = try getTypeBinding(type.asNode) + private func getIReferenceTypeBinding(of type: BoundType) throws -> TypeBinding? { + let typeBinding = try getTypeBinding(type.asNode) let bindingType: SwiftType if type.definition.namespace == "System", let primitiveType = WinRTPrimitiveType(fromSystemNamespaceType: type.definition.name) { bindingType = SupportModules.WinRT.ireferenceToOptionalBinding(of: primitiveType) } else if type.definition is EnumDefinition || type.definition is StructDefinition || type.definition is DelegateDefinition { - bindingType = SupportModules.WinRT.ireferenceToOptionalBinding(of: typeProjection.bindingType) + bindingType = SupportModules.WinRT.ireferenceToOptionalBinding(of: typeBinding.bindingType) } else { return nil } - return TypeProjection( + return TypeBinding( abiType: .unsafeMutablePointer(pointee: .named(CAbi.ireferenceName)).optional(), abiDefaultValue: .nil, - swiftType: typeProjection.swiftType.optional(), + swiftType: typeBinding.swiftType.optional(), swiftDefaultValue: .nil, bindingType: bindingType, kind: .allocating) diff --git a/Generator/Sources/ProjectionModel/TypeProjection.swift b/Generator/Sources/ProjectionModel/TypeBinding.swift similarity index 95% rename from Generator/Sources/ProjectionModel/TypeProjection.swift rename to Generator/Sources/ProjectionModel/TypeBinding.swift index 997aadec..9170cab9 100644 --- a/Generator/Sources/ProjectionModel/TypeProjection.swift +++ b/Generator/Sources/ProjectionModel/TypeBinding.swift @@ -1,7 +1,7 @@ import CodeWriters /// Describes a type's Swift and ABI representation, and how to project between the two. -public struct TypeProjection { +public struct TypeBinding { public enum DefaultValue: ExpressibleByStringLiteral, CustomStringConvertible { case defaultInitializer // .init() case expression(String) @@ -57,8 +57,8 @@ public struct TypeProjection { self.kind = kind } - public static func numeric(_ type: SwiftType) -> TypeProjection { - TypeProjection( + public static func numeric(_ type: SwiftType) -> TypeBinding { + TypeBinding( abiType: type, abiDefaultValue: "0", swiftType: type, diff --git a/Generator/Sources/SwiftWinRT/Writing/ABIBinding.swift b/Generator/Sources/SwiftWinRT/Writing/ABIBinding.swift index ab852ce9..5139b618 100644 --- a/Generator/Sources/SwiftWinRT/Writing/ABIBinding.swift +++ b/Generator/Sources/SwiftWinRT/Writing/ABIBinding.swift @@ -153,7 +153,7 @@ fileprivate func writeStructBindingExtension( if index > 0 { output.write(",", endLine: true) } try writeStructABIToSwiftInitializerParam( abiValueName: "value", abiFieldName: field.name, swiftFieldName: Projection.toMemberName(field), - typeProjection: projection.getTypeBinding(field.type), to: output) + typeBinding: projection.getTypeBinding(field.type), to: output) } } output.write(")", endLine: true) @@ -176,7 +176,7 @@ fileprivate func writeStructBindingExtension( if index > 0 { output.write(",", endLine: true) } try writeStructSwiftToABIInitializerParam( swiftValueName: "value", swiftFieldName: Projection.toMemberName(field), abiFieldName: field.name, - typeProjection: projection.getTypeBinding(field.type), to: output) + typeBinding: projection.getTypeBinding(field.type), to: output) } } output.write(")", endLine: true) @@ -188,9 +188,9 @@ fileprivate func writeStructBindingExtension( visibility: .public, static: true, name: "release", params: [.init(label: "_", name: "value", `inout`: true, type: abiType)]) { writer in for field in fields { - let typeProjection = try projection.getTypeBinding(field.type) - if typeProjection.kind == .allocating { - writer.writeStatement("\(typeProjection.bindingType).release(&value.\(field.name))") + let typeBinding = try projection.getTypeBinding(field.type) + if typeBinding.kind == .allocating { + writer.writeStatement("\(typeBinding.bindingType).release(&value.\(field.name))") } } } @@ -200,13 +200,13 @@ fileprivate func writeStructBindingExtension( fileprivate func writeStructABIToSwiftInitializerParam( abiValueName: String, abiFieldName: String, swiftFieldName: String, - typeProjection: TypeProjection, to output: LineBasedTextOutputStream) throws { + typeBinding: TypeBinding, to output: LineBasedTextOutputStream) throws { var output = output SwiftIdentifier.write(swiftFieldName, to: &output) output.write(": ") - if typeProjection.kind != .identity { - typeProjection.bindingType.write(to: &output) + if typeBinding.kind != .identity { + typeBinding.bindingType.write(to: &output) output.write(".fromABI(") } @@ -214,21 +214,21 @@ fileprivate func writeStructABIToSwiftInitializerParam( output.write(".") SwiftIdentifier.write(abiFieldName, to: &output) - if typeProjection.kind != .identity { + if typeBinding.kind != .identity { output.write(")") } } fileprivate func writeStructSwiftToABIInitializerParam( swiftValueName: String, swiftFieldName: String, abiFieldName: String, - typeProjection: TypeProjection, to output: LineBasedTextOutputStream) throws { + typeBinding: TypeBinding, to output: LineBasedTextOutputStream) throws { var output = output SwiftIdentifier.write(abiFieldName, to: &output) output.write(": ") - if typeProjection.kind != .identity { - if typeProjection.kind != .pod { output.write("try ") } - typeProjection.bindingType.write(to: &output) + if typeBinding.kind != .identity { + if typeBinding.kind != .pod { output.write("try ") } + typeBinding.bindingType.write(to: &output) output.write(".toABI(") } @@ -236,7 +236,7 @@ fileprivate func writeStructSwiftToABIInitializerParam( output.write(".") SwiftIdentifier.write(swiftFieldName, to: &output) - if typeProjection.kind != .identity { + if typeBinding.kind != .identity { output.write(")") } } diff --git a/Generator/Sources/SwiftWinRT/Writing/COMInteropExtension.swift b/Generator/Sources/SwiftWinRT/Writing/COMInteropExtension.swift index 8d281864..2e51d79c 100644 --- a/Generator/Sources/SwiftWinRT/Writing/COMInteropExtension.swift +++ b/Generator/Sources/SwiftWinRT/Writing/COMInteropExtension.swift @@ -72,7 +72,7 @@ fileprivate func writeCOMInteropMethod( visibility: visibility, name: Projection.toInteropMethodName(method), params: paramBindings.map { $0.toSwiftParam() }, - throws: true, returnType: returnBinding.map { $0.typeProjection.swiftType }) { writer in + throws: true, returnType: returnBinding.map { $0.typeBinding.swiftType }) { writer in try writeSwiftToABICall( abiMethodName: abiMethodName, params: paramBindings, @@ -84,8 +84,8 @@ fileprivate func writeCOMInteropMethod( fileprivate func writeSwiftToABICall( abiMethodName: String, - params: [ParamProjection], - returnParam: ParamProjection?, + params: [ParamBinding], + returnParam: ParamBinding?, returnCOMReference: Bool, to writer: SwiftStatementWriter) throws { @@ -104,40 +104,40 @@ fileprivate func writeSwiftToABICall( // Prologue: convert arguments from the Swift to the ABI representation for param in params { - let typeProjection = param.typeProjection - if param.typeProjection.kind == .identity { + let typeBinding = param.typeBinding + if param.typeBinding.kind == .identity { addAbiArg(param.name, byRef: param.passBy != .value, array: false) continue } - let declarator: SwiftVariableDeclarator = param.passBy.isReference || typeProjection.kind != .pod ? .var : .let + let declarator: SwiftVariableDeclarator = param.passBy.isReference || typeBinding.kind != .pod ? .var : .let if param.passBy.isOutput { needsOutParamsEpilogue = true } if param.passBy.isOutput && !param.passBy.isInput { - writer.writeStatement("\(declarator) \(param.abiBindingName): \(typeProjection.abiType) = \(typeProjection.abiDefaultValue)") + writer.writeStatement("\(declarator) \(param.abiBindingName): \(typeBinding.abiType) = \(typeBinding.abiDefaultValue)") } else { - let tryPrefix = typeProjection.kind == .pod ? "" : "try " + let tryPrefix = typeBinding.kind == .pod ? "" : "try " writer.writeStatement("\(declarator) \(param.abiBindingName) = " - + "\(tryPrefix)\(typeProjection.bindingType).toABI(\(param.name))") + + "\(tryPrefix)\(typeBinding.bindingType).toABI(\(param.name))") } - if typeProjection.kind != .pod { - writer.writeStatement("defer { \(typeProjection.bindingType).release(&\(param.abiBindingName)) }") + if typeBinding.kind != .pod { + writer.writeStatement("defer { \(typeBinding.bindingType).release(&\(param.abiBindingName)) }") } - addAbiArg(param.abiBindingName, byRef: param.passBy.isReference, array: typeProjection.kind == .array) + addAbiArg(param.abiBindingName, byRef: param.passBy.isReference, array: typeBinding.kind == .array) } func writeOutParamsEpilogue() throws { for param in params { - let typeProjection = param.typeProjection - if typeProjection.kind != .identity && param.passBy.isOutput { - if typeProjection.kind == .pod { - writer.writeStatement("\(param.name) = \(typeProjection.bindingType).fromABI(\(param.abiBindingName))") + let typeBinding = param.typeBinding + if typeBinding.kind != .identity && param.passBy.isOutput { + if typeBinding.kind == .pod { + writer.writeStatement("\(param.name) = \(typeBinding.bindingType).fromABI(\(param.abiBindingName))") } else { - writer.writeStatement("\(param.name) = \(typeProjection.bindingType).fromABI(consuming: &\(param.abiBindingName))") + writer.writeStatement("\(param.name) = \(typeBinding.bindingType).fromABI(consuming: &\(param.abiBindingName))") } } } @@ -156,7 +156,7 @@ fileprivate func writeSwiftToABICall( } // Value-returning functions - let returnTypeBinding = returnParam.typeProjection + let returnTypeBinding = returnParam.typeBinding writer.writeStatement("var \(returnParam.name): \(returnTypeBinding.abiType) = \(returnTypeBinding.abiDefaultValue)") addAbiArg(returnParam.name, byRef: true, array: returnTypeBinding.kind == .array) try writeCall() diff --git a/Generator/Sources/SwiftWinRT/Writing/MemberDefinition.swift b/Generator/Sources/SwiftWinRT/Writing/MemberDefinition.swift index 69c10649..ee01f543 100644 --- a/Generator/Sources/SwiftWinRT/Writing/MemberDefinition.swift +++ b/Generator/Sources/SwiftWinRT/Writing/MemberDefinition.swift @@ -167,7 +167,7 @@ fileprivate func writeMethodDefinition( } internal func writeInteropMethodCall( - name: String, params: [ParamProjection], returnParam: ParamProjection?, thisPointer: ThisPointer, + name: String, params: [ParamBinding], returnParam: ParamBinding?, thisPointer: ThisPointer, projection: Projection, to output: LineBasedTextOutputStream) throws { let nullReturnAsError = { diff --git a/Generator/Sources/SwiftWinRT/Writing/VirtualTable.swift b/Generator/Sources/SwiftWinRT/Writing/VirtualTable.swift index c53c0a08..70f9998e 100644 --- a/Generator/Sources/SwiftWinRT/Writing/VirtualTable.swift +++ b/Generator/Sources/SwiftWinRT/Writing/VirtualTable.swift @@ -59,7 +59,7 @@ fileprivate func writeVirtualTable( } } -fileprivate func getABIParamNames(_ params: [ParamProjection], returnParam: ParamProjection?) -> [String] { +fileprivate func getABIParamNames(_ params: [ParamBinding], returnParam: ParamBinding?) -> [String] { var abiParamNames = [String]() for param in params { if param.isArray { abiParamNames.append(param.arrayLengthName) } @@ -73,7 +73,7 @@ fileprivate func getABIParamNames(_ params: [ParamProjection], returnParam: Para } fileprivate func writeVirtualTableFunc( - params: [ParamProjection], returnParam: ParamProjection?, + params: [ParamBinding], returnParam: ParamBinding?, swiftMemberName: String, methodKind: WinRTMethodKind, to output: LineBasedTextOutputStream) throws { // Ensure non-optional by reference params are non-null pointers for param in params { @@ -87,8 +87,8 @@ fileprivate func writeVirtualTableFunc( // Declare the Swift representation of params var epilogueOutParamWithCleanupCount = 0 for param in params { - guard param.typeProjection.kind != .identity else { continue } - if param.passBy.isOutput, param.typeProjection.kind != .pod { + guard param.typeBinding.kind != .identity else { continue } + if param.passBy.isOutput, param.typeBinding.kind != .pod { epilogueOutParamWithCleanupCount += 1 } try writePrologueForParam(param, to: output) @@ -96,11 +96,11 @@ fileprivate func writeVirtualTableFunc( // Set up the return value if let returnParam { - if returnParam.typeProjection.kind == .identity { + if returnParam.typeBinding.kind == .identity { output.write("\(returnParam.name).pointee = ") } else { - if returnParam.typeProjection.kind != .pod { + if returnParam.typeBinding.kind != .pod { epilogueOutParamWithCleanupCount += 1 } output.write("let \(returnParam.swiftBindingName) = ") @@ -124,7 +124,7 @@ fileprivate func writeVirtualTableFunc( for (index, param) in params.enumerated() { if index > 0 { output.write(", ") } if param.passBy != .value { output.write("&") } - if param.typeProjection.kind == .identity { + if param.typeBinding.kind == .identity { output.write(param.name) if param.passBy != .value { output.write(".pointee") } } else { @@ -145,11 +145,11 @@ fileprivate func writeVirtualTableFunc( if epilogueRequiresCleanup { output.writeFullLine("var _success = false") } for param in params { - guard param.passBy.isOutput, param.typeProjection.kind != .identity else { continue } + guard param.passBy.isOutput, param.typeBinding.kind != .identity else { continue } try writeEpilogueForOutParam(param, skipCleanup: !epilogueRequiresCleanup, to: output) } - if let returnParam, returnParam.typeProjection.kind != .identity { + if let returnParam, returnParam.typeBinding.kind != .identity { try writeEpilogueForOutParam(returnParam, skipCleanup: !epilogueRequiresCleanup, to: output) } @@ -167,11 +167,11 @@ fileprivate func writeVirtualTableFuncImplementation(name: String, paramNames: [ output.write("} }") } -fileprivate func writePrologueForParam(_ param: ParamProjection, to output: LineBasedTextOutputStream) throws { +fileprivate func writePrologueForParam(_ param: ParamBinding, to output: LineBasedTextOutputStream) throws { if param.passBy.isInput { let declarator: SwiftVariableDeclarator = param.passBy.isOutput ? .var : .let output.write("\(declarator) \(param.swiftBindingName) = \(param.bindingType).fromABI") - switch param.typeProjection.kind { + switch param.typeBinding.kind { case .identity: fatalError("Case should have been ignored earlier.") case .pod, .allocating: output.write("(\(param.name))") @@ -179,16 +179,16 @@ fileprivate func writePrologueForParam(_ param: ParamProjection, to output: Line output.write("(pointer: \(param.name), count: \(param.arrayLengthName))") } } else { - output.write("var \(param.swiftBindingName): \(param.typeProjection.swiftType)" - + " = \(param.typeProjection.swiftDefaultValue)") + output.write("var \(param.swiftBindingName): \(param.typeBinding.swiftType)" + + " = \(param.typeBinding.swiftDefaultValue)") } output.endLine() } -fileprivate func writeEpilogueForOutParam(_ param: ParamProjection, skipCleanup: Bool, to output: LineBasedTextOutputStream) throws { +fileprivate func writeEpilogueForOutParam(_ param: ParamBinding, skipCleanup: Bool, to output: LineBasedTextOutputStream) throws { precondition(param.passBy.isOutput) - if param.typeProjection.kind == .array { + if param.typeBinding.kind == .array { output.writeFullLine(#"fatalError("Not implemented: out arrays")"#) } else { @@ -202,10 +202,10 @@ fileprivate func writeEpilogueForOutParam(_ param: ParamProjection, skipCleanup: if isOptional { output.write("if let \(param.name) { ") } output.write("\(param.name).pointee = ") - if param.typeProjection.kind == .identity { + if param.typeBinding.kind == .identity { output.write(param.swiftBindingName) } else { - if param.typeProjection.kind == .allocating { output.write ("try ") } + if param.typeBinding.kind == .allocating { output.write ("try ") } output.write("\(param.bindingType).toABI(\(param.swiftBindingName))") } @@ -213,7 +213,7 @@ fileprivate func writeEpilogueForOutParam(_ param: ParamProjection, skipCleanup: output.endLine() - if param.typeProjection.kind == .allocating, !skipCleanup { + if param.typeBinding.kind == .allocating, !skipCleanup { output.write("defer { ") output.write("if !_success { ") output.write("\(param.bindingType).release(&\(param.name).pointee)")