Skip to content
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

Switch to custom bindings for the windows::core internals #1993

Merged
merged 1 commit into from Aug 30, 2022
Merged

Conversation

kennykerr
Copy link
Collaborator

@kennykerr kennykerr commented Aug 30, 2022

The windows::core module provides various facilities in support of Windows APIs published by the windows crate and relies on various Windows API internally to make that happen. Up to this point, those APIs were generated by a variant of the bindgen crate but this has a few drawbacks:

  1. It complicates the bindgen crate
  2. It generates far more code than is needed
  3. It assumes you're on the "outside"

I had considered using windows-sys internally but that's not practical because:

  1. The windows-sys crate lacks support for COM interfaces
  2. windows-sys is versioned independently from the windows crate

So I ended up just taking a snapshot of the APIs I need internally. This avoids all kinds of inter-dependencies that were making it harder and harder to make improvements to the windows::core module and frees me to fix a number of outstanding issues far more easily. It also greatly reduces the amount of code in the windows::core module.

@@ -25,6 +25,6 @@ unsafe impl<T: Interface> Sync for AgileReference<T> {}

impl<T> std::fmt::Debug for AgileReference<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "AgileReference({:?})", <&IAgileReference as Into<&IUnknown>>::into(&self.0))
write!(f, "AgileReference({:?})", &self.0 .0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Is the space in .0 .0 intentional here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that too. It's rustfmt being creative. 🙄

@kennykerr kennykerr merged commit 51919f1 into master Aug 30, 2022
@kennykerr kennykerr deleted the bindings branch August 30, 2022 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants