diff --git a/Package.swift b/Package.swift index 56a892f0..d8a05a49 100644 --- a/Package.swift +++ b/Package.swift @@ -4,6 +4,9 @@ import PackageDescription let package = Package( name: "SwiftWinRT", products: [ + .library( + name: "WindowsRuntime_ABI", + targets: ["COM_ABI", "WindowsRuntime_ABI"]), .library( name: "WindowsRuntime", targets: ["COM", "WindowsRuntime"]), @@ -13,19 +16,24 @@ let package = Package( name: "COM_ABI", path: "Support/Sources/COM_ABI", exclude: ["CMakeLists.txt"]), - .target( - name: "COM", - dependencies: ["COM_ABI"], - path: "Support/Sources/COM", - exclude: ["CMakeLists.txt"]), .target( name: "WindowsRuntime_ABI", dependencies: ["COM_ABI"], path: "Support/Sources/WindowsRuntime_ABI", exclude: ["CMakeLists.txt"]), + .target( + name: "InternalABI", + dependencies: ["COM_ABI", "WindowsRuntime_ABI"], + path: "Support/Sources/InternalABI", + exclude: ["CMakeLists.txt"]), + .target( + name: "COM", + dependencies: ["COM_ABI", "InternalABI"], + path: "Support/Sources/COM", + exclude: ["CMakeLists.txt"]), .target( name: "WindowsRuntime", - dependencies: ["WindowsRuntime_ABI", "COM"], + dependencies: ["COM", "WindowsRuntime_ABI", "InternalABI"], path: "Support/Sources/WindowsRuntime", exclude: ["CMakeLists.txt"]), .testTarget( diff --git a/Support/Sources/CMakeLists.txt b/Support/Sources/CMakeLists.txt index 55c1c306..5e0c9f98 100644 --- a/Support/Sources/CMakeLists.txt +++ b/Support/Sources/CMakeLists.txt @@ -1,4 +1,6 @@ add_subdirectory(COM_ABI) -add_subdirectory(COM) add_subdirectory(WindowsRuntime_ABI) +add_subdirectory(InternalABI) + +add_subdirectory(COM) add_subdirectory(WindowsRuntime) \ No newline at end of file diff --git a/Support/Sources/COM/CMakeLists.txt b/Support/Sources/COM/CMakeLists.txt index 09b99291..af95fd7f 100644 --- a/Support/Sources/COM/CMakeLists.txt +++ b/Support/Sources/COM/CMakeLists.txt @@ -1,3 +1,3 @@ file(GLOB_RECURSE SOURCES *.swift) add_library(COM STATIC ${SOURCES}) -target_link_libraries(COM PRIVATE COM_ABI) \ No newline at end of file +target_link_libraries(COM PRIVATE COM_ABI SWRT_InternalABI) \ No newline at end of file diff --git a/Support/Sources/COM/COMEmbedding.swift b/Support/Sources/COM/COMEmbedding.swift index 187c146b..28a8f6b2 100644 --- a/Support/Sources/COM/COMEmbedding.swift +++ b/Support/Sources/COM/COMEmbedding.swift @@ -1,4 +1,5 @@ import COM_ABI +import SWRT_SwiftCOMObject /// Protocol for Swift objects which embed COM interfaces. public protocol COMEmbedderWithDelegatedImplementation: IUnknownProtocol { @@ -18,7 +19,7 @@ public struct COMEmbedding /*: ~Copyable */ { // Instead, it is initialized in two steps: first to an invalid value, and then to a valid value. public static var uninitialized: COMEmbedding { .init() } - private var comObject: COM_ABI.SWRT_SwiftCOMObject + private var comObject: SWRT_SwiftCOMObject private init() { comObject = .init() @@ -42,13 +43,13 @@ public struct COMEmbedding /*: ~Copyable */ { public mutating func toCOM() -> IUnknownReference { .init(addingRef: unknownPointer) } fileprivate static func toUnmanagedUnsafe(_ this: UnsafeMutablePointer) -> Unmanaged { - this.withMemoryRebound(to: COM_ABI.SWRT_SwiftCOMObject.self, capacity: 1) { + this.withMemoryRebound(to: SWRT_SwiftCOMObject.self, capacity: 1) { Unmanaged.fromOpaque($0.pointee.swiftObject) } } public static func test(_ this: UnsafeMutablePointer) -> Bool { - do { _ = try COMInterop(this).queryInterface(uuidof(COM_ABI.SWRT_SwiftCOMObject.self)) } catch { return false } + do { _ = try COMInterop(this).queryInterface(uuidof(SWRT_SwiftCOMObject.self)) } catch { return false } return true } @@ -92,7 +93,7 @@ public struct COMEmbedding /*: ~Copyable */ { } } -internal func uuidof(_: COM_ABI.SWRT_SwiftCOMObject.Type) -> COMInterfaceID { +internal func uuidof(_: SWRT_SwiftCOMObject.Type) -> COMInterfaceID { .init(0x33934271, 0x7009, 0x4EF3, 0x90F1, 0x02090D7EBD64) } @@ -130,7 +131,7 @@ public enum IUnknownVirtualTable { return HResult.catchValue { let id = GUIDProjection.toSwift(iid.pointee) let this = IUnknownPointer(OpaquePointer(this)) - let reference = id == uuidof(COM_ABI.SWRT_SwiftCOMObject.self) + let reference = id == uuidof(SWRT_SwiftCOMObject.self) ? IUnknownReference(addingRef: this) : try (COMEmbedding.getEmbedderObjectOrCrash(this) as! IUnknown)._queryInterface(id) ppvObject.pointee = UnsafeMutableRawPointer(reference.detach()) diff --git a/Support/Sources/COM_ABI/combaseapi.c b/Support/Sources/COM_ABI/combaseapi.c index 30b06893..de6285c2 100644 --- a/Support/Sources/COM_ABI/combaseapi.c +++ b/Support/Sources/COM_ABI/combaseapi.c @@ -1,4 +1,4 @@ -#include "SWRT/combaseapi.h" +#include "SWRT/windows/combaseapi.h" #include #include diff --git a/Support/Sources/COM_ABI/include/SWRT/COM.h b/Support/Sources/COM_ABI/include/SWRT/COM.h new file mode 100644 index 00000000..f6dbe84a --- /dev/null +++ b/Support/Sources/COM_ABI/include/SWRT/COM.h @@ -0,0 +1,7 @@ +#include "windows/BaseTsd.h" +#include "windows/combaseapi.h" +#include "windows/guiddef.h" +#include "windows/oaidl.h" +#include "windows/objidl.h" +#include "windows/oleauto.h" +#include "windows/unknwn.h" \ No newline at end of file diff --git a/Support/Sources/COM_ABI/include/SWRT/BaseTsd.h b/Support/Sources/COM_ABI/include/SWRT/windows/BaseTsd.h similarity index 100% rename from Support/Sources/COM_ABI/include/SWRT/BaseTsd.h rename to Support/Sources/COM_ABI/include/SWRT/windows/BaseTsd.h diff --git a/Support/Sources/COM_ABI/include/SWRT/combaseapi.h b/Support/Sources/COM_ABI/include/SWRT/windows/combaseapi.h similarity index 63% rename from Support/Sources/COM_ABI/include/SWRT/combaseapi.h rename to Support/Sources/COM_ABI/include/SWRT/windows/combaseapi.h index 62ca44ac..51dea897 100644 --- a/Support/Sources/COM_ABI/include/SWRT/combaseapi.h +++ b/Support/Sources/COM_ABI/include/SWRT/windows/combaseapi.h @@ -1,6 +1,6 @@ #pragma once -#include "SWRT/BaseTsd.h" -#include "SWRT/unknwn.h" +#include "SWRT/windows/BaseTsd.h" +#include "SWRT/windows/unknwn.h" SWRT_HResult SWRT_CoCreateFreeThreadedMarshaler(SWRT_IUnknown* punkOuter, SWRT_IUnknown** ppunkMarshal); \ No newline at end of file diff --git a/Support/Sources/COM_ABI/include/SWRT/guiddef.h b/Support/Sources/COM_ABI/include/SWRT/windows/guiddef.h similarity index 100% rename from Support/Sources/COM_ABI/include/SWRT/guiddef.h rename to Support/Sources/COM_ABI/include/SWRT/windows/guiddef.h diff --git a/Support/Sources/COM_ABI/include/SWRT/oaidl.h b/Support/Sources/COM_ABI/include/SWRT/windows/oaidl.h similarity index 92% rename from Support/Sources/COM_ABI/include/SWRT/oaidl.h rename to Support/Sources/COM_ABI/include/SWRT/windows/oaidl.h index 844b5bdb..f75138ab 100644 --- a/Support/Sources/COM_ABI/include/SWRT/oaidl.h +++ b/Support/Sources/COM_ABI/include/SWRT/windows/oaidl.h @@ -1,7 +1,7 @@ #pragma once -#include "SWRT/oleauto.h" -#include "SWRT/unknwn.h" +#include "SWRT/windows/oleauto.h" +#include "SWRT/windows/unknwn.h" typedef struct SWRT_IErrorInfo { struct SWRT_IErrorInfo_VirtualTable* VirtualTable; diff --git a/Support/Sources/COM_ABI/include/SWRT/objidl.h b/Support/Sources/COM_ABI/include/SWRT/windows/objidl.h similarity index 94% rename from Support/Sources/COM_ABI/include/SWRT/objidl.h rename to Support/Sources/COM_ABI/include/SWRT/windows/objidl.h index c11bde50..9bb9fa5a 100644 --- a/Support/Sources/COM_ABI/include/SWRT/objidl.h +++ b/Support/Sources/COM_ABI/include/SWRT/windows/objidl.h @@ -1,8 +1,8 @@ #pragma once -#include "SWRT/guiddef.h" -#include "SWRT/oleauto.h" -#include "SWRT/unknwn.h" +#include "SWRT/windows/guiddef.h" +#include "SWRT/windows/oleauto.h" +#include "SWRT/windows/unknwn.h" // IAgileObject typedef struct SWRT_IAgileObject { diff --git a/Support/Sources/COM_ABI/include/SWRT/oleauto.h b/Support/Sources/COM_ABI/include/SWRT/windows/oleauto.h similarity index 100% rename from Support/Sources/COM_ABI/include/SWRT/oleauto.h rename to Support/Sources/COM_ABI/include/SWRT/windows/oleauto.h diff --git a/Support/Sources/COM_ABI/include/SWRT/unknwn.h b/Support/Sources/COM_ABI/include/SWRT/windows/unknwn.h similarity index 84% rename from Support/Sources/COM_ABI/include/SWRT/unknwn.h rename to Support/Sources/COM_ABI/include/SWRT/windows/unknwn.h index 86fe43a6..8aeeeb12 100644 --- a/Support/Sources/COM_ABI/include/SWRT/unknwn.h +++ b/Support/Sources/COM_ABI/include/SWRT/windows/unknwn.h @@ -1,7 +1,7 @@ #pragma once -#include "SWRT/guiddef.h" -#include "SWRT/BaseTsd.h" +#include "SWRT/windows/guiddef.h" +#include "SWRT/windows/BaseTsd.h" // IUnknown typedef struct SWRT_IUnknown { diff --git a/Support/Sources/COM_ABI/include/module.modulemap b/Support/Sources/COM_ABI/include/module.modulemap index f09b747a..38319687 100644 --- a/Support/Sources/COM_ABI/include/module.modulemap +++ b/Support/Sources/COM_ABI/include/module.modulemap @@ -1,11 +1,11 @@ module COM_ABI { - header "SwiftCOMObject.h" - header "SWRT/BaseTsd.h" - header "SWRT/combaseapi.h" - header "SWRT/guiddef.h" - header "SWRT/oaidl.h" - header "SWRT/objidl.h" - header "SWRT/oleauto.h" - header "SWRT/unknwn.h" + header "SWRT/COM.h" + header "SWRT/windows/BaseTsd.h" + header "SWRT/windows/combaseapi.h" + header "SWRT/windows/guiddef.h" + header "SWRT/windows/oaidl.h" + header "SWRT/windows/objidl.h" + header "SWRT/windows/oleauto.h" + header "SWRT/windows/unknwn.h" export * -} \ No newline at end of file +} diff --git a/Support/Sources/COM_ABI/oleauto.c b/Support/Sources/COM_ABI/oleauto.c index 6f6570e0..959e5775 100644 --- a/Support/Sources/COM_ABI/oleauto.c +++ b/Support/Sources/COM_ABI/oleauto.c @@ -1,4 +1,4 @@ -#include "SWRT/oleauto.h" +#include "SWRT/windows/oleauto.h" #include #include diff --git a/Support/Sources/InternalABI/CMakeLists.txt b/Support/Sources/InternalABI/CMakeLists.txt new file mode 100644 index 00000000..4e3a25e2 --- /dev/null +++ b/Support/Sources/InternalABI/CMakeLists.txt @@ -0,0 +1,3 @@ +add_library(SWRT_InternalABI INTERFACE) +target_include_directories(SWRT_InternalABI INTERFACE include) +target_link_libraries(SWRT_InternalABI INTERFACE COM_ABI WindowsRuntime_ABI) \ No newline at end of file diff --git a/Support/Sources/WindowsRuntime_ABI/include/SWRT/windows.foundation.h b/Support/Sources/InternalABI/include/SWRT/windows/windows.foundation.h similarity index 99% rename from Support/Sources/WindowsRuntime_ABI/include/SWRT/windows.foundation.h rename to Support/Sources/InternalABI/include/SWRT/windows/windows.foundation.h index bee48cc7..fb28ab8f 100644 --- a/Support/Sources/WindowsRuntime_ABI/include/SWRT/windows.foundation.h +++ b/Support/Sources/InternalABI/include/SWRT/windows/windows.foundation.h @@ -1,6 +1,6 @@ #pragma once -#include "SWRT/inspectable.h" +#include "SWRT/windows/inspectable.h" // Windows.Foundation.PropertyType typedef int32_t SWRT_WindowsFoundation_PropertyType; diff --git a/Support/Sources/COM_ABI/include/SwiftCOMObject.h b/Support/Sources/InternalABI/include/SwiftCOMObject.h similarity index 100% rename from Support/Sources/COM_ABI/include/SwiftCOMObject.h rename to Support/Sources/InternalABI/include/SwiftCOMObject.h diff --git a/Support/Sources/InternalABI/include/module.modulemap b/Support/Sources/InternalABI/include/module.modulemap new file mode 100644 index 00000000..d1424182 --- /dev/null +++ b/Support/Sources/InternalABI/include/module.modulemap @@ -0,0 +1,9 @@ +module SWRT_SwiftCOMObject { + header "SwiftCOMObject.h" + export * +} + +module SWRT_WindowsFoundation { + header "SWRT/windows/windows.foundation.h" + export * +} \ No newline at end of file diff --git a/Support/Sources/WindowsRuntime/CMakeLists.txt b/Support/Sources/WindowsRuntime/CMakeLists.txt index 6bdea678..599fddc3 100644 --- a/Support/Sources/WindowsRuntime/CMakeLists.txt +++ b/Support/Sources/WindowsRuntime/CMakeLists.txt @@ -1,3 +1,3 @@ file(GLOB_RECURSE SOURCES *.swift) add_library(WindowsRuntime STATIC ${SOURCES}) -target_link_libraries(WindowsRuntime PRIVATE COM WindowsRuntime_ABI) \ No newline at end of file +target_link_libraries(WindowsRuntime PRIVATE COM WindowsRuntime_ABI SWRT_InternalABI) \ No newline at end of file diff --git a/Support/Sources/WindowsRuntime/IReferenceUnboxingProjection.swift b/Support/Sources/WindowsRuntime/IReferenceUnboxingProjection.swift index 17af367e..e4dc46f1 100644 --- a/Support/Sources/WindowsRuntime/IReferenceUnboxingProjection.swift +++ b/Support/Sources/WindowsRuntime/IReferenceUnboxingProjection.swift @@ -1,5 +1,6 @@ import COM import WindowsRuntime_ABI +import SWRT_WindowsFoundation public enum IReferenceUnboxingProjection { public typealias Boolean = Of @@ -18,7 +19,7 @@ public enum IReferenceUnboxingProjection { public enum Of: WinRTProjection, COMProjection { public typealias SwiftObject = Projection.SwiftValue - public typealias ABIStruct = WindowsRuntime_ABI.SWRT_WindowsFoundation_IReference + public typealias ABIStruct = SWRT_WindowsFoundation_IReference 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/Infra/ProjectionProtocols+extensions.swift b/Support/Sources/WindowsRuntime/Infra/ProjectionProtocols+extensions.swift index 82f4513c..56d1993d 100644 --- a/Support/Sources/WindowsRuntime/Infra/ProjectionProtocols+extensions.swift +++ b/Support/Sources/WindowsRuntime/Infra/ProjectionProtocols+extensions.swift @@ -1,4 +1,5 @@ import WindowsRuntime_ABI +import SWRT_WindowsFoundation extension BoxableProjection { public static func box(_ value: SwiftValue) throws -> IInspectable { diff --git a/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/DateTime.swift b/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/DateTime.swift index f2496c79..e28a58b2 100644 --- a/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/DateTime.swift +++ b/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/DateTime.swift @@ -33,7 +33,7 @@ extension WindowsFoundation_DateTime { } } -import WindowsRuntime_ABI +import SWRT_WindowsFoundation extension WindowsFoundation_DateTime: WindowsRuntime.StructProjection, COM.ABIInertProjection { public typealias SwiftValue = Self diff --git a/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/IPropertyValue.swift b/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/IPropertyValue.swift index cea633ed..40948031 100644 --- a/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/IPropertyValue.swift +++ b/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/IPropertyValue.swift @@ -1,5 +1,3 @@ -import WindowsRuntime_ABI - /// Represents a value in a property store. You can't implement this interface, see Remarks. public typealias WindowsFoundation_IPropertyValue = any WindowsFoundation_IPropertyValueProtocol @@ -93,11 +91,13 @@ extension WindowsFoundation_IPropertyValueProtocol { public func getRectArray(_ value: inout [WindowsFoundation_Rect]) throws { throw HResult.Error.notImpl } } -internal func uuidof(_: WindowsRuntime_ABI.SWRT_WindowsFoundation_IPropertyValue.Type) -> COMInterfaceID { +import SWRT_WindowsFoundation + +internal func uuidof(_: SWRT_WindowsFoundation_IPropertyValue.Type) -> COMInterfaceID { .init(0x4BD682DD, 0x7554, 0x40E9, 0x9A9B, 0x82654EDE7E62) } -extension COMInterop where ABIStruct == WindowsRuntime_ABI.SWRT_WindowsFoundation_IPropertyValue { +extension COMInterop where ABIStruct == SWRT_WindowsFoundation_IPropertyValue { internal func get_Type() throws -> WindowsFoundation_PropertyType { var abi_value: SWRT_WindowsFoundation_PropertyType = .init() try WinRTError.throwIfFailed(this.pointee.VirtualTable.pointee.get_Type(this, &abi_value)) diff --git a/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/IReference.swift b/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/IReference.swift index e987bff5..1105c791 100644 --- a/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/IReference.swift +++ b/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/IReference.swift @@ -19,7 +19,7 @@ extension WindowsFoundation_IReferenceProtocol { var value: T { try! _value() } } -import WindowsRuntime_ABI +import SWRT_WindowsFoundation public enum WindowsFoundation_IReferenceProjection: InterfaceProjection { public typealias SwiftObject = WindowsFoundation_IReference diff --git a/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/IStringable.swift b/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/IStringable.swift index b58ec73c..17ceeba7 100644 --- a/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/IStringable.swift +++ b/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/IStringable.swift @@ -7,7 +7,7 @@ public protocol WindowsFoundation_IStringableProtocol: IInspectableProtocol { func toString() throws -> String } -import WindowsRuntime_ABI +import SWRT_WindowsFoundation public enum WindowsFoundation_IStringableProjection: InterfaceProjection { public typealias SwiftObject = WindowsFoundation_IStringable @@ -41,7 +41,7 @@ public enum WindowsFoundation_IStringableProjection: InterfaceProjection { ToString: { this, value in _implement(this) { try _set(value, PrimitiveProjection.String.toABI($0.toString())) } }) } -public func uuidof(_: WindowsRuntime_ABI.SWRT_WindowsFoundation_IStringable.Type) -> COMInterfaceID { +public func uuidof(_: SWRT_WindowsFoundation_IStringable.Type) -> COMInterfaceID { .init(0x96369F54, 0x8EB6, 0x48F0, 0xABCE, 0xC1B211E627C3); } diff --git a/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/Point.swift b/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/Point.swift index 8c2cb37b..b0fc5aee 100644 --- a/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/Point.swift +++ b/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/Point.swift @@ -17,7 +17,7 @@ public struct WindowsFoundation_Point: Hashable, Codable, Sendable { } } -import WindowsRuntime_ABI +import SWRT_WindowsFoundation extension WindowsFoundation_Point: WindowsRuntime.StructProjection, COM.ABIInertProjection { public typealias SwiftValue = Self diff --git a/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/Rect.swift b/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/Rect.swift index 8dd2d8e6..dffd02b7 100644 --- a/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/Rect.swift +++ b/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/Rect.swift @@ -27,7 +27,7 @@ public struct WindowsFoundation_Rect: Hashable, Codable, Sendable { } } -import WindowsRuntime_ABI +import SWRT_WindowsFoundation extension WindowsFoundation_Rect: WindowsRuntime.StructProjection, COM.ABIInertProjection { public typealias SwiftValue = Self diff --git a/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/Size.swift b/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/Size.swift index ed7dabeb..cf158545 100644 --- a/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/Size.swift +++ b/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/Size.swift @@ -17,7 +17,7 @@ public struct WindowsFoundation_Size: Hashable, Codable, Sendable { } } -import WindowsRuntime_ABI +import SWRT_WindowsFoundation extension WindowsFoundation_Size: WindowsRuntime.StructProjection, COM.ABIInertProjection { public typealias SwiftValue = Self diff --git a/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/TimeSpan.swift b/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/TimeSpan.swift index 7775fd86..8edd87e5 100644 --- a/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/TimeSpan.swift +++ b/Support/Sources/WindowsRuntime/ProjectedTypes/WindowsFoundation/TimeSpan.swift @@ -49,7 +49,7 @@ extension WindowsFoundation_TimeSpan { } // Projection -import WindowsRuntime_ABI +import SWRT_WindowsFoundation /// Projects a Windows.Foundation.TimeSpan into a Swift.Duration value. extension WindowsFoundation_TimeSpan: StructProjection, ABIInertProjection { diff --git a/Support/Sources/WindowsRuntime/PropertyValueStatics.swift b/Support/Sources/WindowsRuntime/PropertyValueStatics.swift index 61093c7a..b35e9c73 100644 --- a/Support/Sources/WindowsRuntime/PropertyValueStatics.swift +++ b/Support/Sources/WindowsRuntime/PropertyValueStatics.swift @@ -1,11 +1,12 @@ import COM import WindowsRuntime_ABI +import SWRT_WindowsFoundation internal enum PropertyValueStatics { private static let iid = COMInterfaceID(0x629BDBC8, 0xD932, 0x4FF4, 0x96B9, 0x8D96C5C1E858) - private static var lazyReference: COM.COMReference.Optional = .none + private static var lazyReference: COM.COMReference.Optional = .none - private static var this: UnsafeMutablePointer { + private static var this: UnsafeMutablePointer { get throws { try lazyReference.lazyInitPointer { try SystemActivationFactoryResolver.resolve( diff --git a/Support/Sources/WindowsRuntime_ABI/include/SWRT/WindowsRuntime.h b/Support/Sources/WindowsRuntime_ABI/include/SWRT/WindowsRuntime.h new file mode 100644 index 00000000..fb148251 --- /dev/null +++ b/Support/Sources/WindowsRuntime_ABI/include/SWRT/WindowsRuntime.h @@ -0,0 +1,12 @@ +#include "SWRT/COM.h" + +#include "windows/activation.h" +#include "windows/eventtoken.h" +#include "windows/inspectable.h" +#include "windows/memorybuffer.h" +#include "windows/restrictederrorinfo.h" +#include "windows/roapi.h" +#include "windows/robuffer.h" +#include "windows/roerrorapi.h" +#include "windows/weakreference.h" +#include "windows/winstring.h" \ No newline at end of file diff --git a/Support/Sources/WindowsRuntime_ABI/include/SWRT/activation.h b/Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/activation.h similarity index 95% rename from Support/Sources/WindowsRuntime_ABI/include/SWRT/activation.h rename to Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/activation.h index 9625ddb5..75fca034 100644 --- a/Support/Sources/WindowsRuntime_ABI/include/SWRT/activation.h +++ b/Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/activation.h @@ -1,6 +1,6 @@ #pragma once -#include "SWRT/inspectable.h" +#include "SWRT/windows/inspectable.h" // IActivationFactory typedef struct SWRT_IActivationFactory { diff --git a/Support/Sources/WindowsRuntime_ABI/include/SWRT/eventtoken.h b/Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/eventtoken.h similarity index 100% rename from Support/Sources/WindowsRuntime_ABI/include/SWRT/eventtoken.h rename to Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/eventtoken.h diff --git a/Support/Sources/WindowsRuntime_ABI/include/SWRT/inspectable.h b/Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/inspectable.h similarity index 91% rename from Support/Sources/WindowsRuntime_ABI/include/SWRT/inspectable.h rename to Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/inspectable.h index 39f1bfa5..17d7ffca 100644 --- a/Support/Sources/WindowsRuntime_ABI/include/SWRT/inspectable.h +++ b/Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/inspectable.h @@ -1,7 +1,7 @@ #pragma once -#include "SWRT/unknwn.h" -#include "SWRT/winstring.h" +#include "SWRT/windows/unknwn.h" +#include "SWRT/windows/winstring.h" // TrustLevel typedef int32_t SWRT_TrustLevel; diff --git a/Support/Sources/WindowsRuntime_ABI/include/SWRT/memorybuffer.h b/Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/memorybuffer.h similarity index 95% rename from Support/Sources/WindowsRuntime_ABI/include/SWRT/memorybuffer.h rename to Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/memorybuffer.h index faaabb09..894c2386 100644 --- a/Support/Sources/WindowsRuntime_ABI/include/SWRT/memorybuffer.h +++ b/Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/memorybuffer.h @@ -1,6 +1,6 @@ #pragma once -#include "SWRT/unknwn.h" +#include "SWRT/windows/unknwn.h" typedef struct SWRT_IMemoryBufferByteAccess SWRT_IMemoryBufferByteAccess; diff --git a/Support/Sources/WindowsRuntime_ABI/include/SWRT/restrictederrorinfo.h b/Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/restrictederrorinfo.h similarity index 91% rename from Support/Sources/WindowsRuntime_ABI/include/SWRT/restrictederrorinfo.h rename to Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/restrictederrorinfo.h index 1890acc8..e907eaf1 100644 --- a/Support/Sources/WindowsRuntime_ABI/include/SWRT/restrictederrorinfo.h +++ b/Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/restrictederrorinfo.h @@ -1,7 +1,7 @@ #pragma once -#include "SWRT/oleauto.h" -#include "SWRT/unknwn.h" +#include "SWRT/windows/oleauto.h" +#include "SWRT/windows/unknwn.h" typedef struct SWRT_IRestrictedErrorInfo { struct SWRT_IRestrictedErrorInfo_VirtualTable* VirtualTable; diff --git a/Support/Sources/WindowsRuntime_ABI/include/SWRT/roapi.h b/Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/roapi.h similarity index 58% rename from Support/Sources/WindowsRuntime_ABI/include/SWRT/roapi.h rename to Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/roapi.h index c579a6e7..8b134cbd 100644 --- a/Support/Sources/WindowsRuntime_ABI/include/SWRT/roapi.h +++ b/Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/roapi.h @@ -1,14 +1,15 @@ #pragma once -#include "SWRT/activation.h" -#include "SWRT/BaseTsd.h" -#include "SWRT/winstring.h" +#include "SWRT/windows/activation.h" +#include "SWRT/windows/BaseTsd.h" +#include "SWRT/windows/winstring.h" typedef enum SWRT_RO_INIT_TYPE { SWRT_RO_INIT_SINGLETHREADED = 0, SWRT_RO_INIT_MULTITHREADED = 1 } SWRT_RO_INIT_TYPE; +typedef SWRT_HResult(__stdcall *SWRT_DllGetActivationFactory)(SWRT_HString activatableClassId, SWRT_IActivationFactory** factory); SWRT_HResult SWRT_RoGetActivationFactory(SWRT_HString activatableClassId, SWRT_Guid* iid, void** factory); SWRT_HResult SWRT_RoInitialize(SWRT_RO_INIT_TYPE initType); void SWRT_RoUninitialize(); diff --git a/Support/Sources/WindowsRuntime_ABI/include/SWRT/robuffer.h b/Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/robuffer.h similarity index 94% rename from Support/Sources/WindowsRuntime_ABI/include/SWRT/robuffer.h rename to Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/robuffer.h index 387abd14..141d171e 100644 --- a/Support/Sources/WindowsRuntime_ABI/include/SWRT/robuffer.h +++ b/Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/robuffer.h @@ -1,6 +1,6 @@ #pragma once -#include "SWRT/unknwn.h" +#include "SWRT/windows/unknwn.h" typedef struct SWRT_IBufferByteAccess SWRT_IBufferByteAccess; diff --git a/Support/Sources/WindowsRuntime_ABI/include/SWRT/roerrorapi.h b/Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/roerrorapi.h similarity index 84% rename from Support/Sources/WindowsRuntime_ABI/include/SWRT/roerrorapi.h rename to Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/roerrorapi.h index 4508614d..0a153795 100644 --- a/Support/Sources/WindowsRuntime_ABI/include/SWRT/roerrorapi.h +++ b/Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/roerrorapi.h @@ -1,8 +1,8 @@ #pragma once #include -#include "SWRT/restrictederrorinfo.h" -#include "SWRT/winstring.h" +#include "SWRT/windows/restrictederrorinfo.h" +#include "SWRT/windows/winstring.h" SWRT_HResult SWRT_GetRestrictedErrorInfo(SWRT_IRestrictedErrorInfo** ppRestrictedErrorInfo); void SWRT_RoClearError(); diff --git a/Support/Sources/WindowsRuntime_ABI/include/SWRT/weakreference.h b/Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/weakreference.h similarity index 96% rename from Support/Sources/WindowsRuntime_ABI/include/SWRT/weakreference.h rename to Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/weakreference.h index 0aa3bafb..aadc2380 100644 --- a/Support/Sources/WindowsRuntime_ABI/include/SWRT/weakreference.h +++ b/Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/weakreference.h @@ -1,6 +1,6 @@ #pragma once -#include "SWRT/inspectable.h" +#include "SWRT/windows/inspectable.h" typedef struct SWRT_IWeakReference { struct SWRT_IWeakReference_VirtualTable* VirtualTable; diff --git a/Support/Sources/WindowsRuntime_ABI/include/SWRT/winstring.h b/Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/winstring.h similarity index 96% rename from Support/Sources/WindowsRuntime_ABI/include/SWRT/winstring.h rename to Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/winstring.h index 0075e567..cac493d7 100644 --- a/Support/Sources/WindowsRuntime_ABI/include/SWRT/winstring.h +++ b/Support/Sources/WindowsRuntime_ABI/include/SWRT/windows/winstring.h @@ -2,7 +2,7 @@ #include #include -#include "SWRT/BaseTsd.h" +#include "SWRT/windows/BaseTsd.h" struct SWRT_HString_ {}; typedef struct SWRT_HString_* SWRT_HString; diff --git a/Support/Sources/WindowsRuntime_ABI/include/SWRT/winrt.h b/Support/Sources/WindowsRuntime_ABI/include/SWRT/winrt.h deleted file mode 100644 index 43739df4..00000000 --- a/Support/Sources/WindowsRuntime_ABI/include/SWRT/winrt.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "SWRT/BaseTsd.h" -#include "SWRT/winstring.h" -#include "SWRT/activation.h" - -typedef SWRT_HResult(__stdcall *SWRT_DllGetActivationFactory)(SWRT_HString activatableClassId, SWRT_IActivationFactory** factory); \ No newline at end of file diff --git a/Support/Sources/WindowsRuntime_ABI/include/module.modulemap b/Support/Sources/WindowsRuntime_ABI/include/module.modulemap index 7f1e7973..5ac8c277 100644 --- a/Support/Sources/WindowsRuntime_ABI/include/module.modulemap +++ b/Support/Sources/WindowsRuntime_ABI/include/module.modulemap @@ -1,15 +1,14 @@ module WindowsRuntime_ABI { - header "SWRT/activation.h" - header "SWRT/eventtoken.h" - header "SWRT/inspectable.h" - header "SWRT/memorybuffer.h" - header "SWRT/restrictederrorinfo.h" - header "SWRT/roapi.h" - header "SWRT/robuffer.h" - header "SWRT/roerrorapi.h" - header "SWRT/weakreference.h" - header "SWRT/windows.foundation.h" - header "SWRT/winrt.h" - header "SWRT/winstring.h" + header "SWRT/WindowsRuntime.h" + header "SWRT/windows/activation.h" + header "SWRT/windows/eventtoken.h" + header "SWRT/windows/inspectable.h" + header "SWRT/windows/memorybuffer.h" + header "SWRT/windows/restrictederrorinfo.h" + header "SWRT/windows/roapi.h" + header "SWRT/windows/robuffer.h" + header "SWRT/windows/roerrorapi.h" + header "SWRT/windows/weakreference.h" + header "SWRT/windows/winstring.h" export * -} \ No newline at end of file +} diff --git a/Support/Sources/WindowsRuntime_ABI/roapi.c b/Support/Sources/WindowsRuntime_ABI/roapi.c index 53a9000f..895e2121 100644 --- a/Support/Sources/WindowsRuntime_ABI/roapi.c +++ b/Support/Sources/WindowsRuntime_ABI/roapi.c @@ -1,4 +1,4 @@ -#include "SWRT/roapi.h" +#include "SWRT/windows/roapi.h" #include #include diff --git a/Support/Sources/WindowsRuntime_ABI/roerrorapi.c b/Support/Sources/WindowsRuntime_ABI/roerrorapi.c index b83c9710..9e7148a5 100644 --- a/Support/Sources/WindowsRuntime_ABI/roerrorapi.c +++ b/Support/Sources/WindowsRuntime_ABI/roerrorapi.c @@ -1,4 +1,4 @@ -#include "SWRT/roerrorapi.h" +#include "SWRT/windows/roerrorapi.h" #include #include diff --git a/Support/Sources/WindowsRuntime_ABI/winstring.c b/Support/Sources/WindowsRuntime_ABI/winstring.c index 6afd93de..c7a03fb5 100644 --- a/Support/Sources/WindowsRuntime_ABI/winstring.c +++ b/Support/Sources/WindowsRuntime_ABI/winstring.c @@ -1,4 +1,4 @@ -#include "SWRT/winstring.h" +#include "SWRT/windows/winstring.h" #include