Implement Deref
for COM interface hierarchies in windows-bindgen
#2968
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 fromDeref
for single inheritance.windows-bindgen
will now generateDeref
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
andinterface
macros.