summaryrefslogtreecommitdiff
path: root/tests/MyGame/Example
diff options
context:
space:
mode:
authorCharlie Yin <charlieyinjunhao@hotmail.com>2020-11-05 11:23:56 -0800
committerGitHub <noreply@github.com>2020-11-05 11:23:56 -0800
commitc9b29d088550d5b18a952fdc126f5894981bb011 (patch)
tree1437ee8d5fa3a983e7205fc4fde7a7d162e22112 /tests/MyGame/Example
parentfba93e0abb2c59e4263bdbd7a6cfb3f5636f6c09 (diff)
downloadflatbuffers-c9b29d088550d5b18a952fdc126f5894981bb011.tar.gz
flatbuffers-c9b29d088550d5b18a952fdc126f5894981bb011.tar.bz2
flatbuffers-c9b29d088550d5b18a952fdc126f5894981bb011.zip
Support size-prefixed buffers and add tests for size-prefixed messages (#6232)
Diffstat (limited to 'tests/MyGame/Example')
-rw-r--r--tests/MyGame/Example/Monster.go7
-rw-r--r--tests/MyGame/Example/Referrable.go7
-rw-r--r--tests/MyGame/Example/Stat.go7
-rw-r--r--tests/MyGame/Example/TestSimpleTableWithEnum.go7
-rw-r--r--tests/MyGame/Example/TypeAliases.go7
5 files changed, 35 insertions, 0 deletions
diff --git a/tests/MyGame/Example/Monster.go b/tests/MyGame/Example/Monster.go
index 7db88a9c..b3472710 100644
--- a/tests/MyGame/Example/Monster.go
+++ b/tests/MyGame/Example/Monster.go
@@ -442,6 +442,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
diff --git a/tests/MyGame/Example/Referrable.go b/tests/MyGame/Example/Referrable.go
index 8f21e910..66c59729 100644
--- a/tests/MyGame/Example/Referrable.go
+++ b/tests/MyGame/Example/Referrable.go
@@ -39,6 +39,13 @@ func GetRootAsReferrable(buf []byte, offset flatbuffers.UOffsetT) *Referrable {
return x
}
+func GetSizePrefixedRootAsReferrable(buf []byte, offset flatbuffers.UOffsetT) *Referrable {
+ n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:])
+ x := &Referrable{}
+ x.Init(buf, n+offset+flatbuffers.SizeUint32)
+ return x
+}
+
func (rcv *Referrable) Init(buf []byte, i flatbuffers.UOffsetT) {
rcv._tab.Bytes = buf
rcv._tab.Pos = i
diff --git a/tests/MyGame/Example/Stat.go b/tests/MyGame/Example/Stat.go
index 6034e01c..5c060d1a 100644
--- a/tests/MyGame/Example/Stat.go
+++ b/tests/MyGame/Example/Stat.go
@@ -46,6 +46,13 @@ func GetRootAsStat(buf []byte, offset flatbuffers.UOffsetT) *Stat {
return x
}
+func GetSizePrefixedRootAsStat(buf []byte, offset flatbuffers.UOffsetT) *Stat {
+ n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:])
+ x := &Stat{}
+ x.Init(buf, n+offset+flatbuffers.SizeUint32)
+ return x
+}
+
func (rcv *Stat) Init(buf []byte, i flatbuffers.UOffsetT) {
rcv._tab.Bytes = buf
rcv._tab.Pos = i
diff --git a/tests/MyGame/Example/TestSimpleTableWithEnum.go b/tests/MyGame/Example/TestSimpleTableWithEnum.go
index 14805af7..b8cde12b 100644
--- a/tests/MyGame/Example/TestSimpleTableWithEnum.go
+++ b/tests/MyGame/Example/TestSimpleTableWithEnum.go
@@ -39,6 +39,13 @@ func GetRootAsTestSimpleTableWithEnum(buf []byte, offset flatbuffers.UOffsetT) *
return x
}
+func GetSizePrefixedRootAsTestSimpleTableWithEnum(buf []byte, offset flatbuffers.UOffsetT) *TestSimpleTableWithEnum {
+ n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:])
+ x := &TestSimpleTableWithEnum{}
+ x.Init(buf, n+offset+flatbuffers.SizeUint32)
+ return x
+}
+
func (rcv *TestSimpleTableWithEnum) Init(buf []byte, i flatbuffers.UOffsetT) {
rcv._tab.Bytes = buf
rcv._tab.Pos = i
diff --git a/tests/MyGame/Example/TypeAliases.go b/tests/MyGame/Example/TypeAliases.go
index 1c259aa5..d018fa1f 100644
--- a/tests/MyGame/Example/TypeAliases.go
+++ b/tests/MyGame/Example/TypeAliases.go
@@ -98,6 +98,13 @@ func GetRootAsTypeAliases(buf []byte, offset flatbuffers.UOffsetT) *TypeAliases
return x
}
+func GetSizePrefixedRootAsTypeAliases(buf []byte, offset flatbuffers.UOffsetT) *TypeAliases {
+ n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:])
+ x := &TypeAliases{}
+ x.Init(buf, n+offset+flatbuffers.SizeUint32)
+ return x
+}
+
func (rcv *TypeAliases) Init(buf []byte, i flatbuffers.UOffsetT) {
rcv._tab.Bytes = buf
rcv._tab.Pos = i