【调整】将多态类型id字段ID改名为__ID__,避免与常见的字段名ID冲突而产生编译错误
parent
f6b8b32123
commit
2034e8050f
|
|
@ -55,9 +55,9 @@ class {{name}} : public {{if parent_def_type}} {{parent_def_type.cpp_full_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~}}
|
||||||
|
|
||||||
virtual void resolve(::bright::HashMap<::bright::String, void*>& _tables);
|
virtual void resolve(::bright::HashMap<::bright::String, void*>& _tables);
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ namespace {{x.top_module}}
|
||||||
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.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~}}
|
{{~end~}}
|
||||||
default: { _out = nullptr; return false;}
|
default: { _out = nullptr; return false;}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ public {{x.cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{x.paren
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
@ -65,8 +65,8 @@ public {{x.cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{x.paren
|
||||||
{{~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)
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ public {{cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{parent}}
|
||||||
{
|
{
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
@ -50,10 +50,10 @@ public {{cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{parent}}
|
||||||
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~}}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,11 @@ public sealed class {{name}} : Bright.Net.Protocol
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
public const int ID = {{id}};
|
public const int __ID__ = {{id}};
|
||||||
|
|
||||||
public override int GetTypeId()
|
public override int GetTypeId()
|
||||||
{
|
{
|
||||||
return ID;
|
return __ID__;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Serialize(ByteBuf _buf)
|
public override void Serialize(ByteBuf _buf)
|
||||||
|
|
|
||||||
|
|
@ -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>
|
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~}}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,8 +74,8 @@ public {{x.cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{parent}
|
||||||
{{~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)
|
||||||
|
|
|
||||||
|
|
@ -75,8 +75,8 @@ public {{x.cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{parent}
|
||||||
{{~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)
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ public {{x.java_class_modifier}} class {{name}}{{if parent_def_type}} extends {{
|
||||||
public static {{name}} deserialize{{name}}(ByteBuf _buf) {
|
public static {{name}} deserialize{{name}}(ByteBuf _buf) {
|
||||||
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_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();
|
||||||
}
|
}
|
||||||
|
|
@ -70,10 +70,10 @@ public {{x.java_class_modifier}} class {{name}}{{if parent_def_type}} extends {{
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
|
|
||||||
{{~if !x.is_abstract_type && x.parent_def_type~}}
|
{{~if !x.is_abstract_type && x.parent_def_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__; }
|
||||||
{{~else if x.is_abstract_type && !x.parent_def_type~}}
|
{{~else if x.is_abstract_type && !x.parent_def_type~}}
|
||||||
public abstract int getTypeId();
|
public abstract int getTypeId();
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
|
|
|
||||||
|
|
@ -73,10 +73,10 @@ public {{x.java_class_modifier}} class {{name}}{{if parent_def_type}} extends {{
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
|
|
||||||
{{~if !x.is_abstract_type && x.parent_def_type~}}
|
{{~if !x.is_abstract_type && x.parent_def_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__; }
|
||||||
{{~else if x.is_abstract_type && !x.parent_def_type~}}
|
{{~else if x.is_abstract_type && !x.parent_def_type~}}
|
||||||
public abstract int getTypeId();
|
public abstract int getTypeId();
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ public {{x.cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{x.paren
|
||||||
{
|
{
|
||||||
case 0 : return null;
|
case 0 : return null;
|
||||||
{{~ for child in x.hierarchy_not_abstract_children~}}
|
{{~ 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~}}
|
{{~end~}}
|
||||||
default: throw new SerializationException();
|
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 const int __ID__ = {{x.id}};
|
||||||
public override int GetTypeId() => ID;
|
public override int GetTypeId() => __ID__;
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
|
|
||||||
protected override void InitChildrenRoot(BrightDB.Storage.TKey root)
|
protected override void InitChildrenRoot(BrightDB.Storage.TKey root)
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ public {{x.cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{x.paren
|
||||||
{
|
{
|
||||||
case 0 : return null;
|
case 0 : return null;
|
||||||
{{~ for child in x.hierarchy_not_abstract_children~}}
|
{{~ 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~}}
|
{{~end~}}
|
||||||
default: throw new SerializationException();
|
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 const int __ID__ = {{x.id}};
|
||||||
public override int GetTypeId() => ID;
|
public override int GetTypeId() => __ID__;
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
|
|
||||||
protected override void InitChildrenRoot(Bright.Storage.TKey root)
|
protected override void InitChildrenRoot(Bright.Storage.TKey root)
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ export {{x.ts_class_modifier}} class {{name}} extends {{if parent_def_type}} {{x
|
||||||
let x: {{name}}
|
let x: {{name}}
|
||||||
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: x = new {{child.full_name}}(); break
|
case {{child.full_name}}.__ID__: x = new {{child.full_name}}(); break
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
default: throw new Error()
|
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}}
|
static readonly __ID__ = {{x.id}}
|
||||||
getTypeId(): number { return {{name}}.ID }
|
getTypeId(): number { return {{name}}.__ID__ }
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
|
|
||||||
initChildrenRoot(root: TKey) {
|
initChildrenRoot(root: TKey) {
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ namespace {{x.namespace_with_top_module}}
|
||||||
{
|
{
|
||||||
case 0 : return null;
|
case 0 : return null;
|
||||||
{{~ for child in x.hierarchy_not_abstract_children~}}
|
{{~ 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~}}
|
{{~end~}}
|
||||||
default: throw new SerializationException();
|
default: throw new SerializationException();
|
||||||
}
|
}
|
||||||
|
|
@ -85,8 +85,8 @@ namespace {{x.namespace_with_top_module}}
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
|
|
||||||
{{~if !is_abstract_type~}}
|
{{~if !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__;
|
||||||
|
|
||||||
public override void Serialize(ByteBuf _buf)
|
public override void Serialize(ByteBuf _buf)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,11 @@ namespace {{x.namespace_with_top_module}}
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
public const int ID = {{x.id}};
|
public const int __ID__ = {{x.id}};
|
||||||
|
|
||||||
public override int GetTypeId()
|
public override int GetTypeId()
|
||||||
{
|
{
|
||||||
return ID;
|
return __ID__;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Serialize(ByteBuf _buf)
|
public override void Serialize(ByteBuf _buf)
|
||||||
|
|
|
||||||
|
|
@ -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()
|
public override int GetTypeId()
|
||||||
{
|
{
|
||||||
return ID;
|
return __ID__;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Reset()
|
public override void Reset()
|
||||||
|
|
|
||||||
|
|
@ -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>
|
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 ~}}
|
{{~ for proto in protos ~}}
|
||||||
[{{proto.full_name}}.ID] = () => new {{proto.full_name}}(),
|
[{{proto.full_name}}.__ID__] = () => new {{proto.full_name}}(),
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
|
|
||||||
{{~ for rpc in rpcs ~}}
|
{{~ for rpc in rpcs ~}}
|
||||||
[{{rpc.full_name}}.ID] = () => new {{rpc.full_name}}(),
|
[{{rpc.full_name}}.__ID__] = () => new {{rpc.full_name}}(),
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,8 @@ export {{if x.is_abstract_type}} abstract {{end}} class {{name}} extends {{if pa
|
||||||
return _bean_
|
return _bean_
|
||||||
}
|
}
|
||||||
{{else}}
|
{{else}}
|
||||||
static readonly ID = {{x.id}}
|
static readonly __ID__ = {{x.id}}
|
||||||
getTypeId() { return {{name}}.ID }
|
getTypeId() { return {{name}}.__ID__ }
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@
|
||||||
*/
|
*/
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
export class {{name}} extends Protocol {
|
export class {{name}} extends Protocol {
|
||||||
static readonly ID = {{x.id}}
|
static readonly __ID__ = {{x.id}}
|
||||||
getTypeId() { return {{name}}.ID }
|
getTypeId() { return {{name}}.__ID__ }
|
||||||
|
|
||||||
|
|
||||||
{{~ for field in fields ~}}
|
{{~ for field in fields ~}}
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@
|
||||||
static readonly Factories = new Map<number, ProtocolFactory>([
|
static readonly Factories = new Map<number, ProtocolFactory>([
|
||||||
|
|
||||||
{{~ for proto in protos ~}}
|
{{~ for proto in protos ~}}
|
||||||
[{{proto.full_name}}.ID, () => new {{proto.full_name}}()],
|
[{{proto.full_name}}.__ID__, () => new {{proto.full_name}}()],
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
|
|
||||||
{{~ for rpc in rpcs ~}}
|
{{~ 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~}}
|
{{~end~}}
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue