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 ArrayTable(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 = ArrayTable() 16 x.Init(buf, n + offset) 17 return x 18 19 @classmethod 20 def GetRootAsArrayTable(cls, buf, offset=0): 21 """This method is deprecated. Please switch to GetRootAs.""" 22 return cls.GetRootAs(buf, offset) 23 @classmethod 24 def ArrayTableBufferHasIdentifier(cls, buf, offset, size_prefixed=False): 25 return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x41\x52\x52\x54", size_prefixed=size_prefixed) 26 27 # ArrayTable 28 def Init(self, buf, pos): 29 self._tab = flatbuffers.table.Table(buf, pos) 30 31 # ArrayTable 32 def A(self): 33 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) 34 if o != 0: 35 x = o + self._tab.Pos 36 from MyGame.Example.ArrayStruct import ArrayStruct 37 obj = ArrayStruct() 38 obj.Init(self._tab.Bytes, x) 39 return obj 40 return None 41 42def Start(builder): builder.StartObject(1) 43def ArrayTableStart(builder): 44 """This method is deprecated. Please switch to Start.""" 45 return Start(builder) 46def AddA(builder, a): builder.PrependStructSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(a), 0) 47def ArrayTableAddA(builder, a): 48 """This method is deprecated. Please switch to AddA.""" 49 return AddA(builder, a) 50def End(builder): return builder.EndObject() 51def ArrayTableEnd(builder): 52 """This method is deprecated. Please switch to End.""" 53 return End(builder) 54import MyGame.Example.ArrayStruct 55try: 56 from typing import Optional 57except: 58 pass 59 60class ArrayTableT(object): 61 62 # ArrayTableT 63 def __init__(self): 64 self.a = None # type: Optional[MyGame.Example.ArrayStruct.ArrayStructT] 65 66 @classmethod 67 def InitFromBuf(cls, buf, pos): 68 arrayTable = ArrayTable() 69 arrayTable.Init(buf, pos) 70 return cls.InitFromObj(arrayTable) 71 72 @classmethod 73 def InitFromObj(cls, arrayTable): 74 x = ArrayTableT() 75 x._UnPack(arrayTable) 76 return x 77 78 # ArrayTableT 79 def _UnPack(self, arrayTable): 80 if arrayTable is None: 81 return 82 if arrayTable.A() is not None: 83 self.a = MyGame.Example.ArrayStruct.ArrayStructT.InitFromObj(arrayTable.A()) 84 85 # ArrayTableT 86 def Pack(self, builder): 87 Start(builder) 88 if self.a is not None: 89 a = self.a.Pack(builder) 90 AddA(builder, a) 91 arrayTable = End(builder) 92 return arrayTable 93