blob: d5022971526ade36fd1e5e4986616c7428494d2c [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';
3import { Enum } from '../reflection/enum.js';
4import { Object_ } from '../reflection/object.js';
5import { SchemaFile } from '../reflection/schema-file.js';
6import { Service } from '../reflection/service.js';
7export class Schema {
8 constructor() {
9 this.bb = null;
10 this.bb_pos = 0;
11 }
12 __init(i, bb) {
13 this.bb_pos = i;
14 this.bb = bb;
15 return this;
16 }
17 static getRootAsSchema(bb, obj) {
18 return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
19 }
20 static getSizePrefixedRootAsSchema(bb, obj) {
21 bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
22 return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23 }
24 static bufferHasIdentifier(bb) {
25 return bb.__has_identifier('BFBS');
26 }
27 objects(index, obj) {
28 const offset = this.bb.__offset(this.bb_pos, 4);
29 return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
30 }
31 objectsLength() {
32 const offset = this.bb.__offset(this.bb_pos, 4);
33 return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
34 }
35 enums(index, obj) {
36 const offset = this.bb.__offset(this.bb_pos, 6);
37 return offset ? (obj || new Enum()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
38 }
39 enumsLength() {
40 const offset = this.bb.__offset(this.bb_pos, 6);
41 return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
42 }
43 fileIdent(optionalEncoding) {
44 const offset = this.bb.__offset(this.bb_pos, 8);
45 return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
46 }
47 fileExt(optionalEncoding) {
48 const offset = this.bb.__offset(this.bb_pos, 10);
49 return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
50 }
51 rootTable(obj) {
52 const offset = this.bb.__offset(this.bb_pos, 12);
53 return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
54 }
55 services(index, obj) {
56 const offset = this.bb.__offset(this.bb_pos, 14);
57 return offset ? (obj || new Service()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
58 }
59 servicesLength() {
60 const offset = this.bb.__offset(this.bb_pos, 14);
61 return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
62 }
63 advancedFeatures() {
64 const offset = this.bb.__offset(this.bb_pos, 16);
65 return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
66 }
67 mutate_advanced_features(value) {
68 const offset = this.bb.__offset(this.bb_pos, 16);
69 if (offset === 0) {
70 return false;
71 }
72 this.bb.writeUint64(this.bb_pos + offset, value);
73 return true;
74 }
75 /**
76 * All the files used in this compilation. Files are relative to where
77 * flatc was invoked.
78 */
79 fbsFiles(index, obj) {
80 const offset = this.bb.__offset(this.bb_pos, 18);
81 return offset ? (obj || new SchemaFile()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
82 }
83 fbsFilesLength() {
84 const offset = this.bb.__offset(this.bb_pos, 18);
85 return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
86 }
87 static getFullyQualifiedName() {
88 return 'reflection_Schema';
89 }
90 static startSchema(builder) {
91 builder.startObject(8);
92 }
93 static addObjects(builder, objectsOffset) {
94 builder.addFieldOffset(0, objectsOffset, 0);
95 }
96 static createObjectsVector(builder, data) {
97 builder.startVector(4, data.length, 4);
98 for (let i = data.length - 1; i >= 0; i--) {
99 builder.addOffset(data[i]);
100 }
101 return builder.endVector();
102 }
103 static startObjectsVector(builder, numElems) {
104 builder.startVector(4, numElems, 4);
105 }
106 static addEnums(builder, enumsOffset) {
107 builder.addFieldOffset(1, enumsOffset, 0);
108 }
109 static createEnumsVector(builder, data) {
110 builder.startVector(4, data.length, 4);
111 for (let i = data.length - 1; i >= 0; i--) {
112 builder.addOffset(data[i]);
113 }
114 return builder.endVector();
115 }
116 static startEnumsVector(builder, numElems) {
117 builder.startVector(4, numElems, 4);
118 }
119 static addFileIdent(builder, fileIdentOffset) {
120 builder.addFieldOffset(2, fileIdentOffset, 0);
121 }
122 static addFileExt(builder, fileExtOffset) {
123 builder.addFieldOffset(3, fileExtOffset, 0);
124 }
125 static addRootTable(builder, rootTableOffset) {
126 builder.addFieldOffset(4, rootTableOffset, 0);
127 }
128 static addServices(builder, servicesOffset) {
129 builder.addFieldOffset(5, servicesOffset, 0);
130 }
131 static createServicesVector(builder, data) {
132 builder.startVector(4, data.length, 4);
133 for (let i = data.length - 1; i >= 0; i--) {
134 builder.addOffset(data[i]);
135 }
136 return builder.endVector();
137 }
138 static startServicesVector(builder, numElems) {
139 builder.startVector(4, numElems, 4);
140 }
141 static addAdvancedFeatures(builder, advancedFeatures) {
142 builder.addFieldInt64(6, advancedFeatures, BigInt('0'));
143 }
144 static addFbsFiles(builder, fbsFilesOffset) {
145 builder.addFieldOffset(7, fbsFilesOffset, 0);
146 }
147 static createFbsFilesVector(builder, data) {
148 builder.startVector(4, data.length, 4);
149 for (let i = data.length - 1; i >= 0; i--) {
150 builder.addOffset(data[i]);
151 }
152 return builder.endVector();
153 }
154 static startFbsFilesVector(builder, numElems) {
155 builder.startVector(4, numElems, 4);
156 }
157 static endSchema(builder) {
158 const offset = builder.endObject();
159 builder.requiredField(offset, 4); // objects
160 builder.requiredField(offset, 6); // enums
161 return offset;
162 }
163 static finishSchemaBuffer(builder, offset) {
164 builder.finish(offset, 'BFBS');
165 }
166 static finishSizePrefixedSchemaBuffer(builder, offset) {
167 builder.finish(offset, 'BFBS', true);
168 }
169 unpack() {
170 return new SchemaT(this.bb.createObjList(this.objects.bind(this), this.objectsLength()), this.bb.createObjList(this.enums.bind(this), this.enumsLength()), this.fileIdent(), this.fileExt(), (this.rootTable() !== null ? this.rootTable().unpack() : null), this.bb.createObjList(this.services.bind(this), this.servicesLength()), this.advancedFeatures(), this.bb.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength()));
171 }
172 unpackTo(_o) {
173 _o.objects = this.bb.createObjList(this.objects.bind(this), this.objectsLength());
174 _o.enums = this.bb.createObjList(this.enums.bind(this), this.enumsLength());
175 _o.fileIdent = this.fileIdent();
176 _o.fileExt = this.fileExt();
177 _o.rootTable = (this.rootTable() !== null ? this.rootTable().unpack() : null);
178 _o.services = this.bb.createObjList(this.services.bind(this), this.servicesLength());
179 _o.advancedFeatures = this.advancedFeatures();
180 _o.fbsFiles = this.bb.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength());
181 }
182}
183export class SchemaT {
184 constructor(objects = [], enums = [], fileIdent = null, fileExt = null, rootTable = null, services = [], advancedFeatures = BigInt('0'), fbsFiles = []) {
185 this.objects = objects;
186 this.enums = enums;
187 this.fileIdent = fileIdent;
188 this.fileExt = fileExt;
189 this.rootTable = rootTable;
190 this.services = services;
191 this.advancedFeatures = advancedFeatures;
192 this.fbsFiles = fbsFiles;
193 }
194 pack(builder) {
195 const objects = Schema.createObjectsVector(builder, builder.createObjectOffsetList(this.objects));
196 const enums = Schema.createEnumsVector(builder, builder.createObjectOffsetList(this.enums));
197 const fileIdent = (this.fileIdent !== null ? builder.createString(this.fileIdent) : 0);
198 const fileExt = (this.fileExt !== null ? builder.createString(this.fileExt) : 0);
199 const rootTable = (this.rootTable !== null ? this.rootTable.pack(builder) : 0);
200 const services = Schema.createServicesVector(builder, builder.createObjectOffsetList(this.services));
201 const fbsFiles = Schema.createFbsFilesVector(builder, builder.createObjectOffsetList(this.fbsFiles));
202 Schema.startSchema(builder);
203 Schema.addObjects(builder, objects);
204 Schema.addEnums(builder, enums);
205 Schema.addFileIdent(builder, fileIdent);
206 Schema.addFileExt(builder, fileExt);
207 Schema.addRootTable(builder, rootTable);
208 Schema.addServices(builder, services);
209 Schema.addAdvancedFeatures(builder, this.advancedFeatures);
210 Schema.addFbsFiles(builder, fbsFiles);
211 return Schema.endSchema(builder);
212 }
213}