1// automatically generated by the FlatBuffers compiler, do not modify
2
3import * as flatbuffers from 'flatbuffers';
4
5import { OuterStruct, OuterStructT } from '../../my-game/example/outer-struct.js';
6import { TestEnum } from '../../my-game/example/test-enum.js';
7
8
9export class NestedStruct implements flatbuffers.IUnpackableObject<NestedStructT> {
10 bb: flatbuffers.ByteBuffer|null = null;
11 bb_pos = 0;
12 __init(i:number, bb:flatbuffers.ByteBuffer):NestedStruct {
13 this.bb_pos = i;
14 this.bb = bb;
15 return this;
16}
17
18a(index: number):number|null {
19 return this.bb!.readInt32(this.bb_pos + 0 + index * 4);
20}
21
22b():TestEnum {
23 return this.bb!.readInt8(this.bb_pos + 8);
24}
25
26cUnderscore(index: number):TestEnum|null {
27 return this.bb!.readInt8(this.bb_pos + 9 + index);
28}
29
30dOuter(index: number, obj?:OuterStruct):OuterStruct|null {
31 return (obj || new OuterStruct()).__init(this.bb_pos + 16 + index * 208, this.bb!);
32}
33
34e(index: number):bigint|null {
35 return this.bb!.readInt64(this.bb_pos + 1056 + index * 8);
36}
37
38static getFullyQualifiedName():string {
39 return 'MyGame.Example.NestedStruct';
40}
41
42static sizeOf():number {
43 return 1072;
44}
45
46static createNestedStruct(builder:flatbuffers.Builder, a: number[]|null, b: TestEnum, c_underscore: number[]|null, d_outer: (any|OuterStructT)[]|null, e: bigint[]|null):flatbuffers.Offset {
47 builder.prep(8, 1072);
48
49 for (let i = 1; i >= 0; --i) {
50 builder.writeInt64(BigInt(e?.[i] ?? 0));
51 }
52
53
54 for (let i = 4; i >= 0; --i) {
55 const item = d_outer?.[i];
56
57 if (item instanceof OuterStructT) {
58 item.pack(builder);
59 continue;
60 }
61
62 OuterStruct.createOuterStruct(builder,
63 item?.a,
64 item?.b,
65 (item?.cUnderscore?.a ?? 0),
66 (item?.cUnderscore?.b ?? []),
67 (item?.cUnderscore?.c ?? 0),
68 (item?.cUnderscore?.dUnderscore ?? BigInt(0)),
69 item?.d,
70 (item?.e?.a ?? 0),
71 (item?.e?.b ?? []),
72 (item?.e?.c ?? 0),
73 (item?.e?.dUnderscore ?? BigInt(0)),
74 item?.f
75 );
76 }
77
78 builder.pad(5);
79
80 for (let i = 1; i >= 0; --i) {
81 builder.writeInt8((c_underscore?.[i] ?? 0));
82
83 }
84
85 builder.writeInt8(b);
86
87 for (let i = 1; i >= 0; --i) {
88 builder.writeInt32((a?.[i] ?? 0));
89
90 }
91
92 return builder.offset();
93}
94
95
96unpack(): NestedStructT {
97 return new NestedStructT(
98 this.bb!.createScalarList<number>(this.a.bind(this), 2),
99 this.b(),
100 this.bb!.createScalarList<TestEnum>(this.cUnderscore.bind(this), 2),
101 this.bb!.createObjList<OuterStruct, OuterStructT>(this.dOuter.bind(this), 5),
102 this.bb!.createScalarList<bigint>(this.e.bind(this), 2)
103 );
104}
105
106
107unpackTo(_o: NestedStructT): void {
108 _o.a = this.bb!.createScalarList<number>(this.a.bind(this), 2);
109 _o.b = this.b();
110 _o.cUnderscore = this.bb!.createScalarList<TestEnum>(this.cUnderscore.bind(this), 2);
111 _o.dOuter = this.bb!.createObjList<OuterStruct, OuterStructT>(this.dOuter.bind(this), 5);
112 _o.e = this.bb!.createScalarList<bigint>(this.e.bind(this), 2);
113}
114}
115
116export class NestedStructT implements flatbuffers.IGeneratedObject {
117constructor(
118 public a: (number)[] = [],
119 public b: TestEnum = TestEnum.A,
120 public cUnderscore: (TestEnum)[] = [TestEnum.A, TestEnum.A],
121 public dOuter: (OuterStructT)[] = [],
122 public e: (bigint)[] = []
123){}
124
125
126pack(builder:flatbuffers.Builder): flatbuffers.Offset {
127 return NestedStruct.createNestedStruct(builder,
128 this.a,
129 this.b,
130 this.cUnderscore,
131 this.dOuter,
132 this.e
133 );
134}
135}
View as plain text