1# automatically generated by the FlatBuffers compiler, do not modify 2 3# namespace: NamespaceA 4 5import flatbuffers 6from flatbuffers.compat import import_numpy 7np = import_numpy() 8 9class TableInFirstNS(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 = TableInFirstNS() 16 x.Init(buf, n + offset) 17 return x 18 19 @classmethod 20 def GetRootAsTableInFirstNS(cls, buf, offset=0): 21 """This method is deprecated. Please switch to GetRootAs.""" 22 return cls.GetRootAs(buf, offset) 23 # TableInFirstNS 24 def Init(self, buf, pos): 25 self._tab = flatbuffers.table.Table(buf, pos) 26 27 # TableInFirstNS 28 def FooTable(self): 29 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) 30 if o != 0: 31 x = self._tab.Indirect(o + self._tab.Pos) 32 obj = TableInNestedNS() 33 obj.Init(self._tab.Bytes, x) 34 return obj 35 return None 36 37 # TableInFirstNS 38 def FooEnum(self): 39 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) 40 if o != 0: 41 return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) 42 return 0 43 44 # TableInFirstNS 45 def FooUnionType(self): 46 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) 47 if o != 0: 48 return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos) 49 return 0 50 51 # TableInFirstNS 52 def FooUnion(self): 53 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) 54 if o != 0: 55 from flatbuffers.table import Table 56 obj = Table(bytearray(), 0) 57 self._tab.Union(obj, o) 58 return obj 59 return None 60 61 # TableInFirstNS 62 def FooStruct(self): 63 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) 64 if o != 0: 65 x = o + self._tab.Pos 66 obj = StructInNestedNS() 67 obj.Init(self._tab.Bytes, x) 68 return obj 69 return None 70 71def Start(builder): builder.StartObject(5) 72def TableInFirstNSStart(builder): 73 """This method is deprecated. Please switch to Start.""" 74 return Start(builder) 75def AddFooTable(builder, fooTable): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(fooTable), 0) 76def TableInFirstNSAddFooTable(builder, fooTable): 77 """This method is deprecated. Please switch to AddFooTable.""" 78 return AddFooTable(builder, fooTable) 79def AddFooEnum(builder, fooEnum): builder.PrependInt8Slot(1, fooEnum, 0) 80def TableInFirstNSAddFooEnum(builder, fooEnum): 81 """This method is deprecated. Please switch to AddFooEnum.""" 82 return AddFooEnum(builder, fooEnum) 83def AddFooUnionType(builder, fooUnionType): builder.PrependUint8Slot(2, fooUnionType, 0) 84def TableInFirstNSAddFooUnionType(builder, fooUnionType): 85 """This method is deprecated. Please switch to AddFooUnionType.""" 86 return AddFooUnionType(builder, fooUnionType) 87def AddFooUnion(builder, fooUnion): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(fooUnion), 0) 88def TableInFirstNSAddFooUnion(builder, fooUnion): 89 """This method is deprecated. Please switch to AddFooUnion.""" 90 return AddFooUnion(builder, fooUnion) 91def AddFooStruct(builder, fooStruct): builder.PrependStructSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(fooStruct), 0) 92def TableInFirstNSAddFooStruct(builder, fooStruct): 93 """This method is deprecated. Please switch to AddFooStruct.""" 94 return AddFooStruct(builder, fooStruct) 95def End(builder): return builder.EndObject() 96def TableInFirstNSEnd(builder): 97 """This method is deprecated. Please switch to End.""" 98 return End(builder) 99try: 100 from typing import Optional, Union 101except: 102 pass 103 104class TableInFirstNST(object): 105 106 # TableInFirstNST 107 def __init__(self): 108 self.fooTable = None # type: Optional[TableInNestedNST] 109 self.fooEnum = 0 # type: int 110 self.fooUnionType = 0 # type: int 111 self.fooUnion = None # type: Union[None, TableInNestedNST] 112 self.fooStruct = None # type: Optional[StructInNestedNST] 113 114 @classmethod 115 def InitFromBuf(cls, buf, pos): 116 tableInFirstNS = TableInFirstNS() 117 tableInFirstNS.Init(buf, pos) 118 return cls.InitFromObj(tableInFirstNS) 119 120 @classmethod 121 def InitFromObj(cls, tableInFirstNS): 122 x = TableInFirstNST() 123 x._UnPack(tableInFirstNS) 124 return x 125 126 # TableInFirstNST 127 def _UnPack(self, tableInFirstNS): 128 if tableInFirstNS is None: 129 return 130 if tableInFirstNS.FooTable() is not None: 131 self.fooTable = TableInNestedNST.InitFromObj(tableInFirstNS.FooTable()) 132 self.fooEnum = tableInFirstNS.FooEnum() 133 self.fooUnionType = tableInFirstNS.FooUnionType() 134 self.fooUnion = UnionInNestedNSCreator(self.fooUnionType, tableInFirstNS.FooUnion()) 135 if tableInFirstNS.FooStruct() is not None: 136 self.fooStruct = StructInNestedNST.InitFromObj(tableInFirstNS.FooStruct()) 137 138 # TableInFirstNST 139 def Pack(self, builder): 140 if self.fooTable is not None: 141 fooTable = self.fooTable.Pack(builder) 142 if self.fooUnion is not None: 143 fooUnion = self.fooUnion.Pack(builder) 144 Start(builder) 145 if self.fooTable is not None: 146 AddFooTable(builder, fooTable) 147 AddFooEnum(builder, self.fooEnum) 148 AddFooUnionType(builder, self.fooUnionType) 149 if self.fooUnion is not None: 150 AddFooUnion(builder, fooUnion) 151 if self.fooStruct is not None: 152 fooStruct = self.fooStruct.Pack(builder) 153 AddFooStruct(builder, fooStruct) 154 tableInFirstNS = End(builder) 155 return tableInFirstNS 156