1 byte Endianness flag (default 1)
• 0=big endian, 1=little endian
1 byte Size of int (in bytes) (default 4)
1 byte Size of size_t (in bytes) (default 4)
1 byte Size of Instruction (in bytes) (default 4)
It's the byte order. It means that - if I would try to decode Lua bytecode using Preon - I would have to make some changes to the annotations.
Currently, the annotations for decoding numeric data look like this:
@BoundNumber(byteOrder=LittleEndian)
@BoundNumber(byteOrder=BigEndian)
... but now that byteOrder needs to be defined by something read before. I guess there are a couple of ways to deal with it:
Option 1: Have the ability to change the 'global' default byte order setting as a consequence of reading a value
Now, global doesn't really need to be global. It might be good enough if it would be a default for the current 'lexical scope'. So basically, if you would read a block of data that would indicate a change in the byte order, then Preon could basically respect those changes for anything read within that block.
Option 2: Have the ability to refer to ByteOrder enum values read previously from @BoundNumber annotations
Now this is harder. Not undoable, because this is exactly what you can already do for reading the number of bits for instance:
@BoundNumber(size="header.numberOfBits")
For byte order, it could be similar:
@BoundNumber(byteOrder="header.byteOrder")
However, this would mean that instead of typing byteOrder as an enum value of type ByteOrder, it would be a String. That would be less compile time safe. And it would require an incredible number of complex pointers pointing to that header attribute.
But maybe there is a third option. Add a new ByteOrder enum value called Default, basically indicating that the ByteOrder is defined somewhere else. Currently, the default is LittleEndian. But maybe that default needs to be set as an annotation as well.
Anyway, there is a lot to think about. I will see if I can answer this one today.