diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift index dfe04c885..f652e4a33 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift @@ -16,7 +16,7 @@ public import WinSDK /// } extension AttachableImageFormat { private static let _encoderPathExtensionsByCLSID = Result { - var result = [CLSID.Wrapper: [String]]() + var result = [CLSID: [String]]() // Create an imaging factory. let factory = try IWICImagingFactory.create() @@ -69,7 +69,7 @@ extension AttachableImageFormat { continue } let extensions = _pathExtensions(for: info) - result[CLSID.Wrapper(clsid)] = extensions + result[clsid] = extensions } return result @@ -136,7 +136,7 @@ extension AttachableImageFormat { 0 == _wcsicmp(pathExtension, encoderExt) } } - }.map { $0.key.rawValue } + }.map { $0.key } } /// Get the `CLSID` value of the WIC image encoder corresponding to the same @@ -172,13 +172,13 @@ extension AttachableImageFormat { static func appendPathExtension(for clsid: CLSID, to preferredName: String) -> String { // If there's already a CLSID associated with the filename, and it matches // the one passed to us, no changes are needed. - if let existingCLSID = computeEncoderCLSID(forPreferredName: preferredName), CLSID.Wrapper(clsid) == CLSID.Wrapper(existingCLSID) { + if let existingCLSID = computeEncoderCLSID(forPreferredName: preferredName), clsid == existingCLSID { return preferredName } // Find the preferred path extension for the encoder with the given CLSID. let encoderPathExtensionsByCLSID = (try? _encoderPathExtensionsByCLSID.get()) ?? [:] - if let ext = encoderPathExtensionsByCLSID[CLSID.Wrapper(clsid)]?.first { + if let ext = encoderPathExtensionsByCLSID[clsid]?.first { return "\(preferredName).\(ext)" } @@ -221,12 +221,12 @@ extension AttachableImageFormat { /// @Available(Swift, introduced: 6.3) /// } public init(encoderCLSID: CLSID, encodingQuality: Float = 1.0) { - let encoderCLSID = CLSID.Wrapper(encoderCLSID) - let kind: Kind = if encoderCLSID == CLSID.Wrapper(CLSID_WICPngEncoder) { + let kind: Kind = switch encoderCLSID { + case CLSID_WICPngEncoder: .png - } else if encoderCLSID == CLSID.Wrapper(CLSID_WICJpegEncoder) { + case CLSID_WICJpegEncoder: .jpeg - } else { + default: .systemValue(encoderCLSID) } self.init(kind: kind, encodingQuality: encodingQuality) @@ -281,7 +281,7 @@ extension AttachableImageFormat.Kind: CustomStringConvertible, CustomDebugString case .jpeg: CLSID_WICJpegEncoder case let .systemValue(clsid): - (clsid as! CLSID.Wrapper).rawValue + clsid as! CLSID } } @@ -308,7 +308,7 @@ extension AttachableImageFormat.Kind: CustomStringConvertible, CustomDebugString package var description: String { let clsid = encoderCLSID let encoderPathExtensionsByCLSID = (try? AttachableImageFormat._encoderPathExtensionsByCLSID.get()) ?? [:] - if let ext = encoderPathExtensionsByCLSID[CLSID.Wrapper(clsid)]?.first { + if let ext = encoderPathExtensionsByCLSID[clsid]?.first { return "\(ext.uppercased()) format" } return Self._description(of: clsid) @@ -318,7 +318,7 @@ extension AttachableImageFormat.Kind: CustomStringConvertible, CustomDebugString let clsid = encoderCLSID let clsidDescription = Self._description(of: clsid) let encoderPathExtensionsByCLSID = (try? AttachableImageFormat._encoderPathExtensionsByCLSID.get()) ?? [:] - if let ext = encoderPathExtensionsByCLSID[CLSID.Wrapper(clsid)]?.first { + if let ext = encoderPathExtensionsByCLSID[clsid]?.first { return "\(ext.uppercased()) format (\(clsidDescription))" } return clsidDescription diff --git a/Sources/Overlays/_Testing_WinSDK/Support/Additions/GUIDAdditions.swift b/Sources/Overlays/_Testing_WinSDK/Support/Additions/GUIDAdditions.swift index 06985ed4c..95796785a 100644 --- a/Sources/Overlays/_Testing_WinSDK/Support/Additions/GUIDAdditions.swift +++ b/Sources/Overlays/_Testing_WinSDK/Support/Additions/GUIDAdditions.swift @@ -8,48 +8,24 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if os(Windows) -internal import WinSDK +#if compiler(<6.3) && os(Windows) +public import WinSDK -extension GUID { - /// A type that wraps `GUID` instances and conforms to various Swift - /// protocols. - /// - /// - Bug: This type will become obsolete once we can use the `Equatable` and - /// `Hashable` conformances added to the WinSDK module in Swift 6.3. -#if compiler(>=6.3.1) && DEBUG - @available(*, deprecated, message: "GUID.Wrapper is no longer needed and can be removed.") -#endif - struct Wrapper: Sendable, RawRepresentable { - var rawValue: GUID - } -} - -// MARK: - - -extension GUID.Wrapper: Equatable, Hashable, CustomStringConvertible { - init(_ rawValue: GUID) { - self.init(rawValue: rawValue) - } - -#if compiler(<6.3.1) +extension GUID: @retroactive Equatable, @retroactive Hashable { private var _uint128Value: UInt128 { - withUnsafeBytes(of: rawValue) { buffer in + withUnsafeBytes(of: self) { buffer in buffer.baseAddress!.loadUnaligned(as: UInt128.self) } } - static func ==(lhs: Self, rhs: Self) -> Bool { + // SEE: https://github.com/swiftlang/swift/pull/85196 + @_implements(Equatable, ==(_:_:)) + public static func __equals(lhs: Self, rhs: Self) -> Bool { lhs._uint128Value == rhs._uint128Value } - func hash(into hasher: inout Hasher) { + public func hash(into hasher: inout Hasher) { hasher.combine(_uint128Value) } - - var description: String { - String(describing: rawValue) - } -#endif } #endif