[Lua] GetRootAs can accept strings. Made Luatest Benchmarks optional (#6593)

This commit is contained in:
Derek Bailey
2021-04-27 13:02:13 -07:00
committed by GitHub
parent 16836ff95a
commit 14725d6c3b
13 changed files with 71 additions and 0 deletions

View File

@@ -14,6 +14,9 @@ function Monster.New()
return o
end
function Monster.GetRootAsMonster(buf, offset)
if type(buf) == "string" then
buf = flatbuffers.binaryArray.New(buf)
end
local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)
local o = Monster.New()
o:Init(buf, n + offset)

View File

@@ -13,6 +13,9 @@ function Referrable.New()
return o
end
function Referrable.GetRootAsReferrable(buf, offset)
if type(buf) == "string" then
buf = flatbuffers.binaryArray.New(buf)
end
local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)
local o = Referrable.New()
o:Init(buf, n + offset)

View File

@@ -13,6 +13,9 @@ function Stat.New()
return o
end
function Stat.GetRootAsStat(buf, offset)
if type(buf) == "string" then
buf = flatbuffers.binaryArray.New(buf)
end
local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)
local o = Stat.New()
o:Init(buf, n + offset)

View File

@@ -13,6 +13,9 @@ function TestSimpleTableWithEnum.New()
return o
end
function TestSimpleTableWithEnum.GetRootAsTestSimpleTableWithEnum(buf, offset)
if type(buf) == "string" then
buf = flatbuffers.binaryArray.New(buf)
end
local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)
local o = TestSimpleTableWithEnum.New()
o:Init(buf, n + offset)

View File

@@ -13,6 +13,9 @@ function TypeAliases.New()
return o
end
function TypeAliases.GetRootAsTypeAliases(buf, offset)
if type(buf) == "string" then
buf = flatbuffers.binaryArray.New(buf)
end
local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)
local o = TypeAliases.New()
o:Init(buf, n + offset)