1# automatically generated by the FlatBuffers compiler, do not modify 2 3# namespace: Example2 4 5import flatbuffers 6from flatbuffers.compat import import_numpy 7np = import_numpy() 8 9class Monster(object): 10 __slots__ = ['_tab'] 11 12 @classmethod 13 def GetRootAsMonster(cls, buf, offset): 14 n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) 15 x = Monster() 16 x.Init(buf, n + offset) 17 return x 18 19 @classmethod 20 def MonsterBufferHasIdentifier(cls, buf, offset, size_prefixed=False): 21 return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x4F\x4E\x53", size_prefixed=size_prefixed) 22 23 # Monster 24 def Init(self, buf, pos): 25 self._tab = flatbuffers.table.Table(buf, pos) 26 27def MonsterStart(builder): builder.StartObject(0) 28def MonsterEnd(builder): return builder.EndObject() 29 30 31class MonsterT(object): 32 33 # MonsterT 34 def __init__(self): 35 pass 36 37 @classmethod 38 def InitFromBuf(cls, buf, pos): 39 monster = Monster() 40 monster.Init(buf, pos) 41 return cls.InitFromObj(monster) 42 43 @classmethod 44 def InitFromObj(cls, monster): 45 x = MonsterT() 46 x._UnPack(monster) 47 return x 48 49 # MonsterT 50 def _UnPack(self, monster): 51 if monster is None: 52 return 53 54 # MonsterT 55 def Pack(self, builder): 56 MonsterStart(builder) 57 monster = MonsterEnd(builder) 58 return monster 59