Skip to content

Generate xyz/detail/operator_thunks.hh with Python - #525

Draft
jbcoe wants to merge 2 commits into
mainfrom
push-lqumxpypzpqm
Draft

jbcoe wants to merge 2 commits into
mainfrom
push-lqumxpypzpqm

Conversation

@jbcoe

@jbcoe jbcoe commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Replace the 2k+-line xyz/detail/operator_thunks.hh with a generated version.

We cannot use reflection to generate the thunks and prefer a custom build step to a macro (barely).

@jbcoe
jbcoe marked this pull request as draft November 27, 2026 11:47
@codecov

codecov Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.05%. Comparing base (8cdc487) to head (55aaaab).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #525      +/-   ##
==========================================
- Coverage   95.90%   93.05%   -2.85%     
==========================================
  Files          11       10       -1     
  Lines         927      547     -380     
  Branches       30       30              
==========================================
- Hits          889      509     -380     
  Misses         28       28              
  Partials       10       10              
Flag Coverage Δ
consteval 89.65% <ø> (ø)
runtime 96.15% <ø> (-2.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jbcoe
jbcoe force-pushed the push-lqumxpypzpqm branch 4 times, most recently from 7986d94 to 9f9acd0 Compare November 27, 2026 18:43
Replace the 2,269-line hand-maintained xyz/detail/operator_thunks.hh with
scripts/generate_operator_thunks.py (--output <path>), generating all 38
overloadable member operator thunks and overload sets at build time:

- Bazel: add rules_python (Python 3.13 toolchain), py_binary, and genrule
  producing xyz/detail/operator_thunks.hh.
- CMake: find Python3::Interpreter, generate operator_thunks.hh into
  <build>/generated/xyz/detail/operator_thunks.hh via a separate
  generated_headers FILE_SET, and install it with the protocol target.
- Consteval coverage: emit operator_thunks.hh into the probe work directory
  (uninstrumented, as it has no consteval code) so test translation units
  including xyz/protocol.hh compile.
- CI: add scripts/generate_operator_thunks.py to the path filters for
  Bazel, CMake, sanitizers, clang-tidy, and coverage workflows.


Read generated headers from CMake build tree in consteval_coverage.py

Fix multi-line docstring formatting in scripts/generate_operator_thunks.py
@jbcoe
jbcoe force-pushed the push-lqumxpypzpqm branch from 9f9acd0 to 2d83caa Compare November 27, 2026 18:45
@jbcoe
jbcoe marked this pull request as ready for review November 27, 2026 18:45
Comment thread CMakeLists.txt
find_package(ClangTidy)
find_package(Python3 REQUIRED COMPONENTS Interpreter)

set(XYZ_PROTOCOL_GENERATED_INCLUDE_DIRECTORY

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The operator thunks are no longer measured: the generated header lands in the build tree, outside the repository, so Codecov drops it. A thunk that loses its test, including the ref-qualified ones the #524 follow-ups will add through this generator, will no longer show as uncovered. Checking in the generated header, with a CI step that regenerates it and fails on any diff, would keep the measurement and keep the thunks searchable and reviewable. It would also spare CMake users a Python dependency. Your call whether that is worth it.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This feels like a simpler and cleaner approach. I’ll amend the PR.

Comment thread CMakeLists.txt
include(xyz_add_object_library)

find_package(ClangTidy)
find_package(Python3 REQUIRED COMPONENTS Interpreter)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The generator needs Python 3.9 or later (tuple[...] in a module-level annotation), but this accepts any Python 3, so an older one fails at build time with a traceback. find_package(Python3 3.9 REQUIRED COMPONENTS Interpreter) makes it a configure error instead.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Agreed. Re-work suggested above will render this moot.

@jbcoe
jbcoe marked this pull request as draft November 28, 2026 18:07
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