【重构】重构cfg code生成,消除大量重复代码

main
walon 2021-11-27 15:23:42 +08:00
parent 28626d0cfd
commit bb534ef12e
39 changed files with 223 additions and 521 deletions

View File

@ -12,8 +12,12 @@ using System.Threading.Tasks;
namespace Luban.Job.Cfg.Generate
{
[Render("code_cpp_bin")]
class CppCodeBinRender : CodeRenderBase
class CppCodeBinRender : TemplateCodeRenderBase
{
protected override string CommonRenderTemplateDir => "cpp";
protected override string RenderTemplateDir => "cpp_bin";
public override void Render(GenContext ctx)
{
// 将所有 头文件定义 生成到一个文件
@ -96,41 +100,7 @@ namespace {ctx.TopModule}
}
}
public override string Render(DefEnum c)
{
return RenderUtil.RenderCppEnumClass(c);
}
public string RenderForwardDefine(DefBean b)
{
return $"{b.CppNamespaceBegin} class {b.Name}; {b.CppNamespaceEnd} ";
}
public override string Render(DefBean b)
{
var template = StringTemplateUtil.GetTemplate("config/cpp_bin/bean");
var result = template.RenderCode(b);
return result;
}
public override string Render(DefTable p)
{
var template = StringTemplateUtil.GetTemplate("config/cpp_bin/table");
var result = template.RenderCode(p);
return result;
}
public override string RenderService(string name, string module, List<DefTable> tables)
{
var template = StringTemplateUtil.GetTemplate("config/cpp_bin/tables");
var result = template.Render(new {
Name = name,
Tables = tables,
});
return result;
}
public string RenderStub(string topModule, List<DefTypeBase> types)
private string RenderStub(string topModule, List<DefTypeBase> types)
{
var template = StringTemplateUtil.GetTemplate("config/cpp_bin/stub");
return template.RenderCode(new {
@ -138,5 +108,11 @@ namespace {ctx.TopModule}
Types = types,
});
}
private string RenderForwardDefine(DefBean b)
{
return $"{b.CppNamespaceBegin} class {b.Name}; {b.CppNamespaceEnd} ";
}
}
}

View File

@ -6,32 +6,10 @@ using System.Collections.Generic;
namespace Luban.Job.Cfg.Generate
{
[Render("code_cpp_editor")]
class CppEditorRender : CodeRenderBase
class CppEditorRender : TemplateCodeRenderBase
{
protected override string CommonRenderTemplateDir => "cpp";
public override void Render(GenContext ctx)
{
}
public override string Render(DefEnum e)
{
return "// enum";
}
public override string Render(DefBean b)
{
return "// bean";
}
public override string Render(DefTable p)
{
return "// table";
}
public override string RenderService(string name, string module, List<DefTable> tables)
{
return "// service";
}
protected override string RenderTemplateDir => "cpp_editor_json";
}
}

View File

@ -6,31 +6,10 @@ using System.Collections.Generic;
namespace Luban.Job.Cfg.Generate
{
[Render("code_cs_bin")]
class CsCodeBinRender : CsCodeRenderBase
class CsCodeBinRender : TemplateCodeRenderBase
{
public override string Render(DefBean b)
{
var template = StringTemplateUtil.GetTemplate("config/cs_bin/bean");
var result = template.RenderCode(b);
return result;
}
protected override string CommonRenderTemplateDir => "cs";
public override string Render(DefTable p)
{
var template = StringTemplateUtil.GetTemplate("config/cs_bin/table");
var result = template.RenderCode(p);
return result;
}
public override string RenderService(string name, string module, List<DefTable> tables)
{
var template = StringTemplateUtil.GetTemplate("config/cs_bin/tables");
var result = template.RenderCode(new {
Name = name,
Namespace = module,
Tables = tables,
});
return result;
}
protected override string RenderTemplateDir => "cs_bin";
}
}

View File

