...

Text file src/github.com/google/flatbuffers/tests/ts/reflection/schema-file.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
     5
     6
     7/**
     8 * File specific information.
     9 * Symbols declared within a file may be recovered by iterating over all
    10 * symbols and examining the `declaration_file` field.
    11 */
    12export class SchemaFile implements flatbuffers.IUnpackableObject<SchemaFileT> {
    13  bb: flatbuffers.ByteBuffer|null = null;
    14  bb_pos = 0;
    15  __init(i:number, bb:flatbuffers.ByteBuffer):SchemaFile {
    16  this.bb_pos = i;
    17  this.bb = bb;
    18  return this;
    19}
    20
    21static getRootAsSchemaFile(bb:flatbuffers.ByteBuffer, obj?:SchemaFile):SchemaFile {
    22  return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    23}
    24
    25static getSizePrefixedRootAsSchemaFile(bb:flatbuffers.ByteBuffer, obj?:SchemaFile):SchemaFile {
    26  bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
    27  return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    28}
    29
    30/**
    31 * Filename, relative to project root.
    32 */
    33filename():string|null
    34filename(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
    35filename(optionalEncoding?:any):string|Uint8Array|null {
    36  const offset = this.bb!.__offset(this.bb_pos, 4);
    37  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
    38}
    39
    40/**
    41 * Names of included files, relative to project root.
    42 */
    43includedFilenames(index: number):string
    44includedFilenames(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
    45includedFilenames(index: number,optionalEncoding?:any):string|Uint8Array|null {
    46  const offset = this.bb!.__offset(this.bb_pos, 6);
    47  return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
    48}
    49
    50includedFilenamesLength():number {
    51  const offset = this.bb!.__offset(this.bb_pos, 6);
    52  return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
    53}
    54
    55static getFullyQualifiedName():string {
    56  return 'reflection.SchemaFile';
    57}
    58
    59static startSchemaFile(builder:flatbuffers.Builder) {
    60  builder.startObject(2);
    61}
    62
    63static addFilename(builder:flatbuffers.Builder, filenameOffset:flatbuffers.Offset) {
    64  builder.addFieldOffset(0, filenameOffset, 0);
    65}
    66
    67static addIncludedFilenames(builder:flatbuffers.Builder, includedFilenamesOffset:flatbuffers.Offset) {
    68  builder.addFieldOffset(1, includedFilenamesOffset, 0);
    69}
    70
    71static createIncludedFilenamesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
    72  builder.startVector(4, data.length, 4);
    73  for (let i = data.length - 1; i >= 0; i--) {
    74    builder.addOffset(data[i]!);
    75  }
    76  return builder.endVector();
    77}
    78
    79static startIncludedFilenamesVector(builder:flatbuffers.Builder, numElems:number) {
    80  builder.startVector(4, numElems, 4);
    81}
    82
    83static endSchemaFile(builder:flatbuffers.Builder):flatbuffers.Offset {
    84  const offset = builder.endObject();
    85  builder.requiredField(offset, 4) // filename
    86  return offset;
    87}
    88
    89static createSchemaFile(builder:flatbuffers.Builder, filenameOffset:flatbuffers.Offset, includedFilenamesOffset:flatbuffers.Offset):flatbuffers.Offset {
    90  SchemaFile.startSchemaFile(builder);
    91  SchemaFile.addFilename(builder, filenameOffset);
    92  SchemaFile.addIncludedFilenames(builder, includedFilenamesOffset);
    93  return SchemaFile.endSchemaFile(builder);
    94}
    95
    96unpack(): SchemaFileT {
    97  return new SchemaFileT(
    98    this.filename(),
    99    this.bb!.createScalarList<string>(this.includedFilenames.bind(this), this.includedFilenamesLength())
   100  );
   101}
   102
   103
   104unpackTo(_o: SchemaFileT): void {
   105  _o.filename = this.filename();
   106  _o.includedFilenames = this.bb!.createScalarList<string>(this.includedFilenames.bind(this), this.includedFilenamesLength());
   107}
   108}
   109
   110export class SchemaFileT implements flatbuffers.IGeneratedObject {
   111constructor(
   112  public filename: string|Uint8Array|null = null,
   113  public includedFilenames: (string)[] = []
   114){}
   115
   116
   117pack(builder:flatbuffers.Builder): flatbuffers.Offset {
   118  const filename = (this.filename !== null ? builder.createString(this.filename!) : 0);
   119  const includedFilenames = SchemaFile.createIncludedFilenamesVector(builder, builder.createObjectOffsetList(this.includedFilenames));
   120
   121  return SchemaFile.createSchemaFile(builder,
   122    filename,
   123    includedFilenames
   124  );
   125}
   126}

View as plain text