• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# automatically generated by the FlatBuffers compiler, do not modify
2
3# namespace: Example
4
5import flatbuffers
6from flatbuffers.compat import import_numpy
7np = import_numpy()
8
9class StructOfStructsOfStructs(object):
10    __slots__ = ['_tab']
11
12    @classmethod
13    def SizeOf(cls):
14        return 20
15
16    # StructOfStructsOfStructs
17    def Init(self, buf, pos):
18        self._tab = flatbuffers.table.Table(buf, pos)
19
20    # StructOfStructsOfStructs
21    def A(self, obj):
22        obj.Init(self._tab.Bytes, self._tab.Pos + 0)
23        return obj
24
25
26def CreateStructOfStructsOfStructs(builder, a_a_id, a_a_distance, a_b_a, a_b_b, a_c_id, a_c_distance):
27    builder.Prep(4, 20)
28    builder.Prep(4, 20)
29    builder.Prep(4, 8)
30    builder.PrependUint32(a_c_distance)
31    builder.PrependUint32(a_c_id)
32    builder.Prep(2, 4)
33    builder.Pad(1)
34    builder.PrependInt8(a_b_b)
35    builder.PrependInt16(a_b_a)
36    builder.Prep(4, 8)
37    builder.PrependUint32(a_a_distance)
38    builder.PrependUint32(a_a_id)
39    return builder.Offset()
40
41import MyGame.Example.StructOfStructs
42try:
43    from typing import Optional
44except:
45    pass
46
47class StructOfStructsOfStructsT(object):
48
49    # StructOfStructsOfStructsT
50    def __init__(self):
51        self.a = None  # type: Optional[MyGame.Example.StructOfStructs.StructOfStructsT]
52
53    @classmethod
54    def InitFromBuf(cls, buf, pos):
55        structOfStructsOfStructs = StructOfStructsOfStructs()
56        structOfStructsOfStructs.Init(buf, pos)
57        return cls.InitFromObj(structOfStructsOfStructs)
58
59    @classmethod
60    def InitFromPackedBuf(cls, buf, pos=0):
61        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
62        return cls.InitFromBuf(buf, pos+n)
63
64    @classmethod
65    def InitFromObj(cls, structOfStructsOfStructs):
66        x = StructOfStructsOfStructsT()
67        x._UnPack(structOfStructsOfStructs)
68        return x
69
70    # StructOfStructsOfStructsT
71    def _UnPack(self, structOfStructsOfStructs):
72        if structOfStructsOfStructs is None:
73            return
74        if structOfStructsOfStructs.A(MyGame.Example.StructOfStructs.StructOfStructs()) is not None:
75            self.a = MyGame.Example.StructOfStructs.StructOfStructsT.InitFromObj(structOfStructsOfStructs.A(MyGame.Example.StructOfStructs.StructOfStructs()))
76
77    # StructOfStructsOfStructsT
78    def Pack(self, builder):
79        return CreateStructOfStructsOfStructs(builder, self.a.a.id, self.a.a.distance, self.a.b.a, self.a.b.b, self.a.c.id, self.a.c.distance)
80