【重构】将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);
|
var lines = new List<string>(10000);
|
||||||
static void PreContent(List<string> fileContent)
|
static void PreContent(List<string> fileContent)
|
||||||
{
|
{
|
||||||
fileContent.Add(PythonStringTemplates.ImportTython3Enum);
|
//fileContent.Add(PythonStringTemplates.ImportTython3Enum);
|
||||||
fileContent.Add(PythonStringTemplates.PythonVectorTypes);
|
//fileContent.Add(PythonStringTemplates.PythonVectorTypes);
|
||||||
|
fileContent.Add(StringTemplateUtil.GetTemplateString("config/python_json/include"));
|
||||||
}
|
}
|
||||||
|
|
||||||
GenerateCodeMonolithic(ctx, RenderFileUtil.GetFileOrDefault(ctx.GenArgs.OutputCodeMonolithicFile, "Types.py"), lines, PreContent, null);
|
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)
|
public override string RenderService(string name, string module, List<DefTable> tables)
|
||||||
{
|
{
|
||||||
var template = StringTemplateUtil.GetTemplate("config/python_json/tables");
|
var template = StringTemplateUtil.GetTemplate("config/python_json/tables");
|
||||||
var result = template.RenderCode(new
|
var result = template.RenderCode(new {
|
||||||
{
|
|
||||||
Name = name,
|
Name = name,
|
||||||
Namespace = module,
|
Namespace = module,
|
||||||
Tables = tables,
|
Tables = tables,
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,9 @@
|
||||||
<None Update="Templates\config\python_json\bean.tpl">
|
<None Update="Templates\config\python_json\bean.tpl">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="Templates\config\python_json\include.tpl">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<None Update="Templates\config\python_json\table.tpl">
|
<None Update="Templates\config\python_json\table.tpl">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
namespace Luban.Job.Common.Utils
|
from enum import Enum
|
||||||
{
|
import abc
|
||||||
public class PythonStringTemplates
|
|
||||||
{
|
|
||||||
public const string PythonVectorTypes = @"
|
|
||||||
class Vector2:
|
class Vector2:
|
||||||
def __init__(self, x, y):
|
def __init__(self, x, y):
|
||||||
self.x = x
|
self.x = x
|
||||||
|
|
@ -54,11 +52,3 @@ class Vector4:
|
||||||
raise Exception()
|
raise Exception()
|
||||||
return Vector4(x, y, z, w)
|
return Vector4(x, y, z, w)
|
||||||
|
|
||||||
";
|
|
||||||
|
|
||||||
public const string ImportTython3Enum = @"
|
|
||||||
from enum import Enum
|
|
||||||
import abc
|
|
||||||
";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue