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 Start(builder): builder.StartObject(1) 39def TestSimpleTableWithEnumStart(builder): 40 """This method is deprecated. Please switch to Start.""" 41 return Start(builder) 42def AddColor(builder, color): builder.PrependUint8Slot(0, color, 2) 43def TestSimpleTableWithEnumAddColor(builder, color): 44 """This method is deprecated. Please switch to AddColor.""" 45 return AddColor(builder, color) 46def End(builder): return builder.EndObject() 47def TestSimpleTableWithEnumEnd(builder): 48 """This method is deprecated. Please switch to End.""" 49 return End(builder) 50 51class TestSimpleTableWithEnumT(object): 52 53 # TestSimpleTableWithEnumT 54 def __init__(self): 55 self.color = 2 # type: int 56 57 @classmethod 58 def InitFromBuf(cls, buf, pos): 59 testSimpleTableWithEnum = TestSimpleTableWithEnum() 60 testSimpleTableWithEnum.Init(buf, pos) 61 return cls.InitFromObj(testSimpleTableWithEnum) 62 63 @classmethod 64 def InitFromObj(cls, testSimpleTableWithEnum): 65 x = TestSimpleTableWithEnumT() 66 x._UnPack(testSimpleTableWithEnum) 67 return x 68 69 # TestSimpleTableWithEnumT 70 def _UnPack(self, testSimpleTableWithEnum): 71 if testSimpleTableWithEnum is None: 72 return 73 self.color = testSimpleTableWithEnum.Color() 74 75 # TestSimpleTableWithEnumT 76 def Pack(self, builder): 77 Start(builder) 78 AddColor(builder, self.color) 79 testSimpleTableWithEnum = End(builder) 80 return testSimpleTableWithEnum 81