James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame^] | 1 | // automatically generated by the FlatBuffers compiler, do not modify |
| 2 | import * as flatbuffers from 'flatbuffers'; |
| 3 | import { Color } from '../../my-game/example/color'; |
| 4 | export class TestSimpleTableWithEnum { |
| 5 | constructor() { |
| 6 | this.bb = null; |
| 7 | this.bb_pos = 0; |
| 8 | } |
| 9 | __init(i, bb) { |
| 10 | this.bb_pos = i; |
| 11 | this.bb = bb; |
| 12 | return this; |
| 13 | } |
| 14 | static getRootAsTestSimpleTableWithEnum(bb, obj) { |
| 15 | return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); |
| 16 | } |
| 17 | static getSizePrefixedRootAsTestSimpleTableWithEnum(bb, obj) { |
| 18 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); |
| 19 | return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); |
| 20 | } |
| 21 | color() { |
| 22 | const offset = this.bb.__offset(this.bb_pos, 4); |
| 23 | return offset ? this.bb.readUint8(this.bb_pos + offset) : Color.Green; |
| 24 | } |
| 25 | mutate_color(value) { |
| 26 | const offset = this.bb.__offset(this.bb_pos, 4); |
| 27 | if (offset === 0) { |
| 28 | return false; |
| 29 | } |
| 30 | this.bb.writeUint8(this.bb_pos + offset, value); |
| 31 | return true; |
| 32 | } |
| 33 | static getFullyQualifiedName() { |
| 34 | return 'MyGame.Example.TestSimpleTableWithEnum'; |
| 35 | } |
| 36 | static startTestSimpleTableWithEnum(builder) { |
| 37 | builder.startObject(1); |
| 38 | } |
| 39 | static addColor(builder, color) { |
| 40 | builder.addFieldInt8(0, color, Color.Green); |
| 41 | } |
| 42 | static endTestSimpleTableWithEnum(builder) { |
| 43 | const offset = builder.endObject(); |
| 44 | return offset; |
| 45 | } |
| 46 | static createTestSimpleTableWithEnum(builder, color) { |
| 47 | TestSimpleTableWithEnum.startTestSimpleTableWithEnum(builder); |
| 48 | TestSimpleTableWithEnum.addColor(builder, color); |
| 49 | return TestSimpleTableWithEnum.endTestSimpleTableWithEnum(builder); |
| 50 | } |
| 51 | serialize() { |
| 52 | return this.bb.bytes(); |
| 53 | } |
| 54 | static deserialize(buffer) { |
| 55 | return TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum(new flatbuffers.ByteBuffer(buffer)); |
| 56 | } |
| 57 | unpack() { |
| 58 | return new TestSimpleTableWithEnumT(this.color()); |
| 59 | } |
| 60 | unpackTo(_o) { |
| 61 | _o.color = this.color(); |
| 62 | } |
| 63 | } |
| 64 | export class TestSimpleTableWithEnumT { |
| 65 | constructor(color = Color.Green) { |
| 66 | this.color = color; |
| 67 | } |
| 68 | pack(builder) { |
| 69 | return TestSimpleTableWithEnum.createTestSimpleTableWithEnum(builder, this.color); |
| 70 | } |
| 71 | } |