-
Notifications
You must be signed in to change notification settings - Fork 120
Allow attaching an IWICBitmapSource
instance directly.
#1266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This PR adjusts the experimental WIC bitmap attachment support I recently added so that a test author can attach an instance of `IWICBitmapSource` (which is the parent type of the already-supported `IWICBitmap`.) Protocols and conformances are adjusted to match. I could have left the protocols as-is, but then you'd have to convert an `IWICBitmapSource` to an `IWICBitmap` (by allocating a new COM object) then cast it back to an `IWICBitmapSource` (by calling `QueryInterface()` and juggling the refcount) in order to actually attach it.
@swift-ci test |
/// - Important: This function consumes a reference to `self` even if the cast | ||
/// fails. | ||
consuming func cast(to _: IWICBitmapSource.Type) throws -> UnsafeMutablePointer<IWICBitmapSource> { | ||
try self.withMemoryRebound(to: IUnknown.self, capacity: 1) { `self` in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The casts in this file to IUnknown
are safe insofar as we use them to access fixed members of the COM vtable. The casts would become unsafe if we allowed the resulting pointers to escape and if any of the types we use them on have multiple non-virtual inheritance to IUnknown
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we capture this in a code comment for future reference?
@swift-ci test |
This PR adjusts the experimental WIC bitmap attachment support I recently added so that a test author can attach an instance of
IWICBitmapSource
(which is the parent type of the already-supportedIWICBitmap
.) Protocols and conformances are adjusted to match.This PR then explicitly adds conformances to every COM class in WIC that subclasses
IWICBitmapSource
since we can't see COM class inheritance in Swift (yet?)I could have left the protocols as-is, but then you'd have to convert an
IWICBitmapSource
to anIWICBitmap
(by allocating a new COM object) then cast it back to anIWICBitmapSource
(by callingQueryInterface()
and juggling the refcount) in order to actually attach it.Checklist: