Open wcampbell0x2a opened 3 years ago
See https://github.com/sharksforarms/deku/issues/223 for some blocking changes.
Normal Enum
I think actually just requiring a #[bintex(bits = "var")]
will be easier. TWe can also have a EnumType
attribute [bintex(enum_type = EnumType::Fixed)]
for declaring that the size of this is fixed
enum EnumType {
Fixed,
Variable,
}
struct Testing {
#[bintex(bits = "4", enum_type = EnumType::Fixed)]
a: DekuTest,
}
#[deku(type = "u8", bits = "4")]
enum DekuTest {
#[deku(id = "0b1001")]
VariantA,
#[deku(id = "0b0110")]
VariantB,
}
Advanced Enum
For these, we can be certain the size of the enum in bits beforehand, since it will vary at runtime. The best we can do is emit a
\skippedwords
for bytefield LaTeX.
struct Testing {
#[bintex(enum_type = EnumType::Variable)]
a: DekuTest,
}
#[deku(type = "u8", bits = "4")]
enum DekuTest {
#[deku(id = "0b1001")]
VariantA(u8),
#[deku(id = "0b0110")]
VariantB,
}
We can worry about emitting the correct bytefield field for the struct for now. The actual latex_output
for the advanced enum will need more thinking.
Normal Enum
This is pretty trivial for normal Enums:
That would just emit the enum table.
Figure DekuTest
Advanced Enum
This will be difficult for advanced enums:
That
latex_output
would emit one enum table, and another bytefield for theVariantA
.Figure DekuTest
Bytefield VariantA