Conversation
Signed-off-by: Yogev Neumann <xqgex@users.noreply.github.com>
Python CI ReportCommit: Python TestsTest Output✅ All tests passed Coverage: 98%Per-file coverage (52 modules)
Details (3362 statements, 61 missed)
Python Static Analysis
mypypylintflake8ruffcodespell |
CI ReportCommit: Static Analysis
cppcheckClick to expandclang-tidyClick to expandSanitizersValgrind |
There was a problem hiding this comment.
Pull request overview
This pull request adds CHOICE type code generation to the J2735 High-Performance Toolkit, extending the existing SEQUENCE-only code generator to support both composite type classes. The implementation follows the established zero-copy "Lens Architecture" pattern and includes comprehensive test coverage.
Changes:
- Adds CHOICE type generation pipeline with single I/O pattern (reads max wire bits unconditionally for O(1) performance)
- Renames generic names for type-class disambiguation:
WireVariant→SequenceWireVariant, template context variablevariants→sequence_variants - Adds wire format documentation templates for CHOICE alternatives (box-drawing tables mirroring SEQUENCE conventions)
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
tools/j2735_c_generator_wire_format.py |
Adds ChoiceWireVariant dataclass and get_choice_variants() for wire format documentation; renames WireVariant to SequenceWireVariant |
tools/j2735_c_generator_data_frame.py |
Adds _generate_choice() with type resolution, shift calculation, and single I/O validation; dispatches CHOICE alongside SEQUENCE |
tools/templates/assemble_df_choice.j2 |
Master assembly template for CHOICE headers (includes license, wire format docs, usage pattern, and 7 sub-templates) |
tools/templates/choice/*.j2 |
Seven sub-templates for CHOICE macros: index bits, max wire bits, alternative indices, raw read, which-checker, getters, and size calculation |
tools/templates/wire_format_choice_section.j2 |
Renders per-alternative wire format tables with index and value segments |
tools/templates/wire_format_sequence_section.j2 |
Renamed from wire_format_section.j2; updates context variable reference to sequence_variants |
tools/templates/*.j2 (other) |
Updates template comments and context variable references for SEQUENCE/CHOICE disambiguation |
src/J2735_internal_DF_ApproachOrLane.h |
Generated zero-copy CHOICE header for 2-alternative ApproachOrLane type (approach=4 bits, lane=8 bits) |
tests/J2735_internal_DF_ApproachOrLane_test.c |
Seven C tests covering happy path, boundary values (min/max for both alternatives), and misaligned access |
tests/J2735_internal_DF_ApproachOrLane_test.h |
Test declarations for ApproachOrLane CHOICE type |
tests/J2735_run_tests.c |
Registers ApproachOrLane test suite in test runner |
tools/tests/c_generator/test_choice_type.py |
Sixteen Python tests verifying CHOICE code generation structure, MISRA compliance, and error handling |
tools/tests/c_generator/test_wire_format_*.py |
Updates references from WireVariant to SequenceWireVariant for consistency |
Signed-off-by: Yogev Neumann <xqgex@users.noreply.github.com>
Signed-off-by: Yogev Neumann <xqgex@users.noreply.github.com>
Python CI ReportCommit: Python TestsTest Output✅ All tests passed Coverage: 98%Per-file coverage (52 modules)
Details (3362 statements, 61 missed)
Python Static Analysis
mypypylintflake8ruffcodespell |
CI ReportCommit: Static Analysis
cppcheckClick to expandclang-tidyClick to expandSanitizers (ASan + UBSan)Test Output✅ No issues detected Valgrind Memory CheckTest Output✅ No memory issues detected |
Pull Request
Description
Add CHOICE type code generation and align naming across SEQUENCE/CHOICE pipelines.
CHOICE pipeline:
generate_data_frame()now dispatches CHOICE types alongside SEQUENCE. New_generate_choice()resolves alternative bit-widths from the spec, computes shift amounts, validates the single I/O constraint (≤57 bits), and renders throughassemble_df_choice.j2. Seven sub-templates intools/templates/choice/handle index bits, max wire bits, alternative indices, raw read, which-checker, getters (shift vs mask-only), and size calculation.Wire format: New
ChoiceWireVariantdataclass andget_choice_variants()inj2735_c_generator_wire_format.pysupply domain data for a newwire_format_choice_section.j2template that renders per-alternative box-drawing tables, mirroring the SEQUENCE contract.Naming consistency: Generic names disambiguated now that two type classes share the pipeline:
WireVariant→SequenceWireVariantvariantscontext variable →sequence_variantswire_format_section.j2→wire_format_sequence_section.j2Generated output:
J2735_internal_DF_ApproachOrLane.h— zero-copy CHOICE header for the 2-alternativeApproachOrLanetype (approach=4 bits, lane=8 bits). Single I/O reads 9 bits, then pure-computation macros extract index, value, and wire size.Test coverage: 7 C tests (
J2735_internal_DF_ApproachOrLane_test.c) covering happy path, boundary values, and misaligned access. 16 Python tests (test_choice_type.py) verifying generated code structure, MISRA compliance, and error paths. Existing wire format tests updated for the rename.Housekeeping: Reformatted
from_asn1()call sites intest_sequence_field.py(argument indentation).Related Issue
N/A
Additional Notes
Extensible CHOICE types are not yet supported -
_generate_choice()raisesValueErrorwith a clear message pointing to a future phase.Type of Change
Checklist
make pre-pushand all checks passgit commit -s