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

Add weak reference (consumer) support #718

Merged
merged 4 commits into from
Apr 21, 2021
Merged

Add weak reference (consumer) support #718

merged 4 commits into from
Apr 21, 2021

Conversation

kennykerr
Copy link
Collaborator

@kennykerr kennykerr commented Apr 21, 2021

On the way to #81, first up is support for weak references as this is required for Xaml/WinUI and is just generally what COM and WinRT objects should provide by default. This update adds support for creating a weak reference to an existing implementation. This is the easy part. Next up is implementing weak references as part of the implement macro. That's the hard part...

@kennykerr kennykerr merged commit b850be8 into master Apr 21, 2021
@kennykerr kennykerr deleted the weak branch April 21, 2021 18:54
assert_eq!(result.is_err(), true);

// E_NOINTERFACE is returned because IWeakReferenceSource is not implemented.
assert_eq!(result.unwrap_err().code(), HRESULT(0x8000_4002));
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, is there a reason we still don’t define constants for common HRESULTs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These are defined in the Win32 metadata. We need to be careful not to depend on these as part of code gen to avoid forcing the consuming apps to require the same dependency. In this particular case, its just a local test so we could rely on generated HRESULTs here.

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.

2 participants