reaktivity / nukleus-maven-plugin

Nukleus Maven Plugin
Apache License 2.0
0 stars 10 forks source link

Support variant of primitive numeric type #78

Closed jfallows closed 5 years ago

jfallows commented 5 years ago

Support unambiguous variable length integer mappings where builder automatically selects narrowest width case based on value of primitive.

Builder should also support explicitly specifying a wider type.

variant UnsignedInt switch (uint8) of uint32
{
   case 0x04: uint32;
   case 0x01: uint8;
   case 0x00: 0;
}

In each case, the uint8 case value prefixes the actual value, except for case 0 where the 0 literal is implied by the case prefix without also needing to explicitly encode the 0 value.

Therefore the following byte sequences could all represent a primitive value of zero for UnsignedInt.

0x04 0x00 0x00 0x00 0x00
0x01 0x00
0x00