mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-06 05:27:24 +00:00
Fixed vectors of enums in object API serialized incorrectly.
And also added tests for them. Change-Id: I91af1904105435601287291412e82d5066f476a5 Tested: on Linux.
This commit is contained in:
@@ -507,7 +507,22 @@ function Monster_mt:AnyAmbiguous()
|
||||
return obj
|
||||
end
|
||||
end
|
||||
function Monster.Start(builder) builder:StartObject(47) end
|
||||
function Monster_mt:VectorOfEnums(j)
|
||||
local o = self.view:Offset(98)
|
||||
if o ~= 0 then
|
||||
local a = self.view:Vector(o)
|
||||
return self.view:Get(flatbuffers.N.Int8, a + ((j-1) * 1))
|
||||
end
|
||||
return 0
|
||||
end
|
||||
function Monster_mt:VectorOfEnumsLength()
|
||||
local o = self.view:Offset(98)
|
||||
if o ~= 0 then
|
||||
return self.view:VectorLen(o)
|
||||
end
|
||||
return 0
|
||||
end
|
||||
function Monster.Start(builder) builder:StartObject(48) end
|
||||
function Monster.AddPos(builder, pos) builder:PrependStructSlot(0, pos, 0) end
|
||||
function Monster.AddMana(builder, mana) builder:PrependInt16Slot(1, mana, 150) end
|
||||
function Monster.AddHp(builder, hp) builder:PrependInt16Slot(2, hp, 100) end
|
||||
@@ -571,6 +586,8 @@ function Monster.AddAnyUniqueType(builder, anyUniqueType) builder:PrependUint8Sl
|
||||
function Monster.AddAnyUnique(builder, anyUnique) builder:PrependUOffsetTRelativeSlot(44, anyUnique, 0) end
|
||||
function Monster.AddAnyAmbiguousType(builder, anyAmbiguousType) builder:PrependUint8Slot(45, anyAmbiguousType, 0) end
|
||||
function Monster.AddAnyAmbiguous(builder, anyAmbiguous) builder:PrependUOffsetTRelativeSlot(46, anyAmbiguous, 0) end
|
||||
function Monster.AddVectorOfEnums(builder, vectorOfEnums) builder:PrependUOffsetTRelativeSlot(47, vectorOfEnums, 0) end
|
||||
function Monster.StartVectorOfEnumsVector(builder, numElems) return builder:StartVector(1, numElems, 1) end
|
||||
function Monster.End(builder) return builder:EndObject() end
|
||||
|
||||
return Monster -- return the module
|
||||
Reference in New Issue
Block a user