-
Notifications
You must be signed in to change notification settings - Fork 511
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
Basic delegate support #130
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
WinRT delegates are COM interfaces that behave like function objects. They are used as callbacks for some APIs but overwhelmingly used to implement events and are thus required by many Windows APIs.
Much like WinRT interfaces, delegates may be generic and non-generic and like interfaces, generic delegates require GUIDs derived from their generic arguments. This update provides basic support for delegates and while you can call a generic delegate, you cannot use it with any API that might attempt to query its GUID. That's why I need to add support for #129 to unblock full use of delegates and then a ton more Windows APIs will suddenly light up.
Delegates also give the first taste of authoring support in Rust. Full authoring support will come later #81 and includes the ability to author WinRT classes and interfaces. For now, delegates represent a very simple form of type authoring as they require the caller to provide an implementation of the delegate's underlying COM interface. The implementation details need some improvement but this will unblock me to work on some of the other prerequisites as we move toward getting more of the type system online.
There are also a few usability issues that I still need to address.
Ok(())
.DelegateName::new(|| ...)
as that can be quite tedious.delegate(a, b, c)
instead ofdelegate.invoke(a, b, c)
.So room for improvement, but at least here we have the ABI roughed in so we can start building on this.
Fixes #72