windows-bindgen
now uses Ref
and OutRef
for COM interface traits
#3386
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.
Earlier this year I was working on improving COM authoring support and came up with
Ref
andOutRef
to simplify support for the complex memory layout and lifetime management required by COM interface parameters. #3025This was only available as an opt-in for hand-written code and your own COM interfaces defined with the
interface
macro. In particular, the traits generated by thewindows-bindgen
crate did not useRef
andOutRef
and instead continued to useOption
in various ways.With this update the two streams converge and
windows-bindgen
will now useRef
andOutRef
as appropriate. This makes programming across custom and generated COM interfaces more consistent and easier to understand. It also avoids a few pitfalls thatRef
andOutRef
solve that would otherwise not be possible to rectify without it.The
Ref
type now also has a few more convenience methods to directly support common COM programming scenarios.This does not quite close #3233 but it does get us closer.