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