...

Text file src/github.com/google/flatbuffers/tests/ts/foobar/tab.ts

Documentation: github.com/google/flatbuffers/tests/ts/foobar

     1// automatically generated by the FlatBuffers compiler, do not modify
     2
     3import * as flatbuffers from 'flatbuffers';
     4
     5import { Abc } from '../foobar/abc.js';
     6import { class_ } from '../foobar/class.js';
     7
     8
     9export class Tab implements flatbuffers.IUnpackableObject<TabT> {
    10  bb: flatbuffers.ByteBuffer|null = null;
    11  bb_pos = 0;
    12  __init(i:number, bb:flatbuffers.ByteBuffer):Tab {
    13  this.bb_pos = i;
    14  this.bb = bb;
    15  return this;
    16}
    17
    18static getRootAsTab(bb:flatbuffers.ByteBuffer, obj?:Tab):Tab {
    19  return (obj || new Tab()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    20}
    21
    22static getSizePrefixedRootAsTab(bb:flatbuffers.ByteBuffer, obj?:Tab):Tab {
    23  bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
    24  return (obj || new Tab()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    25}
    26
    27abc():Abc {
    28  const offset = this.bb!.__offset(this.bb_pos, 4);
    29  return offset ? this.bb!.readInt32(this.bb_pos + offset) : Abc.a;
    30}
    31
    32mutate_abc(value:Abc):boolean {
    33  const offset = this.bb!.__offset(this.bb_pos, 4);
    34
    35  if (offset === 0) {
    36    return false;
    37  }
    38
    39  this.bb!.writeInt32(this.bb_pos + offset, value);
    40  return true;
    41}
    42
    43arg():class_ {
    44  const offset = this.bb!.__offset(this.bb_pos, 6);
    45  return offset ? this.bb!.readInt32(this.bb_pos + offset) : class_.arguments_;
    46}
    47
    48mutate_arg(value:class_):boolean {
    49  const offset = this.bb!.__offset(this.bb_pos, 6);
    50
    51  if (offset === 0) {
    52    return false;
    53  }
    54
    55  this.bb!.writeInt32(this.bb_pos + offset, value);
    56  return true;
    57}
    58
    59name():string|null
    60name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
    61name(optionalEncoding?:any):string|Uint8Array|null {
    62  const offset = this.bb!.__offset(this.bb_pos, 8);
    63  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
    64}
    65
    66static getFullyQualifiedName():string {
    67  return 'foobar.Tab';
    68}
    69
    70static startTab(builder:flatbuffers.Builder) {
    71  builder.startObject(3);
    72}
    73
    74static addAbc(builder:flatbuffers.Builder, abc:Abc) {
    75  builder.addFieldInt32(0, abc, Abc.a);
    76}
    77
    78static addArg(builder:flatbuffers.Builder, arg:class_) {
    79  builder.addFieldInt32(1, arg, class_.arguments_);
    80}
    81
    82static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
    83  builder.addFieldOffset(2, nameOffset, 0);
    84}
    85
    86static endTab(builder:flatbuffers.Builder):flatbuffers.Offset {
    87  const offset = builder.endObject();
    88  return offset;
    89}
    90
    91static createTab(builder:flatbuffers.Builder, abc:Abc, arg:class_, nameOffset:flatbuffers.Offset):flatbuffers.Offset {
    92  Tab.startTab(builder);
    93  Tab.addAbc(builder, abc);
    94  Tab.addArg(builder, arg);
    95  Tab.addName(builder, nameOffset);
    96  return Tab.endTab(builder);
    97}
    98
    99unpack(): TabT {
   100  return new TabT(
   101    this.abc(),
   102    this.arg(),
   103    this.name()
   104  );
   105}
   106
   107
   108unpackTo(_o: TabT): void {
   109  _o.abc = this.abc();
   110  _o.arg = this.arg();
   111  _o.name = this.name();
   112}
   113}
   114
   115export class TabT implements flatbuffers.IGeneratedObject {
   116constructor(
   117  public abc: Abc = Abc.a,
   118  public arg: class_ = class_.arguments_,
   119  public name: string|Uint8Array|null = null
   120){}
   121
   122
   123pack(builder:flatbuffers.Builder): flatbuffers.Offset {
   124  const name = (this.name !== null ? builder.createString(this.name!) : 0);
   125
   126  return Tab.createTab(builder,
   127    this.abc,
   128    this.arg,
   129    name
   130  );
   131}
   132}

View as plain text