blob: 9e58cc4b5510d284ff048a1282bc1c312ea69cbb [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 TestSimpleTableWithEnum(object):
10 __slots__ = ['_tab']
11
12 @classmethod
James Kuszmaul8e62b022022-03-22 09:33:25 -070013 def GetRootAs(cls, buf, offset=0):
Austin Schuhe89fa2d2019-08-14 20:24:23 -070014 n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
15 x = TestSimpleTableWithEnum()
16 x.Init(buf, n + offset)
17 return x
18
19 @classmethod
James Kuszmaul8e62b022022-03-22 09:33:25 -070020 def GetRootAsTestSimpleTableWithEnum(cls, buf, offset=0):
21 """This method is deprecated. Please switch to GetRootAs."""
22 return cls.GetRootAs(buf, offset)
23 @classmethod
Austin Schuhe89fa2d2019-08-14 20:24:23 -070024 def TestSimpleTableWithEnumBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
25 return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x4F\x4E\x53", size_prefixed=size_prefixed)
26
27 # TestSimpleTableWithEnum
28 def Init(self, buf, pos):
29 self._tab = flatbuffers.table.Table(buf, pos)
30
31 # TestSimpleTableWithEnum
32 def Color(self):
33 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
34 if o != 0:
35 return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
36 return 2
37
38def TestSimpleTableWithEnumStart(builder): builder.StartObject(1)
James Kuszmaul8e62b022022-03-22 09:33:25 -070039def Start(builder):
40 return TestSimpleTableWithEnumStart(builder)
Austin Schuhe89fa2d2019-08-14 20:24:23 -070041def TestSimpleTableWithEnumAddColor(builder, color): builder.PrependUint8Slot(0, color, 2)
James Kuszmaul8e62b022022-03-22 09:33:25 -070042def AddColor(builder, color):
43 return TestSimpleTableWithEnumAddColor(builder, color)
Austin Schuhe89fa2d2019-08-14 20:24:23 -070044def TestSimpleTableWithEnumEnd(builder): return builder.EndObject()
James Kuszmaul8e62b022022-03-22 09:33:25 -070045def End(builder):
46 return TestSimpleTableWithEnumEnd(builder)
Austin Schuh272c6132020-11-14 16:37:52 -080047
48class TestSimpleTableWithEnumT(object):
49
50 # TestSimpleTableWithEnumT
51 def __init__(self):
52 self.color = 2 # type: int
53
54 @classmethod
55 def InitFromBuf(cls, buf, pos):
56 testSimpleTableWithEnum = TestSimpleTableWithEnum()
57 testSimpleTableWithEnum.Init(buf, pos)
58 return cls.InitFromObj(testSimpleTableWithEnum)
59
60 @classmethod
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080061 def InitFromPackedBuf(cls, buf, pos=0):
62 n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
63 return cls.InitFromBuf(buf, pos+n)
64
65 @classmethod
Austin Schuh272c6132020-11-14 16:37:52 -080066 def InitFromObj(cls, testSimpleTableWithEnum):
67 x = TestSimpleTableWithEnumT()
68 x._UnPack(testSimpleTableWithEnum)
69 return x
70
71 # TestSimpleTableWithEnumT
72 def _UnPack(self, testSimpleTableWithEnum):
73 if testSimpleTableWithEnum is None:
74 return
75 self.color = testSimpleTableWithEnum.Color()
76
77 # TestSimpleTableWithEnumT
78 def Pack(self, builder):
79 TestSimpleTableWithEnumStart(builder)
80 TestSimpleTableWithEnumAddColor(builder, self.color)
81 testSimpleTableWithEnum = TestSimpleTableWithEnumEnd(builder)
82 return testSimpleTableWithEnum