refactor: registering actions/categories in action.cpp #2672
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.
Summary
SUMMARY: Infrastructure "Refactor registering actions/categories in action.cpp"
Purpose of change
i was bored and the code looked bad.
Describe the solution
replaced
REGISTER_ACTION
andREGISTER_CATEGORY
macro withmake_register_actions
andmake_register_categories
.they are curried functions which capture state then return another function which you can conveniently name
register_actions
andregister_categories
. pass it a set and you're good to go. also, it should be fairly performant because it's rvalue refed and uses std::transform under the hood.Describe alternatives you've considered
put registering action and action for it in same function, because current system is very bug prone
Testing
idk i guess it'd pass tests?
Additional context