【重构】将python_json生成代码中import和vector定义部分移到 include.tpl,方便定制
parent
e9f608a238
commit
8c02821fd8
|
|
@ -16,8 +16,9 @@ namespace Luban.Job.Cfg.Generate
|
|||
var lines = new List<string>(10000);
|
||||
static void PreContent(List<string> fileContent)
|
||||
{
|
||||
fileContent.Add(PythonStringTemplates.ImportTython3Enum);
|
||||
fileContent.Add(PythonStringTemplates.PythonVectorTypes);
|
||||
//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);
|
||||
|
|
@ -31,8 +32,7 @@ namespace Luban.Job.Cfg.Generate
|
|||
public override string RenderService(string name, string module, List<DefTable> tables)
|
||||
{
|
||||
var template = StringTemplateUtil.GetTemplate("config/python_json/tables");
|
||||
var result = template.RenderCode(new
|
||||
{
|
||||
var result = template.RenderCode(new {
|
||||
Name = name,
|
||||
Namespace = module,
|
||||
Tables = tables,
|
||||
|
|
|
|||
|
|
@ -167,6 +167,9 @@
|
|||
<None Update="Templates\config\python_json\bean.tpl">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Templates\config\python_json\include.tpl">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Templates\config\python_json\table.tpl">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
namespace Luban.Job.Common.Utils
|
||||
{
|
||||
public class PythonStringTemplates
|
||||
{
|
||||
public const string PythonVectorTypes = @"
|
||||
from enum import Enum
|
||||
import abc
|
||||
|
||||
class Vector2:
|
||||
def __init__(self, x, y):
|
||||
self.x = x
|
||||
|
|
@ -54,11 +52,3 @@ class Vector4:
|
|||
raise Exception()
|
||||
return Vector4(x, y, z, w)
|
||||
|
||||
";
|
||||
|
||||
public const string ImportTython3Enum = @"
|
||||
from enum import Enum
|
||||
import abc
|
||||
";
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue