【修复】修复cfg typescript优化序列化代码最后的分号";"引发的proto与db的生成代码编译错误问题
parent
1a79272af3
commit
e278566289
|
|
@ -11,11 +11,11 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
{
|
{
|
||||||
if (type.Bean.IsAbstractType)
|
if (type.Bean.IsAbstractType)
|
||||||
{
|
{
|
||||||
return $"{fieldName} = {type.Bean.FullName}.deserializeFrom({bufVarName});";
|
return $"{fieldName} = {type.Bean.FullName}.deserializeFrom({bufVarName})";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $"{fieldName} = new {type.Bean.FullName}(); {fieldName}.deserialize({bufVarName});";
|
return $"{fieldName} = new {type.Bean.FullName}(); {fieldName}.deserialize({bufVarName})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,72 +14,72 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TBool type, string bufName, string fieldName)
|
public string Accept(TBool type, string bufName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{bufName}.WriteBool({fieldName});";
|
return $"{bufName}.WriteBool({fieldName})";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(TByte type, string bufName, string fieldName)
|
public string Accept(TByte type, string bufName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{bufName}.WriteByte({fieldName});";
|
return $"{bufName}.WriteByte({fieldName})";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(TShort type, string bufName, string fieldName)
|
public string Accept(TShort type, string bufName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{bufName}.WriteShort({fieldName});";
|
return $"{bufName}.WriteShort({fieldName})";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(TFshort type, string bufName, string fieldName)
|
public string Accept(TFshort type, string bufName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{bufName}.WriteFshort({fieldName});";
|
return $"{bufName}.WriteFshort({fieldName})";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(TInt type, string bufName, string fieldName)
|
public string Accept(TInt type, string bufName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{bufName}.WriteInt({fieldName});";
|
return $"{bufName}.WriteInt({fieldName})";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(TFint type, string bufName, string fieldName)
|
public string Accept(TFint type, string bufName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{bufName}.WriteFint({fieldName});";
|
return $"{bufName}.WriteFint({fieldName})";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(TLong type, string bufName, string fieldName)
|
public string Accept(TLong type, string bufName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{bufName}.{(type.IsBigInt ? "WriteLong" : "WriteNumberAsLong")}({fieldName});";
|
return $"{bufName}.{(type.IsBigInt ? "WriteLong" : "WriteNumberAsLong")}({fieldName})";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(TFlong type, string bufName, string fieldName)
|
public string Accept(TFlong type, string bufName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{bufName}.WriteFlong({fieldName});";
|
return $"{bufName}.WriteFlong({fieldName})";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(TFloat type, string bufName, string fieldName)
|
public string Accept(TFloat type, string bufName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{bufName}.WriteFloat({fieldName});";
|
return $"{bufName}.WriteFloat({fieldName})";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(TDouble type, string bufName, string fieldName)
|
public string Accept(TDouble type, string bufName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{bufName}.WriteDouble({fieldName});";
|
return $"{bufName}.WriteDouble({fieldName})";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(TEnum type, string bufName, string fieldName)
|
public string Accept(TEnum type, string bufName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{bufName}.WriteInt({fieldName});";
|
return $"{bufName}.WriteInt({fieldName})";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(TString type, string bufName, string fieldName)
|
public string Accept(TString type, string bufName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{bufName}.WriteString({fieldName});";
|
return $"{bufName}.WriteString({fieldName})";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(TBytes type, string bufName, string fieldName)
|
public string Accept(TBytes type, string bufName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{bufName}.WriteArrayBuffer({fieldName}.buffer);";
|
return $"{bufName}.WriteArrayBuffer({fieldName}.buffer)";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(TText type, string bufName, string fieldName)
|
public string Accept(TText type, string bufName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{bufName}.WriteString({fieldName});";
|
return $"{bufName}.WriteString({fieldName})";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(TVector2 type, string bufVarName, string fieldName)
|
public string Accept(TVector2 type, string bufVarName, string fieldName)
|
||||||
|
|
@ -99,18 +99,18 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type, string bufVarName, string fieldName)
|
public string Accept(TDateTime type, string bufVarName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{bufVarName}.WriteInt({fieldName});";
|
return $"{bufVarName}.WriteInt({fieldName})";
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string Accept(TBean type, string bufVarName, string fieldName)
|
public virtual string Accept(TBean type, string bufVarName, string fieldName)
|
||||||
{
|
{
|
||||||
if (type.Bean.IsAbstractType)
|
if (type.Bean.IsAbstractType)
|
||||||
{
|
{
|
||||||
return $"{type.Bean.FullName}.serializeTo({bufVarName}, {fieldName});";
|
return $"{type.Bean.FullName}.serializeTo({bufVarName}, {fieldName})";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $"{fieldName}.serialize({bufVarName});";
|
return $"{fieldName}.serialize({bufVarName})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -131,7 +131,7 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
|
|
||||||
public virtual string Accept(TMap type, string bufVarName, string fieldName)
|
public virtual string Accept(TMap type, string bufVarName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{{ {bufVarName}.WriteSize({fieldName}.size); for(let [_k, _v] of {fieldName}) {{ {type.KeyType.Apply(this, bufVarName, "_k")} {type.ValueType.Apply(this, bufVarName, "_v")} }} }}";
|
return $"{{ {bufVarName}.WriteSize({fieldName}.size); for(let [_k, _v] of {fieldName}) {{ {type.KeyType.Apply(this, bufVarName, "_k")}; {type.ValueType.Apply(this, bufVarName, "_v")} }} }}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ export {{x.ts_class_modifier}} class {{name}} extends {{if parent_def_type}} {{x
|
||||||
let _tag_ = _buf.ReadInt()
|
let _tag_ = _buf.ReadInt()
|
||||||
switch (_tag_) {
|
switch (_tag_) {
|
||||||
{{~ for field in hierarchy_fields~}}
|
{{~ for field in hierarchy_fields~}}
|
||||||
case FieldTag.{{tag_name field.ctype}} | ({{field.id}} << FieldTag.TAG_SHIFT) : { {{db_ts_compatible_deserialize '_buf' field.internal_name_with_this field.ctype}} break; }
|
case FieldTag.{{tag_name field.ctype}} | ({{field.id}} << FieldTag.TAG_SHIFT) : { {{db_ts_compatible_deserialize '_buf' field.internal_name_with_this field.ctype}}; break; }
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
default: { _buf.SkipUnknownField(_tag_); break; }
|
default: { _buf.SkipUnknownField(_tag_); break; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue