From ba7a8b5000ed3f9f077000d1a31f2a0b19907657 Mon Sep 17 00:00:00 2001 From: Steve Kirbach Date: Tue, 13 Feb 2024 17:59:52 -0800 Subject: [PATCH] Initial commit --- .gitignore | 95 + .vscode/tasks.json | 11 + LICENSE | 29 + Package.swift | 21 + README.md | 18 + .../Generated/Support/AGGREGATION.swift | 128 + .../Generated/Support/ARRAY+TOVECTOR.swift | 81 + .../Generated/Support/COM+EXTENSIONS.swift | 36 + .../Generated/Support/COMPTR.swift | 126 + .../Support/CPPINTEROPWORKAROUND.swift | 35 + .../Support/CUSTOMQUERYINTERFACE.swift | 23 + .../Generated/Support/DEBUGGING.swift | 67 + .../Generated/Support/DICTIONARY+TOMAP.swift | 58 + .../Generated/Support/ERROR.swift | 174 ++ .../Generated/Support/ERRORHANDLING.swift | 15 + .../Generated/Support/EVENT.swift | 44 + .../Support/EVENTHANDLERSUBSCRIPTION.swift | 39 + .../Generated/Support/EVENTSOURCE.swift | 33 + .../Generated/Support/GUID.swift | 84 + .../Generated/Support/HSTRING.swift | 47 + .../Generated/Support/IBUFFERBYTEACCESS.swift | 64 + .../Support/IINSPECTABLE+SWIFT.swift | 79 + .../Generated/Support/IINSPECTABLE.swift | 141 + .../Generated/Support/IMAP+SWIFT.swift | 58 + .../Support/IMEMORYBUFFERBYTEACCESS.swift | 74 + .../Generated/Support/IUNKNOWN+SWIFT.swift | 41 + .../Generated/Support/IUNKNOWN.swift | 35 + .../Generated/Support/IUNKNOWNREF.swift | 21 + .../Generated/Support/IVECTOR+SWIFT.swift | 43 + .../Generated/Support/MAKEFROMABI.swift | 31 + .../Generated/Support/MARSHALER.swift | 136 + .../Generated/Support/PROPERTYVALUE+ABI.swift | 173 ++ .../Generated/Support/PROPERTYVALUE.swift | 142 + .../Generated/Support/RAWTYPED.swift | 32 + .../Generated/Support/RUNTIME+SWIFT.swift | 31 + .../Generated/Support/SWIFT+EXTENSIONS.swift | 38 + .../Generated/Support/TRUSTLEVEL+SWIFT.swift | 18 + .../Generated/Support/WAITABLEEVENT.swift | 40 + .../Generated/Support/WINRTDELEGATE.swift | 4 + .../Generated/Support/WINRTPROTOCOLS.swift | 95 + .../Generated/Support/WINRTWRAPPERBASE.swift | 255 ++ .../Generated/Support/WINSDK+EXTENSIONS.swift | 39 + .../Generated/Windows.Foundation+ABI.swift | 1502 +++++++++++ .../Generated/Windows.Foundation+Impl.swift | 457 ++++ .../Windows.Foundation.Collections+ABI.swift | 166 ++ .../Windows.Foundation.Collections+Impl.swift | 126 + .../Windows.Foundation.Collections.swift | 504 ++++ .../Windows.Foundation.Numerics+ABI.swift | 48 + .../Windows.Foundation.Numerics+Impl.swift | 7 + .../Windows.Foundation.Numerics.swift | 202 ++ .../Generated/Windows.Foundation.swift | 956 +++++++ .../WindowsFoundation+Generics.swift | 2387 +++++++++++++++++ .../WindowsFoundation+MakeFromAbi.swift | 113 + generate-bindings.ps1 | 138 + projections.json | 18 + 55 files changed, 9378 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/tasks.json create mode 100644 LICENSE create mode 100644 Package.swift create mode 100644 README.md create mode 100644 Sources/WindowsFoundation/Generated/Support/AGGREGATION.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/ARRAY+TOVECTOR.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/COM+EXTENSIONS.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/COMPTR.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/CPPINTEROPWORKAROUND.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/CUSTOMQUERYINTERFACE.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/DEBUGGING.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/DICTIONARY+TOMAP.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/ERROR.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/ERRORHANDLING.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/EVENT.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/EVENTHANDLERSUBSCRIPTION.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/EVENTSOURCE.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/GUID.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/HSTRING.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/IBUFFERBYTEACCESS.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/IINSPECTABLE+SWIFT.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/IINSPECTABLE.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/IMAP+SWIFT.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/IMEMORYBUFFERBYTEACCESS.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/IUNKNOWN+SWIFT.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/IUNKNOWN.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/IUNKNOWNREF.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/IVECTOR+SWIFT.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/MAKEFROMABI.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/MARSHALER.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/PROPERTYVALUE+ABI.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/PROPERTYVALUE.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/RAWTYPED.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/RUNTIME+SWIFT.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/SWIFT+EXTENSIONS.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/TRUSTLEVEL+SWIFT.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/WAITABLEEVENT.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/WINRTDELEGATE.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/WINRTPROTOCOLS.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/WINRTWRAPPERBASE.swift create mode 100644 Sources/WindowsFoundation/Generated/Support/WINSDK+EXTENSIONS.swift create mode 100644 Sources/WindowsFoundation/Generated/Windows.Foundation+ABI.swift create mode 100644 Sources/WindowsFoundation/Generated/Windows.Foundation+Impl.swift create mode 100644 Sources/WindowsFoundation/Generated/Windows.Foundation.Collections+ABI.swift create mode 100644 Sources/WindowsFoundation/Generated/Windows.Foundation.Collections+Impl.swift create mode 100644 Sources/WindowsFoundation/Generated/Windows.Foundation.Collections.swift create mode 100644 Sources/WindowsFoundation/Generated/Windows.Foundation.Numerics+ABI.swift create mode 100644 Sources/WindowsFoundation/Generated/Windows.Foundation.Numerics+Impl.swift create mode 100644 Sources/WindowsFoundation/Generated/Windows.Foundation.Numerics.swift create mode 100644 Sources/WindowsFoundation/Generated/Windows.Foundation.swift create mode 100644 Sources/WindowsFoundation/Generated/WindowsFoundation+Generics.swift create mode 100644 Sources/WindowsFoundation/Generated/WindowsFoundation+MakeFromAbi.swift create mode 100644 generate-bindings.ps1 create mode 100644 projections.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2a6669c --- /dev/null +++ b/.gitignore @@ -0,0 +1,95 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## User settings +xcuserdata/ + +## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) +*.xcscmblueprint +*.xccheckout + +## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) +build/ +DerivedData/ +*.moved-aside +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 + +## Obj-C/Swift specific +*.hmap + +## App packaging +*.ipa +*.dSYM.zip +*.dSYM + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +# Package.pins +# Package.resolved +# *.xcodeproj +# +# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata +# hence it is not needed unless you have added a package configuration file to your project +# .swiftpm + +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ +# +# Add this line if you want to avoid checking in source code from the Xcode workspace +# *.xcworkspace + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build/ + +# Accio dependency management +Dependencies/ +.accio/ + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. +# Instead, use fastlane to re-generate the screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/#source-control + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots/**/*.png +fastlane/test_output + +# Code Injection +# +# After new code Injection tools there's a generated folder /iOSInjectionProject +# https://github.com/johnno1962/injectionforxcode + +iOSInjectionProject/ + +.packages +.generated +swift-winrt.rsp +Package.resolved diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..16b5b5d --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,11 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "shell", + "label": "Generate swift-windowsfoundation bindings", + "command": "${workspaceFolder:swift-windowsfoundation}/generate-bindings.ps1", + "problemMatcher": [] + } + ] +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..88a95f5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2024, The Browser Company +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..00add87 --- /dev/null +++ b/Package.swift @@ -0,0 +1,21 @@ +// swift-tools-version: 5.10 + +import PackageDescription + +let package = Package( + name: "swift-windowsfoundation", + products: [ + .library(name: "WindowsFoundation", type: .dynamic, targets: ["WindowsFoundation"]), + ], + dependencies: [ + .package(url: "https://github.com/thebrowsercompany/swift-cwinrt", branch: "main"), + ], + targets: [ + .target( + name: "WindowsFoundation", + dependencies: [ + .product(name: "CWinRT", package: "swift-cwinrt"), + ] + ), + ] +) diff --git a/README.md b/README.md new file mode 100644 index 0000000..7ccc428 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# Swift Language Bindings for `Windows.Foundation` APIs + +This repository contains the Swift/WinRT language bindings for types in the `Windows.Foundation` namespace. It also contains general helper APIs used throughout all generated bindings. + +These APIs are intendened to be used in conjuction with the following projects: +- [swift-uwp](https://github.com/thebrowsercompany/swift-uwp) +- [swift-winui](https://github.com/thebrowsercompany/swift-winui) +- [swift-windowsappsdk](https://github.com/thebrowsercompany/swift-windowsappsdk) +- [swift-win2d](https://github.com/thebrowsercompany/swift-win2d) + +## Filing Issues + +Please file any issues you have with this repository on https://github.com/thebrowsercompany/swift-winrt + +## Known Issues and Limitations +- The developer experience for consuming WinRT APIs from Swift is a work in progress. Due to current limitations, not all APIs can be generated as this causes export limit issues. + +- The APIs listed in projections.json are required for the other `swift-*` projects to build. Modify a projections.json in any one of those projects could require an update here. diff --git a/Sources/WindowsFoundation/Generated/Support/AGGREGATION.swift b/Sources/WindowsFoundation/Generated/Support/AGGREGATION.swift new file mode 100644 index 0000000..0dbe2b6 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/AGGREGATION.swift @@ -0,0 +1,128 @@ +import CWinRT +import Foundation + +// The WinRTClassWeakReference class is a proxy for properly managing the reference count of +// the WinRTClass that is being aggregated. The aggregated object holds a weak reference to +// the outer IInspectable (swift) that is passed in during construction. In general, the +// swift wrappers we create hold strong references to the objects they are wrapping, as we +// expect an AddRef from WinRT to keep the object alive. Since this doesn't happen for aggregated +// objects, we need a proxy which sits in the middle. The WinRTClassWeakReference object doesn't +// keep a strong ref to the swift object, but it forwards all AddRef/Release calls from WinRT +// to the swift object, to ensure it doesn't get cleaned up. The Swift object in turn holds a strong +// reference to this object so that it stays alive. +@_spi(WinRTInternal) +public final class WinRTClassWeakReference { + fileprivate weak var instance: Class? + public init(_ instance: Class){ + self.instance = instance + } +} + +extension WinRTClassWeakReference: CustomQueryInterface { + @_spi(WinRTImplements) + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + guard let instance else { return nil } + return instance.queryInterface(iid) + } +} + +extension WinRTClassWeakReference: CustomAddRef { + func addRef() { + guard let instance else { return } + let unmanaged = Unmanaged.passUnretained(instance) + _ = unmanaged.retain() + } + + func release() { + guard let instance else { return } + let unmanaged = Unmanaged.passUnretained(instance) + unmanaged.release() + } +} + +extension WinRTClassWeakReference: AnyObjectWrapper { + var obj: AnyObject? { instance } +} + +@_spi(WinRTInternal) +public protocol ComposableImpl : AbiInterfaceBridge where SwiftABI: IInspectable, SwiftProjection: WinRTClassWeakReference { + associatedtype Class: WinRTClass + associatedtype Default : AbiInterface where Default.SwiftABI: WindowsFoundation.IInspectable + static func makeAbi() -> CABI +} + +// At a high level, aggregation simply requires the WinRT object to have a pointer back to the Swift world, so that it can call +// overridable methods on the class. This Swift pointer is given to the WinRT object during construction. The construction of the +// WinRT object returns us two different pointers: + +// 1. A non-delegating "inner" pointer. A non-delegating pointer means that any QueryInterface calls won't "delegate" back into the Swift world +// 2. A pointer to the default interface. + +// Below is a table which shows what the input parameters to CreateInstance is, and what we should do with the +// output parameters in order to properly aggregate a type. For reference, a constructor for a winrt object (without any parameters) +// looks like this: + +// CreateInstance(IInspectable* baseInsp, IInspectable** innerInsp, IInspectable** result) + +// | Aggregating? | baseInsp (Swift pointer) | innerInsp (C++ pointer) | result (C++) | +// |---------------|---------------------------|-------------------------|--------------------------| +// | Yes | self | stored on swift object | ignored or stored | +// | No | nil | ignored | stored on swift object | +@_spi(WinRTInternal) +public func MakeComposed( + composing: Composable.Type, + _ this: Composable.Class, + _ createCallback: (UnsealedWinRTClassWrapper?, inout WindowsFoundation.IInspectable?) -> Composable.Default.SwiftABI) { + let aggregated = type(of: this) != Composable.Class.self + let wrapper:UnsealedWinRTClassWrapper? = .init(aggregated ? this : nil) + + var innerInsp: WindowsFoundation.IInspectable? = nil + let base = createCallback(wrapper, &innerInsp) + guard let innerInsp else { + fatalError("Unexpected nil returned after successful creation") + } + + if let wrapper { + this.identity = ComPtr(wrapper.toIInspectableABI { $0 }) + // Storing a strong ref to the wrapper adds a ref to ourselves, remove the + // reference + wrapper.swiftObj.release() + } + this._inner = aggregated ? innerInsp : base +} + +@_spi(WinRTInternal) +public class UnsealedWinRTClassWrapper : WinRTAbiBridgeWrapper { + override public class var IID: WindowsFoundation.IID { Composable.SwiftABI.IID } + public init?(_ impl: Composable.Class?) { + guard let impl = impl else { return nil } + let abi = Composable.makeAbi() + super.init(abi, Composable.SwiftProjection(impl)) + } + + public static func unwrapFrom(base: ComPtr) -> Composable.Class? { + let overrides: Composable.SwiftABI = try! base.queryInterface() + if let weakRef = tryUnwrapFrom(abi: RawPointer(overrides)) { return weakRef.instance } + guard let instance = makeFrom(abi: overrides) else { + // the derived class doesn't exist, which is fine, just return the type the API specifies. + return make(type: Composable.Class.self, from: overrides) + } + return instance as? Composable.Class + } + + public static func tryUnwrapFrom(raw pUnk: UnsafeMutableRawPointer?) -> Composable.Class? { + tryUnwrapFromBase(raw: pUnk)?.instance + } + + public func toIInspectableABI(_ body: (UnsafeMutablePointer) throws -> ResultType) + rethrows -> ResultType { + let abi = try! toABI { $0 } + return try abi.withMemoryRebound(to: C_IInspectable.self, capacity: 1) { try body($0) } + } +} + +public extension ComposableImpl { + static func from(abi: ComPtr?) -> SwiftProjection? { + return nil + } +} diff --git a/Sources/WindowsFoundation/Generated/Support/ARRAY+TOVECTOR.swift b/Sources/WindowsFoundation/Generated/Support/ARRAY+TOVECTOR.swift new file mode 100644 index 0000000..f958bac --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/ARRAY+TOVECTOR.swift @@ -0,0 +1,81 @@ +// Swift Array to IVector Adaptor +import WinSDK + +extension Array { + public func toVector() -> AnyIVector { + ArrayVector(self) + } +} + +internal class ArrayVector : IVector { + typealias Element = T + private var storage: Array + internal init(_ storage: Array){ + self.storage = storage + } + + // MARK: WinRT APIs + func getAt(_ index: UInt32) -> T { storage[Int(index)] } + var size : UInt32 { UInt32(storage.count) } + func indexOf(_ item: T, _ index: inout UInt32) -> Bool { return false } + func append(_ item: T) { storage.append(item ) } + func setAt(_ index: UInt32, _ item: T) { storage[Int(index)] = item } + func insertAt(_ index: UInt32, _ item: T) { storage.insert(item, at: Int(index)) } + func removeAt(_ index: UInt32) { storage.remove(at: Int(index) )} + func removeAtEnd() { storage.removeLast() } + func clear() { storage.removeAll() } + func getView() -> AnyIVectorView? { return ArrayVectorView(storage) } + + func first() -> AnyIIterator? { ArrayIterator(storage) } +} + +extension ArrayVector where T: Equatable { + func indexOf(_ item: T, _ index: inout UInt32) throws -> Bool { + guard let foundIndex = storage.firstIndex(of: item) else { return false } + index = UInt32(foundIndex) + return true + } +} + +extension ArrayVector { + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { nil } +} + +internal class ArrayVectorView : IVectorView { + typealias Element = T + private var storage: Array + internal init(_ storage: Array){ + self.storage = storage + } + func getAt(_ index: UInt32) -> T { storage[Int(index)] } + var size : UInt32 { UInt32(storage.count) } + func indexOf(_ item: T, _ index: inout UInt32) -> Bool { return false } + + func first() -> AnyIIterator? { ArrayIterator(storage) } +} + +extension ArrayVectorView where T: Equatable { + func indexOf(_ item: T, _ index: inout UInt32) throws -> Bool { + guard let foundIndex = storage.firstIndex(of: item) else { return false } + index = UInt32(foundIndex) + return true + } +} + +extension ArrayVectorView { + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { nil } +} + +class ArrayIterator: IIterator { + typealias Element = T + private let storage: Array + private var index: Int = 0 + init(_ storage: Array){ + self.storage = storage + } + func moveNext() -> Bool { index += 1; return index < storage.count } + var current: T { storage[index] } + var hasCurrent: Bool { index < storage.count } + + func queryInterface(_ iid: IID) -> IUnknownRef? { nil } +} diff --git a/Sources/WindowsFoundation/Generated/Support/COM+EXTENSIONS.swift b/Sources/WindowsFoundation/Generated/Support/COM+EXTENSIONS.swift new file mode 100644 index 0000000..44bac5b --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/COM+EXTENSIONS.swift @@ -0,0 +1,36 @@ +// Copyright © 2021 Saleem Abdulrasool +// SPDX-License-Identifier: BSD-3 + +import WinSDK +import CWinRT + +public func ==(_ lhs: (T, T, T, T, T, T, T, T), + _ rhs: (T, T, T, T, T, T, T, T)) -> Bool { + return lhs.0 == rhs.0 && + lhs.1 == rhs.1 && + lhs.2 == rhs.2 && + lhs.3 == rhs.3 && + lhs.4 == rhs.4 && + lhs.5 == rhs.5 && + lhs.6 == rhs.6 && + lhs.7 == rhs.7 +} + +extension IInspectable : Equatable { + // Test for COM-style equality. + public static func ==(_ lhs: IInspectable, _ rhs: IInspectable) -> Bool { + let lhsUnknown: IUnknown = try! lhs.QueryInterface() + let rhsUnknown: IUnknown = try! rhs.QueryInterface() + let equals = (lhsUnknown.pUnk.borrow == rhsUnknown.pUnk.borrow) + + return equals + } +} + +private var IID_IAgileObject: WindowsFoundation.IID { + .init(Data1: 0x94ea2b94, Data2: 0xe9cc, Data3: 0x49e0, Data4: ( 0xc0, 0xff, 0xee, 0x64, 0xca, 0x8f, 0x5b, 0x90 )) // 94ea2b94-e9cc-49e0-c0ff-ee64ca8f5b90 +} + +public final class IAgileObject : IUnknown { + override public class var IID: WindowsFoundation.IID { IID_IAgileObject } +} diff --git a/Sources/WindowsFoundation/Generated/Support/COMPTR.swift b/Sources/WindowsFoundation/Generated/Support/COMPTR.swift new file mode 100644 index 0000000..37f6bcb --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/COMPTR.swift @@ -0,0 +1,126 @@ +// Copyright © 2023 The Browser Company +// SPDX-License-Identifier: BSD-3 +import CWinRT + +// ComPtr is a smart pointer for COM interfaces. It holds on to the underlying pointer + +// and the semantics of it are meant to mirror that of the ComPtr class in WRL. The +// design of ComPtr and ComPtrs.intialize is that there should be no use of UnsafeMutablePointer +// anywhere else in the code base. The only place where UnsafeMutablePointer should be used is + +// where it's required at the ABI boundary. +public class ComPtr { + fileprivate var pUnk: UnsafeMutablePointer? + + public init(_ ptr: UnsafeMutablePointer) { + self.pUnk = ptr + asIUnknown { + _ = $0.pointee.lpVtbl.pointee.AddRef($0) + } + } + + public convenience init?(_ ptr: UnsafeMutablePointer?) { + guard let ptr else { return nil } + self.init(ptr) + } + + fileprivate init?(takingOwnership ptr: UnsafeMutablePointer?) { + guard let ptr else { return nil } + self.pUnk = ptr + } + + // Release ownership of the underlying pointer and return it. This is + // useful when assigning to an out parameter and avoids an extra Add/Ref + // release call. + public func detach() -> UnsafeMutableRawPointer? { + let result = pUnk + pUnk = nil + return UnsafeMutableRawPointer(result) + } + + public func get() -> UnsafeMutablePointer { + guard let pUnk else { preconditionFailure("get() called on nil pointer") } + return pUnk + } + + deinit { + release() + } + + private func release() { + guard pUnk != nil else { return } + asIUnknown { + _ = $0.pointee.lpVtbl.pointee.Release($0) + } + } + + func asIUnknown(_ body: (UnsafeMutablePointer) throws -> ResultType) rethrows -> ResultType { + guard let pUnk else { preconditionFailure("asIUnknown called on nil pointer") } + return try pUnk.withMemoryRebound(to: C_IUnknown.self, capacity: 1) { try body($0) } + } +} + +public extension ComPtr { + func queryInterface() throws -> Interface { + let ptr = try self.asIUnknown { pUnk in + var iid = Interface.IID + return try ComPtrs.initialize(to: C_IUnknown.self) { result in + try CHECKED(pUnk.pointee.lpVtbl.pointee.QueryInterface(pUnk, &iid, &result)) + } + } + return .init(ptr!) + } +} + +// ComPtrs properly initializes pointers who have ownership of the underlying raw pointers. This is used at the ABI boundary layer, for example: +// let (return1, return2) = try ComPtrs.initialize { return1Abi, return2Abi in +// try CHECKED(pThis.pointee.lpVtbl.pointee.Method(pThis, &return1Abi, &return2Abi)) +// } +public struct ComPtrs { + // Note: The single initialization methods still return a tuple for ease of code generation + public static func initialize(to: I.Type, _ body: (inout UnsafeMutableRawPointer?) throws -> ()) rethrows -> (ComPtr?) { + var ptrRaw: UnsafeMutableRawPointer? + try body(&ptrRaw) + return (ComPtr(takingOwnership: ptrRaw?.assumingMemoryBound(to: I.self))) + } + + public static func initialize(_ body: (inout UnsafeMutablePointer?) throws -> ()) rethrows -> (ComPtr?) { + var ptr: UnsafeMutablePointer? + try body(&ptr) + return (ComPtr(takingOwnership: ptr)) + } + + public static func initialize(_ body: (inout UnsafeMutablePointer?, inout UnsafeMutablePointer?) throws -> ()) rethrows -> (ComPtr?, ComPtr?) { + var ptr1: UnsafeMutablePointer? + var ptr2: UnsafeMutablePointer? + try body(&ptr1, &ptr2) + return (ComPtr(takingOwnership: ptr1), ComPtr(takingOwnership: ptr2)) + } + + public static func initialize(_ body: (inout UnsafeMutablePointer?, inout UnsafeMutablePointer?, inout UnsafeMutablePointer?) throws -> ()) rethrows -> (ComPtr?, ComPtr?, ComPtr?) { + var ptr1: UnsafeMutablePointer? + var ptr2: UnsafeMutablePointer? + var ptr3: UnsafeMutablePointer? + try body(&ptr1, &ptr2, &ptr3) + return (ComPtr(takingOwnership: ptr1), ComPtr(takingOwnership: ptr2), ComPtr(takingOwnership: ptr3)) + } + + public static func initialize(_ body: (inout UnsafeMutablePointer?, inout UnsafeMutablePointer?, inout UnsafeMutablePointer?, inout UnsafeMutablePointer?) throws -> ()) rethrows -> (ComPtr?, ComPtr?, ComPtr?, ComPtr?) { + var ptr1: UnsafeMutablePointer? + var ptr2: UnsafeMutablePointer? + var ptr3: UnsafeMutablePointer? + var ptr4: UnsafeMutablePointer? + try body(&ptr1, &ptr2, &ptr3, &ptr4) + return (ComPtr(takingOwnership: ptr1), ComPtr(takingOwnership: ptr2), ComPtr(takingOwnership: ptr3), ComPtr(takingOwnership: ptr4)) + } + + public static func initialize(_ body: (inout UnsafeMutablePointer?, inout UnsafeMutablePointer?, inout UnsafeMutablePointer?, inout UnsafeMutablePointer?, inout UnsafeMutablePointer?) throws -> ()) rethrows -> (ComPtr?, ComPtr?, ComPtr?, ComPtr?, ComPtr?) { + var ptr1: UnsafeMutablePointer? + var ptr2: UnsafeMutablePointer? + var ptr3: UnsafeMutablePointer? + var ptr4: UnsafeMutablePointer? + var ptr5: UnsafeMutablePointer? + try body(&ptr1, &ptr2, &ptr3, &ptr4, &ptr5) + return (ComPtr(takingOwnership: ptr1), ComPtr(takingOwnership: ptr2), ComPtr(takingOwnership: ptr3), ComPtr(takingOwnership: ptr4), ComPtr(takingOwnership: ptr5)) + } +} diff --git a/Sources/WindowsFoundation/Generated/Support/CPPINTEROPWORKAROUND.swift b/Sources/WindowsFoundation/Generated/Support/CPPINTEROPWORKAROUND.swift new file mode 100644 index 0000000..cc95e89 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/CPPINTEROPWORKAROUND.swift @@ -0,0 +1,35 @@ +import CWinRT + +#if true // TODO(WIN-860): Remove workaround once C++ interop issues with WinSDK.GUID are fixed. +public typealias GUID = CWinRT.GUID_Workaround +public typealias IID = CWinRT.IID_Workaround +public typealias CLSID = CWinRT.CLSID_Workaround +public typealias REFIID = UnsafePointer +public typealias C_IUnknown = CWinRT.IUnknown_Workaround +public typealias C_IInspectable = CWinRT.IInspectable_Workaround +public typealias C_IInspectableVtbl = CWinRT.IInspectableVtbl_Workaround +public typealias C_IMarshal = CWinRT.IMarshal_Workaround +public typealias C_IMarshalVtbl = CWinRT.IMarshalVtbl_Workaround +internal let CoCreateInstance = CWinRT.CoCreateInstance_Workaround +internal let UuidFromStringA = CWinRT.UuidFromStringA_Workaround +internal let RoActivateInstance = CWinRT.RoActivateInstance_Workaround +internal let RoGetActivationFactory = CWinRT.RoGetActivationFactory_Workaround +internal let StringFromGUID2 = CWinRT.StringFromGUID2_Workaround +internal let CoCreateFreeThreadedMarshaler = CWinRT.CoCreateFreeThreadedMarshaler_Workaround +#else +public typealias GUID = CWinRT.GUID +public typealias IID = CWinRT.IID +public typealias CLSID = CWinRT.CLSID +public typealias REFIID = UnsafePointer +public typealias C_IUnknown = CWinRT.IUnknown +public typealias C_IInspectable = CWinRT.IInspectable +public typealias C_IInspectableVtbl = CWinRT.IInspectableVtbl +public typealias C_IMarshal = CWinRT.IMarshal +public typealias C_IMarshalVtbl = CWinRT.IMarshalVtbl +internal let CoCreateInstance = CWinRT.CoCreateInstance +internal let UuidFromStringA = CWinRT.UuidFromStringA +internal let RoActivateInstance = CWinRT.RoActivateInstance +internal let RoGetActivationFactory = CWinRT.RoGetActivationFactory +internal let StringFromGUID2 = CWinRT.StringFromGUID2 +internal let CoCreateFreeThreadedMarshaler = CWinRT.CoCreateFreeThreadedMarshaler +#endif diff --git a/Sources/WindowsFoundation/Generated/Support/CUSTOMQUERYINTERFACE.swift b/Sources/WindowsFoundation/Generated/Support/CUSTOMQUERYINTERFACE.swift new file mode 100644 index 0000000..a5017a0 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/CUSTOMQUERYINTERFACE.swift @@ -0,0 +1,23 @@ +import CWinRT +import WinSDK + +public protocol CustomQueryInterface { + @_spi(WinRTImplements) + func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? +} + +extension IUnknownRef { + func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + var iid = iid + let (ptr) = try? ComPtrs.initialize(to: C_IUnknown.self) { result in + try CHECKED(borrow.pointee.lpVtbl.pointee.QueryInterface(borrow, &iid, &result)) + } + guard let ptr else { return nil} + return IUnknownRef(ptr) + } +} + +@_spi(WinRTInternal) +public func queryInterface(_ obj: WinRTClass, _ iid: WindowsFoundation.IID) -> IUnknownRef? { + obj._inner.pUnk.queryInterface(iid) +} diff --git a/Sources/WindowsFoundation/Generated/Support/DEBUGGING.swift b/Sources/WindowsFoundation/Generated/Support/DEBUGGING.swift new file mode 100644 index 0000000..096580f --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/DEBUGGING.swift @@ -0,0 +1,67 @@ +import WinSDK +import Foundation + +// Use with debugPrint, dump, etc. to simultaneously output to the debugger and +// console window. +// +// debugPrint("Useful stuff: \(var)", to: &debugOut) +// dump(self, to: &debugOut, name: "myObjectName", indent: 2, maxDepth: 4) +public var debugOut = DebugOutputStream() + +public class DebugOutputStream : TextOutputStream { + public func write(_ text: String) { + let sanitizedText = text.replacingOccurrences(of: "▿", with: "+") + print(sanitizedText, terminator: "") + OutputDebugStringA(sanitizedText) + } +} + +public func debugPrintAddress(_ description: String, _ object: AnyObject) { + debugPrint(description, terminator: "", to: &debugOut) + debugPrint(Unmanaged.passUnretained(object).toOpaque(), to: &debugOut) +} + +open class TrackableObject { + internal var uniqueId: UInt = 0 + + public init() { + TrackedObjects.add(self) + } + + deinit { + TrackedObjects.remove(self) + } +} + +internal class TrackedObject { + private var object: TrackableObject + internal var uniqueId: UInt + private static var idGenerator: UInt = 6000 + + public init(_ object: TrackableObject) { + self.object = object + self.uniqueId = TrackedObject.idGenerator + object.uniqueId = self.uniqueId + TrackedObject.idGenerator += 1 + } +} + +public class TrackedObjects { + private static var objects: Array = Array() + + public static func add(_ object: TrackableObject) { + objects.append(TrackedObject(object)) + } + + public static func remove(_ object: TrackableObject) { + objects.removeAll(where: { $0.uniqueId == object.uniqueId }) + } + + public static func dumpAll() { + objects.forEach { object in + print("\r\n------------------------------------------------------------------\r\n") + OutputDebugStringA("\r\n------------------------------------------------------------------\r\n") + dump(object, to: &debugOut, name: String(describing: object), indent: 2, maxDepth: 10) + } + } +} diff --git a/Sources/WindowsFoundation/Generated/Support/DICTIONARY+TOMAP.swift b/Sources/WindowsFoundation/Generated/Support/DICTIONARY+TOMAP.swift new file mode 100644 index 0000000..ad2a16f --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/DICTIONARY+TOMAP.swift @@ -0,0 +1,58 @@ +import WinSDK + +// Swift Dictionary to IMap Adaptor +extension Dictionary { + public func toMap() -> AnyIMap { + DictionaryMap(self) + } +} + +internal class DictionaryMap : IMap where K : Hashable { + typealias T = AnyIKeyValuePair? + private var storage: Dictionary + internal init(_ storage: Dictionary){ + self.storage = storage + } + + var size : UInt32 { UInt32(storage.count) } + func hasKey(_ K: K) -> Bool { storage[K] != nil } + func lookup(_ K: K) -> V { storage[K]! } + func getView() -> AnyIMapView? { DictionaryMapView(storage) } + + @discardableResult func insert(_ K: K, _ V: V) -> Bool { + // WinRT returns true if replacing + storage.updateValue(V, forKey: K) != nil + } + func remove(_ K: K) { storage.removeValue(forKey: K) } + func clear() { storage.removeAll(keepingCapacity: true) } + + func first() -> AnyIIterator? { fatalError("Not implemented: ArrayVector.First") } +} + +extension DictionaryMap { + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { nil } +} + +internal class DictionaryMapView : IMapView where K : Hashable { + typealias T = AnyIKeyValuePair? + + private var storage: Dictionary + internal init(_ storage: Dictionary){ + self.storage = storage + } + + var size : UInt32 { UInt32(storage.count) } + func hasKey(_ key: K) -> Bool { storage[key] != nil } + func lookup(_ key: K) -> V { storage[key]! } + func split( + _ first: inout AnyIMapView?, + _ second: inout AnyIMapView?) { + fatalError("Not implemented: DictionaryMapView.Split") + } + + func first() -> AnyIIterator? { fatalError("Not implemented: ArrayVector.First") } +} + +extension DictionaryMapView { + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { nil } +} \ No newline at end of file diff --git a/Sources/WindowsFoundation/Generated/Support/ERROR.swift b/Sources/WindowsFoundation/Generated/Support/ERROR.swift new file mode 100644 index 0000000..af3714b --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/ERROR.swift @@ -0,0 +1,174 @@ +// Copyright © 2021 Saleem Abdulrasool +// SPDX-License-Identifier: BSD-3 + +import WinSDK +import CWinRT + +// winerror.h + +@_transparent +public var E_FAIL: WinSDK.HRESULT { + HRESULT(bitPattern: 0x80004005) +} + +@_transparent +public var E_INVALIDARG: WinSDK.HRESULT { + HRESULT(bitPattern: 0x80070057) +} + +@_transparent +public var E_NOTIMPL: WinSDK.HRESULT { + HRESULT(bitPattern: 0x80004001) +} + +@_transparent +public var E_NOINTERFACE: WinSDK.HRESULT { + HRESULT(bitPattern: 0x80004002) +} + +@_transparent +public var E_ACCESSDENIED: WinSDK.HRESULT { + HRESULT(bitPattern: 0x80070005) +} + +@_transparent +public var RPC_E_WRONG_THREAD: WinSDK.HRESULT { + HRESULT(bitPattern: 0x8001010E) +} + +@_transparent +public var E_BOUNDS: WinSDK.HRESULT { + HRESULT(bitPattern: 0x8000000B) +} + +@_transparent +public var CLASS_E_CLASSNOTAVAILABLE: WinSDK.HRESULT { + HRESULT(bitPattern: 0x80040111) +} + +@_transparent +public var REGDB_E_CLASSNOTREG: WinSDK.HRESULT { + HRESULT(bitPattern: 0x80040154) +} + +@_transparent +public var E_CHANGED_STATE: WinSDK.HRESULT { + HRESULT(bitPattern: 0x8000000C) +} + +@_transparent +public var E_ILLEGAL_METHOD_CALL: WinSDK.HRESULT { + HRESULT(bitPattern: 0x8000000E) +} + +@_transparent +public var E_ILLEGAL_STATE_CHANGE: WinSDK.HRESULT { + HRESULT(bitPattern: 0x8000000D) +} + +@_transparent +public var E_ILLEGAL_DELEGATE_ASSIGNMENT: WinSDK.HRESULT { + HRESULT(bitPattern: 0x80000018) +} + +@_transparent +public var ERROR_CANCELLED: WinSDK.HRESULT { + HRESULT(bitPattern: 0x800704C7) +} + +@_transparent +public var E_OUTOFMEMORY: WinSDK.HRESULT { + HRESULT(bitPattern: 0x8007000E) +} + +@_transparent +public var CO_E_NOTINITIALIZED: WinSDK.HRESULT { + HRESULT(bitPattern: 0x800401F0) +} + +@_transparent +public var ERROR_FILE_NOT_FOUND: WinSDK.HRESULT { + HRESULT(bitPattern: 0x80070002) +} + +@_transparent +public var E_LAYOUTCYCLE: WinSDK.HRESULT { + HRESULT(bitPattern: 0x802B0014) +} + +@_transparent +public var E_XAMLPARSEFAILED : WinSDK.HRESULT { + HRESULT(bitPattern: 0x802B000A) +} + +private func getErrorDescription(expecting hr: HRESULT) -> String? { + var errorInfo: UnsafeMutablePointer? + guard GetRestrictedErrorInfo(&errorInfo) == S_OK else { return nil } + defer { + _ = errorInfo?.pointee.lpVtbl.pointee.Release(errorInfo) + } + + var errorDescription: BSTR? + var restrictedDescription: BSTR? + var capabilitySid: BSTR? + defer { + SysFreeString(errorDescription) + SysFreeString(restrictedDescription) + SysFreeString(capabilitySid) + } + var resultLocal: HRESULT = S_OK + _ = errorInfo?.pointee.lpVtbl.pointee.GetErrorDetails( + errorInfo, + &errorDescription, + &resultLocal, + &restrictedDescription, + &capabilitySid) + + guard resultLocal == hr else { return nil } + + // Favor restrictedDescription as this is a more user friendly message, which + // is intended to be displayed to the caller to help them understand why the + // api call failed. If it's not set, then fallback to the generic error message + // for the result + if SysStringLen(restrictedDescription) > 0 { + return String(decodingCString: restrictedDescription!, as: UTF16.self) + } else if SysStringLen(errorDescription) > 0 { + return String(decodingCString: errorDescription!, as: UTF16.self) + } else { + return nil + } +} + +private func hrToString(_ hr: HRESULT) -> String { + let dwFlags: DWORD = DWORD(FORMAT_MESSAGE_ALLOCATE_BUFFER) + | DWORD(FORMAT_MESSAGE_FROM_SYSTEM) + | DWORD(FORMAT_MESSAGE_IGNORE_INSERTS) + + var buffer: UnsafeMutablePointer? = nil + let dwResult: DWORD = withUnsafeMutablePointer(to: &buffer) { + $0.withMemoryRebound(to: WCHAR.self, capacity: 2) { + FormatMessageW(dwFlags, nil, DWORD(bitPattern: hr), + MAKELANGID(WORD(LANG_NEUTRAL), WORD(SUBLANG_DEFAULT)), + $0, 0, nil) + } + } + guard dwResult > 0, let message = buffer else { + return "HRESULT(0x\(String(DWORD(bitPattern: hr), radix: 16)))" + } + defer { LocalFree(buffer) } + return "0x\(String(DWORD(bitPattern: hr), radix: 16)) - \(String(decodingCString: message, as: UTF16.self))" +} + +public struct Error : Swift.Error, CustomStringConvertible { + public let description: String + public let hr: HRESULT + + public init(hr: HRESULT) { + self.description = getErrorDescription(expecting: hr) ?? hrToString(hr) + self.hr = hr + } +} + +public func failWith(err: HRESULT) -> HRESULT { + return err +} diff --git a/Sources/WindowsFoundation/Generated/Support/ERRORHANDLING.swift b/Sources/WindowsFoundation/Generated/Support/ERRORHANDLING.swift new file mode 100644 index 0000000..12515a4 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/ERRORHANDLING.swift @@ -0,0 +1,15 @@ +// Copyright © 2021 Saleem Abdulrasool +// SPDX-License-Identifier: BSD-3 + +import WinSDK + +@_alwaysEmitIntoClient @inline(__always) +public func CHECKED(_ body: () -> HRESULT) throws { + let hr: HRESULT = body() + guard hr >= 0 else { throw Error(hr: hr) } +} + +@_alwaysEmitIntoClient @inline(__always) +public func CHECKED(_ body: @autoclosure () -> HRESULT) throws { + try CHECKED(body) +} diff --git a/Sources/WindowsFoundation/Generated/Support/EVENT.swift b/Sources/WindowsFoundation/Generated/Support/EVENT.swift new file mode 100644 index 0000000..ffd1620 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/EVENT.swift @@ -0,0 +1,44 @@ +import WinSDK +import CWinRT + +public protocol Disposable { + func dispose() +} + +public struct Event { + fileprivate var add: (Handler) -> EventRegistrationToken + fileprivate var remove: (_ token: EventRegistrationToken) -> Void + + public init(add: @escaping (Handler) -> EventRegistrationToken, remove: @escaping (_ token: EventRegistrationToken) -> Void) { + self.add = add + self.remove = remove + } + + @discardableResult public func addHandler(_ handler: Handler) -> EventCleanup { + let token = add(handler) + return EventCleanup(token: token, closeAction: remove) + } + + public func removeHandler(_ token: EventRegistrationToken) { + remove(token) + } +} + +public struct EventCleanup: Disposable { + fileprivate let token: EventRegistrationToken + let closeAction: (_ token: EventRegistrationToken) -> Void + public init(token: EventRegistrationToken, closeAction: @escaping (_ token: EventRegistrationToken) -> Void) { + self.token = token + self.closeAction = closeAction + } + + public func dispose() { + closeAction(token) + } +} + +extension CWinRT.EventRegistrationToken { + public static func from(swift: EventCleanup) -> CWinRT.EventRegistrationToken { + return swift.token + } +} diff --git a/Sources/WindowsFoundation/Generated/Support/EVENTHANDLERSUBSCRIPTION.swift b/Sources/WindowsFoundation/Generated/Support/EVENTHANDLERSUBSCRIPTION.swift new file mode 100644 index 0000000..98a54de --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/EVENTHANDLERSUBSCRIPTION.swift @@ -0,0 +1,39 @@ +import Foundation +import WinSDK +import CWinRT + +struct EventHandlerSubscription { + var handler: Handler + var token: CWinRT.EventRegistrationToken +} + +struct EventHandlerSubscriptions { + typealias Subscription = EventHandlerSubscription + private var buffer = [Subscription]() + let lock = NSLock() + init(){} + mutating func append(_ handler: Handler) -> CWinRT.EventRegistrationToken { + let token = CWinRT.EventRegistrationToken(value: Int64(Int(bitPattern: Unmanaged.passUnretained(handler as AnyObject).toOpaque()))) + lock.lock() + buffer.append(.init(handler: handler, token: token)) + lock.unlock() + return token + } + + mutating func remove(token: CWinRT.EventRegistrationToken) { + lock.lock() + // The semantics when the same event handler is added multiple times + // is to append to the end and to remove the last occurrence first. + if let index = buffer.lastIndex(where: { $0.token == token }) { + buffer.remove(at: index) + } + lock.unlock() + } + + func getInvocationList() -> [Handler] { + lock.lock() + let result = buffer.map { $0.handler } + lock.unlock() + return result + } +} diff --git a/Sources/WindowsFoundation/Generated/Support/EVENTSOURCE.swift b/Sources/WindowsFoundation/Generated/Support/EVENTSOURCE.swift new file mode 100644 index 0000000..4b43039 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/EVENTSOURCE.swift @@ -0,0 +1,33 @@ +import Foundation +import WinSDK +import CWinRT + +/// EventSource is the class which implements handling event subscriptions, removals, +/// and invoking events for authoring events in Swift +@propertyWrapper public class EventSource { + private var event: Event! + private var handlers = EventHandlerSubscriptions() + + public init() { + event = .init( + add: { self.handlers.append($0) }, + remove: { self.handlers.remove(token: $0) } + ) + } + + public var wrappedValue: Event { event } + + public func getInvocationList() -> [Handler] { + handlers.getInvocationList() + } +} + +extension CWinRT.EventRegistrationToken: @retroactive Hashable { + public static func == (lhs: CWinRT.EventRegistrationToken, rhs: CWinRT.EventRegistrationToken) -> Bool { + return lhs.value == rhs.value + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(value) + } +} diff --git a/Sources/WindowsFoundation/Generated/Support/GUID.swift b/Sources/WindowsFoundation/Generated/Support/GUID.swift new file mode 100644 index 0000000..cb7c421 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/GUID.swift @@ -0,0 +1,84 @@ +import Foundation +import CWinRT + +extension GUID: @retroactive CustomStringConvertible { + public var description: String { + withUnsafePointer(to: self) { pGUID in + Array(unsafeUninitializedCapacity: 40) { + $1 = Int(StringFromGUID2(pGUID, $0.baseAddress, CInt($0.count))) + }.withUnsafeBufferPointer { + String(decodingCString: $0.baseAddress!, as: UTF16.self) + } + } + } +} + +extension GUID { + /// Create a GUID from a string such as "E621E1F8-C36C-495A-93FC-0C247A3E6E5F" + /// + /// returns nil for invalid strings + public init?(parsingString string: String){ + var _self : GUID = .init() + + // use UuidFromString because it expects the correct format. + // See https://devblogs.microsoft.com/oldnewthing/20151015-00/?p=91351 + var bytes = string.utf8.map { UInt8($0) } + [0] + guard bytes.withUnsafeMutableBufferPointer({ UuidFromStringA($0.baseAddress, &_self) }) == S_OK else { return nil } + self = _self + } +} + +extension GUID: @retroactive Equatable { + public static func ==(_ lhs: GUID, _ rhs: GUID) -> Bool { + return lhs.Data1 == rhs.Data1 && + lhs.Data2 == rhs.Data2 && + lhs.Data3 == rhs.Data3 && + lhs.Data4 == rhs.Data4 + } +} + +public func ~=(_ lhs: GUID, _ rhs: GUID) -> Bool { lhs == rhs} + +public extension Foundation.UUID { + init(from guid: GUID) { + let uuid: uuid_t = ( + UInt8((guid.Data1 >> 24) & 0xff), + UInt8((guid.Data1 >> 16) & 0xff), + UInt8((guid.Data1 >> 8) & 0xff), + UInt8(guid.Data1 & 0xff), + UInt8((guid.Data2 >> 8) & 0xff), + UInt8(guid.Data2 & 0xff), + UInt8((guid.Data3 >> 8) & 0xff), + UInt8(guid.Data3 & 0xff), + guid.Data4.0, + guid.Data4.1, + guid.Data4.2, + guid.Data4.3, + guid.Data4.4, + guid.Data4.5, + guid.Data4.6, + guid.Data4.7 + ) + self.init(uuid: uuid) + } +} + +public extension GUID { + init(from uuid: Foundation.UUID) { + self.init( + Data1: UInt32((UInt32(uuid.uuid.0) << 24) | (UInt32(uuid.uuid.1) << 16) | (UInt32(uuid.uuid.2) << 8) | UInt32(uuid.uuid.3)), + Data2: UInt16((UInt16(uuid.uuid.4) << 8) | UInt16(uuid.uuid.5)), + Data3: UInt16((UInt16(uuid.uuid.6) << 8) | UInt16(uuid.uuid.7)), + Data4: ( + uuid.uuid.8, + uuid.uuid.9, + uuid.uuid.10, + uuid.uuid.11, + uuid.uuid.12, + uuid.uuid.13, + uuid.uuid.14, + uuid.uuid.15 + ) + ) + } +} \ No newline at end of file diff --git a/Sources/WindowsFoundation/Generated/Support/HSTRING.swift b/Sources/WindowsFoundation/Generated/Support/HSTRING.swift new file mode 100644 index 0000000..529303f --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/HSTRING.swift @@ -0,0 +1,47 @@ +// Copyright © 2021 Saleem Abdulrasool +// SPDX-License-Identifier: BSD-3 + +import CWinRT +import Foundation +import ucrt + +@_fixed_layout +final public class HString { + internal private(set) var hString: HSTRING? + + public init(_ string: String) throws { + self.hString = try string.withCString(encodedAs: UTF16.self) { + var result: HSTRING? + try CHECKED(WindowsCreateString($0, UINT32(wcslen($0)), &result)) + return result + } + } + + public init(_ hString: HSTRING?) throws { + try CHECKED(WindowsDuplicateString(hString, &self.hString)) + } + + public init(consuming hString: HSTRING?) { + self.hString = hString + } + + public init() { } + public init(_ buffer: UnsafeBufferPointer?) throws { + try CHECKED(WindowsCreateString(buffer?.baseAddress ?? nil, + UINT32(buffer?.count ?? 0), + &self.hString)) + } + + public func get() -> HSTRING? { hString } + + public func detach() -> HSTRING? { + let tempString = hString + hString = nil + return tempString + } + + deinit { + try! CHECKED(WindowsDeleteString(self.hString)) + } +} + diff --git a/Sources/WindowsFoundation/Generated/Support/IBUFFERBYTEACCESS.swift b/Sources/WindowsFoundation/Generated/Support/IBUFFERBYTEACCESS.swift new file mode 100644 index 0000000..3781c00 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/IBUFFERBYTEACCESS.swift @@ -0,0 +1,64 @@ +import CWinRT +import Foundation + +/// IBufferByteAccess provides direct access to the underlying bytes of an IBuffer. +/// This buffer is only valid for the lifetime of the IBuffer. For a read-only representation +/// of the buffer, access the bytes through the Data property of the IBuffer. +/// [Open Microsoft Documentation](https://learn.microsoft.com/en-us/windows/win32/api/robuffer/ns-robuffer-ibufferbyteaccess) +public protocol IBufferByteAccess: WinRTInterface { + var buffer: UnsafeMutablePointer? { get throws } +} + +public typealias AnyIBufferByteAccess = any IBufferByteAccess + +fileprivate let IID_IBufferByteAccess = IID(Data1: 0x905A0FEF, Data2: 0xBC53, Data3: 0x11DF, Data4: ( 0x8C, 0x49, 0x00, 0x1E, 0x4F, 0xC6, 0x86, 0xDA )) // 905a0fef-bc53-11df-8c49-001e4fc686da + +extension __ABI_ { + public class IBufferByteAccess: IUnknown { + override public class var IID: IID { IID_IBufferByteAccess} + + public func Buffer() throws -> UnsafeMutablePointer? { + var buffer: UnsafeMutablePointer? + try perform(as: CWinRT.C_IBufferByteAccess.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Buffer(pThis, &buffer)) + } + return buffer + } + } + + public typealias IBufferByteAccessWrapper = InterfaceWrapperBase +} + +public enum IBufferByteAccessBridge: AbiInterfaceBridge { + public static func makeAbi() -> CABI { + return CABI(lpVtbl: &IBufferByteAccessVTable) + } + + public static func from(abi: ComPtr?) -> SwiftProjection? { + // This code path is not actually reachable since IBufferByteAccess is not a WinRT interface. + // It is a COM interface which is implemented by any object which implements the IBuffer interface. + // And the IBufferImpl object will correctly have the implementation of this interface, so this isn't needed + assertionFailure("IBufferByteAccessBridge.from not implemented") + return nil + } + + public typealias CABI = CWinRT.C_IBufferByteAccess + public typealias SwiftABI = __ABI_.IBufferByteAccess + public typealias SwiftProjection = AnyIBufferByteAccess +} + +private var IBufferByteAccessVTable: CWinRT.C_IBufferByteAccessVtbl = .init( + QueryInterface: { __ABI_.IBufferByteAccessWrapper.queryInterface($0, $1, $2) }, + AddRef: { __ABI_.IBufferByteAccessWrapper.addRef($0) }, + Release: { __ABI_.IBufferByteAccessWrapper.release($0) }, + Buffer: { __ABI_.IBufferByteAccessWrapper.buffer($0, $1) } +) + +extension __ABI_.IBufferByteAccessWrapper { + fileprivate static func buffer(_ this: UnsafeMutablePointer?, _ buffer: UnsafeMutablePointer?>?) -> HRESULT { + guard let swiftObj = __ABI_.IBufferByteAccessWrapper.tryUnwrapFrom(raw: this) else { return E_INVALIDARG } + guard let buffer else { return E_INVALIDARG } + buffer.pointee = try? swiftObj.buffer + return S_OK + } +} \ No newline at end of file diff --git a/Sources/WindowsFoundation/Generated/Support/IINSPECTABLE+SWIFT.swift b/Sources/WindowsFoundation/Generated/Support/IINSPECTABLE+SWIFT.swift new file mode 100644 index 0000000..13e8612 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/IINSPECTABLE+SWIFT.swift @@ -0,0 +1,79 @@ +// Copyright © 2021 Saleem Abdulrasool +// SPDX-License-Identifier: BSD-3 + +import CWinRT + +// usually thrown when a call to IInspectable.GetRuntimeClassName +// returns a class name that we cannot resolve. This should +// never be exposed to developers. +struct InvalidRuntimeClassName: Swift.Error { + let className: String +} + +extension IInspectable { + public func GetIids() throws -> [WindowsFoundation.IID] { + var iids: UnsafeMutablePointer? + var iidCount: ULONG = 0 + + try self.GetIids(&iidCount, &iids) + defer { CoTaskMemFree(iids) } + + return Array(unsafeUninitializedCapacity: Int(iidCount)) { + _ = memcpy($0.baseAddress, iids, MemoryLayout.stride * Int(iidCount)) + $1 = Int(iidCount) + } + } + + public func GetRuntimeClassName() throws -> HString { + var className: CWinRT.HSTRING? + try self.GetRuntimeClassName(&className) + return HString(consuming: className) + } + + public func GetTrustLevel() throws -> TrustLevel { + var trustLevel: TrustLevel = .BaseTrust + try self.GetTrustLevel(&trustLevel) + return trustLevel + } +} + +struct SwiftTypeName { + let module: String + let typeName: String +} + +extension IInspectable { + // maps the namespace to a swift module. needs to be kept in sync with + // get_swift_module defined in common.h in the code generator + private func GetSwiftModule(from ns: String) -> String { + if ns.starts(with: "Windows.Foundation") { + return "WindowsFoundation" + } else if ns.starts(with: "Microsoft.UI.Xaml") || ns.starts(with: "Windows.UI.Xaml") { + return "WinUI" + } else if ns.starts(with: "Windows") { + return "UWP" + } else if ns.starts(with: "Microsoft.Web.WebView2.Core") { + return "WebView2Core" + } else if ns.starts(with: "Microsoft.Graphics.Canvas"){ + return "Win2D" + } else if ns.starts(with: "Microsoft") { + return "WinAppSDK" + } + var mod: String = ns + mod.removeAll(where: { $0 == "." }) + return mod + } + + + func GetSwiftTypeName() throws -> SwiftTypeName { + let className = try String(hString: GetRuntimeClassName()) + let lastNsIndex = className.lastIndex(of: ".") + guard let lastNsIndex = lastNsIndex else { + throw InvalidRuntimeClassName(className: className) + } + let ns = className.prefix(upTo: lastNsIndex) + let lastNsIndexPlus1 = className.index(after: lastNsIndex) + let typeName = className.suffix(from: lastNsIndexPlus1) + return SwiftTypeName(module: GetSwiftModule(from: String(ns)), typeName: String(typeName)) + } +} \ No newline at end of file diff --git a/Sources/WindowsFoundation/Generated/Support/IINSPECTABLE.swift b/Sources/WindowsFoundation/Generated/Support/IINSPECTABLE.swift new file mode 100644 index 0000000..9419096 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/IINSPECTABLE.swift @@ -0,0 +1,141 @@ +// Copyright © 2021 Saleem Abdulrasool +// SPDX-License-Identifier: BSD-3 + +import CWinRT +import Foundation + +fileprivate let IID_IInspectable = IID(Data1: 0xAF86E2E0, Data2: 0xB12D, Data3: 0x4C6A, Data4: ( 0x9C, 0x5A, 0xD7, 0xAA, 0x65, 0x10, 0x1E, 0x90 )) // AF86E2E0-B12D-4c6a-9C5A-D7AA65101E90 + +open class IInspectable: IUnknown { + override open class var IID: WindowsFoundation.IID { IID_IInspectable } + + public func GetIids(_ iidCount: UnsafeMutablePointer, _ iids: UnsafeMutablePointer?>?) throws { + return try perform(as: C_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetIids(pThis, iidCount, iids)) + } + } + + public func GetRuntimeClassName(_ className: UnsafeMutablePointer) throws { + return try perform(as: C_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetRuntimeClassName(pThis, className)) + } + } + + public func GetTrustLevel(_ trustLevel: UnsafeMutablePointer?) throws { + return try perform(as: C_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetTrustLevel(pThis, trustLevel)) + } + } +} + +// Provide facilities for creating a general IInspectable vtbl which can hold onto any UnsealedWinRTClass. +// These types are used for composable types which don't provide an overrides interface. Composable types which +// follow this pattern should define their composability contract like the following: +// internal class IBaseNoOverrides : OverridesImpl { +// internal typealias CABI = C_IInspectable +// internal typealias SwiftABI = __ABI_WindowsFoundation.IBaseNoOverrides +// internal typealias SwiftProjection = BaseNoOverrides +// internal typealias c_defaultABI = __x_ABI_Ctest__component_CIBaseNoOverrides +// internal typealias swift_overrides = WindowsFoundation.IInspectable +// } +// internal typealias Composable = IBaseNoOverrides +protocol AnyObjectWrapper { + var obj: AnyObject? { get } +} + +public enum __ABI_ { + public class AnyWrapper : WinRTWrapperBase { + public init?(_ swift: Any?) { + guard let swift else { return nil } + if let propertyValue = PropertyValue.createFrom(swift) { + let abi: UnsafeMutablePointer = RawPointer(propertyValue) + super.init(abi.pointee, propertyValue) + } else { + let vtblPtr = withUnsafeMutablePointer(to: &IInspectableVTable) { $0 } + let cAbi = C_IInspectable(lpVtbl: vtblPtr) + super.init(cAbi, swift as AnyObject) + } + } + + override public func toABI(_ body: (UnsafeMutablePointer) throws -> ResultType) + throws -> ResultType { + if let swiftAbi = swiftObj as? IInspectable { + let abi: UnsafeMutablePointer = RawPointer(swiftAbi) + return try body(abi) + } else { + return try super.toABI(body) + } + } + public static func unwrapFrom(abi: ComPtr?) -> Any? { + guard let abi = abi else { return nil } + if let instance = tryUnwrapFrom(abi: abi) { + if let weakRef = instance as? AnyObjectWrapper { return weakRef.obj } + return instance + } + + let ref = IInspectable(abi) + return makeFrom(abi: ref) ?? ref + } + public static func tryUnwrapFrom(raw pUnk: UnsafeMutableRawPointer?) -> AnyObject? { + tryUnwrapFromBase(raw: pUnk) + } + } + + internal static var IInspectableVTable: C_IInspectableVtbl = .init( + QueryInterface: { + guard let pUnk = $0, let riid = $1, let ppvObject = $2 else { return E_INVALIDARG } + ppvObject.pointee = nil + if riid.pointee == IUnknown.IID || + riid.pointee == IInspectable.IID || + riid.pointee == ISwiftImplemented.IID || + riid.pointee == IAgileObject.IID { + _ = pUnk.pointee.lpVtbl.pointee.AddRef(pUnk) + ppvObject.pointee = UnsafeMutableRawPointer(pUnk) + return S_OK + } + let swiftObj = AnyWrapper.tryUnwrapFrom(raw: pUnk) + if let customQueryInterface = swiftObj as? CustomQueryInterface, + let result = customQueryInterface.queryInterface(riid.pointee) { + ppvObject.pointee = result.detach() + return S_OK + } + return E_NOINTERFACE + }, + AddRef: { AnyWrapper.addRef($0) }, + Release: { AnyWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 2).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + + $1!.pointee = 2 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + guard let instance = AnyWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + guard let winrtClass = instance as? WinRTClass else { + let string = String(reflecting: type(of: instance)) + $1!.pointee = try! HString(string).detach() + return S_OK + } + $1!.pointee = winrtClass.GetRuntimeClassName().detach() + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + } + ) +} + +extension ComposableImpl where CABI == C_IInspectable { + public static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__ABI_.IInspectableVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } +} \ No newline at end of file diff --git a/Sources/WindowsFoundation/Generated/Support/IMAP+SWIFT.swift b/Sources/WindowsFoundation/Generated/Support/IMAP+SWIFT.swift new file mode 100644 index 0000000..e1d0aef --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/IMAP+SWIFT.swift @@ -0,0 +1,58 @@ +// Swift Dictionary-like extensions to IMap[View] +extension IMap { + public typealias Key = K + public typealias Value = V + + public var count: Int { Int(size) } + public var underestimatedCount: Int { Int(size) } + public var isEmpty: Bool { size == 0 } + + public subscript(key: Key) -> Value? { + get { hasKey(key) ? lookup(key) : nil } + set(newValue) { + if let value = newValue { + _ = insert(key, value) + } + else { + remove(key) + } + } + } + + public subscript(key: Key, default defaultValue: @autoclosure () -> Value) -> Value { + get { hasKey(key) ? lookup(key) : defaultValue() } + } + + @discardableResult + public func updateValue(_ value: Value, forKey key: Key) -> Value? { + let oldValue = hasKey(key) ? lookup(key) : nil + _ = insert(key, value) + return oldValue + } + + @discardableResult + public func removeValue(forKey key: Key) -> Value? { + let oldValue = hasKey(key) ? lookup(key) : nil + remove(key) + return oldValue + } + + public func removeAll() { clear() } +} + +extension IMapView { + public typealias Key = K + public typealias Value = V + + public var count: Int { Int(size) } + public var underestimatedCount: Int { Int(size) } + public var isEmpty: Bool { size == 0 } + + public subscript(key: Key) -> Value? { + hasKey(key) ? lookup(key) : nil + } + + public subscript(key: Key, default defaultValue: @autoclosure () -> Value) -> Value { + get { hasKey(key) ? lookup(key) : defaultValue() } + } +} \ No newline at end of file diff --git a/Sources/WindowsFoundation/Generated/Support/IMEMORYBUFFERBYTEACCESS.swift b/Sources/WindowsFoundation/Generated/Support/IMEMORYBUFFERBYTEACCESS.swift new file mode 100644 index 0000000..8b579bb --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/IMEMORYBUFFERBYTEACCESS.swift @@ -0,0 +1,74 @@ +import CWinRT +import Foundation + +/// IMemoryBufferByteAccess provides direct access to the underlying bytes of an IMemoryBuffer. +/// This buffer is only valid for the lifetime of the buffer. For a read-only representation +/// of the buffer, access the bytes through the Data property of the IBuffer. +/// [Open Microsoft Documentation](https://learn.microsoft.com/en-us/previous-versions/mt297505(v=vs.85)) +public protocol IMemoryBufferByteAccess: WinRTInterface { + var buffer: UnsafeMutableBufferPointer? { get throws } +} + +public typealias AnyIMemoryBufferByteAccess = any IMemoryBufferByteAccess +fileprivate let IID_IMemoryBufferByteAccess = IID(Data1: 0x5B0D3235, Data2: 0x4DBA, Data3: 0x4D44, Data4: ( 0x86, 0x5E, 0x8F, 0x1D, 0x0E, 0x4F, 0xD0, 0x4D )) // 5b0d3235-4dba-4d44-865e-8f1d0e4fd04d + +extension __ABI_ { + public class IMemoryBufferByteAccess: IUnknown { + override public class var IID: IID { IID_IMemoryBufferByteAccess} + + public func Buffer() throws -> UnsafeMutableBufferPointer? { + var capacity: UInt32 = 0 + let ptr = try GetBuffer(&capacity) + return UnsafeMutableBufferPointer(start: ptr, count: Int(capacity)) + } + + fileprivate func GetBuffer(_ capacity: inout UInt32) throws -> UnsafeMutablePointer? { + var buffer: UnsafeMutablePointer? + try perform(as: CWinRT.IMemoryBufferByteAccess.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetBuffer(pThis, &buffer, &capacity)) + } + return buffer + } + } + + public typealias IMemoryBufferByteAccessWrapper = InterfaceWrapperBase +} + +public enum IMemoryBufferByteAccessBridge: AbiInterfaceBridge { + public static func makeAbi() -> CABI { + return CABI(lpVtbl: &IMemoryBufferByteAccessVTable) + } + + public static func from(abi: ComPtr?) -> SwiftProjection? { + // This code path is not actually reachable since IMemoryBufferByteAccess is not a WinRT interface. + // It is a COM interface which is implemented by any object which implements the IMemoryBufferReference interface. + // And the IMemoryBufferReferenceImpl object will correctly have the implementation of this interface, so this isn't needed + assertionFailure("IMemoryBufferByteAccessBridge.from not implemented") + return nil + } + + public typealias CABI = CWinRT.IMemoryBufferByteAccess + public typealias SwiftABI = __ABI_.IMemoryBufferByteAccess + public typealias SwiftProjection = AnyIMemoryBufferByteAccess +} + +fileprivate var IMemoryBufferByteAccessVTable: CWinRT.IMemoryBufferByteAccessVtbl = .init( + QueryInterface: { __ABI_.IMemoryBufferByteAccessWrapper.queryInterface($0, $1, $2) }, + AddRef: { __ABI_.IMemoryBufferByteAccessWrapper.addRef($0) }, + Release: { __ABI_.IMemoryBufferByteAccessWrapper.release($0) }, + GetBuffer: { __ABI_.IMemoryBufferByteAccessWrapper.getBuffer($0, $1, $2) } +) + +extension __ABI_.IMemoryBufferByteAccessWrapper { + fileprivate static func getBuffer(_ this: UnsafeMutablePointer?, _ buffer: UnsafeMutablePointer?>?, _ count: UnsafeMutablePointer?) -> HRESULT { + guard let swiftObj = __ABI_.IMemoryBufferByteAccessWrapper.tryUnwrapFrom(raw: this) else { return E_INVALIDARG } + guard let buffer, let count else { return E_INVALIDARG } + count.pointee = 0 + buffer.pointee = nil + + guard let swiftBuffer = try? swiftObj.buffer else { return E_FAIL } + count.pointee = UInt32(swiftBuffer.count) + buffer.pointee = swiftBuffer.baseAddress + return S_OK + } +} \ No newline at end of file diff --git a/Sources/WindowsFoundation/Generated/Support/IUNKNOWN+SWIFT.swift b/Sources/WindowsFoundation/Generated/Support/IUNKNOWN+SWIFT.swift new file mode 100644 index 0000000..9410fb5 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/IUNKNOWN+SWIFT.swift @@ -0,0 +1,41 @@ +// Copyright © 2021 Saleem Abdulrasool +// SPDX-License-Identifier: BSD-3 + +import WinSDK + +extension IUnknown { + public func QueryInterface() throws -> Interface { + var iid = Interface.IID + let (pointer) = try ComPtrs.initialize(to: C_IUnknown.self) { abi in + try CHECKED(self.pUnk.borrow.pointee.lpVtbl.pointee.QueryInterface(self.pUnk.borrow, &iid, &abi)) + } + return Interface(pointer!) + } +} + +extension IUnknown { + @_alwaysEmitIntoClient @inline(__always) + public func perform(as type: Type.Type, + _ body: (UnsafeMutablePointer) throws -> ResultType) + throws -> ResultType { + let pThis = UnsafeMutableRawPointer(self.pUnk.borrow).bindMemory(to: Type.self, capacity: 1) + return try body(pThis) + } +} + +extension IUnknown { + public static func CreateInstance(`class` clsid: CLSID, + outer pUnkOuter: IUnknown? = nil, + context dwClsContext: CLSCTX = CLSCTX_INPROC_SERVER) + throws -> Interface { + var clsid = clsid + var iid = Interface.IID + + let (instance) = try ComPtrs.initialize(to: C_IUnknown.self) { instanceAbi in + try CHECKED(CoCreateInstance(&clsid, RawPointer(pUnkOuter), DWORD(dwClsContext.rawValue), &iid, &instanceAbi)) + } + // https://learn.microsoft.com/en-us/windows/win32/api/combaseapi/nf-combaseapi-cocreateinstance + // "Upon successful return, *ppv contains the requested interface pointer." + return try instance!.queryInterface() + } +} \ No newline at end of file diff --git a/Sources/WindowsFoundation/Generated/Support/IUNKNOWN.swift b/Sources/WindowsFoundation/Generated/Support/IUNKNOWN.swift new file mode 100644 index 0000000..9c88c15 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/IUNKNOWN.swift @@ -0,0 +1,35 @@ +// Copyright © 2021 Saleem Abdulrasool +// SPDX-License-Identifier: BSD-3 + +import WinSDK +import CWinRT + +fileprivate let IID_IUnknown = IID(Data1: 0x00000000, Data2: 0x0000, Data3: 0x0000, Data4: ( 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 )) // 00000000-0000-0000-C000-000000000046 + +open class IUnknown : HasIID { + public let pUnk: IUnknownRef + + open class var IID: WindowsFoundation.IID { IID_IUnknown } + + public required init(_ pointer: ComPtr) { + self.pUnk = .init(pointer) + } + + @_alwaysEmitIntoClient @inline(__always) + public func QueryInterface(_ iid: REFIID, _ ppvObject: UnsafeMutablePointer?) throws { + let pUnk: UnsafeMutablePointer! = self.pUnk.borrow + try CHECKED(pUnk.pointee.lpVtbl.pointee.QueryInterface(pUnk, iid, ppvObject)) + } + + @_alwaysEmitIntoClient @inline(__always) @discardableResult + public func AddRef() -> ULONG { + let pUnk: UnsafeMutablePointer! = self.pUnk.borrow + return pUnk.pointee.lpVtbl.pointee.AddRef(pUnk) + } + + @_alwaysEmitIntoClient @inline(__always) @discardableResult + public func Release() -> ULONG { + let pUnk: UnsafeMutablePointer! = self.pUnk.borrow + return pUnk.pointee.lpVtbl.pointee.Release(pUnk) + } +} diff --git a/Sources/WindowsFoundation/Generated/Support/IUNKNOWNREF.swift b/Sources/WindowsFoundation/Generated/Support/IUNKNOWNREF.swift new file mode 100644 index 0000000..d9cf4d9 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/IUNKNOWNREF.swift @@ -0,0 +1,21 @@ +// Copyright © 2021 Saleem Abdulrasool +// SPDX-License-Identifier: BSD-3 + +@_fixed_layout +public final class IUnknownRef { + private var pUnk: ComPtr + + init(_ pUnk: ComPtr) { + let pointer: UnsafeMutablePointer = + UnsafeMutableRawPointer(pUnk.get()).bindMemory(to: C_IUnknown.self, capacity: 1) + self.pUnk = .init(pointer) + } + + func detach() -> UnsafeMutableRawPointer? { + return self.pUnk.detach() + } + + public var borrow: UnsafeMutablePointer { + return self.pUnk.get() + } +} diff --git a/Sources/WindowsFoundation/Generated/Support/IVECTOR+SWIFT.swift b/Sources/WindowsFoundation/Generated/Support/IVECTOR+SWIFT.swift new file mode 100644 index 0000000..dc87d17 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/IVECTOR+SWIFT.swift @@ -0,0 +1,43 @@ +// Default Swift Collection protocol implementation for IVector +public extension IVector { + var startIndex: Int { 0 } + var endIndex: Int { count } + var count: Int { Int(size) } + + subscript(position: Int) -> Element { + get { getAt(UInt32(position)) } + set(newValue) { setAt(UInt32(position), newValue) } + } + + func index(after i: Int) -> Int { i+1 } + func removeLast() { removeAtEnd()} + + func index(of: Element) -> Int? { + var index: UInt32 = 0 + let result = indexOf(of, &index) + guard result else { return nil } + return Int(index) + } + + func remove(at: Int) -> Element { + let item = self[at] + removeAt(UInt32(at)) + return item + } +} + +public extension IVectorView { + var startIndex: Int { 0 } + var endIndex: Int { count } + var count: Int { Int(size) } + + func index(after i: Int) -> Int { i+1} + subscript(position: Int) -> Element { getAt(UInt32(position)) } + + func index(of: Element) -> Int? { + var index: UInt32 = 0 + let result = indexOf(of, &index) + guard result else { return nil } + return Int(index) + } +} \ No newline at end of file diff --git a/Sources/WindowsFoundation/Generated/Support/MAKEFROMABI.swift b/Sources/WindowsFoundation/Generated/Support/MAKEFROMABI.swift new file mode 100644 index 0000000..23f7244 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/MAKEFROMABI.swift @@ -0,0 +1,31 @@ +import Foundation + +// Not strongly typed, we lose the type safety of the associatedtype anyways +// when we cast to `any MakeFromAbi`, plus that requires a lot more exported +// simples than we want +public protocol MakeFromAbi { + static func from(typeName: String, abi: WindowsFoundation.IInspectable) -> Any? +} + +func make(typeName: SwiftTypeName, from abi: WindowsFoundation.IInspectable) -> Any? { + guard let makerType = NSClassFromString("\(typeName.module).__MakeFromAbi") as? any MakeFromAbi.Type else { + return nil + } + return makerType.from(typeName: typeName.typeName, abi: abi) +} + +func makeFrom(abi: WindowsFoundation.IInspectable) -> Any? { + // When creating a swift class which represents this type, we want to get the class name that we're trying to create + // via GetRuntimeClassName so that we can create the proper derived type. For example, the API may return UIElement, + // but we want to return a Button type. + + // Note that we'll *never* be trying to create an app implemented object at this point + guard let className = try? abi.GetSwiftTypeName() else { return nil } + + return make(typeName: className, from: abi) +} + +func make(type: T.Type, from abi: WindowsFoundation.IInspectable) -> T? { + let classString = NSStringFromClass(type).split(separator: ".", maxSplits: 2) + return make(typeName: SwiftTypeName(module: String(classString[0]), typeName: String(classString[1])), from: abi) as? T +} diff --git a/Sources/WindowsFoundation/Generated/Support/MARSHALER.swift b/Sources/WindowsFoundation/Generated/Support/MARSHALER.swift new file mode 100644 index 0000000..989e0d9 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/MARSHALER.swift @@ -0,0 +1,136 @@ +import CWinRT + +internal let IID_IMarshal: IID = IID(Data1: 0x01000300, Data2: 0x0000, Data3: 0x0000, Data4: (0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)) // 01000300-0000-0000-C000-00000046 + +fileprivate extension IUnknownRef { + func copyTo(_ riid: REFIID?, _ ppvObj: UnsafeMutablePointer?) -> HRESULT { + self.borrow.pointee.lpVtbl.pointee.QueryInterface(self.borrow, riid, ppvObj) + } +} + +func makeMarshaler(_ outer: IUnknownRef, _ result: UnsafeMutablePointer) throws { + let marshaler = try Marshaler(outer) + let wrapper = MarshalWrapper(marshaler) + try wrapper.toABI { + _ = $0.pointee.lpVtbl.pointee.AddRef($0) + result.pointee = UnsafeMutableRawPointer($0) + } +} + +fileprivate class MarshalWrapper: WinRTAbiBridgeWrapper { + init(_ marshaler: Marshaler){ + super.init(IMarshalBridge.makeAbi(), marshaler) + } +} + +fileprivate enum IMarshalBridge: AbiBridge { + static func makeAbi() -> C_IMarshal { + return C_IMarshal(lpVtbl: &IMarshalVTable) + } + + static func from(abi: ComPtr?) -> Marshaler? { + guard let abi = abi else { return nil } + return try? Marshaler(IUnknownRef(abi)) + } + + typealias CABI = C_IMarshal + typealias SwiftProjection = Marshaler +} + +private var IMarshalVTable: C_IMarshalVtbl = .init( + QueryInterface: { pUnk, riid, ppvObject in + guard let pUnk, let riid, let ppvObject else { return E_INVALIDARG } + switch riid.pointee { + case IID_IMarshal: + _ = pUnk.pointee.lpVtbl.pointee.AddRef(pUnk) + return S_OK + default: + guard let obj = MarshalWrapper.tryUnwrapFromBase(raw: pUnk)?.obj else { return E_NOINTERFACE } + return obj.copyTo(riid, ppvObject) + } + }, + AddRef: { MarshalWrapper.addRef($0) }, + Release: { MarshalWrapper.release($0) }, + GetUnmarshalClass: { Marshaler.GetUnmarshalClass($0, $1, $2, $3, $4, $5, $6) }, + GetMarshalSizeMax: { Marshaler.GetMarshalSizeMax($0, $1, $2, $3, $4, $5, $6) }, + MarshalInterface: { Marshaler.MarshalInterface($0, $1, $2, $3, $4, $5, $6) }, + UnmarshalInterface: { Marshaler.UnmarshalInterface($0, $1, $2, $3)}, + ReleaseMarshalData: { Marshaler.ReleaseMarshalData($0, $1) }, + DisconnectObject: { Marshaler.DisconnectObject($0, $1) } +) + +private class Marshaler { + var obj: IUnknownRef + + init(_ obj: IUnknownRef) throws { + self.obj = obj + var marshalerPtr: UnsafeMutablePointer? + try CHECKED(CoCreateFreeThreadedMarshaler(nil, &marshalerPtr)) + guard let marshalerPtr else { throw WindowsFoundation.Error(hr: E_FAIL) } + marshaler = UnsafeMutableRawPointer(marshalerPtr).bindMemory(to: C_IMarshal.self, capacity: 1) + } + + deinit { + _ = marshaler.pointee.lpVtbl.pointee.Release(marshaler) + } + + var marshaler: UnsafeMutablePointer + + static func GetUnmarshalClass( + _ this: UnsafeMutablePointer?, + _ riid: REFIID?, + _ pv: UnsafeMutableRawPointer?, + _ dwDestContext: DWORD, + _ pvDestContext: UnsafeMutableRawPointer?, + _ mshlflags: DWORD, + _ pCid: UnsafeMutablePointer?) -> HRESULT { + guard let marshaler = MarshalWrapper.tryUnwrapFrom(abi: ComPtr(this))?.marshaler else { return E_FAIL } + return marshaler.pointee.lpVtbl.pointee.GetUnmarshalClass(marshaler, riid, pv, dwDestContext, pvDestContext, mshlflags, pCid) + } + + static func GetMarshalSizeMax( + _ this: UnsafeMutablePointer?, + _ riid: REFIID?, _ pv: UnsafeMutableRawPointer?, + _ dwDestContext: DWORD, + _ pvDestContext: UnsafeMutableRawPointer?, + _ mshlflags: DWORD, + _ pSize: UnsafeMutablePointer?) -> HRESULT { + guard let marshaler = MarshalWrapper.tryUnwrapFrom(abi: ComPtr(this))?.marshaler else { return E_FAIL } + return marshaler.pointee.lpVtbl.pointee.GetMarshalSizeMax(marshaler, riid, pv, dwDestContext, pvDestContext, mshlflags, pSize) + } + + static func MarshalInterface( + _ this: UnsafeMutablePointer?, + _ pStm: UnsafeMutablePointer?, + _ riid: REFIID?, + _ pv: UnsafeMutableRawPointer?, + _ dwDestContext: DWORD, + _ pvDestContext: UnsafeMutableRawPointer?, + _ mshlflags: DWORD) -> HRESULT { + guard let marshaler = MarshalWrapper.tryUnwrapFrom(abi: ComPtr(this))?.marshaler else { return E_FAIL } + return marshaler.pointee.lpVtbl.pointee.MarshalInterface(marshaler, pStm, riid, pv, dwDestContext, pvDestContext, mshlflags) + } + + static func UnmarshalInterface( + _ this: UnsafeMutablePointer?, + _ pStm: UnsafeMutablePointer?, + _ riid: REFIID?, + _ ppv: UnsafeMutablePointer?) -> HRESULT { + guard let marshaler = MarshalWrapper.tryUnwrapFrom(abi: ComPtr(this))?.marshaler else { return E_FAIL } + return marshaler.pointee.lpVtbl.pointee.UnmarshalInterface(marshaler, pStm, riid, ppv) + } + + static func ReleaseMarshalData( + _ this: UnsafeMutablePointer?, + _ pStm: UnsafeMutablePointer?) -> HRESULT { + guard let marshaler = MarshalWrapper.tryUnwrapFrom(abi: ComPtr(this))?.marshaler else { return E_FAIL } + return marshaler.pointee.lpVtbl.pointee.ReleaseMarshalData(marshaler, pStm) + } + + static func DisconnectObject( + _ this: UnsafeMutablePointer?, + _ dwReserved: DWORD) -> HRESULT { + guard let marshaler = MarshalWrapper.tryUnwrapFrom(abi: ComPtr(this))?.marshaler else { return E_FAIL } + return marshaler.pointee.lpVtbl.pointee.DisconnectObject(marshaler, dwReserved) + } +} diff --git a/Sources/WindowsFoundation/Generated/Support/PROPERTYVALUE+ABI.swift b/Sources/WindowsFoundation/Generated/Support/PROPERTYVALUE+ABI.swift new file mode 100644 index 0000000..377eb52 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/PROPERTYVALUE+ABI.swift @@ -0,0 +1,173 @@ +import CWinRT +import WinSDK + +// Internal implementation of IPropertyValue +fileprivate var IID___x_ABI_CWindows_CFoundation_CIPropertyValueStatics: WindowsFoundation.IID { + .init(Data1: 0x629BDBC8, Data2: 0xD932, Data3: 0x4FF4, Data4: ( 0x96,0xB9,0x8D,0x96,0xC5,0xC1,0xE8,0x58 ))// 629BDBC8-D932-4FF4-96B9-8D96C5C1E858 +} + +internal class IPropertyValueStatics: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIPropertyValueStatics } + + internal func CreateUInt8Impl(_ value: UINT8) throws -> ComPtr? { + let (propertyValue) = try ComPtrs.initialize { abi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValueStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateUInt8(pThis, value, &abi)) + } + } + return propertyValue + } + + internal func CreateInt16Impl(_ value: INT16) throws -> ComPtr? { + let (propertyValue) = try ComPtrs.initialize { abi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValueStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateInt16(pThis, value, &abi)) + } + } + return propertyValue + } + + internal func CreateUInt16Impl(_ value: UINT16) throws -> ComPtr? { + let (propertyValue) = try ComPtrs.initialize { abi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValueStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateUInt16(pThis, value, &abi)) + } + } + return propertyValue + } + + internal func CreateInt32Impl(_ value: INT32) throws -> ComPtr? { + let (propertyValue) = try ComPtrs.initialize { abi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValueStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateInt32(pThis, value, &abi)) + } + } + return propertyValue + } + + internal func CreateUInt32Impl(_ value: UINT32) throws -> ComPtr? { + let (propertyValue) = try ComPtrs.initialize { abi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValueStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateUInt32(pThis, value, &abi)) + } + } + return propertyValue + } + + internal func CreateInt64Impl(_ value: INT64) throws -> ComPtr? { + let (propertyValue) = try ComPtrs.initialize { abi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValueStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateInt64(pThis, value, &abi)) + } + } + return propertyValue + } + + internal func CreateUInt64Impl(_ value: UINT64) throws -> ComPtr? { + let (propertyValue) = try ComPtrs.initialize { abi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValueStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateUInt64(pThis, value, &abi)) + } + } + return propertyValue + } + + internal func CreateSingleImpl(_ value: FLOAT) throws -> ComPtr? { + let (propertyValue) = try ComPtrs.initialize { abi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValueStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateSingle(pThis, value, &abi)) + } + } + return propertyValue + } + + internal func CreateDoubleImpl(_ value: DOUBLE) throws -> ComPtr? { + let (propertyValue) = try ComPtrs.initialize { abi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValueStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateDouble(pThis, value, &abi)) + } + } + return propertyValue + } + + internal func CreateChar16Impl(_ value: WCHAR) throws -> ComPtr? { + let (propertyValue) = try ComPtrs.initialize { abi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValueStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateChar16(pThis, value, &abi)) + } + } + return propertyValue + } + + internal func CreateBooleanImpl(_ value: boolean) throws -> ComPtr? { + let (propertyValue) = try ComPtrs.initialize { abi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValueStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateBoolean(pThis, value, &abi)) + } + } + return propertyValue + } + + internal func CreateStringImpl(_ value: HSTRING?) throws -> ComPtr? { + let (propertyValue) = try ComPtrs.initialize { abi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValueStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateString(pThis, value, &abi)) + } + } + return propertyValue + } + + internal func CreateGuidImpl(_ value: GUID) throws -> ComPtr? { + let (propertyValue) = try ComPtrs.initialize { abi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValueStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateGuid(pThis, value, &abi)) + } + } + return propertyValue + } + + internal func CreateDateTimeImpl(_ value: __x_ABI_CWindows_CFoundation_CDateTime) throws -> ComPtr? { + let (propertyValue) = try ComPtrs.initialize { abi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValueStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateDateTime(pThis, value, &abi)) + } + } + return propertyValue + } + + internal func CreateTimeSpanImpl(_ value: __x_ABI_CWindows_CFoundation_CTimeSpan) throws -> ComPtr? { + let (propertyValue) = try ComPtrs.initialize { abi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValueStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateTimeSpan(pThis, value, &abi)) + } + } + return propertyValue + } + + internal func CreatePointImpl(_ value: __x_ABI_CWindows_CFoundation_CPoint) throws -> ComPtr? { + let (propertyValue) = try ComPtrs.initialize { abi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValueStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreatePoint(pThis, value, &abi)) + } + } + return propertyValue + } + + internal func CreateSizeImpl(_ value: __x_ABI_CWindows_CFoundation_CSize) throws -> ComPtr? { + let (propertyValue) = try ComPtrs.initialize { abi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValueStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateSize(pThis, value, &abi)) + } + } + return propertyValue + } + + internal func CreateRectImpl(_ value: __x_ABI_CWindows_CFoundation_CRect) throws -> ComPtr? { + let (propertyValue) = try ComPtrs.initialize { abi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValueStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateRect(pThis, value, &abi)) + } + } + return propertyValue + } + } \ No newline at end of file diff --git a/Sources/WindowsFoundation/Generated/Support/PROPERTYVALUE.swift b/Sources/WindowsFoundation/Generated/Support/PROPERTYVALUE.swift new file mode 100644 index 0000000..213ebec --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/PROPERTYVALUE.swift @@ -0,0 +1,142 @@ +import Foundation +import CWinRT +import WinSDK + +// Handwritten implementation for PropertyValue which *doesn't* try to do the IInspectable <-> Any mapping. +// This class is used by the AnyWrapper to create IInspectable instances from this subset of known Any values. +internal final class PropertyValue { + private static let _IPropertyValueStatics: IPropertyValueStatics = try! RoGetActivationFactory(HString("Windows.Foundation.PropertyValue")) + + public static func createUInt8(_ value: UInt8) -> WindowsFoundation.IInspectable { + let propertyValue = try! _IPropertyValueStatics.CreateUInt8Impl(value) + return .init(propertyValue!) + } + + public static func createInt16(_ value: Int16) -> WindowsFoundation.IInspectable { + let propertyValue = try! _IPropertyValueStatics.CreateInt16Impl(value) + return .init(propertyValue!) + } + + public static func createUInt16(_ value: UInt16) -> WindowsFoundation.IInspectable { + let propertyValue = try! _IPropertyValueStatics.CreateUInt16Impl(value) + return .init(propertyValue!) + } + + public static func createInt32(_ value: Int32) -> WindowsFoundation.IInspectable { + let propertyValue = try! _IPropertyValueStatics.CreateInt32Impl(value) + return .init(propertyValue!) + } + + public static func createUInt32(_ value: UInt32) -> WindowsFoundation.IInspectable { + let propertyValue = try! _IPropertyValueStatics.CreateUInt32Impl(value) + return .init(propertyValue!) + } + + public static func createInt64(_ value: Int64) -> WindowsFoundation.IInspectable { + let propertyValue = try! _IPropertyValueStatics.CreateInt64Impl(value) + return .init(propertyValue!) + } + + public static func createUInt64(_ value: UInt64) -> WindowsFoundation.IInspectable { + let propertyValue = try! _IPropertyValueStatics.CreateUInt64Impl(value) + return .init(propertyValue!) + } + + public static func createSingle(_ value: Float) -> WindowsFoundation.IInspectable { + let propertyValue = try! _IPropertyValueStatics.CreateSingleImpl(value) + return .init(propertyValue!) + } + + public static func createDouble(_ value: Double) -> WindowsFoundation.IInspectable { + let propertyValue = try! _IPropertyValueStatics.CreateDoubleImpl(value) + return .init(propertyValue!) + } + + public static func createBoolean(_ value: Bool) -> WindowsFoundation.IInspectable { + let propertyValue = try! _IPropertyValueStatics.CreateBooleanImpl(.init(from: value)) + return .init(propertyValue!) + } + + public static func createString(_ value: String) -> WindowsFoundation.IInspectable { + let _value = try! HString(value) + let propertyValue = try! _IPropertyValueStatics.CreateStringImpl(_value.get()) + return .init(propertyValue!) + } + + public static func createGuid(_ value: GUID) -> WindowsFoundation.IInspectable { + let propertyValue = try! _IPropertyValueStatics.CreateGuidImpl(value) + return .init(propertyValue!) + } + + public static func createDateTime(_ value: DateTime) -> WindowsFoundation.IInspectable { + let propertyValue = try! _IPropertyValueStatics.CreateDateTimeImpl(.from(swift: value)) + return .init(propertyValue!) + } + + public static func createTimeSpan(_ value: TimeSpan) -> WindowsFoundation.IInspectable { + let propertyValue = try! _IPropertyValueStatics.CreateTimeSpanImpl(.from(swift: value)) + return .init(propertyValue!) + } + + public static func createPoint(_ value: Point) -> WindowsFoundation.IInspectable { + let propertyValue = try! _IPropertyValueStatics.CreatePointImpl(.from(swift: value)) + return .init(propertyValue!) + } + + public static func createSize(_ value: Size) -> WindowsFoundation.IInspectable { + let propertyValue = try! _IPropertyValueStatics.CreateSizeImpl(.from(swift: value)) + return .init(propertyValue!) + } + + public static func createRect(_ value: Rect) -> WindowsFoundation.IInspectable { + let propertyValue = try! _IPropertyValueStatics.CreateRectImpl(.from(swift: value)) + return .init(propertyValue!) + } +} + +extension PropertyValue +{ + static func createInt(_ value: Int) -> WindowsFoundation.IInspectable { + #if arch(x86_64) || arch(arm64) + return PropertyValue.createInt64(Int64(value)) + #elseif arch(i386) || arch(arm) + return PropertyValue.createInt32(Int32(value)) + #else + fatalError("unknown process architecture size") + #endif + } + + static func createUInt(_ value: UInt) -> WindowsFoundation.IInspectable { + #if arch(x86_64) || arch(arm64) + return PropertyValue.createUInt64(UInt64(value)) + #elseif arch(i386) || arch(arm) + return PropertyValue.createUInt32(UInt32(value)) + #else + fatalError("unknown process architecture size") + #endif + } + + static func createFrom(_ any: Any) -> WindowsFoundation.IInspectable? { + switch any { + case let value as String: return PropertyValue.createString(value) + case let value as Int: return PropertyValue.createInt(value) + case let value as Int16: return PropertyValue.createInt16(value) + case let value as Int32: return PropertyValue.createInt32(value) + case let value as Int64: return PropertyValue.createInt64(value) + case let value as UInt: return PropertyValue.createUInt(value) + case let value as UInt8: return PropertyValue.createUInt8(value) + case let value as UInt32: return PropertyValue.createUInt32(value) + case let value as UInt64: return PropertyValue.createUInt64(value) + case let value as Float: return PropertyValue.createSingle(value) + case let value as Double: return PropertyValue.createDouble(value) + case let value as Bool: return PropertyValue.createBoolean(value) + case let value as GUID: return PropertyValue.createGuid(value) + case let value as DateTime: return PropertyValue.createDateTime(value) + case let value as TimeSpan: return PropertyValue.createTimeSpan(value) + case let value as Point: return PropertyValue.createPoint(value) + case let value as Size: return PropertyValue.createSize(value) + case let value as Rect: return PropertyValue.createRect(value) + default: return nil + } + } +} diff --git a/Sources/WindowsFoundation/Generated/Support/RAWTYPED.swift b/Sources/WindowsFoundation/Generated/Support/RAWTYPED.swift new file mode 100644 index 0000000..9d758c4 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/RAWTYPED.swift @@ -0,0 +1,32 @@ +// Copyright © 2021 Saleem Abdulrasool +// SPDX-License-Identifier: BSD-3 + +import WinSDK + +public func RawPointer(_ pUnk: T) -> UnsafeMutablePointer { + return UnsafeMutableRawPointer(pUnk.pUnk.borrow).bindMemory(to: U.self, capacity: 1) +} + +public func RawPointer(_ pUnk: T) -> ComPtr { + return ComPtr(UnsafeMutableRawPointer(pUnk.pUnk.borrow).bindMemory(to: U.self, capacity: 1)) +} + +public func RawPointer(_ pUnk: T?) -> UnsafeMutablePointer? { + guard let pUnk else { return nil } + let result: UnsafeMutablePointer = RawPointer(pUnk) + return result +} + +public func RawPointer(_ obj: T?) -> UnsafeMutablePointer? { + return obj?._getABI() +} + +public func RawPointer(_ obj: T) -> UnsafeMutablePointer { + return RawPointer(obj._default) +} + +public func RawPointer(_ obj: T?) -> UnsafeMutablePointer? { + guard let obj else { return nil} + let result: UnsafeMutablePointer = RawPointer(obj) + return result +} \ No newline at end of file diff --git a/Sources/WindowsFoundation/Generated/Support/RUNTIME+SWIFT.swift b/Sources/WindowsFoundation/Generated/Support/RUNTIME+SWIFT.swift new file mode 100644 index 0000000..eb7e607 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/RUNTIME+SWIFT.swift @@ -0,0 +1,31 @@ +// Copyright © 2021 Saleem Abdulrasool +// SPDX-License-Identifier: BSD-3 + +import WinSDK +import CWinRT + +public func RoGetActivationFactory(_ activatableClassId: HString) throws -> Factory { + var iid = Factory.IID + let (factory) = try ComPtrs.initialize(to: C_IInspectable.self) { factoryAbi in + try CHECKED(RoGetActivationFactory(activatableClassId.get(), &iid, &factoryAbi)) + } + return try factory!.queryInterface() +} + +public func RoActivateInstance(_ activatableClassId: HString) throws -> Instance { + let (instance) = try ComPtrs.initialize { instanceAbi in + try CHECKED(RoActivateInstance(activatableClassId.get(), &instanceAbi)) + } + return try instance!.queryInterface() +} + +// ISwiftImplemented is a marker interface for code-gen types which are created by swift/winrt. It's used to QI +// an IUnknown VTABLE to see whether we can unwrap this type as a known swift object. The class is marked final +// because it isn't intended to actually be implemented. +private var IID_ISwiftImplemented: WindowsFoundation.IID { + .init(Data1: 0xbfd14ad5, Data2: 0x950b, Data3: 0x4b82, Data4: ( 0x96, 0xc, 0x1, 0xf4, 0xf4, 0x77, 0x7e, 0x57 )) // BFD14AD5-950B-4B82-960C-01F4F4777E57 +} + +public final class ISwiftImplemented : IInspectable { + override public class var IID: WindowsFoundation.IID { IID_ISwiftImplemented } +} diff --git a/Sources/WindowsFoundation/Generated/Support/SWIFT+EXTENSIONS.swift b/Sources/WindowsFoundation/Generated/Support/SWIFT+EXTENSIONS.swift new file mode 100644 index 0000000..27c7e3f --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/SWIFT+EXTENSIONS.swift @@ -0,0 +1,38 @@ +// Copyright © 2021 Saleem Abdulrasool +// SPDX-License-Identifier: BSD-3 + +import CWinRT + +extension String { + public init(from hString: HSTRING?) { + var length: UINT32 = 0 + let pwszBuffer: PCWSTR = WindowsGetStringRawBuffer(hString, &length) + self.init(decoding: UnsafeBufferPointer(start: pwszBuffer, count: Int(length)), as: UTF16.self) + } + + public init(hString: HString) { + var length: UINT32 = 0 + let pwszBuffer: PCWSTR = WindowsGetStringRawBuffer(hString.get(), &length) + self.init(decoding: UnsafeBufferPointer(start: pwszBuffer, count: Int(length)), as: UTF16.self) + } +} + +extension Bool { + public init(from val: boolean) { + self.init(booleanLiteral: val != 0) + } +} + +extension Character { + public init(from wchar: WCHAR) { + if let scalar = Unicode.Scalar(wchar) { + self.init(scalar) + } else { + self.init("") + } + } +} + +extension UnsafeMutableRawPointer { + public static var none : UnsafeMutableRawPointer? { return nil } +} \ No newline at end of file diff --git a/Sources/WindowsFoundation/Generated/Support/TRUSTLEVEL+SWIFT.swift b/Sources/WindowsFoundation/Generated/Support/TRUSTLEVEL+SWIFT.swift new file mode 100644 index 0000000..a1e31fb --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/TRUSTLEVEL+SWIFT.swift @@ -0,0 +1,18 @@ +// Copyright © 2021 Saleem Abdulrasool +// SPDX-License-Identifier: BSD-3 + +import CWinRT + +extension TrustLevel { + public static var BaseTrust: TrustLevel { + TrustLevel(rawValue: 0) + } + + public static var PartialTrust: TrustLevel { + TrustLevel(rawValue: 1) + } + + public static var FullTrust: TrustLevel { + TrustLevel(rawValue: 2) + } +} diff --git a/Sources/WindowsFoundation/Generated/Support/WAITABLEEVENT.swift b/Sources/WindowsFoundation/Generated/Support/WAITABLEEVENT.swift new file mode 100644 index 0000000..9fcf788 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/WAITABLEEVENT.swift @@ -0,0 +1,40 @@ +import Foundation + +actor WaitableEvent { + typealias Observer = @Sendable () -> Void + + private var observer: Observer? + private var signaled = false + + init() {} + + /// Block until the signaled state is `true`. + func wait() async { + guard !signaled else { return } + guard observer == nil else { + #if DEBUG + preconditionFailure("message has already been waited on") + #else + return + #endif + } + await withCheckedContinuation { continuation in + observer = { + continuation.resume(returning: ()) + } + } + } + + /// Signals the event, unblocking any current or future waiter. + func signal() async { + guard !signaled else { + #if DEBUG + preconditionFailure("message already signaled") + #else + return + #endif + } + signaled = true + observer?() + } +} diff --git a/Sources/WindowsFoundation/Generated/Support/WINRTDELEGATE.swift b/Sources/WindowsFoundation/Generated/Support/WINRTDELEGATE.swift new file mode 100644 index 0000000..ea979c0 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/WINRTDELEGATE.swift @@ -0,0 +1,4 @@ +// WinRTDelegateBridge specifies the contract for bridging between WinRT and Swift for event handlers and d +public protocol WinRTDelegateBridge: AbiInterfaceBridge where SwiftProjection == Handler { + associatedtype Handler +} diff --git a/Sources/WindowsFoundation/Generated/Support/WINRTPROTOCOLS.swift b/Sources/WindowsFoundation/Generated/Support/WINRTPROTOCOLS.swift new file mode 100644 index 0000000..c34e8f7 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/WINRTPROTOCOLS.swift @@ -0,0 +1,95 @@ +import CWinRT +import Foundation + +// Protocols for WinRT types that are used by public APIs + +public protocol WinRTStruct {} +public protocol WinRTEnum {} + +public protocol IWinRTObject: AnyObject { + var thisPtr: WindowsFoundation.IInspectable { get } +} + +public protocol WinRTInterface: AnyObject, CustomQueryInterface { +} + +open class WinRTClass : CustomQueryInterface, Equatable { + public init() {} + + @_spi(WinRTInternal) + public init(_ ptr: WindowsFoundation.IInspectable) { + _inner = ptr + } + + @_spi(WinRTInternal) + open func _getABI() -> UnsafeMutablePointer? { + if T.self == C_IInspectable.self { + return UnsafeMutableRawPointer(identity?.get())?.bindMemory(to: T.self, capacity: 1) ?? RawPointer(_inner) + } + if T.self == C_IUnknown.self { + return UnsafeMutableRawPointer(identity?.get())?.bindMemory(to: T.self, capacity: 1) ?? RawPointer(_inner) + } + return nil + } + + @_spi(WinRTInternal) + public internal(set) var _inner: WindowsFoundation.IInspectable! + + var identity: ComPtr? + + @_spi(WinRTImplements) + open func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + WindowsFoundation.queryInterface(self, iid) + } + + deinit { + // ensure we release the identity pointer before releasing _inner. releasing the _inner + // cleans up the underlying COM object. + identity = nil + _inner = nil + } +} + +public func ==(_ lhs: T, _ rhs: T) -> Bool { + return lhs.thisPtr == rhs.thisPtr +} + +extension WinRTClass: IWinRTObject { + public var thisPtr: WindowsFoundation.IInspectable { try! _inner.QueryInterface() } +} + +@_spi(WinRTInternal) +extension WinRTClass { + public func copyTo(_ ptr: UnsafeMutablePointer?>?) { + guard let ptr else { return } + let result: UnsafeMutablePointer = _getABI()! + result.withMemoryRebound(to: C_IInspectable.self, capacity: 1) { + _ = $0.pointee.lpVtbl.pointee.AddRef($0) + } + ptr.initialize(to: result) + } + + public func GetRuntimeClassName() -> HString { + // always use the runtime class name of the inner WinRT object. the winui runtime will query for + // class names and if it isn't recognized, it will call out to IXamlMetadataProvider (IXMP) + // to get the associated XamlType. We aren't using Xaml for swift, so we don't actually + // need or want the framework to think it's dealing with custom types. + return try! _inner.GetRuntimeClassName() + } + + fileprivate func aggregated() -> Bool { identity != nil } + + // Get an interface for caching on a class. This method properly handles + // reference counting via releasing the reference added on the Swift object + // in the case of being aggregated. The wrapper still has the +1 ref on it, + // which will be released when the object is destroyed. We can safely let the + // objects be destroyed since _inner is destroyed last. Releasing _inner is what + // cleans up the underlying COM object. + public func getInterfaceForCaching() -> T { + let ptr:T = try! _inner.QueryInterface() + if aggregated() { + Unmanaged.passUnretained(self).release() + } + return ptr + } +} diff --git a/Sources/WindowsFoundation/Generated/Support/WINRTWRAPPERBASE.swift b/Sources/WindowsFoundation/Generated/Support/WINRTWRAPPERBASE.swift new file mode 100644 index 0000000..7260a47 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/WINRTWRAPPERBASE.swift @@ -0,0 +1,255 @@ +import CWinRT +import WinSDK + +public protocol Initializable { + init() +} + +public protocol HasIID { + static var IID: WindowsFoundation.IID { get } +} + +public protocol AbiInterface { + associatedtype CABI + associatedtype SwiftABI : WindowsFoundation.IUnknown +} + +// A protocol for defining a type which implements a WinRT interface and defines +// the swift <-> winrt translation. Note that AbiBridge doesn't depend on the SwiftABI, +// this is because not all conversions between the ABI and Swift have a SwiftABI implementation. +// For example, IReference does not since those types are projected to T? in Swift. +public protocol AbiBridge { + associatedtype CABI + associatedtype SwiftProjection + static func makeAbi() -> CABI + static func from(abi: ComPtr?) -> SwiftProjection? +} + +public protocol ReferenceBridge : AbiBridge, HasIID { +} + +public protocol AbiInterfaceBridge : AbiBridge & AbiInterface { +} + +public protocol AbiInterfaceImpl { + associatedtype Bridge: AbiInterfaceBridge + var _default: Bridge.SwiftABI { get } +} + +@_spi(WinRTInternal) +extension AbiInterfaceImpl { + public func getInterfaceForCaching() -> T { + return try! _default.QueryInterface() + } +} + +internal typealias AnyAbiInterfaceImpl = any AbiInterfaceImpl +public protocol WinRTAbiImpl: AbiInterfaceImpl where Bridge.SwiftABI: IInspectable {} +internal typealias AnyWinRTAbiImpl = any WinRTAbiImpl + +internal protocol CustomAddRef { + func addRef() + func release() +} + +// The WinRTWrapperBase class wraps an AbiBridge and is used for wrapping and unwrapping swift +// objects at the ABI layer. The contract for how to do this is defined by the AbiBridge protocol +open class WinRTWrapperBase { + public struct ComObjectABI { + public var comInterface: CInterface + public var wrapper: Unmanaged? + } + + public var instance: ComObjectABI + public var swiftObj: Prototype! + + open class var IID: WindowsFoundation.IID { get { fatalError("not implemented") } } + + public init(_ pointer: CInterface, _ impl: Prototype!) { + self.instance = ComObjectABI(comInterface: pointer) + self.swiftObj = impl + self.instance.wrapper = Unmanaged.passUnretained(self) + } + + @_alwaysEmitIntoClient @inline(__always) + public func toABI(_ body: (UnsafeMutablePointer) throws -> ResultType) + throws -> ResultType { + + try withUnsafeMutablePointer(to:&instance.comInterface){ + return try body($0) + } + } + + @_alwaysEmitIntoClient @inline(__always) + public func copyTo(_ ptr: UnsafeMutablePointer?>?) { + guard let ptr else { return } + // Use toABI as derived classes may override this to get the ABI pointer of the swift + // object they are holding onto + let abi: UnsafeMutablePointer = try! toABI { $0 } + abi.withMemoryRebound(to: C_IUnknown.self, capacity: 1) { + _ = $0.pointee.lpVtbl.pointee.AddRef($0) + } + + ptr.initialize(to: abi) + } + + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + // Use toABI as derived classes may override this to get the ABI pointer of the swift + // object they are holding onto + try! toABI { + $0.withMemoryRebound(to: C_IUnknown.self, capacity: 1) { pThis in + var iid = iid + let (ptr) = try? ComPtrs.initialize(to: C_IUnknown.self) { ptrAbi in + try CHECKED(pThis.pointee.lpVtbl.pointee.QueryInterface(pThis, &iid, &ptrAbi)) + } + guard let ptr else { return nil } + return IUnknownRef(ptr) + } + } + } + + public static func fromRaw(_ pUnk: UnsafeMutableRawPointer?) -> Unmanaged? { + guard let pUnk = pUnk else { return nil } + return pUnk.assumingMemoryBound(to: WinRTWrapperBase.ComObjectABI.self).pointee.wrapper + } + + internal static func tryUnwrapFromBase(raw pUnk: UnsafeMutableRawPointer?) -> Prototype? { + guard let pUnk = pUnk else { return nil } + return fromRaw(pUnk)?.takeUnretainedValue().swiftObj + } + + // When unwrapping from the abi, we want to see if the object has an existing implementation so we can use + // that to get to the existing swift object. if it doesn't exist then we can create a new implementation + public static func tryUnwrapFrom(abi pointer: ComPtr?) -> Prototype? { + guard let pointer = pointer else { return nil } + guard let wrapper: ISwiftImplemented = try? pointer.queryInterface() else { return nil } + let pUnk = UnsafeMutableRawPointer(wrapper.pUnk.borrow) + + // try to get the original wrapper so we can get the apps implementation. if that doesn't + // exist, then return nil + guard let wrapper = pUnk.bindMemory(to: WinRTWrapperBase.ComObjectABI.self, capacity: 1).pointee.wrapper else { return nil } + return wrapper.takeUnretainedValue().swiftObj + } + + public static func addRef(_ pUnk: UnsafeMutablePointer?) -> ULONG { + guard let unmanaged = fromRaw(pUnk) else { return 1 } + let wrapper = unmanaged.takeUnretainedValue() + _ = unmanaged.retain() + + if let customAddRef = wrapper.swiftObj as? CustomAddRef { + customAddRef.addRef() + } + return ULONG(_getRetainCount(wrapper)) + } + + public static func release(_ pUnk: UnsafeMutablePointer?) -> ULONG { + guard let unmanaged = fromRaw(pUnk) else { return 1 } + let wrapper = unmanaged.takeUnretainedValue() + unmanaged.release() + + if let customAddRef = wrapper.swiftObj as? CustomAddRef { + customAddRef.release() + } + return ULONG(_getRetainCount(wrapper)) + } + + fileprivate static func queryInterfaceBase(_ pUnk: UnsafeMutablePointer, _ riid: UnsafePointer, _ result: UnsafeMutablePointer) -> HRESULT { + guard let instance = tryUnwrapFromBase(raw: pUnk) else { return E_FAIL } + do + { + switch riid.pointee { + case IID_IMarshal: + try makeMarshaler(IUnknownRef(ComPtr(pUnk)), result) + default: + guard let customQI = instance as? CustomQueryInterface, + let iUnknownRef = customQI.queryInterface(riid.pointee) else { return E_NOINTERFACE } + result.pointee = iUnknownRef.detach() + } + return S_OK + } catch { + return (error as? WindowsFoundation.Error)?.hr ?? E_FAIL + } + } +} + +open class WinRTAbiBridgeWrapper : WinRTWrapperBase { + + public static func unwrapFrom(abi pointer: ComPtr?) -> I.SwiftProjection? { + guard let pointer = pointer else { return nil } + guard let unwrapped = tryUnwrapFrom(abi: pointer) else { return I.from(abi: pointer) } + return unwrapped + } + + open class func queryInterface(_ pUnk: UnsafeMutablePointer?, _ riid: UnsafePointer?, _ ppvObject: UnsafeMutablePointer?) -> HRESULT { + guard let pUnk, let riid, let ppvObject else { return E_INVALIDARG } + ppvObject.pointee = nil + switch riid.pointee { + case IUnknown.IID, IInspectable.IID, ISwiftImplemented.IID, IAgileObject.IID, Self.IID: + _ = addRef(pUnk) + ppvObject.pointee = UnsafeMutableRawPointer(pUnk) + return S_OK + default: + return super.queryInterfaceBase(pUnk, riid, ppvObject) + } + } +} + +open class InterfaceWrapperBase : WinRTAbiBridgeWrapper { + override public class var IID: WindowsFoundation.IID { I.SwiftABI.IID } + public init?(_ impl: I.SwiftProjection?) { + guard let impl = impl else { return nil } + // try to see if already wrapping an ABI pointer and if so, use that + if let internalImpl = impl as? AnyAbiInterfaceImpl { + let abi: UnsafeMutablePointer = RawPointer(internalImpl) + super.init(abi.pointee, impl) + } else { + let abi = I.makeAbi() + super.init(abi, impl) + } + } + + override public func toABI(_ body: (UnsafeMutablePointer) throws -> ResultType) + throws -> ResultType { + // If this is an implementation then we're holding onto a WinRT object pointer, get that pointer + // and return that. + if let internalImpl = swiftObj as? AnyAbiInterfaceImpl { + let abi: UnsafeMutablePointer = RawPointer(internalImpl._default) + return try body(abi) + } else { + return try super.toABI(body) + } + } + + public static func tryUnwrapFrom(raw pUnk: UnsafeMutableRawPointer?) -> I.SwiftProjection? { + tryUnwrapFromBase(raw: pUnk) + } +} + +public class ReferenceWrapperBase: WinRTAbiBridgeWrapper { + override public class var IID: WindowsFoundation.IID { I.IID } + + public init?(_ value: I.SwiftProjection?) { + guard let value = value else { return nil } + let abi = I.makeAbi() + super.init(abi, value) + } + + override public class func queryInterface(_ pUnk: UnsafeMutablePointer?, _ riid: UnsafePointer?, _ ppvObject: UnsafeMutablePointer?) -> HRESULT { + guard let pUnk, let riid, let ppvObject else { return E_INVALIDARG } + ppvObject.pointee = nil + switch riid.pointee { + case __ABI_Windows_Foundation.IPropertyValueWrapper.IID: + guard let value = tryUnwrapFrom(raw: pUnk), + let wrapper = __ABI_Windows_Foundation.IPropertyValueWrapper(__IMPL_Windows_Foundation.IPropertyValueImpl(value: value)) else { return E_FAIL } + guard let iUnk = wrapper.queryInterface(__ABI_Windows_Foundation.IPropertyValueWrapper.IID) else { return E_NOINTERFACE } + ppvObject.pointee = iUnk.detach() + return S_OK + default: + return super.queryInterface(pUnk, riid, ppvObject) + } + } + + public static func tryUnwrapFrom(raw pUnk: UnsafeMutableRawPointer?) -> I.SwiftProjection? { + tryUnwrapFromBase(raw: pUnk) + } +} \ No newline at end of file diff --git a/Sources/WindowsFoundation/Generated/Support/WINSDK+EXTENSIONS.swift b/Sources/WindowsFoundation/Generated/Support/WINSDK+EXTENSIONS.swift new file mode 100644 index 0000000..0964dc7 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Support/WINSDK+EXTENSIONS.swift @@ -0,0 +1,39 @@ +// Copyright © 2021 Saleem Abdulrasool +// SPDX-License-Identifier: BSD-3 + +import WinSDK + +public typealias LPVOID = UnsafeMutableRawPointer + +// winnt.h + +@_transparent +internal func MAKELANGID(_ p: WORD, _ s: WORD) -> DWORD { + return DWORD((s << 10) | p) +} + +extension boolean { + public init(from val: Bool) { + let value : boolean = val ? 1 : 0 + self.init(value) + } +} + +extension HWND { + public init?(from val: UInt64) { + self.init(HWND(bitPattern: UInt(val))) + } +} + +extension WCHAR { + public init(from val: Character) { + // FIXME(compnerd) this needs to be a failable initializer as there may be a + // surrogate pair required. + self.init(val.utf16.first!) + } +} + +// stdlib.h +public var MB_MAX : Int { + Int(___mb_cur_max_func()) +} diff --git a/Sources/WindowsFoundation/Generated/Windows.Foundation+ABI.swift b/Sources/WindowsFoundation/Generated/Windows.Foundation+ABI.swift new file mode 100644 index 0000000..cf634bf --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Windows.Foundation+ABI.swift @@ -0,0 +1,1502 @@ +// WARNING: Please don't edit this file. It was generated by Swift/WinRT v0.0.1 +// swiftlint:disable all +import Foundation +import CWinRT + +private var IID___x_ABI_CWindows_CFoundation_CIAsyncAction: WindowsFoundation.IID { + .init(Data1: 0x5A648006, Data2: 0x843A, Data3: 0x4DA9, Data4: ( 0x86,0x5B,0x9D,0x26,0xE5,0xDF,0xAD,0x7B ))// 5A648006-843A-4DA9-865B-9D26E5DFAD7B +} + +private var IID___x_ABI_C__FIAsyncActionWithProgress_1_TProgress: WindowsFoundation.IID { + .init(Data1: 0x1F6DB258, Data2: 0xE803, Data3: 0x48A1, Data4: ( 0x95,0x46,0xEB,0x73,0x53,0x39,0x88,0x84 ))// 1F6DB258-E803-48A1-9546-EB7353398884 +} + +private var IID___x_ABI_CWindows_CFoundation_CIAsyncInfo: WindowsFoundation.IID { + .init(Data1: 0x00000036, Data2: 0x0000, Data3: 0x0000, Data4: ( 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 ))// 00000036-0000-0000-C000-000000000046 +} + +private var IID___x_ABI_C__FIAsyncOperationWithProgress_2_TResult_TProgress: WindowsFoundation.IID { + .init(Data1: 0xB5D036D7, Data2: 0xE297, Data3: 0x498F, Data4: ( 0xBA,0x60,0x02,0x89,0xE7,0x6E,0x23,0xDD ))// B5D036D7-E297-498F-BA60-0289E76E23DD +} + +private var IID___x_ABI_C__FIAsyncOperation_1_TResult: WindowsFoundation.IID { + .init(Data1: 0x9FC2B0BB, Data2: 0xE446, Data3: 0x44E2, Data4: ( 0xAA,0x61,0x9C,0xAB,0x8F,0x63,0x6A,0xF2 ))// 9FC2B0BB-E446-44E2-AA61-9CAB8F636AF2 +} + +private var IID___x_ABI_CWindows_CFoundation_CIClosable: WindowsFoundation.IID { + .init(Data1: 0x30D5A829, Data2: 0x7FA4, Data3: 0x4026, Data4: ( 0x83,0xBB,0xD7,0x5B,0xAE,0x4E,0xA9,0x9E ))// 30D5A829-7FA4-4026-83BB-D75BAE4EA99E +} + +private var IID___x_ABI_CWindows_CFoundation_CIDeferral: WindowsFoundation.IID { + .init(Data1: 0xD6269732, Data2: 0x3B7F, Data3: 0x46A7, Data4: ( 0xB4,0x0B,0x4F,0xDC,0xA2,0xA2,0xC6,0x93 ))// D6269732-3B7F-46A7-B40B-4FDCA2A2C693 +} + +private var IID___x_ABI_CWindows_CFoundation_CIDeferralFactory: WindowsFoundation.IID { + .init(Data1: 0x65A1ECC5, Data2: 0x3FB5, Data3: 0x4832, Data4: ( 0x8C,0xA9,0xF0,0x61,0xB2,0x81,0xD1,0x3A ))// 65A1ECC5-3FB5-4832-8CA9-F061B281D13A +} + +private var IID___x_ABI_CWindows_CFoundation_CIGetActivationFactory: WindowsFoundation.IID { + .init(Data1: 0x4EDB8EE2, Data2: 0x96DD, Data3: 0x49A7, Data4: ( 0x94,0xF7,0x46,0x07,0xDD,0xAB,0x8E,0x3C ))// 4EDB8EE2-96DD-49A7-94F7-4607DDAB8E3C +} + +private var IID___x_ABI_CWindows_CFoundation_CIGuidHelperStatics: WindowsFoundation.IID { + .init(Data1: 0x59C7966B, Data2: 0xAE52, Data3: 0x5283, Data4: ( 0xAD,0x7F,0xA1,0xB9,0xE9,0x67,0x8A,0xDD ))// 59C7966B-AE52-5283-AD7F-A1B9E9678ADD +} + +private var IID___x_ABI_CWindows_CFoundation_CIMemoryBuffer: WindowsFoundation.IID { + .init(Data1: 0xFBC4DD2A, Data2: 0x245B, Data3: 0x11E4, Data4: ( 0xAF,0x98,0x68,0x94,0x23,0x26,0x0C,0xF8 ))// FBC4DD2A-245B-11E4-AF98-689423260CF8 +} + +private var IID___x_ABI_CWindows_CFoundation_CIMemoryBufferFactory: WindowsFoundation.IID { + .init(Data1: 0xFBC4DD2B, Data2: 0x245B, Data3: 0x11E4, Data4: ( 0xAF,0x98,0x68,0x94,0x23,0x26,0x0C,0xF8 ))// FBC4DD2B-245B-11E4-AF98-689423260CF8 +} + +private var IID___x_ABI_CWindows_CFoundation_CIMemoryBufferReference: WindowsFoundation.IID { + .init(Data1: 0xFBC4DD29, Data2: 0x245B, Data3: 0x11E4, Data4: ( 0xAF,0x98,0x68,0x94,0x23,0x26,0x0C,0xF8 ))// FBC4DD29-245B-11E4-AF98-689423260CF8 +} + +private var IID___x_ABI_CWindows_CFoundation_CIPropertyValue: WindowsFoundation.IID { + .init(Data1: 0x4BD682DD, Data2: 0x7554, Data3: 0x40E9, Data4: ( 0x9A,0x9B,0x82,0x65,0x4E,0xDE,0x7E,0x62 ))// 4BD682DD-7554-40E9-9A9B-82654EDE7E62 +} + +private var IID___x_ABI_CWindows_CFoundation_CIPropertyValueStatics: WindowsFoundation.IID { + .init(Data1: 0x629BDBC8, Data2: 0xD932, Data3: 0x4FF4, Data4: ( 0x96,0xB9,0x8D,0x96,0xC5,0xC1,0xE8,0x58 ))// 629BDBC8-D932-4FF4-96B9-8D96C5C1E858 +} + +private var IID___x_ABI_C__FIReferenceArray_1_T: WindowsFoundation.IID { + .init(Data1: 0x61C17707, Data2: 0x2D65, Data3: 0x11E0, Data4: ( 0x9A,0xE8,0xD4,0x85,0x64,0x01,0x54,0x72 ))// 61C17707-2D65-11E0-9AE8-D48564015472 +} + +private var IID___x_ABI_C__FIReference_1_T: WindowsFoundation.IID { + .init(Data1: 0x61C17706, Data2: 0x2D65, Data3: 0x11E0, Data4: ( 0x9A,0xE8,0xD4,0x85,0x64,0x01,0x54,0x72 ))// 61C17706-2D65-11E0-9AE8-D48564015472 +} + +private var IID___x_ABI_CWindows_CFoundation_CIStringable: WindowsFoundation.IID { + .init(Data1: 0x96369F54, Data2: 0x8EB6, Data3: 0x48F0, Data4: ( 0xAB,0xCE,0xC1,0xB2,0x11,0xE6,0x27,0xC3 ))// 96369F54-8EB6-48F0-ABCE-C1B211E627C3 +} + +private var IID___x_ABI_CWindows_CFoundation_CIUriEscapeStatics: WindowsFoundation.IID { + .init(Data1: 0xC1D432BA, Data2: 0xC824, Data3: 0x4452, Data4: ( 0xA7,0xFD,0x51,0x2B,0xC3,0xBB,0xE9,0xA1 ))// C1D432BA-C824-4452-A7FD-512BC3BBE9A1 +} + +private var IID___x_ABI_CWindows_CFoundation_CIUriRuntimeClass: WindowsFoundation.IID { + .init(Data1: 0x9E365E57, Data2: 0x48B2, Data3: 0x4160, Data4: ( 0x95,0x6F,0xC7,0x38,0x51,0x20,0xBB,0xFC ))// 9E365E57-48B2-4160-956F-C7385120BBFC +} + +private var IID___x_ABI_CWindows_CFoundation_CIUriRuntimeClassFactory: WindowsFoundation.IID { + .init(Data1: 0x44A9796F, Data2: 0x723E, Data3: 0x4FDF, Data4: ( 0xA2,0x18,0x03,0x3E,0x75,0xB0,0xC0,0x84 ))// 44A9796F-723E-4FDF-A218-033E75B0C084 +} + +private var IID___x_ABI_CWindows_CFoundation_CIUriRuntimeClassWithAbsoluteCanonicalUri: WindowsFoundation.IID { + .init(Data1: 0x758D9661, Data2: 0x221C, Data3: 0x480F, Data4: ( 0xA3,0x39,0x50,0x65,0x66,0x73,0xF4,0x6F ))// 758D9661-221C-480F-A339-50656673F46F +} + +private var IID___x_ABI_CWindows_CFoundation_CIWwwFormUrlDecoderEntry: WindowsFoundation.IID { + .init(Data1: 0x125E7431, Data2: 0xF678, Data3: 0x4E8E, Data4: ( 0xB6,0x70,0x20,0xA9,0xB0,0x6C,0x51,0x2D ))// 125E7431-F678-4E8E-B670-20A9B06C512D +} + +private var IID___x_ABI_CWindows_CFoundation_CIWwwFormUrlDecoderRuntimeClass: WindowsFoundation.IID { + .init(Data1: 0xD45A0451, Data2: 0xF225, Data3: 0x4542, Data4: ( 0x92,0x96,0x0E,0x1D,0xF5,0xD2,0x54,0xDF ))// D45A0451-F225-4542-9296-0E1DF5D254DF +} + +private var IID___x_ABI_CWindows_CFoundation_CIWwwFormUrlDecoderRuntimeClassFactory: WindowsFoundation.IID { + .init(Data1: 0x5B8C6B3D, Data2: 0x24AE, Data3: 0x41B5, Data4: ( 0xA1,0xBF,0xF0,0xC3,0xD5,0x44,0x84,0x5B ))// 5B8C6B3D-24AE-41B5-A1BF-F0C3D544845B +} + +private var IID___x_ABI_CWindows_CFoundation_CIAsyncActionCompletedHandler: WindowsFoundation.IID { + .init(Data1: 0xA4ED5C81, Data2: 0x76C9, Data3: 0x40BD, Data4: ( 0x8B,0xE6,0xB1,0xD9,0x0F,0xB2,0x0A,0xE7 ))// A4ED5C81-76C9-40BD-8BE6-B1D90FB20AE7 +} + +private var IID___x_ABI_C__FIAsyncActionProgressHandler_1_TProgress: WindowsFoundation.IID { + .init(Data1: 0x6D844858, Data2: 0x0CFF, Data3: 0x4590, Data4: ( 0xAE,0x89,0x95,0xA5,0xA5,0xC8,0xB4,0xB8 ))// 6D844858-0CFF-4590-AE89-95A5A5C8B4B8 +} + +private var IID___x_ABI_C__FIAsyncActionWithProgressCompletedHandler_1_TProgress: WindowsFoundation.IID { + .init(Data1: 0x9C029F91, Data2: 0xCC84, Data3: 0x44FD, Data4: ( 0xAC,0x26,0x0A,0x6C,0x4E,0x55,0x52,0x81 ))// 9C029F91-CC84-44FD-AC26-0A6C4E555281 +} + +private var IID___x_ABI_C__FIAsyncOperationCompletedHandler_1_TResult: WindowsFoundation.IID { + .init(Data1: 0xFCDCF02C, Data2: 0xE5D8, Data3: 0x4478, Data4: ( 0x91,0x5A,0x4D,0x90,0xB7,0x4B,0x83,0xA5 ))// FCDCF02C-E5D8-4478-915A-4D90B74B83A5 +} + +private var IID___x_ABI_C__FIAsyncOperationProgressHandler_2_TResult_TProgress: WindowsFoundation.IID { + .init(Data1: 0x55690902, Data2: 0x0AAB, Data3: 0x421A, Data4: ( 0x87,0x78,0xF8,0xCE,0x50,0x26,0xD7,0x58 ))// 55690902-0AAB-421A-8778-F8CE5026D758 +} + +private var IID___x_ABI_C__FIAsyncOperationWithProgressCompletedHandler_2_TResult_TProgress: WindowsFoundation.IID { + .init(Data1: 0xE85DF41D, Data2: 0x6AA7, Data3: 0x46E3, Data4: ( 0xA8,0xE2,0xF0,0x09,0xD8,0x40,0xC6,0x27 ))// E85DF41D-6AA7-46E3-A8E2-F009D840C627 +} + +private var IID___x_ABI_CWindows_CFoundation_CIDeferralCompletedHandler: WindowsFoundation.IID { + .init(Data1: 0xED32A372, Data2: 0xF3C8, Data3: 0x4FAA, Data4: ( 0x9C,0xFB,0x47,0x01,0x48,0xDA,0x38,0x88 ))// ED32A372-F3C8-4FAA-9CFB-470148DA3888 +} + +private var IID___x_ABI_C__FIEventHandler_1_T: WindowsFoundation.IID { + .init(Data1: 0x9DE1C535, Data2: 0x6AE1, Data3: 0x11E0, Data4: ( 0x84,0xE1,0x18,0xA9,0x05,0xBC,0xC5,0x3F ))// 9DE1C535-6AE1-11E0-84E1-18A905BCC53F +} + +private var IID___x_ABI_C__FITypedEventHandler_2_TSender_TResult: WindowsFoundation.IID { + .init(Data1: 0x9DE1C534, Data2: 0x6AE1, Data3: 0x11E0, Data4: ( 0x84,0xE1,0x18,0xA9,0x05,0xBC,0xC5,0x3F ))// 9DE1C534-6AE1-11E0-84E1-18A905BCC53F +} + +public enum __ABI_Windows_Foundation { + public class IAsyncAction: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIAsyncAction } + + open func put_CompletedImpl(_ handler: WindowsFoundation.AsyncActionCompletedHandler?) throws { + let handlerWrapper = __ABI_Windows_Foundation.AsyncActionCompletedHandlerWrapper(handler) + let _handler = try! handlerWrapper?.toABI { $0 } + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIAsyncAction.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.put_Completed(pThis, _handler)) + } + } + + open func get_CompletedImpl() throws -> WindowsFoundation.AsyncActionCompletedHandler? { + let (handler) = try ComPtrs.initialize { handlerAbi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIAsyncAction.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Completed(pThis, &handlerAbi)) + } + } + return __ABI_Windows_Foundation.AsyncActionCompletedHandlerWrapper.unwrapFrom(abi: handler) + } + + open func GetResultsImpl() throws { + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIAsyncAction.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetResults(pThis)) + } + } + + } + + internal static var IAsyncActionVTable: __x_ABI_CWindows_CFoundation_CIAsyncActionVtbl = .init( + QueryInterface: { IAsyncActionWrapper.queryInterface($0, $1, $2) }, + AddRef: { IAsyncActionWrapper.addRef($0) }, + Release: { IAsyncActionWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 4).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = __ABI_Windows_Foundation.IAsyncActionWrapper.IID + iids[3] = __ABI_Windows_Foundation.IAsyncInfoWrapper.IID + $1!.pointee = 4 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.IAsyncAction").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + put_Completed: { + guard let __unwrapped__instance = IAsyncActionWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + guard let handler = __ABI_Windows_Foundation.AsyncActionCompletedHandlerWrapper.unwrapFrom(abi: ComPtr($1)) else { return E_INVALIDARG } + __unwrapped__instance.completed = handler + return S_OK + }, + + get_Completed: { + guard let __unwrapped__instance = IAsyncActionWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let handler = __unwrapped__instance.completed + let handlerWrapper = __ABI_Windows_Foundation.AsyncActionCompletedHandlerWrapper(handler) + handlerWrapper?.copyTo($1) + return S_OK + }, + + GetResults: { + do { + guard let __unwrapped__instance = IAsyncActionWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + try __unwrapped__instance.getResults() + return S_OK + } catch { return failWith(err: E_FAIL) } + } + ) + + public typealias IAsyncActionWrapper = InterfaceWrapperBase<__IMPL_Windows_Foundation.IAsyncActionBridge> + public class IAsyncInfo: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIAsyncInfo } + + open func get_IdImpl() throws -> UInt32 { + var result: UINT32 = 0 + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIAsyncInfo.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Id(pThis, &result)) + } + return result + } + + open func get_StatusImpl() throws -> WindowsFoundation.AsyncStatus { + var result: __x_ABI_CWindows_CFoundation_CAsyncStatus = .init(0) + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIAsyncInfo.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Status(pThis, &result)) + } + return result + } + + open func get_ErrorCodeImpl() throws -> HRESULT { + var result: HRESULT = 0 + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIAsyncInfo.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_ErrorCode(pThis, &result)) + } + return result + } + + open func CancelImpl() throws { + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIAsyncInfo.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Cancel(pThis)) + } + } + + open func CloseImpl() throws { + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIAsyncInfo.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Close(pThis)) + } + } + + } + + internal static var IAsyncInfoVTable: __x_ABI_CWindows_CFoundation_CIAsyncInfoVtbl = .init( + QueryInterface: { IAsyncInfoWrapper.queryInterface($0, $1, $2) }, + AddRef: { IAsyncInfoWrapper.addRef($0) }, + Release: { IAsyncInfoWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 3).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = __ABI_Windows_Foundation.IAsyncInfoWrapper.IID + $1!.pointee = 3 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.IAsyncInfo").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + get_Id: { + guard let __unwrapped__instance = IAsyncInfoWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.id + $1?.initialize(to: result) + return S_OK + }, + + get_Status: { + guard let __unwrapped__instance = IAsyncInfoWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.status + $1?.initialize(to: result) + return S_OK + }, + + get_ErrorCode: { + guard let __unwrapped__instance = IAsyncInfoWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.errorCode + $1?.initialize(to: result) + return S_OK + }, + + Cancel: { + do { + guard let __unwrapped__instance = IAsyncInfoWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + try __unwrapped__instance.cancel() + return S_OK + } catch { return failWith(err: E_FAIL) } + }, + + Close: { + do { + guard let __unwrapped__instance = IAsyncInfoWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + try __unwrapped__instance.close() + return S_OK + } catch { return failWith(err: E_FAIL) } + } + ) + + public typealias IAsyncInfoWrapper = InterfaceWrapperBase<__IMPL_Windows_Foundation.IAsyncInfoBridge> + public class IClosable: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIClosable } + + open func CloseImpl() throws { + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIClosable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Close(pThis)) + } + } + + } + + internal static var IClosableVTable: __x_ABI_CWindows_CFoundation_CIClosableVtbl = .init( + QueryInterface: { IClosableWrapper.queryInterface($0, $1, $2) }, + AddRef: { IClosableWrapper.addRef($0) }, + Release: { IClosableWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 3).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = __ABI_Windows_Foundation.IClosableWrapper.IID + $1!.pointee = 3 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.IClosable").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + Close: { + do { + guard let __unwrapped__instance = IClosableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + try __unwrapped__instance.close() + return S_OK + } catch { return failWith(err: E_FAIL) } + } + ) + + public typealias IClosableWrapper = InterfaceWrapperBase<__IMPL_Windows_Foundation.IClosableBridge> + public class IDeferral: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIDeferral } + + internal func CompleteImpl() throws { + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIDeferral.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Complete(pThis)) + } + } + + } + + public class IDeferralFactory: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIDeferralFactory } + + internal func CreateImpl(_ handler: WindowsFoundation.DeferralCompletedHandler?) throws -> IDeferral { + let (result) = try ComPtrs.initialize { resultAbi in + let handlerWrapper = __ABI_Windows_Foundation.DeferralCompletedHandlerWrapper(handler) + let _handler = try! handlerWrapper?.toABI { $0 } + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIDeferralFactory.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Create(pThis, _handler, &resultAbi)) + } + } + return IDeferral(result!) + } + + } + + public class IGetActivationFactory: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIGetActivationFactory } + + open func GetActivationFactoryImpl(_ activatableClassId: String) throws -> Any? { + let (factory) = try ComPtrs.initialize { factoryAbi in + let _activatableClassId = try! HString(activatableClassId) + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIGetActivationFactory.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetActivationFactory(pThis, _activatableClassId.get(), &factoryAbi)) + } + } + return __ABI_.AnyWrapper.unwrapFrom(abi: factory) + } + + } + + internal static var IGetActivationFactoryVTable: __x_ABI_CWindows_CFoundation_CIGetActivationFactoryVtbl = .init( + QueryInterface: { IGetActivationFactoryWrapper.queryInterface($0, $1, $2) }, + AddRef: { IGetActivationFactoryWrapper.addRef($0) }, + Release: { IGetActivationFactoryWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 3).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = __ABI_Windows_Foundation.IGetActivationFactoryWrapper.IID + $1!.pointee = 3 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.IGetActivationFactory").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + GetActivationFactory: { + do { + guard let __unwrapped__instance = IGetActivationFactoryWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let activatableClassId: String = .init(from: $1) + let factory = try __unwrapped__instance.getActivationFactory(activatableClassId) + let factoryWrapper = __ABI_.AnyWrapper(factory) + factoryWrapper?.copyTo($2) + return S_OK + } catch { return failWith(err: E_FAIL) } + } + ) + + public typealias IGetActivationFactoryWrapper = InterfaceWrapperBase<__IMPL_Windows_Foundation.IGetActivationFactoryBridge> + public class IGuidHelperStatics: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIGuidHelperStatics } + + internal func CreateNewGuidImpl() throws -> Foundation.UUID { + var result: WindowsFoundation.GUID = .init() + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIGuidHelperStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateNewGuid(pThis, &result)) + } + return .init(from: result) + } + + internal func get_EmptyImpl() throws -> Foundation.UUID { + var value: WindowsFoundation.GUID = .init() + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIGuidHelperStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Empty(pThis, &value)) + } + return .init(from: value) + } + + } + + public class IMemoryBuffer: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIMemoryBuffer } + + open func CreateReferenceImpl() throws -> WindowsFoundation.AnyIMemoryBufferReference? { + let (reference) = try ComPtrs.initialize { referenceAbi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIMemoryBuffer.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateReference(pThis, &referenceAbi)) + } + } + return __ABI_Windows_Foundation.IMemoryBufferReferenceWrapper.unwrapFrom(abi: reference) + } + + } + + internal static var IMemoryBufferVTable: __x_ABI_CWindows_CFoundation_CIMemoryBufferVtbl = .init( + QueryInterface: { IMemoryBufferWrapper.queryInterface($0, $1, $2) }, + AddRef: { IMemoryBufferWrapper.addRef($0) }, + Release: { IMemoryBufferWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 4).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = __ABI_Windows_Foundation.IMemoryBufferWrapper.IID + iids[3] = __ABI_Windows_Foundation.IClosableWrapper.IID + $1!.pointee = 4 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.IMemoryBuffer").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + CreateReference: { + do { + guard let __unwrapped__instance = IMemoryBufferWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let reference = try __unwrapped__instance.createReference() + let referenceWrapper = __ABI_Windows_Foundation.IMemoryBufferReferenceWrapper(reference) + referenceWrapper?.copyTo($1) + return S_OK + } catch { return failWith(err: E_FAIL) } + } + ) + + public typealias IMemoryBufferWrapper = InterfaceWrapperBase<__IMPL_Windows_Foundation.IMemoryBufferBridge> + public class IMemoryBufferFactory: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIMemoryBufferFactory } + + internal func CreateImpl(_ capacity: UInt32) throws -> IMemoryBuffer { + let (value) = try ComPtrs.initialize { valueAbi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIMemoryBufferFactory.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Create(pThis, capacity, &valueAbi)) + } + } + return IMemoryBuffer(value!) + } + + } + + public class IMemoryBufferReference: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIMemoryBufferReference } + + open func get_CapacityImpl() throws -> UInt32 { + var value: UINT32 = 0 + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIMemoryBufferReference.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Capacity(pThis, &value)) + } + return value + } + + open func add_ClosedImpl(_ handler: TypedEventHandler?) throws -> EventRegistrationToken { + var cookie: EventRegistrationToken = .init() + let handlerWrapper = WindowsFoundation.__x_ABI_C__FITypedEventHandler_2___x_ABI_CWindows__CFoundation__CIMemoryBufferReference_IInspectableWrapper(handler) + let _handler = try! handlerWrapper?.toABI { $0 } + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIMemoryBufferReference.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.add_Closed(pThis, _handler, &cookie)) + } + return cookie + } + + open func remove_ClosedImpl(_ cookie: EventRegistrationToken) throws { + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIMemoryBufferReference.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.remove_Closed(pThis, cookie)) + } + } + + } + + internal static var IMemoryBufferReferenceVTable: __x_ABI_CWindows_CFoundation_CIMemoryBufferReferenceVtbl = .init( + QueryInterface: { IMemoryBufferReferenceWrapper.queryInterface($0, $1, $2) }, + AddRef: { IMemoryBufferReferenceWrapper.addRef($0) }, + Release: { IMemoryBufferReferenceWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 5).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = __ABI_Windows_Foundation.IMemoryBufferReferenceWrapper.IID + iids[3] = __ABI_Windows_Foundation.IClosableWrapper.IID + iids[4] = __ABI_.IMemoryBufferByteAccessWrapper.IID + $1!.pointee = 5 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.IMemoryBufferReference").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + get_Capacity: { + guard let __unwrapped__instance = IMemoryBufferReferenceWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = __unwrapped__instance.capacity + $1?.initialize(to: value) + return S_OK + }, + + add_Closed: { + guard let __unwrapped__instance = IMemoryBufferReferenceWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + guard let handler = WindowsFoundation.__x_ABI_C__FITypedEventHandler_2___x_ABI_CWindows__CFoundation__CIMemoryBufferReference_IInspectableWrapper.unwrapFrom(abi: ComPtr($1)) else { return E_INVALIDARG } + let cookie = __unwrapped__instance.closed.addHandler(handler) + $2?.initialize(to: .from(swift: cookie)) + return S_OK + }, + + remove_Closed: { + guard let __unwrapped__instance = IMemoryBufferReferenceWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let cookie: EventRegistrationToken = $1 + __unwrapped__instance.closed.removeHandler(cookie) + return S_OK + } + ) + + public typealias IMemoryBufferReferenceWrapper = InterfaceWrapperBase<__IMPL_Windows_Foundation.IMemoryBufferReferenceBridge> + public class IPropertyValue: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIPropertyValue } + + open func get_TypeImpl() throws -> WindowsFoundation.PropertyType { + var value: __x_ABI_CWindows_CFoundation_CPropertyType = .init(0) + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValue.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Type(pThis, &value)) + } + return value + } + + open func get_IsNumericScalarImpl() throws -> Bool { + var value: boolean = 0 + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValue.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_IsNumericScalar(pThis, &value)) + } + return .init(from: value) + } + + open func GetUInt8Impl() throws -> UInt8 { + var value: UINT8 = 0 + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValue.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetUInt8(pThis, &value)) + } + return value + } + + open func GetInt16Impl() throws -> Int16 { + var value: INT16 = 0 + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValue.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetInt16(pThis, &value)) + } + return value + } + + open func GetUInt16Impl() throws -> UInt16 { + var value: UINT16 = 0 + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValue.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetUInt16(pThis, &value)) + } + return value + } + + open func GetInt32Impl() throws -> Int32 { + var value: INT32 = 0 + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValue.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetInt32(pThis, &value)) + } + return value + } + + open func GetUInt32Impl() throws -> UInt32 { + var value: UINT32 = 0 + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValue.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetUInt32(pThis, &value)) + } + return value + } + + open func GetInt64Impl() throws -> Int64 { + var value: INT64 = 0 + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValue.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetInt64(pThis, &value)) + } + return value + } + + open func GetUInt64Impl() throws -> UInt64 { + var value: UINT64 = 0 + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValue.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetUInt64(pThis, &value)) + } + return value + } + + open func GetSingleImpl() throws -> Float { + var value: FLOAT = 0.0 + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValue.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetSingle(pThis, &value)) + } + return value + } + + open func GetDoubleImpl() throws -> Double { + var value: DOUBLE = 0.0 + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValue.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetDouble(pThis, &value)) + } + return value + } + + open func GetChar16Impl() throws -> Character { + var value: WCHAR = 0 + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValue.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetChar16(pThis, &value)) + } + return .init(from: value) + } + + open func GetBooleanImpl() throws -> Bool { + var value: boolean = 0 + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValue.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetBoolean(pThis, &value)) + } + return .init(from: value) + } + + open func GetStringImpl() throws -> String { + var value: HSTRING? + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValue.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetString(pThis, &value)) + } + return .init(from: value) + } + + open func GetGuidImpl() throws -> Foundation.UUID { + var value: WindowsFoundation.GUID = .init() + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValue.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetGuid(pThis, &value)) + } + return .init(from: value) + } + + open func GetDateTimeImpl() throws -> WindowsFoundation.DateTime { + var value: __x_ABI_CWindows_CFoundation_CDateTime = .init() + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValue.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetDateTime(pThis, &value)) + } + return .from(abi: value) + } + + open func GetTimeSpanImpl() throws -> WindowsFoundation.TimeSpan { + var value: __x_ABI_CWindows_CFoundation_CTimeSpan = .init() + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValue.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetTimeSpan(pThis, &value)) + } + return .from(abi: value) + } + + open func GetPointImpl() throws -> WindowsFoundation.Point { + var value: __x_ABI_CWindows_CFoundation_CPoint = .init() + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValue.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetPoint(pThis, &value)) + } + return .from(abi: value) + } + + open func GetSizeImpl() throws -> WindowsFoundation.Size { + var value: __x_ABI_CWindows_CFoundation_CSize = .init() + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValue.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetSize(pThis, &value)) + } + return .from(abi: value) + } + + open func GetRectImpl() throws -> WindowsFoundation.Rect { + var value: __x_ABI_CWindows_CFoundation_CRect = .init() + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIPropertyValue.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetRect(pThis, &value)) + } + return .from(abi: value) + } + + } + + internal static var IPropertyValueVTable: __x_ABI_CWindows_CFoundation_CIPropertyValueVtbl = .init( + QueryInterface: { IPropertyValueWrapper.queryInterface($0, $1, $2) }, + AddRef: { IPropertyValueWrapper.addRef($0) }, + Release: { IPropertyValueWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 3).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = __ABI_Windows_Foundation.IPropertyValueWrapper.IID + $1!.pointee = 3 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.IPropertyValue").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + get_Type: { + guard let __unwrapped__instance = IPropertyValueWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = __unwrapped__instance.type + $1?.initialize(to: value) + return S_OK + }, + + get_IsNumericScalar: { + guard let __unwrapped__instance = IPropertyValueWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = __unwrapped__instance.isNumericScalar + $1?.initialize(to: .init(from: value)) + return S_OK + }, + + GetUInt8: { + do { + guard let __unwrapped__instance = IPropertyValueWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = try __unwrapped__instance.getUInt8() + $1?.initialize(to: value) + return S_OK + } catch { return failWith(err: E_FAIL) } + }, + + GetInt16: { + do { + guard let __unwrapped__instance = IPropertyValueWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = try __unwrapped__instance.getInt16() + $1?.initialize(to: value) + return S_OK + } catch { return failWith(err: E_FAIL) } + }, + + GetUInt16: { + do { + guard let __unwrapped__instance = IPropertyValueWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = try __unwrapped__instance.getUInt16() + $1?.initialize(to: value) + return S_OK + } catch { return failWith(err: E_FAIL) } + }, + + GetInt32: { + do { + guard let __unwrapped__instance = IPropertyValueWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = try __unwrapped__instance.getInt32() + $1?.initialize(to: value) + return S_OK + } catch { return failWith(err: E_FAIL) } + }, + + GetUInt32: { + do { + guard let __unwrapped__instance = IPropertyValueWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = try __unwrapped__instance.getUInt32() + $1?.initialize(to: value) + return S_OK + } catch { return failWith(err: E_FAIL) } + }, + + GetInt64: { + do { + guard let __unwrapped__instance = IPropertyValueWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = try __unwrapped__instance.getInt64() + $1?.initialize(to: value) + return S_OK + } catch { return failWith(err: E_FAIL) } + }, + + GetUInt64: { + do { + guard let __unwrapped__instance = IPropertyValueWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = try __unwrapped__instance.getUInt64() + $1?.initialize(to: value) + return S_OK + } catch { return failWith(err: E_FAIL) } + }, + + GetSingle: { + do { + guard let __unwrapped__instance = IPropertyValueWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = try __unwrapped__instance.getSingle() + $1?.initialize(to: value) + return S_OK + } catch { return failWith(err: E_FAIL) } + }, + + GetDouble: { + do { + guard let __unwrapped__instance = IPropertyValueWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = try __unwrapped__instance.getDouble() + $1?.initialize(to: value) + return S_OK + } catch { return failWith(err: E_FAIL) } + }, + + GetChar16: { + do { + guard let __unwrapped__instance = IPropertyValueWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = try __unwrapped__instance.getChar16() + $1?.initialize(to: .init(from: value)) + return S_OK + } catch { return failWith(err: E_FAIL) } + }, + + GetBoolean: { + do { + guard let __unwrapped__instance = IPropertyValueWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = try __unwrapped__instance.getBoolean() + $1?.initialize(to: .init(from: value)) + return S_OK + } catch { return failWith(err: E_FAIL) } + }, + + GetString: { + do { + guard let __unwrapped__instance = IPropertyValueWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = try __unwrapped__instance.getString() + $1?.initialize(to: try! HString(value).detach()) + return S_OK + } catch { return failWith(err: E_FAIL) } + }, + + GetGuid: { + do { + guard let __unwrapped__instance = IPropertyValueWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = try __unwrapped__instance.getGuid() + $1?.initialize(to: .init(from: value)) + return S_OK + } catch { return failWith(err: E_FAIL) } + }, + + GetDateTime: { + do { + guard let __unwrapped__instance = IPropertyValueWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = try __unwrapped__instance.getDateTime() + $1?.initialize(to: .from(swift: value)) + return S_OK + } catch { return failWith(err: E_FAIL) } + }, + + GetTimeSpan: { + do { + guard let __unwrapped__instance = IPropertyValueWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = try __unwrapped__instance.getTimeSpan() + $1?.initialize(to: .from(swift: value)) + return S_OK + } catch { return failWith(err: E_FAIL) } + }, + + GetPoint: { + do { + guard let __unwrapped__instance = IPropertyValueWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = try __unwrapped__instance.getPoint() + $1?.initialize(to: .from(swift: value)) + return S_OK + } catch { return failWith(err: E_FAIL) } + }, + + GetSize: { + do { + guard let __unwrapped__instance = IPropertyValueWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = try __unwrapped__instance.getSize() + $1?.initialize(to: .from(swift: value)) + return S_OK + } catch { return failWith(err: E_FAIL) } + }, + + GetRect: { + do { + guard let __unwrapped__instance = IPropertyValueWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = try __unwrapped__instance.getRect() + $1?.initialize(to: .from(swift: value)) + return S_OK + } catch { return failWith(err: E_FAIL) } + }, + + GetUInt8Array: { _, _, _ in return failWith(err: E_NOTIMPL) }, + + GetInt16Array: { _, _, _ in return failWith(err: E_NOTIMPL) }, + + GetUInt16Array: { _, _, _ in return failWith(err: E_NOTIMPL) }, + + GetInt32Array: { _, _, _ in return failWith(err: E_NOTIMPL) }, + + GetUInt32Array: { _, _, _ in return failWith(err: E_NOTIMPL) }, + + GetInt64Array: { _, _, _ in return failWith(err: E_NOTIMPL) }, + + GetUInt64Array: { _, _, _ in return failWith(err: E_NOTIMPL) }, + + GetSingleArray: { _, _, _ in return failWith(err: E_NOTIMPL) }, + + GetDoubleArray: { _, _, _ in return failWith(err: E_NOTIMPL) }, + + GetChar16Array: { _, _, _ in return failWith(err: E_NOTIMPL) }, + + GetBooleanArray: { _, _, _ in return failWith(err: E_NOTIMPL) }, + + GetStringArray: { _, _, _ in return failWith(err: E_NOTIMPL) }, + + GetInspectableArray: { _, _, _ in return failWith(err: E_NOTIMPL) }, + + GetGuidArray: { _, _, _ in return failWith(err: E_NOTIMPL) }, + + GetDateTimeArray: { _, _, _ in return failWith(err: E_NOTIMPL) }, + + GetTimeSpanArray: { _, _, _ in return failWith(err: E_NOTIMPL) }, + + GetPointArray: { _, _, _ in return failWith(err: E_NOTIMPL) }, + + GetSizeArray: { _, _, _ in return failWith(err: E_NOTIMPL) }, + + GetRectArray: { _, _, _ in return failWith(err: E_NOTIMPL) } + ) + + public typealias IPropertyValueWrapper = InterfaceWrapperBase<__IMPL_Windows_Foundation.IPropertyValueBridge> + public class IStringable: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIStringable } + + open func ToStringImpl() throws -> String { + var value: HSTRING? + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIStringable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.ToString(pThis, &value)) + } + return .init(from: value) + } + + } + + internal static var IStringableVTable: __x_ABI_CWindows_CFoundation_CIStringableVtbl = .init( + QueryInterface: { IStringableWrapper.queryInterface($0, $1, $2) }, + AddRef: { IStringableWrapper.addRef($0) }, + Release: { IStringableWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 3).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = __ABI_Windows_Foundation.IStringableWrapper.IID + $1!.pointee = 3 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.IStringable").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + ToString: { + do { + guard let __unwrapped__instance = IStringableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = try __unwrapped__instance.toString() + $1?.initialize(to: try! HString(value).detach()) + return S_OK + } catch { return failWith(err: E_FAIL) } + } + ) + + public typealias IStringableWrapper = InterfaceWrapperBase<__IMPL_Windows_Foundation.IStringableBridge> + public class IUriEscapeStatics: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIUriEscapeStatics } + + internal func UnescapeComponentImpl(_ toUnescape: String) throws -> String { + var value: HSTRING? + let _toUnescape = try! HString(toUnescape) + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriEscapeStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.UnescapeComponent(pThis, _toUnescape.get(), &value)) + } + return .init(from: value) + } + + internal func EscapeComponentImpl(_ toEscape: String) throws -> String { + var value: HSTRING? + let _toEscape = try! HString(toEscape) + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriEscapeStatics.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.EscapeComponent(pThis, _toEscape.get(), &value)) + } + return .init(from: value) + } + + } + + public class IUriRuntimeClass: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIUriRuntimeClass } + + internal func get_AbsoluteUriImpl() throws -> String { + var value: HSTRING? + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_AbsoluteUri(pThis, &value)) + } + return .init(from: value) + } + + internal func get_DisplayUriImpl() throws -> String { + var value: HSTRING? + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_DisplayUri(pThis, &value)) + } + return .init(from: value) + } + + internal func get_DomainImpl() throws -> String { + var value: HSTRING? + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Domain(pThis, &value)) + } + return .init(from: value) + } + + internal func get_ExtensionImpl() throws -> String { + var value: HSTRING? + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Extension(pThis, &value)) + } + return .init(from: value) + } + + internal func get_FragmentImpl() throws -> String { + var value: HSTRING? + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Fragment(pThis, &value)) + } + return .init(from: value) + } + + internal func get_HostImpl() throws -> String { + var value: HSTRING? + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Host(pThis, &value)) + } + return .init(from: value) + } + + internal func get_PasswordImpl() throws -> String { + var value: HSTRING? + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Password(pThis, &value)) + } + return .init(from: value) + } + + internal func get_PathImpl() throws -> String { + var value: HSTRING? + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Path(pThis, &value)) + } + return .init(from: value) + } + + internal func get_QueryImpl() throws -> String { + var value: HSTRING? + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Query(pThis, &value)) + } + return .init(from: value) + } + + internal func get_QueryParsedImpl() throws -> WindowsFoundation.WwwFormUrlDecoder? { + let (ppWwwFormUrlDecoder) = try ComPtrs.initialize { ppWwwFormUrlDecoderAbi in + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_QueryParsed(pThis, &ppWwwFormUrlDecoderAbi)) + } + } + return .from(abi: ppWwwFormUrlDecoder) + } + + internal func get_RawUriImpl() throws -> String { + var value: HSTRING? + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_RawUri(pThis, &value)) + } + return .init(from: value) + } + + internal func get_SchemeNameImpl() throws -> String { + var value: HSTRING? + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_SchemeName(pThis, &value)) + } + return .init(from: value) + } + + internal func get_UserNameImpl() throws -> String { + var value: HSTRING? + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_UserName(pThis, &value)) + } + return .init(from: value) + } + + internal func get_PortImpl() throws -> Int32 { + var value: INT32 = 0 + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Port(pThis, &value)) + } + return value + } + + internal func get_SuspiciousImpl() throws -> Bool { + var value: boolean = 0 + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Suspicious(pThis, &value)) + } + return .init(from: value) + } + + internal func EqualsImpl(_ pUri: WindowsFoundation.Uri?) throws -> Bool { + var value: boolean = 0 + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Equals(pThis, RawPointer(pUri), &value)) + } + return .init(from: value) + } + + internal func CombineUriImpl(_ relativeUri: String) throws -> WindowsFoundation.Uri? { + let (instance) = try ComPtrs.initialize { instanceAbi in + let _relativeUri = try! HString(relativeUri) + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CombineUri(pThis, _relativeUri.get(), &instanceAbi)) + } + } + return .from(abi: instance) + } + + } + + public class IUriRuntimeClassFactory: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIUriRuntimeClassFactory } + + internal func CreateUriImpl(_ uri: String) throws -> IUriRuntimeClass { + let (instance) = try ComPtrs.initialize { instanceAbi in + let _uri = try! HString(uri) + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClassFactory.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateUri(pThis, _uri.get(), &instanceAbi)) + } + } + return IUriRuntimeClass(instance!) + } + + internal func CreateWithRelativeUriImpl(_ baseUri: String, _ relativeUri: String) throws -> IUriRuntimeClass { + let (instance) = try ComPtrs.initialize { instanceAbi in + let _baseUri = try! HString(baseUri) + let _relativeUri = try! HString(relativeUri) + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClassFactory.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateWithRelativeUri(pThis, _baseUri.get(), _relativeUri.get(), &instanceAbi)) + } + } + return IUriRuntimeClass(instance!) + } + + } + + public class IUriRuntimeClassWithAbsoluteCanonicalUri: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIUriRuntimeClassWithAbsoluteCanonicalUri } + + internal func get_AbsoluteCanonicalUriImpl() throws -> String { + var value: HSTRING? + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClassWithAbsoluteCanonicalUri.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_AbsoluteCanonicalUri(pThis, &value)) + } + return .init(from: value) + } + + internal func get_DisplayIriImpl() throws -> String { + var value: HSTRING? + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClassWithAbsoluteCanonicalUri.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_DisplayIri(pThis, &value)) + } + return .init(from: value) + } + + } + + public class IWwwFormUrlDecoderEntry: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIWwwFormUrlDecoderEntry } + + open func get_NameImpl() throws -> String { + var value: HSTRING? + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIWwwFormUrlDecoderEntry.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Name(pThis, &value)) + } + return .init(from: value) + } + + open func get_ValueImpl() throws -> String { + var value: HSTRING? + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIWwwFormUrlDecoderEntry.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Value(pThis, &value)) + } + return .init(from: value) + } + + } + + internal static var IWwwFormUrlDecoderEntryVTable: __x_ABI_CWindows_CFoundation_CIWwwFormUrlDecoderEntryVtbl = .init( + QueryInterface: { IWwwFormUrlDecoderEntryWrapper.queryInterface($0, $1, $2) }, + AddRef: { IWwwFormUrlDecoderEntryWrapper.addRef($0) }, + Release: { IWwwFormUrlDecoderEntryWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 3).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = __ABI_Windows_Foundation.IWwwFormUrlDecoderEntryWrapper.IID + $1!.pointee = 3 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.IWwwFormUrlDecoderEntry").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + get_Name: { + guard let __unwrapped__instance = IWwwFormUrlDecoderEntryWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = __unwrapped__instance.name + $1?.initialize(to: try! HString(value).detach()) + return S_OK + }, + + get_Value: { + guard let __unwrapped__instance = IWwwFormUrlDecoderEntryWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = __unwrapped__instance.value + $1?.initialize(to: try! HString(value).detach()) + return S_OK + } + ) + + public typealias IWwwFormUrlDecoderEntryWrapper = InterfaceWrapperBase<__IMPL_Windows_Foundation.IWwwFormUrlDecoderEntryBridge> + public class IWwwFormUrlDecoderRuntimeClass: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIWwwFormUrlDecoderRuntimeClass } + + internal func GetFirstValueByNameImpl(_ name: String) throws -> String { + var phstrValue: HSTRING? + let _name = try! HString(name) + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIWwwFormUrlDecoderRuntimeClass.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetFirstValueByName(pThis, _name.get(), &phstrValue)) + } + return .init(from: phstrValue) + } + + } + + public class IWwwFormUrlDecoderRuntimeClassFactory: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIWwwFormUrlDecoderRuntimeClassFactory } + + internal func CreateWwwFormUrlDecoderImpl(_ query: String) throws -> IWwwFormUrlDecoderRuntimeClass { + let (instance) = try ComPtrs.initialize { instanceAbi in + let _query = try! HString(query) + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIWwwFormUrlDecoderRuntimeClassFactory.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.CreateWwwFormUrlDecoder(pThis, _query.get(), &instanceAbi)) + } + } + return IWwwFormUrlDecoderRuntimeClass(instance!) + } + + } + +} +extension __x_ABI_CWindows_CFoundation_CDateTime { + public static func from(swift: WindowsFoundation.DateTime) -> __x_ABI_CWindows_CFoundation_CDateTime { + .init(UniversalTime: swift.universalTime) + } + } + extension __x_ABI_CWindows_CFoundation_CPoint { + public static func from(swift: WindowsFoundation.Point) -> __x_ABI_CWindows_CFoundation_CPoint { + .init(X: swift.x, Y: swift.y) + } + } + extension __x_ABI_CWindows_CFoundation_CRect { + public static func from(swift: WindowsFoundation.Rect) -> __x_ABI_CWindows_CFoundation_CRect { + .init(X: swift.x, Y: swift.y, Width: swift.width, Height: swift.height) + } + } + extension __x_ABI_CWindows_CFoundation_CSize { + public static func from(swift: WindowsFoundation.Size) -> __x_ABI_CWindows_CFoundation_CSize { + .init(Width: swift.width, Height: swift.height) + } + } + extension __x_ABI_CWindows_CFoundation_CTimeSpan { + public static func from(swift: WindowsFoundation.TimeSpan) -> __x_ABI_CWindows_CFoundation_CTimeSpan { + .init(Duration: swift.duration) + } + } + // MARK - AsyncActionCompletedHandler +extension __ABI_Windows_Foundation { + public class AsyncActionCompletedHandler: WindowsFoundation.IUnknown { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIAsyncActionCompletedHandler } + + open func InvokeImpl(_ asyncInfo: WindowsFoundation.AnyIAsyncAction?, _ asyncStatus: WindowsFoundation.AsyncStatus) throws { + let asyncInfoWrapper = __ABI_Windows_Foundation.IAsyncActionWrapper(asyncInfo) + let _asyncInfo = try! asyncInfoWrapper?.toABI { $0 } + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIAsyncActionCompletedHandler.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Invoke(pThis, _asyncInfo, asyncStatus)) + } + } + + } + + + typealias AsyncActionCompletedHandlerWrapper = InterfaceWrapperBase<__IMPL_Windows_Foundation.AsyncActionCompletedHandlerBridge> + internal static var AsyncActionCompletedHandlerVTable: __x_ABI_CWindows_CFoundation_CIAsyncActionCompletedHandlerVtbl = .init( + QueryInterface: { AsyncActionCompletedHandlerWrapper.queryInterface($0, $1, $2) }, + AddRef: { AsyncActionCompletedHandlerWrapper.addRef($0) }, + Release: { AsyncActionCompletedHandlerWrapper.release($0) }, + Invoke: { + guard let __unwrapped__instance = AsyncActionCompletedHandlerWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let asyncInfo: WindowsFoundation.AnyIAsyncAction? = __ABI_Windows_Foundation.IAsyncActionWrapper.unwrapFrom(abi: ComPtr($1)) + let asyncStatus: WindowsFoundation.AsyncStatus = $2 + __unwrapped__instance(asyncInfo, asyncStatus) + return S_OK + } + ) +} +public extension WinRTDelegateBridge where CABI == __x_ABI_CWindows_CFoundation_CIAsyncActionCompletedHandler { + static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__ABI_Windows_Foundation.AsyncActionCompletedHandlerVTable) { $0 } + return .init(lpVtbl:vtblPtr) + } +} + +// MARK - DeferralCompletedHandler +extension __ABI_Windows_Foundation { + public class DeferralCompletedHandler: WindowsFoundation.IUnknown { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CIDeferralCompletedHandler } + + open func InvokeImpl() throws { + _ = try perform(as: __x_ABI_CWindows_CFoundation_CIDeferralCompletedHandler.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Invoke(pThis)) + } + } + + } + + + typealias DeferralCompletedHandlerWrapper = InterfaceWrapperBase<__IMPL_Windows_Foundation.DeferralCompletedHandlerBridge> + internal static var DeferralCompletedHandlerVTable: __x_ABI_CWindows_CFoundation_CIDeferralCompletedHandlerVtbl = .init( + QueryInterface: { DeferralCompletedHandlerWrapper.queryInterface($0, $1, $2) }, + AddRef: { DeferralCompletedHandlerWrapper.addRef($0) }, + Release: { DeferralCompletedHandlerWrapper.release($0) }, + Invoke: { + guard let __unwrapped__instance = DeferralCompletedHandlerWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + __unwrapped__instance() + return S_OK + } + ) +} +public extension WinRTDelegateBridge where CABI == __x_ABI_CWindows_CFoundation_CIDeferralCompletedHandler { + static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__ABI_Windows_Foundation.DeferralCompletedHandlerVTable) { $0 } + return .init(lpVtbl:vtblPtr) + } +} + diff --git a/Sources/WindowsFoundation/Generated/Windows.Foundation+Impl.swift b/Sources/WindowsFoundation/Generated/Windows.Foundation+Impl.swift new file mode 100644 index 0000000..518ed73 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Windows.Foundation+Impl.swift @@ -0,0 +1,457 @@ +// WARNING: Please don't edit this file. It was generated by Swift/WinRT v0.0.1 +// swiftlint:disable all +import Foundation +import CWinRT + +public enum __IMPL_Windows_Foundation { + public enum IAsyncActionBridge : AbiInterfaceBridge { + public typealias CABI = __x_ABI_CWindows_CFoundation_CIAsyncAction + public typealias SwiftABI = __ABI_Windows_Foundation.IAsyncAction + public typealias SwiftProjection = AnyIAsyncAction + public static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return IAsyncActionImpl(abi) + } + + public static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__ABI_Windows_Foundation.IAsyncActionVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } + } + + fileprivate class IAsyncActionImpl: IAsyncAction, WinRTAbiImpl { + fileprivate typealias Bridge = IAsyncActionBridge + fileprivate let _default: Bridge.SwiftABI + fileprivate var thisPtr: WindowsFoundation.IInspectable { _default } + fileprivate init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncaction.getresults) + fileprivate func getResults() throws { + try _default.GetResultsImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncaction.completed) + fileprivate var completed : AsyncActionCompletedHandler! { + get { try! _default.get_CompletedImpl() } + set { try! _default.put_CompletedImpl(newValue) } + } + + private lazy var _IAsyncInfo: __ABI_Windows_Foundation.IAsyncInfo! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncaction.cancel) + fileprivate func cancel() throws { + try _IAsyncInfo.CancelImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncaction.close) + fileprivate func close() throws { + try _IAsyncInfo.CloseImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncaction.errorcode) + fileprivate var errorCode : HRESULT { + get { try! _IAsyncInfo.get_ErrorCodeImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncaction.id) + fileprivate var id : UInt32 { + get { try! _IAsyncInfo.get_IdImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncaction.status) + fileprivate var status : AsyncStatus { + get { try! _IAsyncInfo.get_StatusImpl() } + } + + } + + public enum IAsyncInfoBridge : AbiInterfaceBridge { + public typealias CABI = __x_ABI_CWindows_CFoundation_CIAsyncInfo + public typealias SwiftABI = __ABI_Windows_Foundation.IAsyncInfo + public typealias SwiftProjection = AnyIAsyncInfo + public static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return IAsyncInfoImpl(abi) + } + + public static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__ABI_Windows_Foundation.IAsyncInfoVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } + } + + fileprivate class IAsyncInfoImpl: IAsyncInfo, WinRTAbiImpl { + fileprivate typealias Bridge = IAsyncInfoBridge + fileprivate let _default: Bridge.SwiftABI + fileprivate var thisPtr: WindowsFoundation.IInspectable { _default } + fileprivate init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncinfo.cancel) + fileprivate func cancel() throws { + try _default.CancelImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncinfo.close) + fileprivate func close() throws { + try _default.CloseImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncinfo.errorcode) + fileprivate var errorCode : HRESULT { + get { try! _default.get_ErrorCodeImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncinfo.id) + fileprivate var id : UInt32 { + get { try! _default.get_IdImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncinfo.status) + fileprivate var status : AsyncStatus { + get { try! _default.get_StatusImpl() } + } + + } + + public enum IClosableBridge : AbiInterfaceBridge { + public typealias CABI = __x_ABI_CWindows_CFoundation_CIClosable + public typealias SwiftABI = __ABI_Windows_Foundation.IClosable + public typealias SwiftProjection = AnyIClosable + public static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return IClosableImpl(abi) + } + + public static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__ABI_Windows_Foundation.IClosableVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } + } + + fileprivate class IClosableImpl: IClosable, WinRTAbiImpl { + fileprivate typealias Bridge = IClosableBridge + fileprivate let _default: Bridge.SwiftABI + fileprivate var thisPtr: WindowsFoundation.IInspectable { _default } + fileprivate init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iclosable.close) + fileprivate func close() throws { + try _default.CloseImpl() + } + + } + + public enum IGetActivationFactoryBridge : AbiInterfaceBridge { + public typealias CABI = __x_ABI_CWindows_CFoundation_CIGetActivationFactory + public typealias SwiftABI = __ABI_Windows_Foundation.IGetActivationFactory + public typealias SwiftProjection = AnyIGetActivationFactory + public static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return IGetActivationFactoryImpl(abi) + } + + public static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__ABI_Windows_Foundation.IGetActivationFactoryVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } + } + + fileprivate class IGetActivationFactoryImpl: IGetActivationFactory, WinRTAbiImpl { + fileprivate typealias Bridge = IGetActivationFactoryBridge + fileprivate let _default: Bridge.SwiftABI + fileprivate var thisPtr: WindowsFoundation.IInspectable { _default } + fileprivate init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.igetactivationfactory.getactivationfactory) + fileprivate func getActivationFactory(_ activatableClassId: String) throws -> Any! { + try _default.GetActivationFactoryImpl(activatableClassId) + } + + } + + public enum IMemoryBufferBridge : AbiInterfaceBridge { + public typealias CABI = __x_ABI_CWindows_CFoundation_CIMemoryBuffer + public typealias SwiftABI = __ABI_Windows_Foundation.IMemoryBuffer + public typealias SwiftProjection = AnyIMemoryBuffer + public static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return IMemoryBufferImpl(abi) + } + + public static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__ABI_Windows_Foundation.IMemoryBufferVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } + } + + fileprivate class IMemoryBufferImpl: IMemoryBuffer, WinRTAbiImpl { + fileprivate typealias Bridge = IMemoryBufferBridge + fileprivate let _default: Bridge.SwiftABI + fileprivate var thisPtr: WindowsFoundation.IInspectable { _default } + fileprivate init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.imemorybuffer.createreference) + fileprivate func createReference() throws -> AnyIMemoryBufferReference! { + try _default.CreateReferenceImpl() + } + + private lazy var _IClosable: __ABI_Windows_Foundation.IClosable! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.imemorybuffer.close) + fileprivate func close() throws { + try _IClosable.CloseImpl() + } + + } + + public enum IMemoryBufferReferenceBridge : AbiInterfaceBridge { + public typealias CABI = __x_ABI_CWindows_CFoundation_CIMemoryBufferReference + public typealias SwiftABI = __ABI_Windows_Foundation.IMemoryBufferReference + public typealias SwiftProjection = AnyIMemoryBufferReference + public static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return IMemoryBufferReferenceImpl(abi) + } + + public static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__ABI_Windows_Foundation.IMemoryBufferReferenceVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } + } + + fileprivate class IMemoryBufferReferenceImpl: IMemoryBufferReference, WinRTAbiImpl { + fileprivate typealias Bridge = IMemoryBufferReferenceBridge + fileprivate let _default: Bridge.SwiftABI + fileprivate var thisPtr: WindowsFoundation.IInspectable { _default } + fileprivate init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.imemorybufferreference.capacity) + fileprivate var capacity : UInt32 { + get { try! _default.get_CapacityImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.imemorybufferreference.closed) + fileprivate lazy var closed : Event> = { + .init( + add: { [weak self] in + guard let this = self?._default else { return .init() } + return try! this.add_ClosedImpl($0) + }, + remove: { [weak self] in + try? self?._default.remove_ClosedImpl($0) + } + ) + }() + + private lazy var _IClosable: __ABI_Windows_Foundation.IClosable! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.imemorybufferreference.close) + fileprivate func close() throws { + try _IClosable.CloseImpl() + } + + private lazy var _IMemoryBufferByteAccess: __ABI_.IMemoryBufferByteAccess! = getInterfaceForCaching() + fileprivate var buffer: UnsafeMutableBufferPointer? { + get throws { + let bufferByteAccess: WindowsFoundation.__ABI_.IMemoryBufferByteAccess = try _IMemoryBufferByteAccess.QueryInterface() + return try bufferByteAccess.Buffer() + } + } + } + + public enum IPropertyValueBridge : AbiInterfaceBridge { + public typealias CABI = __x_ABI_CWindows_CFoundation_CIPropertyValue + public typealias SwiftABI = __ABI_Windows_Foundation.IPropertyValue + public typealias SwiftProjection = AnyIPropertyValue + public static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return IPropertyValueImpl(abi) + } + + public static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__ABI_Windows_Foundation.IPropertyValueVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } + } + + public class IPropertyValueImpl : IPropertyValue, IReference { + public typealias T = Any + var _value: Any + var propertyType : PropertyType + + fileprivate init(_ abi: ComPtr<__x_ABI_CWindows_CFoundation_CIPropertyValue>) { fatalError("not implemented") } + public init(value: Any) { + _value = value + if _value is Int32 { + propertyType = .int32 + } else if _value is UInt8 { + propertyType = .uint8 + } else if _value is Int16 { + propertyType = .int16 + } else if _value is UInt32 { + propertyType = .uint32 + } else if _value is Int64 { + propertyType = .int64 + } else if _value is UInt64 { + propertyType = .uint64 + } else if _value is Float { + propertyType = .single + } else if _value is Double { + propertyType = .double + } else if _value is Character { + propertyType = .char16 + } else if _value is Bool { + propertyType = .boolean + } else if _value is DateTime { + propertyType = .dateTime + } else if _value is TimeSpan { + propertyType = .timeSpan + } else if _value is IWinRTObject { + propertyType = .inspectable + } else if _value is IInspectable { + propertyType = .inspectable + } else { + propertyType = .otherType + } + } + + public var type: PropertyType { propertyType } + public var isNumericScalar: Bool { + switch propertyType { + case .int16, .int32, .int64, .uint8, .uint16, .uint32, .uint64, .single, .double: return true + default: return false + } + } + + public var value: Any { _value } + + public func getUInt8() -> UInt8 { _value as! UInt8 } + public func getInt16() -> Int16 { _value as! Int16 } + public func getUInt16() -> UInt16 { _value as! UInt16 } + public func getInt32() -> Int32 { _value as! Int32 } + public func getUInt32() -> UInt32 { _value as! UInt32 } + public func getInt64() -> Int64 { _value as! Int64 } + public func getUInt64() -> UInt64 { _value as! UInt64 } + public func getSingle() -> Float { _value as! Float } + public func getDouble() -> Double { _value as! Double } + public func getChar16() -> Character { _value as! Character } + public func getBoolean() -> Bool { _value as! Bool } + public func getString() -> String { _value as! String } + public func getGuid() -> Foundation.UUID { _value as! Foundation.UUID } + public func getDateTime() -> DateTime { _value as! DateTime } + public func getTimeSpan() -> TimeSpan { _value as! TimeSpan } + public func getPoint() -> Point { _value as! Point } + public func getSize() -> Size { _value as! Size } + public func getRect() -> Rect { _value as! Rect } + + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + guard iid == __ABI_Windows_Foundation.IPropertyValueWrapper.IID else { return nil } + guard let thisAsIPropValue = __ABI_Windows_Foundation.IPropertyValueWrapper(self) else { fatalError("creating non-nil wrapper shouldn't fail") } + return thisAsIPropValue.queryInterface(iid) + } + + } + + public enum IStringableBridge : AbiInterfaceBridge { + public typealias CABI = __x_ABI_CWindows_CFoundation_CIStringable + public typealias SwiftABI = __ABI_Windows_Foundation.IStringable + public typealias SwiftProjection = AnyIStringable + public static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return IStringableImpl(abi) + } + + public static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__ABI_Windows_Foundation.IStringableVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } + } + + fileprivate class IStringableImpl: IStringable, WinRTAbiImpl { + fileprivate typealias Bridge = IStringableBridge + fileprivate let _default: Bridge.SwiftABI + fileprivate var thisPtr: WindowsFoundation.IInspectable { _default } + fileprivate init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.istringable.tostring) + fileprivate func toString() throws -> String { + try _default.ToStringImpl() + } + + } + + public enum IWwwFormUrlDecoderEntryBridge : AbiInterfaceBridge { + public typealias CABI = __x_ABI_CWindows_CFoundation_CIWwwFormUrlDecoderEntry + public typealias SwiftABI = __ABI_Windows_Foundation.IWwwFormUrlDecoderEntry + public typealias SwiftProjection = AnyIWwwFormUrlDecoderEntry + public static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return IWwwFormUrlDecoderEntryImpl(abi) + } + + public static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__ABI_Windows_Foundation.IWwwFormUrlDecoderEntryVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } + } + + fileprivate class IWwwFormUrlDecoderEntryImpl: IWwwFormUrlDecoderEntry, WinRTAbiImpl { + fileprivate typealias Bridge = IWwwFormUrlDecoderEntryBridge + fileprivate let _default: Bridge.SwiftABI + fileprivate var thisPtr: WindowsFoundation.IInspectable { _default } + fileprivate init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iwwwformurldecoderentry.name) + fileprivate var name : String { + get { try! _default.get_NameImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iwwwformurldecoderentry.value) + fileprivate var value : String { + get { try! _default.get_ValueImpl() } + } + + } + + public class AsyncActionCompletedHandlerBridge : WinRTDelegateBridge { + public typealias Handler = AsyncActionCompletedHandler + public typealias CABI = __x_ABI_CWindows_CFoundation_CIAsyncActionCompletedHandler + public typealias SwiftABI = __ABI_Windows_Foundation.AsyncActionCompletedHandler + + public static func from(abi: ComPtr?) -> Handler? { + guard let abi = abi else { return nil } + let _default = SwiftABI(abi) + let handler: Handler = { (asyncInfo, asyncStatus) in + try! _default.InvokeImpl(asyncInfo, asyncStatus) + } + return handler + } + } + public class DeferralCompletedHandlerBridge : WinRTDelegateBridge { + public typealias Handler = DeferralCompletedHandler + public typealias CABI = __x_ABI_CWindows_CFoundation_CIDeferralCompletedHandler + public typealias SwiftABI = __ABI_Windows_Foundation.DeferralCompletedHandler + + public static func from(abi: ComPtr?) -> Handler? { + guard let abi = abi else { return nil } + let _default = SwiftABI(abi) + let handler: Handler = { () in + try! _default.InvokeImpl() + } + return handler + } + } +} diff --git a/Sources/WindowsFoundation/Generated/Windows.Foundation.Collections+ABI.swift b/Sources/WindowsFoundation/Generated/Windows.Foundation.Collections+ABI.swift new file mode 100644 index 0000000..bbf8315 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Windows.Foundation.Collections+ABI.swift @@ -0,0 +1,166 @@ +// WARNING: Please don't edit this file. It was generated by Swift/WinRT v0.0.1 +// swiftlint:disable all +import Foundation +import CWinRT + +private var IID___x_ABI_C__FIIterable_1_T: WindowsFoundation.IID { + .init(Data1: 0xFAA585EA, Data2: 0x6214, Data3: 0x4217, Data4: ( 0xAF,0xDA,0x7F,0x46,0xDE,0x58,0x69,0xB3 ))// FAA585EA-6214-4217-AFDA-7F46DE5869B3 +} + +private var IID___x_ABI_C__FIIterator_1_T: WindowsFoundation.IID { + .init(Data1: 0x6A79E863, Data2: 0x4300, Data3: 0x459A, Data4: ( 0x99,0x66,0xCB,0xB6,0x60,0x96,0x3E,0xE1 ))// 6A79E863-4300-459A-9966-CBB660963EE1 +} + +private var IID___x_ABI_C__FIKeyValuePair_2_K_V: WindowsFoundation.IID { + .init(Data1: 0x02B51929, Data2: 0xC1C4, Data3: 0x4A7E, Data4: ( 0x89,0x40,0x03,0x12,0xB5,0xC1,0x85,0x00 ))// 02B51929-C1C4-4A7E-8940-0312B5C18500 +} + +private var IID___x_ABI_C__FIMapChangedEventArgs_1_K: WindowsFoundation.IID { + .init(Data1: 0x9939F4DF, Data2: 0x050A, Data3: 0x4C0F, Data4: ( 0xAA,0x60,0x77,0x07,0x5F,0x9C,0x47,0x77 ))// 9939F4DF-050A-4C0F-AA60-77075F9C4777 +} + +private var IID___x_ABI_C__FIMapView_2_K_V: WindowsFoundation.IID { + .init(Data1: 0xE480CE40, Data2: 0xA338, Data3: 0x4ADA, Data4: ( 0xAD,0xCF,0x27,0x22,0x72,0xE4,0x8C,0xB9 ))// E480CE40-A338-4ADA-ADCF-272272E48CB9 +} + +private var IID___x_ABI_C__FIMap_2_K_V: WindowsFoundation.IID { + .init(Data1: 0x3C2925FE, Data2: 0x8519, Data3: 0x45C1, Data4: ( 0xAA,0x79,0x19,0x7B,0x67,0x18,0xC1,0xC1 ))// 3C2925FE-8519-45C1-AA79-197B6718C1C1 +} + +private var IID___x_ABI_C__FIObservableMap_2_K_V: WindowsFoundation.IID { + .init(Data1: 0x65DF2BF5, Data2: 0xBF39, Data3: 0x41B5, Data4: ( 0xAE,0xBC,0x5A,0x9D,0x86,0x5E,0x47,0x2B ))// 65DF2BF5-BF39-41B5-AEBC-5A9D865E472B +} + +private var IID___x_ABI_C__FIObservableVector_1_T: WindowsFoundation.IID { + .init(Data1: 0x5917EB53, Data2: 0x50B4, Data3: 0x4A0D, Data4: ( 0xB3,0x09,0x65,0x86,0x2B,0x3F,0x1D,0xBC ))// 5917EB53-50B4-4A0D-B309-65862B3F1DBC +} + +private var IID___x_ABI_CWindows_CFoundation_CCollections_CIPropertySet: WindowsFoundation.IID { + .init(Data1: 0x8A43ED9F, Data2: 0xF4E6, Data3: 0x4421, Data4: ( 0xAC,0xF9,0x1D,0xAB,0x29,0x86,0x82,0x0C ))// 8A43ED9F-F4E6-4421-ACF9-1DAB2986820C +} + +private var IID___x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs: WindowsFoundation.IID { + .init(Data1: 0x575933DF, Data2: 0x34FE, Data3: 0x4480, Data4: ( 0xAF,0x15,0x07,0x69,0x1F,0x3D,0x5D,0x9B ))// 575933DF-34FE-4480-AF15-07691F3D5D9B +} + +private var IID___x_ABI_C__FIVectorView_1_T: WindowsFoundation.IID { + .init(Data1: 0xBBE1FA4C, Data2: 0xB0E3, Data3: 0x4583, Data4: ( 0xBA,0xEF,0x1F,0x1B,0x2E,0x48,0x3E,0x56 ))// BBE1FA4C-B0E3-4583-BAEF-1F1B2E483E56 +} + +private var IID___x_ABI_C__FIVector_1_T: WindowsFoundation.IID { + .init(Data1: 0x913337E9, Data2: 0x11A1, Data3: 0x4345, Data4: ( 0xA3,0xA2,0x4E,0x7F,0x95,0x6E,0x22,0x2D ))// 913337E9-11A1-4345-A3A2-4E7F956E222D +} + +private var IID___x_ABI_C__FMapChangedEventHandler_2_K_V: WindowsFoundation.IID { + .init(Data1: 0x179517F3, Data2: 0x94EE, Data3: 0x41F8, Data4: ( 0xBD,0xDC,0x76,0x8A,0x89,0x55,0x44,0xF3 ))// 179517F3-94EE-41F8-BDDC-768A895544F3 +} + +private var IID___x_ABI_C__FVectorChangedEventHandler_1_T: WindowsFoundation.IID { + .init(Data1: 0x0C051752, Data2: 0x9FBF, Data3: 0x4C70, Data4: ( 0xAA,0x0C,0x0E,0x4C,0x82,0xD9,0xA7,0x61 ))// 0C051752-9FBF-4C70-AA0C-0E4C82D9A761 +} + +public enum __ABI_Windows_Foundation_Collections { + public class IPropertySet: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CCollections_CIPropertySet } + + } + + internal static var IPropertySetVTable: __x_ABI_CWindows_CFoundation_CCollections_CIPropertySetVtbl = .init( + QueryInterface: { IPropertySetWrapper.queryInterface($0, $1, $2) }, + AddRef: { IPropertySetWrapper.addRef($0) }, + Release: { IPropertySetWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 6).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = __ABI_Windows_Foundation_Collections.IPropertySetWrapper.IID + iids[3] = WindowsFoundation.__x_ABI_C__FIObservableMap_2_HSTRING_IInspectableWrapper.IID + iids[4] = WindowsFoundation.__x_ABI_C__FIMap_2_HSTRING_IInspectableWrapper.IID + iids[5] = WindowsFoundation.__x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.IID + $1!.pointee = 6 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.Collections.IPropertySet").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + } + ) + + public typealias IPropertySetWrapper = InterfaceWrapperBase<__IMPL_Windows_Foundation_Collections.IPropertySetBridge> + public class IVectorChangedEventArgs: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs } + + open func get_CollectionChangeImpl() throws -> WindowsFoundation.CollectionChange { + var value: __x_ABI_CWindows_CFoundation_CCollections_CCollectionChange = .init(0) + _ = try perform(as: __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_CollectionChange(pThis, &value)) + } + return value + } + + open func get_IndexImpl() throws -> UInt32 { + var value: UINT32 = 0 + _ = try perform(as: __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Index(pThis, &value)) + } + return value + } + + } + + internal static var IVectorChangedEventArgsVTable: __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgsVtbl = .init( + QueryInterface: { IVectorChangedEventArgsWrapper.queryInterface($0, $1, $2) }, + AddRef: { IVectorChangedEventArgsWrapper.addRef($0) }, + Release: { IVectorChangedEventArgsWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 3).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = __ABI_Windows_Foundation_Collections.IVectorChangedEventArgsWrapper.IID + $1!.pointee = 3 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.Collections.IVectorChangedEventArgs").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + get_CollectionChange: { + guard let __unwrapped__instance = IVectorChangedEventArgsWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = __unwrapped__instance.collectionChange + $1?.initialize(to: value) + return S_OK + }, + + get_Index: { + guard let __unwrapped__instance = IVectorChangedEventArgsWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value = __unwrapped__instance.index + $1?.initialize(to: value) + return S_OK + } + ) + + public typealias IVectorChangedEventArgsWrapper = InterfaceWrapperBase<__IMPL_Windows_Foundation_Collections.IVectorChangedEventArgsBridge> +} diff --git a/Sources/WindowsFoundation/Generated/Windows.Foundation.Collections+Impl.swift b/Sources/WindowsFoundation/Generated/Windows.Foundation.Collections+Impl.swift new file mode 100644 index 0000000..093f857 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Windows.Foundation.Collections+Impl.swift @@ -0,0 +1,126 @@ +// WARNING: Please don't edit this file. It was generated by Swift/WinRT v0.0.1 +// swiftlint:disable all +import Foundation +import CWinRT + +public enum __IMPL_Windows_Foundation_Collections { + public enum IPropertySetBridge : AbiInterfaceBridge { + public typealias CABI = __x_ABI_CWindows_CFoundation_CCollections_CIPropertySet + public typealias SwiftABI = __ABI_Windows_Foundation_Collections.IPropertySet + public typealias SwiftProjection = AnyIPropertySet + public static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return IPropertySetImpl(abi) + } + + public static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__ABI_Windows_Foundation_Collections.IPropertySetVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } + } + + fileprivate class IPropertySetImpl: IPropertySet, WinRTAbiImpl { + fileprivate typealias Bridge = IPropertySetBridge + fileprivate let _default: Bridge.SwiftABI + fileprivate var thisPtr: WindowsFoundation.IInspectable { _default } + fileprivate init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + public typealias K = String + public typealias V = Any? + public typealias T = AnyIKeyValuePair? + private lazy var _IObservableMap: IObservableMapString_Any! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ipropertyset.mapchanged) + fileprivate lazy var mapChanged : Event> = { + .init( + add: { [weak self] in + guard let this = self?._IObservableMap else { return .init() } + return try! this.add_MapChangedImpl($0) + }, + remove: { [weak self] in + try? self?._IObservableMap.remove_MapChangedImpl($0) + } + ) + }() + + private lazy var _IMap: IMapString_Any! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ipropertyset.lookup) + fileprivate func lookup(_ key: String) -> Any? { + try! _IMap.LookupImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ipropertyset.haskey) + fileprivate func hasKey(_ key: String) -> Bool { + try! _IMap.HasKeyImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ipropertyset.getview) + fileprivate func getView() -> AnyIMapView? { + try! _IMap.GetViewImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ipropertyset.insert) + fileprivate func insert(_ key: String, _ value: Any?) -> Bool { + try! _IMap.InsertImpl(key, value) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ipropertyset.remove) + fileprivate func remove(_ key: String) { + try! _IMap.RemoveImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ipropertyset.clear) + fileprivate func clear() { + try! _IMap.ClearImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ipropertyset.size) + fileprivate var size : UInt32 { + get { try! _IMap.get_SizeImpl() } + } + + private lazy var _IIterable: IIterableIKeyValuePairString_Any! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ipropertyset.first) + fileprivate func first() -> AnyIIterator?>? { + try! _IIterable.FirstImpl() + } + + } + + public enum IVectorChangedEventArgsBridge : AbiInterfaceBridge { + public typealias CABI = __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs + public typealias SwiftABI = __ABI_Windows_Foundation_Collections.IVectorChangedEventArgs + public typealias SwiftProjection = AnyIVectorChangedEventArgs + public static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return IVectorChangedEventArgsImpl(abi) + } + + public static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__ABI_Windows_Foundation_Collections.IVectorChangedEventArgsVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } + } + + fileprivate class IVectorChangedEventArgsImpl: IVectorChangedEventArgs, WinRTAbiImpl { + fileprivate typealias Bridge = IVectorChangedEventArgsBridge + fileprivate let _default: Bridge.SwiftABI + fileprivate var thisPtr: WindowsFoundation.IInspectable { _default } + fileprivate init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivectorchangedeventargs.collectionchange) + fileprivate var collectionChange : CollectionChange { + get { try! _default.get_CollectionChangeImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivectorchangedeventargs.index) + fileprivate var index : UInt32 { + get { try! _default.get_IndexImpl() } + } + + } + +} diff --git a/Sources/WindowsFoundation/Generated/Windows.Foundation.Collections.swift b/Sources/WindowsFoundation/Generated/Windows.Foundation.Collections.swift new file mode 100644 index 0000000..8070333 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Windows.Foundation.Collections.swift @@ -0,0 +1,504 @@ +// WARNING: Please don't edit this file. It was generated by Swift/WinRT v0.0.1 +// swiftlint:disable all +import Foundation +import CWinRT + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.collectionchange) +public typealias CollectionChange = __x_ABI_CWindows_CFoundation_CCollections_CCollectionChange +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.propertyset) +public final class PropertySet : WinRTClass, IObservableMap, IMap, IIterable, IPropertySet { + public typealias K = String + public typealias V = Any? + public typealias T = AnyIKeyValuePair? + private typealias SwiftABI = __ABI_Windows_Foundation_Collections.IPropertySet + private typealias CABI = __x_ABI_CWindows_CFoundation_CCollections_CIPropertySet + private lazy var _default: SwiftABI! = getInterfaceForCaching() + @_spi(WinRTInternal) + override public func _getABI() -> UnsafeMutablePointer? { + if T.self == CABI.self { + return RawPointer(_default) + } + return super._getABI() + } + + @_spi(WinRTInternal) + public static func from(abi: ComPtr<__x_ABI_CWindows_CFoundation_CCollections_CIPropertySet>?) -> PropertySet? { + guard let abi = abi else { return nil } + return .init(fromAbi: WindowsFoundation.IInspectable(abi)) + } + + @_spi(WinRTInternal) + public init(fromAbi: WindowsFoundation.IInspectable) { + super.init(fromAbi) + } + + override public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + return super.queryInterface(iid) + } + override public init() { + super.init(try! RoActivateInstance(HString("Windows.Foundation.Collections.PropertySet"))) + } + + private lazy var _IObservableMap: IObservableMapString_Any! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.propertyset.mapchanged) + public lazy var mapChanged : Event> = { + .init( + add: { [weak self] in + guard let this = self?._IObservableMap else { return .init() } + return try! this.add_MapChangedImpl($0) + }, + remove: { [weak self] in + try? self?._IObservableMap.remove_MapChangedImpl($0) + } + ) + }() + + private lazy var _IMap: IMapString_Any! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.propertyset.lookup) + public func lookup(_ key: String) -> Any? { + try! _IMap.LookupImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.propertyset.haskey) + public func hasKey(_ key: String) -> Bool { + try! _IMap.HasKeyImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.propertyset.getview) + public func getView() -> AnyIMapView? { + try! _IMap.GetViewImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.propertyset.insert) + public func insert(_ key: String, _ value: Any?) -> Bool { + try! _IMap.InsertImpl(key, value) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.propertyset.remove) + public func remove(_ key: String) { + try! _IMap.RemoveImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.propertyset.clear) + public func clear() { + try! _IMap.ClearImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.propertyset.size) + public var size : UInt32 { + get { try! _IMap.get_SizeImpl() } + } + + private lazy var _IIterable: IIterableIKeyValuePairString_Any! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.propertyset.first) + public func first() -> AnyIIterator?>? { + try! _IIterable.FirstImpl() + } + + deinit { + _IObservableMap = nil + _IMap = nil + _IIterable = nil + _default = nil + } +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.stringmap) +public final class StringMap : WinRTClass, IMap, IIterable, IObservableMap { + public typealias K = String + public typealias V = String + public typealias T = AnyIKeyValuePair? + private typealias SwiftABI = WindowsFoundation.IMapString_String + private typealias CABI = __x_ABI_C__FIMap_2_HSTRING_HSTRING + private lazy var _default: SwiftABI! = getInterfaceForCaching() + @_spi(WinRTInternal) + override public func _getABI() -> UnsafeMutablePointer? { + if T.self == CABI.self { + return RawPointer(_default) + } + return super._getABI() + } + + @_spi(WinRTInternal) + public static func from(abi: ComPtr<__x_ABI_C__FIMap_2_HSTRING_HSTRING>?) -> StringMap? { + guard let abi = abi else { return nil } + return .init(fromAbi: WindowsFoundation.IInspectable(abi)) + } + + @_spi(WinRTInternal) + public init(fromAbi: WindowsFoundation.IInspectable) { + super.init(fromAbi) + } + + override public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + return super.queryInterface(iid) + } + override public init() { + super.init(try! RoActivateInstance(HString("Windows.Foundation.Collections.StringMap"))) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.stringmap.lookup) + public func lookup(_ key: String) -> String { + try! _default.LookupImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.stringmap.haskey) + public func hasKey(_ key: String) -> Bool { + try! _default.HasKeyImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.stringmap.getview) + public func getView() -> AnyIMapView? { + try! _default.GetViewImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.stringmap.insert) + public func insert(_ key: String, _ value: String) -> Bool { + try! _default.InsertImpl(key, value) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.stringmap.remove) + public func remove(_ key: String) { + try! _default.RemoveImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.stringmap.clear) + public func clear() { + try! _default.ClearImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.stringmap.size) + public var size : UInt32 { + get { try! _default.get_SizeImpl() } + } + + private lazy var _IIterable: IIterableIKeyValuePairString_String! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.stringmap.first) + public func first() -> AnyIIterator?>? { + try! _IIterable.FirstImpl() + } + + private lazy var _IObservableMap: IObservableMapString_String! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.stringmap.mapchanged) + public lazy var mapChanged : Event> = { + .init( + add: { [weak self] in + guard let this = self?._IObservableMap else { return .init() } + return try! this.add_MapChangedImpl($0) + }, + remove: { [weak self] in + try? self?._IObservableMap.remove_MapChangedImpl($0) + } + ) + }() + + deinit { + _default = nil + _IIterable = nil + _IObservableMap = nil + } +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.valueset) +public final class ValueSet : WinRTClass, IObservableMap, IMap, IIterable, IPropertySet { + public typealias K = String + public typealias V = Any? + public typealias T = AnyIKeyValuePair? + private typealias SwiftABI = __ABI_Windows_Foundation_Collections.IPropertySet + private typealias CABI = __x_ABI_CWindows_CFoundation_CCollections_CIPropertySet + private lazy var _default: SwiftABI! = getInterfaceForCaching() + @_spi(WinRTInternal) + override public func _getABI() -> UnsafeMutablePointer? { + if T.self == CABI.self { + return RawPointer(_default) + } + return super._getABI() + } + + @_spi(WinRTInternal) + public static func from(abi: ComPtr<__x_ABI_CWindows_CFoundation_CCollections_CIPropertySet>?) -> ValueSet? { + guard let abi = abi else { return nil } + return .init(fromAbi: WindowsFoundation.IInspectable(abi)) + } + + @_spi(WinRTInternal) + public init(fromAbi: WindowsFoundation.IInspectable) { + super.init(fromAbi) + } + + override public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + return super.queryInterface(iid) + } + override public init() { + super.init(try! RoActivateInstance(HString("Windows.Foundation.Collections.ValueSet"))) + } + + private lazy var _IObservableMap: IObservableMapString_Any! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.valueset.mapchanged) + public lazy var mapChanged : Event> = { + .init( + add: { [weak self] in + guard let this = self?._IObservableMap else { return .init() } + return try! this.add_MapChangedImpl($0) + }, + remove: { [weak self] in + try? self?._IObservableMap.remove_MapChangedImpl($0) + } + ) + }() + + private lazy var _IMap: IMapString_Any! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.valueset.lookup) + public func lookup(_ key: String) -> Any? { + try! _IMap.LookupImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.valueset.haskey) + public func hasKey(_ key: String) -> Bool { + try! _IMap.HasKeyImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.valueset.getview) + public func getView() -> AnyIMapView? { + try! _IMap.GetViewImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.valueset.insert) + public func insert(_ key: String, _ value: Any?) -> Bool { + try! _IMap.InsertImpl(key, value) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.valueset.remove) + public func remove(_ key: String) { + try! _IMap.RemoveImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.valueset.clear) + public func clear() { + try! _IMap.ClearImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.valueset.size) + public var size : UInt32 { + get { try! _IMap.get_SizeImpl() } + } + + private lazy var _IIterable: IIterableIKeyValuePairString_Any! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.valueset.first) + public func first() -> AnyIIterator?>? { + try! _IIterable.FirstImpl() + } + + deinit { + _IObservableMap = nil + _IMap = nil + _IIterable = nil + _default = nil + } +} + +public typealias MapChangedEventHandler = (AnyIObservableMap?, AnyIMapChangedEventArgs?) -> () +public typealias VectorChangedEventHandler = (AnyIObservableVector?, AnyIVectorChangedEventArgs?) -> () +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iiterable-1) +public protocol IIterable : WinRTInterface { + associatedtype T + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iiterable-1.first) + func first() -> WindowsFoundation.AnyIIterator? +} + +public typealias AnyIIterable = any IIterable + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iiterator-1) +public protocol IIterator : WinRTInterface { + associatedtype T + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iiterator-1.movenext) + func moveNext() -> Bool + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iiterator-1.current) + var current: T { get } + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iiterator-1.hascurrent) + var hasCurrent: Bool { get } +} + +public typealias AnyIIterator = any IIterator + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ikeyvaluepair-2) +public protocol IKeyValuePair : WinRTInterface { + associatedtype K + associatedtype V + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ikeyvaluepair-2.key) + var key: K { get } + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ikeyvaluepair-2.value) + var value: V { get } +} + +public typealias AnyIKeyValuePair = any IKeyValuePair + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imapchangedeventargs-1) +public protocol IMapChangedEventArgs : WinRTInterface { + associatedtype K + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imapchangedeventargs-1.collectionchange) + var collectionChange: WindowsFoundation.CollectionChange { get } + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imapchangedeventargs-1.key) + var key: K { get } +} + +public typealias AnyIMapChangedEventArgs = any IMapChangedEventArgs + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imapview-2) +public protocol IMapView : IIterable where T == AnyIKeyValuePair? { + associatedtype K + associatedtype V + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imapview-2.lookup) + func lookup(_ key: K) -> V + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imapview-2.haskey) + func hasKey(_ key: K) -> Bool + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imapview-2.split) + func split(_ first: inout WindowsFoundation.AnyIMapView?, _ second: inout WindowsFoundation.AnyIMapView?) + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imapview-2.size) + var size: UInt32 { get } +} + +public typealias AnyIMapView = any IMapView + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2) +public protocol IMap : IIterable where T == AnyIKeyValuePair? { + associatedtype K + associatedtype V + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.lookup) + func lookup(_ key: K) -> V + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.haskey) + func hasKey(_ key: K) -> Bool + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.getview) + func getView() -> WindowsFoundation.AnyIMapView? + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.insert) + func insert(_ key: K, _ value: V) -> Bool + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.remove) + func remove(_ key: K) + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.clear) + func clear() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.size) + var size: UInt32 { get } +} + +public typealias AnyIMap = any IMap + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablemap-2) +public protocol IObservableMap : IIterable, IMap { + associatedtype K + associatedtype V + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablemap-2.mapchanged) + var mapChanged: Event> { get } +} + +public typealias AnyIObservableMap = any IObservableMap + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablevector-1) +public protocol IObservableVector : IIterable, IVector { + associatedtype T + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablevector-1.vectorchanged) + var vectorChanged: Event> { get } +} + +public typealias AnyIObservableVector = any IObservableVector + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ipropertyset) +public protocol IPropertySet : IObservableMap, IMap, IIterable?> { +} + +extension IPropertySet { + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + switch iid { + case __ABI_Windows_Foundation_Collections.IPropertySetWrapper.IID: + let wrapper = __ABI_Windows_Foundation_Collections.IPropertySetWrapper(self) + return wrapper!.queryInterface(iid) + case WindowsFoundation.__x_ABI_C__FIObservableMap_2_HSTRING_IInspectableWrapper.IID: + let wrapper = WindowsFoundation.__x_ABI_C__FIObservableMap_2_HSTRING_IInspectableWrapper(self) + return wrapper!.queryInterface(iid) + case WindowsFoundation.__x_ABI_C__FIMap_2_HSTRING_IInspectableWrapper.IID: + let wrapper = WindowsFoundation.__x_ABI_C__FIMap_2_HSTRING_IInspectableWrapper(self) + return wrapper!.queryInterface(iid) + case WindowsFoundation.__x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.IID: + let wrapper = WindowsFoundation.__x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper(self) + return wrapper!.queryInterface(iid) + default: return nil + } + } +} +public typealias AnyIPropertySet = any IPropertySet + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivectorchangedeventargs) +public protocol IVectorChangedEventArgs : WinRTInterface { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivectorchangedeventargs.collectionchange) + var collectionChange: WindowsFoundation.CollectionChange { get } + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivectorchangedeventargs.index) + var index: UInt32 { get } +} + +extension IVectorChangedEventArgs { + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + switch iid { + case __ABI_Windows_Foundation_Collections.IVectorChangedEventArgsWrapper.IID: + let wrapper = __ABI_Windows_Foundation_Collections.IVectorChangedEventArgsWrapper(self) + return wrapper!.queryInterface(iid) + default: return nil + } + } +} +public typealias AnyIVectorChangedEventArgs = any IVectorChangedEventArgs + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivectorview-1) +public protocol IVectorView : IIterable, Collection where Element == T, Index == Int { + associatedtype T + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivectorview-1.getat) + func getAt(_ index: UInt32) -> T + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivectorview-1.indexof) + func indexOf(_ value: T, _ index: inout UInt32) -> Bool + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivectorview-1.size) + var size: UInt32 { get } +} + +public typealias AnyIVectorView = any IVectorView + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivector-1) +public protocol IVector : IIterable, Collection where Element == T, Index == Int { + associatedtype T + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivector-1.getat) + func getAt(_ index: UInt32) -> T + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivector-1.getview) + func getView() -> WindowsFoundation.AnyIVectorView? + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivector-1.indexof) + func indexOf(_ value: T, _ index: inout UInt32) -> Bool + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivector-1.setat) + func setAt(_ index: UInt32, _ value: T) + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivector-1.insertat) + func insertAt(_ index: UInt32, _ value: T) + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivector-1.removeat) + func removeAt(_ index: UInt32) + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivector-1.append) + func append(_ value: T) + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivector-1.removeatend) + func removeAtEnd() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivector-1.clear) + func clear() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivector-1.size) + var size: UInt32 { get } +} + +public typealias AnyIVector = any IVector + +extension WindowsFoundation.CollectionChange { + public static var reset : WindowsFoundation.CollectionChange { + CollectionChange_Reset + } + public static var itemInserted : WindowsFoundation.CollectionChange { + CollectionChange_ItemInserted + } + public static var itemRemoved : WindowsFoundation.CollectionChange { + CollectionChange_ItemRemoved + } + public static var itemChanged : WindowsFoundation.CollectionChange { + CollectionChange_ItemChanged + } +} +extension WindowsFoundation.CollectionChange: @retroactive Hashable, @retroactive Codable {} + diff --git a/Sources/WindowsFoundation/Generated/Windows.Foundation.Numerics+ABI.swift b/Sources/WindowsFoundation/Generated/Windows.Foundation.Numerics+ABI.swift new file mode 100644 index 0000000..2d980ac --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Windows.Foundation.Numerics+ABI.swift @@ -0,0 +1,48 @@ +// WARNING: Please don't edit this file. It was generated by Swift/WinRT v0.0.1 +// swiftlint:disable all +import Foundation +import CWinRT + +public enum __ABI_Windows_Foundation_Numerics { +} +extension __x_ABI_CWindows_CFoundation_CNumerics_CMatrix3x2 { + public static func from(swift: WindowsFoundation.Matrix3x2) -> __x_ABI_CWindows_CFoundation_CNumerics_CMatrix3x2 { + .init(M11: swift.m11, M12: swift.m12, M21: swift.m21, M22: swift.m22, M31: swift.m31, M32: swift.m32) + } + } + extension __x_ABI_CWindows_CFoundation_CNumerics_CMatrix4x4 { + public static func from(swift: WindowsFoundation.Matrix4x4) -> __x_ABI_CWindows_CFoundation_CNumerics_CMatrix4x4 { + .init(M11: swift.m11, M12: swift.m12, M13: swift.m13, M14: swift.m14, M21: swift.m21, M22: swift.m22, M23: swift.m23, M24: swift.m24, M31: swift.m31, M32: swift.m32, M33: swift.m33, M34: swift.m34, M41: swift.m41, M42: swift.m42, M43: swift.m43, M44: swift.m44) + } + } + extension __x_ABI_CWindows_CFoundation_CNumerics_CVector3 { + public static func from(swift: WindowsFoundation.Vector3) -> __x_ABI_CWindows_CFoundation_CNumerics_CVector3 { + .init(X: swift.x, Y: swift.y, Z: swift.z) + } + } + extension __x_ABI_CWindows_CFoundation_CNumerics_CPlane { + public static func from(swift: WindowsFoundation.Plane) -> __x_ABI_CWindows_CFoundation_CNumerics_CPlane { + .init(Normal: .from(swift: swift.normal), D: swift.d) + } + } + extension __x_ABI_CWindows_CFoundation_CNumerics_CQuaternion { + public static func from(swift: WindowsFoundation.Quaternion) -> __x_ABI_CWindows_CFoundation_CNumerics_CQuaternion { + .init(X: swift.x, Y: swift.y, Z: swift.z, W: swift.w) + } + } + extension __x_ABI_CWindows_CFoundation_CNumerics_CRational { + public static func from(swift: WindowsFoundation.Rational) -> __x_ABI_CWindows_CFoundation_CNumerics_CRational { + .init(Numerator: swift.numerator, Denominator: swift.denominator) + } + } + extension __x_ABI_CWindows_CFoundation_CNumerics_CVector2 { + public static func from(swift: WindowsFoundation.Vector2) -> __x_ABI_CWindows_CFoundation_CNumerics_CVector2 { + .init(X: swift.x, Y: swift.y) + } + } + extension __x_ABI_CWindows_CFoundation_CNumerics_CVector4 { + public static func from(swift: WindowsFoundation.Vector4) -> __x_ABI_CWindows_CFoundation_CNumerics_CVector4 { + .init(X: swift.x, Y: swift.y, Z: swift.z, W: swift.w) + } + } + \ No newline at end of file diff --git a/Sources/WindowsFoundation/Generated/Windows.Foundation.Numerics+Impl.swift b/Sources/WindowsFoundation/Generated/Windows.Foundation.Numerics+Impl.swift new file mode 100644 index 0000000..7424bb2 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Windows.Foundation.Numerics+Impl.swift @@ -0,0 +1,7 @@ +// WARNING: Please don't edit this file. It was generated by Swift/WinRT v0.0.1 +// swiftlint:disable all +import Foundation +import CWinRT + +public enum __IMPL_Windows_Foundation_Numerics { +} diff --git a/Sources/WindowsFoundation/Generated/Windows.Foundation.Numerics.swift b/Sources/WindowsFoundation/Generated/Windows.Foundation.Numerics.swift new file mode 100644 index 0000000..1f1f64e --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Windows.Foundation.Numerics.swift @@ -0,0 +1,202 @@ +// WARNING: Please don't edit this file. It was generated by Swift/WinRT v0.0.1 +// swiftlint:disable all +import Foundation +import CWinRT + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix3x2) +public struct Matrix3x2: Hashable, Codable { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix3x2.m11) + public var m11: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix3x2.m12) + public var m12: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix3x2.m21) + public var m21: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix3x2.m22) + public var m22: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix3x2.m31) + public var m31: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix3x2.m32) + public var m32: Float = 0.0 + public init() {} + public init(m11: Float, m12: Float, m21: Float, m22: Float, m31: Float, m32: Float) { + self.m11 = m11 + self.m12 = m12 + self.m21 = m21 + self.m22 = m22 + self.m31 = m31 + self.m32 = m32 + } + public static func from(abi: __x_ABI_CWindows_CFoundation_CNumerics_CMatrix3x2) -> Matrix3x2 { + .init(m11: abi.M11, m12: abi.M12, m21: abi.M21, m22: abi.M22, m31: abi.M31, m32: abi.M32) + } +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix4x4) +public struct Matrix4x4: Hashable, Codable { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix4x4.m11) + public var m11: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix4x4.m12) + public var m12: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix4x4.m13) + public var m13: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix4x4.m14) + public var m14: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix4x4.m21) + public var m21: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix4x4.m22) + public var m22: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix4x4.m23) + public var m23: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix4x4.m24) + public var m24: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix4x4.m31) + public var m31: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix4x4.m32) + public var m32: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix4x4.m33) + public var m33: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix4x4.m34) + public var m34: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix4x4.m41) + public var m41: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix4x4.m42) + public var m42: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix4x4.m43) + public var m43: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.matrix4x4.m44) + public var m44: Float = 0.0 + public init() {} + public init(m11: Float, m12: Float, m13: Float, m14: Float, m21: Float, m22: Float, m23: Float, m24: Float, m31: Float, m32: Float, m33: Float, m34: Float, m41: Float, m42: Float, m43: Float, m44: Float) { + self.m11 = m11 + self.m12 = m12 + self.m13 = m13 + self.m14 = m14 + self.m21 = m21 + self.m22 = m22 + self.m23 = m23 + self.m24 = m24 + self.m31 = m31 + self.m32 = m32 + self.m33 = m33 + self.m34 = m34 + self.m41 = m41 + self.m42 = m42 + self.m43 = m43 + self.m44 = m44 + } + public static func from(abi: __x_ABI_CWindows_CFoundation_CNumerics_CMatrix4x4) -> Matrix4x4 { + .init(m11: abi.M11, m12: abi.M12, m13: abi.M13, m14: abi.M14, m21: abi.M21, m22: abi.M22, m23: abi.M23, m24: abi.M24, m31: abi.M31, m32: abi.M32, m33: abi.M33, m34: abi.M34, m41: abi.M41, m42: abi.M42, m43: abi.M43, m44: abi.M44) + } +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.vector3) +public struct Vector3: Hashable, Codable { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.vector3.x) + public var x: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.vector3.y) + public var y: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.vector3.z) + public var z: Float = 0.0 + public init() {} + public init(x: Float, y: Float, z: Float) { + self.x = x + self.y = y + self.z = z + } + public static func from(abi: __x_ABI_CWindows_CFoundation_CNumerics_CVector3) -> Vector3 { + .init(x: abi.X, y: abi.Y, z: abi.Z) + } +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.plane) +public struct Plane: Hashable, Codable { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.plane.normal) + public var normal: Vector3 = .init() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.plane.d) + public var d: Float = 0.0 + public init() {} + public init(normal: Vector3, d: Float) { + self.normal = normal + self.d = d + } + public static func from(abi: __x_ABI_CWindows_CFoundation_CNumerics_CPlane) -> Plane { + .init(normal: .from(abi: abi.Normal), d: abi.D) + } +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.quaternion) +public struct Quaternion: Hashable, Codable { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.quaternion.x) + public var x: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.quaternion.y) + public var y: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.quaternion.z) + public var z: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.quaternion.w) + public var w: Float = 0.0 + public init() {} + public init(x: Float, y: Float, z: Float, w: Float) { + self.x = x + self.y = y + self.z = z + self.w = w + } + public static func from(abi: __x_ABI_CWindows_CFoundation_CNumerics_CQuaternion) -> Quaternion { + .init(x: abi.X, y: abi.Y, z: abi.Z, w: abi.W) + } +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.rational) +public struct Rational: Hashable, Codable { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.rational.numerator) + public var numerator: UInt32 = 0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.rational.denominator) + public var denominator: UInt32 = 0 + public init() {} + public init(numerator: UInt32, denominator: UInt32) { + self.numerator = numerator + self.denominator = denominator + } + public static func from(abi: __x_ABI_CWindows_CFoundation_CNumerics_CRational) -> Rational { + .init(numerator: abi.Numerator, denominator: abi.Denominator) + } +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.vector2) +public struct Vector2: Hashable, Codable { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.vector2.x) + public var x: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.vector2.y) + public var y: Float = 0.0 + public init() {} + public init(x: Float, y: Float) { + self.x = x + self.y = y + } + public static func from(abi: __x_ABI_CWindows_CFoundation_CNumerics_CVector2) -> Vector2 { + .init(x: abi.X, y: abi.Y) + } +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.vector4) +public struct Vector4: Hashable, Codable { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.vector4.x) + public var x: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.vector4.y) + public var y: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.vector4.z) + public var z: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.numerics.vector4.w) + public var w: Float = 0.0 + public init() {} + public init(x: Float, y: Float, z: Float, w: Float) { + self.x = x + self.y = y + self.z = z + self.w = w + } + public static func from(abi: __x_ABI_CWindows_CFoundation_CNumerics_CVector4) -> Vector4 { + .init(x: abi.X, y: abi.Y, z: abi.Z, w: abi.W) + } +} + diff --git a/Sources/WindowsFoundation/Generated/Windows.Foundation.swift b/Sources/WindowsFoundation/Generated/Windows.Foundation.swift new file mode 100644 index 0000000..b4804b5 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/Windows.Foundation.swift @@ -0,0 +1,956 @@ +// WARNING: Please don't edit this file. It was generated by Swift/WinRT v0.0.1 +// swiftlint:disable all +import Foundation +import CWinRT + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.asyncstatus) +public typealias AsyncStatus = __x_ABI_CWindows_CFoundation_CAsyncStatus +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.propertytype) +public typealias PropertyType = __x_ABI_CWindows_CFoundation_CPropertyType +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.deferral) +public final class Deferral : WinRTClass, IClosable { + private typealias SwiftABI = __ABI_Windows_Foundation.IDeferral + private typealias CABI = __x_ABI_CWindows_CFoundation_CIDeferral + private lazy var _default: SwiftABI! = getInterfaceForCaching() + @_spi(WinRTInternal) + override public func _getABI() -> UnsafeMutablePointer? { + if T.self == CABI.self { + return RawPointer(_default) + } + return super._getABI() + } + + @_spi(WinRTInternal) + public static func from(abi: ComPtr<__x_ABI_CWindows_CFoundation_CIDeferral>?) -> Deferral? { + guard let abi = abi else { return nil } + return .init(fromAbi: WindowsFoundation.IInspectable(abi)) + } + + @_spi(WinRTInternal) + public init(fromAbi: WindowsFoundation.IInspectable) { + super.init(fromAbi) + } + + override public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + return super.queryInterface(iid) + } + private static let _IDeferralFactory: __ABI_Windows_Foundation.IDeferralFactory = try! RoGetActivationFactory(HString("Windows.Foundation.Deferral")) + public init(_ handler: DeferralCompletedHandler!) { + super.init(try! Self._IDeferralFactory.CreateImpl(handler)) + } + + private lazy var _IClosable: __ABI_Windows_Foundation.IClosable! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.deferral.close) + public func close() throws { + try _IClosable.CloseImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.deferral.complete) + public func complete() throws { + try _default.CompleteImpl() + } + + deinit { + _IClosable = nil + _default = nil + } +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.guidhelper) +public final class GuidHelper { + private static let _IGuidHelperStatics: __ABI_Windows_Foundation.IGuidHelperStatics = try! RoGetActivationFactory(HString("Windows.Foundation.GuidHelper")) + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.guidhelper.createnewguid) + public static func createNewGuid() -> Foundation.UUID { + return try! _IGuidHelperStatics.CreateNewGuidImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.guidhelper.empty) + public static var empty : Foundation.UUID { + get { try! _IGuidHelperStatics.get_EmptyImpl() } + } + +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.memorybuffer) +public final class MemoryBuffer : WinRTClass, IClosable, IMemoryBuffer { + private typealias SwiftABI = __ABI_Windows_Foundation.IMemoryBuffer + private typealias CABI = __x_ABI_CWindows_CFoundation_CIMemoryBuffer + private lazy var _default: SwiftABI! = getInterfaceForCaching() + @_spi(WinRTInternal) + override public func _getABI() -> UnsafeMutablePointer? { + if T.self == CABI.self { + return RawPointer(_default) + } + return super._getABI() + } + + @_spi(WinRTInternal) + public static func from(abi: ComPtr<__x_ABI_CWindows_CFoundation_CIMemoryBuffer>?) -> MemoryBuffer? { + guard let abi = abi else { return nil } + return .init(fromAbi: WindowsFoundation.IInspectable(abi)) + } + + @_spi(WinRTInternal) + public init(fromAbi: WindowsFoundation.IInspectable) { + super.init(fromAbi) + } + + override public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + return super.queryInterface(iid) + } + private static let _IMemoryBufferFactory: __ABI_Windows_Foundation.IMemoryBufferFactory = try! RoGetActivationFactory(HString("Windows.Foundation.MemoryBuffer")) + public init(_ capacity: UInt32) { + super.init(try! Self._IMemoryBufferFactory.CreateImpl(capacity)) + } + + private lazy var _IClosable: __ABI_Windows_Foundation.IClosable! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.memorybuffer.close) + public func close() throws { + try _IClosable.CloseImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.memorybuffer.createreference) + public func createReference() throws -> AnyIMemoryBufferReference! { + try _default.CreateReferenceImpl() + } + + deinit { + _IClosable = nil + _default = nil + } +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri) +public final class Uri : WinRTClass, IStringable { + private typealias SwiftABI = __ABI_Windows_Foundation.IUriRuntimeClass + private typealias CABI = __x_ABI_CWindows_CFoundation_CIUriRuntimeClass + private lazy var _default: SwiftABI! = getInterfaceForCaching() + @_spi(WinRTInternal) + override public func _getABI() -> UnsafeMutablePointer? { + if T.self == CABI.self { + return RawPointer(_default) + } + return super._getABI() + } + + @_spi(WinRTInternal) + public static func from(abi: ComPtr<__x_ABI_CWindows_CFoundation_CIUriRuntimeClass>?) -> Uri? { + guard let abi = abi else { return nil } + return .init(fromAbi: WindowsFoundation.IInspectable(abi)) + } + + @_spi(WinRTInternal) + public init(fromAbi: WindowsFoundation.IInspectable) { + super.init(fromAbi) + } + + override public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + return super.queryInterface(iid) + } + private static let _IUriEscapeStatics: __ABI_Windows_Foundation.IUriEscapeStatics = try! RoGetActivationFactory(HString("Windows.Foundation.Uri")) + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.unescapecomponent) + public static func unescapeComponent(_ toUnescape: String) -> String { + return try! _IUriEscapeStatics.UnescapeComponentImpl(toUnescape) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.escapecomponent) + public static func escapeComponent(_ toEscape: String) -> String { + return try! _IUriEscapeStatics.EscapeComponentImpl(toEscape) + } + + private static let _IUriRuntimeClassFactory: __ABI_Windows_Foundation.IUriRuntimeClassFactory = try! RoGetActivationFactory(HString("Windows.Foundation.Uri")) + public init(_ uri: String) { + super.init(try! Self._IUriRuntimeClassFactory.CreateUriImpl(uri)) + } + + public init(_ baseUri: String, _ relativeUri: String) { + super.init(try! Self._IUriRuntimeClassFactory.CreateWithRelativeUriImpl(baseUri, relativeUri)) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.equals) + public func equals(_ pUri: Uri!) throws -> Bool { + try _default.EqualsImpl(pUri) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.combineuri) + public func combineUri(_ relativeUri: String) throws -> Uri! { + try _default.CombineUriImpl(relativeUri) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.absoluteuri) + public var absoluteUri : String { + get { try! _default.get_AbsoluteUriImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.displayuri) + public var displayUri : String { + get { try! _default.get_DisplayUriImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.domain) + public var domain : String { + get { try! _default.get_DomainImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.extension) + public var `extension` : String { + get { try! _default.get_ExtensionImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.fragment) + public var fragment : String { + get { try! _default.get_FragmentImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.host) + public var host : String { + get { try! _default.get_HostImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.password) + public var password : String { + get { try! _default.get_PasswordImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.path) + public var path : String { + get { try! _default.get_PathImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.port) + public var port : Int32 { + get { try! _default.get_PortImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.query) + public var query : String { + get { try! _default.get_QueryImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.queryparsed) + public var queryParsed : WwwFormUrlDecoder! { + get { try! _default.get_QueryParsedImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.rawuri) + public var rawUri : String { + get { try! _default.get_RawUriImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.schemename) + public var schemeName : String { + get { try! _default.get_SchemeNameImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.suspicious) + public var suspicious : Bool { + get { try! _default.get_SuspiciousImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.username) + public var userName : String { + get { try! _default.get_UserNameImpl() } + } + + private lazy var _IUriRuntimeClassWithAbsoluteCanonicalUri: __ABI_Windows_Foundation.IUriRuntimeClassWithAbsoluteCanonicalUri! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.absolutecanonicaluri) + public var absoluteCanonicalUri : String { + get { try! _IUriRuntimeClassWithAbsoluteCanonicalUri.get_AbsoluteCanonicalUriImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.displayiri) + public var displayIri : String { + get { try! _IUriRuntimeClassWithAbsoluteCanonicalUri.get_DisplayIriImpl() } + } + + private lazy var _IStringable: __ABI_Windows_Foundation.IStringable! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.uri.tostring) + public func toString() throws -> String { + try _IStringable.ToStringImpl() + } + + deinit { + _default = nil + _IUriRuntimeClassWithAbsoluteCanonicalUri = nil + _IStringable = nil + } +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.wwwformurldecoder) +public final class WwwFormUrlDecoder : WinRTClass, IIterable, IVectorView { + public typealias T = AnyIWwwFormUrlDecoderEntry? + private typealias SwiftABI = __ABI_Windows_Foundation.IWwwFormUrlDecoderRuntimeClass + private typealias CABI = __x_ABI_CWindows_CFoundation_CIWwwFormUrlDecoderRuntimeClass + private lazy var _default: SwiftABI! = getInterfaceForCaching() + @_spi(WinRTInternal) + override public func _getABI() -> UnsafeMutablePointer? { + if T.self == CABI.self { + return RawPointer(_default) + } + return super._getABI() + } + + @_spi(WinRTInternal) + public static func from(abi: ComPtr<__x_ABI_CWindows_CFoundation_CIWwwFormUrlDecoderRuntimeClass>?) -> WwwFormUrlDecoder? { + guard let abi = abi else { return nil } + return .init(fromAbi: WindowsFoundation.IInspectable(abi)) + } + + @_spi(WinRTInternal) + public init(fromAbi: WindowsFoundation.IInspectable) { + super.init(fromAbi) + } + + override public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + return super.queryInterface(iid) + } + private static let _IWwwFormUrlDecoderRuntimeClassFactory: __ABI_Windows_Foundation.IWwwFormUrlDecoderRuntimeClassFactory = try! RoGetActivationFactory(HString("Windows.Foundation.WwwFormUrlDecoder")) + public init(_ query: String) { + super.init(try! Self._IWwwFormUrlDecoderRuntimeClassFactory.CreateWwwFormUrlDecoderImpl(query)) + } + + private lazy var _IIterable: IIterableIWwwFormUrlDecoderEntry! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.wwwformurldecoder.first) + public func first() -> AnyIIterator? { + try! _IIterable.FirstImpl() + } + + // MARK: Collection + public typealias Element = T + public var startIndex: Int { 0 } + public var endIndex: Int { Int(size) } + public func index(after i: Int) -> Int { + i+1 + } + + public func index(of: Element) -> Int? { + var index: UInt32 = 0 + let result = indexOf(of, &index) + guard result else { return nil } + return Int(index) + } + public var count: Int { Int(size) } + + public subscript(position: Int) -> Element { + get { + getAt(UInt32(position)) + } + } + // MARK: WinRT + private lazy var _IVectorView: IVectorViewIWwwFormUrlDecoderEntry! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.wwwformurldecoder.getat) + public func getAt(_ index: UInt32) -> AnyIWwwFormUrlDecoderEntry? { + try! _IVectorView.GetAtImpl(index) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.wwwformurldecoder.indexof) + public func indexOf(_ value: AnyIWwwFormUrlDecoderEntry?, _ index: inout UInt32) -> Bool { + try! _IVectorView.IndexOfImpl(value, &index) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.wwwformurldecoder.size) + public var size : UInt32 { + get { try! _IVectorView.get_SizeImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.wwwformurldecoder.getfirstvaluebyname) + public func getFirstValueByName(_ name: String) throws -> String { + try _default.GetFirstValueByNameImpl(name) + } + + deinit { + _IIterable = nil + _IVectorView = nil + _default = nil + } +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.wwwformurldecoderentry) +public final class WwwFormUrlDecoderEntry : WinRTClass, IWwwFormUrlDecoderEntry { + private typealias SwiftABI = __ABI_Windows_Foundation.IWwwFormUrlDecoderEntry + private typealias CABI = __x_ABI_CWindows_CFoundation_CIWwwFormUrlDecoderEntry + private lazy var _default: SwiftABI! = getInterfaceForCaching() + @_spi(WinRTInternal) + override public func _getABI() -> UnsafeMutablePointer? { + if T.self == CABI.self { + return RawPointer(_default) + } + return super._getABI() + } + + @_spi(WinRTInternal) + public static func from(abi: ComPtr<__x_ABI_CWindows_CFoundation_CIWwwFormUrlDecoderEntry>?) -> WwwFormUrlDecoderEntry? { + guard let abi = abi else { return nil } + return .init(fromAbi: WindowsFoundation.IInspectable(abi)) + } + + @_spi(WinRTInternal) + public init(fromAbi: WindowsFoundation.IInspectable) { + super.init(fromAbi) + } + + override public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + return super.queryInterface(iid) + } + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.wwwformurldecoderentry.name) + public var name : String { + get { try! _default.get_NameImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.wwwformurldecoderentry.value) + public var value : String { + get { try! _default.get_ValueImpl() } + } + + deinit { + _default = nil + } +} + +public typealias AsyncActionCompletedHandler = (AnyIAsyncAction?, AsyncStatus) -> () +public typealias AsyncActionProgressHandler = (AnyIAsyncActionWithProgress?, TProgress) -> () +public typealias AsyncActionWithProgressCompletedHandler = (AnyIAsyncActionWithProgress?, AsyncStatus) -> () +public typealias AsyncOperationCompletedHandler = (AnyIAsyncOperation?, AsyncStatus) -> () +public typealias AsyncOperationProgressHandler = (AnyIAsyncOperationWithProgress?, TProgress) -> () +public typealias AsyncOperationWithProgressCompletedHandler = (AnyIAsyncOperationWithProgress?, AsyncStatus) -> () +public typealias DeferralCompletedHandler = () -> () +public typealias EventHandler = (Any?, T) -> () +public typealias TypedEventHandler = (TSender, TResult) -> () +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.datetime) +public struct DateTime: Hashable, Codable { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.datetime.universaltime) + public var universalTime: Int64 = 0 + public init() {} + public init(universalTime: Int64) { + self.universalTime = universalTime + } + public static func from(abi: __x_ABI_CWindows_CFoundation_CDateTime) -> DateTime { + .init(universalTime: abi.UniversalTime) + } +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.point) +public struct Point: Hashable, Codable { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.point.x) + public var x: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.point.y) + public var y: Float = 0.0 + public init() {} + public init(x: Float, y: Float) { + self.x = x + self.y = y + } + public static func from(abi: __x_ABI_CWindows_CFoundation_CPoint) -> Point { + .init(x: abi.X, y: abi.Y) + } +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.rect) +public struct Rect: Hashable, Codable { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.rect.x) + public var x: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.rect.y) + public var y: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.rect.width) + public var width: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.rect.height) + public var height: Float = 0.0 + public init() {} + public init(x: Float, y: Float, width: Float, height: Float) { + self.x = x + self.y = y + self.width = width + self.height = height + } + public static func from(abi: __x_ABI_CWindows_CFoundation_CRect) -> Rect { + .init(x: abi.X, y: abi.Y, width: abi.Width, height: abi.Height) + } +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.size) +public struct Size: Hashable, Codable { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.size.width) + public var width: Float = 0.0 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.size.height) + public var height: Float = 0.0 + public init() {} + public init(width: Float, height: Float) { + self.width = width + self.height = height + } + public static func from(abi: __x_ABI_CWindows_CFoundation_CSize) -> Size { + .init(width: abi.Width, height: abi.Height) + } +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.timespan) +public struct TimeSpan: Hashable, Codable { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.timespan.duration) + public var duration: Int64 = 0 + public init() {} + public init(duration: Int64) { + self.duration = duration + } + public static func from(abi: __x_ABI_CWindows_CFoundation_CTimeSpan) -> TimeSpan { + .init(duration: abi.Duration) + } +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncaction) +public protocol IAsyncAction : IAsyncInfo { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncaction.getresults) + func getResults() throws + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncaction.completed) + var completed: WindowsFoundation.AsyncActionCompletedHandler! { get set } +} + +extension IAsyncAction { + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + switch iid { + case __ABI_Windows_Foundation.IAsyncActionWrapper.IID: + let wrapper = __ABI_Windows_Foundation.IAsyncActionWrapper(self) + return wrapper!.queryInterface(iid) + case __ABI_Windows_Foundation.IAsyncInfoWrapper.IID: + let wrapper = __ABI_Windows_Foundation.IAsyncInfoWrapper(self) + return wrapper!.queryInterface(iid) + default: return nil + } + } +} +public typealias AnyIAsyncAction = any IAsyncAction + +public extension IAsyncAction { + func get() async throws { + if status == .started { + let event = WaitableEvent() + completed = { _, _ in + Task { await event.signal() } + } + await event.wait() + } + return try getResults() + } +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncactionwithprogress-1) +public protocol IAsyncActionWithProgress : IAsyncInfo { + associatedtype TProgress + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncactionwithprogress-1.getresults) + func getResults() throws + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncactionwithprogress-1.progress) + var progress: WindowsFoundation.AsyncActionProgressHandler? { get set } + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncactionwithprogress-1.completed) + var completed: WindowsFoundation.AsyncActionWithProgressCompletedHandler? { get set } +} + +public typealias AnyIAsyncActionWithProgress = any IAsyncActionWithProgress + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncinfo) +public protocol IAsyncInfo : WinRTInterface { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncinfo.cancel) + func cancel() throws + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncinfo.close) + func close() throws + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncinfo.errorcode) + var errorCode: HRESULT { get } + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncinfo.id) + var id: UInt32 { get } + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncinfo.status) + var status: WindowsFoundation.AsyncStatus { get } +} + +extension IAsyncInfo { + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + switch iid { + case __ABI_Windows_Foundation.IAsyncInfoWrapper.IID: + let wrapper = __ABI_Windows_Foundation.IAsyncInfoWrapper(self) + return wrapper!.queryInterface(iid) + default: return nil + } + } +} +public typealias AnyIAsyncInfo = any IAsyncInfo + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncoperationwithprogress-2) +public protocol IAsyncOperationWithProgress : IAsyncInfo { + associatedtype TResult + associatedtype TProgress + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncoperationwithprogress-2.getresults) + func getResults() throws -> TResult + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncoperationwithprogress-2.progress) + var progress: WindowsFoundation.AsyncOperationProgressHandler? { get set } + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncoperationwithprogress-2.completed) + var completed: WindowsFoundation.AsyncOperationWithProgressCompletedHandler? { get set } +} + +public typealias AnyIAsyncOperationWithProgress = any IAsyncOperationWithProgress + +public extension IAsyncOperationWithProgress { + func get() async throws -> TResult { + if status == .started { + let event = WaitableEvent() + completed = { _, _ in + Task { await event.signal() } + } + await event.wait() + } + return try getResults() + } +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncoperation-1) +public protocol IAsyncOperation : IAsyncInfo { + associatedtype TResult + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncoperation-1.getresults) + func getResults() throws -> TResult + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iasyncoperation-1.completed) + var completed: WindowsFoundation.AsyncOperationCompletedHandler? { get set } +} + +public typealias AnyIAsyncOperation = any IAsyncOperation + +public extension IAsyncOperation { + func get() async throws -> TResult { + if status == .started { + let event = WaitableEvent() + completed = { _, _ in + Task { await event.signal() } + } + await event.wait() + } + return try getResults() + } +} + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iclosable) +public protocol IClosable : WinRTInterface { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iclosable.close) + func close() throws +} + +extension IClosable { + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + switch iid { + case __ABI_Windows_Foundation.IClosableWrapper.IID: + let wrapper = __ABI_Windows_Foundation.IClosableWrapper(self) + return wrapper!.queryInterface(iid) + default: return nil + } + } +} +public typealias AnyIClosable = any IClosable + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.igetactivationfactory) +public protocol IGetActivationFactory : WinRTInterface { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.igetactivationfactory.getactivationfactory) + func getActivationFactory(_ activatableClassId: String) throws -> Any! +} + +extension IGetActivationFactory { + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + switch iid { + case __ABI_Windows_Foundation.IGetActivationFactoryWrapper.IID: + let wrapper = __ABI_Windows_Foundation.IGetActivationFactoryWrapper(self) + return wrapper!.queryInterface(iid) + default: return nil + } + } +} +public typealias AnyIGetActivationFactory = any IGetActivationFactory + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.imemorybuffer) +public protocol IMemoryBuffer : IClosable { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.imemorybuffer.createreference) + func createReference() throws -> WindowsFoundation.AnyIMemoryBufferReference! +} + +extension IMemoryBuffer { + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + switch iid { + case __ABI_Windows_Foundation.IMemoryBufferWrapper.IID: + let wrapper = __ABI_Windows_Foundation.IMemoryBufferWrapper(self) + return wrapper!.queryInterface(iid) + case __ABI_Windows_Foundation.IClosableWrapper.IID: + let wrapper = __ABI_Windows_Foundation.IClosableWrapper(self) + return wrapper!.queryInterface(iid) + default: return nil + } + } +} +public typealias AnyIMemoryBuffer = any IMemoryBuffer + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.imemorybufferreference) +public protocol IMemoryBufferReference : IClosable, IMemoryBufferByteAccess { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.imemorybufferreference.capacity) + var capacity: UInt32 { get } + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.imemorybufferreference.closed) + var closed: Event> { get } +} + +extension IMemoryBufferReference { + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + switch iid { + case __ABI_Windows_Foundation.IMemoryBufferReferenceWrapper.IID: + let wrapper = __ABI_Windows_Foundation.IMemoryBufferReferenceWrapper(self) + return wrapper!.queryInterface(iid) + case __ABI_Windows_Foundation.IClosableWrapper.IID: + let wrapper = __ABI_Windows_Foundation.IClosableWrapper(self) + return wrapper!.queryInterface(iid) + case __ABI_.IMemoryBufferByteAccessWrapper.IID: + let wrapper = __ABI_.IMemoryBufferByteAccessWrapper(self) + return wrapper!.queryInterface(iid) + default: return nil + } + } +} +extension IMemoryBufferReference { + public var data: Data { + guard let buffer = try? buffer, let ptr = buffer.baseAddress else { return Data() } + return Data(bytesNoCopy: ptr, count: buffer.count, deallocator: .none) + } +} +public typealias AnyIMemoryBufferReference = any IMemoryBufferReference + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ipropertyvalue) +public protocol IPropertyValue : WinRTInterface { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ipropertyvalue.getuint8) + func getUInt8() throws -> UInt8 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ipropertyvalue.getint16) + func getInt16() throws -> Int16 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ipropertyvalue.getuint16) + func getUInt16() throws -> UInt16 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ipropertyvalue.getint32) + func getInt32() throws -> Int32 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ipropertyvalue.getuint32) + func getUInt32() throws -> UInt32 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ipropertyvalue.getint64) + func getInt64() throws -> Int64 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ipropertyvalue.getuint64) + func getUInt64() throws -> UInt64 + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ipropertyvalue.getsingle) + func getSingle() throws -> Float + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ipropertyvalue.getdouble) + func getDouble() throws -> Double + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ipropertyvalue.getchar16) + func getChar16() throws -> Character + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ipropertyvalue.getboolean) + func getBoolean() throws -> Bool + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ipropertyvalue.getstring) + func getString() throws -> String + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ipropertyvalue.getguid) + func getGuid() throws -> Foundation.UUID + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ipropertyvalue.getdatetime) + func getDateTime() throws -> WindowsFoundation.DateTime + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ipropertyvalue.gettimespan) + func getTimeSpan() throws -> WindowsFoundation.TimeSpan + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ipropertyvalue.getpoint) + func getPoint() throws -> WindowsFoundation.Point + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ipropertyvalue.getsize) + func getSize() throws -> WindowsFoundation.Size + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ipropertyvalue.getrect) + func getRect() throws -> WindowsFoundation.Rect + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ipropertyvalue.isnumericscalar) + var isNumericScalar: Bool { get } + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ipropertyvalue.type) + var type: WindowsFoundation.PropertyType { get } +} + +public typealias AnyIPropertyValue = any IPropertyValue + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ireferencearray-1) +public protocol IReferenceArray : IPropertyValue { + associatedtype T +} + +public typealias AnyIReferenceArray = any IReferenceArray + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ireference-1) +public protocol IReference : IPropertyValue { + associatedtype T + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.ireference-1.value) + var value: T { get } +} + +public typealias AnyIReference = any IReference + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.istringable) +public protocol IStringable : WinRTInterface { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.istringable.tostring) + func toString() throws -> String +} + +extension IStringable { + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + switch iid { + case __ABI_Windows_Foundation.IStringableWrapper.IID: + let wrapper = __ABI_Windows_Foundation.IStringableWrapper(self) + return wrapper!.queryInterface(iid) + default: return nil + } + } +} +public typealias AnyIStringable = any IStringable + +/// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iwwwformurldecoderentry) +public protocol IWwwFormUrlDecoderEntry : WinRTInterface { + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iwwwformurldecoderentry.name) + var name: String { get } + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.iwwwformurldecoderentry.value) + var value: String { get } +} + +extension IWwwFormUrlDecoderEntry { + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { + switch iid { + case __ABI_Windows_Foundation.IWwwFormUrlDecoderEntryWrapper.IID: + let wrapper = __ABI_Windows_Foundation.IWwwFormUrlDecoderEntryWrapper(self) + return wrapper!.queryInterface(iid) + default: return nil + } + } +} +public typealias AnyIWwwFormUrlDecoderEntry = any IWwwFormUrlDecoderEntry + +extension WindowsFoundation.AsyncStatus { + public static var canceled : WindowsFoundation.AsyncStatus { + __x_ABI_CWindows_CFoundation_CAsyncStatus_Canceled + } + public static var completed : WindowsFoundation.AsyncStatus { + __x_ABI_CWindows_CFoundation_CAsyncStatus_Completed + } + public static var error : WindowsFoundation.AsyncStatus { + __x_ABI_CWindows_CFoundation_CAsyncStatus_Error + } + public static var started : WindowsFoundation.AsyncStatus { + __x_ABI_CWindows_CFoundation_CAsyncStatus_Started + } +} +extension WindowsFoundation.AsyncStatus: @retroactive Hashable, @retroactive Codable {} + +extension WindowsFoundation.PropertyType { + public static var empty : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_Empty + } + public static var uint8 : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_UInt8 + } + public static var int16 : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_Int16 + } + public static var uint16 : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_UInt16 + } + public static var int32 : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_Int32 + } + public static var uint32 : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_UInt32 + } + public static var int64 : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_Int64 + } + public static var uint64 : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_UInt64 + } + public static var single : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_Single + } + public static var double : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_Double + } + public static var char16 : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_Char16 + } + public static var boolean : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_Boolean + } + public static var string : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_String + } + public static var inspectable : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_Inspectable + } + public static var dateTime : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_DateTime + } + public static var timeSpan : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_TimeSpan + } + public static var guid : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_Guid + } + public static var point : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_Point + } + public static var size : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_Size + } + public static var rect : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_Rect + } + public static var otherType : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_OtherType + } + public static var uint8Array : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_UInt8Array + } + public static var int16Array : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_Int16Array + } + public static var uint16Array : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_UInt16Array + } + public static var int32Array : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_Int32Array + } + public static var uint32Array : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_UInt32Array + } + public static var int64Array : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_Int64Array + } + public static var uint64Array : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_UInt64Array + } + public static var singleArray : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_SingleArray + } + public static var doubleArray : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_DoubleArray + } + public static var char16Array : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_Char16Array + } + public static var booleanArray : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_BooleanArray + } + public static var stringArray : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_StringArray + } + public static var inspectableArray : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_InspectableArray + } + public static var dateTimeArray : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_DateTimeArray + } + public static var timeSpanArray : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_TimeSpanArray + } + public static var guidArray : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_GuidArray + } + public static var pointArray : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_PointArray + } + public static var sizeArray : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_SizeArray + } + public static var rectArray : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_RectArray + } + public static var otherTypeArray : WindowsFoundation.PropertyType { + __x_ABI_CWindows_CFoundation_CPropertyType_OtherTypeArray + } +} +extension WindowsFoundation.PropertyType: @retroactive Hashable, @retroactive Codable {} + diff --git a/Sources/WindowsFoundation/Generated/WindowsFoundation+Generics.swift b/Sources/WindowsFoundation/Generated/WindowsFoundation+Generics.swift new file mode 100644 index 0000000..baf8d37 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/WindowsFoundation+Generics.swift @@ -0,0 +1,2387 @@ +// WARNING: Please don't edit this file. It was generated by Swift/WinRT v0.0.1 +// swiftlint:disable all +import Foundation +import CWinRT + +private var IID___x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectable: WindowsFoundation.IID { + .init(Data1: 0xfe2f3d47, Data2: 0x5d47, Data3: 0x5499, Data4: ( 0x83,0x74,0x43,0x0c,0x7c,0xda,0x02,0x04 ))// fe2f3d47-5d47-5499-8374-430c7cda0204 +} + +internal var __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableVTable: __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableVtbl = .init( + QueryInterface: { __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.queryInterface($0, $1, $2) }, + AddRef: { __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.addRef($0) }, + Release: { __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 3).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = WindowsFoundation.__x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.IID + $1!.pointee = 3 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.Collections.IIterable`1>").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + First: { + guard let __unwrapped__instance = __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.first() + let resultWrapper = WindowsFoundation.__x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper(result) + resultWrapper?.copyTo($1) + return S_OK + } +) +typealias __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper = InterfaceWrapperBase +internal class IIterableIKeyValuePairString_Any: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectable } + + internal func FirstImpl() throws -> WindowsFoundation.AnyIIterator?>? { + let (result) = try ComPtrs.initialize { resultAbi in + _ = try perform(as: __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.First(pThis, &resultAbi)) + } + } + return WindowsFoundation.__x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.unwrapFrom(abi: result) + } + +} + +internal enum __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableBridge : AbiInterfaceBridge { + internal typealias CABI = __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectable + internal typealias SwiftABI = IIterableIKeyValuePairString_Any + internal typealias SwiftProjection = WindowsFoundation.AnyIIterable?> + internal static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableImpl(abi) + } + + internal static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } +} + +fileprivate class __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableImpl : IIterable, AbiInterfaceImpl { + typealias T = WindowsFoundation.AnyIKeyValuePair? + typealias Bridge = __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableBridge + let _default: Bridge.SwiftABI + init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + // MARK: WinRT + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iiterable-1.first) + fileprivate func first() -> WindowsFoundation.AnyIIterator?>? { + try! _default.FirstImpl() + } + + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { nil } +} + +private var IID___x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRING: WindowsFoundation.IID { + .init(Data1: 0xe9bdaaf0, Data2: 0xcbf6, Data3: 0x5c72, Data4: ( 0xbe,0x90,0x29,0xcb,0xf3,0xa1,0x31,0x9b ))// e9bdaaf0-cbf6-5c72-be90-29cbf3a1319b +} + +internal var __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGVTable: __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGVtbl = .init( + QueryInterface: { __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.queryInterface($0, $1, $2) }, + AddRef: { __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.addRef($0) }, + Release: { __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 3).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = WindowsFoundation.__x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.IID + $1!.pointee = 3 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.Collections.IIterable`1>").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + First: { + guard let __unwrapped__instance = __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.first() + let resultWrapper = WindowsFoundation.__x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper(result) + resultWrapper?.copyTo($1) + return S_OK + } +) +typealias __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper = InterfaceWrapperBase +internal class IIterableIKeyValuePairString_String: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRING } + + internal func FirstImpl() throws -> WindowsFoundation.AnyIIterator?>? { + let (result) = try ComPtrs.initialize { resultAbi in + _ = try perform(as: __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.First(pThis, &resultAbi)) + } + } + return WindowsFoundation.__x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.unwrapFrom(abi: result) + } + +} + +internal enum __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGBridge : AbiInterfaceBridge { + internal typealias CABI = __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRING + internal typealias SwiftABI = IIterableIKeyValuePairString_String + internal typealias SwiftProjection = WindowsFoundation.AnyIIterable?> + internal static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGImpl(abi) + } + + internal static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } +} + +fileprivate class __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGImpl : IIterable, AbiInterfaceImpl { + typealias T = WindowsFoundation.AnyIKeyValuePair? + typealias Bridge = __x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGBridge + let _default: Bridge.SwiftABI + init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + // MARK: WinRT + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iiterable-1.first) + fileprivate func first() -> WindowsFoundation.AnyIIterator?>? { + try! _default.FirstImpl() + } + + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { nil } +} + +private var IID___x_ABI_C__FIIterable_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntry: WindowsFoundation.IID { + .init(Data1: 0x876be83b, Data2: 0x7218, Data3: 0x5bfb, Data4: ( 0xa1,0x69,0x83,0x15,0x2e,0xf7,0xe1,0x46 ))// 876be83b-7218-5bfb-a169-83152ef7e146 +} + +internal var __x_ABI_C__FIIterable_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryVTable: __x_ABI_C__FIIterable_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryVtbl = .init( + QueryInterface: { __x_ABI_C__FIIterable_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper.queryInterface($0, $1, $2) }, + AddRef: { __x_ABI_C__FIIterable_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper.addRef($0) }, + Release: { __x_ABI_C__FIIterable_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 3).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = WindowsFoundation.__x_ABI_C__FIIterable_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper.IID + $1!.pointee = 3 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.Collections.IIterable`1").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + First: { + guard let __unwrapped__instance = __x_ABI_C__FIIterable_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.first() + let resultWrapper = WindowsFoundation.__x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper(result) + resultWrapper?.copyTo($1) + return S_OK + } +) +typealias __x_ABI_C__FIIterable_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper = InterfaceWrapperBase +internal class IIterableIWwwFormUrlDecoderEntry: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_C__FIIterable_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntry } + + internal func FirstImpl() throws -> WindowsFoundation.AnyIIterator? { + let (result) = try ComPtrs.initialize { resultAbi in + _ = try perform(as: __x_ABI_C__FIIterable_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntry.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.First(pThis, &resultAbi)) + } + } + return WindowsFoundation.__x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper.unwrapFrom(abi: result) + } + +} + +internal enum __x_ABI_C__FIIterable_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryBridge : AbiInterfaceBridge { + internal typealias CABI = __x_ABI_C__FIIterable_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntry + internal typealias SwiftABI = IIterableIWwwFormUrlDecoderEntry + internal typealias SwiftProjection = WindowsFoundation.AnyIIterable + internal static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return __x_ABI_C__FIIterable_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryImpl(abi) + } + + internal static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__x_ABI_C__FIIterable_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } +} + +fileprivate class __x_ABI_C__FIIterable_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryImpl : IIterable, AbiInterfaceImpl { + typealias T = WindowsFoundation.AnyIWwwFormUrlDecoderEntry? + typealias Bridge = __x_ABI_C__FIIterable_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryBridge + let _default: Bridge.SwiftABI + init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + // MARK: WinRT + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iiterable-1.first) + fileprivate func first() -> WindowsFoundation.AnyIIterator? { + try! _default.FirstImpl() + } + + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { nil } +} + +private var IID___x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectable: WindowsFoundation.IID { + .init(Data1: 0x5db5fa32, Data2: 0x707c, Data3: 0x5849, Data4: ( 0xa0,0x6b,0x91,0xc8,0xeb,0x9d,0x10,0xe8 ))// 5db5fa32-707c-5849-a06b-91c8eb9d10e8 +} + +internal var __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableVTable: __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableVtbl = .init( + QueryInterface: { __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.queryInterface($0, $1, $2) }, + AddRef: { __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.addRef($0) }, + Release: { __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 3).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = WindowsFoundation.__x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.IID + $1!.pointee = 3 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.Collections.IIterator`1>").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + get_Current: { + guard let __unwrapped__instance = __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.current + let resultWrapper = WindowsFoundation.__x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper(result) + resultWrapper?.copyTo($1) + return S_OK + }, + + get_HasCurrent: { + guard let __unwrapped__instance = __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.hasCurrent + $1?.initialize(to: .init(from: result)) + return S_OK + }, + + MoveNext: { + guard let __unwrapped__instance = __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.moveNext() + $1?.initialize(to: .init(from: result)) + return S_OK + }, + + GetMany: { _, _, _, _ in return failWith(err: E_NOTIMPL) } +) +typealias __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper = InterfaceWrapperBase +internal class IIteratorIKeyValuePairString_Any: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectable } + + internal func get_CurrentImpl() throws -> WindowsFoundation.AnyIKeyValuePair? { + let (result) = try ComPtrs.initialize { resultAbi in + _ = try perform(as: __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Current(pThis, &resultAbi)) + } + } + return WindowsFoundation.__x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.unwrapFrom(abi: result) + } + + internal func get_HasCurrentImpl() throws -> Bool { + var result: boolean = 0 + _ = try perform(as: __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_HasCurrent(pThis, &result)) + } + return .init(from: result) + } + + internal func MoveNextImpl() throws -> Bool { + var result: boolean = 0 + _ = try perform(as: __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.MoveNext(pThis, &result)) + } + return .init(from: result) + } + +} + +internal enum __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableBridge : AbiInterfaceBridge { + internal typealias CABI = __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectable + internal typealias SwiftABI = IIteratorIKeyValuePairString_Any + internal typealias SwiftProjection = WindowsFoundation.AnyIIterator?> + internal static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableImpl(abi) + } + + internal static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } +} + +fileprivate class __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableImpl : IIterator, AbiInterfaceImpl { + typealias T = WindowsFoundation.AnyIKeyValuePair? + typealias Bridge = __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableBridge + let _default: Bridge.SwiftABI + init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + // MARK: WinRT + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iiterator-1.movenext) + fileprivate func moveNext() -> Bool { + try! _default.MoveNextImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iiterator-1.current) + fileprivate var current : WindowsFoundation.AnyIKeyValuePair? { + get { try! _default.get_CurrentImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iiterator-1.hascurrent) + fileprivate var hasCurrent : Bool { + get { try! _default.get_HasCurrentImpl() } + } + + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { nil } +} + +private var IID___x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRING: WindowsFoundation.IID { + .init(Data1: 0x05eb86f1, Data2: 0x7140, Data3: 0x5517, Data4: ( 0xb8,0x8d,0xcb,0xae,0xbe,0x57,0xe6,0xb1 ))// 05eb86f1-7140-5517-b88d-cbaebe57e6b1 +} + +internal var __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGVTable: __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGVtbl = .init( + QueryInterface: { __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.queryInterface($0, $1, $2) }, + AddRef: { __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.addRef($0) }, + Release: { __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 3).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = WindowsFoundation.__x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.IID + $1!.pointee = 3 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.Collections.IIterator`1>").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + get_Current: { + guard let __unwrapped__instance = __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.current + let resultWrapper = WindowsFoundation.__x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper(result) + resultWrapper?.copyTo($1) + return S_OK + }, + + get_HasCurrent: { + guard let __unwrapped__instance = __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.hasCurrent + $1?.initialize(to: .init(from: result)) + return S_OK + }, + + MoveNext: { + guard let __unwrapped__instance = __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.moveNext() + $1?.initialize(to: .init(from: result)) + return S_OK + }, + + GetMany: { _, _, _, _ in return failWith(err: E_NOTIMPL) } +) +typealias __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper = InterfaceWrapperBase +internal class IIteratorIKeyValuePairString_String: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRING } + + internal func get_CurrentImpl() throws -> WindowsFoundation.AnyIKeyValuePair? { + let (result) = try ComPtrs.initialize { resultAbi in + _ = try perform(as: __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Current(pThis, &resultAbi)) + } + } + return WindowsFoundation.__x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.unwrapFrom(abi: result) + } + + internal func get_HasCurrentImpl() throws -> Bool { + var result: boolean = 0 + _ = try perform(as: __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_HasCurrent(pThis, &result)) + } + return .init(from: result) + } + + internal func MoveNextImpl() throws -> Bool { + var result: boolean = 0 + _ = try perform(as: __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.MoveNext(pThis, &result)) + } + return .init(from: result) + } + +} + +internal enum __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGBridge : AbiInterfaceBridge { + internal typealias CABI = __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRING + internal typealias SwiftABI = IIteratorIKeyValuePairString_String + internal typealias SwiftProjection = WindowsFoundation.AnyIIterator?> + internal static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGImpl(abi) + } + + internal static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } +} + +fileprivate class __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGImpl : IIterator, AbiInterfaceImpl { + typealias T = WindowsFoundation.AnyIKeyValuePair? + typealias Bridge = __x_ABI_C__FIIterator_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGBridge + let _default: Bridge.SwiftABI + init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + // MARK: WinRT + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iiterator-1.movenext) + fileprivate func moveNext() -> Bool { + try! _default.MoveNextImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iiterator-1.current) + fileprivate var current : WindowsFoundation.AnyIKeyValuePair? { + get { try! _default.get_CurrentImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iiterator-1.hascurrent) + fileprivate var hasCurrent : Bool { + get { try! _default.get_HasCurrentImpl() } + } + + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { nil } +} + +private var IID___x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntry: WindowsFoundation.IID { + .init(Data1: 0x32e54295, Data2: 0x373c, Data3: 0x50cb, Data4: ( 0x80,0xa1,0x46,0x8a,0x99,0x0c,0xa7,0x80 ))// 32e54295-373c-50cb-80a1-468a990ca780 +} + +internal var __x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryVTable: __x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryVtbl = .init( + QueryInterface: { __x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper.queryInterface($0, $1, $2) }, + AddRef: { __x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper.addRef($0) }, + Release: { __x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 3).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = WindowsFoundation.__x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper.IID + $1!.pointee = 3 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.Collections.IIterator`1").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + get_Current: { + guard let __unwrapped__instance = __x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.current + let resultWrapper = __ABI_Windows_Foundation.IWwwFormUrlDecoderEntryWrapper(result) + resultWrapper?.copyTo($1) + return S_OK + }, + + get_HasCurrent: { + guard let __unwrapped__instance = __x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.hasCurrent + $1?.initialize(to: .init(from: result)) + return S_OK + }, + + MoveNext: { + guard let __unwrapped__instance = __x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.moveNext() + $1?.initialize(to: .init(from: result)) + return S_OK + }, + + GetMany: { _, _, _, _ in return failWith(err: E_NOTIMPL) } +) +typealias __x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper = InterfaceWrapperBase +internal class IIteratorIWwwFormUrlDecoderEntry: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntry } + + internal func get_CurrentImpl() throws -> WindowsFoundation.AnyIWwwFormUrlDecoderEntry? { + let (result) = try ComPtrs.initialize { resultAbi in + _ = try perform(as: __x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntry.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Current(pThis, &resultAbi)) + } + } + return __ABI_Windows_Foundation.IWwwFormUrlDecoderEntryWrapper.unwrapFrom(abi: result) + } + + internal func get_HasCurrentImpl() throws -> Bool { + var result: boolean = 0 + _ = try perform(as: __x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntry.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_HasCurrent(pThis, &result)) + } + return .init(from: result) + } + + internal func MoveNextImpl() throws -> Bool { + var result: boolean = 0 + _ = try perform(as: __x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntry.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.MoveNext(pThis, &result)) + } + return .init(from: result) + } + +} + +internal enum __x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryBridge : AbiInterfaceBridge { + internal typealias CABI = __x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntry + internal typealias SwiftABI = IIteratorIWwwFormUrlDecoderEntry + internal typealias SwiftProjection = WindowsFoundation.AnyIIterator + internal static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return __x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryImpl(abi) + } + + internal static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } +} + +fileprivate class __x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryImpl : IIterator, AbiInterfaceImpl { + typealias T = WindowsFoundation.AnyIWwwFormUrlDecoderEntry? + typealias Bridge = __x_ABI_C__FIIterator_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryBridge + let _default: Bridge.SwiftABI + init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + // MARK: WinRT + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iiterator-1.movenext) + fileprivate func moveNext() -> Bool { + try! _default.MoveNextImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iiterator-1.current) + fileprivate var current : WindowsFoundation.AnyIWwwFormUrlDecoderEntry? { + get { try! _default.get_CurrentImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iiterator-1.hascurrent) + fileprivate var hasCurrent : Bool { + get { try! _default.get_HasCurrentImpl() } + } + + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { nil } +} + +private var IID___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectable: WindowsFoundation.IID { + .init(Data1: 0x09335560, Data2: 0x6c6b, Data3: 0x5a26, Data4: ( 0x93,0x48,0x97,0xb7,0x81,0x13,0x2b,0x20 ))// 09335560-6c6b-5a26-9348-97b781132b20 +} + +internal var __x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableVTable: __x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableVtbl = .init( + QueryInterface: { __x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.queryInterface($0, $1, $2) }, + AddRef: { __x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.addRef($0) }, + Release: { __x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 3).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = WindowsFoundation.__x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.IID + $1!.pointee = 3 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.Collections.IKeyValuePair`2").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + get_Key: { + guard let __unwrapped__instance = __x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.key + $1?.initialize(to: try! HString(result).detach()) + return S_OK + }, + + get_Value: { + guard let __unwrapped__instance = __x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.value + let resultWrapper = __ABI_.AnyWrapper(result) + resultWrapper?.copyTo($1) + return S_OK + } +) +typealias __x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper = InterfaceWrapperBase +internal class IKeyValuePairString_Any: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectable } + + internal func get_KeyImpl() throws -> String { + var result: HSTRING? + _ = try perform(as: __x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Key(pThis, &result)) + } + return .init(from: result) + } + + internal func get_ValueImpl() throws -> Any? { + let (result) = try ComPtrs.initialize { resultAbi in + _ = try perform(as: __x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Value(pThis, &resultAbi)) + } + } + return __ABI_.AnyWrapper.unwrapFrom(abi: result) + } + +} + +internal enum __x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableBridge : AbiInterfaceBridge { + internal typealias CABI = __x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectable + internal typealias SwiftABI = IKeyValuePairString_Any + internal typealias SwiftProjection = WindowsFoundation.AnyIKeyValuePair + internal static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return __x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableImpl(abi) + } + + internal static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } +} + +fileprivate class __x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableImpl : IKeyValuePair, AbiInterfaceImpl { + typealias K = String + typealias V = Any? + typealias Bridge = __x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableBridge + let _default: Bridge.SwiftABI + init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + // MARK: WinRT + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ikeyvaluepair-2.key) + fileprivate var key : String { + get { try! _default.get_KeyImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ikeyvaluepair-2.value) + fileprivate var value : Any? { + get { try! _default.get_ValueImpl() } + } + + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { nil } +} + +private var IID___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRING: WindowsFoundation.IID { + .init(Data1: 0x60310303, Data2: 0x49c5, Data3: 0x52e6, Data4: ( 0xab,0xc6,0xa9,0xb3,0x6e,0xcc,0xc7,0x16 ))// 60310303-49c5-52e6-abc6-a9b36eccc716 +} + +internal var __x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGVTable: __x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGVtbl = .init( + QueryInterface: { __x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.queryInterface($0, $1, $2) }, + AddRef: { __x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.addRef($0) }, + Release: { __x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 3).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = WindowsFoundation.__x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.IID + $1!.pointee = 3 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.Collections.IKeyValuePair`2").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + get_Key: { + guard let __unwrapped__instance = __x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.key + $1?.initialize(to: try! HString(result).detach()) + return S_OK + }, + + get_Value: { + guard let __unwrapped__instance = __x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.value + $1?.initialize(to: try! HString(result).detach()) + return S_OK + } +) +typealias __x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper = InterfaceWrapperBase +internal class IKeyValuePairString_String: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRING } + + internal func get_KeyImpl() throws -> String { + var result: HSTRING? + _ = try perform(as: __x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Key(pThis, &result)) + } + return .init(from: result) + } + + internal func get_ValueImpl() throws -> String { + var result: HSTRING? + _ = try perform(as: __x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Value(pThis, &result)) + } + return .init(from: result) + } + +} + +internal enum __x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGBridge : AbiInterfaceBridge { + internal typealias CABI = __x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRING + internal typealias SwiftABI = IKeyValuePairString_String + internal typealias SwiftProjection = WindowsFoundation.AnyIKeyValuePair + internal static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return __x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGImpl(abi) + } + + internal static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } +} + +fileprivate class __x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGImpl : IKeyValuePair, AbiInterfaceImpl { + typealias K = String + typealias V = String + typealias Bridge = __x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGBridge + let _default: Bridge.SwiftABI + init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + // MARK: WinRT + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ikeyvaluepair-2.key) + fileprivate var key : String { + get { try! _default.get_KeyImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ikeyvaluepair-2.value) + fileprivate var value : String { + get { try! _default.get_ValueImpl() } + } + + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { nil } +} + +private var IID___x_ABI_C__FIMapChangedEventArgs_1_HSTRING: WindowsFoundation.IID { + .init(Data1: 0x60141efb, Data2: 0xf2f9, Data3: 0x5377, Data4: ( 0x96,0xfd,0xf8,0xc6,0x0d,0x95,0x58,0xb5 ))// 60141efb-f2f9-5377-96fd-f8c60d9558b5 +} + +internal var __x_ABI_C__FIMapChangedEventArgs_1_HSTRINGVTable: __x_ABI_C__FIMapChangedEventArgs_1_HSTRINGVtbl = .init( + QueryInterface: { __x_ABI_C__FIMapChangedEventArgs_1_HSTRINGWrapper.queryInterface($0, $1, $2) }, + AddRef: { __x_ABI_C__FIMapChangedEventArgs_1_HSTRINGWrapper.addRef($0) }, + Release: { __x_ABI_C__FIMapChangedEventArgs_1_HSTRINGWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 3).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = WindowsFoundation.__x_ABI_C__FIMapChangedEventArgs_1_HSTRINGWrapper.IID + $1!.pointee = 3 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.Collections.IMapChangedEventArgs`1").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + get_CollectionChange: { + guard let __unwrapped__instance = __x_ABI_C__FIMapChangedEventArgs_1_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.collectionChange + $1?.initialize(to: result) + return S_OK + }, + + get_Key: { + guard let __unwrapped__instance = __x_ABI_C__FIMapChangedEventArgs_1_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.key + $1?.initialize(to: try! HString(result).detach()) + return S_OK + } +) +typealias __x_ABI_C__FIMapChangedEventArgs_1_HSTRINGWrapper = InterfaceWrapperBase +internal class IMapChangedEventArgsString: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_C__FIMapChangedEventArgs_1_HSTRING } + + internal func get_CollectionChangeImpl() throws -> WindowsFoundation.CollectionChange { + var result: __x_ABI_CWindows_CFoundation_CCollections_CCollectionChange = .init(0) + _ = try perform(as: __x_ABI_C__FIMapChangedEventArgs_1_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_CollectionChange(pThis, &result)) + } + return result + } + + internal func get_KeyImpl() throws -> String { + var result: HSTRING? + _ = try perform(as: __x_ABI_C__FIMapChangedEventArgs_1_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Key(pThis, &result)) + } + return .init(from: result) + } + +} + +internal enum __x_ABI_C__FIMapChangedEventArgs_1_HSTRINGBridge : AbiInterfaceBridge { + internal typealias CABI = __x_ABI_C__FIMapChangedEventArgs_1_HSTRING + internal typealias SwiftABI = IMapChangedEventArgsString + internal typealias SwiftProjection = WindowsFoundation.AnyIMapChangedEventArgs + internal static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return __x_ABI_C__FIMapChangedEventArgs_1_HSTRINGImpl(abi) + } + + internal static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__x_ABI_C__FIMapChangedEventArgs_1_HSTRINGVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } +} + +fileprivate class __x_ABI_C__FIMapChangedEventArgs_1_HSTRINGImpl : IMapChangedEventArgs, AbiInterfaceImpl { + typealias K = String + typealias Bridge = __x_ABI_C__FIMapChangedEventArgs_1_HSTRINGBridge + let _default: Bridge.SwiftABI + init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + // MARK: WinRT + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imapchangedeventargs-1.collectionchange) + fileprivate var collectionChange : WindowsFoundation.CollectionChange { + get { try! _default.get_CollectionChangeImpl() } + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imapchangedeventargs-1.key) + fileprivate var key : String { + get { try! _default.get_KeyImpl() } + } + + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { nil } +} + +private var IID___x_ABI_C__FIMapView_2_HSTRING_IInspectable: WindowsFoundation.IID { + .init(Data1: 0xbb78502a, Data2: 0xf79d, Data3: 0x54fa, Data4: ( 0x92,0xc9,0x90,0xc5,0x03,0x9f,0xdf,0x7e ))// bb78502a-f79d-54fa-92c9-90c5039fdf7e +} + +internal var __x_ABI_C__FIMapView_2_HSTRING_IInspectableVTable: __x_ABI_C__FIMapView_2_HSTRING_IInspectableVtbl = .init( + QueryInterface: { __x_ABI_C__FIMapView_2_HSTRING_IInspectableWrapper.queryInterface($0, $1, $2) }, + AddRef: { __x_ABI_C__FIMapView_2_HSTRING_IInspectableWrapper.addRef($0) }, + Release: { __x_ABI_C__FIMapView_2_HSTRING_IInspectableWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 4).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = WindowsFoundation.__x_ABI_C__FIMapView_2_HSTRING_IInspectableWrapper.IID + iids[3] = WindowsFoundation.__x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.IID + $1!.pointee = 4 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.Collections.IMapView`2").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + Lookup: { + guard let __unwrapped__instance = __x_ABI_C__FIMapView_2_HSTRING_IInspectableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let key: String = .init(from: $1) + let result = __unwrapped__instance.lookup(key) + let resultWrapper = __ABI_.AnyWrapper(result) + resultWrapper?.copyTo($2) + return S_OK + }, + + get_Size: { + guard let __unwrapped__instance = __x_ABI_C__FIMapView_2_HSTRING_IInspectableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.size + $1?.initialize(to: result) + return S_OK + }, + + HasKey: { + guard let __unwrapped__instance = __x_ABI_C__FIMapView_2_HSTRING_IInspectableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let key: String = .init(from: $1) + let result = __unwrapped__instance.hasKey(key) + $2?.initialize(to: .init(from: result)) + return S_OK + }, + + Split: { + guard let __unwrapped__instance = __x_ABI_C__FIMapView_2_HSTRING_IInspectableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + var first: WindowsFoundation.AnyIMapView? + var second: WindowsFoundation.AnyIMapView? + __unwrapped__instance.split(&first, &second) + let firstWrapper = WindowsFoundation.__x_ABI_C__FIMapView_2_HSTRING_IInspectableWrapper(first) + firstWrapper?.copyTo($1) + let secondWrapper = WindowsFoundation.__x_ABI_C__FIMapView_2_HSTRING_IInspectableWrapper(second) + secondWrapper?.copyTo($2) + return S_OK + } +) +typealias __x_ABI_C__FIMapView_2_HSTRING_IInspectableWrapper = InterfaceWrapperBase +internal class IMapViewString_Any: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_C__FIMapView_2_HSTRING_IInspectable } + + internal func LookupImpl(_ key: String) throws -> Any? { + let (result) = try ComPtrs.initialize { resultAbi in + let _key = try! HString(key) + _ = try perform(as: __x_ABI_C__FIMapView_2_HSTRING_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Lookup(pThis, _key.get(), &resultAbi)) + } + } + return __ABI_.AnyWrapper.unwrapFrom(abi: result) + } + + internal func get_SizeImpl() throws -> UInt32 { + var result: UINT32 = 0 + _ = try perform(as: __x_ABI_C__FIMapView_2_HSTRING_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Size(pThis, &result)) + } + return result + } + + internal func HasKeyImpl(_ key: String) throws -> Bool { + var result: boolean = 0 + let _key = try! HString(key) + _ = try perform(as: __x_ABI_C__FIMapView_2_HSTRING_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.HasKey(pThis, _key.get(), &result)) + } + return .init(from: result) + } + + internal func SplitImpl(_ first: inout WindowsFoundation.AnyIMapView?, _ second: inout WindowsFoundation.AnyIMapView?) throws { + let (_first, _second) = try ComPtrs.initialize { (_firstAbi, _secondAbi) in + _ = try perform(as: __x_ABI_C__FIMapView_2_HSTRING_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Split(pThis, &_firstAbi, &_secondAbi)) + } + } + first = WindowsFoundation.__x_ABI_C__FIMapView_2_HSTRING_IInspectableWrapper.unwrapFrom(abi: _first) + second = WindowsFoundation.__x_ABI_C__FIMapView_2_HSTRING_IInspectableWrapper.unwrapFrom(abi: _second) + } + +} + +internal enum __x_ABI_C__FIMapView_2_HSTRING_IInspectableBridge : AbiInterfaceBridge { + internal typealias CABI = __x_ABI_C__FIMapView_2_HSTRING_IInspectable + internal typealias SwiftABI = IMapViewString_Any + internal typealias SwiftProjection = WindowsFoundation.AnyIMapView + internal static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return __x_ABI_C__FIMapView_2_HSTRING_IInspectableImpl(abi) + } + + internal static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__x_ABI_C__FIMapView_2_HSTRING_IInspectableVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } +} + +fileprivate class __x_ABI_C__FIMapView_2_HSTRING_IInspectableImpl : IMapView, AbiInterfaceImpl { + typealias T = WindowsFoundation.AnyIKeyValuePair? + typealias K = String + typealias V = Any? + typealias Bridge = __x_ABI_C__FIMapView_2_HSTRING_IInspectableBridge + let _default: Bridge.SwiftABI + init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + // MARK: WinRT + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imapview-2.lookup) + fileprivate func lookup(_ key: String) -> Any? { + try! _default.LookupImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imapview-2.haskey) + fileprivate func hasKey(_ key: String) -> Bool { + try! _default.HasKeyImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imapview-2.split) + fileprivate func split(_ first: inout WindowsFoundation.AnyIMapView?, _ second: inout WindowsFoundation.AnyIMapView?) { + try! _default.SplitImpl(&first, &second) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imapview-2.size) + fileprivate var size : UInt32 { + get { try! _default.get_SizeImpl() } + } + + private lazy var _IIterable: IIterableIKeyValuePairString_Any! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imapview-2.first) + fileprivate func first() -> WindowsFoundation.AnyIIterator?>? { + try! _IIterable.FirstImpl() + } + + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { nil } +} + +private var IID___x_ABI_C__FIMapView_2_HSTRING_HSTRING: WindowsFoundation.IID { + .init(Data1: 0xac7f26f2, Data2: 0xfeb7, Data3: 0x5b2a, Data4: ( 0x8a,0xc4,0x34,0x5b,0xc6,0x2c,0xae,0xde ))// ac7f26f2-feb7-5b2a-8ac4-345bc62caede +} + +internal var __x_ABI_C__FIMapView_2_HSTRING_HSTRINGVTable: __x_ABI_C__FIMapView_2_HSTRING_HSTRINGVtbl = .init( + QueryInterface: { __x_ABI_C__FIMapView_2_HSTRING_HSTRINGWrapper.queryInterface($0, $1, $2) }, + AddRef: { __x_ABI_C__FIMapView_2_HSTRING_HSTRINGWrapper.addRef($0) }, + Release: { __x_ABI_C__FIMapView_2_HSTRING_HSTRINGWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 4).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = WindowsFoundation.__x_ABI_C__FIMapView_2_HSTRING_HSTRINGWrapper.IID + iids[3] = WindowsFoundation.__x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.IID + $1!.pointee = 4 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.Collections.IMapView`2").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + Lookup: { + guard let __unwrapped__instance = __x_ABI_C__FIMapView_2_HSTRING_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let key: String = .init(from: $1) + let result = __unwrapped__instance.lookup(key) + $2?.initialize(to: try! HString(result).detach()) + return S_OK + }, + + get_Size: { + guard let __unwrapped__instance = __x_ABI_C__FIMapView_2_HSTRING_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.size + $1?.initialize(to: result) + return S_OK + }, + + HasKey: { + guard let __unwrapped__instance = __x_ABI_C__FIMapView_2_HSTRING_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let key: String = .init(from: $1) + let result = __unwrapped__instance.hasKey(key) + $2?.initialize(to: .init(from: result)) + return S_OK + }, + + Split: { + guard let __unwrapped__instance = __x_ABI_C__FIMapView_2_HSTRING_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + var first: WindowsFoundation.AnyIMapView? + var second: WindowsFoundation.AnyIMapView? + __unwrapped__instance.split(&first, &second) + let firstWrapper = WindowsFoundation.__x_ABI_C__FIMapView_2_HSTRING_HSTRINGWrapper(first) + firstWrapper?.copyTo($1) + let secondWrapper = WindowsFoundation.__x_ABI_C__FIMapView_2_HSTRING_HSTRINGWrapper(second) + secondWrapper?.copyTo($2) + return S_OK + } +) +typealias __x_ABI_C__FIMapView_2_HSTRING_HSTRINGWrapper = InterfaceWrapperBase +internal class IMapViewString_String: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_C__FIMapView_2_HSTRING_HSTRING } + + internal func LookupImpl(_ key: String) throws -> String { + var result: HSTRING? + let _key = try! HString(key) + _ = try perform(as: __x_ABI_C__FIMapView_2_HSTRING_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Lookup(pThis, _key.get(), &result)) + } + return .init(from: result) + } + + internal func get_SizeImpl() throws -> UInt32 { + var result: UINT32 = 0 + _ = try perform(as: __x_ABI_C__FIMapView_2_HSTRING_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Size(pThis, &result)) + } + return result + } + + internal func HasKeyImpl(_ key: String) throws -> Bool { + var result: boolean = 0 + let _key = try! HString(key) + _ = try perform(as: __x_ABI_C__FIMapView_2_HSTRING_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.HasKey(pThis, _key.get(), &result)) + } + return .init(from: result) + } + + internal func SplitImpl(_ first: inout WindowsFoundation.AnyIMapView?, _ second: inout WindowsFoundation.AnyIMapView?) throws { + let (_first, _second) = try ComPtrs.initialize { (_firstAbi, _secondAbi) in + _ = try perform(as: __x_ABI_C__FIMapView_2_HSTRING_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Split(pThis, &_firstAbi, &_secondAbi)) + } + } + first = WindowsFoundation.__x_ABI_C__FIMapView_2_HSTRING_HSTRINGWrapper.unwrapFrom(abi: _first) + second = WindowsFoundation.__x_ABI_C__FIMapView_2_HSTRING_HSTRINGWrapper.unwrapFrom(abi: _second) + } + +} + +internal enum __x_ABI_C__FIMapView_2_HSTRING_HSTRINGBridge : AbiInterfaceBridge { + internal typealias CABI = __x_ABI_C__FIMapView_2_HSTRING_HSTRING + internal typealias SwiftABI = IMapViewString_String + internal typealias SwiftProjection = WindowsFoundation.AnyIMapView + internal static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return __x_ABI_C__FIMapView_2_HSTRING_HSTRINGImpl(abi) + } + + internal static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__x_ABI_C__FIMapView_2_HSTRING_HSTRINGVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } +} + +fileprivate class __x_ABI_C__FIMapView_2_HSTRING_HSTRINGImpl : IMapView, AbiInterfaceImpl { + typealias T = WindowsFoundation.AnyIKeyValuePair? + typealias K = String + typealias V = String + typealias Bridge = __x_ABI_C__FIMapView_2_HSTRING_HSTRINGBridge + let _default: Bridge.SwiftABI + init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + // MARK: WinRT + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imapview-2.lookup) + fileprivate func lookup(_ key: String) -> String { + try! _default.LookupImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imapview-2.haskey) + fileprivate func hasKey(_ key: String) -> Bool { + try! _default.HasKeyImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imapview-2.split) + fileprivate func split(_ first: inout WindowsFoundation.AnyIMapView?, _ second: inout WindowsFoundation.AnyIMapView?) { + try! _default.SplitImpl(&first, &second) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imapview-2.size) + fileprivate var size : UInt32 { + get { try! _default.get_SizeImpl() } + } + + private lazy var _IIterable: IIterableIKeyValuePairString_String! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imapview-2.first) + fileprivate func first() -> WindowsFoundation.AnyIIterator?>? { + try! _IIterable.FirstImpl() + } + + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { nil } +} + +private var IID___x_ABI_C__FIMap_2_HSTRING_IInspectable: WindowsFoundation.IID { + .init(Data1: 0x1b0d3570, Data2: 0x0877, Data3: 0x5ec2, Data4: ( 0x8a,0x2c,0x3b,0x95,0x39,0x50,0x6a,0xca ))// 1b0d3570-0877-5ec2-8a2c-3b9539506aca +} + +internal var __x_ABI_C__FIMap_2_HSTRING_IInspectableVTable: __x_ABI_C__FIMap_2_HSTRING_IInspectableVtbl = .init( + QueryInterface: { __x_ABI_C__FIMap_2_HSTRING_IInspectableWrapper.queryInterface($0, $1, $2) }, + AddRef: { __x_ABI_C__FIMap_2_HSTRING_IInspectableWrapper.addRef($0) }, + Release: { __x_ABI_C__FIMap_2_HSTRING_IInspectableWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 4).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = WindowsFoundation.__x_ABI_C__FIMap_2_HSTRING_IInspectableWrapper.IID + iids[3] = WindowsFoundation.__x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.IID + $1!.pointee = 4 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.Collections.IMap`2").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + Lookup: { + guard let __unwrapped__instance = __x_ABI_C__FIMap_2_HSTRING_IInspectableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let key: String = .init(from: $1) + let result = __unwrapped__instance.lookup(key) + let resultWrapper = __ABI_.AnyWrapper(result) + resultWrapper?.copyTo($2) + return S_OK + }, + + get_Size: { + guard let __unwrapped__instance = __x_ABI_C__FIMap_2_HSTRING_IInspectableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.size + $1?.initialize(to: result) + return S_OK + }, + + HasKey: { + guard let __unwrapped__instance = __x_ABI_C__FIMap_2_HSTRING_IInspectableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let key: String = .init(from: $1) + let result = __unwrapped__instance.hasKey(key) + $2?.initialize(to: .init(from: result)) + return S_OK + }, + + GetView: { + guard let __unwrapped__instance = __x_ABI_C__FIMap_2_HSTRING_IInspectableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.getView() + let resultWrapper = WindowsFoundation.__x_ABI_C__FIMapView_2_HSTRING_IInspectableWrapper(result) + resultWrapper?.copyTo($1) + return S_OK + }, + + Insert: { + guard let __unwrapped__instance = __x_ABI_C__FIMap_2_HSTRING_IInspectableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let key: String = .init(from: $1) + let value: Any? = __ABI_.AnyWrapper.unwrapFrom(abi: ComPtr($2)) + let result = __unwrapped__instance.insert(key, value) + $3?.initialize(to: .init(from: result)) + return S_OK + }, + + Remove: { + guard let __unwrapped__instance = __x_ABI_C__FIMap_2_HSTRING_IInspectableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let key: String = .init(from: $1) + __unwrapped__instance.remove(key) + return S_OK + }, + + Clear: { + guard let __unwrapped__instance = __x_ABI_C__FIMap_2_HSTRING_IInspectableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + __unwrapped__instance.clear() + return S_OK + } +) +typealias __x_ABI_C__FIMap_2_HSTRING_IInspectableWrapper = InterfaceWrapperBase +internal class IMapString_Any: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_C__FIMap_2_HSTRING_IInspectable } + + internal func LookupImpl(_ key: String) throws -> Any? { + let (result) = try ComPtrs.initialize { resultAbi in + let _key = try! HString(key) + _ = try perform(as: __x_ABI_C__FIMap_2_HSTRING_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Lookup(pThis, _key.get(), &resultAbi)) + } + } + return __ABI_.AnyWrapper.unwrapFrom(abi: result) + } + + internal func get_SizeImpl() throws -> UInt32 { + var result: UINT32 = 0 + _ = try perform(as: __x_ABI_C__FIMap_2_HSTRING_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Size(pThis, &result)) + } + return result + } + + internal func HasKeyImpl(_ key: String) throws -> Bool { + var result: boolean = 0 + let _key = try! HString(key) + _ = try perform(as: __x_ABI_C__FIMap_2_HSTRING_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.HasKey(pThis, _key.get(), &result)) + } + return .init(from: result) + } + + internal func GetViewImpl() throws -> WindowsFoundation.AnyIMapView? { + let (result) = try ComPtrs.initialize { resultAbi in + _ = try perform(as: __x_ABI_C__FIMap_2_HSTRING_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetView(pThis, &resultAbi)) + } + } + return WindowsFoundation.__x_ABI_C__FIMapView_2_HSTRING_IInspectableWrapper.unwrapFrom(abi: result) + } + + internal func InsertImpl(_ key: String, _ value: Any?) throws -> Bool { + var result: boolean = 0 + let _key = try! HString(key) + let valueWrapper = __ABI_.AnyWrapper(value) + let _value = try! valueWrapper?.toABI { $0 } + _ = try perform(as: __x_ABI_C__FIMap_2_HSTRING_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Insert(pThis, _key.get(), _value, &result)) + } + return .init(from: result) + } + + internal func RemoveImpl(_ key: String) throws { + let _key = try! HString(key) + _ = try perform(as: __x_ABI_C__FIMap_2_HSTRING_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Remove(pThis, _key.get())) + } + } + + internal func ClearImpl() throws { + _ = try perform(as: __x_ABI_C__FIMap_2_HSTRING_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Clear(pThis)) + } + } + +} + +internal enum __x_ABI_C__FIMap_2_HSTRING_IInspectableBridge : AbiInterfaceBridge { + internal typealias CABI = __x_ABI_C__FIMap_2_HSTRING_IInspectable + internal typealias SwiftABI = IMapString_Any + internal typealias SwiftProjection = WindowsFoundation.AnyIMap + internal static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return __x_ABI_C__FIMap_2_HSTRING_IInspectableImpl(abi) + } + + internal static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__x_ABI_C__FIMap_2_HSTRING_IInspectableVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } +} + +fileprivate class __x_ABI_C__FIMap_2_HSTRING_IInspectableImpl : IMap, AbiInterfaceImpl { + typealias T = WindowsFoundation.AnyIKeyValuePair? + typealias K = String + typealias V = Any? + typealias Bridge = __x_ABI_C__FIMap_2_HSTRING_IInspectableBridge + let _default: Bridge.SwiftABI + init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + // MARK: WinRT + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.lookup) + fileprivate func lookup(_ key: String) -> Any? { + try! _default.LookupImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.haskey) + fileprivate func hasKey(_ key: String) -> Bool { + try! _default.HasKeyImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.getview) + fileprivate func getView() -> WindowsFoundation.AnyIMapView? { + try! _default.GetViewImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.insert) + fileprivate func insert(_ key: String, _ value: Any?) -> Bool { + try! _default.InsertImpl(key, value) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.remove) + fileprivate func remove(_ key: String) { + try! _default.RemoveImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.clear) + fileprivate func clear() { + try! _default.ClearImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.size) + fileprivate var size : UInt32 { + get { try! _default.get_SizeImpl() } + } + + private lazy var _IIterable: IIterableIKeyValuePairString_Any! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.first) + fileprivate func first() -> WindowsFoundation.AnyIIterator?>? { + try! _IIterable.FirstImpl() + } + + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { nil } +} + +private var IID___x_ABI_C__FIMap_2_HSTRING_HSTRING: WindowsFoundation.IID { + .init(Data1: 0xf6d1f700, Data2: 0x49c2, Data3: 0x52ae, Data4: ( 0x81,0x54,0x82,0x6f,0x99,0x08,0x77,0x3c ))// f6d1f700-49c2-52ae-8154-826f9908773c +} + +internal var __x_ABI_C__FIMap_2_HSTRING_HSTRINGVTable: __x_ABI_C__FIMap_2_HSTRING_HSTRINGVtbl = .init( + QueryInterface: { __x_ABI_C__FIMap_2_HSTRING_HSTRINGWrapper.queryInterface($0, $1, $2) }, + AddRef: { __x_ABI_C__FIMap_2_HSTRING_HSTRINGWrapper.addRef($0) }, + Release: { __x_ABI_C__FIMap_2_HSTRING_HSTRINGWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 4).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = WindowsFoundation.__x_ABI_C__FIMap_2_HSTRING_HSTRINGWrapper.IID + iids[3] = WindowsFoundation.__x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.IID + $1!.pointee = 4 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.Collections.IMap`2").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + Lookup: { + guard let __unwrapped__instance = __x_ABI_C__FIMap_2_HSTRING_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let key: String = .init(from: $1) + let result = __unwrapped__instance.lookup(key) + $2?.initialize(to: try! HString(result).detach()) + return S_OK + }, + + get_Size: { + guard let __unwrapped__instance = __x_ABI_C__FIMap_2_HSTRING_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.size + $1?.initialize(to: result) + return S_OK + }, + + HasKey: { + guard let __unwrapped__instance = __x_ABI_C__FIMap_2_HSTRING_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let key: String = .init(from: $1) + let result = __unwrapped__instance.hasKey(key) + $2?.initialize(to: .init(from: result)) + return S_OK + }, + + GetView: { + guard let __unwrapped__instance = __x_ABI_C__FIMap_2_HSTRING_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.getView() + let resultWrapper = WindowsFoundation.__x_ABI_C__FIMapView_2_HSTRING_HSTRINGWrapper(result) + resultWrapper?.copyTo($1) + return S_OK + }, + + Insert: { + guard let __unwrapped__instance = __x_ABI_C__FIMap_2_HSTRING_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let key: String = .init(from: $1) + let value: String = .init(from: $2) + let result = __unwrapped__instance.insert(key, value) + $3?.initialize(to: .init(from: result)) + return S_OK + }, + + Remove: { + guard let __unwrapped__instance = __x_ABI_C__FIMap_2_HSTRING_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let key: String = .init(from: $1) + __unwrapped__instance.remove(key) + return S_OK + }, + + Clear: { + guard let __unwrapped__instance = __x_ABI_C__FIMap_2_HSTRING_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + __unwrapped__instance.clear() + return S_OK + } +) +typealias __x_ABI_C__FIMap_2_HSTRING_HSTRINGWrapper = InterfaceWrapperBase +internal class IMapString_String: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_C__FIMap_2_HSTRING_HSTRING } + + internal func LookupImpl(_ key: String) throws -> String { + var result: HSTRING? + let _key = try! HString(key) + _ = try perform(as: __x_ABI_C__FIMap_2_HSTRING_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Lookup(pThis, _key.get(), &result)) + } + return .init(from: result) + } + + internal func get_SizeImpl() throws -> UInt32 { + var result: UINT32 = 0 + _ = try perform(as: __x_ABI_C__FIMap_2_HSTRING_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Size(pThis, &result)) + } + return result + } + + internal func HasKeyImpl(_ key: String) throws -> Bool { + var result: boolean = 0 + let _key = try! HString(key) + _ = try perform(as: __x_ABI_C__FIMap_2_HSTRING_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.HasKey(pThis, _key.get(), &result)) + } + return .init(from: result) + } + + internal func GetViewImpl() throws -> WindowsFoundation.AnyIMapView? { + let (result) = try ComPtrs.initialize { resultAbi in + _ = try perform(as: __x_ABI_C__FIMap_2_HSTRING_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetView(pThis, &resultAbi)) + } + } + return WindowsFoundation.__x_ABI_C__FIMapView_2_HSTRING_HSTRINGWrapper.unwrapFrom(abi: result) + } + + internal func InsertImpl(_ key: String, _ value: String) throws -> Bool { + var result: boolean = 0 + let _key = try! HString(key) + let _value = try! HString(value) + _ = try perform(as: __x_ABI_C__FIMap_2_HSTRING_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Insert(pThis, _key.get(), _value.get(), &result)) + } + return .init(from: result) + } + + internal func RemoveImpl(_ key: String) throws { + let _key = try! HString(key) + _ = try perform(as: __x_ABI_C__FIMap_2_HSTRING_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Remove(pThis, _key.get())) + } + } + + internal func ClearImpl() throws { + _ = try perform(as: __x_ABI_C__FIMap_2_HSTRING_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Clear(pThis)) + } + } + +} + +internal enum __x_ABI_C__FIMap_2_HSTRING_HSTRINGBridge : AbiInterfaceBridge { + internal typealias CABI = __x_ABI_C__FIMap_2_HSTRING_HSTRING + internal typealias SwiftABI = IMapString_String + internal typealias SwiftProjection = WindowsFoundation.AnyIMap + internal static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return __x_ABI_C__FIMap_2_HSTRING_HSTRINGImpl(abi) + } + + internal static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__x_ABI_C__FIMap_2_HSTRING_HSTRINGVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } +} + +fileprivate class __x_ABI_C__FIMap_2_HSTRING_HSTRINGImpl : IMap, AbiInterfaceImpl { + typealias T = WindowsFoundation.AnyIKeyValuePair? + typealias K = String + typealias V = String + typealias Bridge = __x_ABI_C__FIMap_2_HSTRING_HSTRINGBridge + let _default: Bridge.SwiftABI + init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + // MARK: WinRT + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.lookup) + fileprivate func lookup(_ key: String) -> String { + try! _default.LookupImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.haskey) + fileprivate func hasKey(_ key: String) -> Bool { + try! _default.HasKeyImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.getview) + fileprivate func getView() -> WindowsFoundation.AnyIMapView? { + try! _default.GetViewImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.insert) + fileprivate func insert(_ key: String, _ value: String) -> Bool { + try! _default.InsertImpl(key, value) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.remove) + fileprivate func remove(_ key: String) { + try! _default.RemoveImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.clear) + fileprivate func clear() { + try! _default.ClearImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.size) + fileprivate var size : UInt32 { + get { try! _default.get_SizeImpl() } + } + + private lazy var _IIterable: IIterableIKeyValuePairString_String! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.imap-2.first) + fileprivate func first() -> WindowsFoundation.AnyIIterator?>? { + try! _IIterable.FirstImpl() + } + + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { nil } +} + +private var IID___x_ABI_C__FIObservableMap_2_HSTRING_IInspectable: WindowsFoundation.IID { + .init(Data1: 0x236aac9d, Data2: 0xfb12, Data3: 0x5c4d, Data4: ( 0xa4,0x1c,0x9e,0x44,0x5f,0xb4,0xd7,0xec ))// 236aac9d-fb12-5c4d-a41c-9e445fb4d7ec +} + +internal var __x_ABI_C__FIObservableMap_2_HSTRING_IInspectableVTable: __x_ABI_C__FIObservableMap_2_HSTRING_IInspectableVtbl = .init( + QueryInterface: { __x_ABI_C__FIObservableMap_2_HSTRING_IInspectableWrapper.queryInterface($0, $1, $2) }, + AddRef: { __x_ABI_C__FIObservableMap_2_HSTRING_IInspectableWrapper.addRef($0) }, + Release: { __x_ABI_C__FIObservableMap_2_HSTRING_IInspectableWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 5).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = WindowsFoundation.__x_ABI_C__FIObservableMap_2_HSTRING_IInspectableWrapper.IID + iids[3] = WindowsFoundation.__x_ABI_C__FIMap_2_HSTRING_IInspectableWrapper.IID + iids[4] = WindowsFoundation.__x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_IInspectableWrapper.IID + $1!.pointee = 5 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.Collections.IObservableMap`2").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + add_MapChanged: { + guard let __unwrapped__instance = __x_ABI_C__FIObservableMap_2_HSTRING_IInspectableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + guard let vhnd = WindowsFoundation.__x_ABI_C__FMapChangedEventHandler_2_HSTRING_IInspectableWrapper.unwrapFrom(abi: ComPtr($1)) else { return E_INVALIDARG } + let result = __unwrapped__instance.mapChanged.addHandler(vhnd) + $2?.initialize(to: .from(swift: result)) + return S_OK + }, + + remove_MapChanged: { + guard let __unwrapped__instance = __x_ABI_C__FIObservableMap_2_HSTRING_IInspectableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let token: EventRegistrationToken = $1 + __unwrapped__instance.mapChanged.removeHandler(token) + return S_OK + } +) +typealias __x_ABI_C__FIObservableMap_2_HSTRING_IInspectableWrapper = InterfaceWrapperBase +internal class IObservableMapString_Any: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_C__FIObservableMap_2_HSTRING_IInspectable } + + internal func add_MapChangedImpl(_ vhnd: MapChangedEventHandler?) throws -> EventRegistrationToken { + var result: EventRegistrationToken = .init() + let vhndWrapper = WindowsFoundation.__x_ABI_C__FMapChangedEventHandler_2_HSTRING_IInspectableWrapper(vhnd) + let _vhnd = try! vhndWrapper?.toABI { $0 } + _ = try perform(as: __x_ABI_C__FIObservableMap_2_HSTRING_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.add_MapChanged(pThis, _vhnd, &result)) + } + return result + } + + internal func remove_MapChangedImpl(_ token: EventRegistrationToken) throws { + _ = try perform(as: __x_ABI_C__FIObservableMap_2_HSTRING_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.remove_MapChanged(pThis, token)) + } + } + +} + +internal enum __x_ABI_C__FIObservableMap_2_HSTRING_IInspectableBridge : AbiInterfaceBridge { + internal typealias CABI = __x_ABI_C__FIObservableMap_2_HSTRING_IInspectable + internal typealias SwiftABI = IObservableMapString_Any + internal typealias SwiftProjection = WindowsFoundation.AnyIObservableMap + internal static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return __x_ABI_C__FIObservableMap_2_HSTRING_IInspectableImpl(abi) + } + + internal static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__x_ABI_C__FIObservableMap_2_HSTRING_IInspectableVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } +} + +fileprivate class __x_ABI_C__FIObservableMap_2_HSTRING_IInspectableImpl : IObservableMap, AbiInterfaceImpl { + typealias K = String + typealias V = Any? + typealias T = WindowsFoundation.AnyIKeyValuePair? + typealias Bridge = __x_ABI_C__FIObservableMap_2_HSTRING_IInspectableBridge + let _default: Bridge.SwiftABI + init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + // MARK: WinRT + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablemap-2.mapchanged) + fileprivate lazy var mapChanged : Event> = { + .init( + add: { [weak self] in + guard let this = self?._default else { return .init() } + return try! this.add_MapChangedImpl($0) + }, + remove: { [weak self] in + try? self?._default.remove_MapChangedImpl($0) + } + ) + }() + + private lazy var _IMap: IMapString_Any! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablemap-2.lookup) + fileprivate func lookup(_ key: String) -> Any? { + try! _IMap.LookupImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablemap-2.haskey) + fileprivate func hasKey(_ key: String) -> Bool { + try! _IMap.HasKeyImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablemap-2.getview) + fileprivate func getView() -> WindowsFoundation.AnyIMapView? { + try! _IMap.GetViewImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablemap-2.insert) + fileprivate func insert(_ key: String, _ value: Any?) -> Bool { + try! _IMap.InsertImpl(key, value) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablemap-2.remove) + fileprivate func remove(_ key: String) { + try! _IMap.RemoveImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablemap-2.clear) + fileprivate func clear() { + try! _IMap.ClearImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablemap-2.size) + fileprivate var size : UInt32 { + get { try! _IMap.get_SizeImpl() } + } + + private lazy var _IIterable: IIterableIKeyValuePairString_Any! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablemap-2.first) + fileprivate func first() -> WindowsFoundation.AnyIIterator?>? { + try! _IIterable.FirstImpl() + } + + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { nil } +} + +private var IID___x_ABI_C__FIObservableMap_2_HSTRING_HSTRING: WindowsFoundation.IID { + .init(Data1: 0x1e036276, Data2: 0x2f60, Data3: 0x55f6, Data4: ( 0xb7,0xf3,0xf8,0x60,0x79,0xe6,0x90,0x0b ))// 1e036276-2f60-55f6-b7f3-f86079e6900b +} + +internal var __x_ABI_C__FIObservableMap_2_HSTRING_HSTRINGVTable: __x_ABI_C__FIObservableMap_2_HSTRING_HSTRINGVtbl = .init( + QueryInterface: { __x_ABI_C__FIObservableMap_2_HSTRING_HSTRINGWrapper.queryInterface($0, $1, $2) }, + AddRef: { __x_ABI_C__FIObservableMap_2_HSTRING_HSTRINGWrapper.addRef($0) }, + Release: { __x_ABI_C__FIObservableMap_2_HSTRING_HSTRINGWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 5).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = WindowsFoundation.__x_ABI_C__FIObservableMap_2_HSTRING_HSTRINGWrapper.IID + iids[3] = WindowsFoundation.__x_ABI_C__FIMap_2_HSTRING_HSTRINGWrapper.IID + iids[4] = WindowsFoundation.__x_ABI_C__FIIterable_1___x_ABI_C__FIKeyValuePair_2_HSTRING_HSTRINGWrapper.IID + $1!.pointee = 5 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.Collections.IObservableMap`2").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + add_MapChanged: { + guard let __unwrapped__instance = __x_ABI_C__FIObservableMap_2_HSTRING_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + guard let vhnd = WindowsFoundation.__x_ABI_C__FMapChangedEventHandler_2_HSTRING_HSTRINGWrapper.unwrapFrom(abi: ComPtr($1)) else { return E_INVALIDARG } + let result = __unwrapped__instance.mapChanged.addHandler(vhnd) + $2?.initialize(to: .from(swift: result)) + return S_OK + }, + + remove_MapChanged: { + guard let __unwrapped__instance = __x_ABI_C__FIObservableMap_2_HSTRING_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let token: EventRegistrationToken = $1 + __unwrapped__instance.mapChanged.removeHandler(token) + return S_OK + } +) +typealias __x_ABI_C__FIObservableMap_2_HSTRING_HSTRINGWrapper = InterfaceWrapperBase +internal class IObservableMapString_String: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_C__FIObservableMap_2_HSTRING_HSTRING } + + internal func add_MapChangedImpl(_ vhnd: MapChangedEventHandler?) throws -> EventRegistrationToken { + var result: EventRegistrationToken = .init() + let vhndWrapper = WindowsFoundation.__x_ABI_C__FMapChangedEventHandler_2_HSTRING_HSTRINGWrapper(vhnd) + let _vhnd = try! vhndWrapper?.toABI { $0 } + _ = try perform(as: __x_ABI_C__FIObservableMap_2_HSTRING_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.add_MapChanged(pThis, _vhnd, &result)) + } + return result + } + + internal func remove_MapChangedImpl(_ token: EventRegistrationToken) throws { + _ = try perform(as: __x_ABI_C__FIObservableMap_2_HSTRING_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.remove_MapChanged(pThis, token)) + } + } + +} + +internal enum __x_ABI_C__FIObservableMap_2_HSTRING_HSTRINGBridge : AbiInterfaceBridge { + internal typealias CABI = __x_ABI_C__FIObservableMap_2_HSTRING_HSTRING + internal typealias SwiftABI = IObservableMapString_String + internal typealias SwiftProjection = WindowsFoundation.AnyIObservableMap + internal static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return __x_ABI_C__FIObservableMap_2_HSTRING_HSTRINGImpl(abi) + } + + internal static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__x_ABI_C__FIObservableMap_2_HSTRING_HSTRINGVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } +} + +fileprivate class __x_ABI_C__FIObservableMap_2_HSTRING_HSTRINGImpl : IObservableMap, AbiInterfaceImpl { + typealias K = String + typealias V = String + typealias T = WindowsFoundation.AnyIKeyValuePair? + typealias Bridge = __x_ABI_C__FIObservableMap_2_HSTRING_HSTRINGBridge + let _default: Bridge.SwiftABI + init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + // MARK: WinRT + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablemap-2.mapchanged) + fileprivate lazy var mapChanged : Event> = { + .init( + add: { [weak self] in + guard let this = self?._default else { return .init() } + return try! this.add_MapChangedImpl($0) + }, + remove: { [weak self] in + try? self?._default.remove_MapChangedImpl($0) + } + ) + }() + + private lazy var _IMap: IMapString_String! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablemap-2.lookup) + fileprivate func lookup(_ key: String) -> String { + try! _IMap.LookupImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablemap-2.haskey) + fileprivate func hasKey(_ key: String) -> Bool { + try! _IMap.HasKeyImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablemap-2.getview) + fileprivate func getView() -> WindowsFoundation.AnyIMapView? { + try! _IMap.GetViewImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablemap-2.insert) + fileprivate func insert(_ key: String, _ value: String) -> Bool { + try! _IMap.InsertImpl(key, value) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablemap-2.remove) + fileprivate func remove(_ key: String) { + try! _IMap.RemoveImpl(key) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablemap-2.clear) + fileprivate func clear() { + try! _IMap.ClearImpl() + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablemap-2.size) + fileprivate var size : UInt32 { + get { try! _IMap.get_SizeImpl() } + } + + private lazy var _IIterable: IIterableIKeyValuePairString_String! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.iobservablemap-2.first) + fileprivate func first() -> WindowsFoundation.AnyIIterator?>? { + try! _IIterable.FirstImpl() + } + + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { nil } +} + +private var IID___x_ABI_C__FIVectorView_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntry: WindowsFoundation.IID { + .init(Data1: 0xb1f00d3b, Data2: 0x1f06, Data3: 0x5117, Data4: ( 0x93,0xea,0x2a,0x0d,0x79,0x11,0x67,0x01 ))// b1f00d3b-1f06-5117-93ea-2a0d79116701 +} + +internal var __x_ABI_C__FIVectorView_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryVTable: __x_ABI_C__FIVectorView_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryVtbl = .init( + QueryInterface: { __x_ABI_C__FIVectorView_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper.queryInterface($0, $1, $2) }, + AddRef: { __x_ABI_C__FIVectorView_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper.addRef($0) }, + Release: { __x_ABI_C__FIVectorView_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper.release($0) }, + GetIids: { + let size = MemoryLayout.size + let iids = CoTaskMemAlloc(UInt64(size) * 4).assumingMemoryBound(to: WindowsFoundation.IID.self) + iids[0] = IUnknown.IID + iids[1] = IInspectable.IID + iids[2] = WindowsFoundation.__x_ABI_C__FIVectorView_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper.IID + iids[3] = WindowsFoundation.__x_ABI_C__FIIterable_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper.IID + $1!.pointee = 4 + $2!.pointee = iids + return S_OK + }, + + GetRuntimeClassName: { + _ = $0 + let hstring = try! HString("Windows.Foundation.Collections.IVectorView`1").detach() + $1!.pointee = hstring + return S_OK + }, + + GetTrustLevel: { + _ = $0 + $1!.pointee = TrustLevel(rawValue: 0) + return S_OK + }, + + GetAt: { + guard let __unwrapped__instance = __x_ABI_C__FIVectorView_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let index: UInt32 = $1 + let result = __unwrapped__instance.getAt(index) + let resultWrapper = __ABI_Windows_Foundation.IWwwFormUrlDecoderEntryWrapper(result) + resultWrapper?.copyTo($2) + return S_OK + }, + + get_Size: { + guard let __unwrapped__instance = __x_ABI_C__FIVectorView_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let result = __unwrapped__instance.size + $1?.initialize(to: result) + return S_OK + }, + + IndexOf: { + guard let __unwrapped__instance = __x_ABI_C__FIVectorView_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let value: WindowsFoundation.AnyIWwwFormUrlDecoderEntry? = __ABI_Windows_Foundation.IWwwFormUrlDecoderEntryWrapper.unwrapFrom(abi: ComPtr($1)) + var index: UInt32 = 0 + let result = __unwrapped__instance.indexOf(value, &index) + $2?.initialize(to: index) + $3?.initialize(to: .init(from: result)) + return S_OK + }, + + GetMany: { _, _, _, _, _ in return failWith(err: E_NOTIMPL) } +) +typealias __x_ABI_C__FIVectorView_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryWrapper = InterfaceWrapperBase +internal class IVectorViewIWwwFormUrlDecoderEntry: WindowsFoundation.IInspectable { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_C__FIVectorView_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntry } + + internal func GetAtImpl(_ index: UInt32) throws -> WindowsFoundation.AnyIWwwFormUrlDecoderEntry? { + let (result) = try ComPtrs.initialize { resultAbi in + _ = try perform(as: __x_ABI_C__FIVectorView_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntry.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.GetAt(pThis, index, &resultAbi)) + } + } + return __ABI_Windows_Foundation.IWwwFormUrlDecoderEntryWrapper.unwrapFrom(abi: result) + } + + internal func get_SizeImpl() throws -> UInt32 { + var result: UINT32 = 0 + _ = try perform(as: __x_ABI_C__FIVectorView_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntry.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.get_Size(pThis, &result)) + } + return result + } + + internal func IndexOfImpl(_ value: WindowsFoundation.AnyIWwwFormUrlDecoderEntry?, _ index: inout UInt32) throws -> Bool { + var result: boolean = 0 + let valueWrapper = __ABI_Windows_Foundation.IWwwFormUrlDecoderEntryWrapper(value) + let _value = try! valueWrapper?.toABI { $0 } + _ = try perform(as: __x_ABI_C__FIVectorView_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntry.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.IndexOf(pThis, _value, &index, &result)) + } + return .init(from: result) + } + +} + +internal enum __x_ABI_C__FIVectorView_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryBridge : AbiInterfaceBridge { + internal typealias CABI = __x_ABI_C__FIVectorView_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntry + internal typealias SwiftABI = IVectorViewIWwwFormUrlDecoderEntry + internal typealias SwiftProjection = WindowsFoundation.AnyIVectorView + internal static func from(abi: ComPtr?) -> SwiftProjection? { + guard let abi = abi else { return nil } + return __x_ABI_C__FIVectorView_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryImpl(abi) + } + + internal static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &__x_ABI_C__FIVectorView_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryVTable) { $0 } + return .init(lpVtbl: vtblPtr) + } +} + +fileprivate class __x_ABI_C__FIVectorView_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryImpl : IVectorView, AbiInterfaceImpl { + typealias T = WindowsFoundation.AnyIWwwFormUrlDecoderEntry? + typealias Bridge = __x_ABI_C__FIVectorView_1___x_ABI_CWindows__CFoundation__CIWwwFormUrlDecoderEntryBridge + let _default: Bridge.SwiftABI + init(_ fromAbi: ComPtr) { + _default = Bridge.SwiftABI(fromAbi) + } + + // MARK: Collection + typealias Element = T + var startIndex: Int { 0 } + var endIndex: Int { Int(size) } + func index(after i: Int) -> Int { + i+1 + } + + func index(of: Element) -> Int? { + var index: UInt32 = 0 + let result = indexOf(of, &index) + guard result else { return nil } + return Int(index) + } + var count: Int { Int(size) } + + subscript(position: Int) -> Element { + get { + getAt(UInt32(position)) + } + } + // MARK: WinRT + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivectorview-1.getat) + fileprivate func getAt(_ index: UInt32) -> WindowsFoundation.AnyIWwwFormUrlDecoderEntry? { + try! _default.GetAtImpl(index) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivectorview-1.indexof) + fileprivate func indexOf(_ value: WindowsFoundation.AnyIWwwFormUrlDecoderEntry?, _ index: inout UInt32) -> Bool { + try! _default.IndexOfImpl(value, &index) + } + + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivectorview-1.size) + fileprivate var size : UInt32 { + get { try! _default.get_SizeImpl() } + } + + private lazy var _IIterable: IIterableIWwwFormUrlDecoderEntry! = getInterfaceForCaching() + /// [Open Microsoft documentation](https://learn.microsoft.com/uwp/api/windows.foundation.collections.ivectorview-1.first) + fileprivate func first() -> WindowsFoundation.AnyIIterator? { + try! _IIterable.FirstImpl() + } + + public func queryInterface(_ iid: WindowsFoundation.IID) -> IUnknownRef? { nil } +} + +private var IID___x_ABI_C__FMapChangedEventHandler_2_HSTRING_IInspectable: WindowsFoundation.IID { + .init(Data1: 0x24f981e5, Data2: 0xddca, Data3: 0x538d, Data4: ( 0xaa,0xda,0xa5,0x99,0x06,0x08,0x4c,0xf1 ))// 24f981e5-ddca-538d-aada-a59906084cf1 +} + +internal extension WinRTDelegateBridge where CABI == __x_ABI_C__FMapChangedEventHandler_2_HSTRING_IInspectable { + static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &WindowsFoundation.__x_ABI_C__FMapChangedEventHandler_2_HSTRING_IInspectableVTable) { $0 } + return .init(lpVtbl:vtblPtr) + } +} + +internal var __x_ABI_C__FMapChangedEventHandler_2_HSTRING_IInspectableVTable: __x_ABI_C__FMapChangedEventHandler_2_HSTRING_IInspectableVtbl = .init( + QueryInterface: { __x_ABI_C__FMapChangedEventHandler_2_HSTRING_IInspectableWrapper.queryInterface($0, $1, $2) }, + AddRef: { __x_ABI_C__FMapChangedEventHandler_2_HSTRING_IInspectableWrapper.addRef($0) }, + Release: { __x_ABI_C__FMapChangedEventHandler_2_HSTRING_IInspectableWrapper.release($0) }, + Invoke: { + guard let __unwrapped__instance = __x_ABI_C__FMapChangedEventHandler_2_HSTRING_IInspectableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let sender: WindowsFoundation.AnyIObservableMap? = WindowsFoundation.__x_ABI_C__FIObservableMap_2_HSTRING_IInspectableWrapper.unwrapFrom(abi: ComPtr($1)) + let event: WindowsFoundation.AnyIMapChangedEventArgs? = WindowsFoundation.__x_ABI_C__FIMapChangedEventArgs_1_HSTRINGWrapper.unwrapFrom(abi: ComPtr($2)) + __unwrapped__instance(sender, event) + return S_OK + } +) +typealias __x_ABI_C__FMapChangedEventHandler_2_HSTRING_IInspectableWrapper = InterfaceWrapperBase +internal class MapChangedEventHandlerString_Any: WindowsFoundation.IUnknown { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_C__FMapChangedEventHandler_2_HSTRING_IInspectable } + + internal func InvokeImpl(_ sender: WindowsFoundation.AnyIObservableMap?, _ event: WindowsFoundation.AnyIMapChangedEventArgs?) throws { + let senderWrapper = WindowsFoundation.__x_ABI_C__FIObservableMap_2_HSTRING_IInspectableWrapper(sender) + let _sender = try! senderWrapper?.toABI { $0 } + let eventWrapper = WindowsFoundation.__x_ABI_C__FIMapChangedEventArgs_1_HSTRINGWrapper(event) + let _event = try! eventWrapper?.toABI { $0 } + _ = try perform(as: __x_ABI_C__FMapChangedEventHandler_2_HSTRING_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Invoke(pThis, _sender, _event)) + } + } + +} + +internal class __x_ABI_C__FMapChangedEventHandler_2_HSTRING_IInspectableBridge : WinRTDelegateBridge { + internal typealias Handler = WindowsFoundation.MapChangedEventHandler + internal typealias CABI = __x_ABI_C__FMapChangedEventHandler_2_HSTRING_IInspectable + internal typealias SwiftABI = WindowsFoundation.MapChangedEventHandlerString_Any + + internal static func from(abi: ComPtr?) -> Handler? { + guard let abi = abi else { return nil } + let _default = SwiftABI(abi) + let handler: Handler = { (sender, event) in + try! _default.InvokeImpl(sender, event) + } + return handler + } +} +private var IID___x_ABI_C__FMapChangedEventHandler_2_HSTRING_HSTRING: WindowsFoundation.IID { + .init(Data1: 0xe2663f37, Data2: 0x2e1b, Data3: 0x500c, Data4: ( 0xad,0x68,0xc3,0xed,0x7a,0x8f,0x74,0xc8 ))// e2663f37-2e1b-500c-ad68-c3ed7a8f74c8 +} + +internal extension WinRTDelegateBridge where CABI == __x_ABI_C__FMapChangedEventHandler_2_HSTRING_HSTRING { + static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &WindowsFoundation.__x_ABI_C__FMapChangedEventHandler_2_HSTRING_HSTRINGVTable) { $0 } + return .init(lpVtbl:vtblPtr) + } +} + +internal var __x_ABI_C__FMapChangedEventHandler_2_HSTRING_HSTRINGVTable: __x_ABI_C__FMapChangedEventHandler_2_HSTRING_HSTRINGVtbl = .init( + QueryInterface: { __x_ABI_C__FMapChangedEventHandler_2_HSTRING_HSTRINGWrapper.queryInterface($0, $1, $2) }, + AddRef: { __x_ABI_C__FMapChangedEventHandler_2_HSTRING_HSTRINGWrapper.addRef($0) }, + Release: { __x_ABI_C__FMapChangedEventHandler_2_HSTRING_HSTRINGWrapper.release($0) }, + Invoke: { + guard let __unwrapped__instance = __x_ABI_C__FMapChangedEventHandler_2_HSTRING_HSTRINGWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let sender: WindowsFoundation.AnyIObservableMap? = WindowsFoundation.__x_ABI_C__FIObservableMap_2_HSTRING_HSTRINGWrapper.unwrapFrom(abi: ComPtr($1)) + let event: WindowsFoundation.AnyIMapChangedEventArgs? = WindowsFoundation.__x_ABI_C__FIMapChangedEventArgs_1_HSTRINGWrapper.unwrapFrom(abi: ComPtr($2)) + __unwrapped__instance(sender, event) + return S_OK + } +) +typealias __x_ABI_C__FMapChangedEventHandler_2_HSTRING_HSTRINGWrapper = InterfaceWrapperBase +internal class MapChangedEventHandlerString_String: WindowsFoundation.IUnknown { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_C__FMapChangedEventHandler_2_HSTRING_HSTRING } + + internal func InvokeImpl(_ sender: WindowsFoundation.AnyIObservableMap?, _ event: WindowsFoundation.AnyIMapChangedEventArgs?) throws { + let senderWrapper = WindowsFoundation.__x_ABI_C__FIObservableMap_2_HSTRING_HSTRINGWrapper(sender) + let _sender = try! senderWrapper?.toABI { $0 } + let eventWrapper = WindowsFoundation.__x_ABI_C__FIMapChangedEventArgs_1_HSTRINGWrapper(event) + let _event = try! eventWrapper?.toABI { $0 } + _ = try perform(as: __x_ABI_C__FMapChangedEventHandler_2_HSTRING_HSTRING.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Invoke(pThis, _sender, _event)) + } + } + +} + +internal class __x_ABI_C__FMapChangedEventHandler_2_HSTRING_HSTRINGBridge : WinRTDelegateBridge { + internal typealias Handler = WindowsFoundation.MapChangedEventHandler + internal typealias CABI = __x_ABI_C__FMapChangedEventHandler_2_HSTRING_HSTRING + internal typealias SwiftABI = WindowsFoundation.MapChangedEventHandlerString_String + + internal static func from(abi: ComPtr?) -> Handler? { + guard let abi = abi else { return nil } + let _default = SwiftABI(abi) + let handler: Handler = { (sender, event) in + try! _default.InvokeImpl(sender, event) + } + return handler + } +} +private var IID___x_ABI_C__FITypedEventHandler_2___x_ABI_CWindows__CFoundation__CIMemoryBufferReference_IInspectable: WindowsFoundation.IID { + .init(Data1: 0xf4637d4a, Data2: 0x0760, Data3: 0x5431, Data4: ( 0xbf,0xc0,0x24,0xeb,0x1d,0x4f,0x6c,0x4f ))// f4637d4a-0760-5431-bfc0-24eb1d4f6c4f +} + +internal extension WinRTDelegateBridge where CABI == __x_ABI_C__FITypedEventHandler_2___x_ABI_CWindows__CFoundation__CIMemoryBufferReference_IInspectable { + static func makeAbi() -> CABI { + let vtblPtr = withUnsafeMutablePointer(to: &WindowsFoundation.__x_ABI_C__FITypedEventHandler_2___x_ABI_CWindows__CFoundation__CIMemoryBufferReference_IInspectableVTable) { $0 } + return .init(lpVtbl:vtblPtr) + } +} + +internal var __x_ABI_C__FITypedEventHandler_2___x_ABI_CWindows__CFoundation__CIMemoryBufferReference_IInspectableVTable: __x_ABI_C__FITypedEventHandler_2___x_ABI_CWindows__CFoundation__CIMemoryBufferReference_IInspectableVtbl = .init( + QueryInterface: { __x_ABI_C__FITypedEventHandler_2___x_ABI_CWindows__CFoundation__CIMemoryBufferReference_IInspectableWrapper.queryInterface($0, $1, $2) }, + AddRef: { __x_ABI_C__FITypedEventHandler_2___x_ABI_CWindows__CFoundation__CIMemoryBufferReference_IInspectableWrapper.addRef($0) }, + Release: { __x_ABI_C__FITypedEventHandler_2___x_ABI_CWindows__CFoundation__CIMemoryBufferReference_IInspectableWrapper.release($0) }, + Invoke: { + guard let __unwrapped__instance = __x_ABI_C__FITypedEventHandler_2___x_ABI_CWindows__CFoundation__CIMemoryBufferReference_IInspectableWrapper.tryUnwrapFrom(raw: $0) else { return E_INVALIDARG } + let sender: WindowsFoundation.AnyIMemoryBufferReference? = __ABI_Windows_Foundation.IMemoryBufferReferenceWrapper.unwrapFrom(abi: ComPtr($1)) + let args: Any? = __ABI_.AnyWrapper.unwrapFrom(abi: ComPtr($2)) + __unwrapped__instance(sender, args) + return S_OK + } +) +typealias __x_ABI_C__FITypedEventHandler_2___x_ABI_CWindows__CFoundation__CIMemoryBufferReference_IInspectableWrapper = InterfaceWrapperBase +internal class TypedEventHandlerIMemoryBufferReference_Any: WindowsFoundation.IUnknown { + override public class var IID: WindowsFoundation.IID { IID___x_ABI_C__FITypedEventHandler_2___x_ABI_CWindows__CFoundation__CIMemoryBufferReference_IInspectable } + + internal func InvokeImpl(_ sender: WindowsFoundation.AnyIMemoryBufferReference?, _ args: Any?) throws { + let senderWrapper = __ABI_Windows_Foundation.IMemoryBufferReferenceWrapper(sender) + let _sender = try! senderWrapper?.toABI { $0 } + let argsWrapper = __ABI_.AnyWrapper(args) + let _args = try! argsWrapper?.toABI { $0 } + _ = try perform(as: __x_ABI_C__FITypedEventHandler_2___x_ABI_CWindows__CFoundation__CIMemoryBufferReference_IInspectable.self) { pThis in + try CHECKED(pThis.pointee.lpVtbl.pointee.Invoke(pThis, _sender, _args)) + } + } + +} + +internal class __x_ABI_C__FITypedEventHandler_2___x_ABI_CWindows__CFoundation__CIMemoryBufferReference_IInspectableBridge : WinRTDelegateBridge { + internal typealias Handler = WindowsFoundation.TypedEventHandler + internal typealias CABI = __x_ABI_C__FITypedEventHandler_2___x_ABI_CWindows__CFoundation__CIMemoryBufferReference_IInspectable + internal typealias SwiftABI = WindowsFoundation.TypedEventHandlerIMemoryBufferReference_Any + + internal static func from(abi: ComPtr?) -> Handler? { + guard let abi = abi else { return nil } + let _default = SwiftABI(abi) + let handler: Handler = { (sender, args) in + try! _default.InvokeImpl(sender, args) + } + return handler + } +} +public extension EventSource where Handler == TypedEventHandler { + func invoke(_ sender: WindowsFoundation.AnyIMemoryBufferReference!, _ args: Any!) { + for handler in getInvocationList() { + handler(sender, args) + } + } +} + diff --git a/Sources/WindowsFoundation/Generated/WindowsFoundation+MakeFromAbi.swift b/Sources/WindowsFoundation/Generated/WindowsFoundation+MakeFromAbi.swift new file mode 100644 index 0000000..813c636 --- /dev/null +++ b/Sources/WindowsFoundation/Generated/WindowsFoundation+MakeFromAbi.swift @@ -0,0 +1,113 @@ +// WARNING: Please don't edit this file. It was generated by Swift/WinRT v0.0.1 +// swiftlint:disable all +import Foundation +import CWinRT + +fileprivate func makeIAsyncActionFrom(abi: WindowsFoundation.IInspectable) -> Any { + let swiftAbi: __ABI_Windows_Foundation.IAsyncAction = try! abi.QueryInterface() + return __IMPL_Windows_Foundation.IAsyncActionBridge.from(abi: RawPointer(swiftAbi))! +} + +fileprivate func makeIAsyncInfoFrom(abi: WindowsFoundation.IInspectable) -> Any { + let swiftAbi: __ABI_Windows_Foundation.IAsyncInfo = try! abi.QueryInterface() + return __IMPL_Windows_Foundation.IAsyncInfoBridge.from(abi: RawPointer(swiftAbi))! +} + +fileprivate func makeIClosableFrom(abi: WindowsFoundation.IInspectable) -> Any { + let swiftAbi: __ABI_Windows_Foundation.IClosable = try! abi.QueryInterface() + return __IMPL_Windows_Foundation.IClosableBridge.from(abi: RawPointer(swiftAbi))! +} + +fileprivate func makeIGetActivationFactoryFrom(abi: WindowsFoundation.IInspectable) -> Any { + let swiftAbi: __ABI_Windows_Foundation.IGetActivationFactory = try! abi.QueryInterface() + return __IMPL_Windows_Foundation.IGetActivationFactoryBridge.from(abi: RawPointer(swiftAbi))! +} + +fileprivate func makeIMemoryBufferFrom(abi: WindowsFoundation.IInspectable) -> Any { + let swiftAbi: __ABI_Windows_Foundation.IMemoryBuffer = try! abi.QueryInterface() + return __IMPL_Windows_Foundation.IMemoryBufferBridge.from(abi: RawPointer(swiftAbi))! +} + +fileprivate func makeIMemoryBufferReferenceFrom(abi: WindowsFoundation.IInspectable) -> Any { + let swiftAbi: __ABI_Windows_Foundation.IMemoryBufferReference = try! abi.QueryInterface() + return __IMPL_Windows_Foundation.IMemoryBufferReferenceBridge.from(abi: RawPointer(swiftAbi))! +} + +fileprivate func makeIStringableFrom(abi: WindowsFoundation.IInspectable) -> Any { + let swiftAbi: __ABI_Windows_Foundation.IStringable = try! abi.QueryInterface() + return __IMPL_Windows_Foundation.IStringableBridge.from(abi: RawPointer(swiftAbi))! +} + +fileprivate func makeIWwwFormUrlDecoderEntryFrom(abi: WindowsFoundation.IInspectable) -> Any { + let swiftAbi: __ABI_Windows_Foundation.IWwwFormUrlDecoderEntry = try! abi.QueryInterface() + return __IMPL_Windows_Foundation.IWwwFormUrlDecoderEntryBridge.from(abi: RawPointer(swiftAbi))! +} + +fileprivate func makeIPropertySetFrom(abi: WindowsFoundation.IInspectable) -> Any { + let swiftAbi: __ABI_Windows_Foundation_Collections.IPropertySet = try! abi.QueryInterface() + return __IMPL_Windows_Foundation_Collections.IPropertySetBridge.from(abi: RawPointer(swiftAbi))! +} + +fileprivate func makeIVectorChangedEventArgsFrom(abi: WindowsFoundation.IInspectable) -> Any { + let swiftAbi: __ABI_Windows_Foundation_Collections.IVectorChangedEventArgs = try! abi.QueryInterface() + return __IMPL_Windows_Foundation_Collections.IVectorChangedEventArgsBridge.from(abi: RawPointer(swiftAbi))! +} + +fileprivate func makeDeferralFrom(abi: WindowsFoundation.IInspectable) -> Any { + return Deferral(fromAbi: abi) +} + +fileprivate func makeMemoryBufferFrom(abi: WindowsFoundation.IInspectable) -> Any { + return MemoryBuffer(fromAbi: abi) +} + +fileprivate func makeUriFrom(abi: WindowsFoundation.IInspectable) -> Any { + return Uri(fromAbi: abi) +} + +fileprivate func makeWwwFormUrlDecoderFrom(abi: WindowsFoundation.IInspectable) -> Any { + return WwwFormUrlDecoder(fromAbi: abi) +} + +fileprivate func makeWwwFormUrlDecoderEntryFrom(abi: WindowsFoundation.IInspectable) -> Any { + return WwwFormUrlDecoderEntry(fromAbi: abi) +} + +fileprivate func makePropertySetFrom(abi: WindowsFoundation.IInspectable) -> Any { + return PropertySet(fromAbi: abi) +} + +fileprivate func makeStringMapFrom(abi: WindowsFoundation.IInspectable) -> Any { + return StringMap(fromAbi: abi) +} + +fileprivate func makeValueSetFrom(abi: WindowsFoundation.IInspectable) -> Any { + return ValueSet(fromAbi: abi) +} + +@_spi(__MakeFromAbi_DoNotImport) +public class __MakeFromAbi: MakeFromAbi { + public static func from(typeName: String, abi: WindowsFoundation.IInspectable) -> Any? { + switch typeName { + case "IAsyncAction": return makeIAsyncActionFrom(abi: abi) + case "IAsyncInfo": return makeIAsyncInfoFrom(abi: abi) + case "IClosable": return makeIClosableFrom(abi: abi) + case "IGetActivationFactory": return makeIGetActivationFactoryFrom(abi: abi) + case "IMemoryBuffer": return makeIMemoryBufferFrom(abi: abi) + case "IMemoryBufferReference": return makeIMemoryBufferReferenceFrom(abi: abi) + case "IStringable": return makeIStringableFrom(abi: abi) + case "IWwwFormUrlDecoderEntry": return makeIWwwFormUrlDecoderEntryFrom(abi: abi) + case "IPropertySet": return makeIPropertySetFrom(abi: abi) + case "IVectorChangedEventArgs": return makeIVectorChangedEventArgsFrom(abi: abi) + case "Deferral": return makeDeferralFrom(abi: abi) + case "MemoryBuffer": return makeMemoryBufferFrom(abi: abi) + case "Uri": return makeUriFrom(abi: abi) + case "WwwFormUrlDecoder": return makeWwwFormUrlDecoderFrom(abi: abi) + case "WwwFormUrlDecoderEntry": return makeWwwFormUrlDecoderEntryFrom(abi: abi) + case "PropertySet": return makePropertySetFrom(abi: abi) + case "StringMap": return makeStringMapFrom(abi: abi) + case "ValueSet": return makeValueSetFrom(abi: abi) + default: return nil + } + } +} diff --git a/generate-bindings.ps1 b/generate-bindings.ps1 new file mode 100644 index 0000000..05778fb --- /dev/null +++ b/generate-bindings.ps1 @@ -0,0 +1,138 @@ +function Get-SwiftWinRTVersion { + $Projections = Get-Content -Path $PSScriptRoot\projections.json | ConvertFrom-Json + return $Projections."swift-winrt" +} + +function Get-PackageString { + param( + $Package + ) + if ($Package) { + return " `n" + } +} +function Restore-Nuget { + param( + [string]$PackagesDir + ) + $NugetDownloadPath = Join-Path $env:TEMP "nuget.exe" + if (-not (Test-Path $NugetDownloadPath)) { + Invoke-WebRequest -Uri "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile $NugetDownloadPath + } + + $Projections = Get-Content -Path $PSScriptRoot\projections.json | ConvertFrom-Json + $SwiftWinRTVersion = Get-SwiftWinRTVersion + $PackagesConfigContent = "`n" + $PackagesConfigContent += "`n" + $PackagesConfigContent += " `n" + if ($Projections.Package) { + $PackagesConfigContent += Get-PackageString -Package $Projections.Package + } + + $Projections.Packages | ForEach-Object { + $PackagesConfigContent += Get-PackageString -Package $_ + } + $Projections.Dependencies | ForEach-Object { + $PackagesConfigContent += Get-PackageString -Package $_ + } + $PackagesConfigContent += "" + if (-not (Test-Path "$PSScriptRoot\.packages")) { + New-Item -ItemType Directory -Path "$PSScriptRoot\.packages" | Out-Null + } + $PackagesConfigPath = Join-Path $PSScriptRoot ".packages\packages.config" + $PackagesConfigContent | Out-File -FilePath $PackagesConfigPath + + & $NugetDownloadPath restore $PackagesConfigPath -PackagesDirectory $PackagesDir | Out-Null + if ($LASTEXITCODE -ne 0) { + exit 1 + } +} + +function Get-WinMDInputs() { + param( + $Package + ) + $Id = $Package.Id + $Version = $Package.Version + return Get-ChildItem -Path $PackagesDir\$Id.$Version\ -Filter *.winmd -Recurse +} + +function Copy-Project { + param( + [string]$OutputLocation, + [string]$ProjectName + ) + + if ($ProjectName) { + $ProjectGeneratedDir = if ($ProjectName -eq "CWinRT") { "$ProjectName" } else { "$ProjectName\Generated" } + + $ProjectDir = Join-Path $PSScriptRoot "Sources\$ProjectGeneratedDir" + if (Test-Path $ProjectDir) { + Remove-Item -Path $ProjectDir -Recurse -Force + } + Copy-Item -Path $OutputLocation\Sources\$ProjectName -Destination $ProjectDir -Recurse -Force + } +} + + +function Invoke-SwiftWinRT() { + param( + [string]$PackagesDir + ) + $Projections = Get-Content -Path $PSScriptRoot\projections.json | ConvertFrom-Json + + $SwiftWinRTVersion = Get-SwiftWinRTVersion + # write generated bindings to a temp directory since swiftwinrt will generate all dependencies and the CWinRT + $OutputLocation = Join-Path $PSScriptRoot ".generated" + if (Test-Path $OutputLocation) { + Remove-Item -Path $OutputLocation -Recurse -Force + } + + $RspParams = "-output $OutputLocation`n" + + # read projections.json and for each "include" write to -include param. for each "exclude" write to -exclude param + $Projections.Include | ForEach-Object { + $RspParams += "-include $_`n" + } + $Projections.Exclude | ForEach-Object { + $RspParams += "-exclude $_`n" + } + + if ($Projections.Package) { + Get-WinMDInputs -Package $Package | ForEach-Object { + $RspParams += "-input $($_.FullName)`n" + } + } + + $Projections.Packages | ForEach-Object { + Get-WinMDInputs -Package $Package | ForEach-Object { + $RspParams += "-input $($_.FullName)`n" + } + } + $Projections.Dependencies | ForEach-Object { + Get-WinMDInputs -Package $Package | ForEach-Object { + $RspParams += "-input $($_.FullName)`n" + } + } + # write rsp params to file + $RspFile = Join-Path $PSScriptRoot "swift-winrt.rsp" + $RspParams | Out-File -FilePath $RspFile + & $PackagesDir\TheBrowserCompany.SwiftWinRT.$SwiftWinRTVersion\bin\swiftwinrt.exe "@$RspFile" + + if ($LASTEXITCODE -ne 0) { + Write-Host "swiftwinrt failed with error code $LASTEXITCODE" -ForegroundColor Red + exit 1 + } + + $Projections.Projects | ForEach-Object { + Copy-Project -OutputLocation $OutputLocation -ProjectName $_ + } + + if ($Projections.Project) { + Copy-Project -OutputLocation $OutputLocation -ProjectName $Projections.Project + } +} +$PackagesDir = Join-Path $PSScriptRoot ".packages" +Restore-Nuget -PackagesDir $PackagesDir +Invoke-SwiftWinRT -PackagesDir $PackagesDir +Write-Host "SwiftWinRT bindings generated successfully!" -ForegroundColor Green \ No newline at end of file diff --git a/projections.json b/projections.json new file mode 100644 index 0000000..8eb2c47 --- /dev/null +++ b/projections.json @@ -0,0 +1,18 @@ +{ + "swift-winrt": "0.5.0", + "package": { + "id": "Microsoft.Windows.SDK.Contracts", + "version": "10.0.18362.2005" + }, + "projects": ["WindowsFoundation"], + "dependencies": [ + ], + "include": [ + "Windows.Foundation.Collections", + "Windows.Foundation.Numerics", + "Windows.Foundation", + ], + "exclude": [ + "Windows.Foundation.PropertyValue" + ] +}