...

Source file src/github.com/google/flatbuffers/tests/MyGame/Example/TestSimpleTableWithEnum.go

Documentation: github.com/google/flatbuffers/tests/MyGame/Example

     1  // Code generated by the FlatBuffers compiler. DO NOT EDIT.
     2  
     3  package Example
     4  
     5  import (
     6  	flatbuffers "github.com/google/flatbuffers/go"
     7  )
     8  
     9  type TestSimpleTableWithEnumT struct {
    10  	Color Color `json:"color"`
    11  }
    12  
    13  func (t *TestSimpleTableWithEnumT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
    14  	if t == nil {
    15  		return 0
    16  	}
    17  	TestSimpleTableWithEnumStart(builder)
    18  	TestSimpleTableWithEnumAddColor(builder, t.Color)
    19  	return TestSimpleTableWithEnumEnd(builder)
    20  }
    21  
    22  func (rcv *TestSimpleTableWithEnum) UnPackTo(t *TestSimpleTableWithEnumT) {
    23  	t.Color = rcv.Color()
    24  }
    25  
    26  func (rcv *TestSimpleTableWithEnum) UnPack() *TestSimpleTableWithEnumT {
    27  	if rcv == nil {
    28  		return nil
    29  	}
    30  	t := &TestSimpleTableWithEnumT{}
    31  	rcv.UnPackTo(t)
    32  	return t
    33  }
    34  
    35  type TestSimpleTableWithEnum struct {
    36  	_tab flatbuffers.Table
    37  }
    38  
    39  func GetRootAsTestSimpleTableWithEnum(buf []byte, offset flatbuffers.UOffsetT) *TestSimpleTableWithEnum {
    40  	n := flatbuffers.GetUOffsetT(buf[offset:])
    41  	x := &TestSimpleTableWithEnum{}
    42  	x.Init(buf, n+offset)
    43  	return x
    44  }
    45  
    46  func FinishTestSimpleTableWithEnumBuffer(builder *flatbuffers.Builder, offset flatbuffers.UOffsetT) {
    47  	builder.Finish(offset)
    48  }
    49  
    50  func GetSizePrefixedRootAsTestSimpleTableWithEnum(buf []byte, offset flatbuffers.UOffsetT) *TestSimpleTableWithEnum {
    51  	n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:])
    52  	x := &TestSimpleTableWithEnum{}
    53  	x.Init(buf, n+offset+flatbuffers.SizeUint32)
    54  	return x
    55  }
    56  
    57  func FinishSizePrefixedTestSimpleTableWithEnumBuffer(builder *flatbuffers.Builder, offset flatbuffers.UOffsetT) {
    58  	builder.FinishSizePrefixed(offset)
    59  }
    60  
    61  func (rcv *TestSimpleTableWithEnum) Init(buf []byte, i flatbuffers.UOffsetT) {
    62  	rcv._tab.Bytes = buf
    63  	rcv._tab.Pos = i
    64  }
    65  
    66  func (rcv *TestSimpleTableWithEnum) Table() flatbuffers.Table {
    67  	return rcv._tab
    68  }
    69  
    70  func (rcv *TestSimpleTableWithEnum) Color() Color {
    71  	o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
    72  	if o != 0 {
    73  		return Color(rcv._tab.GetByte(o + rcv._tab.Pos))
    74  	}
    75  	return 2
    76  }
    77  
    78  func (rcv *TestSimpleTableWithEnum) MutateColor(n Color) bool {
    79  	return rcv._tab.MutateByteSlot(4, byte(n))
    80  }
    81  
    82  func TestSimpleTableWithEnumStart(builder *flatbuffers.Builder) {
    83  	builder.StartObject(1)
    84  }
    85  func TestSimpleTableWithEnumAddColor(builder *flatbuffers.Builder, color Color) {
    86  	builder.PrependByteSlot(0, byte(color), 2)
    87  }
    88  func TestSimpleTableWithEnumEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
    89  	return builder.EndObject()
    90  }
    91  

View as plain text