blob: d80f84253f5cf829952a2febd2795bccb5d419da [file] [log] [blame]
Austin Schuhe89fa2d2019-08-14 20:24:23 -07001# automatically generated by the FlatBuffers compiler, do not modify
2
3# namespace: Example
4
5import flatbuffers
Austin Schuh272c6132020-11-14 16:37:52 -08006from flatbuffers.compat import import_numpy
7np = import_numpy()
Austin Schuhe89fa2d2019-08-14 20:24:23 -07008
9class ArrayStruct(object):
10 __slots__ = ['_tab']
11
Austin Schuh272c6132020-11-14 16:37:52 -080012 @classmethod
13 def SizeOf(cls):
14 return 160
15
Austin Schuhe89fa2d2019-08-14 20:24:23 -070016 # 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
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080023 def B(self, j = None):
24 if j is None:
25 return [self._tab.Get(flatbuffers.number_types.Int32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(4 + i * 4)) for i in range(self.BLength())]
26 elif j >= 0 and j < self.BLength():
27 return self._tab.Get(flatbuffers.number_types.Int32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(4 + j * 4))
28 else:
29 return None
30
31 # ArrayStruct
32 def BAsNumpy(self):
33 return self._tab.GetArrayAsNumpy(flatbuffers.number_types.Int32Flags, self._tab.Pos + 4, self.BLength())
34
Austin Schuhe89fa2d2019-08-14 20:24:23 -070035 # ArrayStruct
Austin Schuh272c6132020-11-14 16:37:52 -080036 def BLength(self):
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080037 return 15
Austin Schuh272c6132020-11-14 16:37:52 -080038
39 # ArrayStruct
40 def BIsNone(self):
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080041 return False
Austin Schuh272c6132020-11-14 16:37:52 -080042
43 # ArrayStruct
Austin Schuhe89fa2d2019-08-14 20:24:23 -070044 def C(self): return self._tab.Get(flatbuffers.number_types.Int8Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(64))
45 # ArrayStruct
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080046 def D(self, i: int):
47 from MyGame.Example.NestedStruct import NestedStruct
48 obj = NestedStruct()
Austin Schuh272c6132020-11-14 16:37:52 -080049 obj.Init(self._tab.Bytes, self._tab.Pos + 72 + i * 32)
Austin Schuhe89fa2d2019-08-14 20:24:23 -070050 return obj
51
Austin Schuh272c6132020-11-14 16:37:52 -080052 # ArrayStruct
53 def DLength(self):
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080054 return 2
Austin Schuhe89fa2d2019-08-14 20:24:23 -070055
Austin Schuh272c6132020-11-14 16:37:52 -080056 # ArrayStruct
57 def DIsNone(self):
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080058 return False
Austin Schuh272c6132020-11-14 16:37:52 -080059
60 # ArrayStruct
61 def E(self): return self._tab.Get(flatbuffers.number_types.Int32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(136))
62 # ArrayStruct
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080063 def F(self, j = None):
64 if j is None:
65 return [self._tab.Get(flatbuffers.number_types.Int64Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(144 + i * 8)) for i in range(self.FLength())]
66 elif j >= 0 and j < self.FLength():
67 return self._tab.Get(flatbuffers.number_types.Int64Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(144 + j * 8))
68 else:
69 return None
70
71 # ArrayStruct
72 def FAsNumpy(self):
73 return self._tab.GetArrayAsNumpy(flatbuffers.number_types.Int64Flags, self._tab.Pos + 144, self.FLength())
74
Austin Schuh272c6132020-11-14 16:37:52 -080075 # ArrayStruct
76 def FLength(self):
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080077 return 2
Austin Schuh272c6132020-11-14 16:37:52 -080078
79 # ArrayStruct
80 def FIsNone(self):
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080081 return False
Austin Schuh272c6132020-11-14 16:37:52 -080082
83
84def CreateArrayStruct(builder, a, b, c, d_a, d_b, d_c, d_d, e, f):
85 builder.Prep(8, 160)
Austin Schuhe89fa2d2019-08-14 20:24:23 -070086 for _idx0 in range(2 , 0, -1):
Austin Schuh272c6132020-11-14 16:37:52 -080087 builder.PrependInt64(f[_idx0-1])
88 builder.Pad(4)
89 builder.PrependInt32(e)
90 for _idx0 in range(2 , 0, -1):
91 builder.Prep(8, 32)
92 for _idx1 in range(2 , 0, -1):
93 builder.PrependInt64(d_d[_idx0-1][_idx1-1])
94 builder.Pad(5)
Austin Schuhe89fa2d2019-08-14 20:24:23 -070095 for _idx1 in range(2 , 0, -1):
96 builder.PrependInt8(d_c[_idx0-1][_idx1-1])
97 builder.PrependInt8(d_b[_idx0-1])
98 for _idx1 in range(2 , 0, -1):
99 builder.PrependInt32(d_a[_idx0-1][_idx1-1])
Austin Schuh272c6132020-11-14 16:37:52 -0800100 builder.Pad(7)
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700101 builder.PrependInt8(c)
102 for _idx0 in range(15 , 0, -1):
103 builder.PrependInt32(b[_idx0-1])
104 builder.PrependFloat32(a)
105 return builder.Offset()
Austin Schuh272c6132020-11-14 16:37:52 -0800106
107import MyGame.Example.NestedStruct
108try:
109 from typing import List
110except:
111 pass
112
113class ArrayStructT(object):
114
115 # ArrayStructT
116 def __init__(self):
117 self.a = 0.0 # type: float
118 self.b = None # type: List[int]
119 self.c = 0 # type: int
120 self.d = None # type: List[MyGame.Example.NestedStruct.NestedStructT]
121 self.e = 0 # type: int
122 self.f = None # type: List[int]
123
124 @classmethod
125 def InitFromBuf(cls, buf, pos):
126 arrayStruct = ArrayStruct()
127 arrayStruct.Init(buf, pos)
128 return cls.InitFromObj(arrayStruct)
129
130 @classmethod
James Kuszmaul3b15b0c2022-11-08 14:03:16 -0800131 def InitFromPackedBuf(cls, buf, pos=0):
132 n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
133 return cls.InitFromBuf(buf, pos+n)
134
135 @classmethod
Austin Schuh272c6132020-11-14 16:37:52 -0800136 def InitFromObj(cls, arrayStruct):
137 x = ArrayStructT()
138 x._UnPack(arrayStruct)
139 return x
140
141 # ArrayStructT
142 def _UnPack(self, arrayStruct):
143 if arrayStruct is None:
144 return
145 self.a = arrayStruct.A()
146 if not arrayStruct.BIsNone():
147 if np is None:
148 self.b = []
149 for i in range(arrayStruct.BLength()):
150 self.b.append(arrayStruct.B(i))
151 else:
152 self.b = arrayStruct.BAsNumpy()
153 self.c = arrayStruct.C()
154 if not arrayStruct.DIsNone():
155 self.d = []
156 for i in range(arrayStruct.DLength()):
James Kuszmaul3b15b0c2022-11-08 14:03:16 -0800157 if arrayStruct.D(i) is None:
158 self.d.append(None)
159 else:
160 nestedStruct_ = MyGame.Example.NestedStruct.NestedStructT.InitFromObj(arrayStruct.D(i))
161 self.d.append(nestedStruct_)
Austin Schuh272c6132020-11-14 16:37:52 -0800162 self.e = arrayStruct.E()
163 if not arrayStruct.FIsNone():
164 if np is None:
165 self.f = []
166 for i in range(arrayStruct.FLength()):
167 self.f.append(arrayStruct.F(i))
168 else:
169 self.f = arrayStruct.FAsNumpy()
170
171 # ArrayStructT
172 def Pack(self, builder):
173 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)