1// automatically generated by the FlatBuffers compiler, do not modify 2/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ 3import * as flatbuffers from 'flatbuffers'; 4import { KeyValue } from '../reflection/key-value.js'; 5import { Type } from '../reflection/type.js'; 6export class Field { 7 constructor() { 8 this.bb = null; 9 this.bb_pos = 0; 10 } 11 __init(i, bb) { 12 this.bb_pos = i; 13 this.bb = bb; 14 return this; 15 } 16 static getRootAsField(bb, obj) { 17 return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb); 18 } 19 static getSizePrefixedRootAsField(bb, obj) { 20 bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); 21 return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb); 22 } 23 name(optionalEncoding) { 24 const offset = this.bb.__offset(this.bb_pos, 4); 25 return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; 26 } 27 type(obj) { 28 const offset = this.bb.__offset(this.bb_pos, 6); 29 return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; 30 } 31 id() { 32 const offset = this.bb.__offset(this.bb_pos, 8); 33 return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; 34 } 35 mutate_id(value) { 36 const offset = this.bb.__offset(this.bb_pos, 8); 37 if (offset === 0) { 38 return false; 39 } 40 this.bb.writeUint16(this.bb_pos + offset, value); 41 return true; 42 } 43 offset() { 44 const offset = this.bb.__offset(this.bb_pos, 10); 45 return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; 46 } 47 mutate_offset(value) { 48 const offset = this.bb.__offset(this.bb_pos, 10); 49 if (offset === 0) { 50 return false; 51 } 52 this.bb.writeUint16(this.bb_pos + offset, value); 53 return true; 54 } 55 defaultInteger() { 56 const offset = this.bb.__offset(this.bb_pos, 12); 57 return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0'); 58 } 59 mutate_default_integer(value) { 60 const offset = this.bb.__offset(this.bb_pos, 12); 61 if (offset === 0) { 62 return false; 63 } 64 this.bb.writeInt64(this.bb_pos + offset, value); 65 return true; 66 } 67 defaultReal() { 68 const offset = this.bb.__offset(this.bb_pos, 14); 69 return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0; 70 } 71 mutate_default_real(value) { 72 const offset = this.bb.__offset(this.bb_pos, 14); 73 if (offset === 0) { 74 return false; 75 } 76 this.bb.writeFloat64(this.bb_pos + offset, value); 77 return true; 78 } 79 deprecated() { 80 const offset = this.bb.__offset(this.bb_pos, 16); 81 return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; 82 } 83 mutate_deprecated(value) { 84 const offset = this.bb.__offset(this.bb_pos, 16); 85 if (offset === 0) { 86 return false; 87 } 88 this.bb.writeInt8(this.bb_pos + offset, +value); 89 return true; 90 } 91 required() { 92 const offset = this.bb.__offset(this.bb_pos, 18); 93 return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; 94 } 95 mutate_required(value) { 96 const offset = this.bb.__offset(this.bb_pos, 18); 97 if (offset === 0) { 98 return false; 99 } 100 this.bb.writeInt8(this.bb_pos + offset, +value); 101 return true; 102 } 103 key() { 104 const offset = this.bb.__offset(this.bb_pos, 20); 105 return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; 106 } 107 mutate_key(value) { 108 const offset = this.bb.__offset(this.bb_pos, 20); 109 if (offset === 0) { 110 return false; 111 } 112 this.bb.writeInt8(this.bb_pos + offset, +value); 113 return true; 114 } 115 attributes(index, obj) { 116 const offset = this.bb.__offset(this.bb_pos, 22); 117 return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; 118 } 119 attributesLength() { 120 const offset = this.bb.__offset(this.bb_pos, 22); 121 return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; 122 } 123 documentation(index, optionalEncoding) { 124 const offset = this.bb.__offset(this.bb_pos, 24); 125 return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; 126 } 127 documentationLength() { 128 const offset = this.bb.__offset(this.bb_pos, 24); 129 return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; 130 } 131 optional() { 132 const offset = this.bb.__offset(this.bb_pos, 26); 133 return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; 134 } 135 mutate_optional(value) { 136 const offset = this.bb.__offset(this.bb_pos, 26); 137 if (offset === 0) { 138 return false; 139 } 140 this.bb.writeInt8(this.bb_pos + offset, +value); 141 return true; 142 } 143 /** 144 * Number of padding octets to always add after this field. Structs only. 145 */ 146 padding() { 147 const offset = this.bb.__offset(this.bb_pos, 28); 148 return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; 149 } 150 mutate_padding(value) { 151 const offset = this.bb.__offset(this.bb_pos, 28); 152 if (offset === 0) { 153 return false; 154 } 155 this.bb.writeUint16(this.bb_pos + offset, value); 156 return true; 157 } 158 /** 159 * If the field uses 64-bit offsets. 160 */ 161 offset64() { 162 const offset = this.bb.__offset(this.bb_pos, 30); 163 return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; 164 } 165 mutate_offset64(value) { 166 const offset = this.bb.__offset(this.bb_pos, 30); 167 if (offset === 0) { 168 return false; 169 } 170 this.bb.writeInt8(this.bb_pos + offset, +value); 171 return true; 172 } 173 static getFullyQualifiedName() { 174 return 'reflection.Field'; 175 } 176 static startField(builder) { 177 builder.startObject(14); 178 } 179 static addName(builder, nameOffset) { 180 builder.addFieldOffset(0, nameOffset, 0); 181 } 182 static addType(builder, typeOffset) { 183 builder.addFieldOffset(1, typeOffset, 0); 184 } 185 static addId(builder, id) { 186 builder.addFieldInt16(2, id, 0); 187 } 188 static addOffset(builder, offset) { 189 builder.addFieldInt16(3, offset, 0); 190 } 191 static addDefaultInteger(builder, defaultInteger) { 192 builder.addFieldInt64(4, defaultInteger, BigInt('0')); 193 } 194 static addDefaultReal(builder, defaultReal) { 195 builder.addFieldFloat64(5, defaultReal, 0.0); 196 } 197 static addDeprecated(builder, deprecated) { 198 builder.addFieldInt8(6, +deprecated, +false); 199 } 200 static addRequired(builder, required) { 201 builder.addFieldInt8(7, +required, +false); 202 } 203 static addKey(builder, key) { 204 builder.addFieldInt8(8, +key, +false); 205 } 206 static addAttributes(builder, attributesOffset) { 207 builder.addFieldOffset(9, attributesOffset, 0); 208 } 209 static createAttributesVector(builder, data) { 210 builder.startVector(4, data.length, 4); 211 for (let i = data.length - 1; i >= 0; i--) { 212 builder.addOffset(data[i]); 213 } 214 return builder.endVector(); 215 } 216 static startAttributesVector(builder, numElems) { 217 builder.startVector(4, numElems, 4); 218 } 219 static addDocumentation(builder, documentationOffset) { 220 builder.addFieldOffset(10, documentationOffset, 0); 221 } 222 static createDocumentationVector(builder, data) { 223 builder.startVector(4, data.length, 4); 224 for (let i = data.length - 1; i >= 0; i--) { 225 builder.addOffset(data[i]); 226 } 227 return builder.endVector(); 228 } 229 static startDocumentationVector(builder, numElems) { 230 builder.startVector(4, numElems, 4); 231 } 232 static addOptional(builder, optional) { 233 builder.addFieldInt8(11, +optional, +false); 234 } 235 static addPadding(builder, padding) { 236 builder.addFieldInt16(12, padding, 0); 237 } 238 static addOffset64(builder, offset64) { 239 builder.addFieldInt8(13, +offset64, +false); 240 } 241 static endField(builder) { 242 const offset = builder.endObject(); 243 builder.requiredField(offset, 4); // name 244 builder.requiredField(offset, 6); // type 245 return offset; 246 } 247 unpack() { 248 return new FieldT(this.name(), (this.type() !== null ? this.type().unpack() : null), this.id(), this.offset(), this.defaultInteger(), this.defaultReal(), this.deprecated(), this.required(), this.key(), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.optional(), this.padding(), this.offset64()); 249 } 250 unpackTo(_o) { 251 _o.name = this.name(); 252 _o.type = (this.type() !== null ? this.type().unpack() : null); 253 _o.id = this.id(); 254 _o.offset = this.offset(); 255 _o.defaultInteger = this.defaultInteger(); 256 _o.defaultReal = this.defaultReal(); 257 _o.deprecated = this.deprecated(); 258 _o.required = this.required(); 259 _o.key = this.key(); 260 _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); 261 _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); 262 _o.optional = this.optional(); 263 _o.padding = this.padding(); 264 _o.offset64 = this.offset64(); 265 } 266} 267export class FieldT { 268 constructor(name = null, type = null, id = 0, offset = 0, defaultInteger = BigInt('0'), defaultReal = 0.0, deprecated = false, required = false, key = false, attributes = [], documentation = [], optional = false, padding = 0, offset64 = false) { 269 this.name = name; 270 this.type = type; 271 this.id = id; 272 this.offset = offset; 273 this.defaultInteger = defaultInteger; 274 this.defaultReal = defaultReal; 275 this.deprecated = deprecated; 276 this.required = required; 277 this.key = key; 278 this.attributes = attributes; 279 this.documentation = documentation; 280 this.optional = optional; 281 this.padding = padding; 282 this.offset64 = offset64; 283 } 284 pack(builder) { 285 const name = (this.name !== null ? builder.createString(this.name) : 0); 286 const type = (this.type !== null ? this.type.pack(builder) : 0); 287 const attributes = Field.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); 288 const documentation = Field.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); 289 Field.startField(builder); 290 Field.addName(builder, name); 291 Field.addType(builder, type); 292 Field.addId(builder, this.id); 293 Field.addOffset(builder, this.offset); 294 Field.addDefaultInteger(builder, this.defaultInteger); 295 Field.addDefaultReal(builder, this.defaultReal); 296 Field.addDeprecated(builder, this.deprecated); 297 Field.addRequired(builder, this.required); 298 Field.addKey(builder, this.key); 299 Field.addAttributes(builder, attributes); 300 Field.addDocumentation(builder, documentation); 301 Field.addOptional(builder, this.optional); 302 Field.addPadding(builder, this.padding); 303 Field.addOffset64(builder, this.offset64); 304 return Field.endField(builder); 305 } 306} 307