diff options
author | Richard A Hofer <rofer@google.com> | 2020-12-14 15:00:28 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-14 12:00:28 -0800 |
commit | f8b203c9c4bec53cb9abceef6bc333a02f272b6b (patch) | |
tree | e31a0b93d9b682574dac49652b75c193c8070ea5 /tests/MyGame/Example/Monster.py | |
parent | 8ab7c7e2c82c168e6ce019f7b538350e3a1528dc (diff) | |
download | flatbuffers-f8b203c9c4bec53cb9abceef6bc333a02f272b6b.tar.gz flatbuffers-f8b203c9c4bec53cb9abceef6bc333a02f272b6b.tar.bz2 flatbuffers-f8b203c9c4bec53cb9abceef6bc333a02f272b6b.zip |
Add vectorNumElements attribute to Builder for simpler vector creation. (#6328)
* Add vectorNumElements attribute to Builder for simpler vector creation.
This adds a default to EndVector which should simplify its use.
* Update tutorial to reflect new default arg in Python EndVector.
* Remove optional argument to Python EndVector.
* Add generated files.
* Unset Builder.vectorNumElems when not in use.
Diffstat (limited to 'tests/MyGame/Example/Monster.py')
-rw-r--r-- | tests/MyGame/Example/Monster.py | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/tests/MyGame/Example/Monster.py b/tests/MyGame/Example/Monster.py index 0d2e966d..0ac5cd46 100644 --- a/tests/MyGame/Example/Monster.py +++ b/tests/MyGame/Example/Monster.py @@ -1082,14 +1082,14 @@ class MonsterT(object): MonsterStartInventoryVector(builder, len(self.inventory)) for i in reversed(range(len(self.inventory))): builder.PrependUint8(self.inventory[i]) - inventory = builder.EndVector(len(self.inventory)) + inventory = builder.EndVector() if self.test is not None: test = self.test.Pack(builder) if self.test4 is not None: MonsterStartTest4Vector(builder, len(self.test4)) for i in reversed(range(len(self.test4))): self.test4[i].Pack(builder) - test4 = builder.EndVector(len(self.test4)) + test4 = builder.EndVector() if self.testarrayofstring is not None: testarrayofstringlist = [] for i in range(len(self.testarrayofstring)): @@ -1097,7 +1097,7 @@ class MonsterT(object): MonsterStartTestarrayofstringVector(builder, len(self.testarrayofstring)) for i in reversed(range(len(self.testarrayofstring))): builder.PrependUOffsetTRelative(testarrayofstringlist[i]) - testarrayofstring = builder.EndVector(len(self.testarrayofstring)) + testarrayofstring = builder.EndVector() if self.testarrayoftables is not None: testarrayoftableslist = [] for i in range(len(self.testarrayoftables)): @@ -1105,7 +1105,7 @@ class MonsterT(object): MonsterStartTestarrayoftablesVector(builder, len(self.testarrayoftables)) for i in reversed(range(len(self.testarrayoftables))): builder.PrependUOffsetTRelative(testarrayoftableslist[i]) - testarrayoftables = builder.EndVector(len(self.testarrayoftables)) + testarrayoftables = builder.EndVector() if self.enemy is not None: enemy = self.enemy.Pack(builder) if self.testnestedflatbuffer is not None: @@ -1115,7 +1115,7 @@ class MonsterT(object): MonsterStartTestnestedflatbufferVector(builder, len(self.testnestedflatbuffer)) for i in reversed(range(len(self.testnestedflatbuffer))): builder.PrependUint8(self.testnestedflatbuffer[i]) - testnestedflatbuffer = builder.EndVector(len(self.testnestedflatbuffer)) + testnestedflatbuffer = builder.EndVector() if self.testempty is not None: testempty = self.testempty.Pack(builder) if self.testarrayofbools is not None: @@ -1125,7 +1125,7 @@ class MonsterT(object): MonsterStartTestarrayofboolsVector(builder, len(self.testarrayofbools)) for i in reversed(range(len(self.testarrayofbools))): builder.PrependBool(self.testarrayofbools[i]) - testarrayofbools = builder.EndVector(len(self.testarrayofbools)) + testarrayofbools = builder.EndVector() if self.testarrayofstring2 is not None: testarrayofstring2list = [] for i in range(len(self.testarrayofstring2)): @@ -1133,12 +1133,12 @@ class MonsterT(object): MonsterStartTestarrayofstring2Vector(builder, len(self.testarrayofstring2)) for i in reversed(range(len(self.testarrayofstring2))): builder.PrependUOffsetTRelative(testarrayofstring2list[i]) - testarrayofstring2 = builder.EndVector(len(self.testarrayofstring2)) + testarrayofstring2 = builder.EndVector() if self.testarrayofsortedstruct is not None: MonsterStartTestarrayofsortedstructVector(builder, len(self.testarrayofsortedstruct)) for i in reversed(range(len(self.testarrayofsortedstruct))): self.testarrayofsortedstruct[i].Pack(builder) - testarrayofsortedstruct = builder.EndVector(len(self.testarrayofsortedstruct)) + testarrayofsortedstruct = builder.EndVector() if self.flex is not None: if np is not None and type(self.flex) is np.ndarray: flex = builder.CreateNumpyVector(self.flex) @@ -1146,12 +1146,12 @@ class MonsterT(object): MonsterStartFlexVector(builder, len(self.flex)) for i in reversed(range(len(self.flex))): builder.PrependUint8(self.flex[i]) - flex = builder.EndVector(len(self.flex)) + flex = builder.EndVector() if self.test5 is not None: MonsterStartTest5Vector(builder, len(self.test5)) for i in reversed(range(len(self.test5))): self.test5[i].Pack(builder) - test5 = builder.EndVector(len(self.test5)) + test5 = builder.EndVector() if self.vectorOfLongs is not None: if np is not None and type(self.vectorOfLongs) is np.ndarray: vectorOfLongs = builder.CreateNumpyVector(self.vectorOfLongs) @@ -1159,7 +1159,7 @@ class MonsterT(object): MonsterStartVectorOfLongsVector(builder, len(self.vectorOfLongs)) for i in reversed(range(len(self.vectorOfLongs))): builder.PrependInt64(self.vectorOfLongs[i]) - vectorOfLongs = builder.EndVector(len(self.vectorOfLongs)) + vectorOfLongs = builder.EndVector() if self.vectorOfDoubles is not None: if np is not None and type(self.vectorOfDoubles) is np.ndarray: vectorOfDoubles = builder.CreateNumpyVector(self.vectorOfDoubles) @@ -1167,7 +1167,7 @@ class MonsterT(object): MonsterStartVectorOfDoublesVector(builder, len(self.vectorOfDoubles)) for i in reversed(range(len(self.vectorOfDoubles))): builder.PrependFloat64(self.vectorOfDoubles[i]) - vectorOfDoubles = builder.EndVector(len(self.vectorOfDoubles)) + vectorOfDoubles = builder.EndVector() if self.parentNamespaceTest is not None: parentNamespaceTest = self.parentNamespaceTest.Pack(builder) if self.vectorOfReferrables is not None: @@ -1177,7 +1177,7 @@ class MonsterT(object): MonsterStartVectorOfReferrablesVector(builder, len(self.vectorOfReferrables)) for i in reversed(range(len(self.vectorOfReferrables))): builder.PrependUOffsetTRelative(vectorOfReferrableslist[i]) - vectorOfReferrables = builder.EndVector(len(self.vectorOfReferrables)) + vectorOfReferrables = builder.EndVector() if self.vectorOfWeakReferences is not None: if np is not None and type(self.vectorOfWeakReferences) is np.ndarray: vectorOfWeakReferences = builder.CreateNumpyVector(self.vectorOfWeakReferences) @@ -1185,7 +1185,7 @@ class MonsterT(object): MonsterStartVectorOfWeakReferencesVector(builder, len(self.vectorOfWeakReferences)) for i in reversed(range(len(self.vectorOfWeakReferences))): builder.PrependUint64(self.vectorOfWeakReferences[i]) - vectorOfWeakReferences = builder.EndVector(len(self.vectorOfWeakReferences)) + vectorOfWeakReferences = builder.EndVector() if self.vectorOfStrongReferrables is not None: vectorOfStrongReferrableslist = [] for i in range(len(self.vectorOfStrongReferrables)): @@ -1193,7 +1193,7 @@ class MonsterT(object): MonsterStartVectorOfStrongReferrablesVector(builder, len(self.vectorOfStrongReferrables)) for i in reversed(range(len(self.vectorOfStrongReferrables))): builder.PrependUOffsetTRelative(vectorOfStrongReferrableslist[i]) - vectorOfStrongReferrables = builder.EndVector(len(self.vectorOfStrongReferrables)) + vectorOfStrongReferrables = builder.EndVector() if self.vectorOfCoOwningReferences is not None: if np is not None and type(self.vectorOfCoOwningReferences) is np.ndarray: vectorOfCoOwningReferences = builder.CreateNumpyVector(self.vectorOfCoOwningReferences) @@ -1201,7 +1201,7 @@ class MonsterT(object): MonsterStartVectorOfCoOwningReferencesVector(builder, len(self.vectorOfCoOwningReferences)) for i in reversed(range(len(self.vectorOfCoOwningReferences))): builder.PrependUint64(self.vectorOfCoOwningReferences[i]) - vectorOfCoOwningReferences = builder.EndVector(len(self.vectorOfCoOwningReferences)) + vectorOfCoOwningReferences = builder.EndVector() if self.vectorOfNonOwningReferences is not None: if np is not None and type(self.vectorOfNonOwningReferences) is np.ndarray: vectorOfNonOwningReferences = builder.CreateNumpyVector(self.vectorOfNonOwningReferences) @@ -1209,7 +1209,7 @@ class MonsterT(object): MonsterStartVectorOfNonOwningReferencesVector(builder, len(self.vectorOfNonOwningReferences)) for i in reversed(range(len(self.vectorOfNonOwningReferences))): builder.PrependUint64(self.vectorOfNonOwningReferences[i]) - vectorOfNonOwningReferences = builder.EndVector(len(self.vectorOfNonOwningReferences)) + vectorOfNonOwningReferences = builder.EndVector() if self.anyUnique is not None: anyUnique = self.anyUnique.Pack(builder) if self.anyAmbiguous is not None: @@ -1221,7 +1221,7 @@ class MonsterT(object): MonsterStartVectorOfEnumsVector(builder, len(self.vectorOfEnums)) for i in reversed(range(len(self.vectorOfEnums))): builder.PrependUint8(self.vectorOfEnums[i]) - vectorOfEnums = builder.EndVector(len(self.vectorOfEnums)) + vectorOfEnums = builder.EndVector() if self.testrequirednestedflatbuffer is not None: if np is not None and type(self.testrequirednestedflatbuffer) is np.ndarray: testrequirednestedflatbuffer = builder.CreateNumpyVector(self.testrequirednestedflatbuffer) @@ -1229,7 +1229,7 @@ class MonsterT(object): MonsterStartTestrequirednestedflatbufferVector(builder, len(self.testrequirednestedflatbuffer)) for i in reversed(range(len(self.testrequirednestedflatbuffer))): builder.PrependUint8(self.testrequirednestedflatbuffer[i]) - testrequirednestedflatbuffer = builder.EndVector(len(self.testrequirednestedflatbuffer)) + testrequirednestedflatbuffer = builder.EndVector() MonsterStart(builder) if self.pos is not None: pos = self.pos.Pack(builder) |