Support size-prefixed buffers and add tests for size-prefixed messages (#6232)

This commit is contained in:
Charlie Yin
2020-11-05 11:23:56 -08:00
committed by GitHub
parent fba93e0abb
commit c9b29d0885
15 changed files with 232 additions and 32 deletions

View File

@@ -36,6 +36,13 @@ func GetRootAsMonster(buf []byte, offset flatbuffers.UOffsetT) *Monster {
return x
}
func GetSizePrefixedRootAsMonster(buf []byte, offset flatbuffers.UOffsetT) *Monster {
n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:])
x := &Monster{}
x.Init(buf, n+offset+flatbuffers.SizeUint32)
return x
}
func (rcv *Monster) Init(buf []byte, i flatbuffers.UOffsetT) {
rcv._tab.Bytes = buf
rcv._tab.Pos = i