...

Text file src/github.com/google/flatbuffers/tests/ts/arrays_test_complex/my-game/example/outer-struct.ts

Documentation: github.com/google/flatbuffers/tests/ts/arrays_test_complex/my-game/example

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

View as plain text