Fix Python min alignment

This was accidentally deleted in:
9fa8245e81

Change-Id: I8cad721e075279f6a67aca81259f73fb75aba482
This commit is contained in:
Wouter van Oortmerssen 2020-03-09 16:43:43 -07:00
parent 5a98d65e86
commit 89b6183ee9
1 changed files with 10 additions and 3 deletions

View File

@ -466,7 +466,7 @@ class Builder(object):
# tobytes ensures c_contiguous ordering # tobytes ensures c_contiguous ordering
self.Bytes[self.Head():self.Head()+l] = x_lend.tobytes(order='C') self.Bytes[self.Head():self.Head()+l] = x_lend.tobytes(order='C')
return self.EndVector(x.size) return self.EndVector(x.size)
## @cond FLATBUFFERS_INTERNAL ## @cond FLATBUFFERS_INTERNAL
@ -514,9 +514,16 @@ class Builder(object):
"""Finish finalizes a buffer, pointing to the given `rootTable`.""" """Finish finalizes a buffer, pointing to the given `rootTable`."""
N.enforce_number(rootTable, N.UOffsetTFlags) N.enforce_number(rootTable, N.UOffsetTFlags)
prepSize = N.UOffsetTFlags.bytewidth
if file_identifier is not None:
prepSize += N.Int32Flags.bytewidth
if sizePrefix:
prepSize += N.Int32Flags.bytewidth
self.Prep(self.minalign, prepSize)
if file_identifier is not None: if file_identifier is not None:
self.Prep(N.UOffsetTFlags.bytewidth, encode.FILE_IDENTIFIER_LENGTH) self.Prep(N.UOffsetTFlags.bytewidth, encode.FILE_IDENTIFIER_LENGTH)
# Convert bytes object file_identifier to an array of 4 8-bit integers, # Convert bytes object file_identifier to an array of 4 8-bit integers,
# and use big-endian to enforce size compliance. # and use big-endian to enforce size compliance.
# https://docs.python.org/2/library/struct.html#format-characters # https://docs.python.org/2/library/struct.html#format-characters
@ -524,7 +531,7 @@ class Builder(object):
for i in range(encode.FILE_IDENTIFIER_LENGTH-1, -1, -1): for i in range(encode.FILE_IDENTIFIER_LENGTH-1, -1, -1):
# Place the bytes of the file_identifer in reverse order: # Place the bytes of the file_identifer in reverse order:
self.Place(file_identifier[i], N.Uint8Flags) self.Place(file_identifier[i], N.Uint8Flags)
self.PrependUOffsetTRelative(rootTable) self.PrependUOffsetTRelative(rootTable)
if sizePrefix: if sizePrefix:
size = len(self.Bytes) - self.Head() size = len(self.Bytes) - self.Head()