diff --git a/Generator/Sources/ProjectionModel/SupportModules.swift b/Generator/Sources/ProjectionModel/SupportModules.swift index 027c01b..d6976d9 100644 --- a/Generator/Sources/ProjectionModel/SupportModules.swift +++ b/Generator/Sources/ProjectionModel/SupportModules.swift @@ -81,6 +81,8 @@ extension SupportModules.WinRT { public static var composableClassBinding: SwiftType { moduleType.member("ComposableClassBinding") } public static var composableClass: SwiftType { moduleType.member("ComposableClass") } + public static var composableClass_outerObject: SwiftType { composableClass.member("OuterObject") } + public static var composableClass_outerObject_shortName: String { "OuterObject" } public static var composableClass_supportsOverrides: String { "supportsOverrides" } public static func winRTImport(of type: SwiftType) -> SwiftType { diff --git a/Generator/Sources/SwiftWinRT/Writing/ABIBinding.swift b/Generator/Sources/SwiftWinRT/Writing/ABIBinding.swift index 344e8a6..c5c72c3 100644 --- a/Generator/Sources/SwiftWinRT/Writing/ABIBinding.swift +++ b/Generator/Sources/SwiftWinRT/Writing/ABIBinding.swift @@ -285,17 +285,16 @@ fileprivate func writeComposableClassOuterObject( _ classDefinition: ClassDefinition, projection: Projection, to writer: SwiftTypeDefinitionWriter) throws { + let outerObjectClassName = SupportModules.WinRT.composableClass_outerObject_shortName + let baseOuterObject: SwiftType if let base = try classDefinition.base, try base.definition.base != nil { - // FIXME: Append .OuterObject - baseOuterObject = SwiftType.identifier(try projection.toBindingTypeName(base.definition)) + baseOuterObject = .named(try projection.toBindingTypeName(base.definition)) + .member(outerObjectClassName) } else { - // FIXME: Append .OuterObject - baseOuterObject = SupportModules.WinRT.composableClass + baseOuterObject = SupportModules.WinRT.composableClass_outerObject } - let outerObjectClassName = "OuterObject" - try writer.writeClass( visibility: .open, name: outerObjectClassName, @@ -316,10 +315,10 @@ fileprivate func writeComposableClassOuterObject( writer.writeBracedBlock("if id == uuidof(\(abiSwiftType).self)") { writer in let propertyName = SecondaryInterfaces.getPropertyName(interface) - // _ifoo_outer.initEmbedder(self) - // return .init(_ifoo_outer.toCOM()) + // _ifoo.initEmbedder(self) + // return _ifoo.toCOM() writer.writeStatement("\(propertyName).initEmbedder(self)") - writer.writeReturnStatement(value: ".init(\(propertyName).toCOM())") + writer.writeReturnStatement(value: "\(propertyName).toCOM()") } } @@ -338,7 +337,7 @@ fileprivate func writeComposableClassOuterObject( for interface in overridableInterfaces { try writeVirtualTableProperty( - visibility: .internal, + visibility: .private, name: Casing.pascalToCamel(interface.definition.nameWithoutGenericArity), abiType: interface.asBoundType, swiftType: classDefinition.bindType(), projection: projection, to: writer) diff --git a/Generator/Sources/SwiftWinRT/Writing/ClassDefinition.swift b/Generator/Sources/SwiftWinRT/Writing/ClassDefinition.swift index 37b740f..0322618 100644 --- a/Generator/Sources/SwiftWinRT/Writing/ClassDefinition.swift +++ b/Generator/Sources/SwiftWinRT/Writing/ClassDefinition.swift @@ -259,7 +259,7 @@ fileprivate func writeComposableInitializers( let propertyName = SecondaryInterfaces.getPropertyName(factoryInterface.bind()) let baseClassDefinition = try getRuntimeClassBase(classDefinition) - let outerObjectType = SwiftType.identifier(try projection.toBindingTypeName(classDefinition)) + let outerObjectType: SwiftType = .named(try projection.toBindingTypeName(classDefinition)).member("OuterObject") for method in factoryInterface.methods { // Swift requires "override" on initializers iff the same initializer is defined in the direct base class diff --git a/Generator/Sources/SwiftWinRT/Writing/SecondaryInterfaces.swift b/Generator/Sources/SwiftWinRT/Writing/SecondaryInterfaces.swift index 6f975d5..550c004 100644 --- a/Generator/Sources/SwiftWinRT/Writing/SecondaryInterfaces.swift +++ b/Generator/Sources/SwiftWinRT/Writing/SecondaryInterfaces.swift @@ -60,18 +60,12 @@ internal enum SecondaryInterfaces { }) } - internal static func getPropertyName(_ interface: BoundInterface, suffix: String? = nil) -> String { - getPropertyName(interfaceName: interface.definition.nameWithoutGenericArity, suffix: suffix) + internal static func getPropertyName(_ interface: BoundInterface) -> String { + getPropertyName(interfaceName: interface.definition.nameWithoutGenericArity) } - internal static func getPropertyName(interfaceName: String, suffix: String? = nil) -> String { - var name = "_" + Casing.pascalToCamel(interfaceName) - if let suffix { name += "_" + suffix } - return name - } - - internal static func getOverridableOuterName(_ interface: BoundInterface) -> String { - "_outer" + interface.definition.nameWithoutGenericArity + internal static func getPropertyName(interfaceName: String) -> String { + "_" + Casing.pascalToCamel(interfaceName) } fileprivate static func getStoredPropertyName(_ interfaceName: String) -> String {