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 { EnumVal } from '../reflection/enum-val.js'; |
| 4 | import { KeyValue } from '../reflection/key-value.js'; |
| 5 | import { Type } from '../reflection/type.js'; |
| 6 | export class Enum { |
| 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 getRootAsEnum(bb, obj) { |
| 17 | return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); |
| 18 | } |
| 19 | static getSizePrefixedRootAsEnum(bb, obj) { |
| 20 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); |
| 21 | return (obj || new Enum()).__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 | values(index, obj) { |
| 28 | const offset = this.bb.__offset(this.bb_pos, 6); |
| 29 | return offset ? (obj || new EnumVal()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; |
| 30 | } |
| 31 | valuesLength() { |
| 32 | const offset = this.bb.__offset(this.bb_pos, 6); |
| 33 | return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; |
| 34 | } |
| 35 | isUnion() { |
| 36 | const offset = this.bb.__offset(this.bb_pos, 8); |
| 37 | return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; |
| 38 | } |
| 39 | mutate_is_union(value) { |
| 40 | const offset = this.bb.__offset(this.bb_pos, 8); |
| 41 | if (offset === 0) { |
| 42 | return false; |
| 43 | } |
| 44 | this.bb.writeInt8(this.bb_pos + offset, +value); |
| 45 | return true; |
| 46 | } |
| 47 | underlyingType(obj) { |
| 48 | const offset = this.bb.__offset(this.bb_pos, 10); |
| 49 | return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; |
| 50 | } |
| 51 | attributes(index, obj) { |
| 52 | const offset = this.bb.__offset(this.bb_pos, 12); |
| 53 | return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; |
| 54 | } |
| 55 | attributesLength() { |
| 56 | const offset = this.bb.__offset(this.bb_pos, 12); |
| 57 | return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; |
| 58 | } |
| 59 | documentation(index, optionalEncoding) { |
| 60 | const offset = this.bb.__offset(this.bb_pos, 14); |
| 61 | return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; |
| 62 | } |
| 63 | documentationLength() { |
| 64 | const offset = this.bb.__offset(this.bb_pos, 14); |
| 65 | return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; |
| 66 | } |
| 67 | declarationFile(optionalEncoding) { |
| 68 | const offset = this.bb.__offset(this.bb_pos, 16); |
| 69 | return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; |
| 70 | } |
| 71 | static getFullyQualifiedName() { |
| 72 | return 'reflection_Enum'; |
| 73 | } |
| 74 | static startEnum(builder) { |
| 75 | builder.startObject(7); |
| 76 | } |
| 77 | static addName(builder, nameOffset) { |
| 78 | builder.addFieldOffset(0, nameOffset, 0); |
| 79 | } |
| 80 | static addValues(builder, valuesOffset) { |
| 81 | builder.addFieldOffset(1, valuesOffset, 0); |
| 82 | } |
| 83 | static createValuesVector(builder, data) { |
| 84 | builder.startVector(4, data.length, 4); |
| 85 | for (let i = data.length - 1; i >= 0; i--) { |
| 86 | builder.addOffset(data[i]); |
| 87 | } |
| 88 | return builder.endVector(); |
| 89 | } |
| 90 | static startValuesVector(builder, numElems) { |
| 91 | builder.startVector(4, numElems, 4); |
| 92 | } |
| 93 | static addIsUnion(builder, isUnion) { |
| 94 | builder.addFieldInt8(2, +isUnion, +false); |
| 95 | } |
| 96 | static addUnderlyingType(builder, underlyingTypeOffset) { |
| 97 | builder.addFieldOffset(3, underlyingTypeOffset, 0); |
| 98 | } |
| 99 | static addAttributes(builder, attributesOffset) { |
| 100 | builder.addFieldOffset(4, attributesOffset, 0); |
| 101 | } |
| 102 | static createAttributesVector(builder, data) { |
| 103 | builder.startVector(4, data.length, 4); |
| 104 | for (let i = data.length - 1; i >= 0; i--) { |
| 105 | builder.addOffset(data[i]); |
| 106 | } |
| 107 | return builder.endVector(); |
| 108 | } |
| 109 | static startAttributesVector(builder, numElems) { |
| 110 | builder.startVector(4, numElems, 4); |
| 111 | } |
| 112 | static addDocumentation(builder, documentationOffset) { |
| 113 | builder.addFieldOffset(5, documentationOffset, 0); |
| 114 | } |
| 115 | static createDocumentationVector(builder, data) { |
| 116 | builder.startVector(4, data.length, 4); |
| 117 | for (let i = data.length - 1; i >= 0; i--) { |
| 118 | builder.addOffset(data[i]); |
| 119 | } |
| 120 | return builder.endVector(); |
| 121 | } |
| 122 | static startDocumentationVector(builder, numElems) { |
| 123 | builder.startVector(4, numElems, 4); |
| 124 | } |
| 125 | static addDeclarationFile(builder, declarationFileOffset) { |
| 126 | builder.addFieldOffset(6, declarationFileOffset, 0); |
| 127 | } |
| 128 | static endEnum(builder) { |
| 129 | const offset = builder.endObject(); |
| 130 | builder.requiredField(offset, 4); // name |
| 131 | builder.requiredField(offset, 6); // values |
| 132 | builder.requiredField(offset, 10); // underlying_type |
| 133 | return offset; |
| 134 | } |
| 135 | unpack() { |
| 136 | return new EnumT(this.name(), this.bb.createObjList(this.values.bind(this), this.valuesLength()), this.isUnion(), (this.underlyingType() !== null ? this.underlyingType().unpack() : null), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.declarationFile()); |
| 137 | } |
| 138 | unpackTo(_o) { |
| 139 | _o.name = this.name(); |
| 140 | _o.values = this.bb.createObjList(this.values.bind(this), this.valuesLength()); |
| 141 | _o.isUnion = this.isUnion(); |
| 142 | _o.underlyingType = (this.underlyingType() !== null ? this.underlyingType().unpack() : null); |
| 143 | _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); |
| 144 | _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); |
| 145 | _o.declarationFile = this.declarationFile(); |
| 146 | } |
| 147 | } |
| 148 | export class EnumT { |
| 149 | constructor(name = null, values = [], isUnion = false, underlyingType = null, attributes = [], documentation = [], declarationFile = null) { |
| 150 | this.name = name; |
| 151 | this.values = values; |
| 152 | this.isUnion = isUnion; |
| 153 | this.underlyingType = underlyingType; |
| 154 | this.attributes = attributes; |
| 155 | this.documentation = documentation; |
| 156 | this.declarationFile = declarationFile; |
| 157 | } |
| 158 | pack(builder) { |
| 159 | const name = (this.name !== null ? builder.createString(this.name) : 0); |
| 160 | const values = Enum.createValuesVector(builder, builder.createObjectOffsetList(this.values)); |
| 161 | const underlyingType = (this.underlyingType !== null ? this.underlyingType.pack(builder) : 0); |
| 162 | const attributes = Enum.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); |
| 163 | const documentation = Enum.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); |
| 164 | const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile) : 0); |
| 165 | Enum.startEnum(builder); |
| 166 | Enum.addName(builder, name); |
| 167 | Enum.addValues(builder, values); |
| 168 | Enum.addIsUnion(builder, this.isUnion); |
| 169 | Enum.addUnderlyingType(builder, underlyingType); |
| 170 | Enum.addAttributes(builder, attributes); |
| 171 | Enum.addDocumentation(builder, documentation); |
| 172 | Enum.addDeclarationFile(builder, declarationFile); |
| 173 | return Enum.endEnum(builder); |
| 174 | } |
| 175 | } |