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 StructOfStructs(object): 10 __slots__ = ['_tab'] 11 12 @classmethod 13 def SizeOf(cls): 14 return 20 15 16 # StructOfStructs 17 def Init(self, buf, pos): 18 self._tab = flatbuffers.table.Table(buf, pos) 19 20 # StructOfStructs 21 def A(self, obj): 22 obj.Init(self._tab.Bytes, self._tab.Pos + 0) 23 return obj 24 25 # StructOfStructs 26 def B(self, obj): 27 obj.Init(self._tab.Bytes, self._tab.Pos + 8) 28 return obj 29 30 # StructOfStructs 31 def C(self, obj): 32 obj.Init(self._tab.Bytes, self._tab.Pos + 12) 33 return obj 34 35 36def CreateStructOfStructs(builder, a_id, a_distance, b_a, b_b, c_id, c_distance): 37 builder.Prep(4, 20) 38 builder.Prep(4, 8) 39 builder.PrependUint32(c_distance) 40 builder.PrependUint32(c_id) 41 builder.Prep(2, 4) 42 builder.Pad(1) 43 builder.PrependInt8(b_b) 44 builder.PrependInt16(b_a) 45 builder.Prep(4, 8) 46 builder.PrependUint32(a_distance) 47 builder.PrependUint32(a_id) 48 return builder.Offset() 49 50import MyGame.Example.Ability 51import MyGame.Example.Test 52try: 53 from typing import Optional 54except: 55 pass 56 57class StructOfStructsT(object): 58 59 # StructOfStructsT 60 def __init__(self): 61 self.a = None # type: Optional[MyGame.Example.Ability.AbilityT] 62 self.b = None # type: Optional[MyGame.Example.Test.TestT] 63 self.c = None # type: Optional[MyGame.Example.Ability.AbilityT] 64 65 @classmethod 66 def InitFromBuf(cls, buf, pos): 67 structOfStructs = StructOfStructs() 68 structOfStructs.Init(buf, pos) 69 return cls.InitFromObj(structOfStructs) 70 71 @classmethod 72 def InitFromObj(cls, structOfStructs): 73 x = StructOfStructsT() 74 x._UnPack(structOfStructs) 75 return x 76 77 # StructOfStructsT 78 def _UnPack(self, structOfStructs): 79 if structOfStructs is None: 80 return 81 if structOfStructs.A(MyGame.Example.Ability.Ability()) is not None: 82 self.a = MyGame.Example.Ability.AbilityT.InitFromObj(structOfStructs.A(MyGame.Example.Ability.Ability())) 83 if structOfStructs.B(MyGame.Example.Test.Test()) is not None: 84 self.b = MyGame.Example.Test.TestT.InitFromObj(structOfStructs.B(MyGame.Example.Test.Test())) 85 if structOfStructs.C(MyGame.Example.Ability.Ability()) is not None: 86 self.c = MyGame.Example.Ability.AbilityT.InitFromObj(structOfStructs.C(MyGame.Example.Ability.Ability())) 87 88 # StructOfStructsT 89 def Pack(self, builder): 90 return CreateStructOfStructs(builder, self.a.id, self.a.distance, self.b.a, self.b.b, self.c.id, self.c.distance) 91