Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 1 | // Code generated by the FlatBuffers compiler. DO NOT EDIT. |
| 2 | |
| 3 | package Example |
| 4 | |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame^] | 5 | import ( |
| 6 | "strconv" |
| 7 | |
| 8 | flatbuffers "github.com/google/flatbuffers/go" |
| 9 | |
| 10 | MyGame__Example2 "MyGame/Example2" |
| 11 | ) |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 12 | |
| 13 | type Any byte |
| 14 | |
| 15 | const ( |
| 16 | AnyNONE Any = 0 |
| 17 | AnyMonster Any = 1 |
| 18 | AnyTestSimpleTableWithEnum Any = 2 |
| 19 | AnyMyGame_Example2_Monster Any = 3 |
| 20 | ) |
| 21 | |
| 22 | var EnumNamesAny = map[Any]string{ |
| 23 | AnyNONE: "NONE", |
| 24 | AnyMonster: "Monster", |
| 25 | AnyTestSimpleTableWithEnum: "TestSimpleTableWithEnum", |
| 26 | AnyMyGame_Example2_Monster: "MyGame_Example2_Monster", |
| 27 | } |
| 28 | |
| 29 | var EnumValuesAny = map[string]Any{ |
| 30 | "NONE": AnyNONE, |
| 31 | "Monster": AnyMonster, |
| 32 | "TestSimpleTableWithEnum": AnyTestSimpleTableWithEnum, |
| 33 | "MyGame_Example2_Monster": AnyMyGame_Example2_Monster, |
| 34 | } |
| 35 | |
| 36 | func (v Any) String() string { |
| 37 | if s, ok := EnumNamesAny[v]; ok { |
| 38 | return s |
| 39 | } |
| 40 | return "Any(" + strconv.FormatInt(int64(v), 10) + ")" |
| 41 | } |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame^] | 42 | |
| 43 | type AnyT struct { |
| 44 | Type Any |
| 45 | Value interface{} |
| 46 | } |
| 47 | |
| 48 | func (t *AnyT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT { |
| 49 | if t == nil { |
| 50 | return 0 |
| 51 | } |
| 52 | switch t.Type { |
| 53 | case AnyMonster: |
| 54 | return t.Value.(*MonsterT).Pack(builder) |
| 55 | case AnyTestSimpleTableWithEnum: |
| 56 | return t.Value.(*TestSimpleTableWithEnumT).Pack(builder) |
| 57 | case AnyMyGame_Example2_Monster: |
| 58 | return t.Value.(*MyGame__Example2.MonsterT).Pack(builder) |
| 59 | } |
| 60 | return 0 |
| 61 | } |
| 62 | |
| 63 | func (rcv Any) UnPack(table flatbuffers.Table) *AnyT { |
| 64 | switch rcv { |
| 65 | case AnyMonster: |
| 66 | x := Monster{_tab: table} |
| 67 | return &AnyT{ Type: AnyMonster, Value: x.UnPack() } |
| 68 | case AnyTestSimpleTableWithEnum: |
| 69 | x := TestSimpleTableWithEnum{_tab: table} |
| 70 | return &AnyT{ Type: AnyTestSimpleTableWithEnum, Value: x.UnPack() } |
| 71 | case AnyMyGame_Example2_Monster: |
| 72 | x := Monster{_tab: table} |
| 73 | return &AnyT{ Type: AnyMyGame_Example2_Monster, Value: x.UnPack() } |
| 74 | } |
| 75 | return nil |
| 76 | } |