Skip to content

Commit

Permalink
Fixed build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanlabelle committed Dec 20, 2024
2 parents c5da34d + d92398c commit 16e3a25
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
2 changes: 2 additions & 0 deletions Generator/Sources/ProjectionModel/SupportModules.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
19 changes: 9 additions & 10 deletions Generator/Sources/SwiftWinRT/Writing/ABIBinding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()")
}
}

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Generator/Sources/SwiftWinRT/Writing/ClassDefinition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 4 additions & 10 deletions Generator/Sources/SwiftWinRT/Writing/SecondaryInterfaces.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 16e3a25

Please sign in to comment.