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
Loading
Please register or sign in to comment