Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit a4a73d75 authored by Martin Geisler's avatar Martin Geisler
Browse files

pdl: Add support for scalar and enum arrays

This implements support for integer and enum arrays with static and
dynamic sizes.

The parse function on the data structs changed its argument from
‘&[u8]’ to ‘Cell<&[u8]>’. This allows us to pass around a single slice
which we mutate in-place. The ‘Cell’ type is a no-overhead type which
cannot panic, so this simply allows us to mutate the slice in-place.

The in-place mutations allow us to eat away the slice as we parse. The
alternative would be to make all parse functions return two values:
the parsed result and the remaining slice. That would in turn
complicate the logic where we collect results.

Another alternative would be to make the parsing stateful by storing
the slice in a struct (and that’s actually what ‘Cell<&[u8]>’ does).

Test: atest pdl_tests pdl_rust_generator_tests_{le,be}
Change-Id: Idc13ab75c5d6c4704f7edb70306be761ee815cab
parent 66d44917
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment