Refactor protocol generators to use composition#57
Merged
Conversation
…minate direct_control_block indirection
2422991 to
f0342d1
Compare
There was a problem hiding this comment.
Pull request overview
Refactors the generated protocol/view glue code to use composition between const/non-const views (and vtables), enabling cleaner reuse and supporting implicit conversion from mutable protocol_view<T> to protocol_view<const T>.
Changes:
- Split protocol concepts into
protocol_const_concept_*+protocol_concept_*(const requirements composed into the non-const concept). - Rework
protocol_viewgeneration to compose const/non-const callbacks/vtables and add mutable→const view conversion. - Add tests covering const view construction from a mutable view (both concrete and protocol-backed cases).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
scripts/protocol.j2 |
Refactors generated view callback types and protocol_view to compose const/non-const behavior and add mutable→const conversions. |
scripts/protocol_manual_vtable.j2 |
Refactors manual-vtable generator to use a composed const/non-const vtable layout and updated view construction. |
protocol_test.cc |
Adds unit tests for constructing a const view from a mutable view. |
.github/workflows/cmake.yml |
Ensures CI triggers on changes to Jinja2 (.j2) generator templates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
philipcraig
approved these changes
Apr 4, 2026
Twon
approved these changes
Apr 5, 2026
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.
Avoid multiple levels of indirection when a
protocol_viewis constructed from aprotocol.