blob: 8357ec209c004c9a081f5166c5fc489cc9acc548 [file] [log] [blame]
Austin Schuhe89fa2d2019-08-14 20:24:23 -07001# automatically generated by the FlatBuffers compiler, do not modify
2
3# namespace: Example
4
5import flatbuffers
Austin Schuh272c6132020-11-14 16:37:52 -08006from flatbuffers.compat import import_numpy
7np = import_numpy()
Austin Schuhe89fa2d2019-08-14 20:24:23 -07008
9class Test(object):
10 __slots__ = ['_tab']
11
Austin Schuh272c6132020-11-14 16:37:52 -080012 @classmethod
13 def SizeOf(cls):
14 return 4
15
Austin Schuhe89fa2d2019-08-14 20:24:23 -070016 # Test
17 def Init(self, buf, pos):
18 self._tab = flatbuffers.table.Table(buf, pos)
19
20 # Test
21 def A(self): return self._tab.Get(flatbuffers.number_types.Int16Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(0))
22 # Test
23 def B(self): return self._tab.Get(flatbuffers.number_types.Int8Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(2))
24
25def CreateTest(builder, a, b):
26 builder.Prep(2, 4)
27 builder.Pad(1)
28 builder.PrependInt8(b)
29 builder.PrependInt16(a)
30 return builder.Offset()
Austin Schuh272c6132020-11-14 16:37:52 -080031
32
33class TestT(object):
34
35 # TestT
36 def __init__(self):
37 self.a = 0 # type: int
38 self.b = 0 # type: int
39
40 @classmethod
41 def InitFromBuf(cls, buf, pos):
42 test = Test()
43 test.Init(buf, pos)
44 return cls.InitFromObj(test)
45
46 @classmethod
47 def InitFromObj(cls, test):
48 x = TestT()
49 x._UnPack(test)
50 return x
51
52 # TestT
53 def _UnPack(self, test):
54 if test is None:
55 return
56 self.a = test.A()
57 self.b = test.B()
58
59 # TestT
60 def Pack(self, builder):
61 return CreateTest(builder, self.a, self.b)