【调整】移除cfg,proto,db对const定义的支持
parent
f90fa41d57
commit
0a5d7b6ab4
|
|
@ -55,7 +55,6 @@ namespace Luban.Job.Cfg.Defs
|
||||||
{
|
{
|
||||||
TopModule = TopModule,
|
TopModule = TopModule,
|
||||||
Patches = _patches,
|
Patches = _patches,
|
||||||
Consts = this._consts,
|
|
||||||
Enums = _enums,
|
Enums = _enums,
|
||||||
Beans = _beans,
|
Beans = _beans,
|
||||||
Tables = _cfgTables,
|
Tables = _cfgTables,
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ namespace Luban.Job.Cfg.Defs
|
||||||
}
|
}
|
||||||
foreach ((var fullTypeName, var type) in this.Types)
|
foreach ((var fullTypeName, var type) in this.Types)
|
||||||
{
|
{
|
||||||
if (!refTypes.ContainsKey(fullTypeName) && (type is DefConst || type is DefEnum))
|
if (!refTypes.ContainsKey(fullTypeName) && (type is DefEnum))
|
||||||
{
|
{
|
||||||
refTypes.Add(fullTypeName, type);
|
refTypes.Add(fullTypeName, type);
|
||||||
}
|
}
|
||||||
|
|
@ -195,11 +195,6 @@ namespace Luban.Job.Cfg.Defs
|
||||||
|
|
||||||
this._patches.AddRange(defines.Patches);
|
this._patches.AddRange(defines.Patches);
|
||||||
|
|
||||||
foreach (var c in defines.Consts)
|
|
||||||
{
|
|
||||||
AddType(new DefConst(c));
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var e in defines.Enums)
|
foreach (var e in defines.Enums)
|
||||||
{
|
{
|
||||||
AddType(new DefEnum(e));
|
AddType(new DefEnum(e));
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ namespace Luban.Job.Cfg.Generate
|
||||||
public abstract void Render(GenContext ctx);
|
public abstract void Render(GenContext ctx);
|
||||||
|
|
||||||
|
|
||||||
public abstract string Render(DefConst c);
|
|
||||||
public abstract string Render(DefEnum c);
|
public abstract string Render(DefEnum c);
|
||||||
public abstract string Render(DefBean b);
|
public abstract string Render(DefBean b);
|
||||||
public abstract string Render(DefTable c);
|
public abstract string Render(DefTable c);
|
||||||
|
|
@ -23,7 +22,6 @@ namespace Luban.Job.Cfg.Generate
|
||||||
{
|
{
|
||||||
switch (o)
|
switch (o)
|
||||||
{
|
{
|
||||||
case DefConst c: return Render(c);
|
|
||||||
case DefEnum e: return Render(e);
|
case DefEnum e: return Render(e);
|
||||||
case DefBean b: return Render(b);
|
case DefBean b: return Render(b);
|
||||||
case DefTable r: return Render(r);
|
case DefTable r: return Render(r);
|
||||||
|
|
|
||||||
|
|
@ -44,14 +44,6 @@ namespace {ctx.TopModule}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var type in ctx.ExportTypes)
|
|
||||||
{
|
|
||||||
if (type is DefConst c)
|
|
||||||
{
|
|
||||||
headerFileContent.Add(Render(c));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var type in ctx.ExportTypes)
|
foreach (var type in ctx.ExportTypes)
|
||||||
{
|
{
|
||||||
if (type is DefBean e)
|
if (type is DefBean e)
|
||||||
|
|
@ -103,11 +95,6 @@ namespace {ctx.TopModule}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Render(DefConst c)
|
|
||||||
{
|
|
||||||
return RenderUtil.RenderCppConstClass(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string Render(DefEnum c)
|
public override string Render(DefEnum c)
|
||||||
{
|
{
|
||||||
return RenderUtil.RenderCppEnumClass(c);
|
return RenderUtil.RenderCppEnumClass(c);
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,6 @@ namespace Luban.Job.Cfg.Generate
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Render(DefConst c)
|
|
||||||
{
|
|
||||||
return "// const";
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string Render(DefEnum e)
|
public override string Render(DefEnum e)
|
||||||
{
|
{
|
||||||
return "// enum";
|
return "// enum";
|
||||||
|
|
|
||||||
|
|
@ -101,11 +101,6 @@ public:
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Render(DefConst c)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string Render(DefTable c)
|
public override string Render(DefTable c)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|
|
||||||
|
|
@ -261,11 +261,6 @@ bool {{type.ue_fname}}FromString(const FString& s, {{type.ue_fname}}& value)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Render(DefConst c)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string Render(DefTable c)
|
public override string Render(DefTable c)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,6 @@ namespace Luban.Job.Cfg.Generate
|
||||||
GenerateCodeScatter(ctx);
|
GenerateCodeScatter(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Render(DefConst c)
|
|
||||||
{
|
|
||||||
return RenderUtil.RenderCsConstClass(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string Render(DefEnum e)
|
public override string Render(DefEnum e)
|
||||||
{
|
{
|
||||||
return RenderUtil.RenderCsEnumClass(e);
|
return RenderUtil.RenderCsEnumClass(e);
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,6 @@ namespace Luban.Job.Cfg.Generate
|
||||||
GenerateCodeScatter(ctx);
|
GenerateCodeScatter(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Render(DefConst c)
|
|
||||||
{
|
|
||||||
string package = "cfg";
|
|
||||||
var template = StringTemplateUtil.GetTemplate("common/go/const");
|
|
||||||
var result = template.RenderCode(c, new Dictionary<string, object>() { ["package"] = package });
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string Render(DefEnum e)
|
public override string Render(DefEnum e)
|
||||||
{
|
{
|
||||||
string package = "cfg";
|
string package = "cfg";
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,6 @@ namespace Luban.Job.Cfg.Generate
|
||||||
GenerateCodeScatter(ctx);
|
GenerateCodeScatter(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Render(DefConst c)
|
|
||||||
{
|
|
||||||
return RenderUtil.RenderJavaConstClass(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string Render(DefEnum c)
|
public override string Render(DefEnum c)
|
||||||
{
|
{
|
||||||
return RenderUtil.RenderJavaEnumClass(c);
|
return RenderUtil.RenderJavaEnumClass(c);
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,13 @@ namespace Luban.Job.Cfg.Generate
|
||||||
{
|
{
|
||||||
public override string RenderAll(List<DefTypeBase> types)
|
public override string RenderAll(List<DefTypeBase> types)
|
||||||
{
|
{
|
||||||
var consts = types.Where(t => t is DefConst).ToList();
|
|
||||||
var enums = types.Where(t => t is DefEnum).ToList();
|
var enums = types.Where(t => t is DefEnum).ToList();
|
||||||
var beans = types.Where(t => t is DefBean).ToList();
|
var beans = types.Where(t => t is DefBean).ToList();
|
||||||
var tables = types.Where(t => t is DefTable).ToList();
|
var tables = types.Where(t => t is DefTable).ToList();
|
||||||
var template = StringTemplateUtil.GetOrAddTemplate("common/lua/base_all", fn =>
|
var template = StringTemplateUtil.GetOrAddTemplate("common/lua/base_all", fn =>
|
||||||
Template.Parse(StringTemplateUtil.GetTemplateString("common/lua/base")
|
Template.Parse(StringTemplateUtil.GetTemplateString("common/lua/base")
|
||||||
+ StringTemplateUtil.GetTemplateString("config/lua_bin/all")));
|
+ StringTemplateUtil.GetTemplateString("config/lua_bin/all")));
|
||||||
return template.RenderCode(new { Consts = consts, Enums = enums, Beans = beans, Tables = tables });
|
return template.RenderCode(new { Enums = enums, Beans = beans, Tables = tables });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,12 @@ namespace Luban.Job.Cfg.Generate
|
||||||
|
|
||||||
public override string RenderAll(List<DefTypeBase> types)
|
public override string RenderAll(List<DefTypeBase> types)
|
||||||
{
|
{
|
||||||
var consts = types.Where(t => t is DefConst).ToList();
|
|
||||||
var enums = types.Where(t => t is DefEnum).ToList();
|
var enums = types.Where(t => t is DefEnum).ToList();
|
||||||
var beans = types.Where(t => t is DefBean).ToList();
|
var beans = types.Where(t => t is DefBean).ToList();
|
||||||
var tables = types.Where(t => t is DefTable).ToList();
|
var tables = types.Where(t => t is DefTable).ToList();
|
||||||
var template = t_allRender ??= Template.Parse(StringTemplateUtil.GetTemplateString("common/lua/base")
|
var template = t_allRender ??= Template.Parse(StringTemplateUtil.GetTemplateString("common/lua/base")
|
||||||
+ StringTemplateUtil.GetTemplateString("config/lua_lua/all"));
|
+ StringTemplateUtil.GetTemplateString("config/lua_lua/all"));
|
||||||
return template.RenderCode(new { Consts = consts, Enums = enums, Beans = beans, Tables = tables });
|
return template.RenderCode(new { Enums = enums, Beans = beans, Tables = tables });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,6 @@ namespace Luban.Job.Cfg.Generate
|
||||||
ctx.GenCodeFilesInOutputCodeDir.Add(new FileInfo() { FilePath = file, MD5 = md5 });
|
ctx.GenCodeFilesInOutputCodeDir.Add(new FileInfo() { FilePath = file, MD5 = md5 });
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Render(DefConst c)
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string Render(DefEnum e)
|
public override string Render(DefEnum e)
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,6 @@ namespace Luban.Job.Cfg.Generate
|
||||||
GenerateCodeMonolithic(ctx, "Types.py", lines, PreContent, null);
|
GenerateCodeMonolithic(ctx, "Types.py", lines, PreContent, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Render(DefConst c)
|
|
||||||
{
|
|
||||||
return RenderUtil.RenderPythonConstClass(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string Render(DefEnum e)
|
public override string Render(DefEnum e)
|
||||||
{
|
{
|
||||||
return RenderUtil.RenderPythonEnumClass(e);
|
return RenderUtil.RenderPythonEnumClass(e);
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,6 @@ namespace Luban.Job.Cfg.Generate
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Render(DefConst c)
|
|
||||||
{
|
|
||||||
return RenderUtil.RenderRustConstClass(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string Render(DefEnum e)
|
public override string Render(DefEnum e)
|
||||||
{
|
{
|
||||||
return RenderUtil.RenderRustEnumClass(e);
|
return RenderUtil.RenderRustEnumClass(e);
|
||||||
|
|
|
||||||
|
|
@ -62,11 +62,6 @@ namespace Luban.Job.Cfg.Generate
|
||||||
GenerateCodeMonolithic(ctx, "Types.ts", lines, preContent, postContent);
|
GenerateCodeMonolithic(ctx, "Types.ts", lines, preContent, postContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Render(DefConst c)
|
|
||||||
{
|
|
||||||
return RenderUtil.RenderTypescriptConstClass(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string Render(DefEnum e)
|
public override string Render(DefEnum e)
|
||||||
{
|
{
|
||||||
return RenderUtil.RenderTypescriptEnumClass(e);
|
return RenderUtil.RenderTypescriptEnumClass(e);
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,6 @@ namespace Luban.Job.Cfg.RawDefs
|
||||||
|
|
||||||
public List<Bean> Beans { get; set; } = new List<Bean>();
|
public List<Bean> Beans { get; set; } = new List<Bean>();
|
||||||
|
|
||||||
public List<Const> Consts { get; set; } = new List<Const>();
|
|
||||||
|
|
||||||
public List<PEnum> Enums { get; set; } = new List<PEnum>();
|
public List<PEnum> Enums { get; set; } = new List<PEnum>();
|
||||||
|
|
||||||
public List<Table> Tables { get; set; } = new List<Table>();
|
public List<Table> Tables { get; set; } = new List<Table>();
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,6 @@ namespace Luban.Job.Common.Defs
|
||||||
|
|
||||||
protected string TopModule { get; private set; }
|
protected string TopModule { get; private set; }
|
||||||
|
|
||||||
protected readonly List<Const> _consts = new List<Const>();
|
|
||||||
protected readonly List<PEnum> _enums = new List<PEnum>();
|
protected readonly List<PEnum> _enums = new List<PEnum>();
|
||||||
protected readonly List<Bean> _beans = new List<Bean>();
|
protected readonly List<Bean> _beans = new List<Bean>();
|
||||||
|
|
||||||
|
|
@ -58,7 +57,6 @@ namespace Luban.Job.Common.Defs
|
||||||
_rootDefineHandlers.Add("topmodule", SetTopModule);
|
_rootDefineHandlers.Add("topmodule", SetTopModule);
|
||||||
|
|
||||||
_moduleDefineHandlers.Add("module", AddModule);
|
_moduleDefineHandlers.Add("module", AddModule);
|
||||||
_moduleDefineHandlers.Add("const", AddConst);
|
|
||||||
_moduleDefineHandlers.Add("enum", AddEnum);
|
_moduleDefineHandlers.Add("enum", AddEnum);
|
||||||
_moduleDefineHandlers.Add("bean", AddBean);
|
_moduleDefineHandlers.Add("bean", AddBean);
|
||||||
}
|
}
|
||||||
|
|
@ -294,37 +292,6 @@ namespace Luban.Job.Common.Defs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static readonly List<string> _constRequiredAttrs = new List<string> { "name" };
|
|
||||||
private static readonly List<string> _constOptionalAttrs = new List<string> { "comment" };
|
|
||||||
|
|
||||||
private static readonly List<string> _constItemRequiredAttrs = new List<string> { "name", "type" };
|
|
||||||
private static readonly List<string> _constItemOptionalAttrs = new List<string> { "value", "comment" };
|
|
||||||
|
|
||||||
protected void AddConst(string defineFile, XElement e)
|
|
||||||
{
|
|
||||||
ValidAttrKeys(defineFile, e, _constOptionalAttrs, _constRequiredAttrs);
|
|
||||||
var c = new Const()
|
|
||||||
{
|
|
||||||
Name = XmlUtil.GetRequiredAttribute(e, "name"),
|
|
||||||
Namespace = CurNamespace,
|
|
||||||
Comment = XmlUtil.GetOptionalAttribute(e, "comment"),
|
|
||||||
};
|
|
||||||
foreach (XElement item in e.Elements())
|
|
||||||
{
|
|
||||||
ValidAttrKeys(defineFile, item, _constItemOptionalAttrs, _constItemRequiredAttrs);
|
|
||||||
c.Items.Add(new ConstItem()
|
|
||||||
{
|
|
||||||
Name = XmlUtil.GetRequiredAttribute(item, "name"),
|
|
||||||
Type = CreateType(item, "type"),
|
|
||||||
Value = XmlUtil.GetRequiredAttribute(item, "value"),
|
|
||||||
Comment = XmlUtil.GetOptionalAttribute(item, "comment"),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
s_logger.Trace("add const {@const}", c);
|
|
||||||
_consts.Add(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static readonly List<string> _enumOptionalAttrs = new List<string> { "flags", "comment", "tags" };
|
private static readonly List<string> _enumOptionalAttrs = new List<string> { "flags", "comment", "tags" };
|
||||||
private static readonly List<string> _enumRequiredAttrs = new List<string> { "name" };
|
private static readonly List<string> _enumRequiredAttrs = new List<string> { "name" };
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,63 +0,0 @@
|
||||||
using Luban.Job.Common.RawDefs;
|
|
||||||
using Luban.Job.Common.Types;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Luban.Job.Common.Defs
|
|
||||||
{
|
|
||||||
public class DefConst : DefTypeBase
|
|
||||||
{
|
|
||||||
public class Item
|
|
||||||
{
|
|
||||||
public string Name { get; set; }
|
|
||||||
|
|
||||||
public string Type { get; set; }
|
|
||||||
|
|
||||||
public string Value { get; set; }
|
|
||||||
|
|
||||||
public TType CType { get; set; }
|
|
||||||
|
|
||||||
public string Comment { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Item> Items { get; set; } = new List<Item>();
|
|
||||||
|
|
||||||
public DefConst(Const c)
|
|
||||||
{
|
|
||||||
Namespace = c.Namespace;
|
|
||||||
Name = c.Name;
|
|
||||||
Comment = c.Comment;
|
|
||||||
|
|
||||||
foreach (var item in c.Items)
|
|
||||||
{
|
|
||||||
Items.Add(new Item { Name = item.Name, Type = item.Type, Value = item.Value, Comment = item.Comment });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Compile()
|
|
||||||
{
|
|
||||||
HashSet<string> names = new HashSet<string>();
|
|
||||||
|
|
||||||
foreach (var item in Items)
|
|
||||||
{
|
|
||||||
if (item.Name.Length == 0)
|
|
||||||
{
|
|
||||||
throw new Exception($"'{FullName}' 常量字段名不能为空");
|
|
||||||
}
|
|
||||||
if (!names.Add(item.Name))
|
|
||||||
{
|
|
||||||
throw new Exception($"'{FullName}' 字段名:'{item.Name}' 重复");
|
|
||||||
}
|
|
||||||
if ((item.CType = AssemblyBase.CreateType(Namespace, item.Type)) == null)
|
|
||||||
{
|
|
||||||
throw new Exception($"'{FullName}' type:'{item.Type}' 类型不存在");
|
|
||||||
}
|
|
||||||
if (!item.CType.TryParseFrom(item.Value))
|
|
||||||
{
|
|
||||||
throw new Exception($"'{FullName}' value:'{item.Value}' 不是合法的 type:'{item.Type}' 类型值");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -7,8 +7,6 @@ namespace Luban.Job.Common.Generate
|
||||||
{
|
{
|
||||||
string RenderAny(DefTypeBase o);
|
string RenderAny(DefTypeBase o);
|
||||||
|
|
||||||
string Render(DefConst c);
|
|
||||||
|
|
||||||
string Render(DefEnum c);
|
string Render(DefEnum c);
|
||||||
|
|
||||||
string RenderService(string name, string module, List<T> tables);
|
string RenderService(string name, string module, List<T> tables);
|
||||||
|
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Luban.Job.Common.RawDefs
|
|
||||||
{
|
|
||||||
public class ConstItem
|
|
||||||
{
|
|
||||||
public string Name { get; set; }
|
|
||||||
|
|
||||||
public string Type { get; set; }
|
|
||||||
|
|
||||||
public string Value { get; set; }
|
|
||||||
|
|
||||||
public string Comment { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Const
|
|
||||||
{
|
|
||||||
|
|
||||||
public string Namespace { get; set; }
|
|
||||||
|
|
||||||
public string Name { get; set; }
|
|
||||||
|
|
||||||
public string Comment { get; set; }
|
|
||||||
|
|
||||||
public List<ConstItem> Items { get; set; } = new List<ConstItem>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -5,21 +5,6 @@ namespace Luban.Job.Common.Utils
|
||||||
{
|
{
|
||||||
public static class RenderUtil
|
public static class RenderUtil
|
||||||
{
|
{
|
||||||
public static string RenderCsConstClass(DefConst c)
|
|
||||||
{
|
|
||||||
var ctx = new TemplateContext();
|
|
||||||
var env = new TTypeTemplateCommonExtends
|
|
||||||
{
|
|
||||||
["x"] = c
|
|
||||||
};
|
|
||||||
ctx.PushGlobal(env);
|
|
||||||
|
|
||||||
var template = StringTemplateUtil.GetTemplate("common/cs/const");
|
|
||||||
var result = template.Render(ctx);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string RenderCsEnumClass(DefEnum e)
|
public static string RenderCsEnumClass(DefEnum e)
|
||||||
{
|
{
|
||||||
var template = StringTemplateUtil.GetTemplate("common/cs/enum");
|
var template = StringTemplateUtil.GetTemplate("common/cs/enum");
|
||||||
|
|
@ -28,22 +13,6 @@ namespace Luban.Job.Common.Utils
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string RenderJavaConstClass(DefConst c)
|
|
||||||
{
|
|
||||||
var ctx = new TemplateContext();
|
|
||||||
var env = new TTypeTemplateCommonExtends
|
|
||||||
{
|
|
||||||
["x"] = c
|
|
||||||
};
|
|
||||||
ctx.PushGlobal(env);
|
|
||||||
|
|
||||||
|
|
||||||
var template = StringTemplateUtil.GetTemplate("common/java/const");
|
|
||||||
var result = template.Render(ctx);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string RenderJavaEnumClass(DefEnum e)
|
public static string RenderJavaEnumClass(DefEnum e)
|
||||||
{
|
{
|
||||||
var template = StringTemplateUtil.GetTemplate("common/java/enum");
|
var template = StringTemplateUtil.GetTemplate("common/java/enum");
|
||||||
|
|
@ -52,21 +21,6 @@ namespace Luban.Job.Common.Utils
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string RenderCppConstClass(DefConst c)
|
|
||||||
{
|
|
||||||
var ctx = new TemplateContext();
|
|
||||||
var env = new TTypeTemplateCommonExtends
|
|
||||||
{
|
|
||||||
["x"] = c
|
|
||||||
};
|
|
||||||
ctx.PushGlobal(env);
|
|
||||||
|
|
||||||
|
|
||||||
var template = StringTemplateUtil.GetTemplate("common/cpp/const");
|
|
||||||
var result = template.Render(ctx);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string RenderCppEnumClass(DefEnum e)
|
public static string RenderCppEnumClass(DefEnum e)
|
||||||
{
|
{
|
||||||
var template = StringTemplateUtil.GetTemplate("common/cpp/enum");
|
var template = StringTemplateUtil.GetTemplate("common/cpp/enum");
|
||||||
|
|
@ -74,22 +28,6 @@ namespace Luban.Job.Common.Utils
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string RenderPythonConstClass(DefConst c)
|
|
||||||
{
|
|
||||||
var ctx = new TemplateContext();
|
|
||||||
var env = new TTypeTemplateCommonExtends
|
|
||||||
{
|
|
||||||
["x"] = c
|
|
||||||
};
|
|
||||||
ctx.PushGlobal(env);
|
|
||||||
|
|
||||||
|
|
||||||
var template = StringTemplateUtil.GetTemplate("common/python/const");
|
|
||||||
var result = template.Render(ctx);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string RenderPythonEnumClass(DefEnum e)
|
public static string RenderPythonEnumClass(DefEnum e)
|
||||||
{
|
{
|
||||||
var template = StringTemplateUtil.GetTemplate("common/python/enum");
|
var template = StringTemplateUtil.GetTemplate("common/python/enum");
|
||||||
|
|
@ -98,22 +36,6 @@ namespace Luban.Job.Common.Utils
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string RenderTypescriptConstClass(DefConst c)
|
|
||||||
{
|
|
||||||
var ctx = new TemplateContext();
|
|
||||||
var env = new TTypeTemplateCommonExtends
|
|
||||||
{
|
|
||||||
["x"] = c
|
|
||||||
};
|
|
||||||
ctx.PushGlobal(env);
|
|
||||||
|
|
||||||
|
|
||||||
var template = StringTemplateUtil.GetTemplate("common/typescript/const");
|
|
||||||
var result = template.Render(ctx);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string RenderTypescriptEnumClass(DefEnum e)
|
public static string RenderTypescriptEnumClass(DefEnum e)
|
||||||
{
|
{
|
||||||
var template = StringTemplateUtil.GetTemplate("common/typescript/enum");
|
var template = StringTemplateUtil.GetTemplate("common/typescript/enum");
|
||||||
|
|
@ -121,19 +43,6 @@ namespace Luban.Job.Common.Utils
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string RenderRustConstClass(DefConst c)
|
|
||||||
{
|
|
||||||
var ctx = new TemplateContext();
|
|
||||||
var env = new TTypeTemplateCommonExtends
|
|
||||||
{
|
|
||||||
["x"] = c
|
|
||||||
};
|
|
||||||
ctx.PushGlobal(env);
|
|
||||||
var template = StringTemplateUtil.GetTemplate("common/rust/const");
|
|
||||||
var result = template.Render(ctx);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string RenderRustEnumClass(DefEnum e)
|
public static string RenderRustEnumClass(DefEnum e)
|
||||||
{
|
{
|
||||||
var template = StringTemplateUtil.GetTemplate("common/rust/enum");
|
var template = StringTemplateUtil.GetTemplate("common/rust/enum");
|
||||||
|
|
|
||||||
|
|
@ -23,15 +23,12 @@ namespace Luban.Job.Db.Defs
|
||||||
return new Defines()
|
return new Defines()
|
||||||
{
|
{
|
||||||
TopModule = TopModule,
|
TopModule = TopModule,
|
||||||
Consts = _consts,
|
|
||||||
Enums = _enums,
|
Enums = _enums,
|
||||||
Beans = _beans,
|
Beans = _beans,
|
||||||
DbTables = _tables,
|
DbTables = _tables,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private readonly List<string> _tableOptionalAttrs = new List<string> { "memory", "comment" };
|
private readonly List<string> _tableOptionalAttrs = new List<string> { "memory", "comment" };
|
||||||
private readonly List<string> _tableRequireAttrs = new List<string> { "name", "id", "key", "value" };
|
private readonly List<string> _tableRequireAttrs = new List<string> { "name", "id", "key", "value" };
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,12 +34,6 @@ namespace Luban.Job.Db.Defs
|
||||||
this.Agent = agent;
|
this.Agent = agent;
|
||||||
TopModule = defines.TopModule;
|
TopModule = defines.TopModule;
|
||||||
|
|
||||||
|
|
||||||
foreach (var c in defines.Consts)
|
|
||||||
{
|
|
||||||
AddType(new DefConst(c));
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var e in defines.Enums)
|
foreach (var e in defines.Enums)
|
||||||
{
|
{
|
||||||
AddType(new DefEnum(e));
|
AddType(new DefEnum(e));
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ namespace Luban.Job.Db.Generate
|
||||||
{
|
{
|
||||||
switch (o)
|
switch (o)
|
||||||
{
|
{
|
||||||
case DefConst c: return Render(c);
|
|
||||||
case DefEnum e: return Render(e);
|
case DefEnum e: return Render(e);
|
||||||
case DefBean b: return Render(b);
|
case DefBean b: return Render(b);
|
||||||
case DefTable p: return Render(p);
|
case DefTable p: return Render(p);
|
||||||
|
|
@ -20,11 +19,6 @@ namespace Luban.Job.Db.Generate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Render(DefConst c)
|
|
||||||
{
|
|
||||||
return RenderUtil.RenderCsConstClass(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Render(DefEnum e)
|
public string Render(DefEnum e)
|
||||||
{
|
{
|
||||||
return RenderUtil.RenderCsEnumClass(e);
|
return RenderUtil.RenderCsEnumClass(e);
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ namespace Luban.Job.Db.Generate
|
||||||
{
|
{
|
||||||
switch (o)
|
switch (o)
|
||||||
{
|
{
|
||||||
case DefConst c: return Render(c);
|
|
||||||
case DefEnum e: return Render(e);
|
case DefEnum e: return Render(e);
|
||||||
case DefBean b: return Render(b);
|
case DefBean b: return Render(b);
|
||||||
case DefTable p: return Render(p);
|
case DefTable p: return Render(p);
|
||||||
|
|
@ -20,11 +19,6 @@ namespace Luban.Job.Db.Generate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Render(DefConst c)
|
|
||||||
{
|
|
||||||
return RenderUtil.RenderCsConstClass(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Render(DefEnum e)
|
public string Render(DefEnum e)
|
||||||
{
|
{
|
||||||
return RenderUtil.RenderCsEnumClass(e);
|
return RenderUtil.RenderCsEnumClass(e);
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ namespace Luban.Job.Db.Generate
|
||||||
{
|
{
|
||||||
switch (o)
|
switch (o)
|
||||||
{
|
{
|
||||||
case DefConst c: return Render(c);
|
|
||||||
case DefEnum e: return Render(e);
|
case DefEnum e: return Render(e);
|
||||||
case DefBean b: return Render(b);
|
case DefBean b: return Render(b);
|
||||||
case DefTable r: return Render(r);
|
case DefTable r: return Render(r);
|
||||||
|
|
@ -20,11 +19,6 @@ namespace Luban.Job.Db.Generate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string Render(DefConst c)
|
|
||||||
{
|
|
||||||
return RenderUtil.RenderTypescriptConstClass(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
private string Render(DefEnum e)
|
private string Render(DefEnum e)
|
||||||
{
|
{
|
||||||
return RenderUtil.RenderTypescriptEnumClass(e);
|
return RenderUtil.RenderTypescriptEnumClass(e);
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,6 @@ namespace Luban.Job.Db.RawDefs
|
||||||
|
|
||||||
public List<Bean> Beans { get; set; } = new List<Bean>();
|
public List<Bean> Beans { get; set; } = new List<Bean>();
|
||||||
|
|
||||||
public List<Const> Consts { get; set; } = new List<Const>();
|
|
||||||
|
|
||||||
public List<PEnum> Enums { get; set; } = new List<PEnum>();
|
public List<PEnum> Enums { get; set; } = new List<PEnum>();
|
||||||
|
|
||||||
public List<Table> DbTables { get; set; } = new List<Table>();
|
public List<Table> DbTables { get; set; } = new List<Table>();
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,6 @@ namespace Luban.Job.Proto.Defs
|
||||||
this.Agent = agent;
|
this.Agent = agent;
|
||||||
TopModule = defines.TopModule;
|
TopModule = defines.TopModule;
|
||||||
|
|
||||||
foreach (var c in defines.Consts)
|
|
||||||
{
|
|
||||||
AddType(new DefConst(c));
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var e in defines.Enums)
|
foreach (var e in defines.Enums)
|
||||||
{
|
{
|
||||||
AddType(new DefEnum(e));
|
AddType(new DefEnum(e));
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ namespace Luban.Job.Proto.Defs
|
||||||
return new Defines()
|
return new Defines()
|
||||||
{
|
{
|
||||||
TopModule = TopModule,
|
TopModule = TopModule,
|
||||||
Consts = _consts,
|
|
||||||
Enums = _enums,
|
Enums = _enums,
|
||||||
Beans = _beans,
|
Beans = _beans,
|
||||||
Protos = _protos,
|
Protos = _protos,
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ namespace Luban.Job.Proto.Generate
|
||||||
{
|
{
|
||||||
switch (o)
|
switch (o)
|
||||||
{
|
{
|
||||||
case DefConst c: return Render(c);
|
|
||||||
case DefEnum e: return Render(e);
|
case DefEnum e: return Render(e);
|
||||||
case DefBean b: return Render(b);
|
case DefBean b: return Render(b);
|
||||||
case DefProto p: return Render(p);
|
case DefProto p: return Render(p);
|
||||||
|
|
@ -22,11 +21,6 @@ namespace Luban.Job.Proto.Generate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string Render(DefConst c)
|
|
||||||
{
|
|
||||||
return RenderUtil.RenderCsConstClass(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
private string Render(DefEnum e)
|
private string Render(DefEnum e)
|
||||||
{
|
{
|
||||||
return RenderUtil.RenderCsEnumClass(e);
|
return RenderUtil.RenderCsEnumClass(e);
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,12 @@ namespace Luban.Job.Proto.Generate
|
||||||
{
|
{
|
||||||
public string RenderTypes(List<DefTypeBase> types)
|
public string RenderTypes(List<DefTypeBase> types)
|
||||||
{
|
{
|
||||||
var consts = types.Where(t => t is DefConst).ToList();
|
|
||||||
var enums = types.Where(t => t is DefEnum).ToList();
|
var enums = types.Where(t => t is DefEnum).ToList();
|
||||||
var beans = types.Where(t => t is DefBean).ToList();
|
var beans = types.Where(t => t is DefBean).ToList();
|
||||||
var protos = types.Where(t => t is DefProto).ToList();
|
var protos = types.Where(t => t is DefProto).ToList();
|
||||||
var rpcs = types.Where(t => t is DefRpc).ToList();
|
var rpcs = types.Where(t => t is DefRpc).ToList();
|
||||||
var template = StringTemplateUtil.GetTemplate("proto/lua/all");
|
var template = StringTemplateUtil.GetTemplate("proto/lua/all");
|
||||||
return template.RenderCode(new { Consts = consts, Enums = enums, Beans = beans, Protos = protos, Rpcs = rpcs });
|
return template.RenderCode(new { Enums = enums, Beans = beans, Protos = protos, Rpcs = rpcs });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ namespace Luban.Job.Proto.Generate
|
||||||
{
|
{
|
||||||
switch (o)
|
switch (o)
|
||||||
{
|
{
|
||||||
case DefConst c: return Render(c);
|
|
||||||
case DefEnum e: return Render(e);
|
case DefEnum e: return Render(e);
|
||||||
case DefBean b: return Render(b);
|
case DefBean b: return Render(b);
|
||||||
case DefProto p: return Render(p);
|
case DefProto p: return Render(p);
|
||||||
|
|
@ -22,11 +21,6 @@ namespace Luban.Job.Proto.Generate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string Render(DefConst c)
|
|
||||||
{
|
|
||||||
return RenderUtil.RenderTypescriptConstClass(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
private string Render(DefEnum e)
|
private string Render(DefEnum e)
|
||||||
{
|
{
|
||||||
return RenderUtil.RenderTypescriptEnumClass(e);
|
return RenderUtil.RenderTypescriptEnumClass(e);
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,6 @@ namespace Luban.Job.Proto.RawDefs
|
||||||
|
|
||||||
public List<Bean> Beans { get; set; } = new List<Bean>();
|
public List<Bean> Beans { get; set; } = new List<Bean>();
|
||||||
|
|
||||||
public List<Const> Consts { get; set; } = new List<Const>();
|
|
||||||
|
|
||||||
public List<PEnum> Enums { get; set; } = new List<PEnum>();
|
public List<PEnum> Enums { get; set; } = new List<PEnum>();
|
||||||
|
|
||||||
public List<PProto> Protos { get; set; } = new List<PProto>();
|
public List<PProto> Protos { get; set; } = new List<PProto>();
|
||||||
|
|
|
||||||
|
|
@ -34,48 +34,27 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Update="Templates\common\cpp\const.tpl">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="Templates\common\cpp\enum.tpl">
|
<None Update="Templates\common\cpp\enum.tpl">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Templates\common\cs\const.tpl">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="Templates\common\cs\enum.tpl">
|
<None Update="Templates\common\cs\enum.tpl">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Templates\common\go\const.tpl">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="Templates\common\go\enum.tpl">
|
<None Update="Templates\common\go\enum.tpl">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Templates\common\java\const.tpl">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="Templates\common\java\enum.tpl">
|
<None Update="Templates\common\java\enum.tpl">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Templates\common\lua\base.tpl">
|
<None Update="Templates\common\lua\base.tpl">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Templates\common\python\const.tpl">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="Templates\common\python\enum.tpl">
|
<None Update="Templates\common\python\enum.tpl">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Templates\common\rust\const.tpl">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="Templates\common\rust\enum.tpl">
|
<None Update="Templates\common\rust\enum.tpl">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Templates\common\typescript\const.tpl">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="Templates\common\typescript\enum.tpl">
|
<None Update="Templates\common\typescript\enum.tpl">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
|
|
||||||
{{x.cpp_namespace_begin}}
|
|
||||||
{{~if comment != '' ~}}
|
|
||||||
/**
|
|
||||||
* {{comment}}
|
|
||||||
*/
|
|
||||||
{{~end~}}
|
|
||||||
struct {{x.name}}
|
|
||||||
{
|
|
||||||
{{~ for item in x.items ~}}
|
|
||||||
{{~if item.comment != '' ~}}
|
|
||||||
/**
|
|
||||||
* {{item.comment}}
|
|
||||||
*/
|
|
||||||
{{~end~}}
|
|
||||||
static constexpr {{cpp_define_type item.ctype}} {{item.name}} = {{cpp_const_value item.ctype item.value}};
|
|
||||||
{{~end~}}
|
|
||||||
};
|
|
||||||
{{x.cpp_namespace_end}}
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
|
|
||||||
namespace {{x.namespace_with_top_module}}
|
|
||||||
{
|
|
||||||
{{~if x.comment != '' ~}}
|
|
||||||
/// <summary>
|
|
||||||
/// {{x.comment}}
|
|
||||||
/// </summary>
|
|
||||||
{{~end~}}
|
|
||||||
public sealed class {{x.name}}
|
|
||||||
{
|
|
||||||
{{~ for item in x.items ~}}
|
|
||||||
{{~if item.comment != '' ~}}
|
|
||||||
/// <summary>
|
|
||||||
/// {{item.comment}}
|
|
||||||
/// </summary>
|
|
||||||
{{~end~}}
|
|
||||||
public const {{cs_define_type item.ctype}} {{item.name}} = {{cs_const_value item.ctype item.value}};
|
|
||||||
{{~end~}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
package {{package}}
|
|
||||||
|
|
||||||
const (
|
|
||||||
{{~for item in x.items ~}}
|
|
||||||
{{x.go_full_name}}_{{item.name}} = {{go_const_value item.ctype item.value}}
|
|
||||||
{{~end~}}
|
|
||||||
)
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
|
|
||||||
package {{x.namespace_with_top_module}};
|
|
||||||
|
|
||||||
{{~if x.comment != '' ~}}
|
|
||||||
/**
|
|
||||||
* {{x.comment}}
|
|
||||||
*/
|
|
||||||
{{~end~}}
|
|
||||||
public final class {{x.name}} {
|
|
||||||
{{~ for item in x.items ~}}
|
|
||||||
{{~if item.comment != '' ~}}
|
|
||||||
/**
|
|
||||||
* {{item.comment}}
|
|
||||||
*/
|
|
||||||
{{~end~}}
|
|
||||||
public static final {{java_define_type item.ctype}} {{item.name}} = {{java_const_value item.ctype item.value}};
|
|
||||||
{{~end~}}
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
{{
|
{{
|
||||||
consts = x.consts
|
|
||||||
enums = x.enums
|
enums = x.enums
|
||||||
beans = x.beans
|
beans = x.beans
|
||||||
tables = x.tables
|
tables = x.tables
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
{{~if x.comment != '' ~}}
|
|
||||||
'''
|
|
||||||
{{x.comment}}
|
|
||||||
'''
|
|
||||||
{{~end~}}
|
|
||||||
class {{x.py_full_name}}:
|
|
||||||
{{~ for item in x.items ~}}
|
|
||||||
{{~if item.comment != '' ~}}
|
|
||||||
'''
|
|
||||||
{{item.comment}}
|
|
||||||
'''
|
|
||||||
{{~end~}}
|
|
||||||
{{item.name}} = {{py_const_value item.ctype item.value}}
|
|
||||||
{{~end~}}
|
|
||||||
{{~if (x.items == empty)~}}
|
|
||||||
pass
|
|
||||||
{{~end~}}
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
{{~if x.comment != '' ~}}
|
|
||||||
/**
|
|
||||||
* {{x.comment}}
|
|
||||||
*/
|
|
||||||
{{~end~}}
|
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
pub mod {{x.rust_full_name}} {
|
|
||||||
{{~ for item in x.items ~}}
|
|
||||||
{{~if item.comment != '' ~}}
|
|
||||||
/**
|
|
||||||
* {{item.comment}}
|
|
||||||
*/
|
|
||||||
{{~end~}}
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub const {{string.upcase item.name}}: {{rust_define_type item.ctype}} = {{rust_const_value item.ctype item.value}};
|
|
||||||
{{~end~}}
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
{{x.typescript_namespace_begin}}
|
|
||||||
{{~if x.comment != '' ~}}
|
|
||||||
/**
|
|
||||||
* {{x.comment}}
|
|
||||||
*/
|
|
||||||
{{~end~}}
|
|
||||||
export class {{x.name}} {
|
|
||||||
{{~ for item in x.items ~}}
|
|
||||||
{{~if item.comment != '' ~}}
|
|
||||||
/**
|
|
||||||
* {{item.comment}}
|
|
||||||
*/
|
|
||||||
{{~end~}}
|
|
||||||
static {{item.name}} = {{ts_const_value item.ctype item.value}};
|
|
||||||
{{~end~}}
|
|
||||||
}
|
|
||||||
{{x.typescript_namespace_end}}
|
|
||||||
|
|
@ -1,13 +1,3 @@
|
||||||
local consts =
|
|
||||||
{
|
|
||||||
{{~ for c in consts ~}}
|
|
||||||
---@class {{c.full_name}}
|
|
||||||
{{~ for item in c.items ~}}
|
|
||||||
---@field public {{item.name}} {{item.type}}
|
|
||||||
{{~end~}}
|
|
||||||
['{{c.full_name}}'] = { {{ for item in c.items }} {{item.name}}={{lua_const_value item.ctype item.value}}, {{end}} };
|
|
||||||
{{~end~}}
|
|
||||||
}
|
|
||||||
|
|
||||||
local enums =
|
local enums =
|
||||||
{
|
{
|
||||||
|
|
@ -129,7 +119,7 @@ local function InitTypes(methods)
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
return { consts = consts, enums = enums, beans = beans, tables = tables }
|
return { enums = enums, beans = beans, tables = tables }
|
||||||
end
|
end
|
||||||
|
|
||||||
return { InitTypes = InitTypes }
|
return { InitTypes = InitTypes }
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,3 @@
|
||||||
local consts =
|
|
||||||
{
|
|
||||||
{{~ for c in consts ~}}
|
|
||||||
---@class {{c.full_name}}
|
|
||||||
{{~ for item in c.items ~}}
|
|
||||||
---@field public {{item.name}} {{item.type}}
|
|
||||||
{{~end~}}
|
|
||||||
['{{c.full_name}}'] = { {{ for item in c.items }} {{item.name}}={{lua_const_value item.ctype item.value}}, {{end}} };
|
|
||||||
{{~end~}}
|
|
||||||
}
|
|
||||||
|
|
||||||
local enums =
|
local enums =
|
||||||
{
|
{
|
||||||
{{~ for c in enums ~}}
|
{{~ for c in enums ~}}
|
||||||
|
|
@ -46,4 +35,4 @@ local tables =
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { consts = consts, enums = enums, beans = beans, tables = tables }
|
return { enums = enums, beans = beans, tables = tables }
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
{{
|
{{
|
||||||
consts = x.consts
|
|
||||||
enums = x.enums
|
enums = x.enums
|
||||||
beans = x.beans
|
beans = x.beans
|
||||||
protos = x.protos
|
protos = x.protos
|
||||||
|
|
@ -21,7 +20,6 @@ local function SimpleClass()
|
||||||
return class
|
return class
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function get_map_size(m)
|
local function get_map_size(m)
|
||||||
local n = 0
|
local n = 0
|
||||||
for _ in pairs(m) do
|
for _ in pairs(m) do
|
||||||
|
|
@ -30,17 +28,6 @@ local function get_map_size(m)
|
||||||
return n
|
return n
|
||||||
end
|
end
|
||||||
|
|
||||||
local consts =
|
|
||||||
{
|
|
||||||
{{~ for c in consts ~}}
|
|
||||||
---@class {{c.full_name}}
|
|
||||||
{{~ for item in c.items ~}}
|
|
||||||
---@field public {{item.name}} {{item.type}}
|
|
||||||
{{~end~}}
|
|
||||||
['{{c.full_name}}'] = { {{ for item in c.items }} {{item.name}}={{lua_const_value item.ctype item.value}}, {{end}} };
|
|
||||||
{{~end~}}
|
|
||||||
}
|
|
||||||
|
|
||||||
local enums =
|
local enums =
|
||||||
{
|
{
|
||||||
{{~ for c in enums ~}}
|
{{~ for c in enums ~}}
|
||||||
|
|
@ -252,7 +239,7 @@ local function InitTypes(methods)
|
||||||
end
|
end
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
return { consts = consts, enums = enums, beans = beans, protos = protos }
|
return { enums = enums, beans = beans, protos = protos }
|
||||||
end
|
end
|
||||||
|
|
||||||
return { InitTypes = InitTypes}
|
return { InitTypes = InitTypes}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue