Debian Codegraph @

tests/ts/arrays_test_complex/my-game/example/nested-struct.ts

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