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 { Field, FieldT } from '../reflection/field.js'; |
| 6 | import { KeyValue, KeyValueT } from '../reflection/key-value.js'; |
| 7 | |
| 8 | |
James Kuszmaul | 3b15b0c | 2022-11-08 14:03:16 -0800 | [diff] [blame^] | 9 | export class Object_ implements flatbuffers.IUnpackableObject<Object_T> { |
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):Object_ { |
| 13 | this.bb_pos = i; |
| 14 | this.bb = bb; |
| 15 | return this; |
| 16 | } |
| 17 | |
| 18 | static getRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ { |
| 19 | return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); |
| 20 | } |
| 21 | |
| 22 | static getSizePrefixedRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ { |
| 23 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); |
| 24 | return (obj || new Object_()).__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 | fields(index: number, obj?:Field):Field|null { |
| 35 | const offset = this.bb!.__offset(this.bb_pos, 6); |
| 36 | return offset ? (obj || new Field()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; |
| 37 | } |
| 38 | |
| 39 | fieldsLength():number { |
| 40 | const offset = this.bb!.__offset(this.bb_pos, 6); |
| 41 | return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; |
| 42 | } |
| 43 | |
| 44 | isStruct():boolean { |
| 45 | const offset = this.bb!.__offset(this.bb_pos, 8); |
| 46 | return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; |
| 47 | } |
| 48 | |
| 49 | mutate_is_struct(value:boolean):boolean { |
| 50 | const offset = this.bb!.__offset(this.bb_pos, 8); |
| 51 | |
| 52 | if (offset === 0) { |
| 53 | return false; |
| 54 | } |
| 55 | |
| 56 | this.bb!.writeInt8(this.bb_pos + offset, +value); |
| 57 | return true; |
| 58 | } |
| 59 | |
| 60 | minalign():number { |
| 61 | const offset = this.bb!.__offset(this.bb_pos, 10); |
| 62 | return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; |
| 63 | } |
| 64 | |
| 65 | mutate_minalign(value:number):boolean { |
| 66 | const offset = this.bb!.__offset(this.bb_pos, 10); |
| 67 | |
| 68 | if (offset === 0) { |
| 69 | return false; |
| 70 | } |
| 71 | |
| 72 | this.bb!.writeInt32(this.bb_pos + offset, value); |
| 73 | return true; |
| 74 | } |
| 75 | |
| 76 | bytesize():number { |
| 77 | const offset = this.bb!.__offset(this.bb_pos, 12); |
| 78 | return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; |
| 79 | } |
| 80 | |
| 81 | mutate_bytesize(value:number):boolean { |
| 82 | const offset = this.bb!.__offset(this.bb_pos, 12); |
| 83 | |
| 84 | if (offset === 0) { |
| 85 | return false; |
| 86 | } |
| 87 | |
| 88 | this.bb!.writeInt32(this.bb_pos + offset, value); |
| 89 | return true; |
| 90 | } |
| 91 | |
| 92 | attributes(index: number, obj?:KeyValue):KeyValue|null { |
| 93 | const offset = this.bb!.__offset(this.bb_pos, 14); |
| 94 | return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; |
| 95 | } |
| 96 | |
| 97 | attributesLength():number { |
| 98 | const offset = this.bb!.__offset(this.bb_pos, 14); |
| 99 | return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; |
| 100 | } |
| 101 | |
| 102 | documentation(index: number):string |
| 103 | documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array |
| 104 | documentation(index: number,optionalEncoding?:any):string|Uint8Array|null { |
| 105 | const offset = this.bb!.__offset(this.bb_pos, 16); |
| 106 | return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; |
| 107 | } |
| 108 | |
| 109 | documentationLength():number { |
| 110 | const offset = this.bb!.__offset(this.bb_pos, 16); |
| 111 | return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * File that this Object is declared in. |
| 116 | */ |
| 117 | declarationFile():string|null |
| 118 | declarationFile(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null |
| 119 | declarationFile(optionalEncoding?:any):string|Uint8Array|null { |
| 120 | const offset = this.bb!.__offset(this.bb_pos, 18); |
| 121 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; |
| 122 | } |
| 123 | |
| 124 | static getFullyQualifiedName():string { |
| 125 | return 'reflection_Object'; |
| 126 | } |
| 127 | |
| 128 | static startObject(builder:flatbuffers.Builder) { |
| 129 | builder.startObject(8); |
| 130 | } |
| 131 | |
| 132 | static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { |
| 133 | builder.addFieldOffset(0, nameOffset, 0); |
| 134 | } |
| 135 | |
| 136 | static addFields(builder:flatbuffers.Builder, fieldsOffset:flatbuffers.Offset) { |
| 137 | builder.addFieldOffset(1, fieldsOffset, 0); |
| 138 | } |
| 139 | |
| 140 | static createFieldsVector(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 startFieldsVector(builder:flatbuffers.Builder, numElems:number) { |
| 149 | builder.startVector(4, numElems, 4); |
| 150 | } |
| 151 | |
| 152 | static addIsStruct(builder:flatbuffers.Builder, isStruct:boolean) { |
| 153 | builder.addFieldInt8(2, +isStruct, +false); |
| 154 | } |
| 155 | |
| 156 | static addMinalign(builder:flatbuffers.Builder, minalign:number) { |
| 157 | builder.addFieldInt32(3, minalign, 0); |
| 158 | } |
| 159 | |
| 160 | static addBytesize(builder:flatbuffers.Builder, bytesize:number) { |
| 161 | builder.addFieldInt32(4, bytesize, 0); |
| 162 | } |
| 163 | |
| 164 | static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) { |
| 165 | builder.addFieldOffset(5, attributesOffset, 0); |
| 166 | } |
| 167 | |
| 168 | static createAttributesVector(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 startAttributesVector(builder:flatbuffers.Builder, numElems:number) { |
| 177 | builder.startVector(4, numElems, 4); |
| 178 | } |
| 179 | |
| 180 | static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) { |
| 181 | builder.addFieldOffset(6, documentationOffset, 0); |
| 182 | } |
| 183 | |
| 184 | static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { |
| 185 | builder.startVector(4, data.length, 4); |
| 186 | for (let i = data.length - 1; i >= 0; i--) { |
| 187 | builder.addOffset(data[i]!); |
| 188 | } |
| 189 | return builder.endVector(); |
| 190 | } |
| 191 | |
| 192 | static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) { |
| 193 | builder.startVector(4, numElems, 4); |
| 194 | } |
| 195 | |
| 196 | static addDeclarationFile(builder:flatbuffers.Builder, declarationFileOffset:flatbuffers.Offset) { |
| 197 | builder.addFieldOffset(7, declarationFileOffset, 0); |
| 198 | } |
| 199 | |
| 200 | static endObject(builder:flatbuffers.Builder):flatbuffers.Offset { |
| 201 | const offset = builder.endObject(); |
| 202 | builder.requiredField(offset, 4) // name |
| 203 | builder.requiredField(offset, 6) // fields |
| 204 | return offset; |
| 205 | } |
| 206 | |
| 207 | static createObject(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset, fieldsOffset:flatbuffers.Offset, isStruct:boolean, minalign:number, bytesize:number, attributesOffset:flatbuffers.Offset, documentationOffset:flatbuffers.Offset, declarationFileOffset:flatbuffers.Offset):flatbuffers.Offset { |
| 208 | Object_.startObject(builder); |
| 209 | Object_.addName(builder, nameOffset); |
| 210 | Object_.addFields(builder, fieldsOffset); |
| 211 | Object_.addIsStruct(builder, isStruct); |
| 212 | Object_.addMinalign(builder, minalign); |
| 213 | Object_.addBytesize(builder, bytesize); |
| 214 | Object_.addAttributes(builder, attributesOffset); |
| 215 | Object_.addDocumentation(builder, documentationOffset); |
| 216 | Object_.addDeclarationFile(builder, declarationFileOffset); |
| 217 | return Object_.endObject(builder); |
| 218 | } |
| 219 | |
| 220 | unpack(): Object_T { |
| 221 | return new Object_T( |
| 222 | this.name(), |
James Kuszmaul | 3b15b0c | 2022-11-08 14:03:16 -0800 | [diff] [blame^] | 223 | this.bb!.createObjList<Field, FieldT>(this.fields.bind(this), this.fieldsLength()), |
Austin Schuh | 2dd86a9 | 2022-09-14 21:19:23 -0700 | [diff] [blame] | 224 | this.isStruct(), |
| 225 | this.minalign(), |
| 226 | this.bytesize(), |
James Kuszmaul | 3b15b0c | 2022-11-08 14:03:16 -0800 | [diff] [blame^] | 227 | this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()), |
| 228 | this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()), |
Austin Schuh | 2dd86a9 | 2022-09-14 21:19:23 -0700 | [diff] [blame] | 229 | this.declarationFile() |
| 230 | ); |
| 231 | } |
| 232 | |
| 233 | |
| 234 | unpackTo(_o: Object_T): void { |
| 235 | _o.name = this.name(); |
James Kuszmaul | 3b15b0c | 2022-11-08 14:03:16 -0800 | [diff] [blame^] | 236 | _o.fields = this.bb!.createObjList<Field, FieldT>(this.fields.bind(this), this.fieldsLength()); |
Austin Schuh | 2dd86a9 | 2022-09-14 21:19:23 -0700 | [diff] [blame] | 237 | _o.isStruct = this.isStruct(); |
| 238 | _o.minalign = this.minalign(); |
| 239 | _o.bytesize = this.bytesize(); |
James Kuszmaul | 3b15b0c | 2022-11-08 14:03:16 -0800 | [diff] [blame^] | 240 | _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()); |
| 241 | _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()); |
Austin Schuh | 2dd86a9 | 2022-09-14 21:19:23 -0700 | [diff] [blame] | 242 | _o.declarationFile = this.declarationFile(); |
| 243 | } |
| 244 | } |
| 245 | |
James Kuszmaul | 3b15b0c | 2022-11-08 14:03:16 -0800 | [diff] [blame^] | 246 | export class Object_T implements flatbuffers.IGeneratedObject { |
Austin Schuh | 2dd86a9 | 2022-09-14 21:19:23 -0700 | [diff] [blame] | 247 | constructor( |
| 248 | public name: string|Uint8Array|null = null, |
| 249 | public fields: (FieldT)[] = [], |
| 250 | public isStruct: boolean = false, |
| 251 | public minalign: number = 0, |
| 252 | public bytesize: number = 0, |
| 253 | public attributes: (KeyValueT)[] = [], |
| 254 | public documentation: (string)[] = [], |
| 255 | public declarationFile: string|Uint8Array|null = null |
| 256 | ){} |
| 257 | |
| 258 | |
| 259 | pack(builder:flatbuffers.Builder): flatbuffers.Offset { |
| 260 | const name = (this.name !== null ? builder.createString(this.name!) : 0); |
| 261 | const fields = Object_.createFieldsVector(builder, builder.createObjectOffsetList(this.fields)); |
| 262 | const attributes = Object_.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); |
| 263 | const documentation = Object_.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); |
| 264 | const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile!) : 0); |
| 265 | |
| 266 | return Object_.createObject(builder, |
| 267 | name, |
| 268 | fields, |
| 269 | this.isStruct, |
| 270 | this.minalign, |
| 271 | this.bytesize, |
| 272 | attributes, |
| 273 | documentation, |
| 274 | declarationFile |
| 275 | ); |
| 276 | } |
| 277 | } |