@ -6,34 +6,10 @@ using System.Collections.Generic;
namespace Luban.Job.Cfg.Generate
{
[Render("code_cs_json")]
class CsCodeJsonRender : CsCodeRenderBase
class CsCodeJsonRender : TemplateCodeRenderBase
{
public override string Render(DefBean b)
{
var template = StringTemplateUtil.GetTemplate("config/cs_json/bean");
var result = template.RenderCode(b);
protected override string CommonRenderTemplateDir => "cs";
return result;
}
public override string Render(DefTable p)
{
var template = StringTemplateUtil.GetTemplate("config/cs_json/table");
var result = template.RenderCode(p);
return result;
}
public override string RenderService(string name, string module, List<DefTable> tables)
{
var template = StringTemplateUtil.GetTemplate("config/cs_json/tables");
var result = template.RenderCode(new {
Name = name,
Namespace = module,
Tables = tables,
});
return result;
}
protected override string RenderTemplateDir => "cs_json";
}
}

View File

@ -1,18 +0,0 @@
using Luban.Job.Common.Defs;
using Luban.Job.Common.Utils;
namespace Luban.Job.Cfg.Generate
{
abstract class CsCodeRenderBase : CodeRenderBase
{
public override void Render(GenContext ctx)
{
GenerateCodeScatter(ctx);
}
public override string Render(DefEnum e)
{
return RenderUtil.RenderCsEnumClass(e);
}
}
}

View File

@ -6,34 +6,10 @@ using System.Collections.Generic;
namespace Luban.Job.Cfg.Generate
{
[Render("code_cs_unity_json")]
class CsCodeUnityJsonRender : CsCodeRenderBase
class CsCodeUnityJsonRender : TemplateCodeRenderBase
{
public override string Render(DefBean b)
{
var template = StringTemplateUtil.GetTemplate("config/cs_unity_json/bean");
var result = template.RenderCode(b);
protected override string CommonRenderTemplateDir => "cs";
return result;
}
public override string Render(DefTable p)
{
var template = StringTemplateUtil.GetTemplate("config/cs_unity_json/table");
var result = template.RenderCode(p);
return result;
}
public override string RenderService(string name, string module, List<DefTable> tables)
{
var template = StringTemplateUtil.GetTemplate("config/cs_unity_json/tables");
var result = template.RenderCode(new {
Name = name,
Namespace = module,
Tables = tables,
});
return result;
}
protected override string RenderTemplateDir => "cs_unity_json";
}
}

View File

