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