mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 12:05:50 +00:00
When creating a CreateXxx(...) method for a simple table type, enum-type fields with a non-zero default must have an explicit cast for the respective argument default value, because in C#, there is an implicit cast from int to an enum only for 0. Also, added an example of such type into the example monster_test type, so that we test this feature.
28 lines
802 B
Go
28 lines
802 B
Go
// automatically generated, do not modify
|
|
|
|
package Example
|
|
|
|
import (
|
|
flatbuffers "github.com/google/flatbuffers/go"
|
|
)
|
|
type TestSimpleTableWithEnum struct {
|
|
_tab flatbuffers.Table
|
|
}
|
|
|
|
func (rcv *TestSimpleTableWithEnum) Init(buf []byte, i flatbuffers.UOffsetT) {
|
|
rcv._tab.Bytes = buf
|
|
rcv._tab.Pos = i
|
|
}
|
|
|
|
func (rcv *TestSimpleTableWithEnum) Color() int8 {
|
|
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
|
|
if o != 0 {
|
|
return rcv._tab.GetInt8(o + rcv._tab.Pos)
|
|
}
|
|
return 2
|
|
}
|
|
|
|
func TestSimpleTableWithEnumStart(builder *flatbuffers.Builder) { builder.StartObject(1) }
|
|
func TestSimpleTableWithEnumAddColor(builder *flatbuffers.Builder, color int8) { builder.PrependInt8Slot(0, color, 2) }
|
|
func TestSimpleTableWithEnumEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() }
|