...

Text file src/github.com/google/flatbuffers/tests/ts/reflection/rpccall.ts

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

     1// automatically generated by the FlatBuffers compiler, do not modify
     2
     3import * as flatbuffers from 'flatbuffers';
     4
     5import { KeyValue, KeyValueT } from '../reflection/key-value.js';
     6import { Object_, Object_T } from '../reflection/object.js';
     7
     8
     9export class RPCCall implements flatbuffers.IUnpackableObject<RPCCallT> {
    10  bb: flatbuffers.ByteBuffer|null = null;
    11  bb_pos = 0;
    12  __init(i:number, bb:flatbuffers.ByteBuffer):RPCCall {
    13  this.bb_pos = i;
    14  this.bb = bb;
    15  return this;
    16}
    17
    18static getRootAsRPCCall(bb:flatbuffers.ByteBuffer, obj?:RPCCall):RPCCall {
    19  return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    20}
    21
    22static getSizePrefixedRootAsRPCCall(bb:flatbuffers.ByteBuffer, obj?:RPCCall):RPCCall {
    23  bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
    24  return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    25}
    26
    27name():string|null
    28name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
    29name(optionalEncoding?:any):string|Uint8Array|null {
    30  const offset = this.bb!.__offset(this.bb_pos, 4);
    31  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
    32}
    33
    34request(obj?:Object_):Object_|null {
    35  const offset = this.bb!.__offset(this.bb_pos, 6);
    36  return offset ? (obj || new Object_()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
    37}
    38
    39response(obj?:Object_):Object_|null {
    40  const offset = this.bb!.__offset(this.bb_pos, 8);
    41  return offset ? (obj || new Object_()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
    42}
    43
    44attributes(index: number, obj?:KeyValue):KeyValue|null {
    45  const offset = this.bb!.__offset(this.bb_pos, 10);
    46  return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
    47}
    48
    49attributesLength():number {
    50  const offset = this.bb!.__offset(this.bb_pos, 10);
    51  return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
    52}
    53
    54documentation(index: number):string
    55documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
    56documentation(index: number,optionalEncoding?:any):string|Uint8Array|null {
    57  const offset = this.bb!.__offset(this.bb_pos, 12);
    58  return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
    59}
    60
    61documentationLength():number {
    62  const offset = this.bb!.__offset(this.bb_pos, 12);
    63  return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
    64}
    65
    66static getFullyQualifiedName():string {
    67  return 'reflection.RPCCall';
    68}
    69
    70static startRPCCall(builder:flatbuffers.Builder) {
    71  builder.startObject(5);
    72}
    73
    74static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
    75  builder.addFieldOffset(0, nameOffset, 0);
    76}
    77
    78static addRequest(builder:flatbuffers.Builder, requestOffset:flatbuffers.Offset) {
    79  builder.addFieldOffset(1, requestOffset, 0);
    80}
    81
    82static addResponse(builder:flatbuffers.Builder, responseOffset:flatbuffers.Offset) {
    83  builder.addFieldOffset(2, responseOffset, 0);
    84}
    85
    86static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) {
    87  builder.addFieldOffset(3, attributesOffset, 0);
    88}
    89
    90static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
    91  builder.startVector(4, data.length, 4);
    92  for (let i = data.length - 1; i >= 0; i--) {
    93    builder.addOffset(data[i]!);
    94  }
    95  return builder.endVector();
    96}
    97
    98static startAttributesVector(builder:flatbuffers.Builder, numElems:number) {
    99  builder.startVector(4, numElems, 4);
   100}
   101
   102static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) {
   103  builder.addFieldOffset(4, documentationOffset, 0);
   104}
   105
   106static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
   107  builder.startVector(4, data.length, 4);
   108  for (let i = data.length - 1; i >= 0; i--) {
   109    builder.addOffset(data[i]!);
   110  }
   111  return builder.endVector();
   112}
   113
   114static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) {
   115  builder.startVector(4, numElems, 4);
   116}
   117
   118static endRPCCall(builder:flatbuffers.Builder):flatbuffers.Offset {
   119  const offset = builder.endObject();
   120  builder.requiredField(offset, 4) // name
   121  builder.requiredField(offset, 6) // request
   122  builder.requiredField(offset, 8) // response
   123  return offset;
   124}
   125
   126
   127unpack(): RPCCallT {
   128  return new RPCCallT(
   129    this.name(),
   130    (this.request() !== null ? this.request()!.unpack() : null),
   131    (this.response() !== null ? this.response()!.unpack() : null),
   132    this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()),
   133    this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength())
   134  );
   135}
   136
   137
   138unpackTo(_o: RPCCallT): void {
   139  _o.name = this.name();
   140  _o.request = (this.request() !== null ? this.request()!.unpack() : null);
   141  _o.response = (this.response() !== null ? this.response()!.unpack() : null);
   142  _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength());
   143  _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength());
   144}
   145}
   146
   147export class RPCCallT implements flatbuffers.IGeneratedObject {
   148constructor(
   149  public name: string|Uint8Array|null = null,
   150  public request: Object_T|null = null,
   151  public response: Object_T|null = null,
   152  public attributes: (KeyValueT)[] = [],
   153  public documentation: (string)[] = []
   154){}
   155
   156
   157pack(builder:flatbuffers.Builder): flatbuffers.Offset {
   158  const name = (this.name !== null ? builder.createString(this.name!) : 0);
   159  const request = (this.request !== null ? this.request!.pack(builder) : 0);
   160  const response = (this.response !== null ? this.response!.pack(builder) : 0);
   161  const attributes = RPCCall.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
   162  const documentation = RPCCall.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
   163
   164  RPCCall.startRPCCall(builder);
   165  RPCCall.addName(builder, name);
   166  RPCCall.addRequest(builder, request);
   167  RPCCall.addResponse(builder, response);
   168  RPCCall.addAttributes(builder, attributes);
   169  RPCCall.addDocumentation(builder, documentation);
   170
   171  return RPCCall.endRPCCall(builder);
   172}
   173}

View as plain text