diff --git a/README.md b/README.md index 509d007..c7525e8 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ luban统一了游戏配置开发工作流,极大提升了策划和程序的工
| ##var&column | +##var#column | ##type | ## | 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; } |