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 { Type } from '../reflection/type.js'; |
| 4 | export class EnumVal { |
| 5 | constructor() { |
| 6 | this.bb = null; |
| 7 | this.bb_pos = 0; |
| 8 | } |
| 9 | __init(i, bb) { |
| 10 | this.bb_pos = i; |
| 11 | this.bb = bb; |
| 12 | return this; |
| 13 | } |
| 14 | static getRootAsEnumVal(bb, obj) { |
| 15 | return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb); |
| 16 | } |
| 17 | static getSizePrefixedRootAsEnumVal(bb, obj) { |
| 18 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); |
| 19 | return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb); |
| 20 | } |
| 21 | name(optionalEncoding) { |
| 22 | const offset = this.bb.__offset(this.bb_pos, 4); |
| 23 | return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; |
| 24 | } |
| 25 | value() { |
| 26 | const offset = this.bb.__offset(this.bb_pos, 6); |
| 27 | return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0'); |
| 28 | } |
| 29 | mutate_value(value) { |
| 30 | const offset = this.bb.__offset(this.bb_pos, 6); |
| 31 | if (offset === 0) { |
| 32 | return false; |
| 33 | } |
| 34 | this.bb.writeInt64(this.bb_pos + offset, value); |
| 35 | return true; |
| 36 | } |
| 37 | unionType(obj) { |
| 38 | const offset = this.bb.__offset(this.bb_pos, 10); |
| 39 | return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; |
| 40 | } |
| 41 | documentation(index, optionalEncoding) { |
| 42 | const offset = this.bb.__offset(this.bb_pos, 12); |
| 43 | return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; |
| 44 | } |
| 45 | documentationLength() { |
| 46 | const offset = this.bb.__offset(this.bb_pos, 12); |
| 47 | return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; |
| 48 | } |
| 49 | static getFullyQualifiedName() { |
| 50 | return 'reflection_EnumVal'; |
| 51 | } |
| 52 | static startEnumVal(builder) { |
| 53 | builder.startObject(5); |
| 54 | } |
| 55 | static addName(builder, nameOffset) { |
| 56 | builder.addFieldOffset(0, nameOffset, 0); |
| 57 | } |
| 58 | static addValue(builder, value) { |
| 59 | builder.addFieldInt64(1, value, BigInt('0')); |
| 60 | } |
| 61 | static addUnionType(builder, unionTypeOffset) { |
| 62 | builder.addFieldOffset(3, unionTypeOffset, 0); |
| 63 | } |
| 64 | static addDocumentation(builder, documentationOffset) { |
| 65 | builder.addFieldOffset(4, documentationOffset, 0); |
| 66 | } |
| 67 | static createDocumentationVector(builder, data) { |
| 68 | builder.startVector(4, data.length, 4); |
| 69 | for (let i = data.length - 1; i >= 0; i--) { |
| 70 | builder.addOffset(data[i]); |
| 71 | } |
| 72 | return builder.endVector(); |
| 73 | } |
| 74 | static startDocumentationVector(builder, numElems) { |
| 75 | builder.startVector(4, numElems, 4); |
| 76 | } |
| 77 | static endEnumVal(builder) { |
| 78 | const offset = builder.endObject(); |
| 79 | builder.requiredField(offset, 4); // name |
| 80 | return offset; |
| 81 | } |
| 82 | unpack() { |
| 83 | return new EnumValT(this.name(), this.value(), (this.unionType() !== null ? this.unionType().unpack() : null), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength())); |
| 84 | } |
| 85 | unpackTo(_o) { |
| 86 | _o.name = this.name(); |
| 87 | _o.value = this.value(); |
| 88 | _o.unionType = (this.unionType() !== null ? this.unionType().unpack() : null); |
| 89 | _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); |
| 90 | } |
| 91 | } |
| 92 | export class EnumValT { |
| 93 | constructor(name = null, value = BigInt('0'), unionType = null, documentation = []) { |
| 94 | this.name = name; |
| 95 | this.value = value; |
| 96 | this.unionType = unionType; |
| 97 | this.documentation = documentation; |
| 98 | } |
| 99 | pack(builder) { |
| 100 | const name = (this.name !== null ? builder.createString(this.name) : 0); |
| 101 | const unionType = (this.unionType !== null ? this.unionType.pack(builder) : 0); |
| 102 | const documentation = EnumVal.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); |
| 103 | EnumVal.startEnumVal(builder); |
| 104 | EnumVal.addName(builder, name); |
| 105 | EnumVal.addValue(builder, this.value); |
| 106 | EnumVal.addUnionType(builder, unionType); |
| 107 | EnumVal.addDocumentation(builder, documentation); |
| 108 | return EnumVal.endEnumVal(builder); |
| 109 | } |
| 110 | } |