Skip to content

Refactor protocol generators to use composition#57

Merged
jbcoe merged 1 commit intomainfrom
jbcoe/view-from-protocol
Apr 5, 2026
Merged

Refactor protocol generators to use composition#57
jbcoe merged 1 commit intomainfrom
jbcoe/view-from-protocol

Conversation

@jbcoe
Copy link
Copy Markdown
Owner

@jbcoe jbcoe commented Apr 4, 2026

Avoid multiple levels of indirection when a protocol_view is constructed from a protocol.

@jbcoe jbcoe force-pushed the jbcoe/view-from-protocol branch from 2422991 to f0342d1 Compare April 4, 2026 21:58
@jbcoe jbcoe requested a review from Copilot April 4, 2026 21:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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

@jbcoe jbcoe marked this pull request as ready for review April 4, 2026 22:12
@jbcoe jbcoe requested a review from Twon April 4, 2026 22:12
@jbcoe jbcoe merged commit a95ff24 into main Apr 5, 2026
42 checks passed
@jbcoe jbcoe deleted the jbcoe/view-from-protocol branch April 5, 2026 10:22
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.

4 participants