...

Text file src/github.com/google/flatbuffers/tests/ts/arrays_test_complex/my-game/example/array-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 { NestedStruct, NestedStructT } from '../../my-game/example/nested-struct.js';
     6import { OuterStruct, OuterStructT } from '../../my-game/example/outer-struct.js';
     7
     8
     9export class ArrayStruct implements flatbuffers.IUnpackableObject<ArrayStructT> {
    10  bb: flatbuffers.ByteBuffer|null = null;
    11  bb_pos = 0;
    12  __init(i:number, bb:flatbuffers.ByteBuffer):ArrayStruct {
    13  this.bb_pos = i;
    14  this.bb = bb;
    15  return this;
    16}
    17
    18aUnderscore():number {
    19  return this.bb!.readFloat32(this.bb_pos);
    20}
    21
    22bUnderscore(index: number):number|null {
    23    return this.bb!.readInt32(this.bb_pos + 4 + index * 4);
    24}
    25
    26c():number {
    27  return this.bb!.readInt8(this.bb_pos + 64);
    28}
    29
    30d(index: number, obj?:NestedStruct):NestedStruct|null {
    31    return (obj || new NestedStruct()).__init(this.bb_pos + 72 + index * 1072, this.bb!);
    32}
    33
    34e():number {
    35  return this.bb!.readInt32(this.bb_pos + 2216);
    36}
    37
    38f(index: number, obj?:OuterStruct):OuterStruct|null {
    39    return (obj || new OuterStruct()).__init(this.bb_pos + 2224 + index * 208, this.bb!);
    40}
    41
    42g(index: number):bigint|null {
    43    return this.bb!.readInt64(this.bb_pos + 2640 + index * 8);
    44}
    45
    46static getFullyQualifiedName():string {
    47  return 'MyGame.Example.ArrayStruct';
    48}
    49
    50static sizeOf():number {
    51  return 2656;
    52}
    53
    54static createArrayStruct(builder:flatbuffers.Builder, a_underscore: number, b_underscore: number[]|null, c: number, d: (any|NestedStructT)[]|null, e: number, f: (any|OuterStructT)[]|null, g: bigint[]|null):flatbuffers.Offset {
    55  builder.prep(8, 2656);
    56
    57  for (let i = 1; i >= 0; --i) {
    58    builder.writeInt64(BigInt(g?.[i] ?? 0));
    59  }
    60
    61
    62  for (let i = 1; i >= 0; --i) {
    63    const item = f?.[i];
    64
    65    if (item instanceof OuterStructT) {
    66      item.pack(builder);
    67      continue;
    68    }
    69
    70    OuterStruct.createOuterStruct(builder,
    71    item?.a,
    72    item?.b,
    73    (item?.cUnderscore?.a ?? 0),
    74    (item?.cUnderscore?.b ?? []),
    75    (item?.cUnderscore?.c ?? 0),
    76    (item?.cUnderscore?.dUnderscore ?? BigInt(0)),
    77    item?.d,
    78    (item?.e?.a ?? 0),
    79    (item?.e?.b ?? []),
    80    (item?.e?.c ?? 0),
    81    (item?.e?.dUnderscore ?? BigInt(0)),
    82    item?.f
    83    );
    84  }
    85
    86  builder.pad(4);
    87  builder.writeInt32(e);
    88
    89  for (let i = 1; i >= 0; --i) {
    90    const item = d?.[i];
    91
    92    if (item instanceof NestedStructT) {
    93      item.pack(builder);
    94      continue;
    95    }
    96
    97    NestedStruct.createNestedStruct(builder,
    98    item?.a,
    99    item?.b,
   100    item?.cUnderscore,
   101    item?.dOuter,
   102    item?.e
   103    );
   104  }
   105
   106  builder.pad(7);
   107  builder.writeInt8(c);
   108
   109  for (let i = 14; i >= 0; --i) {
   110    builder.writeInt32((b_underscore?.[i] ?? 0));
   111
   112  }
   113
   114  builder.writeFloat32(a_underscore);
   115  return builder.offset();
   116}
   117
   118
   119unpack(): ArrayStructT {
   120  return new ArrayStructT(
   121    this.aUnderscore(),
   122    this.bb!.createScalarList<number>(this.bUnderscore.bind(this), 15),
   123    this.c(),
   124    this.bb!.createObjList<NestedStruct, NestedStructT>(this.d.bind(this), 2),
   125    this.e(),
   126    this.bb!.createObjList<OuterStruct, OuterStructT>(this.f.bind(this), 2),
   127    this.bb!.createScalarList<bigint>(this.g.bind(this), 2)
   128  );
   129}
   130
   131
   132unpackTo(_o: ArrayStructT): void {
   133  _o.aUnderscore = this.aUnderscore();
   134  _o.bUnderscore = this.bb!.createScalarList<number>(this.bUnderscore.bind(this), 15);
   135  _o.c = this.c();
   136  _o.d = this.bb!.createObjList<NestedStruct, NestedStructT>(this.d.bind(this), 2);
   137  _o.e = this.e();
   138  _o.f = this.bb!.createObjList<OuterStruct, OuterStructT>(this.f.bind(this), 2);
   139  _o.g = this.bb!.createScalarList<bigint>(this.g.bind(this), 2);
   140}
   141}
   142
   143export class ArrayStructT implements flatbuffers.IGeneratedObject {
   144constructor(
   145  public aUnderscore: number = 0.0,
   146  public bUnderscore: (number)[] = [],
   147  public c: number = 0,
   148  public d: (NestedStructT)[] = [],
   149  public e: number = 0,
   150  public f: (OuterStructT)[] = [],
   151  public g: (bigint)[] = []
   152){}
   153
   154
   155pack(builder:flatbuffers.Builder): flatbuffers.Offset {
   156  return ArrayStruct.createArrayStruct(builder,
   157    this.aUnderscore,
   158    this.bUnderscore,
   159    this.c,
   160    this.d,
   161    this.e,
   162    this.f,
   163    this.g
   164  );
   165}
   166}

View as plain text