Austin Schuh | 2dd86a9 | 2022-09-14 21:19:23 -0700 | [diff] [blame^] | 1 | // automatically generated by the FlatBuffers compiler, do not modify |
| 2 | |
| 3 | import * as flatbuffers from 'flatbuffers'; |
| 4 | |
| 5 | import { Enum, EnumT } from '../reflection/enum.js'; |
| 6 | import { Object_, Object_T } from '../reflection/object.js'; |
| 7 | import { SchemaFile, SchemaFileT } from '../reflection/schema-file.js'; |
| 8 | import { Service, ServiceT } from '../reflection/service.js'; |
| 9 | |
| 10 | |
| 11 | export class Schema { |
| 12 | bb: flatbuffers.ByteBuffer|null = null; |
| 13 | bb_pos = 0; |
| 14 | __init(i:number, bb:flatbuffers.ByteBuffer):Schema { |
| 15 | this.bb_pos = i; |
| 16 | this.bb = bb; |
| 17 | return this; |
| 18 | } |
| 19 | |
| 20 | static getRootAsSchema(bb:flatbuffers.ByteBuffer, obj?:Schema):Schema { |
| 21 | return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb); |
| 22 | } |
| 23 | |
| 24 | static getSizePrefixedRootAsSchema(bb:flatbuffers.ByteBuffer, obj?:Schema):Schema { |
| 25 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); |
| 26 | return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb); |
| 27 | } |
| 28 | |
| 29 | static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean { |
| 30 | return bb.__has_identifier('BFBS'); |
| 31 | } |
| 32 | |
| 33 | objects(index: number, obj?:Object_):Object_|null { |
| 34 | const offset = this.bb!.__offset(this.bb_pos, 4); |
| 35 | return offset ? (obj || new Object_()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; |
| 36 | } |
| 37 | |
| 38 | objectsLength():number { |
| 39 | const offset = this.bb!.__offset(this.bb_pos, 4); |
| 40 | return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; |
| 41 | } |
| 42 | |
| 43 | enums(index: number, obj?:Enum):Enum|null { |
| 44 | const offset = this.bb!.__offset(this.bb_pos, 6); |
| 45 | return offset ? (obj || new Enum()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; |
| 46 | } |
| 47 | |
| 48 | enumsLength():number { |
| 49 | const offset = this.bb!.__offset(this.bb_pos, 6); |
| 50 | return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; |
| 51 | } |
| 52 | |
| 53 | fileIdent():string|null |
| 54 | fileIdent(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null |
| 55 | fileIdent(optionalEncoding?:any):string|Uint8Array|null { |
| 56 | const offset = this.bb!.__offset(this.bb_pos, 8); |
| 57 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; |
| 58 | } |
| 59 | |
| 60 | fileExt():string|null |
| 61 | fileExt(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null |
| 62 | fileExt(optionalEncoding?:any):string|Uint8Array|null { |
| 63 | const offset = this.bb!.__offset(this.bb_pos, 10); |
| 64 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; |
| 65 | } |
| 66 | |
| 67 | rootTable(obj?:Object_):Object_|null { |
| 68 | const offset = this.bb!.__offset(this.bb_pos, 12); |
| 69 | return offset ? (obj || new Object_()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; |
| 70 | } |
| 71 | |
| 72 | services(index: number, obj?:Service):Service|null { |
| 73 | const offset = this.bb!.__offset(this.bb_pos, 14); |
| 74 | return offset ? (obj || new Service()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; |
| 75 | } |
| 76 | |
| 77 | servicesLength():number { |
| 78 | const offset = this.bb!.__offset(this.bb_pos, 14); |
| 79 | return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; |
| 80 | } |
| 81 | |
| 82 | advancedFeatures():bigint { |
| 83 | const offset = this.bb!.__offset(this.bb_pos, 16); |
| 84 | return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); |
| 85 | } |
| 86 | |
| 87 | mutate_advanced_features(value:bigint):boolean { |
| 88 | const offset = this.bb!.__offset(this.bb_pos, 16); |
| 89 | |
| 90 | if (offset === 0) { |
| 91 | return false; |
| 92 | } |
| 93 | |
| 94 | this.bb!.writeUint64(this.bb_pos + offset, value); |
| 95 | return true; |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * All the files used in this compilation. Files are relative to where |
| 100 | * flatc was invoked. |
| 101 | */ |
| 102 | fbsFiles(index: number, obj?:SchemaFile):SchemaFile|null { |
| 103 | const offset = this.bb!.__offset(this.bb_pos, 18); |
| 104 | return offset ? (obj || new SchemaFile()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; |
| 105 | } |
| 106 | |
| 107 | fbsFilesLength():number { |
| 108 | const offset = this.bb!.__offset(this.bb_pos, 18); |
| 109 | return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; |
| 110 | } |
| 111 | |
| 112 | static getFullyQualifiedName():string { |
| 113 | return 'reflection_Schema'; |
| 114 | } |
| 115 | |
| 116 | static startSchema(builder:flatbuffers.Builder) { |
| 117 | builder.startObject(8); |
| 118 | } |
| 119 | |
| 120 | static addObjects(builder:flatbuffers.Builder, objectsOffset:flatbuffers.Offset) { |
| 121 | builder.addFieldOffset(0, objectsOffset, 0); |
| 122 | } |
| 123 | |
| 124 | static createObjectsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { |
| 125 | builder.startVector(4, data.length, 4); |
| 126 | for (let i = data.length - 1; i >= 0; i--) { |
| 127 | builder.addOffset(data[i]!); |
| 128 | } |
| 129 | return builder.endVector(); |
| 130 | } |
| 131 | |
| 132 | static startObjectsVector(builder:flatbuffers.Builder, numElems:number) { |
| 133 | builder.startVector(4, numElems, 4); |
| 134 | } |
| 135 | |
| 136 | static addEnums(builder:flatbuffers.Builder, enumsOffset:flatbuffers.Offset) { |
| 137 | builder.addFieldOffset(1, enumsOffset, 0); |
| 138 | } |
| 139 | |
| 140 | static createEnumsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { |
| 141 | builder.startVector(4, data.length, 4); |
| 142 | for (let i = data.length - 1; i >= 0; i--) { |
| 143 | builder.addOffset(data[i]!); |
| 144 | } |
| 145 | return builder.endVector(); |
| 146 | } |
| 147 | |
| 148 | static startEnumsVector(builder:flatbuffers.Builder, numElems:number) { |
| 149 | builder.startVector(4, numElems, 4); |
| 150 | } |
| 151 | |
| 152 | static addFileIdent(builder:flatbuffers.Builder, fileIdentOffset:flatbuffers.Offset) { |
| 153 | builder.addFieldOffset(2, fileIdentOffset, 0); |
| 154 | } |
| 155 | |
| 156 | static addFileExt(builder:flatbuffers.Builder, fileExtOffset:flatbuffers.Offset) { |
| 157 | builder.addFieldOffset(3, fileExtOffset, 0); |
| 158 | } |
| 159 | |
| 160 | static addRootTable(builder:flatbuffers.Builder, rootTableOffset:flatbuffers.Offset) { |
| 161 | builder.addFieldOffset(4, rootTableOffset, 0); |
| 162 | } |
| 163 | |
| 164 | static addServices(builder:flatbuffers.Builder, servicesOffset:flatbuffers.Offset) { |
| 165 | builder.addFieldOffset(5, servicesOffset, 0); |
| 166 | } |
| 167 | |
| 168 | static createServicesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { |
| 169 | builder.startVector(4, data.length, 4); |
| 170 | for (let i = data.length - 1; i >= 0; i--) { |
| 171 | builder.addOffset(data[i]!); |
| 172 | } |
| 173 | return builder.endVector(); |
| 174 | } |
| 175 | |
| 176 | static startServicesVector(builder:flatbuffers.Builder, numElems:number) { |
| 177 | builder.startVector(4, numElems, 4); |
| 178 | } |
| 179 | |
| 180 | static addAdvancedFeatures(builder:flatbuffers.Builder, advancedFeatures:bigint) { |
| 181 | builder.addFieldInt64(6, advancedFeatures, BigInt('0')); |
| 182 | } |
| 183 | |
| 184 | static addFbsFiles(builder:flatbuffers.Builder, fbsFilesOffset:flatbuffers.Offset) { |
| 185 | builder.addFieldOffset(7, fbsFilesOffset, 0); |
| 186 | } |
| 187 | |
| 188 | static createFbsFilesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { |
| 189 | builder.startVector(4, data.length, 4); |
| 190 | for (let i = data.length - 1; i >= 0; i--) { |
| 191 | builder.addOffset(data[i]!); |
| 192 | } |
| 193 | return builder.endVector(); |
| 194 | } |
| 195 | |
| 196 | static startFbsFilesVector(builder:flatbuffers.Builder, numElems:number) { |
| 197 | builder.startVector(4, numElems, 4); |
| 198 | } |
| 199 | |
| 200 | static endSchema(builder:flatbuffers.Builder):flatbuffers.Offset { |
| 201 | const offset = builder.endObject(); |
| 202 | builder.requiredField(offset, 4) // objects |
| 203 | builder.requiredField(offset, 6) // enums |
| 204 | return offset; |
| 205 | } |
| 206 | |
| 207 | static finishSchemaBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { |
| 208 | builder.finish(offset, 'BFBS'); |
| 209 | } |
| 210 | |
| 211 | static finishSizePrefixedSchemaBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { |
| 212 | builder.finish(offset, 'BFBS', true); |
| 213 | } |
| 214 | |
| 215 | |
| 216 | unpack(): SchemaT { |
| 217 | return new SchemaT( |
| 218 | this.bb!.createObjList(this.objects.bind(this), this.objectsLength()), |
| 219 | this.bb!.createObjList(this.enums.bind(this), this.enumsLength()), |
| 220 | this.fileIdent(), |
| 221 | this.fileExt(), |
| 222 | (this.rootTable() !== null ? this.rootTable()!.unpack() : null), |
| 223 | this.bb!.createObjList(this.services.bind(this), this.servicesLength()), |
| 224 | this.advancedFeatures(), |
| 225 | this.bb!.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength()) |
| 226 | ); |
| 227 | } |
| 228 | |
| 229 | |
| 230 | unpackTo(_o: SchemaT): void { |
| 231 | _o.objects = this.bb!.createObjList(this.objects.bind(this), this.objectsLength()); |
| 232 | _o.enums = this.bb!.createObjList(this.enums.bind(this), this.enumsLength()); |
| 233 | _o.fileIdent = this.fileIdent(); |
| 234 | _o.fileExt = this.fileExt(); |
| 235 | _o.rootTable = (this.rootTable() !== null ? this.rootTable()!.unpack() : null); |
| 236 | _o.services = this.bb!.createObjList(this.services.bind(this), this.servicesLength()); |
| 237 | _o.advancedFeatures = this.advancedFeatures(); |
| 238 | _o.fbsFiles = this.bb!.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength()); |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | export class SchemaT { |
| 243 | constructor( |
| 244 | public objects: (Object_T)[] = [], |
| 245 | public enums: (EnumT)[] = [], |
| 246 | public fileIdent: string|Uint8Array|null = null, |
| 247 | public fileExt: string|Uint8Array|null = null, |
| 248 | public rootTable: Object_T|null = null, |
| 249 | public services: (ServiceT)[] = [], |
| 250 | public advancedFeatures: bigint = BigInt('0'), |
| 251 | public fbsFiles: (SchemaFileT)[] = [] |
| 252 | ){} |
| 253 | |
| 254 | |
| 255 | pack(builder:flatbuffers.Builder): flatbuffers.Offset { |
| 256 | const objects = Schema.createObjectsVector(builder, builder.createObjectOffsetList(this.objects)); |
| 257 | const enums = Schema.createEnumsVector(builder, builder.createObjectOffsetList(this.enums)); |
| 258 | const fileIdent = (this.fileIdent !== null ? builder.createString(this.fileIdent!) : 0); |
| 259 | const fileExt = (this.fileExt !== null ? builder.createString(this.fileExt!) : 0); |
| 260 | const rootTable = (this.rootTable !== null ? this.rootTable!.pack(builder) : 0); |
| 261 | const services = Schema.createServicesVector(builder, builder.createObjectOffsetList(this.services)); |
| 262 | const fbsFiles = Schema.createFbsFilesVector(builder, builder.createObjectOffsetList(this.fbsFiles)); |
| 263 | |
| 264 | Schema.startSchema(builder); |
| 265 | Schema.addObjects(builder, objects); |
| 266 | Schema.addEnums(builder, enums); |
| 267 | Schema.addFileIdent(builder, fileIdent); |
| 268 | Schema.addFileExt(builder, fileExt); |
| 269 | Schema.addRootTable(builder, rootTable); |
| 270 | Schema.addServices(builder, services); |
| 271 | Schema.addAdvancedFeatures(builder, this.advancedFeatures); |
| 272 | Schema.addFbsFiles(builder, fbsFiles); |
| 273 | |
| 274 | return Schema.endSchema(builder); |
| 275 | } |
| 276 | } |