diff --git a/src/Luban.Job.Cfg/Source/Generate/CppBinCodeRender.cs b/src/Luban.Job.Cfg/Source/Generate/CppBinCodeRender.cs index a0ea147..3e3fa67 100644 --- a/src/Luban.Job.Cfg/Source/Generate/CppBinCodeRender.cs +++ b/src/Luban.Job.Cfg/Source/Generate/CppBinCodeRender.cs @@ -53,9 +53,9 @@ class {{name}} : public {{if parent_def_type}} {{parent_def_type.cpp_full_name}} {{~if !hierarchy_export_fields.empty?~}} {{name}}({{- for field in hierarchy_export_fields }}{{cpp_define_type field.ctype}} {{field.name}}{{if !for.last}},{{end}} {{end}}) - {{-if parent_def_type-}} + {{~if parent_def_type~}} : {{parent_def_type.cpp_full_name}}({{ for field in parent_def_type.hierarchy_export_fields }}{{field.name}}{{if !for.last}}, {{end}}{{end}}) - {{-end-}} + {{~end~}} { {{~ for field in export_fields ~}} @@ -71,11 +71,11 @@ class {{name}} : public {{if parent_def_type}} {{parent_def_type.cpp_full_name}} {{cpp_define_type field.ctype}} {{field.cpp_style_name}}; {{~end~}} -{{if !x.is_abstract_type}} +{{~if !x.is_abstract_type~}} static constexpr int ID = {{x.id}}; int getTypeId() const { return ID; } -{{end}} +{{~end~}} }; @@ -154,7 +154,7 @@ class {{name}} {{cpp_define_type field.ctype}}& {{field.cpp_getter_name}}() const { return _data->{{field.cpp_style_name}}; } {{~end~}} - {{end}} + {{~end~}} }; {{x.cpp_namespace_end}} "); @@ -171,17 +171,17 @@ class {{name}} class {{name}} { public: - {{- for table in tables }} + {{~for table in tables ~}} {{table.cpp_full_name}} {{table.name}}; - {{-end}} + {{~end~}} bool load(std::function loader) { ByteBuf buf; - {{- for table in tables }} + {{~for table in tables~}} if (!loader(buf, ""{{table.output_data_file}}"")) return false; if (!{{table.name}}.load(buf)) return false; - {{-end}} + {{~end~}} return true; } }; @@ -228,17 +228,17 @@ namespace {{x.top_module}} bool {{type.cpp_full_name}}::deserialize{{type.name}}(ByteBuf& _buf, {{type.cpp_full_name}}*& _out) { - {{if type.is_abstract_type}} + {{~if type.is_abstract_type~}} int id; if (!_buf.readInt(id)) return false; switch (id) { - {{- for child in type.hierarchy_not_abstract_children}} + {{~for child in type.hierarchy_not_abstract_children~}} case {{child.cpp_full_name}}::ID: { _out = new {{child.cpp_full_name}}(); if (_out->deserialize(_buf)) { return true; } else { delete _out; _out = nullptr; return false;} } - {{-end}} + {{~end~}} default: { _out = nullptr; return false;} } - {{else}} + {{~else~}} _out = new {{type.cpp_full_name}}(); if (_out->deserialize(_buf)) { @@ -250,7 +250,7 @@ namespace {{x.top_module}} _out = nullptr; return false; } - {{end}} + {{~end~}} } {{~end~}} } diff --git a/src/Luban.Job.Cfg/Source/Generate/CsBinCodeRender.cs b/src/Luban.Job.Cfg/Source/Generate/CsBinCodeRender.cs index 9e2ecb9..f6cdeb5 100644 --- a/src/Luban.Job.Cfg/Source/Generate/CsBinCodeRender.cs +++ b/src/Luban.Job.Cfg/Source/Generate/CsBinCodeRender.cs @@ -56,17 +56,17 @@ public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} { public static {{name}} Deserialize{{name}}(ByteBuf _buf) { - {{if x.is_abstract_type}} + {{~if x.is_abstract_type~}} switch (_buf.ReadInt()) { - {{- for child in x.hierarchy_not_abstract_children}} + {{~for child in x.hierarchy_not_abstract_children~}} case {{child.full_name}}.ID: return new {{child.full_name}}(_buf); - {{-end}} + {{~end~}} default: throw new SerializationException(); } - {{else}} + {{~else~}} return new {{x.full_name}}(_buf); - {{end}} + {{~end~}} } {{~ for field in export_fields ~}} @@ -79,14 +79,16 @@ public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} { {{~end~}} {{~end~}} -{{if !x.is_abstract_type}} +{{~if !x.is_abstract_type~}} public const int ID = {{x.id}}; public override int GetTypeId() => ID; -{{end}} +{{~end~}} public {{x.cs_method_modifier}} void Resolve(Dictionary _tables) { - {{~if parent_def_type}}base.Resolve(_tables);{{end}} + {{~if parent_def_type~}} + base.Resolve(_tables); + {{~end~}} {{~ for field in export_fields ~}} {{~if field.gen_ref~}} {{cs_ref_validator_resolve field}} @@ -102,9 +104,9 @@ public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} { public override string ToString() { return ""{{full_name}}{ "" - {{- for field in hierarchy_export_fields }} + {{~for field in hierarchy_export_fields ~}} + ""{{field.cs_style_name}}:"" + {{cs_to_string field.cs_style_name field.ctype}} + "","" - {{-end}} + {{~end~}} + ""}""; } } @@ -199,7 +201,7 @@ public sealed partial class {{name}} OnResolveFinish(_tables); } - {{end}} + {{~end~}} partial void OnResolveFinish(Dictionary _tables); } @@ -229,21 +231,21 @@ namespace {{namespace}} public sealed class {{name}} { - {{- for table in tables }} + {{~for table in tables ~}} public {{table.full_name}} {{table.name}} {get; } - {{-end}} + {{~end~}} public {{name}}(System.Func loader) { var tables = new System.Collections.Generic.Dictionary(); - {{- for table in tables }} + {{~for table in tables ~}} {{table.name}} = new {{table.full_name}}(loader(""{{table.output_data_file}}"")); tables.Add(""{{table.full_name}}"", {{table.name}}); - {{-end}} + {{~end~}} - {{- for table in tables }} + {{~for table in tables ~}} {{table.name}}.Resolve(tables); - {{-end}} + {{~end~}} } } diff --git a/src/Luban.Job.Cfg/Source/Generate/CsJsonCodeRender.cs b/src/Luban.Job.Cfg/Source/Generate/CsJsonCodeRender.cs index eea989e..ccef599 100644 --- a/src/Luban.Job.Cfg/Source/Generate/CsJsonCodeRender.cs +++ b/src/Luban.Job.Cfg/Source/Generate/CsJsonCodeRender.cs @@ -39,7 +39,7 @@ public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} { {{~end~}} } - public {{name}}({{- for field in hierarchy_export_fields }}{{cs_define_type field.ctype}} {{field.name}}{{if !for.last}},{{end}} {{end}}) {{if parent_def_type}} : base({{- for field in parent_def_type.hierarchy_export_fields }}{{field.name}}{{if !for.last}},{{end}}{{end}}) {{end}} + public {{name}}({{~for field in hierarchy_export_fields }}{{cs_define_type field.ctype}} {{field.name}}{{if !for.last}},{{end}} {{end}}) {{if parent_def_type}} : base({{- for field in parent_def_type.hierarchy_export_fields }}{{field.name}}{{if !for.last}},{{end}}{{end}}) {{end}} { {{~ for field in export_fields ~}} this.{{field.cs_style_name}} = {{field.name}}; @@ -54,9 +54,9 @@ public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} { {{~if x.is_abstract_type~}} switch (_buf.GetProperty(""__type__"").GetString()) { - {{- for child in x.hierarchy_not_abstract_children}} + {{~for child in x.hierarchy_not_abstract_children~}} case ""{{child.name}}"": return new {{child.full_name}}(_buf); - {{-end}} + {{~end~}} default: throw new SerializationException(); } {{~else~}} @@ -195,7 +195,7 @@ public sealed partial class {{name}} OnResolveFinish(_tables); } - {{end}} + {{~end~}} partial void OnResolveFinish(Dictionary _tables); } @@ -225,21 +225,21 @@ namespace {{namespace}} public sealed partial class {{name}} { - {{- for table in tables }} + {{~for table in tables ~}} public {{table.full_name}} {{table.name}} {get; } - {{-end}} + {{~end~}} public {{name}}(System.Func loader) { var tables = new System.Collections.Generic.Dictionary(); - {{- for table in tables }} + {{~for table in tables ~}} {{table.name}} = new {{table.full_name}}(loader(""{{table.json_output_data_file}}"")); tables.Add(""{{table.full_name}}"", {{table.name}}); - {{-end}} + {{~end~}} - {{- for table in tables }} + {{~for table in tables ~}} {{table.name}}.Resolve(tables); - {{-end}} + {{~end~}} } } diff --git a/src/Luban.Job.Cfg/Source/Generate/EditorCsRender.cs b/src/Luban.Job.Cfg/Source/Generate/EditorCsRender.cs index adc55f2..4f08c18 100644 --- a/src/Luban.Job.Cfg/Source/Generate/EditorCsRender.cs +++ b/src/Luban.Job.Cfg/Source/Generate/EditorCsRender.cs @@ -51,12 +51,14 @@ public {{cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{parent}} public {{name}}(Bright.Common.NotNullInitialization _) {{if parent_def_type}} : base(_) {{end}} { - {{- for field in fields }} - {{if field.ctype.need_init}}{{field.proto_cs_init_field}} {{end}} - {{-end}} + {{~for field in fields ~}} + {{~if field.ctype.need_init~}} + {{field.proto_cs_init_field}} + {{~end~}} + {{~end~}} } - {{if is_abstract_type}} + {{~if is_abstract_type~}} public static void Serialize{{name}}(ByteBuf _buf, {{name}} x) { if (x == null) { _buf.WriteInt(0); return; } @@ -70,52 +72,56 @@ public {{cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{parent}} switch (_buf.ReadInt()) { case 0 : return null; - {{- for child in hierarchy_not_abstract_children}} + {{~for child in hierarchy_not_abstract_children~}} case {{child.full_name}}.ID: x = new {{child.full_name}}(false); break; - {{-end}} + {{~end~}} default: throw new SerializationException(); } x.Deserialize(_buf); return x; } - {{end}} - {{- for field in fields }} + {{~end~}} + {{~for field in fields ~}} public {{field.ctype.cs_define_type}} {{field.cs_style_name}}; - {{-end}} + {{~end~}} - {{if !parent_def_type && is_abstract_type}} - public abstract int GetTypeId(); - {{end}} - {{if parent_def_type && !is_abstract_type}} + {{~if !parent_def_type && is_abstract_type~}} + public abstract int GetTypeId(); + {{~end~}} + {{~if parent_def_type && !is_abstract_type~}} public const int ID = {{id}}; public override int GetTypeId() { return ID; } - {{end}} + {{~end~}} public {{cs_method_modifer}} void Serialize(ByteBuf _buf) { - {{if parent_def_type}} base.Serialize(_buf); {{end}} - {{- for field in fields }} + {{~if parent_def_type~}} + base.Serialize(_buf); + {{~end~}} + {{~for field in fields ~}} {{field.cs_serialize}} - {{-end}} + {{~end~}} } public {{cs_method_modifer}} void Deserialize(ByteBuf _buf) { - {{if parent_def_type}} base.Deserialize(_buf); {{end}} - {{- for field in fields }} + {{~if parent_def_type~}} + base.Deserialize(_buf); + {{~end~}} + {{~for field in fields ~}} {{field.cs_deserialize}} - {{-end}} + {{~end~}} } public override string ToString() { return ""{{full_name}}{ "" - {{- for field in hierarchy_fields }} + {{~for field in hierarchy_fields ~}} + ""{{field.cs_style_name}}:"" + {{field.proto_cs_to_string}} + "","" - {{-end}} + {{~end~}} + ""}""; } } @@ -140,17 +146,19 @@ namespace {{namespace}} public sealed class {{name}} : Bright.Net.Protocol { - {{- for field in fields }} + {{~for field in fields ~}} public {{field.ctype.cs_define_type}} {{field.cs_style_name}}; - {{-end}} + {{~end~}} public {{name}}() { } public {{name}}(Bright.Common.NotNullInitialization _) { - {{- for field in fields }} - {{if field.ctype.need_init}}{{field.proto_cs_init_field}} {{end}} - {{-end}} + {{~for field in fields ~}} + {{~if field.ctype.need_init~}} + {{field.proto_cs_init_field}} + {{~end~}} + {{~end~}} } public const int ID = {{id}}; @@ -161,16 +169,16 @@ public sealed class {{name}} : Bright.Net.Protocol public override void Serialize(ByteBuf _buf) { - {{- for field in fields }} + {{~for field in fields ~}} {{field.cs_serialize}} - {{-end}} + {{~end~}} } public override void Deserialize(ByteBuf _buf) { - {{- for field in fields }} + {{~for field in fields ~}} {{field.cs_deserialize}} - {{-end}} + {{~end~}} } public override void Reset() @@ -186,9 +194,9 @@ public sealed class {{name}} : Bright.Net.Protocol public override string ToString() { return ""{{full_name}}{ "" - {{- for field in fields }} + {{~for field in fields ~}} + ""{{field.cs_style_name}}:"" + {{field.proto_cs_to_string}} + "","" - {{-end}} + {{~end~}} + ""}""; } } @@ -215,9 +223,9 @@ public static class {{name}} { public static System.Collections.Generic.Dictionary Factories { get; } = new System.Collections.Generic.Dictionary { - {{- for proto in protos }} + {{~for proto in protos ~}} [{{proto.full_name}}.ID] = () => new {{proto.full_name}}(false), - {{-end}} + {{~end~}} }; } diff --git a/src/Luban.Job.Cfg/Source/Generate/GoCodeRender.cs b/src/Luban.Job.Cfg/Source/Generate/GoCodeRender.cs index 6d0b868..a024d70 100644 --- a/src/Luban.Job.Cfg/Source/Generate/GoCodeRender.cs +++ b/src/Luban.Job.Cfg/Source/Generate/GoCodeRender.cs @@ -31,9 +31,9 @@ namespace Luban.Job.Cfg.Generate package {{package}} const ( - {{- for item in x.items }} + {{~for item in x.items ~}} {{x.go_full_name}}_{{item.name}} = {{go_const_value item.ctype item.value}} - {{-end}} + {{~end~}} ) "); var result = template.RenderCode(c, new Dictionary() { ["package"] = package }); @@ -52,9 +52,9 @@ const ( package {{package}} const ( - {{- for item in x.items }} + {{~for item in x.items ~}} {{x.go_full_name}}_{{item.name}} = {{item.value}} - {{-end}} + {{~end~}} ) "); @@ -85,31 +85,33 @@ import ""bright/serialization"" {{x.go_import}} type {{go_full_name}} struct { - {{if parent_def_type}}{{parent_def_type.go_full_name}}{{end}} - {{- for field in export_fields }} + {{~if parent_def_type~}} + {{parent_def_type.go_full_name}} + {{~end~}} + {{~for field in export_fields ~}} {{field.cs_style_name}} {{go_define_type field.ctype}} - {{-end}} + {{~end~}} } -{{if !is_abstract_type}} +{{~if !is_abstract_type~}} func ({{go_full_name}}) GetTypeId() int { return {{x.id}} } -{{end}} +{{~end~}} func New{{go_full_name}}(_buf *serialization.ByteBuf) (_v *{{go_full_name}}, err error) { _v = &{{go_full_name}}{} -{{if parent_def_type}} +{{~if parent_def_type~}} var _p *{{parent_def_type.go_full_name}} if _p, err = New{{parent_def_type.go_full_name}}(_buf) ; err != nil { return } _v.{{parent_def_type.go_full_name}} = *_p -{{end}} - {{- for field in export_fields }} +{{~end~}} + {{~for field in export_fields ~}} {{go_deserialize_field field '_buf'}} - {{-end}} + {{~end~}} return } -{{if is_abstract_type}} +{{~if is_abstract_type~}} func NewChild{{go_full_name}}(_buf *serialization.ByteBuf) (_v interface{}, err error) { var id int32 if id, err = _buf.ReadInt() ; err != nil { @@ -117,13 +119,13 @@ func NewChild{{go_full_name}}(_buf *serialization.ByteBuf) (_v interface{}, err } switch id { case 0 : return nil, nil - {{- for child in hierarchy_not_abstract_children}} + {{~for child in hierarchy_not_abstract_children~}} case {{child.id}}: return New{{child.go_full_name}}(_buf); - {{-end}} + {{~end~}} } return } -{{end}} +{{~end~}} "); var result = template.RenderCode(b, new Dictionary() { ["package"] = package }); @@ -172,12 +174,12 @@ func New{{go_full_name}}(_buf *serialization.ByteBuf) (*{{go_full_name}}, error) } else { _dataList = append(_dataList, _v) {{~if value_type.is_dynamic ~}} - {{- for child in value_type.bean.hierarchy_not_abstract_children}} + {{~for child in value_type.bean.hierarchy_not_abstract_children~}} if __v, __is := _v.(*{{child.go_full_name}}) ; __is { dataMap[__v.{{index_field.cs_style_name}}] = _v continue } - {{-end}} + {{~end~}} {{~else~}} dataMap[_v.{{index_field.cs_style_name}}] = _v {{~end~}} @@ -200,7 +202,7 @@ func (table *{{go_full_name}}) Get(key {{go_define_type key_type}}) {{go_define_ } -{{else}} +{{~else~}} import ""errors"" @@ -226,7 +228,7 @@ func (table *{{go_full_name}}) Get() {{go_define_type value_type}} { return table._data } -{{end}} +{{~end~}} "); var result = template.RenderCode(p, new Dictionary() { ["package"] = package }); @@ -247,9 +249,9 @@ import ""bright/serialization"" type ByteBufLoader func(string) (*serialization.ByteBuf, error) type {{name}} struct { - {{- for table in tables }} + {{~for table in tables ~}} {{table.name}} *{{table.go_full_name}} - {{-end}} + {{~end~}} } func NewTables(loader ByteBufLoader) (*{{name}}, error) { @@ -257,14 +259,14 @@ func NewTables(loader ByteBufLoader) (*{{name}}, error) { var buf *serialization.ByteBuf tables := &{{name}}{} - {{- for table in tables }} + {{~for table in tables ~}} if buf, err = loader(""{{table.output_data_file}}"") ; err != nil { return nil, err } if tables.{{table.name}}, err = New{{table.go_full_name}}(buf) ; err != nil { return nil, err } - {{-end}} + {{~end~}} return tables, nil } diff --git a/src/Luban.Job.Cfg/Source/Generate/JavaBinCodeRender.cs b/src/Luban.Job.Cfg/Source/Generate/JavaBinCodeRender.cs index 2575495..4021d25 100644 --- a/src/Luban.Job.Cfg/Source/Generate/JavaBinCodeRender.cs +++ b/src/Luban.Job.Cfg/Source/Generate/JavaBinCodeRender.cs @@ -57,7 +57,7 @@ public {{x.java_class_modifier}} class {{name}} extends {{if parent_def_type}} { public {{name}}({{- for field in hierarchy_export_fields }}{{java_define_type field.ctype}} {{field.name}}{{if !for.last}},{{end}} {{end}}) { {{~if parent_def_type~}} - super({{ for field in parent_def_type.hierarchy_export_fields }}{{field.name}}{{if !for.last}}, {{end}}{{end}}); + super({{ for field in parent_def_type.hierarchy_export_fields }}{{field.name}}{{if !for.last}}, {{end}}{{end}}); {{~end~}} {{~ for field in export_fields ~}} this.{{field.java_style_name}} = {{field.name}}; @@ -72,36 +72,35 @@ public {{x.java_class_modifier}} class {{name}} extends {{if parent_def_type}} { public static {{name}} deserialize{{name}}(ByteBuf _buf) { - {{if x.is_abstract_type}} + {{~if x.is_abstract_type~}} switch (_buf.readInt()) { - case 0 : return null; - {{- for child in x.hierarchy_not_abstract_children}} + {{~for child in x.hierarchy_not_abstract_children~}} case {{child.full_name_with_top_module}}.ID: return new {{child.full_name_with_top_module}}(_buf); - {{-end}} + {{~end~}} default: throw new SerializationException(); } - {{else}} + {{~else~}} return new {{name}}(_buf); - {{end}} + {{~end~}} } {{~ for field in export_fields ~}} - public final {{java_define_type field.ctype}} {{field.java_style_name}}; + public final {{java_define_type field.ctype}} {{field.java_style_name}}; {{~if field.index_field~}} public final java.util.HashMap<{{java_box_define_type field.index_field.ctype}}, {{java_box_define_type field.ctype.element_type}}> {{field.java_style_name}}_Index = new java.util.HashMap<>(); {{~end~}} {{~if field.gen_ref~}} - public {{field.java_ref_validator_define}} + public {{field.java_ref_validator_define}} {{~end~}} {{~end~}} -{{if !x.is_abstract_type}} +{{~if !x.is_abstract_type~}} public static final int ID = {{x.id}}; @Override public int getTypeId() { return ID; } -{{end}} +{{~end~}} @Override public void serialize(ByteBuf os) @@ -117,7 +116,9 @@ public {{x.java_class_modifier}} class {{name}} extends {{if parent_def_type}} { public void resolve(java.util.HashMap _tables) { - {{~if parent_def_type}}super.resolve(_tables);{{end}} + {{~if parent_def_type~}} + super.resolve(_tables); + {{~end~}} {{~ for field in export_fields ~}} {{~if field.gen_ref~}} {{java_ref_validator_resolve field}} @@ -131,9 +132,9 @@ public {{x.java_class_modifier}} class {{name}} extends {{if parent_def_type}} { public String toString() { return ""{{full_name}}{ "" - {{- for field in hierarchy_export_fields }} + {{~for field in hierarchy_export_fields ~}} + ""{{field.java_style_name}}:"" + {{java_to_string field.java_style_name field.ctype}} + "","" - {{-end}} + {{~end~}} + ""}""; } } @@ -199,7 +200,7 @@ public final class {{name}} } {{~else~}} - private final {{java_define_type value_type}} _data; + private final {{java_define_type value_type}} _data; public final {{java_define_type value_type}} data() { return _data; } @@ -220,7 +221,7 @@ public final class {{name}} _data.resolve(_tables); } - {{end}} + {{~end~}} } "); var result = template.RenderCode(p); @@ -243,20 +244,20 @@ public final class {{name}} ByteBuf load(String file) throws java.io.IOException; } - {{- for table in tables }} + {{~for table in tables ~}} public final {{table.full_name_with_top_module}} {{table.name}}; - {{-end}} + {{~end~}} public {{name}}(IByteBufLoader loader) throws java.io.IOException { var tables = new java.util.HashMap(); - {{- for table in tables }} + {{~for table in tables ~}} {{table.name}} = new {{table.full_name_with_top_module}}(loader.load(""{{table.output_data_file}}"")); tables.put(""{{table.full_name}}"", {{table.name}}); - {{-end}} + {{~end~}} - {{- for table in tables }} + {{~ for table in tables ~}} {{table.name}}.resolve(tables); - {{-end}} + {{~end~}} } } diff --git a/src/Luban.Job.Cfg/Source/Generate/UE4BpCppRender.cs b/src/Luban.Job.Cfg/Source/Generate/UE4BpCppRender.cs index 6b3b775..b6fd578 100644 --- a/src/Luban.Job.Cfg/Source/Generate/UE4BpCppRender.cs +++ b/src/Luban.Job.Cfg/Source/Generate/UE4BpCppRender.cs @@ -33,16 +33,16 @@ namespace Luban.Job.Cfg.Generate UENUM(BlueprintType) enum class {{ue_bp_full_name}} : uint8 { - {{if !contains_value_equal0_item}} + {{~if !contains_value_equal0_item~}} __DEFAULT__ = 0, - {{end}} - {{if contains_any_ue_enum_compatible_item}} - {{- for item in items }} - {{if item.int_value >= 256}}//{{end}} {{item.name}} = {{item.value}} UMETA(DisplayName = ""{{item.alias_or_name}}""), - {{-end}} - {{else}} + {{~end~}} + {{~if contains_any_ue_enum_compatible_item~}} + {{~for item in items ~}} + {{if item.int_value >= 256}}//{{end}}{{item.name}} = {{item.value}} UMETA(DisplayName = ""{{item.alias_or_name}}""), + {{~end~}} + {{~else~}} DUMMY UMETA(DisplayName = ""DUMMY""), - {{end}} + {{~end~}} }; "); @@ -73,10 +73,10 @@ class X6PROTO_API {{ue_bp_full_name}} : public {{if parent_def_type}} {{parent_d public: - {{- for field in export_fields }} + {{~for field in export_fields ~}} UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (DisplayName = ""{{field.name}}"")) {{field.ctype.ue_bp_cpp_define_type}} {{field.name}}; - {{-end}} + {{~end~}} }; diff --git a/src/Luban.Job.Cfg/Source/Generate/UE4EditorCppRender.cs b/src/Luban.Job.Cfg/Source/Generate/UE4EditorCppRender.cs index 285316e..c3fd1f2 100644 --- a/src/Luban.Job.Cfg/Source/Generate/UE4EditorCppRender.cs +++ b/src/Luban.Job.Cfg/Source/Generate/UE4EditorCppRender.cs @@ -34,9 +34,9 @@ namespace editor enum class {{ue_fname}} { - {{- for item in items }} + {{~for item in items ~}} {{item.name}} = {{item.value}}, - {{-end}} + {{~end~}} }; bool X6PROTOEDITOR_API {{ue_fname}}ToString({{ue_fname}} value, FString& s); @@ -69,14 +69,14 @@ namespace editor struct X6PROTOEDITOR_API {{ue_fname}} : public {{if parent_def_type}} {{parent_def_type.ue_fname}}{{else}}FCfgObj{{end}} { - {{- for field in fields }} + {{~for field in fields ~}} {{field.ctype.editor_ue_cpp_define_type}} {{field.name}}; - {{-end}} + {{~end~}} -{{if !is_abstract_type}} +{{~if !is_abstract_type~}} bool Load(FJsonObject* _json) override; bool Save(FJsonObject*& result) override; -{{end}} +{{~end~}} static bool Create(FJsonObject* _json, {{ue_fname}}*& result); }; @@ -131,21 +131,21 @@ struct X6PROTOEDITOR_API {{ue_fname}} : public {{if parent_def_type}} {{parent_d namespace editor { -{{for type in types}} +{{~for type in types~}} {{type.cpp_namespace_begin}} -{{if type.is_bean}} -{{if type.is_abstract_type}} +{{~if type.is_bean~}} +{{~if type.is_abstract_type~}} bool {{type.ue_fname}}::Create(FJsonObject* _json, {{type.ue_fname}}*& result) { FString type; if (_json->TryGetStringField(FString(""__type__""), type)) { - {{-for child in type.hierarchy_not_abstract_children}} + {{~for child in type.hierarchy_not_abstract_children~}} if (type == ""{{child.name}}"") { result = new {{child.ue_fname}}(); } else - {{-end}} + {{~end~}} { result = nullptr; return false; @@ -163,7 +163,7 @@ namespace editor return false; } } -{{else}} +{{~else~}} bool {{type.ue_fname}}::Create(FJsonObject* _json, {{type.ue_fname}}*& result) { result = new {{type.ue_fname}}(); @@ -181,45 +181,45 @@ namespace editor auto _json = new FJsonObject(); _json->SetStringField(""__type__"", ""{{type.name}}""); -{{for field in type.hierarchy_fields}} +{{~for field in type.hierarchy_fields~}} {{field.editor_ue_cpp_save}} -{{end}} +{{~end~}} result = _json; return true; } bool {{type.ue_fname}}::Load(FJsonObject* _json) { -{{for field in type.hierarchy_fields}} +{{~for field in type.hierarchy_fields~}} {{field.editor_ue_cpp_load}} -{{end}} +{{~end~}} return true; } -{{end}} -{{else}} +{{~end~}} +{{~else~}} bool {{type.ue_fname}}ToString({{type.ue_fname}} value, FString& s) { - {{- for item in type.items }} + {{~for item in type.items ~}} if (value == {{type.ue_fname}}::{{item.name}}) { s = ""{{item.name}}""; return true; } - {{-end}} + {{~end~}} return false; } bool {{type.ue_fname}}FromString(const FString& s, {{type.ue_fname}}& value) { - {{- for item in type.items }} + {{~for item in type.items ~}} if (s == ""{{item.name}}"") { value = {{type.ue_fname}}::{{item.name}}; return true; } - {{-end}} + {{~end~}} return false; } -{{end}} +{{~end~}} {{type.cpp_namespace_end}} -{{end}} +{{~end~}} } "); var result = template.Render(new Stub diff --git a/src/Luban.Job.Cfg/Source/TypeVisitors/JavaDeserializeVisitor.cs b/src/Luban.Job.Cfg/Source/TypeVisitors/JavaDeserializeVisitor.cs index 60ebf28..8da2c1b 100644 --- a/src/Luban.Job.Cfg/Source/TypeVisitors/JavaDeserializeVisitor.cs +++ b/src/Luban.Job.Cfg/Source/TypeVisitors/JavaDeserializeVisitor.cs @@ -18,10 +18,5 @@ namespace Luban.Job.Cfg.TypeVisitors return type.Apply(JavaUnderingDeserializeVisitor.Ins, bufName, fieldName); } } - - public override string Accept(TBean type, string bufName, string fieldName) - { - return type.Apply(JavaUnderingDeserializeVisitor.Ins, bufName, fieldName); - } } } diff --git a/src/Luban.Job.Common/Source/Utils/RenderUtil.cs b/src/Luban.Job.Common/Source/Utils/RenderUtil.cs index 57843e6..49667eb 100644 --- a/src/Luban.Job.Common/Source/Utils/RenderUtil.cs +++ b/src/Luban.Job.Common/Source/Utils/RenderUtil.cs @@ -43,9 +43,9 @@ namespace {{x.namespace_with_top_module}} var template = t_enumRender ??= Template.Parse(@" namespace {{namespace_with_top_module}} { - {{-if is_flags}} + {{~if is_flags~}} [System.Flags] - {{-end}} + {{~end~}} public enum {{name}} { {{~ for item in items ~}} @@ -213,9 +213,9 @@ export class {{x.name}} { {{typescript_namespace_begin}} export enum {{name}} { - {{- for item in items }} + {{~for item in items ~}} {{item.name}} = {{item.value}}, - {{-end}} + {{~end~}} } {{typescript_namespace_end}} "); diff --git a/src/Luban.Job.Db/Source/Generate/AsyncCsRender.cs b/src/Luban.Job.Db/Source/Generate/AsyncCsRender.cs index fabdb18..1d3e3ee 100644 --- a/src/Luban.Job.Db/Source/Generate/AsyncCsRender.cs +++ b/src/Luban.Job.Db/Source/Generate/AsyncCsRender.cs @@ -52,7 +52,7 @@ namespace {{x.namespace_with_top_module}} public {{x.cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{x.parent}} {{else}} Bright.Transaction.TxnBeanBase {{end}} { {{~ for field in fields~}} - {{if is_abstract_type}}protected{{else}}private{{end}} {{db_cs_define_type field.ctype}} {{field.internal_name}}; + {{if is_abstract_type}}protected{{else}}private{{end}} {{db_cs_define_type field.ctype}} {{field.internal_name}}; {{~end}} public {{name}}() @@ -106,9 +106,9 @@ public {{x.cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{x.paren { var txn = Bright.Transaction.TransactionContext.AsyncLocalCtx; txn.PutField(_objectId_ + {{field.id}}, new {{field.log_type}}(this, value)); - {{~if field.ctype.need_set_children_root}} + {{~if field.ctype.need_set_children_root~}} value?.InitRoot(GetRoot()); - {{end}} + {{~end~}} } else { @@ -199,7 +199,7 @@ public {{x.cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{x.paren { {{~ for field in hierarchy_fields~}} {{if need_set_children_root field.ctype}}{{field.internal_name}}?.InitRoot(root);{{end}} - {{~end}} + {{~end~}} } public override string ToString()