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 { KeyValue, KeyValueT } from '../reflection/key-value.js'; |
| 6 | import { Type, TypeT } from '../reflection/type.js'; |
| 7 | |
| 8 | |
James Kuszmaul | 3b15b0c | 2022-11-08 14:03:16 -0800 | [diff] [blame^] | 9 | export class Field implements flatbuffers.IUnpackableObject<FieldT> { |
Austin Schuh | 2dd86a9 | 2022-09-14 21:19:23 -0700 | [diff] [blame] | 10 | bb: flatbuffers.ByteBuffer|null = null; |
| 11 | bb_pos = 0; |
| 12 | __init(i:number, bb:flatbuffers.ByteBuffer):Field { |
| 13 | this.bb_pos = i; |
| 14 | this.bb = bb; |
| 15 | return this; |
| 16 | } |
| 17 | |
| 18 | static getRootAsField(bb:flatbuffers.ByteBuffer, obj?:Field):Field { |
| 19 | return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb); |
| 20 | } |
| 21 | |
| 22 | static getSizePrefixedRootAsField(bb:flatbuffers.ByteBuffer, obj?:Field):Field { |
| 23 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); |
| 24 | return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb); |
| 25 | } |
| 26 | |
| 27 | name():string|null |
| 28 | name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null |
| 29 | name(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 | |
| 34 | type(obj?:Type):Type|null { |
| 35 | const offset = this.bb!.__offset(this.bb_pos, 6); |
| 36 | return offset ? (obj || new Type()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; |
| 37 | } |
| 38 | |
| 39 | id():number { |
| 40 | const offset = this.bb!.__offset(this.bb_pos, 8); |
| 41 | return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; |
| 42 | } |
| 43 | |
| 44 | mutate_id(value:number):boolean { |
| 45 | const offset = this.bb!.__offset(this.bb_pos, 8); |
| 46 | |
| 47 | if (offset === 0) { |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | this.bb!.writeUint16(this.bb_pos + offset, value); |
| 52 | return true; |
| 53 | } |
| 54 | |
| 55 | offset():number { |
| 56 | const offset = this.bb!.__offset(this.bb_pos, 10); |
| 57 | return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; |
| 58 | } |
| 59 | |
| 60 | mutate_offset(value:number):boolean { |
| 61 | const offset = this.bb!.__offset(this.bb_pos, 10); |
| 62 | |
| 63 | if (offset === 0) { |
| 64 | return false; |
| 65 | } |
| 66 | |
| 67 | this.bb!.writeUint16(this.bb_pos + offset, value); |
| 68 | return true; |
| 69 | } |
| 70 | |
| 71 | defaultInteger():bigint { |
| 72 | const offset = this.bb!.__offset(this.bb_pos, 12); |
| 73 | return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0'); |
| 74 | } |
| 75 | |
| 76 | mutate_default_integer(value:bigint):boolean { |
| 77 | const offset = this.bb!.__offset(this.bb_pos, 12); |
| 78 | |
| 79 | if (offset === 0) { |
| 80 | return false; |
| 81 | } |
| 82 | |
| 83 | this.bb!.writeInt64(this.bb_pos + offset, value); |
| 84 | return true; |
| 85 | } |
| 86 | |
| 87 | defaultReal():number { |
| 88 | const offset = this.bb!.__offset(this.bb_pos, 14); |
| 89 | return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0; |
| 90 | } |
| 91 | |
| 92 | mutate_default_real(value:number):boolean { |
| 93 | const offset = this.bb!.__offset(this.bb_pos, 14); |
| 94 | |
| 95 | if (offset === 0) { |
| 96 | return false; |
| 97 | } |
| 98 | |
| 99 | this.bb!.writeFloat64(this.bb_pos + offset, value); |
| 100 | return true; |
| 101 | } |
| 102 | |
| 103 | deprecated():boolean { |
| 104 | const offset = this.bb!.__offset(this.bb_pos, 16); |
| 105 | return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; |
| 106 | } |
| 107 | |
| 108 | mutate_deprecated(value:boolean):boolean { |
| 109 | const offset = this.bb!.__offset(this.bb_pos, 16); |
| 110 | |
| 111 | if (offset === 0) { |
| 112 | return false; |
| 113 | } |
| 114 | |
| 115 | this.bb!.writeInt8(this.bb_pos + offset, +value); |
| 116 | return true; |
| 117 | } |
| 118 | |
| 119 | required():boolean { |
| 120 | const offset = this.bb!.__offset(this.bb_pos, 18); |
| 121 | return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; |
| 122 | } |
| 123 | |
| 124 | mutate_required(value:boolean):boolean { |
| 125 | const offset = this.bb!.__offset(this.bb_pos, 18); |
| 126 | |
| 127 | if (offset === 0) { |
| 128 | return false; |
| 129 | } |
| 130 | |
| 131 | this.bb!.writeInt8(this.bb_pos + offset, +value); |
| 132 | return true; |
| 133 | } |
| 134 | |
| 135 | key():boolean { |
| 136 | const offset = this.bb!.__offset(this.bb_pos, 20); |
| 137 | return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; |
| 138 | } |
| 139 | |
| 140 | mutate_key(value:boolean):boolean { |
| 141 | const offset = this.bb!.__offset(this.bb_pos, 20); |
| 142 | |
| 143 | if (offset === 0) { |
| 144 | return false; |
| 145 | } |
| 146 | |
| 147 | this.bb!.writeInt8(this.bb_pos + offset, +value); |
| 148 | return true; |
| 149 | } |
| 150 | |
| 151 | attributes(index: number, obj?:KeyValue):KeyValue|null { |
| 152 | const offset = this.bb!.__offset(this.bb_pos, 22); |
| 153 | return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; |
| 154 | } |
| 155 | |
| 156 | attributesLength():number { |
| 157 | const offset = this.bb!.__offset(this.bb_pos, 22); |
| 158 | return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; |
| 159 | } |
| 160 | |
| 161 | documentation(index: number):string |
| 162 | documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array |
| 163 | documentation(index: number,optionalEncoding?:any):string|Uint8Array|null { |
| 164 | const offset = this.bb!.__offset(this.bb_pos, 24); |
| 165 | return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; |
| 166 | } |
| 167 | |
| 168 | documentationLength():number { |
| 169 | const offset = this.bb!.__offset(this.bb_pos, 24); |
| 170 | return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; |
| 171 | } |
| 172 | |
| 173 | optional():boolean { |
| 174 | const offset = this.bb!.__offset(this.bb_pos, 26); |
| 175 | return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; |
| 176 | } |
| 177 | |
| 178 | mutate_optional(value:boolean):boolean { |
| 179 | const offset = this.bb!.__offset(this.bb_pos, 26); |
| 180 | |
| 181 | if (offset === 0) { |
| 182 | return false; |
| 183 | } |
| 184 | |
| 185 | this.bb!.writeInt8(this.bb_pos + offset, +value); |
| 186 | return true; |
| 187 | } |
| 188 | |
| 189 | /** |
| 190 | * Number of padding octets to always add after this field. Structs only. |
| 191 | */ |
| 192 | padding():number { |
| 193 | const offset = this.bb!.__offset(this.bb_pos, 28); |
| 194 | return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; |
| 195 | } |
| 196 | |
| 197 | mutate_padding(value:number):boolean { |
| 198 | const offset = this.bb!.__offset(this.bb_pos, 28); |
| 199 | |
| 200 | if (offset === 0) { |
| 201 | return false; |
| 202 | } |
| 203 | |
| 204 | this.bb!.writeUint16(this.bb_pos + offset, value); |
| 205 | return true; |
| 206 | } |
| 207 | |
| 208 | static getFullyQualifiedName():string { |
| 209 | return 'reflection_Field'; |
| 210 | } |
| 211 | |
| 212 | static startField(builder:flatbuffers.Builder) { |
| 213 | builder.startObject(13); |
| 214 | } |
| 215 | |
| 216 | static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { |
| 217 | builder.addFieldOffset(0, nameOffset, 0); |
| 218 | } |
| 219 | |
| 220 | static addType(builder:flatbuffers.Builder, typeOffset:flatbuffers.Offset) { |
| 221 | builder.addFieldOffset(1, typeOffset, 0); |
| 222 | } |
| 223 | |
| 224 | static addId(builder:flatbuffers.Builder, id:number) { |
| 225 | builder.addFieldInt16(2, id, 0); |
| 226 | } |
| 227 | |
| 228 | static addOffset(builder:flatbuffers.Builder, offset:number) { |
| 229 | builder.addFieldInt16(3, offset, 0); |
| 230 | } |
| 231 | |
| 232 | static addDefaultInteger(builder:flatbuffers.Builder, defaultInteger:bigint) { |
| 233 | builder.addFieldInt64(4, defaultInteger, BigInt('0')); |
| 234 | } |
| 235 | |
| 236 | static addDefaultReal(builder:flatbuffers.Builder, defaultReal:number) { |
| 237 | builder.addFieldFloat64(5, defaultReal, 0.0); |
| 238 | } |
| 239 | |
| 240 | static addDeprecated(builder:flatbuffers.Builder, deprecated:boolean) { |
| 241 | builder.addFieldInt8(6, +deprecated, +false); |
| 242 | } |
| 243 | |
| 244 | static addRequired(builder:flatbuffers.Builder, required:boolean) { |
| 245 | builder.addFieldInt8(7, +required, +false); |
| 246 | } |
| 247 | |
| 248 | static addKey(builder:flatbuffers.Builder, key:boolean) { |
| 249 | builder.addFieldInt8(8, +key, +false); |
| 250 | } |
| 251 | |
| 252 | static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) { |
| 253 | builder.addFieldOffset(9, attributesOffset, 0); |
| 254 | } |
| 255 | |
| 256 | static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { |
| 257 | builder.startVector(4, data.length, 4); |
| 258 | for (let i = data.length - 1; i >= 0; i--) { |
| 259 | builder.addOffset(data[i]!); |
| 260 | } |
| 261 | return builder.endVector(); |
| 262 | } |
| 263 | |
| 264 | static startAttributesVector(builder:flatbuffers.Builder, numElems:number) { |
| 265 | builder.startVector(4, numElems, 4); |
| 266 | } |
| 267 | |
| 268 | static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) { |
| 269 | builder.addFieldOffset(10, documentationOffset, 0); |
| 270 | } |
| 271 | |
| 272 | static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { |
| 273 | builder.startVector(4, data.length, 4); |
| 274 | for (let i = data.length - 1; i >= 0; i--) { |
| 275 | builder.addOffset(data[i]!); |
| 276 | } |
| 277 | return builder.endVector(); |
| 278 | } |
| 279 | |
| 280 | static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) { |
| 281 | builder.startVector(4, numElems, 4); |
| 282 | } |
| 283 | |
| 284 | static addOptional(builder:flatbuffers.Builder, optional:boolean) { |
| 285 | builder.addFieldInt8(11, +optional, +false); |
| 286 | } |
| 287 | |
| 288 | static addPadding(builder:flatbuffers.Builder, padding:number) { |
| 289 | builder.addFieldInt16(12, padding, 0); |
| 290 | } |
| 291 | |
| 292 | static endField(builder:flatbuffers.Builder):flatbuffers.Offset { |
| 293 | const offset = builder.endObject(); |
| 294 | builder.requiredField(offset, 4) // name |
| 295 | builder.requiredField(offset, 6) // type |
| 296 | return offset; |
| 297 | } |
| 298 | |
| 299 | |
| 300 | unpack(): FieldT { |
| 301 | return new FieldT( |
| 302 | this.name(), |
| 303 | (this.type() !== null ? this.type()!.unpack() : null), |
| 304 | this.id(), |
| 305 | this.offset(), |
| 306 | this.defaultInteger(), |
| 307 | this.defaultReal(), |
| 308 | this.deprecated(), |
| 309 | this.required(), |
| 310 | this.key(), |
James Kuszmaul | 3b15b0c | 2022-11-08 14:03:16 -0800 | [diff] [blame^] | 311 | this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()), |
| 312 | this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()), |
Austin Schuh | 2dd86a9 | 2022-09-14 21:19:23 -0700 | [diff] [blame] | 313 | this.optional(), |
| 314 | this.padding() |
| 315 | ); |
| 316 | } |
| 317 | |
| 318 | |
| 319 | unpackTo(_o: FieldT): void { |
| 320 | _o.name = this.name(); |
| 321 | _o.type = (this.type() !== null ? this.type()!.unpack() : null); |
| 322 | _o.id = this.id(); |
| 323 | _o.offset = this.offset(); |
| 324 | _o.defaultInteger = this.defaultInteger(); |
| 325 | _o.defaultReal = this.defaultReal(); |
| 326 | _o.deprecated = this.deprecated(); |
| 327 | _o.required = this.required(); |
| 328 | _o.key = this.key(); |
James Kuszmaul | 3b15b0c | 2022-11-08 14:03:16 -0800 | [diff] [blame^] | 329 | _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()); |
| 330 | _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()); |
Austin Schuh | 2dd86a9 | 2022-09-14 21:19:23 -0700 | [diff] [blame] | 331 | _o.optional = this.optional(); |
| 332 | _o.padding = this.padding(); |
| 333 | } |
| 334 | } |
| 335 | |
James Kuszmaul | 3b15b0c | 2022-11-08 14:03:16 -0800 | [diff] [blame^] | 336 | export class FieldT implements flatbuffers.IGeneratedObject { |
Austin Schuh | 2dd86a9 | 2022-09-14 21:19:23 -0700 | [diff] [blame] | 337 | constructor( |
| 338 | public name: string|Uint8Array|null = null, |
| 339 | public type: TypeT|null = null, |
| 340 | public id: number = 0, |
| 341 | public offset: number = 0, |
| 342 | public defaultInteger: bigint = BigInt('0'), |
| 343 | public defaultReal: number = 0.0, |
| 344 | public deprecated: boolean = false, |
| 345 | public required: boolean = false, |
| 346 | public key: boolean = false, |
| 347 | public attributes: (KeyValueT)[] = [], |
| 348 | public documentation: (string)[] = [], |
| 349 | public optional: boolean = false, |
| 350 | public padding: number = 0 |
| 351 | ){} |
| 352 | |
| 353 | |
| 354 | pack(builder:flatbuffers.Builder): flatbuffers.Offset { |
| 355 | const name = (this.name !== null ? builder.createString(this.name!) : 0); |
| 356 | const type = (this.type !== null ? this.type!.pack(builder) : 0); |
| 357 | const attributes = Field.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); |
| 358 | const documentation = Field.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); |
| 359 | |
| 360 | Field.startField(builder); |
| 361 | Field.addName(builder, name); |
| 362 | Field.addType(builder, type); |
| 363 | Field.addId(builder, this.id); |
| 364 | Field.addOffset(builder, this.offset); |
| 365 | Field.addDefaultInteger(builder, this.defaultInteger); |
| 366 | Field.addDefaultReal(builder, this.defaultReal); |
| 367 | Field.addDeprecated(builder, this.deprecated); |
| 368 | Field.addRequired(builder, this.required); |
| 369 | Field.addKey(builder, this.key); |
| 370 | Field.addAttributes(builder, attributes); |
| 371 | Field.addDocumentation(builder, documentation); |
| 372 | Field.addOptional(builder, this.optional); |
| 373 | Field.addPadding(builder, this.padding); |
| 374 | |
| 375 | return Field.endField(builder); |
| 376 | } |
| 377 | } |