@ -9,16 +9,19 @@ using System.Threading.Tasks;
namespace Luban.Job.Cfg.Generate
{
[Render("code_cs_unity_editor")]
class CsEditorRender : CsCodeRenderBase
class CsEditorRender : TemplateCodeRenderBase
{
override protected string CommonRenderTemplateDir => "cs";
override protected string RenderTemplateDir => "cs_editor_json";
public override void Render(GenContext ctx)
{
var render = new CsEditorRender();
foreach (var c in ctx.Assembly.Types.Values)
{
ctx.Tasks.Add(Task.Run(() =>
{
var content = FileHeaderUtil.ConcatAutoGenerationHeader(render.RenderAny(c), ELanguage.CS);
var content = FileHeaderUtil.ConcatAutoGenerationHeader(RenderAny(c), ELanguage.CS);
var file = RenderFileUtil.GetDefTypePath(c.FullName, ELanguage.CS);
var md5 = CacheFileUtil.GenMd5AndAddCache(file, content);
ctx.GenCodeFilesInOutputCodeDir.Add(new FileInfo() { FilePath = file, MD5 = md5 });
@ -26,32 +29,6 @@ namespace Luban.Job.Cfg.Generate
}
}
public override string Render(DefBean b)
{
var template = StringTemplateUtil.GetTemplate("config/cs_editor_json/bean");
var result = template.Render(b);
return result;
}
public override string Render(DefTable p)
{
var template = StringTemplateUtil.GetTemplate("config/cs_editor_json/table");
var result = template.Render(p);
return result;
}
public override string RenderService(string name, string module, List<DefTable> tables)
{
var template = StringTemplateUtil.GetTemplate("config/cs_editor_json/tables");
var result = template.Render(new {
Name = name,
Namespace = module,
Tables = tables,
});
return result;
}
}
}

View File

@ -6,31 +6,10 @@ using System.Collections.Generic;
namespace Luban.Job.Cfg.Generate
{
[Render("code_go_bin")]
class GoCodeBinRender : GoCodeRenderBase
class GoCodeBinRender : TemplateCodeRenderBase
{
public override string Render(DefBean b)
{
var template = StringTemplateUtil.GetTemplate("config/go_bin/bean");
var result = template.RenderCode(b);
return result;
}
protected override string CommonRenderTemplateDir => "go";
public override string Render(DefTable p)
{
var template = StringTemplateUtil.GetTemplate("config/go_bin/table");
var result = template.RenderCode(p);
return result;
}
public override string RenderService(string name, string module, List<DefTable> tables)
{
var template = StringTemplateUtil.GetTemplate("config/go_bin/tables");
var result = template.Render(new {
Name = name,
Namespace = module,
Tables = tables,
});
return result;
}
protected override string RenderTemplateDir => "go_bin";
}
}

View File

@ -6,34 +6,10 @@ using System.Collections.Generic;
namespace Luban.Job.Cfg.Generate
{
[Render("code_go_json")]
class GoCodeJsonRender : GoCodeRenderBase
class GoCodeJsonRender : TemplateCodeRenderBase
{
public override string Render(DefBean b)
{
var template = StringTemplateUtil.GetTemplate("config/go_json/bean");
var result = template.RenderCode(b);
protected override string CommonRenderTemplateDir => "go";
return result;
}
public override string Render(DefTable p)
{
var template = StringTemplateUtil.GetTemplate("config/go_json/table");
var result = template.RenderCode(p);
return result;
}
public override string RenderService(string name, string module, List<DefTable> tables)
{
var template = StringTemplateUtil.GetTemplate("config/go_json/tables");
var result = template.Render(new {
Name = name,
Namespace = module,
Tables = tables,
});
return result;
}
protected override string RenderTemplateDir => "go_json";
}
}

View File

@ -1,23 +0,0 @@
using Luban.Job.Common.Defs;
using Luban.Job.Common.Utils;
using System.Collections.Generic;
namespace Luban.Job.Cfg.Generate
{
abstract class GoCodeRenderBase : CodeRenderBase
{
public override void Render(GenContext ctx)
{
GenerateCodeScatter(ctx);
}
public override string Render(DefEnum e)
{
string package = "cfg";
var template = StringTemplateUtil.GetTemplate("common/go/enum");
var result = template.RenderCode(e, new Dictionary<string, object>() { ["package"] = package });
return result;
}
}
}

View File

@ -6,34 +6,10 @@ using System.Collections.Generic;
namespace Luban.Job.Cfg.Generate
{
[Render("code_java_bin")]
class JavaCodeBinRender : JavaCodeRenderBase
class JavaCodeBinRender : TemplateCodeRenderBase
{
public override string Render(DefBean b)
{
var template = StringTemplateUtil.GetTemplate("config/java_bin/bean");
var result = template.RenderCode(b);
protected override string CommonRenderTemplateDir => "java";
return result;
}
public override string Render(DefTable p)
{
var template = StringTemplateUtil.GetTemplate("config/java_bin/table");
var result = template.RenderCode(p);
return result;
}
public override string RenderService(string name, string module, List<DefTable> tables)
{
var template = StringTemplateUtil.GetTemplate("config/java_bin/tables");
var result = template.Render(new {
Name = name,
Package = module,
Tables = tables,
});
return result;
}
protected override string RenderTemplateDir => "java_bin";
}
}

View File

@ -6,34 +6,10 @@ using System.Collections.Generic;
namespace Luban.Job.Cfg.Generate
{
[Render("code_java_json")]
class JavaCodeJsonRender : JavaCodeRenderBase
class JavaCodeJsonRender : TemplateCodeRenderBase
{
public override string Render(DefBean b)
{
var template = StringTemplateUtil.GetTemplate("config/java_json/bean");
var result = template.RenderCode(b);
protected override string CommonRenderTemplateDir => "java";
return result;
}
public override string Render(DefTable p)
{
var template = StringTemplateUtil.GetTemplate("config/java_json/table");
var result = template.RenderCode(p);
return result;
}
public override string RenderService(string name, string module, List<DefTable> tables)
{
var template = StringTemplateUtil.GetTemplate("config/java_json/tables");
var result = template.Render(new {
Name = name,
Package = module,
Tables = tables,
});
return result;
}
protected override string RenderTemplateDir => "java_json";
}
}

View File

@ -1,18 +0,0 @@
using Luban.Job.Common.Defs;
using Luban.Job.Common.Utils;
namespace Luban.Job.Cfg.Generate
{
abstract class JavaCodeRenderBase : CodeRenderBase
{
public override void Render(GenContext ctx)
{
GenerateCodeScatter(ctx);
}
public override string Render(DefEnum c)
{
return RenderUtil.RenderJavaEnumClass(c);
}
}
}

View File

@ -11,6 +11,8 @@ namespace Luban.Job.Cfg.Generate
[Render("code_lua_bin")]
class LuaCodeBinRender : LuaCodeRenderBase
{
protected override string RenderTemplateDir => "lua_bin";
public override string RenderAll(List<DefTypeBase> types)
{
var enums = types.Where(t => t is DefEnum).ToList();

View File

@ -12,6 +12,8 @@ namespace Luban.Job.Cfg.Generate
[Render("code_lua_lua")]
class LuaCodeLuaRender : LuaCodeRenderBase
{
protected override string RenderTemplateDir => "lua_lua";
[ThreadStatic]
private static Template t_allRender;

View File

@ -7,8 +7,10 @@ using System.Collections.Generic;
namespace Luban.Job.Cfg.Generate
{
abstract class LuaCodeRenderBase : CodeRenderBase
abstract class LuaCodeRenderBase : TemplateCodeRenderBase
{
protected override string CommonRenderTemplateDir => "lua";
public override void Render(GenContext ctx)
{
DefAssembly.LocalAssebmly.CurrentLanguage = Common.ELanguage.LUA;
@ -18,26 +20,6 @@ namespace Luban.Job.Cfg.Generate
ctx.GenCodeFilesInOutputCodeDir.Add(new FileInfo() { FilePath = file, MD5 = md5 });
}
public override string Render(DefEnum e)
{
throw new System.NotImplementedException();
}
public override string Render(DefTable c)
{
throw new System.NotImplementedException();
}
public override string Render(DefBean b)
{
throw new NotImplementedException();
}
public override string RenderService(string name, string module, List<DefTable> tables)
{
throw new System.NotImplementedException();
}
public abstract string RenderAll(List<DefTypeBase> types);
}
}

View File

@ -1,27 +1,33 @@
using Luban.Job.Cfg.Defs;
using Luban.Job.Common.Generate;
using Luban.Job.Common.Utils;
using System.Collections.Generic;
namespace Luban.Job.Cfg.Generate
{
[Render("code_python_json")]
[Render("code_python3_json")]
class Python3CodeJsonRender : PythonCodeRenderBase
class Python3CodeJsonRender : TemplateCodeRenderBase
{
public override string Render(DefBean b)
{
var template = StringTemplateUtil.GetTemplate("config/python_json/bean");
var result = template.RenderCode(b);
protected override string CommonRenderTemplateDir => "python";
return result;
protected override string RenderTemplateDir => "python_json";
public override void Render(GenContext ctx)
{
ctx.Render = this;
ctx.Lan = Common.ELanguage.PYTHON;
DefAssembly.LocalAssebmly.CurrentLanguage = ctx.Lan;
var lines = new List<string>(10000);
static void PreContent(List<string> fileContent)
{
//fileContent.Add(PythonStringTemplates.ImportTython3Enum);
//fileContent.Add(PythonStringTemplates.PythonVectorTypes);
fileContent.Add(StringTemplateUtil.GetTemplateString("config/python_json/include"));
}
public override string Render(DefTable p)
{
var template = StringTemplateUtil.GetTemplate("config/python_json/table");
var result = template.RenderCode(p);
return result;
GenerateCodeMonolithic(ctx, RenderFileUtil.GetFileOrDefault(ctx.GenArgs.OutputCodeMonolithicFile, "Types.py"), lines, PreContent, null);
}
}
}

View File

@ -1,44 +0,0 @@
using Luban.Job.Cfg.Defs;
using Luban.Job.Common.Defs;
using Luban.Job.Common.Utils;
using System.Collections.Generic;
namespace Luban.Job.Cfg.Generate
{
abstract class PythonCodeRenderBase : CodeRenderBase
{
public override void Render(GenContext ctx)
{
ctx.Render = this;
ctx.Lan = Common.ELanguage.PYTHON;
DefAssembly.LocalAssebmly.CurrentLanguage = ctx.Lan;
var lines = new List<string>(10000);
static void PreContent(List<string> fileContent)
{
//fileContent.Add(PythonStringTemplates.ImportTython3Enum);
//fileContent.Add(PythonStringTemplates.PythonVectorTypes);
fileContent.Add(StringTemplateUtil.GetTemplateString("config/python_json/include"));
}
GenerateCodeMonolithic(ctx, RenderFileUtil.GetFileOrDefault(ctx.GenArgs.OutputCodeMonolithicFile, "Types.py"), lines, PreContent, null);
}
public override string Render(DefEnum e)
{
return RenderUtil.RenderPythonEnumClass(e);
}
public override string RenderService(string name, string module, List<DefTable> tables)
{
var template = StringTemplateUtil.GetTemplate("config/python_json/tables");
var result = template.RenderCode(new {
Name = name,
Namespace = module,
Tables = tables,
});
return result;
}
}
}

View File

@ -11,8 +11,12 @@ using System.Threading.Tasks;
namespace Luban.Job.Cfg.Generate
{
[Render("code_rust_json")]
class RustCodeJsonRender : CodeRenderBase
class RustCodeJsonRender : TemplateCodeRenderBase
{
protected override string CommonRenderTemplateDir => "rust";
protected override string RenderTemplateDir => "rust_json";
public override void Render(GenContext ctx)
{
string genType = ctx.GenType;
@ -29,38 +33,5 @@ namespace Luban.Job.Cfg.Generate
ls.Add(result);
}, null);
}
public override string Render(DefEnum e)
{
return RenderUtil.RenderRustEnumClass(e);
}
public override string Render(DefBean b)
{
var template = StringTemplateUtil.GetTemplate("config/rust_json/bean");
var result = template.RenderCode(b);
return result;
}
public override string Render(DefTable p)
{
var template = StringTemplateUtil.GetTemplate("config/rust_json/table");
var result = template.RenderCode(p);
return result;
}
public override string RenderService(string name, string module, List<DefTable> tables)
{
var template = StringTemplateUtil.GetTemplate("config/rust_json/tables");
var result = template.RenderCode(new {
Name = name,
Namespace = module,
Tables = tables,
});
return result;
}
}
}

View File

@ -0,0 +1,56 @@
using Luban.Job.Cfg.Defs;
using Luban.Job.Common.Defs;
using Luban.Job.Common.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Luban.Job.Cfg.Generate
{
abstract class TemplateCodeRenderBase : CodeRenderBase
{
protected abstract string CommonRenderTemplateDir { get; }
protected abstract string RenderTemplateDir { get; }
public override void Render(GenContext ctx)
{
GenerateCodeScatter(ctx);
}
public override string Render(DefEnum e)
{
var template = StringTemplateUtil.GetTemplate($"common/{CommonRenderTemplateDir}/enum");
var result = template.RenderCode(e);
return result;
}
public override string Render(DefBean b)
{
var template = StringTemplateUtil.GetTemplate($"config/{RenderTemplateDir}/bean");
var result = template.RenderCode(b);
return result;
}
public override string Render(DefTable p)
{
var template = StringTemplateUtil.GetTemplate($"config/{RenderTemplateDir}/table");
var result = template.RenderCode(p);
return result;
}
public override string RenderService(string name, string module, List<DefTable> tables)
{
var template = StringTemplateUtil.GetTemplate($"config/{RenderTemplateDir}/tables");
var result = template.RenderCode(new {
Name = name,
Namespace = module,
Tables = tables,
});
return result;
}
}
}

View File

@ -8,32 +8,6 @@ namespace Luban.Job.Cfg.Generate
[Render("code_typescript_bin")]
class TypescriptCodeBinRender : TypescriptCodeRenderBase
{
public override string Render(DefBean b)
{
var template = StringTemplateUtil.GetTemplate("config/typescript_bin/bean");
var result = template.RenderCode(b);
return result;
}
public override string Render(DefTable p)
{
var template = StringTemplateUtil.GetTemplate("config/typescript_bin/table");
var result = template.RenderCode(p);
return result;
}
public override string RenderService(string name, string module, List<DefTable> tables)
{
var template = StringTemplateUtil.GetTemplate("config/typescript_bin/tables");
var result = template.RenderCode(new {
Name = name,
Namespace = module,
Tables = tables,
});
return result;
}
protected override string RenderTemplateDir => "typescript_bin";
}
}

View File

@ -8,32 +8,6 @@ namespace Luban.Job.Cfg.Generate
[Render("code_typescript_json")]
class TypescriptCodeJsonRender : TypescriptCodeRenderBase
{
public override string Render(DefBean b)
{
var template = StringTemplateUtil.GetTemplate("config/typescript_json/bean");
var result = template.RenderCode(b);
return result;
}
public override string Render(DefTable p)
{
var template = StringTemplateUtil.GetTemplate("config/typescript_json/table");
var result = template.RenderCode(p);
return result;
}
public override string RenderService(string name, string module, List<DefTable> tables)
{
var template = StringTemplateUtil.GetTemplate("config/typescript_json/tables");
var result = template.RenderCode(new {
Name = name,
Namespace = module,
Tables = tables,
});
return result;
}
protected override string RenderTemplateDir => "typescript_json";
}
}

View File

@ -6,8 +6,10 @@ using System.Collections.Generic;
namespace Luban.Job.Cfg.Generate
{
abstract class TypescriptCodeRenderBase : CodeRenderBase
abstract class TypescriptCodeRenderBase : TemplateCodeRenderBase
{
protected override string CommonRenderTemplateDir => "typescript";
public override void Render(GenContext ctx)
{
string genType = ctx.GenType;
@ -63,10 +65,5 @@ namespace Luban.Job.Cfg.Generate
GenerateCodeMonolithic(ctx, RenderFileUtil.GetFileOrDefault(ctx.GenArgs.OutputCodeMonolithicFile, "Types.ts"), lines, preContent, postContent);
}
public override string Render(DefEnum e)
{
return RenderUtil.RenderTypescriptEnumClass(e);
}
}
}

View File

@ -1,4 +1,11 @@
{{cpp_namespace_begin}}
{{~
name = x.name
namespace_with_top_module = x.namespace_with_top_module
comment = x.comment
items = x.items
~}}
{{x.cpp_namespace_begin}}
{{~if comment != '' ~}}
/**
* {{comment | html.escape}}
@ -15,4 +22,4 @@ enum class {{name}}
{{item.name}} = {{item.value}},
{{~end~}}
};
{{cpp_namespace_end}}
{{x.cpp_namespace_end}}

View File

@ -1,3 +1,9 @@
{{~
name = x.name
namespace_with_top_module = x.namespace_with_top_module
comment = x.comment
items = x.items
~}}
namespace {{namespace_with_top_module}}
{
@ -6,7 +12,7 @@ namespace {{namespace_with_top_module}}
/// {{comment | html.escape}}
/// </summary>
{{~end~}}
{{~if is_flags~}}
{{~if x.is_flags~}}
[System.Flags]
{{~end~}}
public enum {{name}}

View File

@ -1,7 +1,14 @@
{{~
name = x.name
namespace_with_top_module = x.namespace_with_top_module
comment = x.comment
items = x.items
~}}
package {{x.top_module}}
const (
{{~for item in x.items ~}}
{{~for item in items ~}}
{{x.go_full_name}}_{{item.name}} = {{item.int_value}}
{{~end~}}
)

View File

@ -1,3 +1,10 @@
{{~
name = x.name
namespace_with_top_module = x.namespace_with_top_module
comment = x.comment
items = x.items
~}}
package {{namespace_with_top_module}};
{{~if comment != '' ~}}
/**

View File

@ -1,9 +1,16 @@
{{~
name = x.name
namespace_with_top_module = x.namespace_with_top_module
comment = x.comment
items = x.items
~}}
{{~if comment != '' ~}}
'''
{{comment | html.escape}}
'''
{{~end~}}
class {{py_full_name}}(Enum):
class {{x.py_full_name}}(Enum):
{{~ for item in items ~}}
{{~if item.comment != '' ~}}
'''

View File

@ -1,3 +1,10 @@
{{~
name = x.name
namespace_with_top_module = x.namespace_with_top_module
comment = x.comment
items = x.items
~}}
{{~if comment != '' ~}}
/**
* {{comment | html.escape}}
@ -5,7 +12,7 @@
{{~end~}}
#[allow(dead_code)]
#[allow(non_camel_case_types)]
pub enum {{rust_full_name}} {
pub enum {{x.rust_full_name}} {
{{~for item in items ~}}
{{~if item.comment != '' ~}}
/**

View File

@ -1,4 +1,11 @@
{{typescript_namespace_begin}}
{{~
name = x.name
namespace_with_top_module = x.namespace_with_top_module
comment = x.comment
items = x.items
~}}
{{x.typescript_namespace_begin}}
{{~if comment != '' ~}}
/**
* {{comment | html.escape}}
@ -14,4 +21,4 @@ export enum {{name}} {
{{item.name}} = {{item.value}},
{{~end~}}
}
{{typescript_namespace_end}}
{{x.typescript_namespace_end}}

View File

@ -1,3 +1,7 @@
{{~
tables = x.tables
name = x.name
~}}
class {{name}}
{
public:

View File

@ -1,10 +1,10 @@
{{-
{{~
go_full_name = x.go_full_name
parent_def_type = x.parent_def_type
is_abstract_type = x.is_abstract_type
export_fields = x.export_fields
hierarchy_not_abstract_children = x.hierarchy_not_abstract_children
-}}
~}}
package {{x.top_module}}

View File

@ -1,4 +1,4 @@
{{-
{{~
go_full_name = x.go_full_name
key_type = x.key_ttype
key_type1 = x.key_ttype1
@ -7,7 +7,7 @@
index_field = x.index_field
index_field1 = x.index_field1
index_field2 = x.index_field2
-}}
~}}
package {{x.top_module}}

View File

@ -1,3 +1,8 @@
{{~
name = x.name
namespace = x.namespace
tables = x.tables
~}}
package {{namespace}}

View File

@ -1,10 +1,10 @@
{{-
{{~
go_full_name = x.go_full_name
parent_def_type = x.parent_def_type
is_abstract_type = x.is_abstract_type
export_fields = x.export_fields
hierarchy_not_abstract_children = x.hierarchy_not_abstract_children
-}}
~}}
package {{x.top_module}}

View File

@ -1,4 +1,4 @@
{{-
{{~
go_full_name = x.go_full_name
key_type = x.key_ttype
key_type1 = x.key_ttype1
@ -7,7 +7,7 @@
index_field = x.index_field
index_field1 = x.index_field1
index_field2 = x.index_field2
-}}
~}}
package {{x.top_module}}

View File

@ -1,3 +1,8 @@
{{~
name = x.name
namespace = x.namespace
tables = x.tables
~}}
package {{namespace}}

View File

@ -1,4 +1,9 @@
package {{package}};
{{~
name = x.name
namespace = x.namespace
tables = x.tables
~}}
package {{namespace}};
import bright.serialization.*;

View File

@ -1,4 +1,9 @@
package {{package}};
{{~
name = x.name
namespace = x.namespace
tables = x.tables
~}}
package {{namespace}};
import com.google.gson.JsonElement;