【调整】将多态类型id字段ID改名为__ID__,避免与常见的字段名ID冲突而产生编译错误

main
walon 2021-11-15 23:47:50 +08:00
parent f6b8b32123
commit 2034e8050f
20 changed files with 45 additions and 45 deletions

View File

@ -55,9 +55,9 @@ class {{name}} : public {{if parent_def_type}} {{parent_def_type.cpp_full_name}}
{{~end~}}
{{~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~}}
virtual void resolve(::bright::HashMap<::bright::String, void*>& _tables);

View File

@ -37,7 +37,7 @@ namespace {{x.top_module}}
switch (id)
{
{{~for child in type.hierarchy_not_abstract_children~}}
case {{child.cpp_full_name}}::ID: { _out.reset(new {{child.cpp_full_name}}()); if (_out->deserialize(_buf)) { return true; } else { _out.reset(); return false;} }
case {{child.cpp_full_name}}::__ID__: { _out.reset(new {{child.cpp_full_name}}()); if (_out->deserialize(_buf)) { return true; } else { _out.reset(); return false;} }
{{~end~}}
default: { _out = nullptr; return false;}
}

View File

@ -37,7 +37,7 @@ public {{x.cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{x.paren
switch (_buf.ReadInt())
{
{{~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~}}
default: throw new SerializationException();
}
@ -65,8 +65,8 @@ public {{x.cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{x.paren
{{~end~}}
{{~if !x.is_abstract_type~}}
public const int ID = {{x.id}};
public override int GetTypeId() => ID;
public const int __ID__ = {{x.id}};
public override int GetTypeId() => __ID__;
{{~end~}}
public {{x.cs_method_modifier}} void Resolve(Dictionary<string, object> _tables)

View File

@ -34,7 +34,7 @@ public {{cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{parent}}
{
case 0 : return null;
{{~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~}}
default: throw new SerializationException();
}
@ -50,10 +50,10 @@ public {{cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{parent}}
public abstract int GetTypeId();
{{~end~}}
{{~if parent_def_type && !is_abstract_type~}}
public const int ID = {{id}};
public const int __ID__ = {{id}};
public override int GetTypeId()
{
return ID;
return __ID__;
}
{{~end~}}

View File

@ -19,11 +19,11 @@ public sealed class {{name}} : Bright.Net.Protocol
{{~end~}}
{{~end~}}
}
public const int ID = {{id}};
public const int __ID__ = {{id}};
public override int GetTypeId()
{
return ID;
return __ID__;
}
public override void Serialize(ByteBuf _buf)

View File

@ -8,7 +8,7 @@ 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>
{
{{~for proto in protos ~}}
[{{proto.full_name}}.ID] = () => new {{proto.full_name}}(false),
[{{proto.full_name}}.__ID__] = () => new {{proto.full_name}}(false),
{{~end~}}
};
}

View File

@ -74,8 +74,8 @@ public {{x.cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{parent}
{{~end~}}
{{~if !x.is_abstract_type~}}
public const int ID = {{x.id}};
public override int GetTypeId() => ID;
public const int __ID__ = {{x.id}};
public override int GetTypeId() => __ID__;
{{~end~}}
public {{x.cs_method_modifier}} void Resolve(Dictionary<string, object> _tables)

View File

@ -75,8 +75,8 @@ public {{x.cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{parent}
{{~end~}}
{{~if !x.is_abstract_type~}}
public const int ID = {{x.id}};
public override int GetTypeId() => ID;
public const int __ID__ = {{x.id}};
public override int GetTypeId() => __ID__;
{{~end~}}
public {{x.cs_method_modifier}} void Resolve(Dictionary<string, object> _tables)

View File

@ -47,7 +47,7 @@ public {{x.java_class_modifier}} class {{name}}{{if parent_def_type}} extends {{
public static {{name}} deserialize{{name}}(ByteBuf _buf) {
switch (_buf.readInt()) {
{{~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~}}
default: throw new SerializationException();
}
@ -70,10 +70,10 @@ public {{x.java_class_modifier}} class {{name}}{{if parent_def_type}} extends {{
{{~end~}}
{{~if !x.is_abstract_type && x.parent_def_type~}}
public static final int ID = {{x.id}};
public static final int __ID__ = {{x.id}};
@Override
public int getTypeId() { return ID; }
public int getTypeId() { return __ID__; }
{{~else if x.is_abstract_type && !x.parent_def_type~}}
public abstract int getTypeId();
{{~end~}}

View File

@ -73,10 +73,10 @@ public {{x.java_class_modifier}} class {{name}}{{if parent_def_type}} extends {{
{{~end~}}
{{~if !x.is_abstract_type && x.parent_def_type~}}
public static final int ID = {{x.id}};
public static final int __ID__ = {{x.id}};
@Override
public int getTypeId() { return ID; }
public int getTypeId() { return __ID__; }
{{~else if x.is_abstract_type && !x.parent_def_type~}}
public abstract int getTypeId();
{{~end~}}

View File

@ -144,7 +144,7 @@ public {{x.cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{x.paren
{
case 0 : return null;
{{~ for child in x.hierarchy_not_abstract_children~}}
case {{child.full_name}}.ID: x = new {{child.full_name}}(); break;
case {{child.full_name}}.__ID__: x = new {{child.full_name}}(); break;
{{~end~}}
default: throw new SerializationException();
}
@ -176,8 +176,8 @@ public {{x.cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{x.paren
}
}
public const int ID = {{x.id}};
public override int GetTypeId() => ID;
public const int __ID__ = {{x.id}};
public override int GetTypeId() => __ID__;
{{~end~}}
protected override void InitChildrenRoot(BrightDB.Storage.TKey root)

View File

@ -144,7 +144,7 @@ public {{x.cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{x.paren
{
case 0 : return null;
{{~ for child in x.hierarchy_not_abstract_children~}}
case {{child.full_name}}.ID: x = new {{child.full_name}}(); break;
case {{child.full_name}}.__ID__: x = new {{child.full_name}}(); break;
{{~end~}}
default: throw new SerializationException();
}
@ -176,8 +176,8 @@ public {{x.cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{x.paren
}
}
public const int ID = {{x.id}};
public override int GetTypeId() => ID;
public const int __ID__ = {{x.id}};
public override int GetTypeId() => __ID__;
{{~end~}}
protected override void InitChildrenRoot(Bright.Storage.TKey root)

View File

@ -105,7 +105,7 @@ export {{x.ts_class_modifier}} class {{name}} extends {{if parent_def_type}} {{x
let x: {{name}}
switch (_buf.ReadInt()) {
{{~ for child in x.hierarchy_not_abstract_children~}}
case {{child.full_name}}.ID: x = new {{child.full_name}}(); break
case {{child.full_name}}.__ID__: x = new {{child.full_name}}(); break
{{~end~}}
default: throw new Error()
}
@ -133,8 +133,8 @@ export {{x.ts_class_modifier}} class {{name}} extends {{if parent_def_type}} {{x
}
}
static readonly ID = {{x.id}}
getTypeId(): number { return {{name}}.ID }
static readonly __ID__ = {{x.id}}
getTypeId(): number { return {{name}}.__ID__ }
{{~end~}}
initChildrenRoot(root: TKey) {

View File

@ -62,7 +62,7 @@ namespace {{x.namespace_with_top_module}}
{
case 0 : return null;
{{~ for child in x.hierarchy_not_abstract_children~}}
case {{child.full_name}}.ID: x = new {{child.full_name}}(); break;
case {{child.full_name}}.__ID__: x = new {{child.full_name}}(); break;
{{~end~}}
default: throw new SerializationException();
}
@ -85,8 +85,8 @@ namespace {{x.namespace_with_top_module}}
{{~end~}}
{{~if !is_abstract_type~}}
public const int ID = {{x.id}};
public override int GetTypeId() => ID;
public const int __ID__ = {{x.id}};
public override int GetTypeId() => __ID__;
public override void Serialize(ByteBuf _buf)
{

View File

@ -37,11 +37,11 @@ namespace {{x.namespace_with_top_module}}
{{~end~}}
{{~end~}}
}
public const int ID = {{x.id}};
public const int __ID__ = {{x.id}};
public override int GetTypeId()
{
return ID;
return __ID__;
}
public override void Serialize(ByteBuf _buf)

View File

@ -22,11 +22,11 @@ namespace {{x.namespace_with_top_module}}
{
}
public const int ID = {{x.id}};
public const int __ID__ = {{x.id}};
public override int GetTypeId()
{
return ID;
return __ID__;
}
public override void Reset()

View File

@ -7,11 +7,11 @@ namespace {{namespace}}
public static System.Collections.Generic.Dictionary<int, Bright.Net.Codecs.ProtocolCreator> Factories { get; } = new System.Collections.Generic.Dictionary<int, Bright.Net.Codecs.ProtocolCreator>
{
{{~ for proto in protos ~}}
[{{proto.full_name}}.ID] = () => new {{proto.full_name}}(),
[{{proto.full_name}}.__ID__] = () => new {{proto.full_name}}(),
{{~end~}}
{{~ for rpc in rpcs ~}}
[{{rpc.full_name}}.ID] = () => new {{rpc.full_name}}(),
[{{rpc.full_name}}.__ID__] = () => new {{rpc.full_name}}(),
{{~end~}}
};
}

View File

@ -36,8 +36,8 @@ export {{if x.is_abstract_type}} abstract {{end}} class {{name}} extends {{if pa
return _bean_
}
{{else}}
static readonly ID = {{x.id}}
getTypeId() { return {{name}}.ID }
static readonly __ID__ = {{x.id}}
getTypeId() { return {{name}}.__ID__ }
{{~end~}}

View File

@ -12,8 +12,8 @@
*/
{{~end~}}
export class {{name}} extends Protocol {
static readonly ID = {{x.id}}
getTypeId() { return {{name}}.ID }
static readonly __ID__ = {{x.id}}
getTypeId() { return {{name}}.__ID__ }
{{~ for field in fields ~}}

View File

@ -5,11 +5,11 @@
static readonly Factories = new Map<number, ProtocolFactory>([
{{~ for proto in protos ~}}
[{{proto.full_name}}.ID, () => new {{proto.full_name}}()],
[{{proto.full_name}}.__ID__, () => new {{proto.full_name}}()],
{{~end~}}
{{~ for rpc in rpcs ~}}
// TODO RPC .. [{{rpc.full_name}}.ID] = () => new {{rpc.full_name}}(),
// TODO RPC .. [{{rpc.full_name}}.__ID__] = () => new {{rpc.full_name}}(),
{{~end~}}
])
}