Skip to content

#99 Rename get_source_includes hook to get_class_cpp_source_includes - #109

Merged
kwabenantim merged 1 commit into
developfrom
get-class-cpp-source-includes
Jul 27, 2026
Merged

#99 Rename get_source_includes hook to get_class_cpp_source_includes#109
kwabenantim merged 1 commit into
developfrom
get-class-cpp-source-includes

Conversation

@kwabenantim

Copy link
Copy Markdown
Member

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..

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>
@kwabenantim
kwabenantim requested a review from Copilot July 27, 2026 22:31
@kwabenantim
kwabenantim marked this pull request as ready for review July 27, 2026 22:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Custom base 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

  • Custom now defines only get_class_cpp_source_includes(). Generators that subclass Custom but still override the older get_source_includes() hook will no longer have their includes picked up (since the base implementation returns []). Consider keeping a deprecated get_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.

Comment thread cppwg/writers/class_writer.py
Comment thread tests/test_class_writer.py
@kwabenantim
kwabenantim merged commit c10e2eb into develop Jul 27, 2026
16 checks passed
@kwabenantim
kwabenantim deleted the get-class-cpp-source-includes branch July 27, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants