Support variable-length structs as array elements#109
Draft
Support variable-length structs as array elements#109
Conversation
- Modified constraint check in constraints.py to allow dynamic-sized array elements when element count is explicit (not automatic) - Added GenericDynamicSizeArrayView C++ template to emboss_array_view.h - Updated header_generator.py to emit GenericDynamicSizeArrayView for arrays with variable-sized elements - Added dynamic_size_array_view_adapter template to generated_code_templates Co-authored-by: AaronWebster <3766083+AaronWebster@users.noreply.github.com>
- Fix potential underflow in ConstructElementAtOffsetHelper by checking offset before computing remaining bytes - Add documentation for required ElementView interface (SizeInBytes, SizeIsKnown, Ok) - Remove unused _get_type_size function from header_generator.py Co-authored-by: AaronWebster <3766083+AaronWebster@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Support variable length structs as array elements
Support variable-length structs as array elements
Dec 6, 2025
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.
Emboss currently rejects arrays with variable-length struct elements, even when the element count is explicitly specified. This prevents defining common packet formats like Bluetooth batch scan results where variable-length records are packed in an array.
Changes
Frontend constraint relaxation (
constraints.py):Bar[n])Bar[]) since element size is needed to compute countNew runtime view (
emboss_array_view.h):GenericDynamicSizeArrayViewthat computes element offsets at runtime by iterating previous elements'SizeInBytes()operator[],ElementCount(),Ok(),Equals()Code generator (
header_generator.py):GenericDynamicSizeArrayViewwhen element size is not compile-time constant_get_type_sizefunctionExample
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
www.googleapis.com/usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 version(dns block)/usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 test //compiler/front_end:constraints_test --test_output=errors(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.