class DirectoryEntry(pyndata.Struct): # this is not a real on-disk struct __ENDIAN__ = 'little' name = pyndata.nullstring(max_length=256) value = pyndata.uint64() value.__SHOW__ = False object_type = pyndata.BitField(value, 4, 60, enum=PosixType) number = pyndata.BitField(value, 48)
class BitFieldTests(pyndata.Struct): real = pyndata.uint16() bit1 = pyndata.BitField(real, 4, shift=0) bit2 = pyndata.BitField(real, 1, shift=4) bit3 = pyndata.BitField(real, 3, shift=5) bit4 = pyndata.BitField(real, 8, shift=8)
class BitField2Tests(pyndata.Struct): real = pyndata.uint16() bit1 = pyndata.BitField(real, 4) bit2 = pyndata.BitField(real, 1) bit3 = pyndata.BitField(real, 3) bit4 = pyndata.BitField(real, 8)
class ArrayWithBitfieldLength(pyndata.Struct): a = pyndata.uint8() b = pyndata.BitField(a, 8, 0) c = pyndata.array(pyndata.uint8(), length=b)
class Mode(pyndata.Struct): __ENDIAN__ = 'little' mode = pyndata.uint64() perms = pyndata.BitField(mode, 10) unknown = pyndata.BitField(mode, 2) file_type = pyndata.BitField(mode, 4, enum=PosixType)
class S(pyndata.Struct): _a = pyndata.uint8() b = pyndata.uint8() c = pyndata.BitField(b, 1) _d = pyndata.BitField(b, 1)