Macro gba_proc_macro::multi_bits
source · multi_bits!() { /* proc-macro */ }
Expand description
Generates one or more virtual multi-bit fields within a type.
You must use this within an impl
block for a tuple struct that has an
integral type as the 0th field.
- Each virtual field has a base position and width.
- Each virtual field is either of the 0th field integral type OR a specified enum type which must have a repr that matches the 0th field type.
Specify the type of the 0th tuple field, a comma, and then a Group. The Group must contain a comma separated list of Group values that each specify one field.
The specification is one of:
(base, width, name)
(base, width, name, EnumType, EnumTag1, EnumTagN...)
With the Enum version, you must provide the tags in the order they should be used. Even a proc-macro doesn’t have the reflection required
Such as the following example:
impl Demo {
multi_bits!(
u16,
[
(0, 2, priority),
(2, 2, cbb),
(8, 5, sbb),
(14, 2, size, SizeEnum, Small, Medium, Large),
]
);
}