Skip to content

Cross-module inheritance#88

Merged
kwabenantim merged 2 commits into
developfrom
57-cross-module-inheritance
Jun 30, 2026
Merged

Cross-module inheritance#88
kwabenantim merged 2 commits into
developfrom
57-cross-module-inheritance

Conversation

@kwabenantim

Copy link
Copy Markdown
Member

Supports #57

@kwabenantim kwabenantim requested a review from Copilot June 30, 2026 07:19
@kwabenantim kwabenantim linked an issue Jun 30, 2026 that may be closed by this pull request

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

Implements support for cross-module inheritance in generated pybind11 bindings by allowing a module to import other extension modules before registering its own classes, enabling externally-wrapped base types to be registered first (per #57 / pybind11 “partitioning code over multiple extension modules” guidance).

Changes:

  • Add imports to module configuration parsing (package_info.yamlModuleInfo) and emit py::module_::import(...) statements at the start of generated modules.
  • Extend class wrapper generation to reference base classes by C++ type when the base is wrapped outside the current module.
  • Add/extend the shapes example and tests to exercise cross-module inheritance (new composites module with Square inheriting Rectangle).

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test_package_info_parser.py Adds unit tests asserting module-level imports parsing and default behavior.
README.md Documents the new imports mechanism for cross-module inheritance.
examples/shapes/wrapper/primitives/_pyshapes_primitives.main.cppwg.cpp Demonstrates generated module-level import for dependency registration.
examples/shapes/wrapper/package_info.yaml Adds imports usage and introduces the new composites module configuration.
examples/shapes/wrapper/composites/Square.cppwg.hpp New generated header for Square registration.
examples/shapes/wrapper/composites/Square.cppwg.cpp New generated wrapper registering Square with an external base (Rectangle).
examples/shapes/wrapper/composites/_pyshapes_composites.main.cppwg.cpp New generated module that imports primitives before registering Square.
examples/shapes/src/py/tests/test_classes.py Adds an integration test verifying cross-module inheritance behavior at runtime.
examples/shapes/src/py/pyshapes/composites/init.py Exposes the composites extension module via Python package init.
examples/shapes/CMakeLists.txt Builds the new composites extension module.
cppwg/writers/module_writer.py Emits configured imports at the start of each generated PYBIND11_MODULE.
cppwg/writers/class_writer.py Adds logic to include external base classes in py::class_ definitions.
cppwg/parsers/package_info_parser.py Adds default imports: [] and parses module imports from YAML.
cppwg/info/module_info.py Adds imports to ModuleInfo and documents intended usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cppwg/writers/class_writer.py Outdated
@kwabenantim kwabenantim merged commit e99544c into develop Jun 30, 2026
13 checks passed
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.

Inheritance across modules

2 participants