From f3949f9c721c3f0614658dd43233bbecd23be3b0 Mon Sep 17 00:00:00 2001 From: yxy Date: Thu, 3 Feb 2022 13:43:40 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91EmmeLua?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E6=B3=A8=E8=A7=A3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Source/Defs/TTypeTemplateCommonExtends.cs | 5 + .../TypeVisitors/EmmeLuaCommentTypeVisitor.cs | 124 ++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 src/Luban.Job.Common/Source/TypeVisitors/EmmeLuaCommentTypeVisitor.cs diff --git a/src/Luban.Job.Common/Source/Defs/TTypeTemplateCommonExtends.cs b/src/Luban.Job.Common/Source/Defs/TTypeTemplateCommonExtends.cs index 159f25b..f7ed09a 100644 --- a/src/Luban.Job.Common/Source/Defs/TTypeTemplateCommonExtends.cs +++ b/src/Luban.Job.Common/Source/Defs/TTypeTemplateCommonExtends.cs @@ -100,6 +100,11 @@ namespace Luban.Job.Common.Defs { return type.Apply(LuaCommentTypeVisitor.Ins); } + + public static string EmmeLuaCommentType(TType type) + { + return type.Apply(EmmeLuaCommentTypeVisitor.Ins); + } public static string LuaSerializeWhileNil(string bufName, string fieldName, TType type) { diff --git a/src/Luban.Job.Common/Source/TypeVisitors/EmmeLuaCommentTypeVisitor.cs b/src/Luban.Job.Common/Source/TypeVisitors/EmmeLuaCommentTypeVisitor.cs new file mode 100644 index 0000000..1b0a661 --- /dev/null +++ b/src/Luban.Job.Common/Source/TypeVisitors/EmmeLuaCommentTypeVisitor.cs @@ -0,0 +1,124 @@ +using Luban.Job.Common.Types; + +namespace Luban.Job.Common.TypeVisitors +{ + public class EmmeLuaCommentTypeVisitor : ITypeFuncVisitor + { + public static EmmeLuaCommentTypeVisitor Ins { get; } = new EmmeLuaCommentTypeVisitor(); + + public string Accept(TBool type) + { + return "boolean"; + } + + public string Accept(TByte type) + { + return "number"; + } + + public string Accept(TShort type) + { + return "number"; + } + + public string Accept(TFshort type) + { + return "number"; + } + + public string Accept(TInt type) + { + return "number"; + } + + public string Accept(TFint type) + { + return "number"; + } + + public string Accept(TLong type) + { + return "number"; + } + + public string Accept(TFlong type) + { + return "number"; + } + + public string Accept(TFloat type) + { + return "number"; + } + + public string Accept(TDouble type) + { + return "number"; + } + + public string Accept(TEnum type) + { + return type.DefineEnum.FullName; + } + + public string Accept(TString type) + { + return "string"; + } + + public string Accept(TBytes type) + { + return $"string"; + } + + public string Accept(TText type) + { + return "string"; + } + + public string Accept(TBean type) + { + return type.Bean.FullName; + } + + public string Accept(TArray type) + { + return $"{type.ElementType.Apply(this)}[]"; + } + + public string Accept(TList type) + { + return $"{type.ElementType.Apply(this)}[]"; + } + + public string Accept(TSet type) + { + return $"{type.ElementType.Apply(this)}[]"; + } + + public string Accept(TMap type) + { + return $"table<{type.KeyType.Apply(this)},{type.ValueType.Apply(this)}>"; + } + + public string Accept(TVector2 type) + { + return "vector2"; + } + + public string Accept(TVector3 type) + { + return "vector3"; + } + + public string Accept(TVector4 type) + { + return "vector4"; + } + + public string Accept(TDateTime type) + { + return "number"; + } + } +} From a4df2de8377a1cb29039de2306df963f50b69dff Mon Sep 17 00:00:00 2001 From: yxy Date: Thu, 3 Feb 2022 22:15:15 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E3=80=90=E4=BF=AE=E5=A4=8D=E3=80=91EmmeLua?= =?UTF-8?q?=E6=94=B9=E4=B8=BAEmmyLua?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Source/Defs/TTypeTemplateCommonExtends.cs | 4 ++-- ...eLuaCommentTypeVisitor.cs => EmmyLuaCommentTypeVisitor.cs} | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename src/Luban.Job.Common/Source/TypeVisitors/{EmmeLuaCommentTypeVisitor.cs => EmmyLuaCommentTypeVisitor.cs} (93%) diff --git a/src/Luban.Job.Common/Source/Defs/TTypeTemplateCommonExtends.cs b/src/Luban.Job.Common/Source/Defs/TTypeTemplateCommonExtends.cs index f7ed09a..9ac7816 100644 --- a/src/Luban.Job.Common/Source/Defs/TTypeTemplateCommonExtends.cs +++ b/src/Luban.Job.Common/Source/Defs/TTypeTemplateCommonExtends.cs @@ -101,9 +101,9 @@ namespace Luban.Job.Common.Defs return type.Apply(LuaCommentTypeVisitor.Ins); } - public static string EmmeLuaCommentType(TType type) + public static string EmmyLuaCommentType(TType type) { - return type.Apply(EmmeLuaCommentTypeVisitor.Ins); + return type.Apply(EmmyLuaCommentTypeVisitor.Ins); } public static string LuaSerializeWhileNil(string bufName, string fieldName, TType type) diff --git a/src/Luban.Job.Common/Source/TypeVisitors/EmmeLuaCommentTypeVisitor.cs b/src/Luban.Job.Common/Source/TypeVisitors/EmmyLuaCommentTypeVisitor.cs similarity index 93% rename from src/Luban.Job.Common/Source/TypeVisitors/EmmeLuaCommentTypeVisitor.cs rename to src/Luban.Job.Common/Source/TypeVisitors/EmmyLuaCommentTypeVisitor.cs index 1b0a661..4d27077 100644 --- a/src/Luban.Job.Common/Source/TypeVisitors/EmmeLuaCommentTypeVisitor.cs +++ b/src/Luban.Job.Common/Source/TypeVisitors/EmmyLuaCommentTypeVisitor.cs @@ -2,9 +2,9 @@ using Luban.Job.Common.Types; namespace Luban.Job.Common.TypeVisitors { - public class EmmeLuaCommentTypeVisitor : ITypeFuncVisitor + public class EmmyLuaCommentTypeVisitor : ITypeFuncVisitor { - public static EmmeLuaCommentTypeVisitor Ins { get; } = new EmmeLuaCommentTypeVisitor(); + public static EmmyLuaCommentTypeVisitor Ins { get; } = new EmmyLuaCommentTypeVisitor(); public string Accept(TBool type) { From 7d05f1fd4d5722200af68313901912e4d806d0f6 Mon Sep 17 00:00:00 2001 From: yxy Date: Thu, 3 Feb 2022 22:18:48 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91EmmyLua?= =?UTF-8?q?Type=E7=9A=84TBytes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Source/TypeVisitors/EmmyLuaCommentTypeVisitor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Luban.Job.Common/Source/TypeVisitors/EmmyLuaCommentTypeVisitor.cs b/src/Luban.Job.Common/Source/TypeVisitors/EmmyLuaCommentTypeVisitor.cs index 4d27077..d929342 100644 --- a/src/Luban.Job.Common/Source/TypeVisitors/EmmyLuaCommentTypeVisitor.cs +++ b/src/Luban.Job.Common/Source/TypeVisitors/EmmyLuaCommentTypeVisitor.cs @@ -68,7 +68,7 @@ namespace Luban.Job.Common.TypeVisitors public string Accept(TBytes type) { - return $"string"; + return "string"; } public string Accept(TText type)