mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-25 11:18:38 +00:00
Use enum types in generated read/mutate methods for Go (#4978)
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
7c3c027295
commit
a4c362a1ba
@@ -97,7 +97,7 @@ func (rcv *Monster) InventoryBytes() []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rcv *Monster) Color() int8 {
|
||||
func (rcv *Monster) Color() Color {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(16))
|
||||
if o != 0 {
|
||||
return rcv._tab.GetInt8(o + rcv._tab.Pos)
|
||||
@@ -105,7 +105,7 @@ func (rcv *Monster) Color() int8 {
|
||||
return 8
|
||||
}
|
||||
|
||||
func (rcv *Monster) MutateColor(n int8) bool {
|
||||
func (rcv *Monster) MutateColor(n Color) bool {
|
||||
return rcv._tab.MutateInt8Slot(16, n)
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ func (rcv *TestSimpleTableWithEnum) Table() flatbuffers.Table {
|
||||
return rcv._tab
|
||||
}
|
||||
|
||||
func (rcv *TestSimpleTableWithEnum) Color() int8 {
|
||||
func (rcv *TestSimpleTableWithEnum) Color() Color {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
|
||||
if o != 0 {
|
||||
return rcv._tab.GetInt8(o + rcv._tab.Pos)
|
||||
@@ -34,7 +34,7 @@ func (rcv *TestSimpleTableWithEnum) Color() int8 {
|
||||
return 2
|
||||
}
|
||||
|
||||
func (rcv *TestSimpleTableWithEnum) MutateColor(n int8) bool {
|
||||
func (rcv *TestSimpleTableWithEnum) MutateColor(n Color) bool {
|
||||
return rcv._tab.MutateInt8Slot(4, n)
|
||||
}
|
||||
|
||||
|
||||
@@ -47,10 +47,10 @@ func (rcv *Vec3) MutateTest1(n float64) bool {
|
||||
return rcv._tab.MutateFloat64(rcv._tab.Pos+flatbuffers.UOffsetT(16), n)
|
||||
}
|
||||
|
||||
func (rcv *Vec3) Test2() int8 {
|
||||
func (rcv *Vec3) Test2() Color {
|
||||
return rcv._tab.GetInt8(rcv._tab.Pos + flatbuffers.UOffsetT(24))
|
||||
}
|
||||
func (rcv *Vec3) MutateTest2(n int8) bool {
|
||||
func (rcv *Vec3) MutateTest2(n Color) bool {
|
||||
return rcv._tab.MutateInt8(rcv._tab.Pos+flatbuffers.UOffsetT(24), n)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user