pak.bit_field¶
Contains BitField.
- class BitField(**fields)¶
Bases:
objectA collection of data packed into specific bits of an underlying integer.
A definition of a
BitFieldlooks like this:class MyBitField(pak.BitField): boolean_field: 1 integer_field: 2 other_field: 2
MyBitFieldinherits fromBitField, and its annotations specify the bit widths of each of its fields, starting at the least significant bit.Fields which have a bit width of
1will have aboolvalue, corresponding to whether the appropriate bit is set or unset.Fields which have a bit width larger than
1will have anintvalue.If a field is specified to have a bit width of
0, then aTypeErroris raised.- Parameters:
**fields – The names and corresponding values of the fields of the
BitField.- Raises:
TypeError – If there are any superfluous keyword arguments.
- classmethod Type(underlying)¶