blob: 93926a61ae76ccce6cadebe109e20a313c5f76ac [file] [log] [blame]
Austin Schuh2dd86a92022-09-14 21:19:23 -07001// automatically generated by the FlatBuffers compiler, do not modify
2import * as flatbuffers from 'flatbuffers';
James Kuszmaul3b15b0c2022-11-08 14:03:16 -08003import { KeyValue } from '../reflection/key-value.js';
Austin Schuh2dd86a92022-09-14 21:19:23 -07004import { Type } from '../reflection/type.js';
5export class EnumVal {
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 getRootAsEnumVal(bb, obj) {
16 return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
17 }
18 static getSizePrefixedRootAsEnumVal(bb, obj) {
19 bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
20 return (obj || new EnumVal()).__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 value() {
27 const offset = this.bb.__offset(this.bb_pos, 6);
28 return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0');
29 }
30 mutate_value(value) {
31 const offset = this.bb.__offset(this.bb_pos, 6);
32 if (offset === 0) {
33 return false;
34 }
35 this.bb.writeInt64(this.bb_pos + offset, value);
36 return true;
37 }
38 unionType(obj) {
39 const offset = this.bb.__offset(this.bb_pos, 10);
40 return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
41 }
42 documentation(index, optionalEncoding) {
43 const offset = this.bb.__offset(this.bb_pos, 12);
44 return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
45 }
46 documentationLength() {
47 const offset = this.bb.__offset(this.bb_pos, 12);
48 return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
49 }
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080050 attributes(index, obj) {
51 const offset = this.bb.__offset(this.bb_pos, 14);
52 return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
53 }
54 attributesLength() {
55 const offset = this.bb.__offset(this.bb_pos, 14);
56 return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
57 }
Austin Schuh2dd86a92022-09-14 21:19:23 -070058 static getFullyQualifiedName() {
59 return 'reflection_EnumVal';
60 }
61 static startEnumVal(builder) {
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080062 builder.startObject(6);
Austin Schuh2dd86a92022-09-14 21:19:23 -070063 }
64 static addName(builder, nameOffset) {
65 builder.addFieldOffset(0, nameOffset, 0);
66 }
67 static addValue(builder, value) {
68 builder.addFieldInt64(1, value, BigInt('0'));
69 }
70 static addUnionType(builder, unionTypeOffset) {
71 builder.addFieldOffset(3, unionTypeOffset, 0);
72 }
73 static addDocumentation(builder, documentationOffset) {
74 builder.addFieldOffset(4, documentationOffset, 0);
75 }
76 static createDocumentationVector(builder, data) {
77 builder.startVector(4, data.length, 4);
78 for (let i = data.length - 1; i >= 0; i--) {
79 builder.addOffset(data[i]);
80 }
81 return builder.endVector();
82 }
83 static startDocumentationVector(builder, numElems) {
84 builder.startVector(4, numElems, 4);
85 }
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080086 static addAttributes(builder, attributesOffset) {
87 builder.addFieldOffset(5, attributesOffset, 0);
88 }
89 static createAttributesVector(builder, data) {
90 builder.startVector(4, data.length, 4);
91 for (let i = data.length - 1; i >= 0; i--) {
92 builder.addOffset(data[i]);
93 }
94 return builder.endVector();
95 }
96 static startAttributesVector(builder, numElems) {
97 builder.startVector(4, numElems, 4);
98 }
Austin Schuh2dd86a92022-09-14 21:19:23 -070099 static endEnumVal(builder) {
100 const offset = builder.endObject();
101 builder.requiredField(offset, 4); // name
102 return offset;
103 }
104 unpack() {
James Kuszmaul3b15b0c2022-11-08 14:03:16 -0800105 return new EnumValT(this.name(), this.value(), (this.unionType() !== null ? this.unionType().unpack() : null), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()));
Austin Schuh2dd86a92022-09-14 21:19:23 -0700106 }
107 unpackTo(_o) {
108 _o.name = this.name();
109 _o.value = this.value();
110 _o.unionType = (this.unionType() !== null ? this.unionType().unpack() : null);
111 _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength());
James Kuszmaul3b15b0c2022-11-08 14:03:16 -0800112 _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength());
Austin Schuh2dd86a92022-09-14 21:19:23 -0700113 }
114}
115export class EnumValT {
James Kuszmaul3b15b0c2022-11-08 14:03:16 -0800116 constructor(name = null, value = BigInt('0'), unionType = null, documentation = [], attributes = []) {
Austin Schuh2dd86a92022-09-14 21:19:23 -0700117 this.name = name;
118 this.value = value;
119 this.unionType = unionType;
120 this.documentation = documentation;
James Kuszmaul3b15b0c2022-11-08 14:03:16 -0800121 this.attributes = attributes;
Austin Schuh2dd86a92022-09-14 21:19:23 -0700122 }
123 pack(builder) {
124 const name = (this.name !== null ? builder.createString(this.name) : 0);
125 const unionType = (this.unionType !== null ? this.unionType.pack(builder) : 0);
126 const documentation = EnumVal.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
James Kuszmaul3b15b0c2022-11-08 14:03:16 -0800127 const attributes = EnumVal.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
Austin Schuh2dd86a92022-09-14 21:19:23 -0700128 EnumVal.startEnumVal(builder);
129 EnumVal.addName(builder, name);
130 EnumVal.addValue(builder, this.value);
131 EnumVal.addUnionType(builder, unionType);
132 EnumVal.addDocumentation(builder, documentation);
James Kuszmaul3b15b0c2022-11-08 14:03:16 -0800133 EnumVal.addAttributes(builder, attributes);
Austin Schuh2dd86a92022-09-14 21:19:23 -0700134 return EnumVal.endEnumVal(builder);
135 }
136}