Skip to content

Commit

Permalink
Rename lpVtbl to VirtualTable (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanlabelle authored Mar 29, 2024
1 parent dd5548e commit 3749ea0
Show file tree
Hide file tree
Showing 24 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Generator/Sources/ProjectionModel/CAbi/CAbi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,5 @@ public enum CAbi {
public static var iactivationFactoryName: String { namespacingPrefix + "IActivationFactory" }

public static var virtualTableSuffix: String { "VTable" }
public static var virtualTableFieldName: String { "lpVtbl" }
public static var virtualTableFieldName: String { "VirtualTable" }
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ fileprivate func writeSwiftToAbiCall(

func writeCall() throws {
writer.writeStatement("try WinRTError.throwIfFailed("
+ "this.pointee.lpVtbl.pointee.\(abiMethodName)("
+ "this.pointee.VirtualTable.pointee.\(abiMethodName)("
+ "\(abiArgs.joined(separator: ", "))))")
}

Expand Down
6 changes: 3 additions & 3 deletions Support/Sources/COM/COMInterop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ public struct COMInterop<Interface> /* where Interface: COMIUnknownStruct */ {

@discardableResult
public func addRef() -> UInt32 {
unknown.pointee.lpVtbl.pointee.AddRef(unknown)
unknown.pointee.VirtualTable.pointee.AddRef(unknown)
}

@discardableResult
public func release() -> UInt32 {
unknown.pointee.lpVtbl.pointee.Release(unknown)
unknown.pointee.VirtualTable.pointee.Release(unknown)
}

public func queryInterface(_ id: COMInterfaceID) throws -> IUnknownReference {
var iid = GUIDProjection.toABI(id)
var rawPointer: UnsafeMutableRawPointer? = nil
try HResult.throwIfFailed(unknown.pointee.lpVtbl.pointee.QueryInterface(unknown, &iid, &rawPointer))
try HResult.throwIfFailed(unknown.pointee.VirtualTable.pointee.QueryInterface(unknown, &iid, &rawPointer))
guard let rawPointer else {
assertionFailure("QueryInterface succeeded but returned a null pointer")
throw HResult.Error.noInterface
Expand Down
10 changes: 5 additions & 5 deletions Support/Sources/COM/IErrorInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,31 @@ extension WindowsRuntime_ABI.SWRT_IErrorInfo: /* @retroactive */ COMIUnknownStru
extension COMInterop where Interface == WindowsRuntime_ABI.SWRT_IErrorInfo {
public func getGuid() throws -> Foundation.UUID {
var value = GUIDProjection.abiDefaultValue
try HResult.throwIfFailed(this.pointee.lpVtbl.pointee.GetGUID(this, &value))
try HResult.throwIfFailed(this.pointee.VirtualTable.pointee.GetGUID(this, &value))
return GUIDProjection.toSwift(value)
}

public func getSource() throws -> String? {
var value = BStrProjection.abiDefaultValue
try HResult.throwIfFailed(this.pointee.lpVtbl.pointee.GetSource(this, &value))
try HResult.throwIfFailed(this.pointee.VirtualTable.pointee.GetSource(this, &value))
return BStrProjection.toSwift(consuming: &value)
}

public func getDescription() throws -> String? {
var value = BStrProjection.abiDefaultValue
try HResult.throwIfFailed(this.pointee.lpVtbl.pointee.GetDescription(this, &value))
try HResult.throwIfFailed(this.pointee.VirtualTable.pointee.GetDescription(this, &value))
return BStrProjection.toSwift(consuming: &value)
}

public func getHelpFile() throws -> String? {
var value = BStrProjection.abiDefaultValue
try HResult.throwIfFailed(this.pointee.lpVtbl.pointee.GetHelpFile(this, &value))
try HResult.throwIfFailed(this.pointee.VirtualTable.pointee.GetHelpFile(this, &value))
return BStrProjection.toSwift(consuming: &value)
}

public func getHelpContext() throws -> UInt32 {
var value = UInt32()
try HResult.throwIfFailed(this.pointee.lpVtbl.pointee.GetHelpContext(this, &value))
try HResult.throwIfFailed(this.pointee.VirtualTable.pointee.GetHelpContext(this, &value))
return value
}
}
4 changes: 2 additions & 2 deletions Support/Sources/WindowsRuntime/IActivationFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ extension COMInterop where Interface == WindowsRuntime_ABI.SWRT_IActivationFacto
// Activation factory methods are special-cased to return the pointer.
public func activateInstance() throws -> IInspectablePointer? {
var instance = IInspectableProjection.abiDefaultValue
try WinRTError.throwIfFailed(this.pointee.lpVtbl.pointee.ActivateInstance(this, &instance))
try WinRTError.throwIfFailed(this.pointee.VirtualTable.pointee.ActivateInstance(this, &instance))
return instance
}

// TODO: Move elsewhere to keep COMInterop only for bridging.
public func activateInstance<Projection: WinRTProjection & COMProjection>(projection: Projection.Type) throws -> Projection.COMPointer {
var inspectable = IInspectableProjection.abiDefaultValue
try WinRTError.throwIfFailed(this.pointee.lpVtbl.pointee.ActivateInstance(this, &inspectable))
try WinRTError.throwIfFailed(this.pointee.VirtualTable.pointee.ActivateInstance(this, &inspectable))
defer { IInspectableProjection.release(&inspectable) }
guard let inspectable else { throw COM.HResult.Error.noInterface }
return try COMInterop<IInspectableProjection.COMInterface>(inspectable)
Expand Down
2 changes: 1 addition & 1 deletion Support/Sources/WindowsRuntime/IBufferByteAccess.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ extension WindowsRuntime_ABI.SWRT_IBufferByteAccess {
extension COMInterop where Interface == WindowsRuntime_ABI.SWRT_IBufferByteAccess {
public func buffer() throws -> UnsafeMutablePointer<UInt8>? {
var value = UnsafeMutablePointer<UInt8>(bitPattern: 0)
try HResult.throwIfFailed(this.pointee.lpVtbl.pointee.Buffer(this, &value))
try HResult.throwIfFailed(this.pointee.VirtualTable.pointee.Buffer(this, &value))
return value
}
}
6 changes: 3 additions & 3 deletions Support/Sources/WindowsRuntime/IInspectable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ extension COMInterop where Interface: /* @retroactive */ COMIInspectableStruct {

public func getIids() throws -> [Foundation.UUID] {
var iids: COMArray<WindowsRuntime_ABI.SWRT_Guid> = .null
try WinRTError.throwIfFailed(inspectable.pointee.lpVtbl.pointee.GetIids(inspectable, &iids.count, &iids.pointer))
try WinRTError.throwIfFailed(inspectable.pointee.VirtualTable.pointee.GetIids(inspectable, &iids.count, &iids.pointer))
defer { iids.deallocate() }
return WinRTArrayProjection<GUIDProjection>.toSwift(consuming: &iids)
}

public func getRuntimeClassName() throws -> String {
var runtimeClassName: WindowsRuntime_ABI.SWRT_HString?
try WinRTError.throwIfFailed(inspectable.pointee.lpVtbl.pointee.GetRuntimeClassName(inspectable, &runtimeClassName))
try WinRTError.throwIfFailed(inspectable.pointee.VirtualTable.pointee.GetRuntimeClassName(inspectable, &runtimeClassName))
return WinRTPrimitiveProjection.String.toSwift(consuming: &runtimeClassName)
}

public func getTrustLevel() throws -> TrustLevel {
var trustLevel: WindowsRuntime_ABI.SWRT_TrustLevel = 0
try WinRTError.throwIfFailed(inspectable.pointee.lpVtbl.pointee.GetTrustLevel(inspectable, &trustLevel))
try WinRTError.throwIfFailed(inspectable.pointee.VirtualTable.pointee.GetTrustLevel(inspectable, &trustLevel))
return TrustLevel.toSwift(trustLevel)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public enum IReferenceUnboxingProjection {
public static func toSwift(_ reference: consuming COMReference<COMInterface>) -> SwiftObject {
var abiValue = Projection.abiDefaultValue
withUnsafeMutablePointer(to: &abiValue) { abiValuePointer in
_ = try! HResult.throwIfFailed(reference.pointer.pointee.lpVtbl.pointee.get_Value(
_ = try! HResult.throwIfFailed(reference.pointer.pointee.VirtualTable.pointee.get_Value(
reference.pointer, abiValuePointer))
}
return Projection.toSwift(consuming: &abiValue)
Expand Down
4 changes: 2 additions & 2 deletions Support/Sources/WindowsRuntime/IRestrictedErrorInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ extension COMInterop where Interface == WindowsRuntime_ABI.SWRT_IRestrictedError
defer { BStrProjection.release(&restrictedDescription_) }
var capabilitySid_: WindowsRuntime_ABI.SWRT_BStr? = nil
defer { BStrProjection.release(&capabilitySid_) }
try HResult.throwIfFailed(this.pointee.lpVtbl.pointee.GetErrorDetails(this, &description_, &error_, &restrictedDescription_, &capabilitySid_))
try HResult.throwIfFailed(this.pointee.VirtualTable.pointee.GetErrorDetails(this, &description_, &error_, &restrictedDescription_, &capabilitySid_))
description = BStrProjection.toSwift(consuming: &description_)
error = HResultProjection.toSwift(error_)
restrictedDescription = BStrProjection.toSwift(consuming: &restrictedDescription_)
Expand All @@ -94,7 +94,7 @@ extension COMInterop where Interface == WindowsRuntime_ABI.SWRT_IRestrictedError

public func getReference() throws -> String? {
var value = BStrProjection.abiDefaultValue
try HResult.throwIfFailed(this.pointee.lpVtbl.pointee.GetReference(this, &value))
try HResult.throwIfFailed(this.pointee.VirtualTable.pointee.GetReference(this, &value))
return BStrProjection.toSwift(consuming: &value)
}
}
2 changes: 1 addition & 1 deletion Support/Sources/WindowsRuntime/IWeakReference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ extension COMInterop where Interface == WindowsRuntime_ABI.SWRT_IWeakReference {
public func resolve(_ iid: COMInterfaceID) throws -> IInspectable? {
var iid = GUIDProjection.toABI(iid)
var objectReference = IInspectableProjection.abiDefaultValue
try HResult.throwIfFailed(this.pointee.lpVtbl.pointee.Resolve(this, &iid, &objectReference))
try HResult.throwIfFailed(this.pointee.VirtualTable.pointee.Resolve(this, &iid, &objectReference))
return IInspectableProjection.toSwift(consuming: &objectReference)
}
}
2 changes: 1 addition & 1 deletion Support/Sources/WindowsRuntime/IWeakReferenceSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extension WindowsRuntime_ABI.SWRT_IWeakReferenceSource: /* @retroactive */ COMII
extension COMInterop where Interface == WindowsRuntime_ABI.SWRT_IWeakReferenceSource {
public func getWeakReference() throws -> IWeakReference? {
var value = IWeakReferenceProjection.abiDefaultValue
try HResult.throwIfFailed(this.pointee.lpVtbl.pointee.GetWeakReference(this, &value))
try HResult.throwIfFailed(this.pointee.VirtualTable.pointee.GetWeakReference(this, &value))
return IWeakReferenceProjection.toSwift(consuming: &value)
}
}
26 changes: 13 additions & 13 deletions Support/Sources/WindowsRuntime/PropertyValueStatics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,78 +18,78 @@ internal enum PropertyValueStatics {

public static func createUInt8(_ value: UInt8) throws -> COMReference<SWRT_IInspectable> {
var propertyValue: IInspectablePointer? = nil
try WinRTError.throwIfFailed(this.pointee.lpVtbl.pointee.CreateUInt8(this, value, &propertyValue))
try WinRTError.throwIfFailed(this.pointee.VirtualTable.pointee.CreateUInt8(this, value, &propertyValue))
guard let propertyValue else { throw HResult.Error.pointer }
return COMReference(transferringRef: propertyValue)
}

public static func createInt16(_ value: Int16) throws -> COMReference<SWRT_IInspectable> {
var propertyValue: IInspectablePointer? = nil
try WinRTError.throwIfFailed(this.pointee.lpVtbl.pointee.CreateInt16(this, value, &propertyValue))
try WinRTError.throwIfFailed(this.pointee.VirtualTable.pointee.CreateInt16(this, value, &propertyValue))
guard let propertyValue else { throw HResult.Error.pointer }
return COMReference(transferringRef: propertyValue)
}

public static func createUInt16(_ value: UInt16) throws -> COMReference<SWRT_IInspectable> {
var propertyValue: IInspectablePointer? = nil
try WinRTError.throwIfFailed(this.pointee.lpVtbl.pointee.CreateUInt16(this, value, &propertyValue))
try WinRTError.throwIfFailed(this.pointee.VirtualTable.pointee.CreateUInt16(this, value, &propertyValue))
guard let propertyValue else { throw HResult.Error.pointer }
return COMReference(transferringRef: propertyValue)
}

public static func createInt32(_ value: Int32) throws -> COMReference<SWRT_IInspectable> {
var propertyValue: IInspectablePointer? = nil
try WinRTError.throwIfFailed(this.pointee.lpVtbl.pointee.CreateInt32(this, value, &propertyValue))
try WinRTError.throwIfFailed(this.pointee.VirtualTable.pointee.CreateInt32(this, value, &propertyValue))
guard let propertyValue else { throw HResult.Error.pointer }
return COMReference(transferringRef: propertyValue)
}

public static func createUInt32(_ value: UInt32) throws -> COMReference<SWRT_IInspectable> {
var propertyValue: IInspectablePointer? = nil
try WinRTError.throwIfFailed(this.pointee.lpVtbl.pointee.CreateUInt32(this, value, &propertyValue))
try WinRTError.throwIfFailed(this.pointee.VirtualTable.pointee.CreateUInt32(this, value, &propertyValue))
guard let propertyValue else { throw HResult.Error.pointer }
return COMReference(transferringRef: propertyValue)
}

public static func createInt64(_ value: Int64) throws -> COMReference<SWRT_IInspectable> {
var propertyValue: IInspectablePointer? = nil
try WinRTError.throwIfFailed(this.pointee.lpVtbl.pointee.CreateInt64(this, value, &propertyValue))
try WinRTError.throwIfFailed(this.pointee.VirtualTable.pointee.CreateInt64(this, value, &propertyValue))
guard let propertyValue else { throw HResult.Error.pointer }
return COMReference(transferringRef: propertyValue)
}

public static func createUInt64(_ value: UInt64) throws -> COMReference<SWRT_IInspectable> {
var propertyValue: IInspectablePointer? = nil
try WinRTError.throwIfFailed(this.pointee.lpVtbl.pointee.CreateUInt64(this, value, &propertyValue))
try WinRTError.throwIfFailed(this.pointee.VirtualTable.pointee.CreateUInt64(this, value, &propertyValue))
guard let propertyValue else { throw HResult.Error.pointer }
return COMReference(transferringRef: propertyValue)
}

public static func createSingle(_ value: Float) throws -> COMReference<SWRT_IInspectable> {
var propertyValue: IInspectablePointer? = nil
try WinRTError.throwIfFailed(this.pointee.lpVtbl.pointee.CreateSingle(this, value, &propertyValue))
try WinRTError.throwIfFailed(this.pointee.VirtualTable.pointee.CreateSingle(this, value, &propertyValue))
guard let propertyValue else { throw HResult.Error.pointer }
return COMReference(transferringRef: propertyValue)
}

public static func createDouble(_ value: Double) throws -> COMReference<SWRT_IInspectable> {
var propertyValue: IInspectablePointer? = nil
try WinRTError.throwIfFailed(this.pointee.lpVtbl.pointee.CreateDouble(this, value, &propertyValue))
try WinRTError.throwIfFailed(this.pointee.VirtualTable.pointee.CreateDouble(this, value, &propertyValue))
guard let propertyValue else { throw HResult.Error.pointer }
return COMReference(transferringRef: propertyValue)
}

public static func createChar16(_ value: Char16) throws -> COMReference<SWRT_IInspectable> {
var propertyValue: IInspectablePointer? = nil
let value = WinRTPrimitiveProjection.Char16.toABI(value)
try WinRTError.throwIfFailed(this.pointee.lpVtbl.pointee.CreateChar16(this, value, &propertyValue))
try WinRTError.throwIfFailed(this.pointee.VirtualTable.pointee.CreateChar16(this, value, &propertyValue))
guard let propertyValue else { throw HResult.Error.pointer }
return COMReference(transferringRef: propertyValue)
}

public static func createBoolean(_ value: Bool) throws -> COMReference<SWRT_IInspectable> {
var propertyValue: IInspectablePointer? = nil
try WinRTError.throwIfFailed(this.pointee.lpVtbl.pointee.CreateBoolean(this, value, &propertyValue))
try WinRTError.throwIfFailed(this.pointee.VirtualTable.pointee.CreateBoolean(this, value, &propertyValue))
guard let propertyValue else { throw HResult.Error.pointer }
return COMReference(transferringRef: propertyValue)
}
Expand All @@ -98,15 +98,15 @@ internal enum PropertyValueStatics {
var value_abi = try WinRTPrimitiveProjection.String.toABI(value)
defer { WinRTPrimitiveProjection.String.release(&value_abi) }
var propertyValue: IInspectablePointer? = nil
try WinRTError.throwIfFailed(this.pointee.lpVtbl.pointee.CreateString(this, value_abi, &propertyValue))
try WinRTError.throwIfFailed(this.pointee.VirtualTable.pointee.CreateString(this, value_abi, &propertyValue))
guard let propertyValue else { throw HResult.Error.pointer }
return COMReference(transferringRef: propertyValue)
}

public static func createGuid(_ value: UUID) throws -> COMReference<SWRT_IInspectable> {
let value_abi = COM.GUIDProjection.toABI(value)
var propertyValue: IInspectablePointer? = nil
try WinRTError.throwIfFailed(this.pointee.lpVtbl.pointee.CreateGuid(this, value_abi, &propertyValue))
try WinRTError.throwIfFailed(this.pointee.VirtualTable.pointee.CreateGuid(this, value_abi, &propertyValue))
guard let propertyValue else { throw HResult.Error.pointer }
return COMReference(transferringRef: propertyValue)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extension WinRTBoxableProjection {
let ireference = try inspectable._queryInterface(ireferenceID).reinterpret(to: SWRT_WindowsFoundation_IReference.self)
var abiValue = abiDefaultValue
try withUnsafeMutablePointer(to: &abiValue) { abiValuePointer in
_ = try WinRTError.throwIfFailed(ireference.pointer.pointee.lpVtbl.pointee.get_Value(ireference.pointer, abiValuePointer))
_ = try WinRTError.throwIfFailed(ireference.pointer.pointee.VirtualTable.pointee.get_Value(ireference.pointer, abiValuePointer))
}
return toSwift(consuming: &abiValue)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ extension WindowsRuntime_ABI.SWRT_WindowsFoundation_IReference: @retroactive COM

extension COMInterop where Interface == WindowsRuntime_ABI.SWRT_WindowsFoundation_IReference {
public func get_Value(_ value: UnsafeMutableRawPointer) throws {
try HResult.throwIfFailed(this.pointee.lpVtbl.pointee.get_Value(this, value))
try HResult.throwIfFailed(this.pointee.VirtualTable.pointee.get_Value(this, value))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extension WindowsRuntime_ABI.SWRT_WindowsFoundation_IStringable: /* @retroactive
extension COMInterop where Interface == WindowsRuntime_ABI.SWRT_WindowsFoundation_IStringable {
public func toString() throws -> String {
var value = WinRTPrimitiveProjection.String.abiDefaultValue
try HResult.throwIfFailed(this.pointee.lpVtbl.pointee.ToString(this, &value))
try HResult.throwIfFailed(this.pointee.VirtualTable.pointee.ToString(this, &value))
return WinRTPrimitiveProjection.String.toSwift(consuming: &value)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// IActivationFactory
typedef struct SWRT_IActivationFactory {
struct SWRT_IActivationFactoryVTable* lpVtbl;
struct SWRT_IActivationFactoryVTable* VirtualTable;
} SWRT_IActivationFactory;

struct SWRT_IActivationFactoryVTable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ typedef int32_t SWRT_TrustLevel;

// IInspectable
typedef struct SWRT_IInspectable {
struct SWRT_IInspectableVTable* lpVtbl;
struct SWRT_IInspectableVTable* VirtualTable;
} SWRT_IInspectable;

struct SWRT_IInspectableVTable {
Expand Down
2 changes: 1 addition & 1 deletion Support/Sources/WindowsRuntime_ABI/include/SWRT/oaidl.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "SWRT/unknwn.h"

typedef struct SWRT_IErrorInfo {
struct SWRT_IErrorInfoVTable* lpVtbl;
struct SWRT_IErrorInfoVTable* VirtualTable;
} SWRT_IErrorInfo;

struct SWRT_IErrorInfoVTable {
Expand Down
4 changes: 2 additions & 2 deletions Support/Sources/WindowsRuntime_ABI/include/SWRT/objidl.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

// IAgileObject
typedef struct SWRT_IAgileObject {
struct SWRT_IAgileObjectVTable* lpVtbl;
struct SWRT_IAgileObjectVTable* VirtualTable;
} SWRT_IAgileObject;

struct SWRT_IAgileObjectVTable {
Expand All @@ -20,7 +20,7 @@ typedef struct SWRT_IStream SWRT_IStream;

// IMarshal
typedef struct SWRT_IMarshal {
struct SWRT_IMarshal* lpVtbl;
struct SWRT_IMarshal* VirtualTable;
} SWRT_IMarshal;

struct SWRT_IMarshalVTable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "SWRT/unknwn.h"

typedef struct SWRT_IRestrictedErrorInfo {
struct SWRT_IRestrictedErrorInfoVTable* lpVtbl;
struct SWRT_IRestrictedErrorInfoVTable* VirtualTable;
} SWRT_IRestrictedErrorInfo;

struct SWRT_IRestrictedErrorInfoVTable {
Expand Down
Loading

0 comments on commit 3749ea0

Please sign in to comment.