diff --git a/src/Luban.Java/TypeVisitors/JavaBinUnderlyingDeserializeVisitor.cs b/src/Luban.Java/TypeVisitors/JavaBinUnderlyingDeserializeVisitor.cs index 3b2b5779..dabf18c4 100644 --- a/src/Luban.Java/TypeVisitors/JavaBinUnderlyingDeserializeVisitor.cs +++ b/src/Luban.Java/TypeVisitors/JavaBinUnderlyingDeserializeVisitor.cs @@ -1,5 +1,6 @@ using Luban.Types; using Luban.TypeVisitors; +using Luban.Utils; namespace Luban.Java.TypeVisitors; @@ -44,7 +45,9 @@ public string Accept(TDouble type, string bufName, string fieldName) public string Accept(TEnum type, string bufName, string fieldName) { - return $"{fieldName} = {bufName}.readInt();"; + string src = $"{bufName}.readInt()"; + string constructor = type.DefEnum.TypeConstructorWithTypeMapper(); + return $"{fieldName} = {(string.IsNullOrEmpty(constructor) ? src : $"{constructor}({src})")};"; } public string Accept(TString type, string bufName, string fieldName) @@ -54,7 +57,9 @@ public string Accept(TString type, string bufName, string fieldName) public string Accept(TBean type, string bufName, string fieldName) { - return $"{fieldName} = {type.DefBean.FullNameWithTopModule}.deserialize({bufName});"; + string src = $"{type.DefBean.FullNameWithTopModule}.deserialize({bufName})"; + string constructor = type.DefBean.TypeConstructorWithTypeMapper(); + return $"{fieldName} = {(string.IsNullOrEmpty(constructor) ? src : $"{constructor}({src})")};"; } public string Accept(TArray type, string bufName, string fieldName) diff --git a/src/Luban.Java/TypeVisitors/JavaDeclaringTypeNameVisitor.cs b/src/Luban.Java/TypeVisitors/JavaDeclaringTypeNameVisitor.cs index 506eb0bf..e1f39524 100644 --- a/src/Luban.Java/TypeVisitors/JavaDeclaringTypeNameVisitor.cs +++ b/src/Luban.Java/TypeVisitors/JavaDeclaringTypeNameVisitor.cs @@ -1,5 +1,6 @@ using Luban.Types; using Luban.TypeVisitors; +using Luban.Utils; namespace Luban.Java.TypeVisitors; @@ -44,8 +45,8 @@ public virtual string Accept(TDouble type) public virtual string Accept(TEnum type) { - //return type.DefineEnum.FullNameWithTopModule; - return type.IsNullable ? "Integer" : "int"; + string src = type.IsNullable ? "Integer" : "int"; + return type.DefEnum.TypeNameWithTypeMapper() ?? src; } public string Accept(TString type) @@ -60,7 +61,7 @@ public virtual string Accept(TDateTime type) public string Accept(TBean type) { - return type.DefBean.FullNameWithTopModule; + return type.DefBean.TypeNameWithTypeMapper() ?? type.DefBean.FullNameWithTopModule; } public string Accept(TArray type)