...
1# automatically generated by the FlatBuffers compiler, do not modify
2
3# namespace: Example
4
5import flatbuffers
6from flatbuffers.compat import import_numpy
7np = import_numpy()
8
9class TestSimpleTableWithEnum(object):
10 __slots__ = ['_tab']
11
12 @classmethod
13 def GetRootAs(cls, buf, offset=0):
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 GetRootAsTestSimpleTableWithEnum(cls, buf, offset=0):
21 """This method is deprecated. Please switch to GetRootAs."""
22 return cls.GetRootAs(buf, offset)
23 @classmethod
24 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):
39 builder.StartObject(1)
40
41def Start(builder):
42 TestSimpleTableWithEnumStart(builder)
43
44def TestSimpleTableWithEnumAddColor(builder, color):
45 builder.PrependUint8Slot(0, color, 2)
46
47def AddColor(builder, color):
48 TestSimpleTableWithEnumAddColor(builder, color)
49
50def TestSimpleTableWithEnumEnd(builder):
51 return builder.EndObject()
52
53def End(builder):
54 return TestSimpleTableWithEnumEnd(builder)
55
56
57class TestSimpleTableWithEnumT(object):
58
59 # TestSimpleTableWithEnumT
60 def __init__(self):
61 self.color = 2 # type: int
62
63 @classmethod
64 def InitFromBuf(cls, buf, pos):
65 testSimpleTableWithEnum = TestSimpleTableWithEnum()
66 testSimpleTableWithEnum.Init(buf, pos)
67 return cls.InitFromObj(testSimpleTableWithEnum)
68
69 @classmethod
70 def InitFromPackedBuf(cls, buf, pos=0):
71 n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
72 return cls.InitFromBuf(buf, pos+n)
73
74 @classmethod
75 def InitFromObj(cls, testSimpleTableWithEnum):
76 x = TestSimpleTableWithEnumT()
77 x._UnPack(testSimpleTableWithEnum)
78 return x
79
80 # TestSimpleTableWithEnumT
81 def _UnPack(self, testSimpleTableWithEnum):
82 if testSimpleTableWithEnum is None:
83 return
84 self.color = testSimpleTableWithEnum.Color()
85
86 # TestSimpleTableWithEnumT
87 def Pack(self, builder):
88 TestSimpleTableWithEnumStart(builder)
89 TestSimpleTableWithEnumAddColor(builder, self.color)
90 testSimpleTableWithEnum = TestSimpleTableWithEnumEnd(builder)
91 return testSimpleTableWithEnum
View as plain text