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 Referrable(object): 10 __slots__ = ['_tab'] 11 12 @classmethod 13 def GetRootAsReferrable(cls, buf, offset): 14 n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) 15 x = Referrable() 16 x.Init(buf, n + offset) 17 return x 18 19 @classmethod 20 def ReferrableBufferHasIdentifier(cls, buf, offset, size_prefixed=False): 21 return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x4F\x4E\x53", size_prefixed=size_prefixed) 22 23 # Referrable 24 def Init(self, buf, pos): 25 self._tab = flatbuffers.table.Table(buf, pos) 26 27 # Referrable 28 def Id(self): 29 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) 30 if o != 0: 31 return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos) 32 return 0 33 34def ReferrableStart(builder): builder.StartObject(1) 35def ReferrableAddId(builder, id): builder.PrependUint64Slot(0, id, 0) 36def ReferrableEnd(builder): return builder.EndObject() 37 38 39class ReferrableT(object): 40 41 # ReferrableT 42 def __init__(self): 43 self.id = 0 # type: int 44 45 @classmethod 46 def InitFromBuf(cls, buf, pos): 47 referrable = Referrable() 48 referrable.Init(buf, pos) 49 return cls.InitFromObj(referrable) 50 51 @classmethod 52 def InitFromObj(cls, referrable): 53 x = ReferrableT() 54 x._UnPack(referrable) 55 return x 56 57 # ReferrableT 58 def _UnPack(self, referrable): 59 if referrable is None: 60 return 61 self.id = referrable.Id() 62 63 # ReferrableT 64 def Pack(self, builder): 65 ReferrableStart(builder) 66 ReferrableAddId(builder, self.id) 67 referrable = ReferrableEnd(builder) 68 return referrable 69