reaktivity / nukleus-maven-plugin

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

Enhance variant to support skipping the kind #81

Closed jfallows closed 4 years ago

jfallows commented 5 years ago

By default, variant does not skip the kind, see #78.

For example:

variant UnsignedNumber
{
    case 0x18:
    case 0x11:
        UnsignedLong;
    case 0x04:
    case 0x01:
    case 0x00:
        UnsignedInteger;
}

variant UnsignedLong of uint64
{
    case 0x18: uint64;
    case 0x11: uint8;
}

variant UnsignedInteger of uint32
{
    case 0x04: uint32;
    case 0x01: uint8;
    case 0x00: 0;
}

Add support to skip the case kind when needed by adding + to the kind type.

variant Descriptor switch (uint8+) as uint64 { case 0x00: UnsignedLong; }

The generated code for Descriptor above is almost identical to that without the + except that the uint8 byte used for the case is skipped during flyweight read, and filled in implicitly during flyweight builder write.

jfallows commented 4 years ago

Fixed by #109