From 45f4a13dd261b1a08f9e9bfbfe5d41522cd149df Mon Sep 17 00:00:00 2001 From: walon Date: Thu, 10 Feb 2022 12:47:15 +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=E5=BD=93=E6=84=8F=E5=A4=96=E4=BD=BF=E7=94=A8bean?= =?UTF-8?q?=E6=88=96=E5=AE=B9=E5=99=A8=E7=AD=89=E4=B8=8D=E8=83=BD=E4=BD=9C?= =?UTF-8?q?=E4=B8=BAindex=E7=B1=BB=E5=9E=8B=E7=9A=84=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E4=B8=BAtable=E7=9A=84index=E6=97=B6=EF=BC=8C=E6=89=93?= =?UTF-8?q?=E5=8D=B0=E7=9A=84=E9=94=99=E8=AF=AF=E6=97=A5=E5=BF=97=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E6=8A=A5=E5=91=8A=E6=AD=A3=E7=A1=AE=E7=9A=84=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E4=BF=A1=E6=81=AF=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=82=E5=9C=A8DefTable=20Compile=E6=97=B6=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E5=B9=B6=E4=B8=94=E7=BB=99=E5=87=BA=E6=B8=85=E6=99=B0=E7=9A=84?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 ++-- src/Luban.Job.Cfg/Source/Defs/DefTable.cs | 16 ++++++++ .../Source/TypeVisitors/IsMultiData.cs | 41 ------------------- ...sitor.cs => IsValidTableKeyTypeVisitor.cs} | 6 +-- 4 files changed, 23 insertions(+), 48 deletions(-) delete mode 100644 src/Luban.Job.Cfg/Source/TypeVisitors/IsMultiData.cs rename src/Luban.Job.Cfg/Source/TypeVisitors/{IsNotSepTypeVisitor.cs => IsValidTableKeyTypeVisitor.cs} (86%) diff --git a/README.md b/README.md index 509d007..c7525e8 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ luban统一了游戏配置开发工作流,极大提升了策划和程序的工 ##type int - array,int + (array#sep=;),int list,int (list#sep=|),string list,string @@ -97,7 +97,7 @@ luban统一了游戏配置开发工作流,极大提升了策划和程序的工 1 -1,2,3 +1;2;3 12 xx|yy xxxzzz @@ -115,7 +115,7 @@ luban统一了游戏配置开发工作流,极大提升了策划和程序的工 3 -2|4|6 +2;4;6 3456 aaaa|bbbb|cccc aaabbbccc @@ -372,7 +372,7 @@ Reward为包含 "int item_id; int count; string desc; " 这三个字段的子结 - + diff --git a/src/Luban.Job.Cfg/Source/Defs/DefTable.cs b/src/Luban.Job.Cfg/Source/Defs/DefTable.cs index 6d1a6df..2d2c48e 100644 --- a/src/Luban.Job.Cfg/Source/Defs/DefTable.cs +++ b/src/Luban.Job.Cfg/Source/Defs/DefTable.cs @@ -1,5 +1,6 @@ using Bright.Collections; using Luban.Job.Cfg.RawDefs; +using Luban.Job.Cfg.TypeVisitors; using Luban.Job.Common.Types; using Luban.Job.Common.Utils; using System; @@ -130,6 +131,7 @@ namespace Luban.Job.Cfg.Defs } KeyTType = IndexField.CType; Type = TMap.Create(false, null, KeyTType, ValueTType, false); + this.IndexList.Add(new IndexInfo(KeyTType, IndexField, IndexFieldIdIndex)); break; } case ETableMode.LIST: @@ -154,6 +156,20 @@ namespace Luban.Job.Cfg.Defs } default: throw new Exception($"unknown mode:'{Mode}'"); } + + foreach(var index in IndexList) + { + TType indexType = index.Type; + string idxName = index.IndexField.Name; + if (indexType.IsNullable) + { + throw new Exception($"table:'{FullName}' index:'{idxName}' 不能为 nullable类型"); + } + if (!indexType.Apply(IsValidTableKeyTypeVisitor.Ins)) + { + throw new Exception($"table:'{FullName}' index:'{idxName}' 的类型:'{index.IndexField.Type}' 不能作为index"); + } + } } } } diff --git a/src/Luban.Job.Cfg/Source/TypeVisitors/IsMultiData.cs b/src/Luban.Job.Cfg/Source/TypeVisitors/IsMultiData.cs deleted file mode 100644 index 9bc1e19..0000000 --- a/src/Luban.Job.Cfg/Source/TypeVisitors/IsMultiData.cs +++ /dev/null @@ -1,41 +0,0 @@ -using Luban.Job.Common.Types; -using Luban.Job.Common.TypeVisitors; - -namespace Luban.Job.Cfg.TypeVisitors -{ - class IsMultiData : AllFalseVisitor - { - public static IsMultiData Ins { get; } = new IsMultiData(); - - public override bool Accept(TBytes type) - { - return true; - } - - - public override bool Accept(TBean type) - { - return true; - } - - public override bool Accept(TArray type) - { - return true; - } - - public override bool Accept(TList type) - { - return true; - } - - public override bool Accept(TSet type) - { - return true; - } - - public override bool Accept(TMap type) - { - return true; - } - } -} diff --git a/src/Luban.Job.Cfg/Source/TypeVisitors/IsNotSepTypeVisitor.cs b/src/Luban.Job.Cfg/Source/TypeVisitors/IsValidTableKeyTypeVisitor.cs similarity index 86% rename from src/Luban.Job.Cfg/Source/TypeVisitors/IsNotSepTypeVisitor.cs rename to src/Luban.Job.Cfg/Source/TypeVisitors/IsValidTableKeyTypeVisitor.cs index 0e16d60..0d8e3bd 100644 --- a/src/Luban.Job.Cfg/Source/TypeVisitors/IsNotSepTypeVisitor.cs +++ b/src/Luban.Job.Cfg/Source/TypeVisitors/IsValidTableKeyTypeVisitor.cs @@ -3,11 +3,11 @@ using Luban.Job.Common.TypeVisitors; namespace Luban.Job.Cfg.TypeVisitors { - class IsNotSepTypeVisitor : AllTrueVisitor + class IsValidTableKeyTypeVisitor : AllTrueVisitor { - //public static IsNotSepTypeVisitor Ins { get; } = new IsNotSepTypeVisitor(); + public static IsValidTableKeyTypeVisitor Ins { get; } = new(); - public override bool Accept(TString type) + public override bool Accept(TText type) { return false; }
##var&column##var#column ##type ##