From ef10cf0a845999ac4c50681e7138da01ac0583f5 Mon Sep 17 00:00:00 2001 From: walon Date: Sat, 14 Aug 2021 14:24:26 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E5=A4=8D=E3=80=91=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=20cfg=20java=20bin=20=E4=BB=A3=E7=A0=81=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=9A=84bug(=E4=B8=8A=E6=AC=A1=E4=BF=AE=E5=A4=8Dcpp?= =?UTF-8?q?=E7=94=9F=E6=88=90=E6=97=B6=E5=A4=B1=E8=AF=AF=E6=94=B9=E9=94=99?= =?UTF-8?q?=E4=BA=86)=20=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20cfg=20typescript=20bin=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99=E7=9A=84=E5=88=86=E5=8F=B7?= =?UTF-8?q?';'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Source/Defs/TTypeTemplateExtends.cs | 30 ++--------------- .../Source/Defs/DefTypeBase.cs | 2 ++ ...scriptBinUnderingDeserializeVisitorBase.cs | 32 +++++++++---------- 3 files changed, 20 insertions(+), 44 deletions(-) diff --git a/src/Luban.Job.Cfg/Source/Defs/TTypeTemplateExtends.cs b/src/Luban.Job.Cfg/Source/Defs/TTypeTemplateExtends.cs index fcd5205..3d66697 100644 --- a/src/Luban.Job.Cfg/Source/Defs/TTypeTemplateExtends.cs +++ b/src/Luban.Job.Cfg/Source/Defs/TTypeTemplateExtends.cs @@ -71,11 +71,11 @@ namespace Luban.Job.Cfg.Defs var table = field.Assembly.GetCfgTable(field.Ref.FirstTable); if (field.IsNullable) { - return $"this.{refVarName} = this.{name} != null ? (({table.CppFullName})_tables.get(\"{tableName}\")).get({name}) : null;"; + return $"this.{refVarName} = this.{name} != null ? (({table.FullNameWithTopModule})_tables.get(\"{tableName}\")).get({name}) : null;"; } else { - return $"this.{refVarName} = (({table.CppFullName})_tables.get(\"{tableName}\")).get({name});"; + return $"this.{refVarName} = (({table.FullNameWithTopModule})_tables.get(\"{tableName}\")).get({name});"; } } @@ -179,31 +179,5 @@ namespace Luban.Job.Cfg.Defs return type.Apply(PyUnderingDeserializeVisitor.Ins, $"{jsonVarName}['{jsonFieldName}']", fieldName); } } - - /* - public static string Py27DeserializeValue(string fieldName, string jsonVarName, TType type) - { - if (type.IsNullable) - { - return $"if {jsonVarName} != None: {type.Apply(PyUnderingDeserializeVisitor.Py27Ins, jsonVarName, fieldName)}"; - } - else - { - return type.Apply(PyUnderingDeserializeVisitor.Py3Ins, jsonVarName, fieldName); - } - } - - public static string Py27DeserializeField(string fieldName, string jsonVarName, string jsonFieldName, TType type) - { - if (type.IsNullable) - { - return $"if {jsonVarName}.get('{jsonFieldName}') != None: {type.Apply(PyUnderingDeserializeVisitor.Py3Ins, $"{jsonVarName}['{jsonFieldName}']", fieldName)}"; - } - else - { - return type.Apply(PyUnderingDeserializeVisitor.Py27Ins, $"{jsonVarName}['{jsonFieldName}']", fieldName); - } - } - */ } } diff --git a/src/Luban.Job.Common/Source/Defs/DefTypeBase.cs b/src/Luban.Job.Common/Source/Defs/DefTypeBase.cs index 519c37d..b21da8f 100644 --- a/src/Luban.Job.Common/Source/Defs/DefTypeBase.cs +++ b/src/Luban.Job.Common/Source/Defs/DefTypeBase.cs @@ -23,6 +23,8 @@ namespace Luban.Job.Common.Defs public string FullNameWithTopModule => TypeUtil.MakeFullName(AssemblyBase.TopModule, FullName); + public string JavaFullName => TypeUtil.MakeFullName(Namespace, Name); + public string GoFullName => TypeUtil.MakeGoFullName(Namespace, Name); public string GoPkgName => TypeUtil.MakeGoPkgName(Namespace); diff --git a/src/Luban.Job.Common/Source/TypeVisitors/TypescriptBinUnderingDeserializeVisitorBase.cs b/src/Luban.Job.Common/Source/TypeVisitors/TypescriptBinUnderingDeserializeVisitorBase.cs index e086dfe..cf2c04c 100644 --- a/src/Luban.Job.Common/Source/TypeVisitors/TypescriptBinUnderingDeserializeVisitorBase.cs +++ b/src/Luban.Job.Common/Source/TypeVisitors/TypescriptBinUnderingDeserializeVisitorBase.cs @@ -7,72 +7,72 @@ namespace Luban.Job.Common.TypeVisitors { public string Accept(TBool type, string bufName, string fieldName) { - return $"{fieldName} = {bufName}.ReadBool();"; + return $"{fieldName} = {bufName}.ReadBool()"; } public string Accept(TByte type, string bufName, string fieldName) { - return $"{fieldName} = {bufName}.ReadByte();"; + return $"{fieldName} = {bufName}.ReadByte()"; } public string Accept(TShort type, string bufName, string fieldName) { - return $"{fieldName} = {bufName}.ReadShort();"; + return $"{fieldName} = {bufName}.ReadShort()"; } public string Accept(TFshort type, string bufName, string fieldName) { - return $"{fieldName} = {bufName}.ReadFshort();"; + return $"{fieldName} = {bufName}.ReadFshort()"; } public string Accept(TInt type, string bufName, string fieldName) { - return $"{fieldName} = {bufName}.ReadInt();"; + return $"{fieldName} = {bufName}.ReadInt()"; } public string Accept(TFint type, string bufName, string fieldName) { - return $"{fieldName} = {bufName}.ReadFint();"; + return $"{fieldName} = {bufName}.ReadFint()"; } public string Accept(TLong type, string bufName, string fieldName) { - return $"{fieldName} = {bufName}.{(type.IsBigInt ? "ReadLong" : "ReadLongAsNumber")}();"; + return $"{fieldName} = {bufName}.{(type.IsBigInt ? "ReadLong" : "ReadLongAsNumber")}()"; } public string Accept(TFlong type, string bufName, string fieldName) { - return $"{fieldName} = {bufName}.ReadFlong();"; + return $"{fieldName} = {bufName}.ReadFlong()"; } public string Accept(TFloat type, string bufName, string fieldName) { - return $"{fieldName} = {bufName}.ReadFloat();"; + return $"{fieldName} = {bufName}.ReadFloat()"; } public string Accept(TDouble type, string bufName, string fieldName) { - return $"{fieldName} = {bufName}.ReadDouble();"; + return $"{fieldName} = {bufName}.ReadDouble()"; } public string Accept(TEnum type, string bufName, string fieldName) { - return $"{fieldName} = {bufName}.ReadInt();"; + return $"{fieldName} = {bufName}.ReadInt()"; } public string Accept(TString type, string bufName, string fieldName) { - return $"{fieldName} = {bufName}.ReadString();"; + return $"{fieldName} = {bufName}.ReadString()"; } public string Accept(TBytes type, string bufName, string fieldName) { - return $"{fieldName} = new Uint8Array({bufName}.ReadArrayBuffer());"; + return $"{fieldName} = new Uint8Array({bufName}.ReadArrayBuffer())"; } public string Accept(TText type, string bufName, string fieldName) { - return $"{fieldName} = {bufName}.ReadString();"; + return $"{fieldName} = {bufName}.ReadString()"; } public abstract string Accept(TBean type, string bufVarName, string fieldName); @@ -118,7 +118,7 @@ namespace Luban.Job.Common.TypeVisitors public virtual string Accept(TList type, string bufVarName, string fieldName) { - return $"{{ {fieldName} = []; for(let i = 0, n = {bufVarName}.ReadSize() ; i < n ; i++) {{ let _e :{type.ElementType.Apply(TypescriptDefineTypeNameVisitor.Ins)};{type.ElementType.Apply(this, bufVarName, "_e")}; {fieldName}.push(_e) }} }}"; + return $"{{ {fieldName} = []; for(let i = 0, n = {bufVarName}.ReadSize() ; i < n ; i++) {{ let _e :{type.ElementType.Apply(TypescriptDefineTypeNameVisitor.Ins)}; {type.ElementType.Apply(this, bufVarName, "_e")}; {fieldName}.push(_e) }} }}"; } public virtual string Accept(TSet type, string bufVarName, string fieldName) @@ -148,7 +148,7 @@ namespace Luban.Job.Common.TypeVisitors public string Accept(TDateTime type, string bufVarName, string fieldName) { - return $"{fieldName} = {bufVarName}.ReadInt();"; + return $"{fieldName} = {bufVarName}.ReadInt()"; } } }