class SwitchTest(cst.TContainerMixin): @dataclasses.dataclass class Case1(cst.TContainerMixin): case1_1: int = cst.sfield(cs.Int16sb) case1_2: int = cst.sfield(cs.Int16sb) @dataclasses.dataclass class Case2(cst.TContainerMixin): case2_1: int = cst.sfield(cs.Int8sb) case2_2: int = cst.sfield(cs.Int8sb) case2_3: int = cst.sfield(cs.Int8sb) case2_4: int = cst.sfield(cs.Int8sb) @dataclasses.dataclass class CaseDefault(cst.TContainerMixin): case_default_1: int = cst.sfield(cs.Int32sb) choice: int = cst.sfield(cs.Int8ub) switch: t.Union[Case1, Case2, CaseDefault] = cst.sfield( cs.Switch( cs.this.choice, { 1: cst.TStruct(Case1), 2: cst.TStruct(Case2), }, cst.TStruct(CaseDefault), ))
class TStructTest(cst.TContainerMixin): type_int: int = cst.sfield(cs.Computed(lambda ctx: 50)) type_float: float = cst.sfield(cs.Computed(lambda ctx: 80.0)) type_bool: bool = cst.sfield(cs.Computed(lambda ctx: True)) type_bytes: bytes = cst.sfield( cs.Computed(lambda ctx: bytes([0x00, 0xAB]))) type_bytearray: bytearray = cst.sfield( cs.Computed(lambda ctx: bytearray([0x00, 0xAB, 0xFF])))
class TStructTest(cst.TContainerMixin): @dataclasses.dataclass class Entry(cst.TContainerMixin): id: int = cst.sfield(cs.Int8sb) width: int = cst.sfield(cs.Int8sb) height: int = cst.sfield(cs.Int8sb) entries: t.List[Entry] = cst.sfield(cs.GreedyRange(cst.TStruct(Entry))) cnt: int = cst.sfield(cs.Computed(lambda ctx: len(ctx.entries)))
class Timestamps(cst.TContainerMixin): time_int8: arrow.Arrow = cst.sfield( cs.Timestamp(cs.Int8ul, unit=1, epoch=arrow.Arrow(2020, 1, 1)) ) time_int16: arrow.Arrow = cst.sfield( cs.Timestamp(cs.Int16ul, unit=1, epoch=arrow.Arrow(2019, 1, 1)) ) time_int32: arrow.Arrow = cst.sfield( cs.Timestamp(cs.Int32ul, unit=1, epoch=arrow.Arrow(2080, 1, 1)) )
class TBitsStructTest(cst.TContainerMixin): @dataclasses.dataclass class Nested(cst.TContainerMixin): test_bit: int = cst.sfield(cs.Bit) test_nibble: int = cst.sfield(cs.Nibble) test_bits_1: int = cst.sfield(cs.BitsInteger(3)) test_bits_2: int = cst.sfield(cs.BitsInteger(6)) test_bits_3: int = cst.sfield(cs.BitsInteger(2)) nested: Nested = cst.sfield(cs.ByteSwapped(cst.TBitStruct(Nested))) nested_reverse: Nested = cst.sfield(cst.TBitStruct(Nested, reverse=True))
class JBSQ(ct.TContainerMixin): magic: Optional[bytes] = ct.sfield( c.Select(c.Const(b"IJBQ"), c.Const(b"IJSQ"), c.Const(b"JBSQ"))) num_events: int = ct.sfield(c.Int32ul) combo: int = ct.sfield(c.Int32ul) end_time: int = ct.sfield(c.Int32ul) _1: None = ct.sfield(c.Padding(2)) starting_buttons: int = ct.sfield(c.Int16ul) start_time: int = ct.sfield(c.Int32ul) _2: None = ct.sfield(c.Padding(12)) density_graph: List[int] = ct.sfield(c.Byte[60]) events: List[Event] = ct.sfield( c.Array(c.this.num_events, ct.TStruct(Event)))
class TStructTest(cst.TContainerMixin): width: int = cst.sfield(cs.Int8sb, doc="Das hier ist die Dokumentation von 'width'") height: int = cst.sfield(cs.Int8sb, doc="Und hier von 'height") @dataclasses.dataclass class Nested(cst.TContainerMixin): nested_width: int = cst.sfield(cs.Int16sb) nested_height: int = cst.sfield(cs.Int16sb) nested_bytes: bytes = cst.sfield(cs.Bytes(2)) nested_array: t.List[int] = cst.sfield(cs.Array(2, cs.Int8sb)) nested: Nested = cst.sfield((cst.TStruct(Nested)))
class RenamedTest(cst.TContainerMixin): height: int = cst.sfield(cs.Int8sb, doc="Und hier von 'height") doc: int = cst.sfield(cs.Int8sb, doc="Das hier ist die Dokumentation von 'width'") doc_multiline: int = cst.sfield( cs.Int8sb, doc=""" Das hier ist die Dokumentation von 'width' """, ) doc2: int = cst.sfield(cs.Int8sb * "Das hier ist die Dokumentation von 'width'") doc2_multiline: int = cst.sfield( cs.Int8sb * """ Das hier ist die Dokumentation von 'width' """ )
class IfThenElse(cst.TContainerMixin): @dataclasses.dataclass class Then(cst.TContainerMixin): then_1: int = cst.sfield(cs.Int16sb) then_2: int = cst.sfield(cs.Int16sb) @dataclasses.dataclass class Else(cst.TContainerMixin): else_1: int = cst.sfield(cs.Int8sb) else_2: int = cst.sfield(cs.Int8sb) else_3: int = cst.sfield(cs.Int8sb) else_4: int = cst.sfield(cs.Int8sb) choice: int = cst.sfield(cs.Int8ub) if_then_else: t.Union[Then, Else] = cst.sfield( cs.IfThenElse(cs.this.choice == 0, cst.TStruct(Then), cst.TStruct(Else)))
class Nested(cst.TContainerMixin): nested_width: int = cst.sfield(cs.Int16sb) nested_height: int = cst.sfield(cs.Int16sb) nested_bytes: bytes = cst.sfield(cs.Bytes(2)) nested_array: t.List[int] = cst.sfield(cs.Array(2, cs.Int8sb))
class CaseDefault(cst.TContainerMixin): case_default_1: int = cst.sfield(cs.Int32sb)
class Entry(cst.TContainerMixin): id: int = cst.sfield(cs.Int8sb) width: int = cst.sfield(cs.Int8sb) height: int = cst.sfield(cs.Int8sb)
class Else(cst.TContainerMixin): else_1: int = cst.sfield(cs.Int8sb) else_2: int = cst.sfield(cs.Int8sb) else_3: int = cst.sfield(cs.Int8sb) else_4: int = cst.sfield(cs.Int8sb)
class Then(cst.TContainerMixin): then_1: int = cst.sfield(cs.Int16sb) then_2: int = cst.sfield(cs.Int16sb)
class Case2(cst.TContainerMixin): case2_1: int = cst.sfield(cs.Int8sb) case2_2: int = cst.sfield(cs.Int8sb) case2_3: int = cst.sfield(cs.Int8sb) case2_4: int = cst.sfield(cs.Int8sb)
class Car(cst.TContainerMixin): brand: CarBrand = cst.sfield(cst.TEnum(cs.Int8ul, CarBrand)) wheels: int = cst.sfield(cs.Int8ul) color: CarColor = cst.sfield(cst.TEnum(cs.Int8ul, CarColor))
class Nested(cst.TContainerMixin): test_bit: int = cst.sfield(cs.Bit) test_nibble: int = cst.sfield(cs.Nibble) test_bits_1: int = cst.sfield(cs.BitsInteger(3)) test_bits_2: int = cst.sfield(cs.BitsInteger(6)) test_bits_3: int = cst.sfield(cs.BitsInteger(2))
class Event(ct.TContainerMixin): type_: EventType = ct.sfield(ct.TEnum(c.Byte, EventType)) time_in_ticks: int = ct.sfield(c.Int24ul) value: int = ct.sfield(c.Int32ul)
class TStructTest(cst.TContainerMixin): static: t.List[int] = cst.sfield(cs.Array(5, cs.Int8sb)) dynamic_len: int = cst.sfield(cs.Int8sb, doc="Die Länge des dynamischen Array'") dynamic: t.List[int] = cst.sfield(cs.Array(cs.this.dynamic_len, cs.Int8sb))
class Case1(cst.TContainerMixin): case1_1: int = cst.sfield(cs.Int16sb) case1_2: int = cst.sfield(cs.Int16sb)