Beispiel #1
0
 class Thing(dictobj.PacketSpec):
     fields = [
         ("one", T.Uint8.enum(E).multiple(3).default(E.ZERO)),
         ("two", T.Int32.multiple(3).default(0)),
         ("three", T.String(32).multiple(3).default(lambda pkt: "")),
         ("four", T.Bytes(40).multiple(3, kls=Other)),
     ]
Beispiel #2
0
 class Thing(dictobj.PacketSpec):
     fields = [
         ("one", T.Uint8.enum(E).multiple(4).default(E.ZERO)),
         ("two", T.Int32.multiple(3).default(0)),
         ("three", T.String(32).multiple(3)),
         ("four", T.Bytes(8).multiple(1, kls=Other)),
         ("five", T.Uint8.enum(E, allow_unknown=False).multiple(3).default(E.ZERO)),
     ]
Beispiel #3
0
class M(Messages):
    # fmt:off
    One = msg(78, ("one", T.String(16)))

    Two = msg(99)

    Three = msg(
        98,
        ("three", T.Int8.transform(lambda _, v: v + 5, lambda _, v: v - 5)))
Beispiel #4
0
        class V:
            other_typ = T.Int16.transform(lambda _, v: v + 5, lambda _, v: v - 5)

            two_typ = T.String(20 * 8).allow_callable()

            thing_typ = T.Reserved(lambda p: p.other * 8)

            @hp.memoized_property
            def G1(s):
                class G1(dictobj.PacketSpec):
                    fields = [("other", s.other_typ), ("thing", s.thing_typ)]

                return G1

            @hp.memoized_property
            def P(s):
                class P(dictobj.PacketSpec):
                    fields = [("one", T.Bool), ("two", s.two_typ), ("g1", s.G1)]

                return P
Beispiel #5
0
        class M(Messages):
            P = msg(1)

            P2 = msg(2, ("thing", T.String(32 * 8)))
 class P(dictobj.PacketSpec):
     fields = [("g", T.String(32))]
Beispiel #7
0
 class Chooser(dictobj.PacketSpec):
     fields = [
         ("choice", T.String(64)),
         ("amount", T.Uint8),
         ("val", T.Bytes(32).multiple(lambda pkt: pkt.amount, kls=choose_kls)),
     ]
Beispiel #8
0
 class Two(dictobj.PacketSpec):
     fields = [("two", T.String(32))]
Beispiel #9
0
 class Other(dictobj.PacketSpec):
     fields = [("other", T.BoolInt), ("another", T.String(64).default(""))]