Files
flatbuffers/tests/ts/arrays_test_complex/arrays_test_complex_generated.ts
James Kuszmaul e43a80c322 [TS] Fix getFullyQualifiedName codegen for typescript (#7730)
#7451 caused getFullyQualifiedName to return a name with underscores,
not periods. Because the fully qualified name is a property of
FlatBuffers, not the language being codegen'd for, it should use
periods. Fixes #7564.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-22 20:59:40 +00:00

627 lines
15 KiB
TypeScript

// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
export enum TestEnum {
A = 0,
B = 1,
C = 2
}
export class InnerStruct implements flatbuffers.IUnpackableObject<InnerStructT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):InnerStruct {
this.bb_pos = i;
this.bb = bb;
return this;
}
a():number {
return this.bb!.readFloat64(this.bb_pos);
}
b(index: number):number|null {
return this.bb!.readUint8(this.bb_pos + 8 + index);
}
c():number {
return this.bb!.readInt8(this.bb_pos + 21);
}
dUnderscore():bigint {
return this.bb!.readInt64(this.bb_pos + 24);
}
static getFullyQualifiedName():string {
return 'MyGame.Example.InnerStruct';
}
static sizeOf():number {
return 32;
}
static createInnerStruct(builder:flatbuffers.Builder, a: number, b: number[]|null, c: number, d_underscore: bigint):flatbuffers.Offset {
builder.prep(8, 32);
builder.writeInt64(BigInt(d_underscore ?? 0));
builder.pad(2);
builder.writeInt8(c);
for (let i = 12; i >= 0; --i) {
builder.writeInt8((b?.[i] ?? 0));
}
builder.writeFloat64(a);
return builder.offset();
}
unpack(): InnerStructT {
return new InnerStructT(
this.a(),
this.bb!.createScalarList<number>(this.b.bind(this), 13),
this.c(),
this.dUnderscore()
);
}
unpackTo(_o: InnerStructT): void {
_o.a = this.a();
_o.b = this.bb!.createScalarList<number>(this.b.bind(this), 13);
_o.c = this.c();
_o.dUnderscore = this.dUnderscore();
}
}
export class InnerStructT implements flatbuffers.IGeneratedObject {
constructor(
public a: number = 0.0,
public b: (number)[] = [],
public c: number = 0,
public dUnderscore: bigint = BigInt('0')
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return InnerStruct.createInnerStruct(builder,
this.a,
this.b,
this.c,
this.dUnderscore
);
}
}
export class OuterStruct implements flatbuffers.IUnpackableObject<OuterStructT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):OuterStruct {
this.bb_pos = i;
this.bb = bb;
return this;
}
a():boolean {
return !!this.bb!.readInt8(this.bb_pos);
}
b():number {
return this.bb!.readFloat64(this.bb_pos + 8);
}
cUnderscore(obj?:InnerStruct):InnerStruct|null {
return (obj || new InnerStruct()).__init(this.bb_pos + 16, this.bb!);
}
d(index: number, obj?:InnerStruct):InnerStruct|null {
return (obj || new InnerStruct()).__init(this.bb_pos + 48 + index * 32, this.bb!);
}
e(obj?:InnerStruct):InnerStruct|null {
return (obj || new InnerStruct()).__init(this.bb_pos + 144, this.bb!);
}
f(index: number):number|null {
return this.bb!.readFloat64(this.bb_pos + 176 + index * 8);
}
static getFullyQualifiedName():string {
return 'MyGame.Example.OuterStruct';
}
static sizeOf():number {
return 208;
}
static createOuterStruct(builder:flatbuffers.Builder, a: boolean, b: number, c_underscore_a: number, c_underscore_b: number[]|null, c_underscore_c: number, c_underscore_d_underscore: bigint, d: (any|InnerStructT)[]|null, e_a: number, e_b: number[]|null, e_c: number, e_d_underscore: bigint, f: number[]|null):flatbuffers.Offset {
builder.prep(8, 208);
for (let i = 3; i >= 0; --i) {
builder.writeFloat64((f?.[i] ?? 0));
}
builder.prep(8, 32);
builder.writeInt64(BigInt(e_d_underscore ?? 0));
builder.pad(2);
builder.writeInt8(e_c);
for (let i = 12; i >= 0; --i) {
builder.writeInt8((e_b?.[i] ?? 0));
}
builder.writeFloat64(e_a);
for (let i = 2; i >= 0; --i) {
const item = d?.[i];
if (item instanceof InnerStructT) {
item.pack(builder);
continue;
}
InnerStruct.createInnerStruct(builder,
item?.a,
item?.b,
item?.c,
item?.dUnderscore
);
}
builder.prep(8, 32);
builder.writeInt64(BigInt(c_underscore_d_underscore ?? 0));
builder.pad(2);
builder.writeInt8(c_underscore_c);
for (let i = 12; i >= 0; --i) {
builder.writeInt8((c_underscore_b?.[i] ?? 0));
}
builder.writeFloat64(c_underscore_a);
builder.writeFloat64(b);
builder.pad(7);
builder.writeInt8(Number(Boolean(a)));
return builder.offset();
}
unpack(): OuterStructT {
return new OuterStructT(
this.a(),
this.b(),
(this.cUnderscore() !== null ? this.cUnderscore()!.unpack() : null),
this.bb!.createObjList<InnerStruct, InnerStructT>(this.d.bind(this), 3),
(this.e() !== null ? this.e()!.unpack() : null),
this.bb!.createScalarList<number>(this.f.bind(this), 4)
);
}
unpackTo(_o: OuterStructT): void {
_o.a = this.a();
_o.b = this.b();
_o.cUnderscore = (this.cUnderscore() !== null ? this.cUnderscore()!.unpack() : null);
_o.d = this.bb!.createObjList<InnerStruct, InnerStructT>(this.d.bind(this), 3);
_o.e = (this.e() !== null ? this.e()!.unpack() : null);
_o.f = this.bb!.createScalarList<number>(this.f.bind(this), 4);
}
}
export class OuterStructT implements flatbuffers.IGeneratedObject {
constructor(
public a: boolean = false,
public b: number = 0.0,
public cUnderscore: InnerStructT|null = null,
public d: (InnerStructT)[] = [],
public e: InnerStructT|null = null,
public f: (number)[] = []
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return OuterStruct.createOuterStruct(builder,
this.a,
this.b,
(this.cUnderscore?.a ?? 0),
(this.cUnderscore?.b ?? []),
(this.cUnderscore?.c ?? 0),
(this.cUnderscore?.dUnderscore ?? BigInt(0)),
this.d,
(this.e?.a ?? 0),
(this.e?.b ?? []),
(this.e?.c ?? 0),
(this.e?.dUnderscore ?? BigInt(0)),
this.f
);
}
}
export class NestedStruct implements flatbuffers.IUnpackableObject<NestedStructT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):NestedStruct {
this.bb_pos = i;
this.bb = bb;
return this;
}
a(index: number):number|null {
return this.bb!.readInt32(this.bb_pos + 0 + index * 4);
}
b():TestEnum {
return this.bb!.readInt8(this.bb_pos + 8);
}
cUnderscore(index: number):TestEnum|null {
return this.bb!.readInt8(this.bb_pos + 9 + index);
}
dOuter(index: number, obj?:OuterStruct):OuterStruct|null {
return (obj || new OuterStruct()).__init(this.bb_pos + 16 + index * 208, this.bb!);
}
e(index: number):bigint|null {
return this.bb!.readInt64(this.bb_pos + 1056 + index * 8);
}
static getFullyQualifiedName():string {
return 'MyGame.Example.NestedStruct';
}
static sizeOf():number {
return 1072;
}
static createNestedStruct(builder:flatbuffers.Builder, a: number[]|null, b: TestEnum, c_underscore: number[]|null, d_outer: (any|OuterStructT)[]|null, e: bigint[]|null):flatbuffers.Offset {
builder.prep(8, 1072);
for (let i = 1; i >= 0; --i) {
builder.writeInt64(BigInt(e?.[i] ?? 0));
}
for (let i = 4; i >= 0; --i) {
const item = d_outer?.[i];
if (item instanceof OuterStructT) {
item.pack(builder);
continue;
}
OuterStruct.createOuterStruct(builder,
item?.a,
item?.b,
(item?.cUnderscore?.a ?? 0),
(item?.cUnderscore?.b ?? []),
(item?.cUnderscore?.c ?? 0),
(item?.cUnderscore?.dUnderscore ?? BigInt(0)),
item?.d,
(item?.e?.a ?? 0),
(item?.e?.b ?? []),
(item?.e?.c ?? 0),
(item?.e?.dUnderscore ?? BigInt(0)),
item?.f
);
}
builder.pad(5);
for (let i = 1; i >= 0; --i) {
builder.writeInt8((c_underscore?.[i] ?? 0));
}
builder.writeInt8(b);
for (let i = 1; i >= 0; --i) {
builder.writeInt32((a?.[i] ?? 0));
}
return builder.offset();
}
unpack(): NestedStructT {
return new NestedStructT(
this.bb!.createScalarList<number>(this.a.bind(this), 2),
this.b(),
this.bb!.createScalarList<TestEnum>(this.cUnderscore.bind(this), 2),
this.bb!.createObjList<OuterStruct, OuterStructT>(this.dOuter.bind(this), 5),
this.bb!.createScalarList<bigint>(this.e.bind(this), 2)
);
}
unpackTo(_o: NestedStructT): void {
_o.a = this.bb!.createScalarList<number>(this.a.bind(this), 2);
_o.b = this.b();
_o.cUnderscore = this.bb!.createScalarList<TestEnum>(this.cUnderscore.bind(this), 2);
_o.dOuter = this.bb!.createObjList<OuterStruct, OuterStructT>(this.dOuter.bind(this), 5);
_o.e = this.bb!.createScalarList<bigint>(this.e.bind(this), 2);
}
}
export class NestedStructT implements flatbuffers.IGeneratedObject {
constructor(
public a: (number)[] = [],
public b: TestEnum = TestEnum.A,
public cUnderscore: (TestEnum)[] = [TestEnum.A, TestEnum.A],
public dOuter: (OuterStructT)[] = [],
public e: (bigint)[] = []
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return NestedStruct.createNestedStruct(builder,
this.a,
this.b,
this.cUnderscore,
this.dOuter,
this.e
);
}
}
export class ArrayStruct implements flatbuffers.IUnpackableObject<ArrayStructT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):ArrayStruct {
this.bb_pos = i;
this.bb = bb;
return this;
}
aUnderscore():number {
return this.bb!.readFloat32(this.bb_pos);
}
bUnderscore(index: number):number|null {
return this.bb!.readInt32(this.bb_pos + 4 + index * 4);
}
c():number {
return this.bb!.readInt8(this.bb_pos + 64);
}
d(index: number, obj?:NestedStruct):NestedStruct|null {
return (obj || new NestedStruct()).__init(this.bb_pos + 72 + index * 1072, this.bb!);
}
e():number {
return this.bb!.readInt32(this.bb_pos + 2216);
}
f(index: number, obj?:OuterStruct):OuterStruct|null {
return (obj || new OuterStruct()).__init(this.bb_pos + 2224 + index * 208, this.bb!);
}
g(index: number):bigint|null {
return this.bb!.readInt64(this.bb_pos + 2640 + index * 8);
}
static getFullyQualifiedName():string {
return 'MyGame.Example.ArrayStruct';
}
static sizeOf():number {
return 2656;
}
static createArrayStruct(builder:flatbuffers.Builder, a_underscore: number, b_underscore: number[]|null, c: number, d: (any|NestedStructT)[]|null, e: number, f: (any|OuterStructT)[]|null, g: bigint[]|null):flatbuffers.Offset {
builder.prep(8, 2656);
for (let i = 1; i >= 0; --i) {
builder.writeInt64(BigInt(g?.[i] ?? 0));
}
for (let i = 1; i >= 0; --i) {
const item = f?.[i];
if (item instanceof OuterStructT) {
item.pack(builder);
continue;
}
OuterStruct.createOuterStruct(builder,
item?.a,
item?.b,
(item?.cUnderscore?.a ?? 0),
(item?.cUnderscore?.b ?? []),
(item?.cUnderscore?.c ?? 0),
(item?.cUnderscore?.dUnderscore ?? BigInt(0)),
item?.d,
(item?.e?.a ?? 0),
(item?.e?.b ?? []),
(item?.e?.c ?? 0),
(item?.e?.dUnderscore ?? BigInt(0)),
item?.f
);
}
builder.pad(4);
builder.writeInt32(e);
for (let i = 1; i >= 0; --i) {
const item = d?.[i];
if (item instanceof NestedStructT) {
item.pack(builder);
continue;
}
NestedStruct.createNestedStruct(builder,
item?.a,
item?.b,
item?.cUnderscore,
item?.dOuter,
item?.e
);
}
builder.pad(7);
builder.writeInt8(c);
for (let i = 14; i >= 0; --i) {
builder.writeInt32((b_underscore?.[i] ?? 0));
}
builder.writeFloat32(a_underscore);
return builder.offset();
}
unpack(): ArrayStructT {
return new ArrayStructT(
this.aUnderscore(),
this.bb!.createScalarList<number>(this.bUnderscore.bind(this), 15),
this.c(),
this.bb!.createObjList<NestedStruct, NestedStructT>(this.d.bind(this), 2),
this.e(),
this.bb!.createObjList<OuterStruct, OuterStructT>(this.f.bind(this), 2),
this.bb!.createScalarList<bigint>(this.g.bind(this), 2)
);
}
unpackTo(_o: ArrayStructT): void {
_o.aUnderscore = this.aUnderscore();
_o.bUnderscore = this.bb!.createScalarList<number>(this.bUnderscore.bind(this), 15);
_o.c = this.c();
_o.d = this.bb!.createObjList<NestedStruct, NestedStructT>(this.d.bind(this), 2);
_o.e = this.e();
_o.f = this.bb!.createObjList<OuterStruct, OuterStructT>(this.f.bind(this), 2);
_o.g = this.bb!.createScalarList<bigint>(this.g.bind(this), 2);
}
}
export class ArrayStructT implements flatbuffers.IGeneratedObject {
constructor(
public aUnderscore: number = 0.0,
public bUnderscore: (number)[] = [],
public c: number = 0,
public d: (NestedStructT)[] = [],
public e: number = 0,
public f: (OuterStructT)[] = [],
public g: (bigint)[] = []
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return ArrayStruct.createArrayStruct(builder,
this.aUnderscore,
this.bUnderscore,
this.c,
this.d,
this.e,
this.f,
this.g
);
}
}
export class ArrayTable implements flatbuffers.IUnpackableObject<ArrayTableT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):ArrayTable {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsArrayTable(bb:flatbuffers.ByteBuffer, obj?:ArrayTable):ArrayTable {
return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsArrayTable(bb:flatbuffers.ByteBuffer, obj?:ArrayTable):ArrayTable {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean {
return bb.__has_identifier('RHUB');
}
a():string|null
a(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
a(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
cUnderscore(obj?:ArrayStruct):ArrayStruct|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? (obj || new ArrayStruct()).__init(this.bb_pos + offset, this.bb!) : null;
}
static getFullyQualifiedName():string {
return 'MyGame.Example.ArrayTable';
}
static startArrayTable(builder:flatbuffers.Builder) {
builder.startObject(2);
}
static addA(builder:flatbuffers.Builder, aOffset:flatbuffers.Offset) {
builder.addFieldOffset(0, aOffset, 0);
}
static addCUnderscore(builder:flatbuffers.Builder, cUnderscoreOffset:flatbuffers.Offset) {
builder.addFieldStruct(1, cUnderscoreOffset, 0);
}
static endArrayTable(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static finishArrayTableBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
builder.finish(offset, 'RHUB');
}
static finishSizePrefixedArrayTableBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
builder.finish(offset, 'RHUB', true);
}
unpack(): ArrayTableT {
return new ArrayTableT(
this.a(),
(this.cUnderscore() !== null ? this.cUnderscore()!.unpack() : null)
);
}
unpackTo(_o: ArrayTableT): void {
_o.a = this.a();
_o.cUnderscore = (this.cUnderscore() !== null ? this.cUnderscore()!.unpack() : null);
}
}
export class ArrayTableT implements flatbuffers.IGeneratedObject {
constructor(
public a: string|Uint8Array|null = null,
public cUnderscore: ArrayStructT|null = null
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const a = (this.a !== null ? builder.createString(this.a!) : 0);
ArrayTable.startArrayTable(builder);
ArrayTable.addA(builder, a);
ArrayTable.addCUnderscore(builder, (this.cUnderscore !== null ? this.cUnderscore!.pack(builder) : 0));
return ArrayTable.endArrayTable(builder);
}
}