Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 1 | # automatically generated by the FlatBuffers compiler, do not modify |
| 2 | |
| 3 | # namespace: NamespaceA |
| 4 | |
| 5 | import flatbuffers |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 6 | from flatbuffers.compat import import_numpy |
| 7 | np = import_numpy() |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 8 | |
| 9 | class TableInFirstNS(object): |
| 10 | __slots__ = ['_tab'] |
| 11 | |
| 12 | @classmethod |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame^] | 13 | def GetRootAs(cls, buf, offset=0): |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 14 | n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) |
| 15 | x = TableInFirstNS() |
| 16 | x.Init(buf, n + offset) |
| 17 | return x |
| 18 | |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame^] | 19 | @classmethod |
| 20 | def GetRootAsTableInFirstNS(cls, buf, offset=0): |
| 21 | """This method is deprecated. Please switch to GetRootAs.""" |
| 22 | return cls.GetRootAs(buf, offset) |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 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) |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 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 |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame^] | 45 | def FooUnionType(self): |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 46 | o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) |
| 47 | if o != 0: |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame^] | 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: |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 65 | x = o + self._tab.Pos |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 66 | obj = StructInNestedNS() |
| 67 | obj.Init(self._tab.Bytes, x) |
| 68 | return obj |
| 69 | return None |
| 70 | |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame^] | 71 | def TableInFirstNSStart(builder): builder.StartObject(5) |
| 72 | def Start(builder): |
| 73 | return TableInFirstNSStart(builder) |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 74 | def TableInFirstNSAddFooTable(builder, fooTable): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(fooTable), 0) |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame^] | 75 | def AddFooTable(builder, fooTable): |
| 76 | return TableInFirstNSAddFooTable(builder, fooTable) |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 77 | def TableInFirstNSAddFooEnum(builder, fooEnum): builder.PrependInt8Slot(1, fooEnum, 0) |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame^] | 78 | def AddFooEnum(builder, fooEnum): |
| 79 | return TableInFirstNSAddFooEnum(builder, fooEnum) |
| 80 | def TableInFirstNSAddFooUnionType(builder, fooUnionType): builder.PrependUint8Slot(2, fooUnionType, 0) |
| 81 | def AddFooUnionType(builder, fooUnionType): |
| 82 | return TableInFirstNSAddFooUnionType(builder, fooUnionType) |
| 83 | def TableInFirstNSAddFooUnion(builder, fooUnion): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(fooUnion), 0) |
| 84 | def AddFooUnion(builder, fooUnion): |
| 85 | return TableInFirstNSAddFooUnion(builder, fooUnion) |
| 86 | def TableInFirstNSAddFooStruct(builder, fooStruct): builder.PrependStructSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(fooStruct), 0) |
| 87 | def AddFooStruct(builder, fooStruct): |
| 88 | return TableInFirstNSAddFooStruct(builder, fooStruct) |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 89 | def TableInFirstNSEnd(builder): return builder.EndObject() |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame^] | 90 | def End(builder): |
| 91 | return TableInFirstNSEnd(builder) |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 92 | try: |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame^] | 93 | from typing import Optional, Union |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 94 | except: |
| 95 | pass |
| 96 | |
| 97 | class TableInFirstNST(object): |
| 98 | |
| 99 | # TableInFirstNST |
| 100 | def __init__(self): |
| 101 | self.fooTable = None # type: Optional[TableInNestedNST] |
| 102 | self.fooEnum = 0 # type: int |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame^] | 103 | self.fooUnionType = 0 # type: int |
| 104 | self.fooUnion = None # type: Union[None, TableInNestedNST] |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 105 | self.fooStruct = None # type: Optional[StructInNestedNST] |
| 106 | |
| 107 | @classmethod |
| 108 | def InitFromBuf(cls, buf, pos): |
| 109 | tableInFirstNS = TableInFirstNS() |
| 110 | tableInFirstNS.Init(buf, pos) |
| 111 | return cls.InitFromObj(tableInFirstNS) |
| 112 | |
| 113 | @classmethod |
| 114 | def InitFromObj(cls, tableInFirstNS): |
| 115 | x = TableInFirstNST() |
| 116 | x._UnPack(tableInFirstNS) |
| 117 | return x |
| 118 | |
| 119 | # TableInFirstNST |
| 120 | def _UnPack(self, tableInFirstNS): |
| 121 | if tableInFirstNS is None: |
| 122 | return |
| 123 | if tableInFirstNS.FooTable() is not None: |
| 124 | self.fooTable = TableInNestedNST.InitFromObj(tableInFirstNS.FooTable()) |
| 125 | self.fooEnum = tableInFirstNS.FooEnum() |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame^] | 126 | self.fooUnionType = tableInFirstNS.FooUnionType() |
| 127 | self.fooUnion = UnionInNestedNSCreator(self.fooUnionType, tableInFirstNS.FooUnion()) |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 128 | if tableInFirstNS.FooStruct() is not None: |
| 129 | self.fooStruct = StructInNestedNST.InitFromObj(tableInFirstNS.FooStruct()) |
| 130 | |
| 131 | # TableInFirstNST |
| 132 | def Pack(self, builder): |
| 133 | if self.fooTable is not None: |
| 134 | fooTable = self.fooTable.Pack(builder) |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame^] | 135 | if self.fooUnion is not None: |
| 136 | fooUnion = self.fooUnion.Pack(builder) |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 137 | TableInFirstNSStart(builder) |
| 138 | if self.fooTable is not None: |
| 139 | TableInFirstNSAddFooTable(builder, fooTable) |
| 140 | TableInFirstNSAddFooEnum(builder, self.fooEnum) |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame^] | 141 | TableInFirstNSAddFooUnionType(builder, self.fooUnionType) |
| 142 | if self.fooUnion is not None: |
| 143 | TableInFirstNSAddFooUnion(builder, fooUnion) |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 144 | if self.fooStruct is not None: |
| 145 | fooStruct = self.fooStruct.Pack(builder) |
| 146 | TableInFirstNSAddFooStruct(builder, fooStruct) |
| 147 | tableInFirstNS = TableInFirstNSEnd(builder) |
| 148 | return tableInFirstNS |