-
Notifications
You must be signed in to change notification settings - Fork 465
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
Replace internal IActivationFactory
definition with tailored definition
#1678
Conversation
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.
Just a few nits.
One thing to note: the actual change here is pretty small, but the diff is big because so many bindings needed to change. It would be very helpful to separate out implementation work in one commit from changes to bindings in another.
use super::*; | ||
use std::mem::*; | ||
|
||
// A streamlined version of the IActivationFactory interface used by WinRT class factories used internally by the windows crate |
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.
Nit: this should be a ///
doc comment so that it's picked up by tooling
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.
How does this work when the docs are hidden for this type?
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.
rust-analyzer
shows hidden docs so those working on Windows (who would be the ones who would benefit from this doc), would be able to see this on hover.
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.
Ah that makes sense. I haven't used rust-analyzer in many months as it seemed to really struggle with the size of the repo.
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.
Anyway, I'll try to make a habit of using ///
for this purpose.
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.
Yes, I noticed rust-analyzer was really struggling... I was able to get it to work fine by editing the workspace definition and removing some things temporarily. This at least allowed me to use rust-analyzer
from within windows::core
.
pub struct IGenericFactory(IUnknown); | ||
|
||
impl IGenericFactory { | ||
pub fn ActivateInstance<I: Interface>(&self) -> Result<I> { |
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.
I know this is an internal API but some documentation would be helpful. Even if it just points out that this is the ActivateInstance
from IActivationFactory
(and then link here)
The
IActivationFactory
interface is implemented by all WinRT class factories and acts as the gateway for DLL-based activation. This is a curious interface whoseActivateInstance
method isn't very practical for language projections to use since they almost always need to immediately cast the result to something other than what this method returns. As such, the definition used by thewindows
crate is different to the one provided by the generated bindings. In order to avoid name collisions, the version used internally by the factory cache is renamed to avoid this conflict. #1675 should also help to avoid such collisions in a more general way in future but is a bigger change that I'll tackle separately.This PR also updates the test component to illustrate how components can implement
IActivationFactory
directly using the bindings generated by thebindgen
crate rather than depending on the internal definition used by thewindows
crate.Fixes #1662