Debian Codegraph @

tests/ts/my-game/example/test-simple-table-with-enum.ts

raw symbols SCIP
1 // automatically generated by the FlatBuffers compiler, do not modify
2
3 import * as flatbuffers from 'flatbuffers';
4
5 import { Color } from '../../my-game/example/color.js';
6
7
8 export class TestSimpleTableWithEnum implements flatbuffers.IUnpackableObject<TestSimpleTableWithEnumT> {
9 bb: flatbuffers.ByteBuffer|null = null;
10 bb_pos = 0;
11 __init(i:number, bb:flatbuffers.ByteBuffer):TestSimpleTableWithEnum {
12 this.bb_pos = i;
13 this.bb = bb;
14 return this;
15 }
16
17 static getRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:TestSimpleTableWithEnum):TestSimpleTableWithEnum {
18 return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
19 }
20
21 static getSizePrefixedRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:TestSimpleTableWithEnum):TestSimpleTableWithEnum {
22 bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
23 return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
24 }
25
26 color():Color {
27 const offset = this.bb!.__offset(this.bb_pos, 4);
28 return offset ? this.bb!.readUint8(this.bb_pos + offset) : Color.Green;
29 }
30
31 mutate_color(value:Color):boolean {
32 const offset = this.bb!.__offset(this.bb_pos, 4);
33
34 if (offset === 0) {
35 return false;
36 }
37
38 this.bb!.writeUint8(this.bb_pos + offset, value);
39 return true;
40 }
41
42 static getFullyQualifiedName():string {
43 return 'MyGame.Example.TestSimpleTableWithEnum';
44 }
45
46 static startTestSimpleTableWithEnum(builder:flatbuffers.Builder) {
47 builder.startObject(1);
48 }
49
50 static addColor(builder:flatbuffers.Builder, color:Color) {
51 builder.addFieldInt8(0, color, Color.Green);
52 }
53
54 static endTestSimpleTableWithEnum(builder:flatbuffers.Builder):flatbuffers.Offset {
55 const offset = builder.endObject();
56 return offset;
57 }
58
59 static createTestSimpleTableWithEnum(builder:flatbuffers.Builder, color:Color):flatbuffers.Offset {
60 TestSimpleTableWithEnum.startTestSimpleTableWithEnum(builder);
61 TestSimpleTableWithEnum.addColor(builder, color);
62 return TestSimpleTableWithEnum.endTestSimpleTableWithEnum(builder);
63 }
64
65 serialize():Uint8Array {
66 return this.bb!.bytes();
67 }
68
69 static deserialize(buffer: Uint8Array):TestSimpleTableWithEnum {
70 return TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum(new flatbuffers.ByteBuffer(buffer))
71 }
72
73 unpack(): TestSimpleTableWithEnumT {
74 return new TestSimpleTableWithEnumT(
75 this.color()
76 );
77 }
78
79
80 unpackTo(_o: TestSimpleTableWithEnumT): void {
81 _o.color = this.color();
82 }
83 }
84
85 export class TestSimpleTableWithEnumT implements flatbuffers.IGeneratedObject {
86 constructor(
87 public color: Color = Color.Green
88 ){}
89
90
91 pack(builder:flatbuffers.Builder): flatbuffers.Offset {
92 return TestSimpleTableWithEnum.createTestSimpleTableWithEnum(builder,
93 this.color
94 );
95 }
96 }