mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-03 18:04:14 +00:00
fixed invalid TS call and added test files (#6495)
e581013e3d broke TS generation - please don't use "replace" to refactor function names :)
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
export enum EnumInNestedNS{
|
||||
A = 0,
|
||||
B = 1,
|
||||
C = 2
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
|
||||
|
||||
export class StructInNestedNS {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):StructInNestedNS {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
a():number {
|
||||
return this.bb!.readInt32(this.bb_pos);
|
||||
}
|
||||
|
||||
mutate_a(value:number):boolean {
|
||||
this.bb!.writeInt32(this.bb_pos + 0, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
b():number {
|
||||
return this.bb!.readInt32(this.bb_pos + 4);
|
||||
}
|
||||
|
||||
mutate_b(value:number):boolean {
|
||||
this.bb!.writeInt32(this.bb_pos + 4, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'NamespaceA.NamespaceB.StructInNestedNS';
|
||||
}
|
||||
|
||||
static sizeOf():number {
|
||||
return 8;
|
||||
}
|
||||
|
||||
static createStructInNestedNS(builder:flatbuffers.Builder, a: number, b: number):flatbuffers.Offset {
|
||||
builder.prep(4, 8);
|
||||
builder.writeInt32(b);
|
||||
builder.writeInt32(a);
|
||||
return builder.offset();
|
||||
}
|
||||
|
||||
|
||||
unpack(): StructInNestedNST {
|
||||
return new StructInNestedNST(
|
||||
this.a(),
|
||||
this.b()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: StructInNestedNST): void {
|
||||
_o.a = this.a();
|
||||
_o.b = this.b();
|
||||
}
|
||||
}
|
||||
|
||||
export class StructInNestedNST {
|
||||
constructor(
|
||||
public a: number = 0,
|
||||
public b: number = 0
|
||||
){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
return StructInNestedNS.createStructInNestedNS(builder,
|
||||
this.a,
|
||||
this.b
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
|
||||
|
||||
export class TableInNestedNS {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):TableInNestedNS {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsTableInNestedNS(bb:flatbuffers.ByteBuffer, obj?:TableInNestedNS):TableInNestedNS {
|
||||
return (obj || new TableInNestedNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsTableInNestedNS(bb:flatbuffers.ByteBuffer, obj?:TableInNestedNS):TableInNestedNS {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new TableInNestedNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
foo():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
mutate_foo(value:number):boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb!.writeInt32(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'NamespaceA.NamespaceB.TableInNestedNS';
|
||||
}
|
||||
|
||||
static startTableInNestedNS(builder:flatbuffers.Builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
|
||||
static addFoo(builder:flatbuffers.Builder, foo:number) {
|
||||
builder.addFieldInt32(0, foo, 0);
|
||||
}
|
||||
|
||||
static endTableInNestedNS(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
static createTableInNestedNS(builder:flatbuffers.Builder, foo:number):flatbuffers.Offset {
|
||||
TableInNestedNS.startTableInNestedNS(builder);
|
||||
TableInNestedNS.addFoo(builder, foo);
|
||||
return TableInNestedNS.endTableInNestedNS(builder);
|
||||
}
|
||||
|
||||
unpack(): TableInNestedNST {
|
||||
return new TableInNestedNST(
|
||||
this.foo()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: TableInNestedNST): void {
|
||||
_o.foo = this.foo();
|
||||
}
|
||||
}
|
||||
|
||||
export class TableInNestedNST {
|
||||
constructor(
|
||||
public foo: number = 0
|
||||
){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
return TableInNestedNS.createTableInNestedNS(builder,
|
||||
this.foo
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import { TableInNestedNS, TableInNestedNST } from '../../namespace-a/namespace-b/table-in-nested-n-s';
|
||||
|
||||
|
||||
export enum UnionInNestedNS{
|
||||
NONE = 0,
|
||||
TableInNestedNS = 1
|
||||
}
|
||||
|
||||
export function unionToUnionInNestedNS(
|
||||
type: UnionInNestedNS,
|
||||
accessor: (obj:TableInNestedNS) => TableInNestedNS|null
|
||||
): TableInNestedNS|null {
|
||||
switch(UnionInNestedNS[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'TableInNestedNS': return accessor(new TableInNestedNS())! as TableInNestedNS;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function unionListToUnionInNestedNS(
|
||||
type: UnionInNestedNS,
|
||||
accessor: (index: number, obj:TableInNestedNS) => TableInNestedNS|null,
|
||||
index: number
|
||||
): TableInNestedNS|null {
|
||||
switch(UnionInNestedNS[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'TableInNestedNS': return accessor(index, new TableInNestedNS())! as TableInNestedNS;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user