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

Implement Deref for COM interface hierarchies in windows-bindgen #2968

Merged
merged 5 commits into from
Apr 4, 2024

Conversation

kennykerr
Copy link
Collaborator

@kennykerr kennykerr commented Apr 4, 2024

I'm working on a few improvements to COM support.

Originally, windows-rs was focused on WinRT - with its support for multiple inheritance - and so I couldn't use Deref since multiple implementations would be needed. Of course, today windows-rs fully supports COM as well where there are plenty of opportunities to benefit from Deref for single inheritance.

windows-bindgen will now generate Deref implementations for COM interfaces.

This also avoids the need to redundantly define inherited interface methods in such cases, greatly reducing lines of code, and build time, for COM-heavy APIs. As an example, the Direct3D12 module goes from 26,896 to 18,935 lines of code.

This changes the way overloaded method names are handled in inherited scenarios. As you can see in 9e6d4bc, this actually simplifies code and makes it a bit more natural by avoiding many artificially mangled method names. If you still need to call the overload from an inherited interface, you can call deref() to reach down explicitly or cast to the inherited interface as needed.

Next up I'm going to make related improvements to the implement and interface macros.

@kennykerr kennykerr merged commit 16792d5 into master Apr 4, 2024
69 checks passed
@kennykerr kennykerr deleted the deref branch April 4, 2024 15:42
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.

1 participant