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: Example |
| 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 ArrayStruct(object): |
| 10 | __slots__ = ['_tab'] |
| 11 | |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame^] | 12 | @classmethod |
| 13 | def SizeOf(cls): |
| 14 | return 160 |
| 15 | |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 16 | # ArrayStruct |
| 17 | def Init(self, buf, pos): |
| 18 | self._tab = flatbuffers.table.Table(buf, pos) |
| 19 | |
| 20 | # ArrayStruct |
| 21 | def A(self): return self._tab.Get(flatbuffers.number_types.Float32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(0)) |
| 22 | # ArrayStruct |
| 23 | def B(self): return [self._tab.Get(flatbuffers.number_types.Int32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(4 + i * 4)) for i in range(15)] |
| 24 | # ArrayStruct |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame^] | 25 | def BLength(self): |
| 26 | o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) |
| 27 | if o != 0: |
| 28 | return self._tab.VectorLen(o) |
| 29 | return 0 |
| 30 | |
| 31 | # ArrayStruct |
| 32 | def BIsNone(self): |
| 33 | o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) |
| 34 | return o == 0 |
| 35 | |
| 36 | # ArrayStruct |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 37 | def C(self): return self._tab.Get(flatbuffers.number_types.Int8Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(64)) |
| 38 | # ArrayStruct |
| 39 | def D(self, obj, i): |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame^] | 40 | obj.Init(self._tab.Bytes, self._tab.Pos + 72 + i * 32) |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 41 | return obj |
| 42 | |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame^] | 43 | # ArrayStruct |
| 44 | def DLength(self): |
| 45 | o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(72)) |
| 46 | if o != 0: |
| 47 | return self._tab.VectorLen(o) |
| 48 | return 0 |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 49 | |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame^] | 50 | # ArrayStruct |
| 51 | def DIsNone(self): |
| 52 | o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(72)) |
| 53 | return o == 0 |
| 54 | |
| 55 | # ArrayStruct |
| 56 | def E(self): return self._tab.Get(flatbuffers.number_types.Int32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(136)) |
| 57 | # ArrayStruct |
| 58 | def F(self): return [self._tab.Get(flatbuffers.number_types.Int64Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(144 + i * 8)) for i in range(2)] |
| 59 | # ArrayStruct |
| 60 | def FLength(self): |
| 61 | o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(144)) |
| 62 | if o != 0: |
| 63 | return self._tab.VectorLen(o) |
| 64 | return 0 |
| 65 | |
| 66 | # ArrayStruct |
| 67 | def FIsNone(self): |
| 68 | o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(144)) |
| 69 | return o == 0 |
| 70 | |
| 71 | |
| 72 | def CreateArrayStruct(builder, a, b, c, d_a, d_b, d_c, d_d, e, f): |
| 73 | builder.Prep(8, 160) |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 74 | for _idx0 in range(2 , 0, -1): |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame^] | 75 | builder.PrependInt64(f[_idx0-1]) |
| 76 | builder.Pad(4) |
| 77 | builder.PrependInt32(e) |
| 78 | for _idx0 in range(2 , 0, -1): |
| 79 | builder.Prep(8, 32) |
| 80 | for _idx1 in range(2 , 0, -1): |
| 81 | builder.PrependInt64(d_d[_idx0-1][_idx1-1]) |
| 82 | builder.Pad(5) |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 83 | for _idx1 in range(2 , 0, -1): |
| 84 | builder.PrependInt8(d_c[_idx0-1][_idx1-1]) |
| 85 | builder.PrependInt8(d_b[_idx0-1]) |
| 86 | for _idx1 in range(2 , 0, -1): |
| 87 | builder.PrependInt32(d_a[_idx0-1][_idx1-1]) |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame^] | 88 | builder.Pad(7) |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 89 | builder.PrependInt8(c) |
| 90 | for _idx0 in range(15 , 0, -1): |
| 91 | builder.PrependInt32(b[_idx0-1]) |
| 92 | builder.PrependFloat32(a) |
| 93 | return builder.Offset() |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame^] | 94 | |
| 95 | import MyGame.Example.NestedStruct |
| 96 | try: |
| 97 | from typing import List |
| 98 | except: |
| 99 | pass |
| 100 | |
| 101 | class ArrayStructT(object): |
| 102 | |
| 103 | # ArrayStructT |
| 104 | def __init__(self): |
| 105 | self.a = 0.0 # type: float |
| 106 | self.b = None # type: List[int] |
| 107 | self.c = 0 # type: int |
| 108 | self.d = None # type: List[MyGame.Example.NestedStruct.NestedStructT] |
| 109 | self.e = 0 # type: int |
| 110 | self.f = None # type: List[int] |
| 111 | |
| 112 | @classmethod |
| 113 | def InitFromBuf(cls, buf, pos): |
| 114 | arrayStruct = ArrayStruct() |
| 115 | arrayStruct.Init(buf, pos) |
| 116 | return cls.InitFromObj(arrayStruct) |
| 117 | |
| 118 | @classmethod |
| 119 | def InitFromObj(cls, arrayStruct): |
| 120 | x = ArrayStructT() |
| 121 | x._UnPack(arrayStruct) |
| 122 | return x |
| 123 | |
| 124 | # ArrayStructT |
| 125 | def _UnPack(self, arrayStruct): |
| 126 | if arrayStruct is None: |
| 127 | return |
| 128 | self.a = arrayStruct.A() |
| 129 | if not arrayStruct.BIsNone(): |
| 130 | if np is None: |
| 131 | self.b = [] |
| 132 | for i in range(arrayStruct.BLength()): |
| 133 | self.b.append(arrayStruct.B(i)) |
| 134 | else: |
| 135 | self.b = arrayStruct.BAsNumpy() |
| 136 | self.c = arrayStruct.C() |
| 137 | if not arrayStruct.DIsNone(): |
| 138 | self.d = [] |
| 139 | for i in range(arrayStruct.DLength()): |
| 140 | self.d.append(arrayStruct.D(i)) |
| 141 | self.e = arrayStruct.E() |
| 142 | if not arrayStruct.FIsNone(): |
| 143 | if np is None: |
| 144 | self.f = [] |
| 145 | for i in range(arrayStruct.FLength()): |
| 146 | self.f.append(arrayStruct.F(i)) |
| 147 | else: |
| 148 | self.f = arrayStruct.FAsNumpy() |
| 149 | |
| 150 | # ArrayStructT |
| 151 | def Pack(self, builder): |
| 152 | return CreateArrayStruct(builder, self.a, self.b, self.c, self.d.a, self.d.b, self.d.c, self.d.d, self.e, self.f) |