...
1# automatically generated by the FlatBuffers compiler, do not modify
2
3# namespace: NestedUnion
4
5import flatbuffers
6from flatbuffers.compat import import_numpy
7from typing import Any
8np = import_numpy()
9
10class Test(object):
11 __slots__ = ['_tab']
12
13 @classmethod
14 def SizeOf(cls) -> int:
15 return 4
16
17 # Test
18 def Init(self, buf: bytes, pos: int):
19 self._tab = flatbuffers.table.Table(buf, pos)
20
21 # Test
22 def A(self): return self._tab.Get(flatbuffers.number_types.Int16Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(0))
23 # Test
24 def B(self): return self._tab.Get(flatbuffers.number_types.Int8Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(2))
25
26def CreateTest(builder, a, b):
27 builder.Prep(2, 4)
28 builder.Pad(1)
29 builder.PrependInt8(b)
30 builder.PrependInt16(a)
31 return builder.Offset()
32
33
34class TestT(object):
35
36 # TestT
37 def __init__(self):
38 self.a = 0 # type: int
39 self.b = 0 # type: int
40
41 @classmethod
42 def InitFromBuf(cls, buf, pos):
43 test = Test()
44 test.Init(buf, pos)
45 return cls.InitFromObj(test)
46
47 @classmethod
48 def InitFromPackedBuf(cls, buf, pos=0):
49 n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
50 return cls.InitFromBuf(buf, pos+n)
51
52 @classmethod
53 def InitFromObj(cls, test):
54 x = TestT()
55 x._UnPack(test)
56 return x
57
58 # TestT
59 def _UnPack(self, test):
60 if test is None:
61 return
62 self.a = test.A()
63 self.b = test.B()
64
65 # TestT
66 def Pack(self, builder):
67 return CreateTest(builder, self.a, self.b)
View as plain text