[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>
This commit is contained in:
James Kuszmaul
2022-12-22 12:59:40 -08:00
committed by GitHub
parent 449d5649d6
commit e43a80c322
54 changed files with 104 additions and 83 deletions

View File

@@ -24,7 +24,7 @@ export class Ability {
return true;
}
static getFullyQualifiedName() {
return 'MyGame_Example_Ability';
return 'MyGame.Example.Ability';
}
static sizeOf() {
return 8;

View File

@@ -32,7 +32,7 @@ mutate_distance(value:number):boolean {
}
static getFullyQualifiedName():string {
return 'MyGame_Example_Ability';
return 'MyGame.Example.Ability';
}
static sizeOf():number {

View File

@@ -610,11 +610,23 @@ export class Monster {
this.bb.writeFloat32(this.bb_pos + offset, value);
return true;
}
doubleInfDefault() {
const offset = this.bb.__offset(this.bb_pos, 126);
return offset ? this.bb.readFloat64(this.bb_pos + offset) : Infinity;
}
mutate_double_inf_default(value) {
const offset = this.bb.__offset(this.bb_pos, 126);
if (offset === 0) {
return false;
}
this.bb.writeFloat64(this.bb_pos + offset, value);
return true;
}
static getFullyQualifiedName() {
return 'MyGame_Example_Monster';
return 'MyGame.Example.Monster';
}
static startMonster(builder) {
builder.startObject(61);
builder.startObject(62);
}
static addPos(builder, posOffset) {
builder.addFieldStruct(0, posOffset, 0);
@@ -975,6 +987,9 @@ export class Monster {
static addNegativeInfinityDefault(builder, negativeInfinityDefault) {
builder.addFieldFloat32(60, negativeInfinityDefault, -Infinity);
}
static addDoubleInfDefault(builder, doubleInfDefault) {
builder.addFieldFloat64(61, doubleInfDefault, Infinity);
}
static endMonster(builder) {
const offset = builder.endObject();
builder.requiredField(offset, 10); // name
@@ -1011,7 +1026,7 @@ export class Monster {
return null;
}
return temp.unpack();
})(), this.bb.createScalarList(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength()), this.signedEnum(), this.bb.createScalarList(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength()), this.bb.createObjList(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength()), (this.nativeInline() !== null ? this.nativeInline().unpack() : null), this.longEnumNonEnumDefault(), this.longEnumNormalDefault(), this.nanDefault(), this.infDefault(), this.positiveInfDefault(), this.infinityDefault(), this.positiveInfinityDefault(), this.negativeInfDefault(), this.negativeInfinityDefault());
})(), this.bb.createScalarList(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength()), this.signedEnum(), this.bb.createScalarList(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength()), this.bb.createObjList(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength()), (this.nativeInline() !== null ? this.nativeInline().unpack() : null), this.longEnumNonEnumDefault(), this.longEnumNormalDefault(), this.nanDefault(), this.infDefault(), this.positiveInfDefault(), this.infinityDefault(), this.positiveInfinityDefault(), this.negativeInfDefault(), this.negativeInfinityDefault(), this.doubleInfDefault());
}
unpackTo(_o) {
_o.pos = (this.pos() !== null ? this.pos().unpack() : null);
@@ -1092,10 +1107,11 @@ export class Monster {
_o.positiveInfinityDefault = this.positiveInfinityDefault();
_o.negativeInfDefault = this.negativeInfDefault();
_o.negativeInfinityDefault = this.negativeInfinityDefault();
_o.doubleInfDefault = this.doubleInfDefault();
}
}
export class MonsterT {
constructor(pos = null, mana = 150, hp = 100, name = null, inventory = [], color = Color.Blue, testType = Any.NONE, test = null, test4 = [], testarrayofstring = [], testarrayoftables = [], enemy = null, testnestedflatbuffer = [], testempty = null, testbool = false, testhashs32Fnv1 = 0, testhashu32Fnv1 = 0, testhashs64Fnv1 = BigInt('0'), testhashu64Fnv1 = BigInt('0'), testhashs32Fnv1a = 0, testhashu32Fnv1a = 0, testhashs64Fnv1a = BigInt('0'), testhashu64Fnv1a = BigInt('0'), testarrayofbools = [], testf = 3.14159, testf2 = 3.0, testf3 = 0.0, testarrayofstring2 = [], testarrayofsortedstruct = [], flex = [], test5 = [], vectorOfLongs = [], vectorOfDoubles = [], parentNamespaceTest = null, vectorOfReferrables = [], singleWeakReference = BigInt('0'), vectorOfWeakReferences = [], vectorOfStrongReferrables = [], coOwningReference = BigInt('0'), vectorOfCoOwningReferences = [], nonOwningReference = BigInt('0'), vectorOfNonOwningReferences = [], anyUniqueType = AnyUniqueAliases.NONE, anyUnique = null, anyAmbiguousType = AnyAmbiguousAliases.NONE, anyAmbiguous = null, vectorOfEnums = [], signedEnum = Race.None, testrequirednestedflatbuffer = [], scalarKeySortedTables = [], nativeInline = null, longEnumNonEnumDefault = BigInt('0'), longEnumNormalDefault = BigInt('2'), nanDefault = NaN, infDefault = Infinity, positiveInfDefault = Infinity, infinityDefault = Infinity, positiveInfinityDefault = Infinity, negativeInfDefault = -Infinity, negativeInfinityDefault = -Infinity) {
constructor(pos = null, mana = 150, hp = 100, name = null, inventory = [], color = Color.Blue, testType = Any.NONE, test = null, test4 = [], testarrayofstring = [], testarrayoftables = [], enemy = null, testnestedflatbuffer = [], testempty = null, testbool = false, testhashs32Fnv1 = 0, testhashu32Fnv1 = 0, testhashs64Fnv1 = BigInt('0'), testhashu64Fnv1 = BigInt('0'), testhashs32Fnv1a = 0, testhashu32Fnv1a = 0, testhashs64Fnv1a = BigInt('0'), testhashu64Fnv1a = BigInt('0'), testarrayofbools = [], testf = 3.14159, testf2 = 3.0, testf3 = 0.0, testarrayofstring2 = [], testarrayofsortedstruct = [], flex = [], test5 = [], vectorOfLongs = [], vectorOfDoubles = [], parentNamespaceTest = null, vectorOfReferrables = [], singleWeakReference = BigInt('0'), vectorOfWeakReferences = [], vectorOfStrongReferrables = [], coOwningReference = BigInt('0'), vectorOfCoOwningReferences = [], nonOwningReference = BigInt('0'), vectorOfNonOwningReferences = [], anyUniqueType = AnyUniqueAliases.NONE, anyUnique = null, anyAmbiguousType = AnyAmbiguousAliases.NONE, anyAmbiguous = null, vectorOfEnums = [], signedEnum = Race.None, testrequirednestedflatbuffer = [], scalarKeySortedTables = [], nativeInline = null, longEnumNonEnumDefault = BigInt('0'), longEnumNormalDefault = BigInt('2'), nanDefault = NaN, infDefault = Infinity, positiveInfDefault = Infinity, infinityDefault = Infinity, positiveInfinityDefault = Infinity, negativeInfDefault = -Infinity, negativeInfinityDefault = -Infinity, doubleInfDefault = Infinity) {
this.pos = pos;
this.mana = mana;
this.hp = hp;
@@ -1156,6 +1172,7 @@ export class MonsterT {
this.positiveInfinityDefault = positiveInfinityDefault;
this.negativeInfDefault = negativeInfDefault;
this.negativeInfinityDefault = negativeInfinityDefault;
this.doubleInfDefault = doubleInfDefault;
}
pack(builder) {
const name = (this.name !== null ? builder.createString(this.name) : 0);
@@ -1246,6 +1263,7 @@ export class MonsterT {
Monster.addPositiveInfinityDefault(builder, this.positiveInfinityDefault);
Monster.addNegativeInfDefault(builder, this.negativeInfDefault);
Monster.addNegativeInfinityDefault(builder, this.negativeInfinityDefault);
Monster.addDoubleInfDefault(builder, this.doubleInfDefault);
return Monster.endMonster(builder);
}
}

View File

@@ -812,7 +812,7 @@ mutate_double_inf_default(value:number):boolean {
}
static getFullyQualifiedName():string {
return 'MyGame_Example_Monster';
return 'MyGame.Example.Monster';
}
static startMonster(builder:flatbuffers.Builder) {

View File

@@ -30,7 +30,7 @@ export class Referrable {
return true;
}
static getFullyQualifiedName() {
return 'MyGame_Example_Referrable';
return 'MyGame.Example.Referrable';
}
static startReferrable(builder) {
builder.startObject(1);

View File

@@ -39,7 +39,7 @@ mutate_id(value:bigint):boolean {
}
static getFullyQualifiedName():string {
return 'MyGame_Example_Referrable';
return 'MyGame.Example.Referrable';
}
static startReferrable(builder:flatbuffers.Builder) {

View File

@@ -46,7 +46,7 @@ export class Stat {
return true;
}
static getFullyQualifiedName() {
return 'MyGame_Example_Stat';
return 'MyGame.Example.Stat';
}
static startStat(builder) {
builder.startObject(3);

View File

@@ -62,7 +62,7 @@ mutate_count(value:number):boolean {
}
static getFullyQualifiedName():string {
return 'MyGame_Example_Stat';
return 'MyGame.Example.Stat';
}
static startStat(builder:flatbuffers.Builder) {

View File

@@ -14,7 +14,7 @@ export class StructOfStructsOfStructs {
return (obj || new StructOfStructs()).__init(this.bb_pos, this.bb);
}
static getFullyQualifiedName() {
return 'MyGame_Example_StructOfStructsOfStructs';
return 'MyGame.Example.StructOfStructsOfStructs';
}
static sizeOf() {
return 20;

View File

@@ -19,7 +19,7 @@ a(obj?:StructOfStructs):StructOfStructs|null {
}
static getFullyQualifiedName():string {
return 'MyGame_Example_StructOfStructsOfStructs';
return 'MyGame.Example.StructOfStructsOfStructs';
}
static sizeOf():number {

View File

@@ -21,7 +21,7 @@ export class StructOfStructs {
return (obj || new Ability()).__init(this.bb_pos + 12, this.bb);
}
static getFullyQualifiedName() {
return 'MyGame_Example_StructOfStructs';
return 'MyGame.Example.StructOfStructs';
}
static sizeOf() {
return 20;

View File

@@ -28,7 +28,7 @@ c(obj?:Ability):Ability|null {
}
static getFullyQualifiedName():string {
return 'MyGame_Example_StructOfStructs';
return 'MyGame.Example.StructOfStructs';
}
static sizeOf():number {

View File

@@ -31,7 +31,7 @@ export class TestSimpleTableWithEnum {
return true;
}
static getFullyQualifiedName() {
return 'MyGame_Example_TestSimpleTableWithEnum';
return 'MyGame.Example.TestSimpleTableWithEnum';
}
static startTestSimpleTableWithEnum(builder) {
builder.startObject(1);

View File

@@ -40,7 +40,7 @@ mutate_color(value:Color):boolean {
}
static getFullyQualifiedName():string {
return 'MyGame_Example_TestSimpleTableWithEnum';
return 'MyGame.Example.TestSimpleTableWithEnum';
}
static startTestSimpleTableWithEnum(builder:flatbuffers.Builder) {

View File

@@ -24,7 +24,7 @@ export class Test {
return true;
}
static getFullyQualifiedName() {
return 'MyGame_Example_Test';
return 'MyGame.Example.Test';
}
static sizeOf() {
return 4;

View File

@@ -32,7 +32,7 @@ mutate_b(value:number):boolean {
}
static getFullyQualifiedName():string {
return 'MyGame_Example_Test';
return 'MyGame.Example.Test';
}
static sizeOf():number {

View File

@@ -162,7 +162,7 @@ export class TypeAliases {
return offset ? new Float64Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
}
static getFullyQualifiedName() {
return 'MyGame_Example_TypeAliases';
return 'MyGame.Example.TypeAliases';
}
static startTypeAliases(builder) {
builder.startObject(12);

View File

@@ -213,7 +213,7 @@ vf64Array():Float64Array|null {
}
static getFullyQualifiedName():string {
return 'MyGame_Example_TypeAliases';
return 'MyGame.Example.TypeAliases';
}
static startTypeAliases(builder:flatbuffers.Builder) {

View File

@@ -49,7 +49,7 @@ export class Vec3 {
return (obj || new Test()).__init(this.bb_pos + 26, this.bb);
}
static getFullyQualifiedName() {
return 'MyGame_Example_Vec3';
return 'MyGame.Example.Vec3';
}
static sizeOf() {
return 32;

View File

@@ -65,7 +65,7 @@ test3(obj?:Test):Test|null {
}
static getFullyQualifiedName():string {
return 'MyGame_Example_Vec3';
return 'MyGame.Example.Vec3';
}
static sizeOf():number {