From d037aaa1da589395713e28e4fbc60978e3cd4b34 Mon Sep 17 00:00:00 2001 From: Miki Rozloznik Date: Thu, 3 Mar 2022 12:40:52 +0100 Subject: [PATCH] [#370] Small update of packed arrays of integers in ZserioInvisible.doc --- doc/ZserioInvisibles.md | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/doc/ZserioInvisibles.md b/doc/ZserioInvisibles.md index 441b5ac79..962a04ff9 100644 --- a/doc/ZserioInvisibles.md +++ b/doc/ZserioInvisibles.md @@ -129,18 +129,23 @@ struct PackedArray **classic zserio** ``` -struct DeltaPackedArray +struct PackingDescriptor +{ + bool isPacked; + bit:6 maxBitNumber if isPacked; +}; + +struct DeltaPackedArray(bit:6 maxBitNumber) { - bit:6 maxBitNumber; uint32 element0; int deltas[4]; }; struct PackedArray { - bool isPacked; - DeltaPackedArray packedList if isPacked; - uint32 unpackedList[5] if !isPacked; + PackingDescriptor packingDescriptor; + DeltaPackedArray(packingDescriptor.maxBitNumber) packedList if packingDescriptor.isPacked; + uint32 unpackedList[5] if !packingDescriptor.isPacked; }; ``` @@ -200,6 +205,9 @@ struct PackedArray Both examples from above result in the exact same byte stream. +Packed arrays of choices and unions are encoding in the same way, meaning that all fields corresponded to the +same case are considered as an array. If such array is empty, nothing is encoded in the bit stream. + ### Packed Arrays of Nested Compounds All packed arrays of nested compounds adds at least one hidden `bool` (1 bit) field before each packable field @@ -223,7 +231,7 @@ struct PackableStructure InnerStructure innerStructure; }; -struct ClassicPackedArray +struct PackedArray { packed PackableStructure list[5]; };