Skip to content

Commit

Permalink
Build fixes and a little more juggling
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanlabelle committed Sep 5, 2024
1 parent 340695b commit 9a82712
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 26 deletions.
23 changes: 23 additions & 0 deletions Support/Sources/COM/COMError+createErrorInfo.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import COM_ABI

extension COMError {
/// Creates an instance of `ICreateErrorInfo`.
public static func createErrorInfo() throws -> ICreateErrorInfo {
var createErrorInfo = ICreateErrorInfoProjection.abiDefaultValue
defer { ICreateErrorInfoProjection.release(&createErrorInfo) }
try COMError.fromABI(SWRT_CreateErrorInfo(&createErrorInfo))
return try NullResult.unwrap(ICreateErrorInfoProjection.toSwift(createErrorInfo))
}

/// Creates an instance of `IErrorInfo` with prepopulated fields.
public static func createErrorInfo(guid: GUID? = nil, source: String? = nil, description: String?,
helpFile: String? = nil, helpContext: UInt32? = nil) throws -> IErrorInfo {
let errorInfo = try createErrorInfo()
if let guid { try errorInfo.setGUID(guid) }
if let source { try errorInfo.setSource(source) }
if let description { try errorInfo.setDescription(description) }
if let helpFile { try errorInfo.setHelpFile(helpFile) }
if let helpContext { try errorInfo.setHelpContext(helpContext) }
return try errorInfo.queryInterface(IErrorInfoProjection.self)
}
}
2 changes: 1 addition & 1 deletion Support/Sources/COM/COMError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public struct COMError: COMErrorProtocol, CustomStringConvertible {
}

public init(hresult: HResult, description: String?) {
self.init(hresult: hresult, errorInfo: description.flatMap { try? createErrorInfo(description: $0) })
self.init(hresult: hresult, errorInfo: description.flatMap { try? Self.createErrorInfo(description: $0) })
}

public var description: String {
Expand Down
21 changes: 0 additions & 21 deletions Support/Sources/COM/ProjectedTypes/ICreateErrorInfo+create.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public enum IRestrictedErrorInfoProjection: COMProjection {

private final class Import: COMImport<IRestrictedErrorInfoProjection>, IRestrictedErrorInfoProtocol {
func getErrorDetails(
description: inout String?,
error: inout HResult,
restrictedDescription: inout String?,
capabilitySid: inout String?) throws {
_ description: inout String?,
_ error: inout HResult,
_ restrictedDescription: inout String?,
_ capabilitySid: inout String?) throws {
try _interop.getErrorDetails(&description, &error, &restrictedDescription, &capabilitySid)
}

Expand Down

0 comments on commit 9a82712

Please sign in to comment.