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 { EnumVal, EnumValT } from '../reflection/enum-val.js'; |
| 6 | import { KeyValue, KeyValueT } from '../reflection/key-value.js'; |
| 7 | import { Type, TypeT } from '../reflection/type.js'; |
| 8 | |
| 9 | |
| 10 | export class Enum { |
| 11 | bb: flatbuffers.ByteBuffer|null = null; |
| 12 | bb_pos = 0; |
| 13 | __init(i:number, bb:flatbuffers.ByteBuffer):Enum { |
| 14 | this.bb_pos = i; |
| 15 | this.bb = bb; |
| 16 | return this; |
| 17 | } |
| 18 | |
| 19 | static getRootAsEnum(bb:flatbuffers.ByteBuffer, obj?:Enum):Enum { |
| 20 | return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); |
| 21 | } |
| 22 | |
| 23 | static getSizePrefixedRootAsEnum(bb:flatbuffers.ByteBuffer, obj?:Enum):Enum { |
| 24 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); |
| 25 | return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); |
| 26 | } |
| 27 | |
| 28 | name():string|null |
| 29 | name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null |
| 30 | name(optionalEncoding?:any):string|Uint8Array|null { |
| 31 | const offset = this.bb!.__offset(this.bb_pos, 4); |
| 32 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; |
| 33 | } |
| 34 | |
| 35 | values(index: number, obj?:EnumVal):EnumVal|null { |
| 36 | const offset = this.bb!.__offset(this.bb_pos, 6); |
| 37 | return offset ? (obj || new EnumVal()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; |
| 38 | } |
| 39 | |
| 40 | valuesLength():number { |
| 41 | const offset = this.bb!.__offset(this.bb_pos, 6); |
| 42 | return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; |
| 43 | } |
| 44 | |
| 45 | isUnion():boolean { |
| 46 | const offset = this.bb!.__offset(this.bb_pos, 8); |
| 47 | return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; |
| 48 | } |
| 49 | |
| 50 | mutate_is_union(value:boolean):boolean { |
| 51 | const offset = this.bb!.__offset(this.bb_pos, 8); |
| 52 | |
| 53 | if (offset === 0) { |
| 54 | return false; |
| 55 | } |
| 56 | |
| 57 | this.bb!.writeInt8(this.bb_pos + offset, +value); |
| 58 | return true; |
| 59 | } |
| 60 | |
| 61 | underlyingType(obj?:Type):Type|null { |
| 62 | const offset = this.bb!.__offset(this.bb_pos, 10); |
| 63 | return offset ? (obj || new Type()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; |
| 64 | } |
| 65 | |
| 66 | attributes(index: number, obj?:KeyValue):KeyValue|null { |
| 67 | const offset = this.bb!.__offset(this.bb_pos, 12); |
| 68 | return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; |
| 69 | } |
| 70 | |
| 71 | attributesLength():number { |
| 72 | const offset = this.bb!.__offset(this.bb_pos, 12); |
| 73 | return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; |
| 74 | } |
| 75 | |
| 76 | documentation(index: number):string |
| 77 | documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array |
| 78 | documentation(index: number,optionalEncoding?:any):string|Uint8Array|null { |
| 79 | const offset = this.bb!.__offset(this.bb_pos, 14); |
| 80 | return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; |
| 81 | } |
| 82 | |
| 83 | documentationLength():number { |
| 84 | const offset = this.bb!.__offset(this.bb_pos, 14); |
| 85 | return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * File that this Enum is declared in. |
| 90 | */ |
| 91 | declarationFile():string|null |
| 92 | declarationFile(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null |
| 93 | declarationFile(optionalEncoding?:any):string|Uint8Array|null { |
| 94 | const offset = this.bb!.__offset(this.bb_pos, 16); |
| 95 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; |
| 96 | } |
| 97 | |
| 98 | static getFullyQualifiedName():string { |
| 99 | return 'reflection_Enum'; |
| 100 | } |
| 101 | |
| 102 | static startEnum(builder:flatbuffers.Builder) { |
| 103 | builder.startObject(7); |
| 104 | } |
| 105 | |
| 106 | static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { |
| 107 | builder.addFieldOffset(0, nameOffset, 0); |
| 108 | } |
| 109 | |
| 110 | static addValues(builder:flatbuffers.Builder, valuesOffset:flatbuffers.Offset) { |
| 111 | builder.addFieldOffset(1, valuesOffset, 0); |
| 112 | } |
| 113 | |
| 114 | static createValuesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { |
| 115 | builder.startVector(4, data.length, 4); |
| 116 | for (let i = data.length - 1; i >= 0; i--) { |
| 117 | builder.addOffset(data[i]!); |
| 118 | } |
| 119 | return builder.endVector(); |
| 120 | } |
| 121 | |
| 122 | static startValuesVector(builder:flatbuffers.Builder, numElems:number) { |
| 123 | builder.startVector(4, numElems, 4); |
| 124 | } |
| 125 | |
| 126 | static addIsUnion(builder:flatbuffers.Builder, isUnion:boolean) { |
| 127 | builder.addFieldInt8(2, +isUnion, +false); |
| 128 | } |
| 129 | |
| 130 | static addUnderlyingType(builder:flatbuffers.Builder, underlyingTypeOffset:flatbuffers.Offset) { |
| 131 | builder.addFieldOffset(3, underlyingTypeOffset, 0); |
| 132 | } |
| 133 | |
| 134 | static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) { |
| 135 | builder.addFieldOffset(4, attributesOffset, 0); |
| 136 | } |
| 137 | |
| 138 | static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { |
| 139 | builder.startVector(4, data.length, 4); |
| 140 | for (let i = data.length - 1; i >= 0; i--) { |
| 141 | builder.addOffset(data[i]!); |
| 142 | } |
| 143 | return builder.endVector(); |
| 144 | } |
| 145 | |
| 146 | static startAttributesVector(builder:flatbuffers.Builder, numElems:number) { |
| 147 | builder.startVector(4, numElems, 4); |
| 148 | } |
| 149 | |
| 150 | static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) { |
| 151 | builder.addFieldOffset(5, documentationOffset, 0); |
| 152 | } |
| 153 | |
| 154 | static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { |
| 155 | builder.startVector(4, data.length, 4); |
| 156 | for (let i = data.length - 1; i >= 0; i--) { |
| 157 | builder.addOffset(data[i]!); |
| 158 | } |
| 159 | return builder.endVector(); |
| 160 | } |
| 161 | |
| 162 | static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) { |
| 163 | builder.startVector(4, numElems, 4); |
| 164 | } |
| 165 | |
| 166 | static addDeclarationFile(builder:flatbuffers.Builder, declarationFileOffset:flatbuffers.Offset) { |
| 167 | builder.addFieldOffset(6, declarationFileOffset, 0); |
| 168 | } |
| 169 | |
| 170 | static endEnum(builder:flatbuffers.Builder):flatbuffers.Offset { |
| 171 | const offset = builder.endObject(); |
| 172 | builder.requiredField(offset, 4) // name |
| 173 | builder.requiredField(offset, 6) // values |
| 174 | builder.requiredField(offset, 10) // underlying_type |
| 175 | return offset; |
| 176 | } |
| 177 | |
| 178 | |
| 179 | unpack(): EnumT { |
| 180 | return new EnumT( |
| 181 | this.name(), |
| 182 | this.bb!.createObjList(this.values.bind(this), this.valuesLength()), |
| 183 | this.isUnion(), |
| 184 | (this.underlyingType() !== null ? this.underlyingType()!.unpack() : null), |
| 185 | this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), |
| 186 | this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), |
| 187 | this.declarationFile() |
| 188 | ); |
| 189 | } |
| 190 | |
| 191 | |
| 192 | unpackTo(_o: EnumT): void { |
| 193 | _o.name = this.name(); |
| 194 | _o.values = this.bb!.createObjList(this.values.bind(this), this.valuesLength()); |
| 195 | _o.isUnion = this.isUnion(); |
| 196 | _o.underlyingType = (this.underlyingType() !== null ? this.underlyingType()!.unpack() : null); |
| 197 | _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); |
| 198 | _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); |
| 199 | _o.declarationFile = this.declarationFile(); |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | export class EnumT { |
| 204 | constructor( |
| 205 | public name: string|Uint8Array|null = null, |
| 206 | public values: (EnumValT)[] = [], |
| 207 | public isUnion: boolean = false, |
| 208 | public underlyingType: TypeT|null = null, |
| 209 | public attributes: (KeyValueT)[] = [], |
| 210 | public documentation: (string)[] = [], |
| 211 | public declarationFile: string|Uint8Array|null = null |
| 212 | ){} |
| 213 | |
| 214 | |
| 215 | pack(builder:flatbuffers.Builder): flatbuffers.Offset { |
| 216 | const name = (this.name !== null ? builder.createString(this.name!) : 0); |
| 217 | const values = Enum.createValuesVector(builder, builder.createObjectOffsetList(this.values)); |
| 218 | const underlyingType = (this.underlyingType !== null ? this.underlyingType!.pack(builder) : 0); |
| 219 | const attributes = Enum.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); |
| 220 | const documentation = Enum.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); |
| 221 | const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile!) : 0); |
| 222 | |
| 223 | Enum.startEnum(builder); |
| 224 | Enum.addName(builder, name); |
| 225 | Enum.addValues(builder, values); |
| 226 | Enum.addIsUnion(builder, this.isUnion); |
| 227 | Enum.addUnderlyingType(builder, underlyingType); |
| 228 | Enum.addAttributes(builder, attributes); |
| 229 | Enum.addDocumentation(builder, documentation); |
| 230 | Enum.addDeclarationFile(builder, declarationFile); |
| 231 | |
| 232 | return Enum.endEnum(builder); |
| 233 | } |
| 234 | } |