Add vectorNumElements attribute to Builder for simpler vector creation. (#6328)
authorRichard A Hofer <rofer@google.com>
Mon, 14 Dec 2020 20:00:28 +0000 (15:00 -0500)
committerGitHub <noreply@github.com>
Mon, 14 Dec 2020 20:00:28 +0000 (12:00 -0800)
* 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.

docs/source/Tutorial.md
python/flatbuffers/builder.py
src/idl_gen_python.cpp
tests/MyGame/Example/Monster.py
tests/MyGame/Example/TypeAliases.py
tests/MyGame/MonsterExtra.py
tests/py_test.py

index 419ea09..f3f03f5 100644 (file)
@@ -1017,7 +1017,7 @@ traversal. This is generally easy to do on any tree structures.
   MyGame.Sample.Monster.MonsterStartInventoryVector(builder, 10)
   for i in reversed(range(0, 10)):
     builder.PrependByte(i)
-  inv = builder.EndVector(10)
+  inv = builder.EndVector()
 ~~~
 </div>
 <div class="language-javascript">
@@ -1207,7 +1207,7 @@ offsets.
   MyGame.Sample.Monster.MonsterStartWeaponsVector(builder, 2)
   builder.PrependUOffsetTRelative(axe)
   builder.PrependUOffsetTRelative(sword)
-  weapons = builder.EndVector(2)
+  weapons = builder.EndVector()
 ~~~
 </div>
 <div class="language-javascript">
@@ -1336,7 +1336,7 @@ for the `path` field above:
   MyGame.Sample.Monster.MonsterStartPathVector(builder, 2)
   MyGame.Sample.Vec3.CreateVec3(builder, 1.0, 2.0, 3.0)
   MyGame.Sample.Vec3.CreateVec3(builder, 4.0, 5.0, 6.0)
-  path = builder.EndVector(2)
+  path = builder.EndVector()
 ~~~
 </div>
 <div class="language-javascript">
index c5978bd..3f0cf4e 100644 (file)
@@ -103,7 +103,7 @@ class Builder(object):
 
     ## @cond FLATBUFFERS_INTENRAL
     __slots__ = ("Bytes", "current_vtable", "head", "minalign", "objectEnd",
-                 "vtables", "nested", "forceDefaults", "finished")
+                 "vtables", "nested", "forceDefaults", "finished", "vectorNumElems")
 
     """Maximum buffer size constant, in bytes.
 
@@ -371,12 +371,13 @@ class Builder(object):
 
         self.assertNotNested()
         self.nested = True
+        self.vectorNumElems = numElems
         self.Prep(N.Uint32Flags.bytewidth, elemSize*numElems)
         self.Prep(alignment, elemSize*numElems)  # In case alignment > int.
         return self.Offset()
     ## @endcond
 
-    def EndVector(self, vectorNumElems):
+    def EndVector(self):
         """EndVector writes data necessary to finish vector construction."""
 
         self.assertNested()
@@ -384,7 +385,8 @@ class Builder(object):
         self.nested = False
         ## @endcond
         # we already made space for this, so write without PrependUint32
-        self.PlaceUOffsetT(vectorNumElems)
+        self.PlaceUOffsetT(self.vectorNumElems)
+        self.vectorNumElems = None
         return self.Offset()
 
     def CreateString(self, s, encoding='utf-8', errors='strict'):
@@ -411,7 +413,8 @@ class Builder(object):
         ## @endcond
         self.Bytes[self.Head():self.Head()+l] = x
 
-        return self.EndVector(len(x))
+        self.vectorNumElems = len(x)
+        return self.EndVector()
 
     def CreateByteVector(self, x):
         """CreateString writes a byte vector."""
@@ -432,7 +435,8 @@ class Builder(object):
         ## @endcond
         self.Bytes[self.Head():self.Head()+l] = x
 
-        return self.EndVector(len(x))
+        self.vectorNumElems = len(x)
+        return self.EndVector()
 
     def CreateNumpyVector(self, x):
         """CreateNumpyVector writes a numpy array into the buffer."""
@@ -467,7 +471,8 @@ class Builder(object):
         # tobytes ensures c_contiguous ordering
         self.Bytes[self.Head():self.Head()+l] = x_lend.tobytes(order='C')
 
-        return self.EndVector(x.size)
+        self.vectorNumElems = x.size
+        return self.EndVector()
 
     ## @cond FLATBUFFERS_INTERNAL
     def assertNested(self):
index 70790a5..43290d3 100644 (file)
@@ -1178,9 +1178,7 @@ class PythonGenerator : public BaseGenerator {
                      field_instance_name + "))):";
       code_prefix +=
           GenIndents(4) + "self." + field_instance_name + "[i].Pack(builder)";
-      code_prefix += GenIndents(3) + field_instance_name +
-                     " = builder.EndVector(len(self." + field_instance_name +
-                     "))";
+      code_prefix += GenIndents(3) + field_instance_name + " = builder.EndVector()";
     } else {
       // If the vector is a struct vector, we need to first build accessor for
       // each struct element.
@@ -1197,9 +1195,7 @@ class PythonGenerator : public BaseGenerator {
                      field_instance_name + "))):";
       code_prefix += GenIndents(4) + "builder.PrependUOffsetTRelative" + "(" +
                      field_instance_name + "list[i])";
-      code_prefix += GenIndents(3) + field_instance_name +
-                     " = builder.EndVector(len(self." + field_instance_name +
-                     "))";
+      code_prefix += GenIndents(3) + field_instance_name + " = builder.EndVector()";
     }
 
     // Adds the field into the struct.
@@ -1273,9 +1269,7 @@ class PythonGenerator : public BaseGenerator {
                      field_instance_name + "[i]))";
       GenPackForScalarVectorFieldHelper(struct_def, field, code_prefix_ptr, 3);
       code_prefix += "(" + MakeLowerCamel(field) + "list[i])";
-      code_prefix += GenIndents(3) + field_instance_name +
-                     " = builder.EndVector(len(self." + field_instance_name +
-                     "))";
+      code_prefix += GenIndents(3) + field_instance_name + " = builder.EndVector()";
       return;
     }
 
@@ -1287,9 +1281,7 @@ class PythonGenerator : public BaseGenerator {
     code_prefix += GenIndents(3) + "else:";
     GenPackForScalarVectorFieldHelper(struct_def, field, code_prefix_ptr, 4);
     code_prefix += "(self." + field_instance_name + "[i])";
-    code_prefix += GenIndents(4) + field_instance_name +
-                   " = builder.EndVector(len(self." + field_instance_name +
-                   "))";
+    code_prefix += GenIndents(4) + field_instance_name + " = builder.EndVector()";
   }
 
   void GenPackForStructField(const StructDef &struct_def, const FieldDef &field,
index 0d2e966..0ac5cd4 100644 (file)
@@ -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)
index 239b274..5eb352c 100644 (file)
@@ -237,7 +237,7 @@ class TypeAliasesT(object):
                 TypeAliasesStartV8Vector(builder, len(self.v8))
                 for i in reversed(range(len(self.v8))):
                     builder.PrependByte(self.v8[i])
-                v8 = builder.EndVector(len(self.v8))
+                v8 = builder.EndVector()
         if self.vf64 is not None:
             if np is not None and type(self.vf64) is np.ndarray:
                 vf64 = builder.CreateNumpyVector(self.vf64)
@@ -245,7 +245,7 @@ class TypeAliasesT(object):
                 TypeAliasesStartVf64Vector(builder, len(self.vf64))
                 for i in reversed(range(len(self.vf64))):
                     builder.PrependFloat64(self.vf64[i])
-                vf64 = builder.EndVector(len(self.vf64))
+                vf64 = builder.EndVector()
         TypeAliasesStart(builder)
         TypeAliasesAddI8(builder, self.i8)
         TypeAliasesAddU8(builder, self.u8)
index 48ab461..da7986a 100644 (file)
@@ -217,7 +217,7 @@ class MonsterExtraT(object):
                 MonsterExtraStartDvecVector(builder, len(self.dvec))
                 for i in reversed(range(len(self.dvec))):
                     builder.PrependFloat64(self.dvec[i])
-                dvec = builder.EndVector(len(self.dvec))
+                dvec = builder.EndVector()
         if self.fvec is not None:
             if np is not None and type(self.fvec) is np.ndarray:
                 fvec = builder.CreateNumpyVector(self.fvec)
@@ -225,7 +225,7 @@ class MonsterExtraT(object):
                 MonsterExtraStartFvecVector(builder, len(self.fvec))
                 for i in reversed(range(len(self.fvec))):
                     builder.PrependFloat32(self.fvec[i])
-                fvec = builder.EndVector(len(self.fvec))
+                fvec = builder.EndVector()
         MonsterExtraStart(builder)
         MonsterExtraAddD0(builder, self.d0)
         MonsterExtraAddD1(builder, self.d1)
index 9b31f60..4fe17ac 100644 (file)
@@ -860,7 +860,7 @@ class TestByteLayout(unittest.TestCase):
         self.assertBuilderEquals(b, [0, 0, 0]) # align to 4bytes
         b.PrependByte(1)
         self.assertBuilderEquals(b, [1, 0, 0, 0])
-        b.EndVector(1)
+        b.EndVector()
         self.assertBuilderEquals(b, [1, 0, 0, 0, 1, 0, 0, 0]) # padding
 
     def test_2xbyte_vector(self):
@@ -871,7 +871,7 @@ class TestByteLayout(unittest.TestCase):
         self.assertBuilderEquals(b, [1, 0, 0])
         b.PrependByte(2)
         self.assertBuilderEquals(b, [2, 1, 0, 0])
-        b.EndVector(2)
+        b.EndVector()
         self.assertBuilderEquals(b, [2, 0, 0, 0, 2, 1, 0, 0]) # padding
 
     def test_1xuint16_vector(self):
@@ -880,7 +880,7 @@ class TestByteLayout(unittest.TestCase):
         self.assertBuilderEquals(b, [0, 0]) # align to 4bytes
         b.PrependUint16(1)
         self.assertBuilderEquals(b, [1, 0, 0, 0])
-        b.EndVector(1)
+        b.EndVector()
         self.assertBuilderEquals(b, [1, 0, 0, 0, 1, 0, 0, 0]) # padding
 
     def test_2xuint16_vector(self):
@@ -891,7 +891,7 @@ class TestByteLayout(unittest.TestCase):
         self.assertBuilderEquals(b, [0xCD, 0xAB])
         b.PrependUint16(0xDCBA)
         self.assertBuilderEquals(b, [0xBA, 0xDC, 0xCD, 0xAB])
-        b.EndVector(2)
+        b.EndVector()
         self.assertBuilderEquals(b, [2, 0, 0, 0, 0xBA, 0xDC, 0xCD, 0xAB])
 
     def test_create_ascii_string(self):
@@ -1288,7 +1288,7 @@ class TestByteLayout(unittest.TestCase):
     def test_vtable_with_empty_vector(self):
         b = flatbuffers.Builder(0)
         b.StartVector(flatbuffers.number_types.Uint8Flags.bytewidth, 0, 1)
-        vecend = b.EndVector(0)
+        vecend = b.EndVector()
         b.StartObject(1)
         b.PrependUOffsetTRelativeSlot(0, vecend, 0)
         b.EndObject()
@@ -1304,7 +1304,7 @@ class TestByteLayout(unittest.TestCase):
     def test_vtable_with_empty_vector_of_byte_and_some_scalars(self):
         b = flatbuffers.Builder(0)
         b.StartVector(flatbuffers.number_types.Uint8Flags.bytewidth, 0, 1)
-        vecend = b.EndVector(0)
+        vecend = b.EndVector()
         b.StartObject(2)
         b.PrependInt16Slot(0, 55, 0)
         b.PrependUOffsetTRelativeSlot(1, vecend, 0)
@@ -1326,7 +1326,7 @@ class TestByteLayout(unittest.TestCase):
         b.StartVector(flatbuffers.number_types.Int16Flags.bytewidth, 2, 1)
         b.PrependInt16(0x1234)
         b.PrependInt16(0x5678)
-        vecend = b.EndVector(2)
+        vecend = b.EndVector()
         b.StartObject(2)
         b.PrependUOffsetTRelativeSlot(1, vecend, 0)
         b.PrependInt16Slot(0, 55, 0)
@@ -1376,7 +1376,7 @@ class TestByteLayout(unittest.TestCase):
         b.PrependInt8(44)
         b.PrependInt8(55)
         b.PrependInt8(66)
-        vecend = b.EndVector(2)
+        vecend = b.EndVector()
         b.StartObject(1)
         b.PrependUOffsetTRelativeSlot(0, vecend, 0)
         b.EndObject()
@@ -1556,7 +1556,7 @@ def make_monster_from_generated_code(sizePrefix = False, file_identifier=None):
     b.PrependByte(2)
     b.PrependByte(1)
     b.PrependByte(0)
-    inv = b.EndVector(5)
+    inv = b.EndVector()
 
     MyGame.Example.Monster.MonsterStart(b)
     MyGame.Example.Monster.MonsterAddName(b, fred)
@@ -1565,12 +1565,12 @@ def make_monster_from_generated_code(sizePrefix = False, file_identifier=None):
     MyGame.Example.Monster.MonsterStartTest4Vector(b, 2)
     MyGame.Example.Test.CreateTest(b, 10, 20)
     MyGame.Example.Test.CreateTest(b, 30, 40)
-    test4 = b.EndVector(2)
+    test4 = b.EndVector()
 
     MyGame.Example.Monster.MonsterStartTestarrayofstringVector(b, 2)
     b.PrependUOffsetTRelative(test2)
     b.PrependUOffsetTRelative(test1)
-    testArrayOfString = b.EndVector(2)
+    testArrayOfString = b.EndVector()
 
     MyGame.Example.Monster.MonsterStartVectorOfLongsVector(b, 5)
     b.PrependInt64(100000000)
@@ -1578,13 +1578,13 @@ def make_monster_from_generated_code(sizePrefix = False, file_identifier=None):
     b.PrependInt64(10000)
     b.PrependInt64(100)
     b.PrependInt64(1)
-    VectorOfLongs = b.EndVector(5)
+    VectorOfLongs = b.EndVector()
 
     MyGame.Example.Monster.MonsterStartVectorOfDoublesVector(b, 3)
     b.PrependFloat64(1.7976931348623157e+308)
     b.PrependFloat64(0)
     b.PrependFloat64(-1.7976931348623157e+308)
-    VectorOfDoubles = b.EndVector(3)
+    VectorOfDoubles = b.EndVector()
 
     MyGame.Example.Monster.MonsterStart(b)
 
@@ -1687,7 +1687,7 @@ class TestAllCodePathsOfExampleSchema(unittest.TestCase):
     def test_empty_monster_inventory_vector(self):
         b = flatbuffers.Builder(0)
         MyGame.Example.Monster.MonsterStartInventoryVector(b, 0)
-        inv = b.EndVector(0)
+        inv = b.EndVector()
         MyGame.Example.Monster.MonsterStart(b)
         MyGame.Example.Monster.MonsterAddInventory(b, inv)
         mon = MyGame.Example.Monster.MonsterEnd(b)
@@ -1727,7 +1727,7 @@ class TestAllCodePathsOfExampleSchema(unittest.TestCase):
     def test_empty_monster_test4_vector(self):
         b = flatbuffers.Builder(0)
         MyGame.Example.Monster.MonsterStartTest4Vector(b, 0)
-        test4 = b.EndVector(0)
+        test4 = b.EndVector()
         MyGame.Example.Monster.MonsterStart(b)
         MyGame.Example.Monster.MonsterAddTest4(b, test4)
         mon = MyGame.Example.Monster.MonsterEnd(b)
@@ -1746,7 +1746,7 @@ class TestAllCodePathsOfExampleSchema(unittest.TestCase):
     def test_empty_monster_testarrayofstring_vector(self):
         b = flatbuffers.Builder(0)
         MyGame.Example.Monster.MonsterStartTestarrayofstringVector(b, 0)
-        testarrayofstring = b.EndVector(0)
+        testarrayofstring = b.EndVector()
         MyGame.Example.Monster.MonsterStart(b)
         MyGame.Example.Monster.MonsterAddTestarrayofstring(b, testarrayofstring)
         mon = MyGame.Example.Monster.MonsterEnd(b)
@@ -1769,7 +1769,7 @@ class TestAllCodePathsOfExampleSchema(unittest.TestCase):
         # build the vector:
         MyGame.Example.Monster.MonsterStartTestarrayoftablesVector(b, 1)
         b.PrependUOffsetTRelative(sub_monster)
-        vec = b.EndVector(1)
+        vec = b.EndVector()
 
         # make the parent monster and include the vector of Monster:
         MyGame.Example.Monster.MonsterStart(b)
@@ -1790,7 +1790,7 @@ class TestAllCodePathsOfExampleSchema(unittest.TestCase):
     def test_empty_monster_testarrayoftables_vector(self):
         b = flatbuffers.Builder(0)
         MyGame.Example.Monster.MonsterStartTestarrayoftablesVector(b, 0)
-        testarrayoftables = b.EndVector(0)
+        testarrayoftables = b.EndVector()
         MyGame.Example.Monster.MonsterStart(b)
         MyGame.Example.Monster.MonsterAddTestarrayoftables(b, testarrayoftables)
         mon = MyGame.Example.Monster.MonsterEnd(b)
@@ -1832,7 +1832,7 @@ class TestAllCodePathsOfExampleSchema(unittest.TestCase):
     def test_empty_monster_testnestedflatbuffer_vector(self):
         b = flatbuffers.Builder(0)
         MyGame.Example.Monster.MonsterStartTestnestedflatbufferVector(b, 0)
-        testnestedflatbuffer = b.EndVector(0)
+        testnestedflatbuffer = b.EndVector()
         MyGame.Example.Monster.MonsterStart(b)
         MyGame.Example.Monster.MonsterAddTestnestedflatbuffer(b, testnestedflatbuffer)
         mon = MyGame.Example.Monster.MonsterEnd(b)
@@ -1848,7 +1848,7 @@ class TestAllCodePathsOfExampleSchema(unittest.TestCase):
         b.PrependByte(4)
         b.PrependByte(2)
         b.PrependByte(0)
-        sub_buf = b.EndVector(3)
+        sub_buf = b.EndVector()
 
         # make the parent monster and include the vector of Monster:
         MyGame.Example.Monster.MonsterStart(b)