mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-23 19:41:48 +00:00
[TS/JS] Move TS tests to dedicated folder and deps upgrade (#7508)
* Move TS tests to dedicated folder and deps upgrade * Attempt to fix generate_code * Fix dir on CI * Add js extension * Fix missing extension * Harmonize with test gen * Unexplained code gen change * Restore yarn.lock * Naive attempt to fix bazel stuff * Pin @bazel/typescript to 5.2.0 * Attempt to fix bazel * More tweak * Upgrade deps * Tweak? * Fix path * Fix test package Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
88
tests/ts/reflection/schema-file.js
Normal file
88
tests/ts/reflection/schema-file.js
Normal file
@@ -0,0 +1,88 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
/**
|
||||
* File specific information.
|
||||
* Symbols declared within a file may be recovered by iterating over all
|
||||
* symbols and examining the `declaration_file` field.
|
||||
*/
|
||||
export class SchemaFile {
|
||||
constructor() {
|
||||
this.bb = null;
|
||||
this.bb_pos = 0;
|
||||
}
|
||||
__init(i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
static getRootAsSchemaFile(bb, obj) {
|
||||
return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
static getSizePrefixedRootAsSchemaFile(bb, obj) {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
filename(optionalEncoding) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
|
||||
}
|
||||
includedFilenames(index, optionalEncoding) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
|
||||
}
|
||||
includedFilenamesLength() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
|
||||
}
|
||||
static getFullyQualifiedName() {
|
||||
return 'reflection_SchemaFile';
|
||||
}
|
||||
static startSchemaFile(builder) {
|
||||
builder.startObject(2);
|
||||
}
|
||||
static addFilename(builder, filenameOffset) {
|
||||
builder.addFieldOffset(0, filenameOffset, 0);
|
||||
}
|
||||
static addIncludedFilenames(builder, includedFilenamesOffset) {
|
||||
builder.addFieldOffset(1, includedFilenamesOffset, 0);
|
||||
}
|
||||
static createIncludedFilenamesVector(builder, data) {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addOffset(data[i]);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
static startIncludedFilenamesVector(builder, numElems) {
|
||||
builder.startVector(4, numElems, 4);
|
||||
}
|
||||
static endSchemaFile(builder) {
|
||||
const offset = builder.endObject();
|
||||
builder.requiredField(offset, 4); // filename
|
||||
return offset;
|
||||
}
|
||||
static createSchemaFile(builder, filenameOffset, includedFilenamesOffset) {
|
||||
SchemaFile.startSchemaFile(builder);
|
||||
SchemaFile.addFilename(builder, filenameOffset);
|
||||
SchemaFile.addIncludedFilenames(builder, includedFilenamesOffset);
|
||||
return SchemaFile.endSchemaFile(builder);
|
||||
}
|
||||
unpack() {
|
||||
return new SchemaFileT(this.filename(), this.bb.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength()));
|
||||
}
|
||||
unpackTo(_o) {
|
||||
_o.filename = this.filename();
|
||||
_o.includedFilenames = this.bb.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength());
|
||||
}
|
||||
}
|
||||
export class SchemaFileT {
|
||||
constructor(filename = null, includedFilenames = []) {
|
||||
this.filename = filename;
|
||||
this.includedFilenames = includedFilenames;
|
||||
}
|
||||
pack(builder) {
|
||||
const filename = (this.filename !== null ? builder.createString(this.filename) : 0);
|
||||
const includedFilenames = SchemaFile.createIncludedFilenamesVector(builder, builder.createObjectOffsetList(this.includedFilenames));
|
||||
return SchemaFile.createSchemaFile(builder, filename, includedFilenames);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user