Skip to content

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Aug 15, 2025

This PR cleans up the implementations of image attachments on Darwin and Windows so that we have less code duplication between the two. _AttachableImageWrapper is partially lowered to the main library (excepting the platform-specific bits) and ImageAttachmentError is lowered in its entirety.

There are some adjustments to the (internal/package) interface of _AttachableImageWrapper to accomodate it not being able to specify conformance to AttachableAsCGImage or AttachableAsIWICBitmapSource. Namely, whatever code initializes an instance of it is responsible for copying image and providing a deinitializer function as needed.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

This PR cleans up the implementations of image attachments on Darwin and Windows
so that we have less code duplication between the two. `_AttachableImageWrapper`
is partially lowered to the main library (excepting the platform-specific bits)
and `ImageAttachmentError` is lowered in its entirety.

There are some adjustments to the (internal/package) interface of
`_AttachableImageWrapper` to accomodate it not being able to specify conformance
to `AttachableAsCGImage` or `AttachableAsIWICBitmapSource`. Namely, whatever
code initializes an instance of it is responsible for copying `image` and
providing a deinitializer function as needed.
@grynspan grynspan added this to the Swift 6.x (main) milestone Aug 15, 2025
@grynspan grynspan self-assigned this Aug 15, 2025
@grynspan grynspan added windows 🪟 Windows support darwin 🍎 macOS, iOS, watchOS, tvOS, and visionOS support attachments/activities 🖇️ Work related to attachments and/or activities tech-debt 💾 reduces technical debt labels Aug 15, 2025
@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan
Copy link
Contributor Author

@swift-ci test Windows

@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan
Copy link
Contributor Author

@swift-ci test macOS

@grynspan
Copy link
Contributor Author

@swift-ci test Linux

@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan
Copy link
Contributor Author

@swift-ci test Windows

@grynspan grynspan marked this pull request as ready for review August 18, 2025 15:12
…ntation shows both even if the WinSDK module isn't being built
@grynspan grynspan requested a review from jerryjrchen as a code owner August 18, 2025 17:03
@grynspan grynspan requested a review from stmontgomery August 18, 2025 17:05
@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan
Copy link
Contributor Author

Untested changes are just comment typo fixes. Merging.

@grynspan grynspan merged commit 8cbb491 into main Aug 18, 2025
@grynspan grynspan deleted the jgrynspan/reduce-code-duplication-in-image-attachments branch August 18, 2025 18:28
@grynspan grynspan added the image-attachments 📸 Work related to image attachments label Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

attachments/activities 🖇️ Work related to attachments and/or activities darwin 🍎 macOS, iOS, watchOS, tvOS, and visionOS support image-attachments 📸 Work related to image attachments tech-debt 💾 reduces technical debt windows 🪟 Windows support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants