blob: 7f18ed24e537bfd00c2a63caff0106c769b60faa [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
61 def InitFromObj(cls, testSimpleTableWithEnum):
62 x = TestSimpleTableWithEnumT()
63 x._UnPack(testSimpleTableWithEnum)
64 return x
65
66 # TestSimpleTableWithEnumT
67 def _UnPack(self, testSimpleTableWithEnum):
68 if testSimpleTableWithEnum is None:
69 return
70 self.color = testSimpleTableWithEnum.Color()
71
72 # TestSimpleTableWithEnumT
73 def Pack(self, builder):
74 TestSimpleTableWithEnumStart(builder)
75 TestSimpleTableWithEnumAddColor(builder, self.color)
76 testSimpleTableWithEnum = TestSimpleTableWithEnumEnd(builder)
77 return testSimpleTableWithEnum