Skip to content

Conversation

bigjt-dev
Copy link
Contributor

I wanted direct access to fixed array bytes. I made some changes to the idl generator to create GetBytes functions following the same naming conventions used for vectors of scalar types. There was not a 'Length' field present to bound the existing index accessor so I added that too.

  • Add generic GetBytes for fixed length arrays of scalar types
  • Implement conditional compilation for ENABLE_SPAN_T:
    • ENABLE_SPAN_T: Returns Span<T> using MemoryMarshal.Cast<byte, T>() as needed.
    • Else: Returns ArraySegment<byte>? for raw byte access
  • Added tests reusing arrays_test.fbs definitions
  • Added const int Length field to support existing index based accessors

I wanted to direct access to fixed array bytes. I made some changes to the idl generator to create GetBytes functions following the same naming conventions used for vectors of scalar types. There was not a 'Length' field present to bound the existing index accessor so I added that too.

+ Add generic GetBytes for fixed length arrays of scalar types
+ Implement conditional compilation for ENABLE_SPAN_T:
  - ENABLE_SPAN_T: Returns `Span<T>` using `MemoryMarshal.Cast<byte, T>()` as needed.
  - Else: Returns `ArraySegment<byte>?` for raw byte access
+ Added tests reusing arrays_test.fbs definitions
+ Added const int Length field to support existing index based accessors
@github-actions github-actions bot added c# c++ codegen Involving generating code from schema labels Jul 2, 2025
@bjornharrtell bjornharrtell self-requested a review August 24, 2025 15:10
Copy link
Collaborator

@bjornharrtell bjornharrtell left a comment

Choose a reason for hiding this comment

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

LGTM

@bjornharrtell
Copy link
Collaborator

@bigjt-dev there are failures at CI, looks like scripts/check_generate_code.py is not happy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c# c++ codegen Involving generating code from schema

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants