diff --git a/Package.swift b/Package.swift index 35331296f..5206b268e 100644 --- a/Package.swift +++ b/Package.swift @@ -269,6 +269,7 @@ let package = Package( "Testing", ], path: "Sources/Overlays/_Testing_WinSDK", + exclude: ["CMakeLists.txt"], swiftSettings: .packageSettings + .enableLibraryEvolution() ), diff --git a/Sources/Overlays/CMakeLists.txt b/Sources/Overlays/CMakeLists.txt index 5629e8229..d4a0e75f2 100644 --- a/Sources/Overlays/CMakeLists.txt +++ b/Sources/Overlays/CMakeLists.txt @@ -11,3 +11,4 @@ add_subdirectory(_Testing_CoreGraphics) add_subdirectory(_Testing_CoreImage) add_subdirectory(_Testing_Foundation) add_subdirectory(_Testing_UIKit) +add_subdirectory(_Testing_WinSDK) diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift index dcdec67f2..2928d7af5 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift @@ -12,6 +12,7 @@ @_spi(Experimental) public import Testing public import WinSDK +@_spi(Experimental) extension AttachableImageFormat { private static let _encoderPathExtensionsByCLSID = Result<[UInt128: [String]], any Error> { var result = [UInt128: [String]]() @@ -26,8 +27,8 @@ extension AttachableImageFormat { var enumerator: UnsafeMutablePointer? let rCreate = factory.pointee.lpVtbl.pointee.CreateComponentEnumerator( factory, - DWORD(bitPattern: WICEncoder.rawValue), - DWORD(bitPattern: WICComponentEnumerateDefault.rawValue), + DWORD(WICEncoder.rawValue), + DWORD(WICComponentEnumerateDefault.rawValue), &enumerator ) guard rCreate == S_OK, let enumerator else { diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/IWICBitmapSource+AttachableAsIWICBitmapSource.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/IWICBitmapSource+AttachableAsIWICBitmapSource.swift index 8ff6d5430..55c2ec4c2 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/IWICBitmapSource+AttachableAsIWICBitmapSource.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/IWICBitmapSource+AttachableAsIWICBitmapSource.swift @@ -96,6 +96,7 @@ extension UnsafeMutablePointer where Pointee: IWICBitmapSourceProtocol { // MARK: - _AttachableByAddressAsIWICBitmapSource implementation +@_spi(Experimental) extension IWICBitmapSourceProtocol { public static func _copyAttachableIWICBitmapSource( from imageAddress: UnsafeMutablePointer, @@ -119,6 +120,7 @@ extension IWICBitmapSourceProtocol { } extension IWICBitmapSource { + @_spi(Experimental) public static func _copyAttachableIWICBitmapSource( from imageAddress: UnsafeMutablePointer, using factory: UnsafeMutablePointer diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift index d80c2eb01..ecf4602e4 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift @@ -46,7 +46,7 @@ extension _AttachableImageWrapper: Attachable, AttachableWrapper where Image: At let rCreate = CoCreateInstance( &encoderCLSID, nil, - DWORD(bitPattern: CLSCTX_INPROC_SERVER.rawValue), + DWORD(CLSCTX_INPROC_SERVER.rawValue), IID_IWICBitmapEncoder, &encoder ) @@ -93,7 +93,7 @@ extension _AttachableImageWrapper: Attachable, AttachableWrapper where Image: At guard rCommit == S_OK else { throw ImageAttachmentError.imageWritingFailed(rCommit) } - rCommit = stream.pointee.lpVtbl.pointee.Commit(stream, DWORD(bitPattern: STGC_DEFAULT.rawValue)) + rCommit = stream.pointee.lpVtbl.pointee.Commit(stream, DWORD(STGC_DEFAULT.rawValue)) guard rCommit == S_OK else { throw ImageAttachmentError.imageWritingFailed(rCommit) } diff --git a/Sources/Overlays/_Testing_WinSDK/CMakeLists.txt b/Sources/Overlays/_Testing_WinSDK/CMakeLists.txt new file mode 100644 index 000000000..4dcbc706e --- /dev/null +++ b/Sources/Overlays/_Testing_WinSDK/CMakeLists.txt @@ -0,0 +1,32 @@ +# This source file is part of the Swift.org open source project +# +# Copyright (c) 2024–2025 Apple Inc. and the Swift project authors +# Licensed under Apache License v2.0 with Runtime Library Exception +# +# See http://swift.org/LICENSE.txt for license information +# See http://swift.org/CONTRIBUTORS.txt for Swift project authors + +if (CMAKE_SYSTEM_NAME STREQUAL "Windows") + add_library(_Testing_WinSDK + Attachments/_AttachableImageWrapper+AttachableWrapper.swift + Attachments/AttachableAsIWICBitmapSource.swift + Attachments/AttachableImageFormat+CLSID.swift + Attachments/Attachment+AttachableAsIWICBitmapSource.swift + Attachments/HBITMAP+AttachableAsIWICBitmapSource.swift + Attachments/HICON+AttachableAsIWICBitmapSource.swift + Attachments/IWICBitmapSource+AttachableAsIWICBitmapSource.swift + Attachments/UnsafeMutablePointer+AttachableAsIWICBitmapSource.swift + Support/Additions/GUIDAdditions.swift + Support/Additions/IPropertyBag2Additions.swift + Support/Additions/IWICImagingFactoryAdditions.swift + ReexportTesting.swift) + + target_link_libraries(_Testing_WinSDK PUBLIC + Testing) + + target_compile_options(_Testing_WinSDK PRIVATE + -enable-library-evolution + -emit-module-interface -emit-module-interface-path $/_Testing_WinSDK.swiftinterface) + + _swift_testing_install_target(_Testing_WinSDK) +endif() diff --git a/Sources/Overlays/_Testing_WinSDK/Support/Additions/IWICImagingFactoryAdditions.swift b/Sources/Overlays/_Testing_WinSDK/Support/Additions/IWICImagingFactoryAdditions.swift index dc11ab0fc..acacc80b1 100644 --- a/Sources/Overlays/_Testing_WinSDK/Support/Additions/IWICImagingFactoryAdditions.swift +++ b/Sources/Overlays/_Testing_WinSDK/Support/Additions/IWICImagingFactoryAdditions.swift @@ -25,7 +25,7 @@ extension IWICImagingFactory { let rCreate = CoCreateInstance( CLSID_WICImagingFactory, nil, - DWORD(bitPattern: CLSCTX_INPROC_SERVER.rawValue), + DWORD(CLSCTX_INPROC_SERVER.rawValue), IID_IWICImagingFactory, &factory ) diff --git a/Sources/Testing/Attachments/Images/ImageAttachmentError.swift b/Sources/Testing/Attachments/Images/ImageAttachmentError.swift index de421bfd9..1bd90b641 100644 --- a/Sources/Testing/Attachments/Images/ImageAttachmentError.swift +++ b/Sources/Testing/Attachments/Images/ImageAttachmentError.swift @@ -23,19 +23,19 @@ package enum ImageAttachmentError: Error { case couldNotConvertImage #elseif os(Windows) /// A call to `QueryInterface()` failed. - case queryInterfaceFailed(Any.Type, Int32) + case queryInterfaceFailed(Any.Type, CLong) /// The testing library failed to create a COM object. - case comObjectCreationFailed(Any.Type, Int32) + case comObjectCreationFailed(Any.Type, CLong) /// An image could not be written. - case imageWritingFailed(Int32) + case imageWritingFailed(CLong) /// The testing library failed to get an in-memory stream's underlying buffer. - case globalFromStreamFailed(Int32) + case globalFromStreamFailed(CLong) /// A property could not be written to a property bag. - case propertyBagWritingFailed(String, Int32) + case propertyBagWritingFailed(String, CLong) #endif } diff --git a/Sources/Testing/Testing.swiftcrossimport/WinSDK.swiftoverlay b/Sources/Testing/Testing.swiftcrossimport/WinSDK.swiftoverlay new file mode 100644 index 000000000..fdaa23701 --- /dev/null +++ b/Sources/Testing/Testing.swiftcrossimport/WinSDK.swiftoverlay @@ -0,0 +1,3 @@ +version: 1 +modules: +- name: _Testing_WinSDK