-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Use x-macros for action args too #11859
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
Conversation
@check-spelling-bot ReportUnrecognized words, please review:
Previously acknowledged words that are now absentcarlos dpg MSVS sid SPACEBAR Unregister Urxvt vcvarsall xIcon yIcon zamoraTo accept these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands... in a clone of the git@github.com:microsoft/terminal.git repository
✏️ Contributor please read thisBy default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.
If the listed items are:
See the 🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉 🗜️ If you see a bunch of garbageIf it relates to a ... well-formed patternSee if there's a pattern that would match it. If not, try writing one and adding it to a Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines. Note that patterns can't match multiline strings. binary-ish stringPlease add a file path to the File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
|
another idea I had ```c++ #define MY_FOO_ARGS(X) \ X(Model::FocusDirection, FocusDirection, "direction", _validateArgs(args), Model::FocusDirection::None) struct MyFooArgs : public MyFooArgsT<MyFooArgs> { ACTION_ARG_BODY(MyFooArgs, MY_FOO_ARGS) private: bool _validateArgs(const auto& args) { /* Something complicated here */ return false; // Args were okay } } ``` But only do that for the last arg, otherwise we'll copy it for all of them
argsMacro(DECLARE_ARGS); \ | ||
\ | ||
private: \ | ||
InitListPlaceholder _placeholder; \ |
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.
You don't need to store the placeholder.
You do need to store it. 😄
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.
[[no_unique_address]]
will be helpful here in a few months with C++20.
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.
few months
Wow you're optimistic, @lhecker.
className() = default; \ | ||
className( \ | ||
argsMacro(CTOR_PARAMS) InitListPlaceholder = {}) : \ | ||
argsMacro(CTOR_INIT) _placeholder{} {}; \ |
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.
This ;
isn't needed.
// New Tabs, Panes, and Windows all use NewTerminalArgs, which is more | ||
// complicated and doesn't play nice with the macro. So those we'll still | ||
// have to define manually. |
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.
Follow-up? I could totally go either way on this one tbh.
// some element of the class definition that will use the x-macro. | ||
// | ||
// You'll author a new arg by: | ||
// 1: define a new x-macro above with all it's properties |
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.
"Above".... probably should be more specific as to where.
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.
Yeah that's some magic alright.
Hello @zadjii-msft! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
I had these out of order, and apparently forgot to launch the Terminal before pushing that commit. This resulted in getting the following with the default settings:  So yea obviously, we should deserialize first, then check if the setting is valid. * [x] regressed in #11859 * [x] actually tested this time * [x] Closes #11896 * [x] Closes #11895
This adds x-macros for each of the actions, greatly reducing the amount of boilerplate needed for each action args.
Originally, I wanted to do more with this, but I think the x-macros we've discovered properly treads the line of ease-of-use and native c++ support, with how much it'll do for us
ShortcutAction
code from ~JSON Schema~ X-Macros #3475