#99 Rename get_source_includes hook to get_class_cpp_source_includes - #109
Merged
Conversation
Align the custom-generator include hook with its siblings (get_class_cpp_pre_code, get_class_cpp_def_code): it is class-scoped and targets the .cppwg.cpp include block, so the name now carries both the class scope and cpp file tokens. No backwards-compatible alias, as the hook is unreleased. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR renames the custom-generator hook used to contribute per-class .cpp wrapper includes from get_source_includes to get_class_cpp_source_includes, aligning it with the other class-scoped hooks (get_class_cpp_pre_code, get_class_cpp_def_code).
Changes:
- Renames the include hook in the
Custombase class and in the class writer call site. - Updates unit tests to use the new hook name.
- Updates custom-generator documentation to reflect the new hook name.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tests/test_utils.py |
Updates hook name used in call_generator_hook test. |
tests/test_class_writer.py |
Renames hook implementations and test docstrings to the new hook name. |
doc/custom-generators.md |
Documents the new hook name and updates example code. |
cppwg/writers/class_writer.py |
Calls the new hook when emitting generator-provided includes. |
cppwg/templates/custom.py |
Renames the base hook method in the Custom template class. |
Comments suppressed due to low confidence (1)
cppwg/templates/custom.py:32
Customnow defines onlyget_class_cpp_source_includes(). Generators that subclassCustombut still override the olderget_source_includes()hook will no longer have their includes picked up (since the base implementation returns[]). Consider keeping a deprecatedget_source_includes()method and having the new hook delegate to it by default, so older subclasses keep working.
def get_class_cpp_source_includes(self, *args, **kwargs) -> list:
"""
Return headers to add to the #include block of the class wrapper.
Use this for headers the generated code needs but that cppwg cannot
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Follow up to #99.
Align the custom-generator include hook with its siblings (get_class_cpp_pre_code, get_class_cpp_def_code): it is class-scoped and targets the .cppwg.cpp include block, so the name now carries both the class scope and cpp file tokens..