From 1bdc6303ba0ca6799c25bdc617ad4834e45a6704 Mon Sep 17 00:00:00 2001 From: Tristan Labelle Date: Mon, 16 Sep 2024 19:09:27 -0400 Subject: [PATCH] Rename toSwift to fromABI --- Docs/How it works.md | 4 ++-- Generator/Sources/SwiftWinRT/Writing/ABIBinding.swift | 6 +++--- .../SwiftWinRT/Writing/COMInteropExtension.swift | 8 ++++---- .../Sources/SwiftWinRT/Writing/VirtualTable.swift | 2 +- Support/Sources/ABIBindings/ABIBinding.swift | 8 ++++---- Support/Sources/ABIBindings/BoolBinding.swift | 2 +- Support/Sources/ABIBindings/ClosedEnumBinding.swift | 2 +- Support/Sources/ABIBindings/IdentityBinding.swift | 2 +- Support/Sources/ABIBindings/NumericBinding.swift | 2 +- Support/Sources/ABIBindings/OpenEnumBinding.swift | 2 +- Support/Sources/ABIBindings/PODBinding.swift | 2 +- Support/Sources/ABIBindings/WideCharBinding.swift | 2 +- Support/Sources/COM/COMBinding.swift | 10 +++++----- Support/Sources/COM/COMEmbedding.swift | 2 +- Support/Sources/COM/COMError+createErrorInfo.swift | 2 +- Support/Sources/COM/COMError.swift | 2 +- Support/Sources/COM/Projection/BStrBinding.swift | 2 +- Support/Sources/COM/Projection/GUID.swift | 2 +- Support/Sources/COM/Projection/HResultBinding.swift | 2 +- Support/Sources/COM/Projection/ICreateErrorInfo.swift | 8 ++++---- Support/Sources/COM/Projection/IErrorInfo.swift | 8 ++++---- Support/Sources/COM/Projection/IUnknown.swift | 2 +- .../WindowsRuntime/BindingProtocols+extensions.swift | 2 +- .../WindowsRuntime/IReferenceToOptionalBinding.swift | 2 +- .../WindowsRuntime/Projection/ArrayBinding.swift | 8 ++++---- .../Projection/EventRegistrationToken.swift | 2 +- .../WindowsRuntime/Projection/IActivationFactory.swift | 2 +- .../WindowsRuntime/Projection/IInspectable.swift | 6 +++--- .../Projection/ILanguageExceptionErrorInfo.swift | 2 +- .../Projection/ILanguageExceptionErrorInfo2.swift | 6 +++--- .../Projection/IRestrictedErrorInfo.swift | 10 +++++----- .../WindowsRuntime/Projection/IWeakReference.swift | 4 ++-- .../Projection/IWeakReferenceSource.swift | 2 +- .../WindowsRuntime/Projection/PrimitiveBindings.swift | 6 +++--- .../WindowsFoundation/WindowsFoundation_DateTime.swift | 2 +- .../WindowsFoundation_IReference.swift | 2 +- .../WindowsFoundation_IReferenceArray.swift | 2 +- .../WindowsFoundation_IStringable.swift | 2 +- .../WindowsFoundation/WindowsFoundation_Point.swift | 2 +- .../WindowsFoundation/WindowsFoundation_Rect.swift | 2 +- .../WindowsFoundation/WindowsFoundation_Size.swift | 2 +- .../WindowsFoundation/WindowsFoundation_TimeSpan.swift | 2 +- .../Sources/WindowsRuntime/PropertyValueStatics.swift | 4 ++-- Support/Sources/WindowsRuntime/WeakReference.swift | 2 +- Support/Sources/WindowsRuntime/WinRTError.swift | 4 ++-- Support/Tests/IReferenceToOptionalTests.swift | 4 ++-- 46 files changed, 82 insertions(+), 82 deletions(-) diff --git a/Docs/How it works.md b/Docs/How it works.md index 4c9f693..66f895e 100644 --- a/Docs/How it works.md +++ b/Docs/How it works.md @@ -91,7 +91,7 @@ extension COMInterop when T == SWRT_IFoo { var name: BSTR? = nil defer { BStrBinding.release(&name) } try COMError.fromABI(pointer.pointee.vtable.pointee.GetName(pointer, &name)) - return BStrBinding.toSwift(name) + return BStrBinding.fromABI(name) } } @@ -123,7 +123,7 @@ enum IFooBinding: COMBinding { // COMBinding conforms to ABIBinding public static var interfaceID: COMInterfaceID { SWRT_IFoo.iid } - public static func toSwift(_ value: UnsafeMutablePointer?) -> IFoo? { + public static func fromABI(_ value: UnsafeMutablePointer?) -> IFoo? { guard let value else { return nil } return IFooImport(addingRef: value) } diff --git a/Generator/Sources/SwiftWinRT/Writing/ABIBinding.swift b/Generator/Sources/SwiftWinRT/Writing/ABIBinding.swift index 0527db8..9879f7f 100644 --- a/Generator/Sources/SwiftWinRT/Writing/ABIBinding.swift +++ b/Generator/Sources/SwiftWinRT/Writing/ABIBinding.swift @@ -124,9 +124,9 @@ fileprivate func writeStructBindingExtension( let fields = structDefinition.fields.filter { $0.isInstance } - // public static func toSwift(_ value: ABIValue) -> SwiftValue { .init(field: value.Field, ...) } + // public static func fromABI(_ value: ABIValue) -> SwiftValue { .init(field: value.Field, ...) } try writer.writeFunc( - visibility: .public, static: true, name: "toSwift", + visibility: .public, static: true, name: "fromABI", params: [.init(label: "_", name: "value", type: abiType)], returnType: .`self`) { writer in if fields.isEmpty { @@ -194,7 +194,7 @@ fileprivate func writeStructABIToSwiftInitializerParam( if typeProjection.kind != .identity { typeProjection.bindingType.write(to: &output) - output.write(".toSwift(") + output.write(".fromABI(") } SwiftIdentifier.write(abiValueName, to: &output) diff --git a/Generator/Sources/SwiftWinRT/Writing/COMInteropExtension.swift b/Generator/Sources/SwiftWinRT/Writing/COMInteropExtension.swift index 502c7bd..8470796 100644 --- a/Generator/Sources/SwiftWinRT/Writing/COMInteropExtension.swift +++ b/Generator/Sources/SwiftWinRT/Writing/COMInteropExtension.swift @@ -141,10 +141,10 @@ fileprivate func writeSwiftToABICall( let typeProjection = param.typeProjection if typeProjection.kind != .identity && param.passBy.isOutput { if typeProjection.kind == .inert { - writer.writeStatement("\(param.name) = \(typeProjection.bindingType).toSwift(\(param.abiBindingName))") + writer.writeStatement("\(param.name) = \(typeProjection.bindingType).fromABI(\(param.abiBindingName))") } else { - writer.writeStatement("\(param.name) = \(typeProjection.bindingType).toSwift(consuming: &\(param.abiBindingName))") + writer.writeStatement("\(param.name) = \(typeProjection.bindingType).fromABI(consuming: &\(param.abiBindingName))") } } } @@ -186,9 +186,9 @@ fileprivate func writeSwiftToABICall( case .identity where !returnCOMReference: returnValue = returnParam.name case .inert: - returnValue = "\(returnTypeBinding.bindingType).toSwift(\(returnParam.name))" + returnValue = "\(returnTypeBinding.bindingType).fromABI(\(returnParam.name))" default: - returnValue = "\(returnTypeBinding.bindingType).toSwift(consuming: &\(returnParam.name))" + returnValue = "\(returnTypeBinding.bindingType).fromABI(consuming: &\(returnParam.name))" } writer.writeReturnStatement(value: returnValue) diff --git a/Generator/Sources/SwiftWinRT/Writing/VirtualTable.swift b/Generator/Sources/SwiftWinRT/Writing/VirtualTable.swift index 28def1d..2d4eb2b 100644 --- a/Generator/Sources/SwiftWinRT/Writing/VirtualTable.swift +++ b/Generator/Sources/SwiftWinRT/Writing/VirtualTable.swift @@ -168,7 +168,7 @@ fileprivate func writeVirtualTableFuncImplementation(name: String, paramNames: [ fileprivate func writePrologueForParam(_ param: ParamProjection, to output: IndentedTextOutputStream) throws { if param.passBy.isInput { let declarator: SwiftVariableDeclarator = param.passBy.isOutput ? .var : .let - output.write("\(declarator) \(param.swiftBindingName) = \(param.bindingType).toSwift") + output.write("\(declarator) \(param.swiftBindingName) = \(param.bindingType).fromABI") switch param.typeProjection.kind { case .identity: fatalError("Case should have been ignored earlier.") case .inert, .allocating: diff --git a/Support/Sources/ABIBindings/ABIBinding.swift b/Support/Sources/ABIBindings/ABIBinding.swift index 5d5c0cb..da0f2d6 100644 --- a/Support/Sources/ABIBindings/ABIBinding.swift +++ b/Support/Sources/ABIBindings/ABIBinding.swift @@ -13,11 +13,11 @@ public protocol ABIBinding { /// Converts a value from its ABI to its Swift representation /// without releasing the original value. - static func toSwift(_ value: ABIValue) -> SwiftValue + static func fromABI(_ value: ABIValue) -> SwiftValue /// Converts a value from its ABI to its Swift representation, /// releasing the original value. - static func toSwift(consuming value: inout ABIValue) -> SwiftValue + static func fromABI(consuming value: inout ABIValue) -> SwiftValue /// Converts a value from its Swift to its ABI representation. /// The resulting value should be released as its creation might have allocated resources. @@ -28,9 +28,9 @@ public protocol ABIBinding { } extension ABIBinding { - public static func toSwift(consuming value: inout ABIValue) -> SwiftValue { + public static func fromABI(consuming value: inout ABIValue) -> SwiftValue { defer { release(&value) } - return toSwift(value) + return fromABI(value) } public static func withABI(_ value: SwiftValue, _ closure: (ABIValue) throws -> Result) throws -> Result { diff --git a/Support/Sources/ABIBindings/BoolBinding.swift b/Support/Sources/ABIBindings/BoolBinding.swift index 0058629..246d195 100644 --- a/Support/Sources/ABIBindings/BoolBinding.swift +++ b/Support/Sources/ABIBindings/BoolBinding.swift @@ -4,6 +4,6 @@ public enum BoolBinding: PODBinding { public typealias SwiftValue = Bool public static var abiDefaultValue: CBool { false } - public static func toSwift(_ value: CBool) -> Bool { value } + public static func fromABI(_ value: CBool) -> Bool { value } public static func toABI(_ value: Bool) -> CBool { value } } \ No newline at end of file diff --git a/Support/Sources/ABIBindings/ClosedEnumBinding.swift b/Support/Sources/ABIBindings/ClosedEnumBinding.swift index 7e4df8d..1a24d3d 100644 --- a/Support/Sources/ABIBindings/ClosedEnumBinding.swift +++ b/Support/Sources/ABIBindings/ClosedEnumBinding.swift @@ -6,6 +6,6 @@ public protocol ClosedEnumBinding: RawRepresentable, PODBinding extension ClosedEnumBinding { public static var abiDefaultValue: RawValue { RawValue.zero } - public static func toSwift(_ value: RawValue) -> Self { Self(rawValue: value)! } + public static func fromABI(_ value: RawValue) -> Self { Self(rawValue: value)! } public static func toABI(_ value: Self) -> RawValue { value.rawValue } } diff --git a/Support/Sources/ABIBindings/IdentityBinding.swift b/Support/Sources/ABIBindings/IdentityBinding.swift index 7a74961..b7ba2c9 100644 --- a/Support/Sources/ABIBindings/IdentityBinding.swift +++ b/Support/Sources/ABIBindings/IdentityBinding.swift @@ -3,5 +3,5 @@ public protocol IdentityBinding: PODBinding where SwiftValue == ABIValue {} extension IdentityBinding { public static func toABI(_ value: SwiftValue) -> ABIValue { value } - public static func toSwift(_ value: ABIValue) -> SwiftValue { value } + public static func fromABI(_ value: ABIValue) -> SwiftValue { value } } \ No newline at end of file diff --git a/Support/Sources/ABIBindings/NumericBinding.swift b/Support/Sources/ABIBindings/NumericBinding.swift index c2d5d8f..7fed1ba 100644 --- a/Support/Sources/ABIBindings/NumericBinding.swift +++ b/Support/Sources/ABIBindings/NumericBinding.swift @@ -4,6 +4,6 @@ public enum NumericBinding: PODBinding { public typealias SwiftValue = Value public static var abiDefaultValue: ABIValue { Value.zero } - public static func toSwift(_ value: Value) -> Value { value } + public static func fromABI(_ value: Value) -> Value { value } public static func toABI(_ value: Value) -> Value { value } } \ No newline at end of file diff --git a/Support/Sources/ABIBindings/OpenEnumBinding.swift b/Support/Sources/ABIBindings/OpenEnumBinding.swift index dae0a26..d3cc382 100644 --- a/Support/Sources/ABIBindings/OpenEnumBinding.swift +++ b/Support/Sources/ABIBindings/OpenEnumBinding.swift @@ -8,6 +8,6 @@ public protocol OpenEnumBinding: RawRepresentable, PODBinding extension OpenEnumBinding { public static var abiDefaultValue: RawValue { RawValue.zero } - public static func toSwift(_ value: RawValue) -> Self { Self(rawValue: value) } + public static func fromABI(_ value: RawValue) -> Self { Self(rawValue: value) } public static func toABI(_ value: Self) -> RawValue { value.rawValue } } diff --git a/Support/Sources/ABIBindings/PODBinding.swift b/Support/Sources/ABIBindings/PODBinding.swift index bc4341c..75c5dff 100644 --- a/Support/Sources/ABIBindings/PODBinding.swift +++ b/Support/Sources/ABIBindings/PODBinding.swift @@ -5,6 +5,6 @@ public protocol PODBinding: ABIBinding { } extension PODBinding { - public static func toSwift(consuming value: inout ABIValue) -> SwiftValue { toSwift(value) } + public static func fromABI(consuming value: inout ABIValue) -> SwiftValue { fromABI(value) } public static func release(_ value: inout ABIValue) {} } \ No newline at end of file diff --git a/Support/Sources/ABIBindings/WideCharBinding.swift b/Support/Sources/ABIBindings/WideCharBinding.swift index 26ec09c..d966966 100644 --- a/Support/Sources/ABIBindings/WideCharBinding.swift +++ b/Support/Sources/ABIBindings/WideCharBinding.swift @@ -4,6 +4,6 @@ public enum WideCharBinding: PODBinding { public typealias SwiftValue = Unicode.UTF16.CodeUnit public static var abiDefaultValue: ABIValue { 0 } - public static func toSwift(_ value: UInt16) -> Unicode.UTF16.CodeUnit { value } + public static func fromABI(_ value: UInt16) -> Unicode.UTF16.CodeUnit { value } public static func toABI(_ value: Unicode.UTF16.CodeUnit) -> UInt16 { value } } \ No newline at end of file diff --git a/Support/Sources/COM/COMBinding.swift b/Support/Sources/COM/COMBinding.swift index 46237b0..8c348cc 100644 --- a/Support/Sources/COM/COMBinding.swift +++ b/Support/Sources/COM/COMBinding.swift @@ -31,15 +31,15 @@ extension COMBinding { // Default ABIBinding implementation public static var abiDefaultValue: ABIValue { nil } - public static func toSwift(_ value: ABIValue) -> SwiftValue { + public static func fromABI(_ value: ABIValue) -> SwiftValue { guard let comPointer = value else { return nil } - return toSwift(ABIReference(addingRef: comPointer)) + return fromABI(ABIReference(addingRef: comPointer)) } - public static func toSwift(consuming value: inout ABIValue) -> SwiftValue { + public static func fromABI(consuming value: inout ABIValue) -> SwiftValue { guard let comPointer = value else { return nil } value = nil - return toSwift(ABIReference(transferringRef: comPointer)) + return fromABI(ABIReference(transferringRef: comPointer)) } public static func toABI(_ value: SwiftValue) throws -> ABIValue { @@ -56,7 +56,7 @@ extension COMBinding { // Default COMBinding implementation public static func _unwrap(_ pointer: ABIPointer) -> SwiftObject? { nil } - public static func toSwift(_ reference: consuming ABIReference) -> SwiftObject { + public static func fromABI(_ reference: consuming ABIReference) -> SwiftObject { if let swiftObject = _unwrap(reference.pointer) { return swiftObject } return _wrap(consume reference) } diff --git a/Support/Sources/COM/COMEmbedding.swift b/Support/Sources/COM/COMEmbedding.swift index 4b49589..8677b70 100644 --- a/Support/Sources/COM/COMEmbedding.swift +++ b/Support/Sources/COM/COMEmbedding.swift @@ -126,7 +126,7 @@ public enum IUnknownVirtualTable { ppvObject.pointee = nil return COMError.toABI { - let id = GUIDBinding.toSwift(iid.pointee) + let id = GUIDBinding.fromABI(iid.pointee) let this = IUnknownPointer(OpaquePointer(this)) let reference = id == uuidof(SWRT_SwiftCOMObject.self) ? IUnknownReference(addingRef: this) diff --git a/Support/Sources/COM/COMError+createErrorInfo.swift b/Support/Sources/COM/COMError+createErrorInfo.swift index 5939e44..b25396e 100644 --- a/Support/Sources/COM/COMError+createErrorInfo.swift +++ b/Support/Sources/COM/COMError+createErrorInfo.swift @@ -6,7 +6,7 @@ extension COMError { var createErrorInfo = ICreateErrorInfoBinding.abiDefaultValue defer { ICreateErrorInfoBinding.release(&createErrorInfo) } try COMError.fromABI(SWRT_CreateErrorInfo(&createErrorInfo)) - return try NullResult.unwrap(ICreateErrorInfoBinding.toSwift(createErrorInfo)) + return try NullResult.unwrap(ICreateErrorInfoBinding.fromABI(createErrorInfo)) } /// Creates an instance of `IErrorInfo` with prepopulated fields. diff --git a/Support/Sources/COM/COMError.swift b/Support/Sources/COM/COMError.swift index a934b77..ac5f619 100644 --- a/Support/Sources/COM/COMError.swift +++ b/Support/Sources/COM/COMError.swift @@ -91,7 +91,7 @@ public struct COMError: COMErrorProtocol, CustomStringConvertible { var errorInfo: UnsafeMutablePointer? defer { IErrorInfoBinding.release(&errorInfo) } try fromABI(captureErrorInfo: false, COM_ABI.SWRT_GetErrorInfo(/* dwReserved: */ 0, &errorInfo)) - return IErrorInfoBinding.toSwift(consuming: &errorInfo) + return IErrorInfoBinding.fromABI(consuming: &errorInfo) } public static func setErrorInfo(_ errorInfo: IErrorInfo?) throws { diff --git a/Support/Sources/COM/Projection/BStrBinding.swift b/Support/Sources/COM/Projection/BStrBinding.swift index 218be93..121e1a7 100644 --- a/Support/Sources/COM/Projection/BStrBinding.swift +++ b/Support/Sources/COM/Projection/BStrBinding.swift @@ -9,7 +9,7 @@ public enum BStrBinding: ABIBinding { public static var abiDefaultValue: ABIValue { nil } - public static func toSwift(_ value: COM_ABI.SWRT_BStr?) -> String? { + public static func fromABI(_ value: COM_ABI.SWRT_BStr?) -> String? { guard let value else { return nil } let length = COM_ABI.SWRT_SysStringLen(value) return String(utf16CodeUnits: value, count: Int(length)) diff --git a/Support/Sources/COM/Projection/GUID.swift b/Support/Sources/COM/Projection/GUID.swift index 195224d..2009440 100644 --- a/Support/Sources/COM/Projection/GUID.swift +++ b/Support/Sources/COM/Projection/GUID.swift @@ -42,7 +42,7 @@ public enum GUIDBinding: PODBinding { .init(Data1: 0, Data2: 0, Data3: 0, Data4: (0, 0, 0, 0, 0, 0, 0, 0)) } - public static func toSwift(_ value: COM_ABI.SWRT_Guid) -> GUID { + public static func fromABI(_ value: COM_ABI.SWRT_Guid) -> GUID { .init(uuid: ( UInt8((value.Data1 >> 24) & 0xFF), UInt8((value.Data1 >> 16) & 0xFF), UInt8((value.Data1 >> 8) & 0xFF), UInt8((value.Data1 >> 0) & 0xFF), diff --git a/Support/Sources/COM/Projection/HResultBinding.swift b/Support/Sources/COM/Projection/HResultBinding.swift index 804b7d6..f40ca74 100644 --- a/Support/Sources/COM/Projection/HResultBinding.swift +++ b/Support/Sources/COM/Projection/HResultBinding.swift @@ -5,6 +5,6 @@ public enum HResultBinding: PODBinding { public typealias ABIValue = COM_ABI.SWRT_HResult public static var abiDefaultValue: ABIValue { 0 /* S_OK */ } - public static func toSwift(_ value: COM_ABI.SWRT_HResult) -> SwiftValue { HResult(value) } + public static func fromABI(_ value: COM_ABI.SWRT_HResult) -> SwiftValue { HResult(value) } public static func toABI(_ value: HResult) -> COM_ABI.SWRT_HResult { value.value } } \ No newline at end of file diff --git a/Support/Sources/COM/Projection/ICreateErrorInfo.swift b/Support/Sources/COM/Projection/ICreateErrorInfo.swift index ee216b1..8a0291f 100644 --- a/Support/Sources/COM/Projection/ICreateErrorInfo.swift +++ b/Support/Sources/COM/Projection/ICreateErrorInfo.swift @@ -38,11 +38,11 @@ public enum ICreateErrorInfoBinding: COMTwoWayBinding { Release: { IUnknownVirtualTable.Release($0) }, SetGUID: { this, guid in _implement(this) { guard let guid else { throw COMError.invalidArg } - try $0.setGUID(GUIDBinding.toSwift(guid.pointee)) + try $0.setGUID(GUIDBinding.fromABI(guid.pointee)) } }, - SetSource: { this, source in _implement(this) { try $0.setSource(BStrBinding.toSwift(source)) } }, - SetDescription: { this, description in _implement(this) { try $0.setDescription(BStrBinding.toSwift(description)) } }, - SetHelpFile: { this, helpFile in _implement(this) { try $0.setHelpFile(BStrBinding.toSwift(helpFile)) } }, + SetSource: { this, source in _implement(this) { try $0.setSource(BStrBinding.fromABI(source)) } }, + SetDescription: { this, description in _implement(this) { try $0.setDescription(BStrBinding.fromABI(description)) } }, + SetHelpFile: { this, helpFile in _implement(this) { try $0.setHelpFile(BStrBinding.fromABI(helpFile)) } }, SetHelpContext: { this, helpContext in _implement(this) { try $0.setHelpContext(helpContext) } }) } diff --git a/Support/Sources/COM/Projection/IErrorInfo.swift b/Support/Sources/COM/Projection/IErrorInfo.swift index a03f7de..0584156 100644 --- a/Support/Sources/COM/Projection/IErrorInfo.swift +++ b/Support/Sources/COM/Projection/IErrorInfo.swift @@ -51,25 +51,25 @@ extension COMInterop where ABIStruct == COM_ABI.SWRT_IErrorInfo { public func getGuid() throws -> GUID { var value = GUIDBinding.abiDefaultValue try COMError.fromABI(this.pointee.VirtualTable.pointee.GetGUID(this, &value)) - return GUIDBinding.toSwift(value) + return GUIDBinding.fromABI(value) } public func getSource() throws -> String? { var value = BStrBinding.abiDefaultValue try COMError.fromABI(this.pointee.VirtualTable.pointee.GetSource(this, &value)) - return BStrBinding.toSwift(consuming: &value) + return BStrBinding.fromABI(consuming: &value) } public func getDescription() throws -> String? { var value = BStrBinding.abiDefaultValue try COMError.fromABI(this.pointee.VirtualTable.pointee.GetDescription(this, &value)) - return BStrBinding.toSwift(consuming: &value) + return BStrBinding.fromABI(consuming: &value) } public func getHelpFile() throws -> String? { var value = BStrBinding.abiDefaultValue try COMError.fromABI(this.pointee.VirtualTable.pointee.GetHelpFile(this, &value)) - return BStrBinding.toSwift(consuming: &value) + return BStrBinding.fromABI(consuming: &value) } public func getHelpContext() throws -> UInt32 { diff --git a/Support/Sources/COM/Projection/IUnknown.swift b/Support/Sources/COM/Projection/IUnknown.swift index 71c1b3f..073c799 100644 --- a/Support/Sources/COM/Projection/IUnknown.swift +++ b/Support/Sources/COM/Projection/IUnknown.swift @@ -28,7 +28,7 @@ extension IUnknownProtocol { /// Queries this object for an additional COM interface described by the given binding. /// On failure, throws a COMError with an HResult of E_NOINTERFACE. public func queryInterface(_: Binding.Type) throws -> Binding.SwiftObject { - Binding.toSwift(try self._queryInterface(Binding.self)) + Binding.fromABI(try self._queryInterface(Binding.self)) } } diff --git a/Support/Sources/WindowsRuntime/BindingProtocols+extensions.swift b/Support/Sources/WindowsRuntime/BindingProtocols+extensions.swift index dd48a35..d37f7e1 100644 --- a/Support/Sources/WindowsRuntime/BindingProtocols+extensions.swift +++ b/Support/Sources/WindowsRuntime/BindingProtocols+extensions.swift @@ -78,7 +78,7 @@ extension ActivatableClassBinding { } extension ComposableClassBinding { - public static func toSwift(consuming value: inout ABIValue) -> SwiftValue { + public static func fromABI(consuming value: inout ABIValue) -> SwiftValue { guard let pointer = value else { return nil } let reference = COMReference(transferringRef: pointer) if let swiftObject = _unwrap(reference.pointer) { return swiftObject } diff --git a/Support/Sources/WindowsRuntime/IReferenceToOptionalBinding.swift b/Support/Sources/WindowsRuntime/IReferenceToOptionalBinding.swift index a4ad0de..8a52a9e 100644 --- a/Support/Sources/WindowsRuntime/IReferenceToOptionalBinding.swift +++ b/Support/Sources/WindowsRuntime/IReferenceToOptionalBinding.swift @@ -16,7 +16,7 @@ public enum IReferenceToOptionalBinding: WinRTBi withUnsafeMutablePointer(to: &abiValue) { abiValuePointer in try! reference.interop.get_Value(abiValuePointer) } - return Binding.toSwift(consuming: &abiValue) + return Binding.fromABI(consuming: &abiValue) } public static func toCOM(_ value: SwiftObject) throws -> ABIReference { diff --git a/Support/Sources/WindowsRuntime/Projection/ArrayBinding.swift b/Support/Sources/WindowsRuntime/Projection/ArrayBinding.swift index 81d7f55..a7c4e35 100644 --- a/Support/Sources/WindowsRuntime/Projection/ArrayBinding.swift +++ b/Support/Sources/WindowsRuntime/Projection/ArrayBinding.swift @@ -8,19 +8,19 @@ public enum ArrayBinding: ABIBinding { public static var abiDefaultValue: ABIValue { .null } - public static func toSwift(_ value: ABIValue) -> SwiftValue { + public static func fromABI(_ value: ABIValue) -> SwiftValue { guard value.count > 0 else { return [] } return .init(unsafeUninitializedCapacity: Int(value.count)) { buffer, initializedCount in for i in 0..?, count: UInt32) -> SwiftValue { + public static func fromABI(pointer: UnsafeMutablePointer?, count: UInt32) -> SwiftValue { if let pointer { - return toSwift(COMArray(pointer: pointer, count: count)) + return fromABI(COMArray(pointer: pointer, count: count)) } else { assert(count == 0) return [] diff --git a/Support/Sources/WindowsRuntime/Projection/EventRegistrationToken.swift b/Support/Sources/WindowsRuntime/Projection/EventRegistrationToken.swift index 31d3732..3f5b043 100644 --- a/Support/Sources/WindowsRuntime/Projection/EventRegistrationToken.swift +++ b/Support/Sources/WindowsRuntime/Projection/EventRegistrationToken.swift @@ -13,6 +13,6 @@ extension EventRegistrationToken: PODBinding { public typealias ABIValue = WindowsRuntime_ABI.SWRT_EventRegistrationToken public static var abiDefaultValue: ABIValue { WindowsRuntime_ABI.SWRT_EventRegistrationToken(value: 0) } - public static func toSwift(_ value: ABIValue) -> SwiftValue { SwiftValue(value.value) } + public static func fromABI(_ value: ABIValue) -> SwiftValue { SwiftValue(value.value) } public static func toABI(_ value: SwiftValue) -> ABIValue { ABIValue(value: value.value) } } \ No newline at end of file diff --git a/Support/Sources/WindowsRuntime/Projection/IActivationFactory.swift b/Support/Sources/WindowsRuntime/Projection/IActivationFactory.swift index 90d28ca..bb388ec 100644 --- a/Support/Sources/WindowsRuntime/Projection/IActivationFactory.swift +++ b/Support/Sources/WindowsRuntime/Projection/IActivationFactory.swift @@ -26,7 +26,7 @@ public enum IActivationFactoryBinding: InterfaceBinding { private final class Import: WinRTImport, IActivationFactoryProtocol { public func activateInstance() throws -> IInspectable { var instancePointer = try _interop.activateInstance() - return try NullResult.unwrap(IInspectableBinding.toSwift(consuming: &instancePointer)) + return try NullResult.unwrap(IInspectableBinding.fromABI(consuming: &instancePointer)) } } } diff --git a/Support/Sources/WindowsRuntime/Projection/IInspectable.swift b/Support/Sources/WindowsRuntime/Projection/IInspectable.swift index c7f31fe..1a9ff53 100644 --- a/Support/Sources/WindowsRuntime/Projection/IInspectable.swift +++ b/Support/Sources/WindowsRuntime/Projection/IInspectable.swift @@ -48,18 +48,18 @@ extension COMInterop where ABIStruct == WindowsRuntime_ABI.SWRT_IInspectable { var iids: COMArray = .null try WinRTError.fromABI(this.pointee.VirtualTable.pointee.GetIids(this, &iids.count, &iids.pointer)) defer { iids.deallocate() } - return ArrayBinding.toSwift(consuming: &iids) + return ArrayBinding.fromABI(consuming: &iids) } public func getRuntimeClassName() throws -> String { var runtimeClassName: WindowsRuntime_ABI.SWRT_HString? try WinRTError.fromABI(this.pointee.VirtualTable.pointee.GetRuntimeClassName(this, &runtimeClassName)) - return StringBinding.toSwift(consuming: &runtimeClassName) + return StringBinding.fromABI(consuming: &runtimeClassName) } public func getTrustLevel() throws -> TrustLevel { var trustLevel: WindowsRuntime_ABI.SWRT_TrustLevel = 0 try WinRTError.fromABI(this.pointee.VirtualTable.pointee.GetTrustLevel(this, &trustLevel)) - return TrustLevel.toSwift(trustLevel) + return TrustLevel.fromABI(trustLevel) } } \ No newline at end of file diff --git a/Support/Sources/WindowsRuntime/Projection/ILanguageExceptionErrorInfo.swift b/Support/Sources/WindowsRuntime/Projection/ILanguageExceptionErrorInfo.swift index 17be669..041be08 100644 --- a/Support/Sources/WindowsRuntime/Projection/ILanguageExceptionErrorInfo.swift +++ b/Support/Sources/WindowsRuntime/Projection/ILanguageExceptionErrorInfo.swift @@ -38,6 +38,6 @@ extension COMInterop where ABIStruct == WindowsRuntime_ABI.SWRT_ILanguageExcepti var result: IUnknownPointer? = nil // IUnknownBinding.abiDefaultValue (compiler bug?) defer { IUnknownBinding.release(&result) } try COMError.fromABI(this.pointee.VirtualTable.pointee.GetLanguageException(this, &result)) - return IUnknownBinding.toSwift(consuming: &result) + return IUnknownBinding.fromABI(consuming: &result) } } \ No newline at end of file diff --git a/Support/Sources/WindowsRuntime/Projection/ILanguageExceptionErrorInfo2.swift b/Support/Sources/WindowsRuntime/Projection/ILanguageExceptionErrorInfo2.swift index 6a40b7e..0403561 100644 --- a/Support/Sources/WindowsRuntime/Projection/ILanguageExceptionErrorInfo2.swift +++ b/Support/Sources/WindowsRuntime/Projection/ILanguageExceptionErrorInfo2.swift @@ -53,14 +53,14 @@ extension COMInterop where ABIStruct == WindowsRuntime_ABI.SWRT_ILanguageExcepti var result: IUnknownPointer? = nil // IUnknownBinding.abiDefaultValue (compiler bug?) defer { IUnknownBinding.release(&result) } try COMError.fromABI(this.pointee.VirtualTable.pointee.GetLanguageException(this, &result)) - return IUnknownBinding.toSwift(consuming: &result) + return IUnknownBinding.fromABI(consuming: &result) } public func getPreviousLanguageExceptionErrorInfo() throws -> ILanguageExceptionErrorInfo2? { var result = ILanguageExceptionErrorInfo2Binding.abiDefaultValue defer { ILanguageExceptionErrorInfo2Binding.release(&result) } try COMError.fromABI(this.pointee.VirtualTable.pointee.GetPreviousLanguageExceptionErrorInfo(this, &result)) - return ILanguageExceptionErrorInfo2Binding.toSwift(consuming: &result) + return ILanguageExceptionErrorInfo2Binding.fromABI(consuming: &result) } public func capturePropagationContext(_ languageException: IUnknown?) throws { @@ -73,6 +73,6 @@ extension COMInterop where ABIStruct == WindowsRuntime_ABI.SWRT_ILanguageExcepti var result = ILanguageExceptionErrorInfo2Binding.abiDefaultValue defer { ILanguageExceptionErrorInfo2Binding.release(&result) } try COMError.fromABI(this.pointee.VirtualTable.pointee.GetPropagationContextHead(this, &result)) - return ILanguageExceptionErrorInfo2Binding.toSwift(consuming: &result) + return ILanguageExceptionErrorInfo2Binding.fromABI(consuming: &result) } } \ No newline at end of file diff --git a/Support/Sources/WindowsRuntime/Projection/IRestrictedErrorInfo.swift b/Support/Sources/WindowsRuntime/Projection/IRestrictedErrorInfo.swift index 154bde6..45fb7df 100644 --- a/Support/Sources/WindowsRuntime/Projection/IRestrictedErrorInfo.swift +++ b/Support/Sources/WindowsRuntime/Projection/IRestrictedErrorInfo.swift @@ -70,15 +70,15 @@ extension COMInterop where ABIStruct == WindowsRuntime_ABI.SWRT_IRestrictedError var capabilitySid_: WindowsRuntime_ABI.SWRT_BStr? = nil defer { BStrBinding.release(&capabilitySid_) } try COMError.fromABI(this.pointee.VirtualTable.pointee.GetErrorDetails(this, &description_, &error_, &restrictedDescription_, &capabilitySid_)) - description = BStrBinding.toSwift(consuming: &description_) - error = HResultBinding.toSwift(error_) - restrictedDescription = BStrBinding.toSwift(consuming: &restrictedDescription_) - capabilitySid = BStrBinding.toSwift(consuming: &capabilitySid_) + description = BStrBinding.fromABI(consuming: &description_) + error = HResultBinding.fromABI(error_) + restrictedDescription = BStrBinding.fromABI(consuming: &restrictedDescription_) + capabilitySid = BStrBinding.fromABI(consuming: &capabilitySid_) } public func getReference() throws -> String? { var value = BStrBinding.abiDefaultValue try COMError.fromABI(this.pointee.VirtualTable.pointee.GetReference(this, &value)) - return BStrBinding.toSwift(consuming: &value) + return BStrBinding.fromABI(consuming: &value) } } \ No newline at end of file diff --git a/Support/Sources/WindowsRuntime/Projection/IWeakReference.swift b/Support/Sources/WindowsRuntime/Projection/IWeakReference.swift index 3631c85..e661a97 100644 --- a/Support/Sources/WindowsRuntime/Projection/IWeakReference.swift +++ b/Support/Sources/WindowsRuntime/Projection/IWeakReference.swift @@ -39,7 +39,7 @@ public enum IWeakReferenceBinding: COMTwoWayBinding { defer { IInspectableBinding.release(&inspectable) } guard let inspectable else { return } objectReference.pointee = try COMInterop(inspectable) - .queryInterface(GUIDBinding.toSwift(iid.pointee), type: SWRT_IInspectable.self) + .queryInterface(GUIDBinding.fromABI(iid.pointee), type: SWRT_IInspectable.self) .detach() } }) } @@ -53,6 +53,6 @@ extension COMInterop where ABIStruct == WindowsRuntime_ABI.SWRT_IWeakReference { var iid = GUIDBinding.toABI(iid) var objectReference = IInspectableBinding.abiDefaultValue try COMError.fromABI(this.pointee.VirtualTable.pointee.Resolve(this, &iid, &objectReference)) - return IInspectableBinding.toSwift(consuming: &objectReference) + return IInspectableBinding.fromABI(consuming: &objectReference) } } \ No newline at end of file diff --git a/Support/Sources/WindowsRuntime/Projection/IWeakReferenceSource.swift b/Support/Sources/WindowsRuntime/Projection/IWeakReferenceSource.swift index 0327587..dac7f14 100644 --- a/Support/Sources/WindowsRuntime/Projection/IWeakReferenceSource.swift +++ b/Support/Sources/WindowsRuntime/Projection/IWeakReferenceSource.swift @@ -43,6 +43,6 @@ extension COMInterop where ABIStruct == WindowsRuntime_ABI.SWRT_IWeakReferenceSo public func getWeakReference() throws -> IWeakReference? { var value = IWeakReferenceBinding.abiDefaultValue try COMError.fromABI(this.pointee.VirtualTable.pointee.GetWeakReference(this, &value)) - return IWeakReferenceBinding.toSwift(consuming: &value) + return IWeakReferenceBinding.fromABI(consuming: &value) } } \ No newline at end of file diff --git a/Support/Sources/WindowsRuntime/Projection/PrimitiveBindings.swift b/Support/Sources/WindowsRuntime/Projection/PrimitiveBindings.swift index 788376e..07e576a 100644 --- a/Support/Sources/WindowsRuntime/Projection/PrimitiveBindings.swift +++ b/Support/Sources/WindowsRuntime/Projection/PrimitiveBindings.swift @@ -139,7 +139,7 @@ public enum Char16Binding: IReferenceableBinding, PODBinding { public static var ireferenceID: COM.COMInterfaceID { COMInterfaceID(0xFB393EF3, 0xBBAC, 0x5BD5, 0x9144, 0x84F23576F415) } public static var ireferenceArrayID: COMInterfaceID { COMInterfaceID(0xA4095AAB, 0xEB7D, 0x5782, 0x8FAD, 0x1609DEA249AD) } public static var abiDefaultValue: ABIType { 0 } - public static func toSwift(_ value: ABIType) -> SwiftType { .init(value) } + public static func fromABI(_ value: ABIType) -> SwiftType { .init(value) } public static func toABI(_ value: SwiftType) -> ABIType { value.codeUnit } public static func createIReference(_ value: SwiftValue) throws -> WindowsFoundation_IReference { try PropertyValueStatics.createIReference(value, valueBinding: Self.self, factory: PropertyValueStatics.createChar16) @@ -158,7 +158,7 @@ public enum StringBinding: IReferenceableBinding { public static var ireferenceArrayID: COMInterfaceID { COMInterfaceID(0x0385688E, 0xE3C7, 0x5C5E, 0xA389, 0x5524EDE349F1) } public static var abiDefaultValue: ABIValue { nil } - public static func toSwift(_ value: ABIValue) -> SwiftValue { HString.toString(value) } + public static func fromABI(_ value: ABIValue) -> SwiftValue { HString.toString(value) } public static func toABI(_ value: SwiftValue) throws -> ABIValue { try HString.create(value).detach() } public static func release(_ value: inout ABIValue) { @@ -183,7 +183,7 @@ public enum GuidBinding: IReferenceableBinding, PODBinding { public static var ireferenceID: COM.COMInterfaceID { COMInterfaceID(0x7D50F649, 0x632C, 0x51F9, 0x849A, 0xEE49428933EA) } public static var ireferenceArrayID: COMInterfaceID { COMInterfaceID(0xEECF9838, 0xC1C2, 0x5B4A, 0x976F, 0xCEC261AE1D55) } public static var abiDefaultValue: ABIType { .init() } - public static func toSwift(_ value: ABIType) -> SwiftType { COM.GUIDBinding.toSwift(value) } + public static func fromABI(_ value: ABIType) -> SwiftType { COM.GUIDBinding.fromABI(value) } public static func toABI(_ value: SwiftType) -> ABIType { COM.GUIDBinding.toABI(value) } public static func createIReference(_ value: SwiftValue) throws -> WindowsFoundation_IReference { try PropertyValueStatics.createIReference(value, valueBinding: Self.self, factory: PropertyValueStatics.createGuid) diff --git a/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_DateTime.swift b/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_DateTime.swift index 181242a..8e8dab1 100644 --- a/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_DateTime.swift +++ b/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_DateTime.swift @@ -51,7 +51,7 @@ extension WindowsFoundation_DateTime: WindowsRuntime.StructBinding, COM.PODBindi public static var abiDefaultValue: ABIValue { .init() } - public static func toSwift(_ value: ABIValue) -> SwiftValue { + public static func fromABI(_ value: ABIValue) -> SwiftValue { .init(universalTime: value.UniversalTime) } diff --git a/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_IReference.swift b/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_IReference.swift index b10f2c3..8b64e01 100644 --- a/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_IReference.swift +++ b/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_IReference.swift @@ -73,7 +73,7 @@ public enum WindowsFoundation_IReferenceBinding try withUnsafeMutablePointer(to: &abiValue) { abiValuePointer in try _interop.get_Value(abiValuePointer) } - return TBinding.toSwift(consuming: &abiValue) + return TBinding.fromABI(consuming: &abiValue) } public func _getABIValue(_ pointer: UnsafeMutableRawPointer) throws { diff --git a/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_IReferenceArray.swift b/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_IReferenceArray.swift index e39eae4..e60adee 100644 --- a/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_IReferenceArray.swift +++ b/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_IReferenceArray.swift @@ -70,7 +70,7 @@ public enum WindowsFoundation_IReferenceArrayBinding( pointer: pointer.bindMemory(to: TBinding.ABIValue.self, capacity: Int(length)), count: length) - return ArrayBinding.toSwift(consuming: &abiValue) + return ArrayBinding.fromABI(consuming: &abiValue) } public func _getABIValue(_ length: inout UInt32, _ pointer: inout UnsafeMutableRawPointer?) throws { diff --git a/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_IStringable.swift b/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_IStringable.swift index de580fb..8553739 100644 --- a/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_IStringable.swift +++ b/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_IStringable.swift @@ -49,6 +49,6 @@ extension COMInterop where ABIStruct == SWRT_WindowsFoundation_IStringable { public func toString() throws -> String { var value = StringBinding.abiDefaultValue try COMError.fromABI(this.pointee.VirtualTable.pointee.ToString(this, &value)) - return StringBinding.toSwift(consuming: &value) + return StringBinding.fromABI(consuming: &value) } } \ No newline at end of file diff --git a/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_Point.swift b/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_Point.swift index a1e6b9f..0e67bd9 100644 --- a/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_Point.swift +++ b/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_Point.swift @@ -35,7 +35,7 @@ extension WindowsFoundation_Point: WindowsRuntime.StructBinding, COM.PODBinding public static var abiDefaultValue: ABIValue { .init() } - public static func toSwift(_ value: ABIValue) -> SwiftValue { + public static func fromABI(_ value: ABIValue) -> SwiftValue { .init(x: value.X, y: value.Y) } diff --git a/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_Rect.swift b/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_Rect.swift index dc6dc0e..3cf5de4 100644 --- a/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_Rect.swift +++ b/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_Rect.swift @@ -45,7 +45,7 @@ extension WindowsFoundation_Rect: WindowsRuntime.StructBinding, COM.PODBinding { public static var abiDefaultValue: ABIValue { .init() } - public static func toSwift(_ value: ABIValue) -> SwiftValue { + public static func fromABI(_ value: ABIValue) -> SwiftValue { .init(x: value.X, y: value.Y, width: value.Width, height: value.Height) } diff --git a/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_Size.swift b/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_Size.swift index 9e0a326..5067602 100644 --- a/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_Size.swift +++ b/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_Size.swift @@ -35,7 +35,7 @@ extension WindowsFoundation_Size: WindowsRuntime.StructBinding, COM.PODBinding { public static var abiDefaultValue: ABIValue { .init() } - public static func toSwift(_ value: ABIValue) -> SwiftValue { + public static func fromABI(_ value: ABIValue) -> SwiftValue { .init(width: value.Width, height: value.Height) } diff --git a/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_TimeSpan.swift b/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_TimeSpan.swift index 4fa4635..d322a54 100644 --- a/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_TimeSpan.swift +++ b/Support/Sources/WindowsRuntime/Projection/WindowsFoundation/WindowsFoundation_TimeSpan.swift @@ -66,7 +66,7 @@ extension WindowsFoundation_TimeSpan: StructBinding, PODBinding { public static var abiDefaultValue: ABIValue { .init() } - public static func toSwift(_ value: ABIValue) -> SwiftValue { + public static func fromABI(_ value: ABIValue) -> SwiftValue { .init(duration: value.Duration) } diff --git a/Support/Sources/WindowsRuntime/PropertyValueStatics.swift b/Support/Sources/WindowsRuntime/PropertyValueStatics.swift index 7ca6a79..bfae3b6 100644 --- a/Support/Sources/WindowsRuntime/PropertyValueStatics.swift +++ b/Support/Sources/WindowsRuntime/PropertyValueStatics.swift @@ -265,7 +265,7 @@ internal enum PropertyValueStatics { valueBinding: ValueBinding.Type, factory: (ValueBinding.SwiftValue) throws -> COMReference) throws -> WindowsFoundation_IReference { - try WindowsFoundation_IReferenceBinding.toSwift( + try WindowsFoundation_IReferenceBinding.fromABI( factory(value).queryInterface(ValueBinding.ireferenceID, type: SWRT_WindowsFoundation_IReference.self)) } @@ -274,7 +274,7 @@ internal enum PropertyValueStatics { valueBinding: ValueBinding.Type, factory: ([ValueBinding.SwiftValue]) throws -> COMReference) throws -> WindowsFoundation_IReferenceArray { - try WindowsFoundation_IReferenceArrayBinding.toSwift( + try WindowsFoundation_IReferenceArrayBinding.fromABI( factory(array).queryInterface(ValueBinding.ireferenceArrayID, type: SWRT_WindowsFoundation_IReferenceArray.self)) } } diff --git a/Support/Sources/WindowsRuntime/WeakReference.swift b/Support/Sources/WindowsRuntime/WeakReference.swift index 4671e31..64ed296 100644 --- a/Support/Sources/WindowsRuntime/WeakReference.swift +++ b/Support/Sources/WindowsRuntime/WeakReference.swift @@ -28,6 +28,6 @@ public final class WeakReference { try WinRTError.fromABI(weakReference.pointer.pointee.VirtualTable.pointee.Resolve( weakReference.pointer, &iid, &inspectableTarget)) var target = Binding.ABIPointer(OpaquePointer(inspectableTarget)) - return Binding.toSwift(consuming: &target) + return Binding.fromABI(consuming: &target) } } \ No newline at end of file diff --git a/Support/Sources/WindowsRuntime/WinRTError.swift b/Support/Sources/WindowsRuntime/WinRTError.swift index 4fba6ac..3107aeb 100644 --- a/Support/Sources/WindowsRuntime/WinRTError.swift +++ b/Support/Sources/WindowsRuntime/WinRTError.swift @@ -141,14 +141,14 @@ public struct WinRTError: COMErrorProtocol, CustomStringConvertible { var restrictedErrorInfo: UnsafeMutablePointer? defer { IRestrictedErrorInfoBinding.release(&restrictedErrorInfo) } try fromABI(captureErrorInfo: false, WindowsRuntime_ABI.SWRT_GetRestrictedErrorInfo(&restrictedErrorInfo)) - return IRestrictedErrorInfoBinding.toSwift(consuming: &restrictedErrorInfo) + return IRestrictedErrorInfoBinding.fromABI(consuming: &restrictedErrorInfo) } public static func getRestrictedErrorInfo(matching expectedHResult: HResult) throws -> IRestrictedErrorInfo? { var restrictedErrorInfo: UnsafeMutablePointer? defer { IRestrictedErrorInfoBinding.release(&restrictedErrorInfo) } try fromABI(captureErrorInfo: false, WindowsRuntime_ABI.SWRT_RoGetMatchingRestrictedErrorInfo(expectedHResult.value, &restrictedErrorInfo)) - return IRestrictedErrorInfoBinding.toSwift(consuming: &restrictedErrorInfo) + return IRestrictedErrorInfoBinding.fromABI(consuming: &restrictedErrorInfo) } public static func setRestrictedErrorInfo(_ value: IRestrictedErrorInfo?) throws { diff --git a/Support/Tests/IReferenceToOptionalTests.swift b/Support/Tests/IReferenceToOptionalTests.swift index ab831b8..79652d2 100644 --- a/Support/Tests/IReferenceToOptionalTests.swift +++ b/Support/Tests/IReferenceToOptionalTests.swift @@ -4,10 +4,10 @@ import WindowsRuntime internal final class IReferenceToOptionalTests: WinRTTestCase { func testCreateNumeric() throws { XCTAssertNil(try Int32Binding.IReferenceToOptional.toABI(nil)) - XCTAssertNil(Int32Binding.IReferenceToOptional.toSwift(nil)) + XCTAssertNil(Int32Binding.IReferenceToOptional.fromABI(nil)) var boxed = try Int32Binding.IReferenceToOptional.toABI(42) defer { Int32Binding.IReferenceToOptional.release(&boxed) } - XCTAssertEqual(Int32Binding.IReferenceToOptional.toSwift(boxed), 42) + XCTAssertEqual(Int32Binding.IReferenceToOptional.fromABI(boxed), 42) } } \ No newline at end of file