• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// automatically generated by the FlatBuffers compiler, do not modify
2import { OuterStruct, OuterStructT } from '../../my-game/example/outer-struct.js';
3import { TestEnum } from '../../my-game/example/test-enum.js';
4export class NestedStruct {
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    a(index) {
15        return this.bb.readInt32(this.bb_pos + 0 + index * 4);
16    }
17    b() {
18        return this.bb.readInt8(this.bb_pos + 8);
19    }
20    cUnderscore(index) {
21        return this.bb.readInt8(this.bb_pos + 9 + index);
22    }
23    dOuter(index, obj) {
24        return (obj || new OuterStruct()).__init(this.bb_pos + 16 + index * 208, this.bb);
25    }
26    e(index) {
27        return this.bb.readInt64(this.bb_pos + 1056 + index * 8);
28    }
29    static getFullyQualifiedName() {
30        return 'MyGame.Example.NestedStruct';
31    }
32    static sizeOf() {
33        return 1072;
34    }
35    static createNestedStruct(builder, a, b, c_underscore, d_outer, e) {
36        builder.prep(8, 1072);
37        for (let i = 1; i >= 0; --i) {
38            builder.writeInt64(BigInt(e?.[i] ?? 0));
39        }
40        for (let i = 4; i >= 0; --i) {
41            const item = d_outer?.[i];
42            if (item instanceof OuterStructT) {
43                item.pack(builder);
44                continue;
45            }
46            OuterStruct.createOuterStruct(builder, item?.a, item?.b, (item?.cUnderscore?.a ?? 0), (item?.cUnderscore?.b ?? []), (item?.cUnderscore?.c ?? 0), (item?.cUnderscore?.dUnderscore ?? BigInt(0)), item?.d, (item?.e?.a ?? 0), (item?.e?.b ?? []), (item?.e?.c ?? 0), (item?.e?.dUnderscore ?? BigInt(0)), item?.f);
47        }
48        builder.pad(5);
49        for (let i = 1; i >= 0; --i) {
50            builder.writeInt8((c_underscore?.[i] ?? 0));
51        }
52        builder.writeInt8(b);
53        for (let i = 1; i >= 0; --i) {
54            builder.writeInt32((a?.[i] ?? 0));
55        }
56        return builder.offset();
57    }
58    unpack() {
59        return new NestedStructT(this.bb.createScalarList(this.a.bind(this), 2), this.b(), this.bb.createScalarList(this.cUnderscore.bind(this), 2), this.bb.createObjList(this.dOuter.bind(this), 5), this.bb.createScalarList(this.e.bind(this), 2));
60    }
61    unpackTo(_o) {
62        _o.a = this.bb.createScalarList(this.a.bind(this), 2);
63        _o.b = this.b();
64        _o.cUnderscore = this.bb.createScalarList(this.cUnderscore.bind(this), 2);
65        _o.dOuter = this.bb.createObjList(this.dOuter.bind(this), 5);
66        _o.e = this.bb.createScalarList(this.e.bind(this), 2);
67    }
68}
69export class NestedStructT {
70    constructor(a = [], b = TestEnum.A, cUnderscore = [TestEnum.A, TestEnum.A], dOuter = [], e = []) {
71        this.a = a;
72        this.b = b;
73        this.cUnderscore = cUnderscore;
74        this.dOuter = dOuter;
75        this.e = e;
76    }
77    pack(builder) {
78        return NestedStruct.createNestedStruct(builder, this.a, this.b, this.cUnderscore, this.dOuter, this.e);
79    }
80}
81