Allow C++/WinRT namespace additions to be injected in the top-level headers#321
Merged
Conversation
DefaultRyan
reviewed
Apr 16, 2019
| object = nullptr; | ||
| } | ||
|
|
||
| return (void**)(&object); |
Contributor
Author
There was a problem hiding this comment.
It's pretty concise. 😉 But yeah...
DefaultRyan
reviewed
Apr 16, 2019
| } | ||
| case param_category::object_type: | ||
| case param_category::string_type: | ||
| w.write("*(void**)(&%)", param_name); |
Contributor
Author
There was a problem hiding this comment.
Going to leave this as-is for now. It's tricky because this is used for in params so this goes from:
(void**)(¶m)
To this:
reinterpret_cast<void**>(const_cast<FULL_TYPE_NAME_HERE*>(¶m))
This is obviously super verbose and I'd argue makes the code harder to debug through.
DefaultRyan
approved these changes
Apr 16, 2019
This file contains hidden or 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.
The ability to inject the "special" additions to each namespace into the top-level .h headers rather than the .2.h headers solves a number of dependency/layering problems. First, mysterious compiler/linker are avoided because popular helpers like "single_threaded_vector" are only defined if their dependent types are actually defined. Second, it means that things like the coroutine helpers can actually be appended to individual namespace headers rather than being lumped into a separate header. While this was easier for the implementation, it has caused a bit of friction during the 2.0 rollout as developers have had to remember to include an additional header.
The ability to do all of this hinges on the removal of the use of std::is_base_of, which has for a long time caused an overly deep type dependency in C++/WinRT where every use of get_abi had to have the full type defintion of its argument. This meant that more headers needed to be included and things like the input param types could not live in the top-level .h headers.
Thanks to the xlang metadata reader, C++/WinRT now properly categorizes parameter types and more acurately casts to the ABI, thus avoiding get_abi in all cases and put_abi in some cases. I plan to further clean this up by removing all uses of put_abi, but this is a good first step as we no longer use get_abi anywhere internally.