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