From fa69e1151712415db11199d6b0845def8c661adf Mon Sep 17 00:00:00 2001 From: Tristan Labelle Date: Mon, 1 Apr 2024 07:13:15 -0400 Subject: [PATCH] Remove COMProjection.COMVirtualTable typealias. (#103) --- .../SwiftWinRT/Writing/ABIProjectionType.swift | 10 ++++------ Support/Sources/COM/COMExportedInterface.swift | 15 ++++++--------- Support/Sources/COM/COMProjection.swift | 4 ---- Support/Sources/COM/COMTwoWayProjection.swift | 2 +- Support/Sources/COM/IAgileObject.swift | 1 - Support/Sources/COM/IErrorInfo.swift | 5 ++--- Support/Sources/COM/IUnknown.swift | 5 ++--- .../WindowsRuntime/IActivationFactory.swift | 3 +-- .../WindowsRuntime/IBufferByteAccess.swift | 5 ++--- Support/Sources/WindowsRuntime/IInspectable.swift | 5 ++--- .../IReferenceUnboxingProjection.swift | 1 - .../WindowsRuntime/IRestrictedErrorInfo.swift | 5 ++--- .../Sources/WindowsRuntime/IWeakReference.swift | 5 ++--- .../WindowsRuntime/IWeakReferenceSource.swift | 5 ++--- .../WindowsFoundation/IReference.swift | 3 +-- .../WindowsFoundation/IStringable.swift | 5 ++--- .../include/SWRT/SwiftCOMObject.h | 4 +--- Support/Tests/IInspectable2.swift | 5 ++--- Support/Tests/IUnknown2.swift | 5 ++--- 19 files changed, 34 insertions(+), 59 deletions(-) diff --git a/Generator/Sources/SwiftWinRT/Writing/ABIProjectionType.swift b/Generator/Sources/SwiftWinRT/Writing/ABIProjectionType.swift index e13b5e6b..a6ebaeb1 100644 --- a/Generator/Sources/SwiftWinRT/Writing/ABIProjectionType.swift +++ b/Generator/Sources/SwiftWinRT/Writing/ABIProjectionType.swift @@ -336,14 +336,14 @@ fileprivate func writeInterfaceOrDelegateProjectionType( type, visibility: .private, name: importClassName, projectionName: projectionName, projection: projection, to: writer) - // public static var virtualTablePointer: COMVirtualTablePointer { withUnsafePointer(to: &virtualTable) { $0 } } - // private static var virtualTable = COMVirtualTable(...) + // public static var virtualTablePointer: UnsafeRawPointer { .init(withUnsafePointer(to: &virtualTable) { $0 }) } writer.writeComputedProperty( visibility: .public, static: true, name: "virtualTablePointer", - type: .identifier("COMVirtualTablePointer")) { writer in - writer.writeStatement("withUnsafePointer(to: &virtualTable) { $0 }") + type: .identifier("UnsafeRawPointer")) { writer in + writer.writeStatement(".init(withUnsafePointer(to: &virtualTable) { $0 })") } + // private static var virtualTable = SWRT_IFooVTable(...) try writeVirtualTableProperty(name: "virtualTable", abiType: type, swiftType: type, projection: projection, to: writer) } } @@ -365,8 +365,6 @@ internal func writeReferenceTypeProjectionConformance( target: try projection.toType(apiType.asNode).unwrapOptional()) writer.writeTypeAlias(visibility: .public, name: "COMInterface", target: try projection.toABIType(abiType)) - writer.writeTypeAlias(visibility: .public, name: "COMVirtualTable", - target: try projection.toABIVirtualTableType(abiType)) // public static var typeName: String { "..." } try writeTypeNameProperty(type: apiType, to: writer) diff --git a/Support/Sources/COM/COMExportedInterface.swift b/Support/Sources/COM/COMExportedInterface.swift index 379bd934..1d35ea87 100644 --- a/Support/Sources/COM/COMExportedInterface.swift +++ b/Support/Sources/COM/COMExportedInterface.swift @@ -11,21 +11,18 @@ public struct COMExportedInterface { comObject = .init() } - public init( + public init( swiftObject: SwiftObject, - virtualTable: UnsafePointer) { - comObject = .init( - comVirtualTable: virtualTable.withMemoryRebound(to: WindowsRuntime_ABI.SWRT_IUnknownVTable.self, capacity: 1) { $0 }, + virtualTable: UnsafeRawPointer) { + comObject = .init(virtualTable: virtualTable, swiftObject: Unmanaged.passUnretained(swiftObject).toOpaque()) } - private init(virtualTable: UnsafePointer) { - comObject = .init( - comVirtualTable: virtualTable.withMemoryRebound(to: WindowsRuntime_ABI.SWRT_IUnknownVTable.self, capacity: 1) { $0 }, - swiftObject: nil) + private init(virtualTable: UnsafeRawPointer) { + comObject = .init(virtualTable: virtualTable, swiftObject: nil) } - public static func withLateSwiftObjectInit(virtualTable: UnsafePointer) -> COMExportedInterface { + public static func withLateSwiftObjectInit(virtualTable: UnsafeRawPointer) -> COMExportedInterface { .init(virtualTable: virtualTable) } diff --git a/Support/Sources/COM/COMProjection.swift b/Support/Sources/COM/COMProjection.swift index 1a9022f0..bc43f8a9 100644 --- a/Support/Sources/COM/COMProjection.swift +++ b/Support/Sources/COM/COMProjection.swift @@ -7,12 +7,8 @@ public protocol COMProjection: ABIProjection where SwiftValue == SwiftObject?, A associatedtype SwiftObject /// The COM interface structure. associatedtype COMInterface /* : COMIUnknownStruct */ - /// The COM interface's virtual table structure. - associatedtype COMVirtualTable /// A pointer to the COM interface structure. typealias COMPointer = UnsafeMutablePointer - /// A pointer to the COM interface's virtual table structure. - typealias COMVirtualTablePointer = UnsafePointer // Non-nullable overloads static func toSwift(_ reference: consuming COMReference) -> SwiftObject diff --git a/Support/Sources/COM/COMTwoWayProjection.swift b/Support/Sources/COM/COMTwoWayProjection.swift index 303cf747..d2ff91f8 100644 --- a/Support/Sources/COM/COMTwoWayProjection.swift +++ b/Support/Sources/COM/COMTwoWayProjection.swift @@ -2,7 +2,7 @@ import WindowsRuntime_ABI /// Protocol for strongly-typed two-way COM interface projections into and from Swift. public protocol COMTwoWayProjection: COMProjection { - static var virtualTablePointer: COMVirtualTablePointer { get } + static var virtualTablePointer: UnsafeRawPointer { get } } /// Helpers for implementing virtual tables diff --git a/Support/Sources/COM/IAgileObject.swift b/Support/Sources/COM/IAgileObject.swift index aca69c3d..6c2f477b 100644 --- a/Support/Sources/COM/IAgileObject.swift +++ b/Support/Sources/COM/IAgileObject.swift @@ -6,7 +6,6 @@ import WindowsRuntime_ABI public enum IAgileObjectProjection: COMProjection { public typealias SwiftObject = IUnknown // Avoid introducing an interface for IAgileObject since it is a marker interface. public typealias COMInterface = WindowsRuntime_ABI.SWRT_IAgileObject - public typealias COMVirtualTable = WindowsRuntime_ABI.SWRT_IAgileObjectVTable public static var interfaceID: COMInterfaceID { COMInterface.iid } diff --git a/Support/Sources/COM/IErrorInfo.swift b/Support/Sources/COM/IErrorInfo.swift index b3d0c03d..99f9d477 100644 --- a/Support/Sources/COM/IErrorInfo.swift +++ b/Support/Sources/COM/IErrorInfo.swift @@ -13,10 +13,9 @@ public protocol IErrorInfoProtocol: IUnknownProtocol { public enum IErrorInfoProjection: COMTwoWayProjection { public typealias SwiftObject = IErrorInfo public typealias COMInterface = WindowsRuntime_ABI.SWRT_IErrorInfo - public typealias COMVirtualTable = WindowsRuntime_ABI.SWRT_IErrorInfoVTable public static var interfaceID: COMInterfaceID { COMInterface.iid } - public static var virtualTablePointer: COMVirtualTablePointer { withUnsafePointer(to: &virtualTable) { $0 } } + public static var virtualTablePointer: UnsafeRawPointer { .init(withUnsafePointer(to: &virtualTable) { $0 }) } public static func toSwift(_ reference: consuming COMReference) -> SwiftObject { Import.toSwift(reference) @@ -34,7 +33,7 @@ public enum IErrorInfoProjection: COMTwoWayProjection { public var helpContext: UInt32 { get throws { try _interop.getHelpContext() } } } - private static var virtualTable: COMVirtualTable = .init( + private static var virtualTable: WindowsRuntime_ABI.SWRT_IErrorInfoVTable = .init( QueryInterface: { COMExportedInterface.QueryInterface($0, $1, $2) }, AddRef: { COMExportedInterface.AddRef($0) }, Release: { COMExportedInterface.Release($0) }, diff --git a/Support/Sources/COM/IUnknown.swift b/Support/Sources/COM/IUnknown.swift index eb83c3d6..7fea95e0 100644 --- a/Support/Sources/COM/IUnknown.swift +++ b/Support/Sources/COM/IUnknown.swift @@ -19,10 +19,9 @@ extension IUnknownProtocol { public enum IUnknownProjection: COMTwoWayProjection { public typealias SwiftObject = IUnknown public typealias COMInterface = WindowsRuntime_ABI.SWRT_IUnknown - public typealias COMVirtualTable = WindowsRuntime_ABI.SWRT_IUnknownVTable public static var interfaceID: COMInterfaceID { COMInterface.iid } - public static var virtualTablePointer: COMVirtualTablePointer { withUnsafePointer(to: &virtualTable) { $0 } } + public static var virtualTablePointer: UnsafeRawPointer { .init(withUnsafePointer(to: &virtualTable) { $0 }) } public static func toSwift(_ reference: consuming COMReference) -> SwiftObject { Import.toSwift(reference) @@ -34,7 +33,7 @@ public enum IUnknownProjection: COMTwoWayProjection { private final class Import: COMImport {} - private static var virtualTable: COMVirtualTable = .init( + private static var virtualTable: WindowsRuntime_ABI.SWRT_IUnknownVTable = .init( QueryInterface: { COMExportedInterface.QueryInterface($0, $1, $2) }, AddRef: { COMExportedInterface.AddRef($0) }, Release: { COMExportedInterface.Release($0) }) diff --git a/Support/Sources/WindowsRuntime/IActivationFactory.swift b/Support/Sources/WindowsRuntime/IActivationFactory.swift index 156ea96c..98befe8e 100644 --- a/Support/Sources/WindowsRuntime/IActivationFactory.swift +++ b/Support/Sources/WindowsRuntime/IActivationFactory.swift @@ -9,11 +9,10 @@ public protocol IActivationFactoryProtocol: IInspectableProtocol { public enum IActivationFactoryProjection: WinRTInterfaceProjection { public typealias SwiftObject = IActivationFactory public typealias COMInterface = WindowsRuntime_ABI.SWRT_IActivationFactory - public typealias COMVirtualTable = WindowsRuntime_ABI.SWRT_IActivationFactoryVTable public static var typeName: String { "IActivationFactory" } public static var interfaceID: COMInterfaceID { COMInterface.iid } - public static var virtualTablePointer: COMVirtualTablePointer { fatalError("Not implemented: \(#function)") } + public static var virtualTablePointer: UnsafeRawPointer { fatalError("Not implemented: \(#function)") } public static func toSwift(_ reference: consuming COMReference) -> SwiftObject { Import.toSwift(reference) diff --git a/Support/Sources/WindowsRuntime/IBufferByteAccess.swift b/Support/Sources/WindowsRuntime/IBufferByteAccess.swift index f19ca464..f553ea78 100644 --- a/Support/Sources/WindowsRuntime/IBufferByteAccess.swift +++ b/Support/Sources/WindowsRuntime/IBufferByteAccess.swift @@ -9,10 +9,9 @@ public protocol IBufferByteAccessProtocol: IUnknownProtocol { public enum IBufferByteAccessProjection: COMTwoWayProjection { public typealias SwiftObject = IBufferByteAccess public typealias COMInterface = WindowsRuntime_ABI.SWRT_IBufferByteAccess - public typealias COMVirtualTable = WindowsRuntime_ABI.SWRT_IBufferByteAccessVTable public static var interfaceID: COMInterfaceID { COMInterface.iid } - public static var virtualTablePointer: COMVirtualTablePointer { withUnsafePointer(to: &virtualTable) { $0 } } + public static var virtualTablePointer: UnsafeRawPointer { .init(withUnsafePointer(to: &virtualTable) { $0 }) } public static func toSwift(_ reference: consuming COMReference) -> SwiftObject { Import.toSwift(reference) @@ -26,7 +25,7 @@ public enum IBufferByteAccessProjection: COMTwoWayProjection { public var buffer: UnsafeMutablePointer { get throws { try NullResult.unwrap(_interop.buffer()) } } } - private static var virtualTable: COMVirtualTable = .init( + private static var virtualTable: WindowsRuntime_ABI.SWRT_IBufferByteAccessVTable = .init( QueryInterface: { COMExportedInterface.QueryInterface($0, $1, $2) }, AddRef: { COMExportedInterface.AddRef($0) }, Release: { COMExportedInterface.Release($0) }, diff --git a/Support/Sources/WindowsRuntime/IInspectable.swift b/Support/Sources/WindowsRuntime/IInspectable.swift index adb1e6d8..2c6ad642 100644 --- a/Support/Sources/WindowsRuntime/IInspectable.swift +++ b/Support/Sources/WindowsRuntime/IInspectable.swift @@ -12,11 +12,10 @@ public protocol IInspectableProtocol: IUnknownProtocol { public enum IInspectableProjection: WinRTInterfaceProjection { public typealias SwiftObject = IInspectable public typealias COMInterface = WindowsRuntime_ABI.SWRT_IInspectable - public typealias COMVirtualTable = WindowsRuntime_ABI.SWRT_IInspectableVTable public static var typeName: String { "IInspectable" } public static var interfaceID: COMInterfaceID { COMInterface.iid } - public static var virtualTablePointer: COMVirtualTablePointer { withUnsafePointer(to: &virtualTable) { $0 } } + public static var virtualTablePointer: UnsafeRawPointer { .init(withUnsafePointer(to: &virtualTable) { $0 }) } public static func toSwift(_ reference: consuming COMReference) -> SwiftObject { Import.toSwift(reference) @@ -28,7 +27,7 @@ public enum IInspectableProjection: WinRTInterfaceProjection { private final class Import: WinRTImport {} - private static var virtualTable: COMVirtualTable = .init( + private static var virtualTable: WindowsRuntime_ABI.SWRT_IInspectableVTable = .init( QueryInterface: { COMExportedInterface.QueryInterface($0, $1, $2) }, AddRef: { COMExportedInterface.AddRef($0) }, Release: { COMExportedInterface.Release($0) }, diff --git a/Support/Sources/WindowsRuntime/IReferenceUnboxingProjection.swift b/Support/Sources/WindowsRuntime/IReferenceUnboxingProjection.swift index fa501145..f33a4270 100644 --- a/Support/Sources/WindowsRuntime/IReferenceUnboxingProjection.swift +++ b/Support/Sources/WindowsRuntime/IReferenceUnboxingProjection.swift @@ -20,7 +20,6 @@ public enum IReferenceUnboxingProjection { public enum Of: WinRTProjection, COMProjection { public typealias SwiftObject = Projection.SwiftValue public typealias COMInterface = WindowsRuntime_ABI.SWRT_WindowsFoundation_IReference - public typealias COMVirtualTable = WindowsRuntime_ABI.SWRT_WindowsFoundation_IReferenceVTable public static var typeName: Swift.String { "Windows.Foundation.IReference`1<\(Projection.typeName)>" } public static var interfaceID: COMInterfaceID { Projection.ireferenceID } diff --git a/Support/Sources/WindowsRuntime/IRestrictedErrorInfo.swift b/Support/Sources/WindowsRuntime/IRestrictedErrorInfo.swift index 990e0250..6b20725b 100644 --- a/Support/Sources/WindowsRuntime/IRestrictedErrorInfo.swift +++ b/Support/Sources/WindowsRuntime/IRestrictedErrorInfo.swift @@ -14,10 +14,9 @@ public protocol IRestrictedErrorInfoProtocol: IUnknownProtocol { public enum IRestrictedErrorInfoProjection: COMTwoWayProjection { public typealias SwiftObject = IRestrictedErrorInfo public typealias COMInterface = WindowsRuntime_ABI.SWRT_IRestrictedErrorInfo - public typealias COMVirtualTable = WindowsRuntime_ABI.SWRT_IRestrictedErrorInfoVTable public static var interfaceID: COMInterfaceID { COMInterface.iid } - public static var virtualTablePointer: COMVirtualTablePointer { withUnsafePointer(to: &virtualTable) { $0 } } + public static var virtualTablePointer: UnsafeRawPointer { .init(withUnsafePointer(to: &virtualTable) { $0 }) } public static func toSwift(_ reference: consuming COMReference) -> SwiftObject { Import.toSwift(reference) @@ -39,7 +38,7 @@ public enum IRestrictedErrorInfoProjection: COMTwoWayProjection { public var reference: String? { get throws { try _interop.getReference() } } } - private static var virtualTable: COMVirtualTable = .init( + private static var virtualTable: WindowsRuntime_ABI.SWRT_IRestrictedErrorInfoVTable = .init( QueryInterface: { COMExportedInterface.QueryInterface($0, $1, $2) }, AddRef: { COMExportedInterface.AddRef($0) }, Release: { COMExportedInterface.Release($0) }, diff --git a/Support/Sources/WindowsRuntime/IWeakReference.swift b/Support/Sources/WindowsRuntime/IWeakReference.swift index 22fc5705..4db86370 100644 --- a/Support/Sources/WindowsRuntime/IWeakReference.swift +++ b/Support/Sources/WindowsRuntime/IWeakReference.swift @@ -8,10 +8,9 @@ public protocol IWeakReferenceProtocol: IUnknownProtocol { public enum IWeakReferenceProjection: COMTwoWayProjection { public typealias SwiftObject = IWeakReference public typealias COMInterface = WindowsRuntime_ABI.SWRT_IWeakReference - public typealias COMVirtualTable = WindowsRuntime_ABI.SWRT_IWeakReferenceVTable public static var interfaceID: COMInterfaceID { COMInterface.iid } - public static var virtualTablePointer: COMVirtualTablePointer { withUnsafePointer(to: &virtualTable) { $0 } } + public static var virtualTablePointer: UnsafeRawPointer { .init(withUnsafePointer(to: &virtualTable) { $0 }) } public static func toSwift(_ reference: consuming COMReference) -> SwiftObject { Import.toSwift(reference) @@ -27,7 +26,7 @@ public enum IWeakReferenceProjection: COMTwoWayProjection { } } - private static var virtualTable: COMVirtualTable = .init( + private static var virtualTable: WindowsRuntime_ABI.SWRT_IWeakReferenceVTable = .init( QueryInterface: { COMExportedInterface.QueryInterface($0, $1, $2) }, AddRef: { COMExportedInterface.AddRef($0) }, Release: { COMExportedInterface.Release($0) }, diff --git a/Support/Sources/WindowsRuntime/IWeakReferenceSource.swift b/Support/Sources/WindowsRuntime/IWeakReferenceSource.swift index 5396644c..6219c078 100644 --- a/Support/Sources/WindowsRuntime/IWeakReferenceSource.swift +++ b/Support/Sources/WindowsRuntime/IWeakReferenceSource.swift @@ -8,10 +8,9 @@ public protocol IWeakReferenceSourceProtocol: IUnknownProtocol { public enum IWeakReferenceSourceProjection: COMTwoWayProjection { public typealias SwiftObject = IWeakReferenceSource public typealias COMInterface = WindowsRuntime_ABI.SWRT_IWeakReferenceSource - public typealias COMVirtualTable = WindowsRuntime_ABI.SWRT_IWeakReferenceSourceVTable public static var interfaceID: COMInterfaceID { COMInterface.iid } - public static var virtualTablePointer: COMVirtualTablePointer { withUnsafePointer(to: &virtualTable) { $0 } } + public static var virtualTablePointer: UnsafeRawPointer { .init(withUnsafePointer(to: &virtualTable) { $0 }) } public static func toSwift(_ reference: consuming COMReference) -> SwiftObject { Import.toSwift(reference) @@ -27,7 +26,7 @@ public enum IWeakReferenceSourceProjection: COMTwoWayProjection { } } - private static var virtualTable: COMVirtualTable = .init( + private static var virtualTable: WindowsRuntime_ABI.SWRT_IWeakReferenceSourceVTable = .init( QueryInterface: { COMExportedInterface.QueryInterface($0, $1, $2) }, AddRef: { COMExportedInterface.AddRef($0) }, Release: { COMExportedInterface.Release($0) }, diff --git a/Support/Sources/WindowsRuntime/WindowsFoundation/IReference.swift b/Support/Sources/WindowsRuntime/WindowsFoundation/IReference.swift index 8e0f9159..a95114ab 100644 --- a/Support/Sources/WindowsRuntime/WindowsFoundation/IReference.swift +++ b/Support/Sources/WindowsRuntime/WindowsFoundation/IReference.swift @@ -25,11 +25,10 @@ extension WindowsFoundation_IReferenceProtocol { public enum WindowsFoundation_IReferenceProjection: WinRTInterfaceProjection { public typealias SwiftObject = WindowsFoundation_IReference public typealias COMInterface = WindowsRuntime_ABI.SWRT_WindowsFoundation_IReference - public typealias COMVirtualTable = WindowsRuntime_ABI.SWRT_WindowsFoundation_IReferenceVTable public static var typeName: String { fatalError("Windows.Foundation.IReference`1<\(TProjection.typeName)>") } public static var interfaceID: COMInterfaceID { TProjection.ireferenceID } - public static var virtualTablePointer: COMVirtualTablePointer { withUnsafePointer(to: &virtualTable) { $0 } } + public static var virtualTablePointer: UnsafeRawPointer { .init(withUnsafePointer(to: &virtualTable) { $0 }) } public static func toSwift(_ reference: consuming COMReference) -> SwiftObject { Import.toSwift(consume reference) diff --git a/Support/Sources/WindowsRuntime/WindowsFoundation/IStringable.swift b/Support/Sources/WindowsRuntime/WindowsFoundation/IStringable.swift index b9c09136..ec542d14 100644 --- a/Support/Sources/WindowsRuntime/WindowsFoundation/IStringable.swift +++ b/Support/Sources/WindowsRuntime/WindowsFoundation/IStringable.swift @@ -12,11 +12,10 @@ public protocol WindowsFoundation_IStringableProtocol: IInspectableProtocol { public enum WindowsFoundation_IStringableProjection: WinRTInterfaceProjection { public typealias SwiftObject = WindowsFoundation_IStringable public typealias COMInterface = WindowsRuntime_ABI.SWRT_WindowsFoundation_IStringable - public typealias COMVirtualTable = WindowsRuntime_ABI.SWRT_WindowsFoundation_IStringableVTable public static var typeName: String { "Windows.Foundation.IStringable" } public static var interfaceID: COMInterfaceID { COMInterface.iid } - public static var virtualTablePointer: COMVirtualTablePointer { withUnsafePointer(to: &virtualTable) { $0 } } + public static var virtualTablePointer: UnsafeRawPointer { .init(withUnsafePointer(to: &virtualTable) { $0 }) } public static func toSwift(_ reference: consuming COMReference) -> SwiftObject { Import.toSwift(reference) @@ -32,7 +31,7 @@ public enum WindowsFoundation_IStringableProjection: WinRTInterfaceProjection { } } - private static var virtualTable: COMVirtualTable = .init( + private static var virtualTable: WindowsRuntime_ABI.SWRT_WindowsFoundation_IStringableVTable = .init( QueryInterface: { COMExportedInterface.QueryInterface($0, $1, $2) }, AddRef: { COMExportedInterface.AddRef($0) }, Release: { COMExportedInterface.Release($0) }, diff --git a/Support/Sources/WindowsRuntime_ABI/include/SWRT/SwiftCOMObject.h b/Support/Sources/WindowsRuntime_ABI/include/SWRT/SwiftCOMObject.h index e330639c..ff0ce342 100644 --- a/Support/Sources/WindowsRuntime_ABI/include/SWRT/SwiftCOMObject.h +++ b/Support/Sources/WindowsRuntime_ABI/include/SWRT/SwiftCOMObject.h @@ -1,9 +1,7 @@ #pragma once -#include "SWRT/unknwn.h" - // A COM-compliant structure for bridging Swift objects into COM. typedef struct SWRT_SwiftCOMObject { - const struct SWRT_IUnknownVTable* comVirtualTable; + const void* virtualTable; void* swiftObject; } SWRT_SwiftCOMObject; \ No newline at end of file diff --git a/Support/Tests/IInspectable2.swift b/Support/Tests/IInspectable2.swift index 9d8c4cb1..7b17eaed 100644 --- a/Support/Tests/IInspectable2.swift +++ b/Support/Tests/IInspectable2.swift @@ -7,11 +7,10 @@ internal typealias IInspectable2 = any IInspectable2Protocol internal enum IInspectable2Projection: WinRTInterfaceProjection { public typealias SwiftObject = IInspectable2 public typealias COMInterface = WindowsRuntime_ABI.SWRT_IInspectable - public typealias COMVirtualTable = WindowsRuntime_ABI.SWRT_IInspectableVTable public static var typeName: String { "IInspectable2" } public static let interfaceID = COMInterfaceID(0xB6706A54, 0xCC67, 0x4090, 0x822D, 0xE165C8E36C11) - public static var virtualTablePointer: COMVirtualTablePointer { withUnsafePointer(to: &virtualTable) { $0 } } + public static var virtualTablePointer: UnsafeRawPointer { .init(withUnsafePointer(to: &virtualTable) { $0 }) } public static func toSwift(_ reference: consuming COMReference) -> SwiftObject { Import.toSwift(reference) @@ -23,7 +22,7 @@ internal enum IInspectable2Projection: WinRTInterfaceProjection { private final class Import: WinRTImport, IInspectable2Protocol {} - private static var virtualTable: COMVirtualTable = .init( + private static var virtualTable: WindowsRuntime_ABI.SWRT_IInspectableVTable = .init( QueryInterface: { COMExportedInterface.QueryInterface($0, $1, $2) }, AddRef: { COMExportedInterface.AddRef($0) }, Release: { COMExportedInterface.Release($0) }, diff --git a/Support/Tests/IUnknown2.swift b/Support/Tests/IUnknown2.swift index 2c8f64db..d2335c45 100644 --- a/Support/Tests/IUnknown2.swift +++ b/Support/Tests/IUnknown2.swift @@ -7,10 +7,9 @@ internal typealias IUnknown2 = any IUnknown2Protocol internal enum IUnknown2Projection: COMTwoWayProjection { public typealias SwiftObject = IUnknown2 public typealias COMInterface = WindowsRuntime_ABI.SWRT_IUnknown - public typealias COMVirtualTable = WindowsRuntime_ABI.SWRT_IUnknownVTable public static let interfaceID = COMInterfaceID(0x5CF9DEB3, 0xD7C6, 0x42A9, 0x85B3, 0x61D8B68A7B2A) - public static var virtualTablePointer: COMVirtualTablePointer { withUnsafePointer(to: &virtualTable) { $0 } } + public static var virtualTablePointer: UnsafeRawPointer { .init(withUnsafePointer(to: &virtualTable) { $0 }) } public static func toSwift(_ reference: consuming COMReference) -> SwiftObject { Import.toSwift(reference) @@ -22,7 +21,7 @@ internal enum IUnknown2Projection: COMTwoWayProjection { private final class Import: COMImport, IUnknown2Protocol {} - private static var virtualTable: COMVirtualTable = .init( + private static var virtualTable: WindowsRuntime_ABI.SWRT_IUnknownVTable = .init( QueryInterface: { COMExportedInterface.QueryInterface($0, $1, $2) }, AddRef: { COMExportedInterface.AddRef($0) }, Release: { COMExportedInterface.Release($0) })