mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-06 13:37:25 +00:00
Fixed LuaJIT when not compiled with COMPAT mode (#6605)
LuaJIT as installed by apt doesn't include the COMPAT mode for using Lua5.2 features. So this change just makes the flatbuffer code use a common implementation.
This commit is contained in:
@@ -70,7 +70,7 @@ function mt:Clear()
|
||||
self.minalign = 1
|
||||
self.currentVTable = nil
|
||||
self.objectEnd = nil
|
||||
self.head = #self.bytes -- place the head at the end of the binary array
|
||||
self.head = self.bytes.size -- place the head at the end of the binary array
|
||||
|
||||
-- clear vtables instead of making a new table
|
||||
local vtable = self.vtables
|
||||
@@ -118,7 +118,7 @@ function mt:WriteVtable()
|
||||
while i >= 1 do
|
||||
|
||||
local vt2Offset = self.vtables[i]
|
||||
local vt2Start = #self.bytes - vt2Offset
|
||||
local vt2Start = self.bytes.size - vt2Offset
|
||||
local vt2lenstr = self.bytes:Slice(vt2Start, vt2Start+1)
|
||||
local vt2Len = string_unpack(VOffsetT.packFmt, vt2lenstr, 1)
|
||||
|
||||
@@ -154,12 +154,12 @@ function mt:WriteVtable()
|
||||
vBytes = vBytes * 2
|
||||
self:PrependVOffsetT(vBytes)
|
||||
|
||||
local objectStart = #self.bytes - objectOffset
|
||||
local objectStart = self.bytes.size - objectOffset
|
||||
self.bytes:Set(SOffsetT:Pack(self:Offset() - objectOffset),objectStart)
|
||||
|
||||
table.insert(self.vtables, self:Offset())
|
||||
else
|
||||
local objectStart = #self.bytes - objectOffset
|
||||
local objectStart = self.bytes.size - objectOffset
|
||||
self.head = objectStart
|
||||
self.bytes:Set(SOffsetT:Pack(exisitingVTable - objectOffset),self.head)
|
||||
end
|
||||
@@ -175,7 +175,7 @@ function mt:EndObject()
|
||||
end
|
||||
|
||||
local function growByteBuffer(self, desiredSize)
|
||||
local s = #self.bytes
|
||||
local s = self.bytes.size
|
||||
assert(s < MAX_BUFFER_SIZE, "Flat Buffers cannot grow buffer beyond 2 gigabytes")
|
||||
local newsize = s
|
||||
repeat
|
||||
@@ -191,7 +191,7 @@ function mt:Head()
|
||||
end
|
||||
|
||||
function mt:Offset()
|
||||
return #self.bytes - self.head
|
||||
return self.bytes.size - self.head
|
||||
end
|
||||
|
||||
function mt:Pad(n)
|
||||
@@ -210,15 +210,15 @@ function mt:Prep(size, additionalBytes)
|
||||
|
||||
local h = self.head
|
||||
|
||||
local k = #self.bytes - h + additionalBytes
|
||||
local k = self.bytes.size - h + additionalBytes
|
||||
local alignsize = getAlignSize(k, size)
|
||||
|
||||
local desiredSize = alignsize + size + additionalBytes
|
||||
|
||||
while self.head < desiredSize do
|
||||
local oldBufSize = #self.bytes
|
||||
local oldBufSize = self.bytes.size
|
||||
growByteBuffer(self, desiredSize)
|
||||
local updatedHead = self.head + #self.bytes - oldBufSize
|
||||
local updatedHead = self.head + self.bytes.size - oldBufSize
|
||||
self.head = updatedHead
|
||||
end
|
||||
|
||||
@@ -301,7 +301,7 @@ local function finish(self, rootTable, sizePrefix)
|
||||
self:Prep(self.minalign, sizePrefix and 8 or 4)
|
||||
self:PrependUOffsetTRelative(rootTable)
|
||||
if sizePrefix then
|
||||
local size = #self.bytes - self.head
|
||||
local size = self.bytes.size - self.head
|
||||
Int32:EnforceNumber(size)
|
||||
self:PrependInt32(size)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user