...

Text file src/github.com/google/flatbuffers/tests/ts/typescript/object.ts

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

     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_ as foobar_class_ } from '../foobar/class.js';
     7import { Schema, SchemaT } from '../reflection/schema.js';
     8import { class_ } from '../typescript/class.js';
     9
    10
    11export class Object_ implements flatbuffers.IUnpackableObject<Object_T> {
    12  bb: flatbuffers.ByteBuffer|null = null;
    13  bb_pos = 0;
    14  __init(i:number, bb:flatbuffers.ByteBuffer):Object_ {
    15  this.bb_pos = i;
    16  this.bb = bb;
    17  return this;
    18}
    19
    20static getRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ {
    21  return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    22}
    23
    24static getSizePrefixedRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ {
    25  bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
    26  return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    27}
    28
    29return_():number {
    30  const offset = this.bb!.__offset(this.bb_pos, 4);
    31  return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
    32}
    33
    34mutate_return(value:number):boolean {
    35  const offset = this.bb!.__offset(this.bb_pos, 4);
    36
    37  if (offset === 0) {
    38    return false;
    39  }
    40
    41  this.bb!.writeInt32(this.bb_pos + offset, value);
    42  return true;
    43}
    44
    45if_():number {
    46  const offset = this.bb!.__offset(this.bb_pos, 6);
    47  return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
    48}
    49
    50mutate_if(value:number):boolean {
    51  const offset = this.bb!.__offset(this.bb_pos, 6);
    52
    53  if (offset === 0) {
    54    return false;
    55  }
    56
    57  this.bb!.writeInt32(this.bb_pos + offset, value);
    58  return true;
    59}
    60
    61switch_():number {
    62  const offset = this.bb!.__offset(this.bb_pos, 8);
    63  return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
    64}
    65
    66mutate_switch(value:number):boolean {
    67  const offset = this.bb!.__offset(this.bb_pos, 8);
    68
    69  if (offset === 0) {
    70    return false;
    71  }
    72
    73  this.bb!.writeInt32(this.bb_pos + offset, value);
    74  return true;
    75}
    76
    77enum_():class_ {
    78  const offset = this.bb!.__offset(this.bb_pos, 10);
    79  return offset ? this.bb!.readInt32(this.bb_pos + offset) : class_.new_;
    80}
    81
    82mutate_enum(value:class_):boolean {
    83  const offset = this.bb!.__offset(this.bb_pos, 10);
    84
    85  if (offset === 0) {
    86    return false;
    87  }
    88
    89  this.bb!.writeInt32(this.bb_pos + offset, value);
    90  return true;
    91}
    92
    93enum2():foobar_class_ {
    94  const offset = this.bb!.__offset(this.bb_pos, 12);
    95  return offset ? this.bb!.readInt32(this.bb_pos + offset) : foobar_class_.arguments_;
    96}
    97
    98mutate_enum2(value:foobar_class_):boolean {
    99  const offset = this.bb!.__offset(this.bb_pos, 12);
   100
   101  if (offset === 0) {
   102    return false;
   103  }
   104
   105  this.bb!.writeInt32(this.bb_pos + offset, value);
   106  return true;
   107}
   108
   109enum3():Abc {
   110  const offset = this.bb!.__offset(this.bb_pos, 14);
   111  return offset ? this.bb!.readInt32(this.bb_pos + offset) : Abc.a;
   112}
   113
   114mutate_enum3(value:Abc):boolean {
   115  const offset = this.bb!.__offset(this.bb_pos, 14);
   116
   117  if (offset === 0) {
   118    return false;
   119  }
   120
   121  this.bb!.writeInt32(this.bb_pos + offset, value);
   122  return true;
   123}
   124
   125reflect(obj?:Schema):Schema|null {
   126  const offset = this.bb!.__offset(this.bb_pos, 16);
   127  return offset ? (obj || new Schema()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
   128}
   129
   130static getFullyQualifiedName():string {
   131  return 'typescript.Object';
   132}
   133
   134static startObject(builder:flatbuffers.Builder) {
   135  builder.startObject(7);
   136}
   137
   138static addReturn(builder:flatbuffers.Builder, return_:number) {
   139  builder.addFieldInt32(0, return_, 0);
   140}
   141
   142static addIf(builder:flatbuffers.Builder, if_:number) {
   143  builder.addFieldInt32(1, if_, 0);
   144}
   145
   146static addSwitch(builder:flatbuffers.Builder, switch_:number) {
   147  builder.addFieldInt32(2, switch_, 0);
   148}
   149
   150static addEnum(builder:flatbuffers.Builder, enum_:class_) {
   151  builder.addFieldInt32(3, enum_, class_.new_);
   152}
   153
   154static addEnum2(builder:flatbuffers.Builder, enum2:foobar_class_) {
   155  builder.addFieldInt32(4, enum2, foobar_class_.arguments_);
   156}
   157
   158static addEnum3(builder:flatbuffers.Builder, enum3:Abc) {
   159  builder.addFieldInt32(5, enum3, Abc.a);
   160}
   161
   162static addReflect(builder:flatbuffers.Builder, reflectOffset:flatbuffers.Offset) {
   163  builder.addFieldOffset(6, reflectOffset, 0);
   164}
   165
   166static endObject(builder:flatbuffers.Builder):flatbuffers.Offset {
   167  const offset = builder.endObject();
   168  return offset;
   169}
   170
   171
   172unpack(): Object_T {
   173  return new Object_T(
   174    this.return_(),
   175    this.if_(),
   176    this.switch_(),
   177    this.enum_(),
   178    this.enum2(),
   179    this.enum3(),
   180    (this.reflect() !== null ? this.reflect()!.unpack() : null)
   181  );
   182}
   183
   184
   185unpackTo(_o: Object_T): void {
   186  _o.return_ = this.return_();
   187  _o.if_ = this.if_();
   188  _o.switch_ = this.switch_();
   189  _o.enum_ = this.enum_();
   190  _o.enum2 = this.enum2();
   191  _o.enum3 = this.enum3();
   192  _o.reflect = (this.reflect() !== null ? this.reflect()!.unpack() : null);
   193}
   194}
   195
   196export class Object_T implements flatbuffers.IGeneratedObject {
   197constructor(
   198  public return_: number = 0,
   199  public if_: number = 0,
   200  public switch_: number = 0,
   201  public enum_: class_ = class_.new_,
   202  public enum2: foobar_class_ = foobar_class_.arguments_,
   203  public enum3: Abc = Abc.a,
   204  public reflect: SchemaT|null = null
   205){}
   206
   207
   208pack(builder:flatbuffers.Builder): flatbuffers.Offset {
   209  const reflect = (this.reflect !== null ? this.reflect!.pack(builder) : 0);
   210
   211  Object_.startObject(builder);
   212  Object_.addReturn(builder, this.return_);
   213  Object_.addIf(builder, this.if_);
   214  Object_.addSwitch(builder, this.switch_);
   215  Object_.addEnum(builder, this.enum_);
   216  Object_.addEnum2(builder, this.enum2);
   217  Object_.addEnum3(builder, this.enum3);
   218  Object_.addReflect(builder, reflect);
   219
   220  return Object_.endObject(builder);
   221}
   222}

View as plain text