parent
0bf3824ebb
commit
dcaee15c0e
|
|
@ -53,9 +53,9 @@ class {{name}} : public {{if parent_def_type}} {{parent_def_type.cpp_full_name}}
|
||||||
|
|
||||||
{{~if !hierarchy_export_fields.empty?~}}
|
{{~if !hierarchy_export_fields.empty?~}}
|
||||||
{{name}}({{- for field in hierarchy_export_fields }}{{cpp_define_type field.ctype}} {{field.name}}{{if !for.last}},{{end}} {{end}})
|
{{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}})
|
: {{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 ~}}
|
{{~ 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}};
|
{{cpp_define_type field.ctype}} {{field.cpp_style_name}};
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
|
|
||||||
{{if !x.is_abstract_type}}
|
{{~if !x.is_abstract_type~}}
|
||||||
static constexpr int ID = {{x.id}};
|
static constexpr int ID = {{x.id}};
|
||||||
|
|
||||||
int getTypeId() const { return 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}}; }
|
{{cpp_define_type field.ctype}}& {{field.cpp_getter_name}}() const { return _data->{{field.cpp_style_name}}; }
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
|
|
||||||
{{end}}
|
{{~end~}}
|
||||||
};
|
};
|
||||||
{{x.cpp_namespace_end}}
|
{{x.cpp_namespace_end}}
|
||||||
");
|
");
|
||||||
|
|
@ -171,17 +171,17 @@ class {{name}}
|
||||||
class {{name}}
|
class {{name}}
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
{{- for table in tables }}
|
{{~for table in tables ~}}
|
||||||
{{table.cpp_full_name}} {{table.name}};
|
{{table.cpp_full_name}} {{table.name}};
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
|
|
||||||
bool load(std::function<bool(ByteBuf&, const std::string&)> loader)
|
bool load(std::function<bool(ByteBuf&, const std::string&)> loader)
|
||||||
{
|
{
|
||||||
ByteBuf buf;
|
ByteBuf buf;
|
||||||
{{- for table in tables }}
|
{{~for table in tables~}}
|
||||||
if (!loader(buf, ""{{table.output_data_file}}"")) return false;
|
if (!loader(buf, ""{{table.output_data_file}}"")) return false;
|
||||||
if (!{{table.name}}.load(buf)) return false;
|
if (!{{table.name}}.load(buf)) return false;
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
return true;
|
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)
|
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;
|
int id;
|
||||||
if (!_buf.readInt(id)) return false;
|
if (!_buf.readInt(id)) return false;
|
||||||
switch (id)
|
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;} }
|
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;}
|
default: { _out = nullptr; return false;}
|
||||||
}
|
}
|
||||||
{{else}}
|
{{~else~}}
|
||||||
_out = new {{type.cpp_full_name}}();
|
_out = new {{type.cpp_full_name}}();
|
||||||
if (_out->deserialize(_buf))
|
if (_out->deserialize(_buf))
|
||||||
{
|
{
|
||||||
|
|
@ -250,7 +250,7 @@ namespace {{x.top_module}}
|
||||||
_out = nullptr;
|
_out = nullptr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
{{end}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,17 +56,17 @@ public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} {
|
||||||
|
|
||||||
public static {{name}} Deserialize{{name}}(ByteBuf _buf)
|
public static {{name}} Deserialize{{name}}(ByteBuf _buf)
|
||||||
{
|
{
|
||||||
{{if x.is_abstract_type}}
|
{{~if x.is_abstract_type~}}
|
||||||
switch (_buf.ReadInt())
|
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);
|
case {{child.full_name}}.ID: return new {{child.full_name}}(_buf);
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
default: throw new SerializationException();
|
default: throw new SerializationException();
|
||||||
}
|
}
|
||||||
{{else}}
|
{{~else~}}
|
||||||
return new {{x.full_name}}(_buf);
|
return new {{x.full_name}}(_buf);
|
||||||
{{end}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{~ for field in export_fields ~}}
|
{{~ for field in export_fields ~}}
|
||||||
|
|
@ -79,14 +79,16 @@ public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} {
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
|
|
||||||
{{if !x.is_abstract_type}}
|
{{~if !x.is_abstract_type~}}
|
||||||
public const int ID = {{x.id}};
|
public const int ID = {{x.id}};
|
||||||
public override int GetTypeId() => ID;
|
public override int GetTypeId() => ID;
|
||||||
{{end}}
|
{{~end~}}
|
||||||
|
|
||||||
public {{x.cs_method_modifier}} void Resolve(Dictionary<string, object> _tables)
|
public {{x.cs_method_modifier}} void Resolve(Dictionary<string, object> _tables)
|
||||||
{
|
{
|
||||||
{{~if parent_def_type}}base.Resolve(_tables);{{end}}
|
{{~if parent_def_type~}}
|
||||||
|
base.Resolve(_tables);
|
||||||
|
{{~end~}}
|
||||||
{{~ for field in export_fields ~}}
|
{{~ for field in export_fields ~}}
|
||||||
{{~if field.gen_ref~}}
|
{{~if field.gen_ref~}}
|
||||||
{{cs_ref_validator_resolve field}}
|
{{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()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return ""{{full_name}}{ ""
|
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}} + "",""
|
+ ""{{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);
|
OnResolveFinish(_tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
{{end}}
|
{{~end~}}
|
||||||
|
|
||||||
partial void OnResolveFinish(Dictionary<string, object> _tables);
|
partial void OnResolveFinish(Dictionary<string, object> _tables);
|
||||||
}
|
}
|
||||||
|
|
@ -229,21 +231,21 @@ namespace {{namespace}}
|
||||||
|
|
||||||
public sealed class {{name}}
|
public sealed class {{name}}
|
||||||
{
|
{
|
||||||
{{- for table in tables }}
|
{{~for table in tables ~}}
|
||||||
public {{table.full_name}} {{table.name}} {get; }
|
public {{table.full_name}} {{table.name}} {get; }
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
|
|
||||||
public {{name}}(System.Func<string, ByteBuf> loader)
|
public {{name}}(System.Func<string, ByteBuf> loader)
|
||||||
{
|
{
|
||||||
var tables = new System.Collections.Generic.Dictionary<string, object>();
|
var tables = new System.Collections.Generic.Dictionary<string, object>();
|
||||||
{{- for table in tables }}
|
{{~for table in tables ~}}
|
||||||
{{table.name}} = new {{table.full_name}}(loader(""{{table.output_data_file}}""));
|
{{table.name}} = new {{table.full_name}}(loader(""{{table.output_data_file}}""));
|
||||||
tables.Add(""{{table.full_name}}"", {{table.name}});
|
tables.Add(""{{table.full_name}}"", {{table.name}});
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
|
|
||||||
{{- for table in tables }}
|
{{~for table in tables ~}}
|
||||||
{{table.name}}.Resolve(tables);
|
{{table.name}}.Resolve(tables);
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} {
|
||||||
{{~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}}
|
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 ~}}
|
{{~ for field in export_fields ~}}
|
||||||
this.{{field.cs_style_name}} = {{field.name}};
|
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~}}
|
{{~if x.is_abstract_type~}}
|
||||||
switch (_buf.GetProperty(""__type__"").GetString())
|
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);
|
case ""{{child.name}}"": return new {{child.full_name}}(_buf);
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
default: throw new SerializationException();
|
default: throw new SerializationException();
|
||||||
}
|
}
|
||||||
{{~else~}}
|
{{~else~}}
|
||||||
|
|
@ -195,7 +195,7 @@ public sealed partial class {{name}}
|
||||||
OnResolveFinish(_tables);
|
OnResolveFinish(_tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
{{end}}
|
{{~end~}}
|
||||||
|
|
||||||
partial void OnResolveFinish(Dictionary<string, object> _tables);
|
partial void OnResolveFinish(Dictionary<string, object> _tables);
|
||||||
}
|
}
|
||||||
|
|
@ -225,21 +225,21 @@ namespace {{namespace}}
|
||||||
|
|
||||||
public sealed partial class {{name}}
|
public sealed partial class {{name}}
|
||||||
{
|
{
|
||||||
{{- for table in tables }}
|
{{~for table in tables ~}}
|
||||||
public {{table.full_name}} {{table.name}} {get; }
|
public {{table.full_name}} {{table.name}} {get; }
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
|
|
||||||
public {{name}}(System.Func<string, JsonElement> loader)
|
public {{name}}(System.Func<string, JsonElement> loader)
|
||||||
{
|
{
|
||||||
var tables = new System.Collections.Generic.Dictionary<string, object>();
|
var tables = new System.Collections.Generic.Dictionary<string, object>();
|
||||||
{{- for table in tables }}
|
{{~for table in tables ~}}
|
||||||
{{table.name}} = new {{table.full_name}}(loader(""{{table.json_output_data_file}}""));
|
{{table.name}} = new {{table.full_name}}(loader(""{{table.json_output_data_file}}""));
|
||||||
tables.Add(""{{table.full_name}}"", {{table.name}});
|
tables.Add(""{{table.full_name}}"", {{table.name}});
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
|
|
||||||
{{- for table in tables }}
|
{{~for table in tables ~}}
|
||||||
{{table.name}}.Resolve(tables);
|
{{table.name}}.Resolve(tables);
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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}}
|
public {{name}}(Bright.Common.NotNullInitialization _) {{if parent_def_type}} : base(_) {{end}}
|
||||||
{
|
{
|
||||||
{{- for field in fields }}
|
{{~for field in fields ~}}
|
||||||
{{if field.ctype.need_init}}{{field.proto_cs_init_field}} {{end}}
|
{{~if field.ctype.need_init~}}
|
||||||
{{-end}}
|
{{field.proto_cs_init_field}}
|
||||||
|
{{~end~}}
|
||||||
|
{{~end~}}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{if is_abstract_type}}
|
{{~if is_abstract_type~}}
|
||||||
public static void Serialize{{name}}(ByteBuf _buf, {{name}} x)
|
public static void Serialize{{name}}(ByteBuf _buf, {{name}} x)
|
||||||
{
|
{
|
||||||
if (x == null) { _buf.WriteInt(0); return; }
|
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())
|
switch (_buf.ReadInt())
|
||||||
{
|
{
|
||||||
case 0 : return null;
|
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;
|
case {{child.full_name}}.ID: x = new {{child.full_name}}(false); break;
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
default: throw new SerializationException();
|
default: throw new SerializationException();
|
||||||
}
|
}
|
||||||
x.Deserialize(_buf);
|
x.Deserialize(_buf);
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
{{end}}
|
{{~end~}}
|
||||||
{{- for field in fields }}
|
{{~for field in fields ~}}
|
||||||
public {{field.ctype.cs_define_type}} {{field.cs_style_name}};
|
public {{field.ctype.cs_define_type}} {{field.cs_style_name}};
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
|
|
||||||
{{if !parent_def_type && is_abstract_type}}
|
{{~if !parent_def_type && is_abstract_type~}}
|
||||||
public abstract int GetTypeId();
|
public abstract int GetTypeId();
|
||||||
{{end}}
|
{{~end~}}
|
||||||
{{if parent_def_type && !is_abstract_type}}
|
{{~if parent_def_type && !is_abstract_type~}}
|
||||||
public const int ID = {{id}};
|
public const int ID = {{id}};
|
||||||
public override int GetTypeId()
|
public override int GetTypeId()
|
||||||
{
|
{
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
{{end}}
|
{{~end~}}
|
||||||
|
|
||||||
public {{cs_method_modifer}} void Serialize(ByteBuf _buf)
|
public {{cs_method_modifer}} void Serialize(ByteBuf _buf)
|
||||||
{
|
{
|
||||||
{{if parent_def_type}} base.Serialize(_buf); {{end}}
|
{{~if parent_def_type~}}
|
||||||
{{- for field in fields }}
|
base.Serialize(_buf);
|
||||||
|
{{~end~}}
|
||||||
|
{{~for field in fields ~}}
|
||||||
{{field.cs_serialize}}
|
{{field.cs_serialize}}
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
|
|
||||||
public {{cs_method_modifer}} void Deserialize(ByteBuf _buf)
|
public {{cs_method_modifer}} void Deserialize(ByteBuf _buf)
|
||||||
{
|
{
|
||||||
{{if parent_def_type}} base.Deserialize(_buf); {{end}}
|
{{~if parent_def_type~}}
|
||||||
{{- for field in fields }}
|
base.Deserialize(_buf);
|
||||||
|
{{~end~}}
|
||||||
|
{{~for field in fields ~}}
|
||||||
{{field.cs_deserialize}}
|
{{field.cs_deserialize}}
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return ""{{full_name}}{ ""
|
return ""{{full_name}}{ ""
|
||||||
{{- for field in hierarchy_fields }}
|
{{~for field in hierarchy_fields ~}}
|
||||||
+ ""{{field.cs_style_name}}:"" + {{field.proto_cs_to_string}} + "",""
|
+ ""{{field.cs_style_name}}:"" + {{field.proto_cs_to_string}} + "",""
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
+ ""}"";
|
+ ""}"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -140,17 +146,19 @@ namespace {{namespace}}
|
||||||
|
|
||||||
public sealed class {{name}} : Bright.Net.Protocol
|
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}};
|
public {{field.ctype.cs_define_type}} {{field.cs_style_name}};
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
public {{name}}()
|
public {{name}}()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
public {{name}}(Bright.Common.NotNullInitialization _)
|
public {{name}}(Bright.Common.NotNullInitialization _)
|
||||||
{
|
{
|
||||||
{{- for field in fields }}
|
{{~for field in fields ~}}
|
||||||
{{if field.ctype.need_init}}{{field.proto_cs_init_field}} {{end}}
|
{{~if field.ctype.need_init~}}
|
||||||
{{-end}}
|
{{field.proto_cs_init_field}}
|
||||||
|
{{~end~}}
|
||||||
|
{{~end~}}
|
||||||
}
|
}
|
||||||
public const int ID = {{id}};
|
public const int ID = {{id}};
|
||||||
|
|
||||||
|
|
@ -161,16 +169,16 @@ public sealed class {{name}} : Bright.Net.Protocol
|
||||||
|
|
||||||
public override void Serialize(ByteBuf _buf)
|
public override void Serialize(ByteBuf _buf)
|
||||||
{
|
{
|
||||||
{{- for field in fields }}
|
{{~for field in fields ~}}
|
||||||
{{field.cs_serialize}}
|
{{field.cs_serialize}}
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Deserialize(ByteBuf _buf)
|
public override void Deserialize(ByteBuf _buf)
|
||||||
{
|
{
|
||||||
{{- for field in fields }}
|
{{~for field in fields ~}}
|
||||||
{{field.cs_deserialize}}
|
{{field.cs_deserialize}}
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Reset()
|
public override void Reset()
|
||||||
|
|
@ -186,9 +194,9 @@ public sealed class {{name}} : Bright.Net.Protocol
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return ""{{full_name}}{ ""
|
return ""{{full_name}}{ ""
|
||||||
{{- for field in fields }}
|
{{~for field in fields ~}}
|
||||||
+ ""{{field.cs_style_name}}:"" + {{field.proto_cs_to_string}} + "",""
|
+ ""{{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<int, Bright.Net.IProtocolFactory> Factories { get; } = new System.Collections.Generic.Dictionary<int, Bright.Net.IProtocolFactory>
|
public static System.Collections.Generic.Dictionary<int, Bright.Net.IProtocolFactory> Factories { get; } = new System.Collections.Generic.Dictionary<int, Bright.Net.IProtocolFactory>
|
||||||
{
|
{
|
||||||
{{- for proto in protos }}
|
{{~for proto in protos ~}}
|
||||||
[{{proto.full_name}}.ID] = () => new {{proto.full_name}}(false),
|
[{{proto.full_name}}.ID] = () => new {{proto.full_name}}(false),
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,9 @@ namespace Luban.Job.Cfg.Generate
|
||||||
package {{package}}
|
package {{package}}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
{{- for item in x.items }}
|
{{~for item in x.items ~}}
|
||||||
{{x.go_full_name}}_{{item.name}} = {{go_const_value item.ctype item.value}}
|
{{x.go_full_name}}_{{item.name}} = {{go_const_value item.ctype item.value}}
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
)
|
)
|
||||||
");
|
");
|
||||||
var result = template.RenderCode(c, new Dictionary<string, object>() { ["package"] = package });
|
var result = template.RenderCode(c, new Dictionary<string, object>() { ["package"] = package });
|
||||||
|
|
@ -52,9 +52,9 @@ const (
|
||||||
package {{package}}
|
package {{package}}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
{{- for item in x.items }}
|
{{~for item in x.items ~}}
|
||||||
{{x.go_full_name}}_{{item.name}} = {{item.value}}
|
{{x.go_full_name}}_{{item.name}} = {{item.value}}
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
)
|
)
|
||||||
|
|
||||||
");
|
");
|
||||||
|
|
@ -85,31 +85,33 @@ import ""bright/serialization""
|
||||||
{{x.go_import}}
|
{{x.go_import}}
|
||||||
|
|
||||||
type {{go_full_name}} struct {
|
type {{go_full_name}} struct {
|
||||||
{{if parent_def_type}}{{parent_def_type.go_full_name}}{{end}}
|
{{~if parent_def_type~}}
|
||||||
{{- for field in export_fields }}
|
{{parent_def_type.go_full_name}}
|
||||||
|
{{~end~}}
|
||||||
|
{{~for field in export_fields ~}}
|
||||||
{{field.cs_style_name}} {{go_define_type field.ctype}}
|
{{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 {
|
func ({{go_full_name}}) GetTypeId() int {
|
||||||
return {{x.id}}
|
return {{x.id}}
|
||||||
}
|
}
|
||||||
{{end}}
|
{{~end~}}
|
||||||
|
|
||||||
func New{{go_full_name}}(_buf *serialization.ByteBuf) (_v *{{go_full_name}}, err error) {
|
func New{{go_full_name}}(_buf *serialization.ByteBuf) (_v *{{go_full_name}}, err error) {
|
||||||
_v = &{{go_full_name}}{}
|
_v = &{{go_full_name}}{}
|
||||||
{{if parent_def_type}}
|
{{~if parent_def_type~}}
|
||||||
var _p *{{parent_def_type.go_full_name}}
|
var _p *{{parent_def_type.go_full_name}}
|
||||||
if _p, err = New{{parent_def_type.go_full_name}}(_buf) ; err != nil { return }
|
if _p, err = New{{parent_def_type.go_full_name}}(_buf) ; err != nil { return }
|
||||||
_v.{{parent_def_type.go_full_name}} = *_p
|
_v.{{parent_def_type.go_full_name}} = *_p
|
||||||
{{end}}
|
{{~end~}}
|
||||||
{{- for field in export_fields }}
|
{{~for field in export_fields ~}}
|
||||||
{{go_deserialize_field field '_buf'}}
|
{{go_deserialize_field field '_buf'}}
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
{{if is_abstract_type}}
|
{{~if is_abstract_type~}}
|
||||||
func NewChild{{go_full_name}}(_buf *serialization.ByteBuf) (_v interface{}, err error) {
|
func NewChild{{go_full_name}}(_buf *serialization.ByteBuf) (_v interface{}, err error) {
|
||||||
var id int32
|
var id int32
|
||||||
if id, err = _buf.ReadInt() ; err != nil {
|
if id, err = _buf.ReadInt() ; err != nil {
|
||||||
|
|
@ -117,13 +119,13 @@ func NewChild{{go_full_name}}(_buf *serialization.ByteBuf) (_v interface{}, err
|
||||||
}
|
}
|
||||||
switch id {
|
switch id {
|
||||||
case 0 : return nil, nil
|
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);
|
case {{child.id}}: return New{{child.go_full_name}}(_buf);
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
{{end}}
|
{{~end~}}
|
||||||
|
|
||||||
");
|
");
|
||||||
var result = template.RenderCode(b, new Dictionary<string, object>() { ["package"] = package });
|
var result = template.RenderCode(b, new Dictionary<string, object>() { ["package"] = package });
|
||||||
|
|
@ -172,12 +174,12 @@ func New{{go_full_name}}(_buf *serialization.ByteBuf) (*{{go_full_name}}, error)
|
||||||
} else {
|
} else {
|
||||||
_dataList = append(_dataList, _v)
|
_dataList = append(_dataList, _v)
|
||||||
{{~if value_type.is_dynamic ~}}
|
{{~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 {
|
if __v, __is := _v.(*{{child.go_full_name}}) ; __is {
|
||||||
dataMap[__v.{{index_field.cs_style_name}}] = _v
|
dataMap[__v.{{index_field.cs_style_name}}] = _v
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
{{~else~}}
|
{{~else~}}
|
||||||
dataMap[_v.{{index_field.cs_style_name}}] = _v
|
dataMap[_v.{{index_field.cs_style_name}}] = _v
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
|
|
@ -200,7 +202,7 @@ func (table *{{go_full_name}}) Get(key {{go_define_type key_type}}) {{go_define_
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
{{else}}
|
{{~else~}}
|
||||||
|
|
||||||
import ""errors""
|
import ""errors""
|
||||||
|
|
||||||
|
|
@ -226,7 +228,7 @@ func (table *{{go_full_name}}) Get() {{go_define_type value_type}} {
|
||||||
return table._data
|
return table._data
|
||||||
}
|
}
|
||||||
|
|
||||||
{{end}}
|
{{~end~}}
|
||||||
");
|
");
|
||||||
var result = template.RenderCode(p, new Dictionary<string, object>() { ["package"] = package });
|
var result = template.RenderCode(p, new Dictionary<string, object>() { ["package"] = package });
|
||||||
|
|
||||||
|
|
@ -247,9 +249,9 @@ import ""bright/serialization""
|
||||||
type ByteBufLoader func(string) (*serialization.ByteBuf, error)
|
type ByteBufLoader func(string) (*serialization.ByteBuf, error)
|
||||||
|
|
||||||
type {{name}} struct {
|
type {{name}} struct {
|
||||||
{{- for table in tables }}
|
{{~for table in tables ~}}
|
||||||
{{table.name}} *{{table.go_full_name}}
|
{{table.name}} *{{table.go_full_name}}
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTables(loader ByteBufLoader) (*{{name}}, error) {
|
func NewTables(loader ByteBufLoader) (*{{name}}, error) {
|
||||||
|
|
@ -257,14 +259,14 @@ func NewTables(loader ByteBufLoader) (*{{name}}, error) {
|
||||||
var buf *serialization.ByteBuf
|
var buf *serialization.ByteBuf
|
||||||
|
|
||||||
tables := &{{name}}{}
|
tables := &{{name}}{}
|
||||||
{{- for table in tables }}
|
{{~for table in tables ~}}
|
||||||
if buf, err = loader(""{{table.output_data_file}}"") ; err != nil {
|
if buf, err = loader(""{{table.output_data_file}}"") ; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if tables.{{table.name}}, err = New{{table.go_full_name}}(buf) ; err != nil {
|
if tables.{{table.name}}, err = New{{table.go_full_name}}(buf) ; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
return tables, nil
|
return tables, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,18 +72,17 @@ public {{x.java_class_modifier}} class {{name}} extends {{if parent_def_type}} {
|
||||||
|
|
||||||
public static {{name}} deserialize{{name}}(ByteBuf _buf)
|
public static {{name}} deserialize{{name}}(ByteBuf _buf)
|
||||||
{
|
{
|
||||||
{{if x.is_abstract_type}}
|
{{~if x.is_abstract_type~}}
|
||||||
switch (_buf.readInt())
|
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);
|
case {{child.full_name_with_top_module}}.ID: return new {{child.full_name_with_top_module}}(_buf);
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
default: throw new SerializationException();
|
default: throw new SerializationException();
|
||||||
}
|
}
|
||||||
{{else}}
|
{{~else~}}
|
||||||
return new {{name}}(_buf);
|
return new {{name}}(_buf);
|
||||||
{{end}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{~ for field in export_fields ~}}
|
{{~ for field in export_fields ~}}
|
||||||
|
|
@ -96,12 +95,12 @@ public {{x.java_class_modifier}} class {{name}} extends {{if parent_def_type}} {
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
|
|
||||||
{{if !x.is_abstract_type}}
|
{{~if !x.is_abstract_type~}}
|
||||||
public static final int ID = {{x.id}};
|
public static final int ID = {{x.id}};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTypeId() { return ID; }
|
public int getTypeId() { return ID; }
|
||||||
{{end}}
|
{{~end~}}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf os)
|
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<String, Object> _tables)
|
public void resolve(java.util.HashMap<String, Object> _tables)
|
||||||
{
|
{
|
||||||
{{~if parent_def_type}}super.resolve(_tables);{{end}}
|
{{~if parent_def_type~}}
|
||||||
|
super.resolve(_tables);
|
||||||
|
{{~end~}}
|
||||||
{{~ for field in export_fields ~}}
|
{{~ for field in export_fields ~}}
|
||||||
{{~if field.gen_ref~}}
|
{{~if field.gen_ref~}}
|
||||||
{{java_ref_validator_resolve field}}
|
{{java_ref_validator_resolve field}}
|
||||||
|
|
@ -131,9 +132,9 @@ public {{x.java_class_modifier}} class {{name}} extends {{if parent_def_type}} {
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return ""{{full_name}}{ ""
|
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}} + "",""
|
+ ""{{field.java_style_name}}:"" + {{java_to_string field.java_style_name field.ctype}} + "",""
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
+ ""}"";
|
+ ""}"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -220,7 +221,7 @@ public final class {{name}}
|
||||||
_data.resolve(_tables);
|
_data.resolve(_tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
{{end}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
");
|
");
|
||||||
var result = template.RenderCode(p);
|
var result = template.RenderCode(p);
|
||||||
|
|
@ -243,20 +244,20 @@ public final class {{name}}
|
||||||
ByteBuf load(String file) throws java.io.IOException;
|
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}};
|
public final {{table.full_name_with_top_module}} {{table.name}};
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
|
|
||||||
public {{name}}(IByteBufLoader loader) throws java.io.IOException {
|
public {{name}}(IByteBufLoader loader) throws java.io.IOException {
|
||||||
var tables = new java.util.HashMap<String, Object>();
|
var tables = new java.util.HashMap<String, Object>();
|
||||||
{{- for table in tables }}
|
{{~for table in tables ~}}
|
||||||
{{table.name}} = new {{table.full_name_with_top_module}}(loader.load(""{{table.output_data_file}}""));
|
{{table.name}} = new {{table.full_name_with_top_module}}(loader.load(""{{table.output_data_file}}""));
|
||||||
tables.put(""{{table.full_name}}"", {{table.name}});
|
tables.put(""{{table.full_name}}"", {{table.name}});
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
|
|
||||||
{{- for table in tables }}
|
{{~ for table in tables ~}}
|
||||||
{{table.name}}.resolve(tables);
|
{{table.name}}.resolve(tables);
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,16 +33,16 @@ namespace Luban.Job.Cfg.Generate
|
||||||
UENUM(BlueprintType)
|
UENUM(BlueprintType)
|
||||||
enum class {{ue_bp_full_name}} : uint8
|
enum class {{ue_bp_full_name}} : uint8
|
||||||
{
|
{
|
||||||
{{if !contains_value_equal0_item}}
|
{{~if !contains_value_equal0_item~}}
|
||||||
__DEFAULT__ = 0,
|
__DEFAULT__ = 0,
|
||||||
{{end}}
|
{{~end~}}
|
||||||
{{if contains_any_ue_enum_compatible_item}}
|
{{~if contains_any_ue_enum_compatible_item~}}
|
||||||
{{- for item in items }}
|
{{~for item in items ~}}
|
||||||
{{if item.int_value >= 256}}//{{end}}{{item.name}} = {{item.value}} UMETA(DisplayName = ""{{item.alias_or_name}}""),
|
{{if item.int_value >= 256}}//{{end}}{{item.name}} = {{item.value}} UMETA(DisplayName = ""{{item.alias_or_name}}""),
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
{{else}}
|
{{~else~}}
|
||||||
DUMMY UMETA(DisplayName = ""DUMMY""),
|
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:
|
public:
|
||||||
|
|
||||||
|
|
||||||
{{- for field in export_fields }}
|
{{~for field in export_fields ~}}
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (DisplayName = ""{{field.name}}""))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (DisplayName = ""{{field.name}}""))
|
||||||
{{field.ctype.ue_bp_cpp_define_type}} {{field.name}};
|
{{field.ctype.ue_bp_cpp_define_type}} {{field.name}};
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,9 @@ namespace editor
|
||||||
|
|
||||||
enum class {{ue_fname}}
|
enum class {{ue_fname}}
|
||||||
{
|
{
|
||||||
{{- for item in items }}
|
{{~for item in items ~}}
|
||||||
{{item.name}} = {{item.value}},
|
{{item.name}} = {{item.value}},
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool X6PROTOEDITOR_API {{ue_fname}}ToString({{ue_fname}} value, FString& s);
|
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}}
|
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}};
|
{{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 Load(FJsonObject* _json) override;
|
||||||
bool Save(FJsonObject*& result) override;
|
bool Save(FJsonObject*& result) override;
|
||||||
{{end}}
|
{{~end~}}
|
||||||
|
|
||||||
static bool Create(FJsonObject* _json, {{ue_fname}}*& result);
|
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
|
namespace editor
|
||||||
{
|
{
|
||||||
|
|
||||||
{{for type in types}}
|
{{~for type in types~}}
|
||||||
{{type.cpp_namespace_begin}}
|
{{type.cpp_namespace_begin}}
|
||||||
{{if type.is_bean}}
|
{{~if type.is_bean~}}
|
||||||
{{if type.is_abstract_type}}
|
{{~if type.is_abstract_type~}}
|
||||||
bool {{type.ue_fname}}::Create(FJsonObject* _json, {{type.ue_fname}}*& result)
|
bool {{type.ue_fname}}::Create(FJsonObject* _json, {{type.ue_fname}}*& result)
|
||||||
{
|
{
|
||||||
FString type;
|
FString type;
|
||||||
if (_json->TryGetStringField(FString(""__type__""), 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}}"")
|
if (type == ""{{child.name}}"")
|
||||||
{
|
{
|
||||||
result = new {{child.ue_fname}}();
|
result = new {{child.ue_fname}}();
|
||||||
} else
|
} else
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
{
|
{
|
||||||
result = nullptr;
|
result = nullptr;
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -163,7 +163,7 @@ namespace editor
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{{else}}
|
{{~else~}}
|
||||||
bool {{type.ue_fname}}::Create(FJsonObject* _json, {{type.ue_fname}}*& result)
|
bool {{type.ue_fname}}::Create(FJsonObject* _json, {{type.ue_fname}}*& result)
|
||||||
{
|
{
|
||||||
result = new {{type.ue_fname}}();
|
result = new {{type.ue_fname}}();
|
||||||
|
|
@ -181,45 +181,45 @@ namespace editor
|
||||||
auto _json = new FJsonObject();
|
auto _json = new FJsonObject();
|
||||||
_json->SetStringField(""__type__"", ""{{type.name}}"");
|
_json->SetStringField(""__type__"", ""{{type.name}}"");
|
||||||
|
|
||||||
{{for field in type.hierarchy_fields}}
|
{{~for field in type.hierarchy_fields~}}
|
||||||
{{field.editor_ue_cpp_save}}
|
{{field.editor_ue_cpp_save}}
|
||||||
{{end}}
|
{{~end~}}
|
||||||
result = _json;
|
result = _json;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool {{type.ue_fname}}::Load(FJsonObject* _json)
|
bool {{type.ue_fname}}::Load(FJsonObject* _json)
|
||||||
{
|
{
|
||||||
{{for field in type.hierarchy_fields}}
|
{{~for field in type.hierarchy_fields~}}
|
||||||
{{field.editor_ue_cpp_load}}
|
{{field.editor_ue_cpp_load}}
|
||||||
{{end}}
|
{{~end~}}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
{{end}}
|
{{~end~}}
|
||||||
{{else}}
|
{{~else~}}
|
||||||
|
|
||||||
bool {{type.ue_fname}}ToString({{type.ue_fname}} value, FString& s)
|
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; }
|
if (value == {{type.ue_fname}}::{{item.name}}) { s = ""{{item.name}}""; return true; }
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool {{type.ue_fname}}FromString(const FString& s, {{type.ue_fname}}& value)
|
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}}"")
|
if (s == ""{{item.name}}"")
|
||||||
{
|
{
|
||||||
value = {{type.ue_fname}}::{{item.name}};
|
value = {{type.ue_fname}}::{{item.name}};
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
{{end}}
|
{{~end~}}
|
||||||
{{type.cpp_namespace_end}}
|
{{type.cpp_namespace_end}}
|
||||||
{{end}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
");
|
");
|
||||||
var result = template.Render(new Stub
|
var result = template.Render(new Stub
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,5 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
return type.Apply(JavaUnderingDeserializeVisitor.Ins, bufName, fieldName);
|
return type.Apply(JavaUnderingDeserializeVisitor.Ins, bufName, fieldName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Accept(TBean type, string bufName, string fieldName)
|
|
||||||
{
|
|
||||||
return type.Apply(JavaUnderingDeserializeVisitor.Ins, bufName, fieldName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,9 @@ namespace {{x.namespace_with_top_module}}
|
||||||
var template = t_enumRender ??= Template.Parse(@"
|
var template = t_enumRender ??= Template.Parse(@"
|
||||||
namespace {{namespace_with_top_module}}
|
namespace {{namespace_with_top_module}}
|
||||||
{
|
{
|
||||||
{{-if is_flags}}
|
{{~if is_flags~}}
|
||||||
[System.Flags]
|
[System.Flags]
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
public enum {{name}}
|
public enum {{name}}
|
||||||
{
|
{
|
||||||
{{~ for item in items ~}}
|
{{~ for item in items ~}}
|
||||||
|
|
@ -213,9 +213,9 @@ export class {{x.name}} {
|
||||||
{{typescript_namespace_begin}}
|
{{typescript_namespace_begin}}
|
||||||
|
|
||||||
export enum {{name}} {
|
export enum {{name}} {
|
||||||
{{- for item in items }}
|
{{~for item in items ~}}
|
||||||
{{item.name}} = {{item.value}},
|
{{item.name}} = {{item.value}},
|
||||||
{{-end}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
{{typescript_namespace_end}}
|
{{typescript_namespace_end}}
|
||||||
");
|
");
|
||||||
|
|
|
||||||
|
|
@ -106,9 +106,9 @@ public {{x.cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{x.paren
|
||||||
{
|
{
|
||||||
var txn = Bright.Transaction.TransactionContext.AsyncLocalCtx;
|
var txn = Bright.Transaction.TransactionContext.AsyncLocalCtx;
|
||||||
txn.PutField(_objectId_ + {{field.id}}, new {{field.log_type}}(this, value));
|
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());
|
value?.InitRoot(GetRoot());
|
||||||
{{end}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -199,7 +199,7 @@ public {{x.cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{x.paren
|
||||||
{
|
{
|
||||||
{{~ for field in hierarchy_fields~}}
|
{{~ for field in hierarchy_fields~}}
|
||||||
{{if need_set_children_root field.ctype}}{{field.internal_name}}?.InitRoot(root);{{end}}
|
{{if need_set_children_root field.ctype}}{{field.internal_name}}?.InitRoot(root);{{end}}
|
||||||
{{~end}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue