blob: d91947a393c93258b02c264b2780c1299deb546d [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
13 def GetRootAsTestSimpleTableWithEnum(cls, buf, offset):
14 n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
15 x = TestSimpleTableWithEnum()
16 x.Init(buf, n + offset)
17 return x
18
19 @classmethod
20 def TestSimpleTableWithEnumBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
21 return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x4F\x4E\x53", size_prefixed=size_prefixed)
22
23 # TestSimpleTableWithEnum
24 def Init(self, buf, pos):
25 self._tab = flatbuffers.table.Table(buf, pos)
26
27 # TestSimpleTableWithEnum
28 def Color(self):
29 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
30 if o != 0:
31 return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
32 return 2
33
34def TestSimpleTableWithEnumStart(builder): builder.StartObject(1)
35def TestSimpleTableWithEnumAddColor(builder, color): builder.PrependUint8Slot(0, color, 2)
36def TestSimpleTableWithEnumEnd(builder): return builder.EndObject()
Austin Schuh272c6132020-11-14 16:37:52 -080037
38
39class TestSimpleTableWithEnumT(object):
40
41 # TestSimpleTableWithEnumT
42 def __init__(self):
43 self.color = 2 # type: int
44
45 @classmethod
46 def InitFromBuf(cls, buf, pos):
47 testSimpleTableWithEnum = TestSimpleTableWithEnum()
48 testSimpleTableWithEnum.Init(buf, pos)
49 return cls.InitFromObj(testSimpleTableWithEnum)
50
51 @classmethod
52 def InitFromObj(cls, testSimpleTableWithEnum):
53 x = TestSimpleTableWithEnumT()
54 x._UnPack(testSimpleTableWithEnum)
55 return x
56
57 # TestSimpleTableWithEnumT
58 def _UnPack(self, testSimpleTableWithEnum):
59 if testSimpleTableWithEnum is None:
60 return
61 self.color = testSimpleTableWithEnum.Color()
62
63 # TestSimpleTableWithEnumT
64 def Pack(self, builder):
65 TestSimpleTableWithEnumStart(builder)
66 TestSimpleTableWithEnumAddColor(builder, self.color)
67 testSimpleTableWithEnum = TestSimpleTableWithEnumEnd(builder)
68 return testSimpleTableWithEnum