mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-08 22:20:56 +00:00
Emit GetRootAs methods for all types in Go and Python
This commit is contained in:
@@ -15,7 +15,6 @@ class Monster(object):
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
|
||||
|
||||
# Monster
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
@@ -9,6 +9,13 @@ type Stat struct {
|
||||
_tab flatbuffers.Table
|
||||
}
|
||||
|
||||
func GetRootAsStat(buf []byte, offset flatbuffers.UOffsetT) *Stat {
|
||||
n := flatbuffers.GetUOffsetT(buf[offset:])
|
||||
x := &Stat{}
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
}
|
||||
|
||||
func (rcv *Stat) Init(buf []byte, i flatbuffers.UOffsetT) {
|
||||
rcv._tab.Bytes = buf
|
||||
rcv._tab.Pos = i
|
||||
|
||||
@@ -7,6 +7,13 @@ import flatbuffers
|
||||
class Stat(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
@classmethod
|
||||
def GetRootAsStat(cls, buf, offset):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||
x = Stat()
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
|
||||
# Stat
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
@@ -9,6 +9,13 @@ type TestSimpleTableWithEnum struct {
|
||||
_tab flatbuffers.Table
|
||||
}
|
||||
|
||||
func GetRootAsTestSimpleTableWithEnum(buf []byte, offset flatbuffers.UOffsetT) *TestSimpleTableWithEnum {
|
||||
n := flatbuffers.GetUOffsetT(buf[offset:])
|
||||
x := &TestSimpleTableWithEnum{}
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
}
|
||||
|
||||
func (rcv *TestSimpleTableWithEnum) Init(buf []byte, i flatbuffers.UOffsetT) {
|
||||
rcv._tab.Bytes = buf
|
||||
rcv._tab.Pos = i
|
||||
|
||||
@@ -7,6 +7,13 @@ import flatbuffers
|
||||
class TestSimpleTableWithEnum(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
@classmethod
|
||||
def GetRootAsTestSimpleTableWithEnum(cls, buf, offset):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||
x = TestSimpleTableWithEnum()
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
|
||||
# TestSimpleTableWithEnum
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
Reference in New Issue
Block a user