xref: /aosp_15_r20/external/flatbuffers/tests/my-game/example/struct-of-structs.js (revision 890232f25432b36107d06881e0a25aaa6b473652)
1// automatically generated by the FlatBuffers compiler, do not modify
2import { Ability } from '../../my-game/example/ability';
3import { Test } from '../../my-game/example/test';
4export class StructOfStructs {
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(obj) {
15        return (obj || new Ability()).__init(this.bb_pos, this.bb);
16    }
17    b(obj) {
18        return (obj || new Test()).__init(this.bb_pos + 8, this.bb);
19    }
20    c(obj) {
21        return (obj || new Ability()).__init(this.bb_pos + 12, this.bb);
22    }
23    static getFullyQualifiedName() {
24        return 'MyGame_Example_StructOfStructs';
25    }
26    static sizeOf() {
27        return 20;
28    }
29    static createStructOfStructs(builder, a_id, a_distance, b_a, b_b, c_id, c_distance) {
30        builder.prep(4, 20);
31        builder.prep(4, 8);
32        builder.writeInt32(c_distance);
33        builder.writeInt32(c_id);
34        builder.prep(2, 4);
35        builder.pad(1);
36        builder.writeInt8(b_b);
37        builder.writeInt16(b_a);
38        builder.prep(4, 8);
39        builder.writeInt32(a_distance);
40        builder.writeInt32(a_id);
41        return builder.offset();
42    }
43    unpack() {
44        return new StructOfStructsT((this.a() !== null ? this.a().unpack() : null), (this.b() !== null ? this.b().unpack() : null), (this.c() !== null ? this.c().unpack() : null));
45    }
46    unpackTo(_o) {
47        _o.a = (this.a() !== null ? this.a().unpack() : null);
48        _o.b = (this.b() !== null ? this.b().unpack() : null);
49        _o.c = (this.c() !== null ? this.c().unpack() : null);
50    }
51}
52export class StructOfStructsT {
53    constructor(a = null, b = null, c = null) {
54        this.a = a;
55        this.b = b;
56        this.c = c;
57    }
58    pack(builder) {
59        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
60        return StructOfStructs.createStructOfStructs(builder, ((_b = (_a = this.a) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : 0), ((_d = (_c = this.a) === null || _c === void 0 ? void 0 : _c.distance) !== null && _d !== void 0 ? _d : 0), ((_f = (_e = this.b) === null || _e === void 0 ? void 0 : _e.a) !== null && _f !== void 0 ? _f : 0), ((_h = (_g = this.b) === null || _g === void 0 ? void 0 : _g.b) !== null && _h !== void 0 ? _h : 0), ((_k = (_j = this.c) === null || _j === void 0 ? void 0 : _j.id) !== null && _k !== void 0 ? _k : 0), ((_m = (_l = this.c) === null || _l === void 0 ? void 0 : _l.distance) !== null && _m !== void 0 ? _m : 0));
61    }
62}
63