blob: 7f8d18ef196d7177a142eaf8e72eca4d7ad241ae [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 NestedStruct(object):
10 __slots__ = ['_tab']
11
Austin Schuh272c6132020-11-14 16:37:52 -080012 @classmethod
13 def SizeOf(cls):
14 return 32
15
Austin Schuhe89fa2d2019-08-14 20:24:23 -070016 # NestedStruct
17 def Init(self, buf, pos):
18 self._tab = flatbuffers.table.Table(buf, pos)
19
20 # NestedStruct
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080021 def A(self, j = None):
22 if j is None:
23 return [self._tab.Get(flatbuffers.number_types.Int32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(0 + i * 4)) for i in range(self.ALength())]
24 elif j >= 0 and j < self.ALength():
25 return self._tab.Get(flatbuffers.number_types.Int32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(0 + j * 4))
26 else:
27 return None
28
29 # NestedStruct
30 def AAsNumpy(self):
31 return self._tab.GetArrayAsNumpy(flatbuffers.number_types.Int32Flags, self._tab.Pos + 0, self.ALength())
32
Austin Schuhe89fa2d2019-08-14 20:24:23 -070033 # NestedStruct
Austin Schuh272c6132020-11-14 16:37:52 -080034 def ALength(self):
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080035 return 2
Austin Schuh272c6132020-11-14 16:37:52 -080036
37 # NestedStruct
38 def AIsNone(self):
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080039 return False
Austin Schuh272c6132020-11-14 16:37:52 -080040
41 # NestedStruct
Austin Schuhe89fa2d2019-08-14 20:24:23 -070042 def B(self): return self._tab.Get(flatbuffers.number_types.Int8Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(8))
43 # NestedStruct
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080044 def C(self, j = None):
45 if j is None:
46 return [self._tab.Get(flatbuffers.number_types.Int8Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(9 + i * 1)) for i in range(self.CLength())]
47 elif j >= 0 and j < self.CLength():
48 return self._tab.Get(flatbuffers.number_types.Int8Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(9 + j * 1))
49 else:
50 return None
51
52 # NestedStruct
53 def CAsNumpy(self):
54 return self._tab.GetArrayAsNumpy(flatbuffers.number_types.Int8Flags, self._tab.Pos + 9, self.CLength())
55
Austin Schuh272c6132020-11-14 16:37:52 -080056 # NestedStruct
57 def CLength(self):
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080058 return 2
Austin Schuhe89fa2d2019-08-14 20:24:23 -070059
Austin Schuh272c6132020-11-14 16:37:52 -080060 # NestedStruct
61 def CIsNone(self):
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080062 return False
Austin Schuh272c6132020-11-14 16:37:52 -080063
64 # NestedStruct
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080065 def D(self, j = None):
66 if j is None:
67 return [self._tab.Get(flatbuffers.number_types.Int64Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(16 + i * 8)) for i in range(self.DLength())]
68 elif j >= 0 and j < self.DLength():
69 return self._tab.Get(flatbuffers.number_types.Int64Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(16 + j * 8))
70 else:
71 return None
72
73 # NestedStruct
74 def DAsNumpy(self):
75 return self._tab.GetArrayAsNumpy(flatbuffers.number_types.Int64Flags, self._tab.Pos + 16, self.DLength())
76
Austin Schuh272c6132020-11-14 16:37:52 -080077 # NestedStruct
78 def DLength(self):
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080079 return 2
Austin Schuh272c6132020-11-14 16:37:52 -080080
81 # NestedStruct
82 def DIsNone(self):
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080083 return False
Austin Schuh272c6132020-11-14 16:37:52 -080084
85
86def CreateNestedStruct(builder, a, b, c, d):
87 builder.Prep(8, 32)
88 for _idx0 in range(2 , 0, -1):
89 builder.PrependInt64(d[_idx0-1])
90 builder.Pad(5)
Austin Schuhe89fa2d2019-08-14 20:24:23 -070091 for _idx0 in range(2 , 0, -1):
92 builder.PrependInt8(c[_idx0-1])
93 builder.PrependInt8(b)
94 for _idx0 in range(2 , 0, -1):
95 builder.PrependInt32(a[_idx0-1])
96 return builder.Offset()
Austin Schuh272c6132020-11-14 16:37:52 -080097
98try:
99 from typing import List
100except:
101 pass
102
103class NestedStructT(object):
104
105 # NestedStructT
106 def __init__(self):
107 self.a = None # type: List[int]
108 self.b = 0 # type: int
109 self.c = None # type: List[int]
110 self.d = None # type: List[int]
111
112 @classmethod
113 def InitFromBuf(cls, buf, pos):
114 nestedStruct = NestedStruct()
115 nestedStruct.Init(buf, pos)
116 return cls.InitFromObj(nestedStruct)
117
118 @classmethod
James Kuszmaul3b15b0c2022-11-08 14:03:16 -0800119 def InitFromPackedBuf(cls, buf, pos=0):
120 n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
121 return cls.InitFromBuf(buf, pos+n)
122
123 @classmethod
Austin Schuh272c6132020-11-14 16:37:52 -0800124 def InitFromObj(cls, nestedStruct):
125 x = NestedStructT()
126 x._UnPack(nestedStruct)
127 return x
128
129 # NestedStructT
130 def _UnPack(self, nestedStruct):
131 if nestedStruct is None:
132 return
133 if not nestedStruct.AIsNone():
134 if np is None:
135 self.a = []
136 for i in range(nestedStruct.ALength()):
137 self.a.append(nestedStruct.A(i))
138 else:
139 self.a = nestedStruct.AAsNumpy()
140 self.b = nestedStruct.B()
141 if not nestedStruct.CIsNone():
142 if np is None:
143 self.c = []
144 for i in range(nestedStruct.CLength()):
145 self.c.append(nestedStruct.C(i))
146 else:
147 self.c = nestedStruct.CAsNumpy()
148 if not nestedStruct.DIsNone():
149 if np is None:
150 self.d = []
151 for i in range(nestedStruct.DLength()):
152 self.d.append(nestedStruct.D(i))
153 else:
154 self.d = nestedStruct.DAsNumpy()
155
156 # NestedStructT
157 def Pack(self, builder):
158 return CreateNestedStruct(builder, self.a, self.b, self.c, self.d)