1# automatically generated by the FlatBuffers compiler, do not modify 2 3# namespace: Example 4 5import flatbuffers 6 7# /// an example documentation comment: monster object 8class Monster(object): 9 __slots__ = ['_tab'] 10 11 @classmethod 12 def GetRootAsMonster(cls, buf, offset): 13 n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) 14 x = Monster() 15 x.Init(buf, n + offset) 16 return x 17 18 # Monster 19 def Init(self, buf, pos): 20 self._tab = flatbuffers.table.Table(buf, pos) 21 22 # Monster 23 def Pos(self): 24 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) 25 if o != 0: 26 x = o + self._tab.Pos 27 from .Vec3 import Vec3 28 obj = Vec3() 29 obj.Init(self._tab.Bytes, x) 30 return obj 31 return None 32 33 # Monster 34 def Mana(self): 35 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) 36 if o != 0: 37 return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos) 38 return 150 39 40 # Monster 41 def Hp(self): 42 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) 43 if o != 0: 44 return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos) 45 return 100 46 47 # Monster 48 def Name(self): 49 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) 50 if o != 0: 51 return self._tab.String(o + self._tab.Pos) 52 return "" 53 54 # Monster 55 def Inventory(self, j): 56 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) 57 if o != 0: 58 a = self._tab.Vector(o) 59 return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)) 60 return 0 61 62 # Monster 63 def InventoryLength(self): 64 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) 65 if o != 0: 66 return self._tab.VectorLen(o) 67 return 0 68 69 # Monster 70 def Color(self): 71 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16)) 72 if o != 0: 73 return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) 74 return 8 75 76 # Monster 77 def TestType(self): 78 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) 79 if o != 0: 80 return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos) 81 return 0 82 83 # Monster 84 def Test(self): 85 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20)) 86 if o != 0: 87 from flatbuffers.table import Table 88 obj = Table(bytearray(), 0) 89 self._tab.Union(obj, o) 90 return obj 91 return None 92 93 # Monster 94 def Test4(self, j): 95 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22)) 96 if o != 0: 97 x = self._tab.Vector(o) 98 x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 99 from .Test import Test 100 obj = Test() 101 obj.Init(self._tab.Bytes, x) 102 return obj 103 return None 104 105 # Monster 106 def Test4Length(self): 107 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22)) 108 if o != 0: 109 return self._tab.VectorLen(o) 110 return 0 111 112 # Monster 113 def Testarrayofstring(self, j): 114 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24)) 115 if o != 0: 116 a = self._tab.Vector(o) 117 return self._tab.String(a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) 118 return "" 119 120 # Monster 121 def TestarrayofstringLength(self): 122 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24)) 123 if o != 0: 124 return self._tab.VectorLen(o) 125 return 0 126 127# /// an example documentation comment: this will end up in the generated code 128# /// multiline too 129 # Monster 130 def Testarrayoftables(self, j): 131 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(26)) 132 if o != 0: 133 x = self._tab.Vector(o) 134 x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 135 x = self._tab.Indirect(x) 136 from .Monster import Monster 137 obj = Monster() 138 obj.Init(self._tab.Bytes, x) 139 return obj 140 return None 141 142 # Monster 143 def TestarrayoftablesLength(self): 144 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(26)) 145 if o != 0: 146 return self._tab.VectorLen(o) 147 return 0 148 149 # Monster 150 def Enemy(self): 151 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(28)) 152 if o != 0: 153 x = self._tab.Indirect(o + self._tab.Pos) 154 from .Monster import Monster 155 obj = Monster() 156 obj.Init(self._tab.Bytes, x) 157 return obj 158 return None 159 160 # Monster 161 def Testnestedflatbuffer(self, j): 162 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(30)) 163 if o != 0: 164 a = self._tab.Vector(o) 165 return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)) 166 return 0 167 168 # Monster 169 def TestnestedflatbufferLength(self): 170 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(30)) 171 if o != 0: 172 return self._tab.VectorLen(o) 173 return 0 174 175 # Monster 176 def Testempty(self): 177 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(32)) 178 if o != 0: 179 x = self._tab.Indirect(o + self._tab.Pos) 180 from .Stat import Stat 181 obj = Stat() 182 obj.Init(self._tab.Bytes, x) 183 return obj 184 return None 185 186 # Monster 187 def Testbool(self): 188 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(34)) 189 if o != 0: 190 return self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos) 191 return 0 192 193 # Monster 194 def Testhashs32Fnv1(self): 195 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(36)) 196 if o != 0: 197 return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) 198 return 0 199 200 # Monster 201 def Testhashu32Fnv1(self): 202 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(38)) 203 if o != 0: 204 return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos) 205 return 0 206 207 # Monster 208 def Testhashs64Fnv1(self): 209 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(40)) 210 if o != 0: 211 return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos) 212 return 0 213 214 # Monster 215 def Testhashu64Fnv1(self): 216 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(42)) 217 if o != 0: 218 return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos) 219 return 0 220 221 # Monster 222 def Testhashs32Fnv1a(self): 223 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(44)) 224 if o != 0: 225 return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) 226 return 0 227 228 # Monster 229 def Testhashu32Fnv1a(self): 230 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(46)) 231 if o != 0: 232 return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos) 233 return 0 234 235 # Monster 236 def Testhashs64Fnv1a(self): 237 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(48)) 238 if o != 0: 239 return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos) 240 return 0 241 242 # Monster 243 def Testhashu64Fnv1a(self): 244 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(50)) 245 if o != 0: 246 return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos) 247 return 0 248 249 # Monster 250 def Testarrayofbools(self, j): 251 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(52)) 252 if o != 0: 253 a = self._tab.Vector(o) 254 return self._tab.Get(flatbuffers.number_types.BoolFlags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)) 255 return 0 256 257 # Monster 258 def TestarrayofboolsLength(self): 259 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(52)) 260 if o != 0: 261 return self._tab.VectorLen(o) 262 return 0 263 264 # Monster 265 def Testf(self): 266 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(54)) 267 if o != 0: 268 return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos) 269 return 3.14159 270 271 # Monster 272 def Testf2(self): 273 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(56)) 274 if o != 0: 275 return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos) 276 return 3.0 277 278 # Monster 279 def Testf3(self): 280 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(58)) 281 if o != 0: 282 return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos) 283 return 0.0 284 285 # Monster 286 def Testarrayofstring2(self, j): 287 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(60)) 288 if o != 0: 289 a = self._tab.Vector(o) 290 return self._tab.String(a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) 291 return "" 292 293 # Monster 294 def Testarrayofstring2Length(self): 295 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(60)) 296 if o != 0: 297 return self._tab.VectorLen(o) 298 return 0 299 300def MonsterStart(builder): builder.StartObject(29) 301def MonsterAddPos(builder, pos): builder.PrependStructSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(pos), 0) 302def MonsterAddMana(builder, mana): builder.PrependInt16Slot(1, mana, 150) 303def MonsterAddHp(builder, hp): builder.PrependInt16Slot(2, hp, 100) 304def MonsterAddName(builder, name): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0) 305def MonsterAddInventory(builder, inventory): builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(inventory), 0) 306def MonsterStartInventoryVector(builder, numElems): return builder.StartVector(1, numElems, 1) 307def MonsterAddColor(builder, color): builder.PrependInt8Slot(6, color, 8) 308def MonsterAddTestType(builder, testType): builder.PrependUint8Slot(7, testType, 0) 309def MonsterAddTest(builder, test): builder.PrependUOffsetTRelativeSlot(8, flatbuffers.number_types.UOffsetTFlags.py_type(test), 0) 310def MonsterAddTest4(builder, test4): builder.PrependUOffsetTRelativeSlot(9, flatbuffers.number_types.UOffsetTFlags.py_type(test4), 0) 311def MonsterStartTest4Vector(builder, numElems): return builder.StartVector(4, numElems, 2) 312def MonsterAddTestarrayofstring(builder, testarrayofstring): builder.PrependUOffsetTRelativeSlot(10, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayofstring), 0) 313def MonsterStartTestarrayofstringVector(builder, numElems): return builder.StartVector(4, numElems, 4) 314def MonsterAddTestarrayoftables(builder, testarrayoftables): builder.PrependUOffsetTRelativeSlot(11, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayoftables), 0) 315def MonsterStartTestarrayoftablesVector(builder, numElems): return builder.StartVector(4, numElems, 4) 316def MonsterAddEnemy(builder, enemy): builder.PrependUOffsetTRelativeSlot(12, flatbuffers.number_types.UOffsetTFlags.py_type(enemy), 0) 317def MonsterAddTestnestedflatbuffer(builder, testnestedflatbuffer): builder.PrependUOffsetTRelativeSlot(13, flatbuffers.number_types.UOffsetTFlags.py_type(testnestedflatbuffer), 0) 318def MonsterStartTestnestedflatbufferVector(builder, numElems): return builder.StartVector(1, numElems, 1) 319def MonsterAddTestempty(builder, testempty): builder.PrependUOffsetTRelativeSlot(14, flatbuffers.number_types.UOffsetTFlags.py_type(testempty), 0) 320def MonsterAddTestbool(builder, testbool): builder.PrependBoolSlot(15, testbool, 0) 321def MonsterAddTesthashs32Fnv1(builder, testhashs32Fnv1): builder.PrependInt32Slot(16, testhashs32Fnv1, 0) 322def MonsterAddTesthashu32Fnv1(builder, testhashu32Fnv1): builder.PrependUint32Slot(17, testhashu32Fnv1, 0) 323def MonsterAddTesthashs64Fnv1(builder, testhashs64Fnv1): builder.PrependInt64Slot(18, testhashs64Fnv1, 0) 324def MonsterAddTesthashu64Fnv1(builder, testhashu64Fnv1): builder.PrependUint64Slot(19, testhashu64Fnv1, 0) 325def MonsterAddTesthashs32Fnv1a(builder, testhashs32Fnv1a): builder.PrependInt32Slot(20, testhashs32Fnv1a, 0) 326def MonsterAddTesthashu32Fnv1a(builder, testhashu32Fnv1a): builder.PrependUint32Slot(21, testhashu32Fnv1a, 0) 327def MonsterAddTesthashs64Fnv1a(builder, testhashs64Fnv1a): builder.PrependInt64Slot(22, testhashs64Fnv1a, 0) 328def MonsterAddTesthashu64Fnv1a(builder, testhashu64Fnv1a): builder.PrependUint64Slot(23, testhashu64Fnv1a, 0) 329def MonsterAddTestarrayofbools(builder, testarrayofbools): builder.PrependUOffsetTRelativeSlot(24, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayofbools), 0) 330def MonsterStartTestarrayofboolsVector(builder, numElems): return builder.StartVector(1, numElems, 1) 331def MonsterAddTestf(builder, testf): builder.PrependFloat32Slot(25, testf, 3.14159) 332def MonsterAddTestf2(builder, testf2): builder.PrependFloat32Slot(26, testf2, 3.0) 333def MonsterAddTestf3(builder, testf3): builder.PrependFloat32Slot(27, testf3, 0.0) 334def MonsterAddTestarrayofstring2(builder, testarrayofstring2): builder.PrependUOffsetTRelativeSlot(28, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayofstring2), 0) 335def MonsterStartTestarrayofstring2Vector(builder, numElems): return builder.StartVector(4, numElems, 4) 336def MonsterEnd(builder): return builder.EndObject() 337