Adhering to new metagen interface
This commit is contained in:
parent
945594c366
commit
6bd8abc39b
|
@ -157,7 +157,7 @@ function cs_type(\mtgType $type)
|
|||
else if($type instanceof \mtgArrType)
|
||||
return "List<" . cs_simple_type($type->getValue()) . ">";
|
||||
else
|
||||
throw new Exception("Unknown type '{$type}'");
|
||||
throw new Exception("Unknown type '{$type->getName()}'");
|
||||
}
|
||||
|
||||
function cs_simple_type(\mtgType $type)
|
||||
|
@ -197,7 +197,7 @@ function cs_simple_type(\mtgType $type)
|
|||
}
|
||||
throw new Exception("Unknown type '{$type}'");
|
||||
}
|
||||
if($type->hasToken("bhl_native_class"))
|
||||
if($type instanceof \mtgUserType && $type->hasToken("bhl_native_class"))
|
||||
return $type->getToken("bhl_native_class");
|
||||
return $type->getName();
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ function cs_type_prefix(\mtgType $type)
|
|||
case "blob":
|
||||
return "Blob";
|
||||
default:
|
||||
throw new Exception("Unknown type '{$type}'");
|
||||
throw new Exception("Unknown type '{$type->getName()}'");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -311,7 +311,7 @@ function var_reset($name, \mtgType $type, $default = null)
|
|||
}
|
||||
else if($type instanceof \mtgArrType)
|
||||
{
|
||||
$str = "MetaSync.ClearList(ref $name);";
|
||||
$str = "MetaIO.ClearList(ref $name);";
|
||||
|
||||
if($default)
|
||||
{
|
||||
|
@ -349,9 +349,9 @@ function var_reset($name, \mtgType $type, $default = null)
|
|||
{
|
||||
$is_pod = $type->hasToken('POD');
|
||||
if($is_pod)
|
||||
$str .= "$name.reset(); ";
|
||||
$str .= "$name.Reset(); ";
|
||||
else
|
||||
$str .= "MetaSync.Reset(ref $name); ";
|
||||
$str .= "MetaIO.Reset(ref $name); ";
|
||||
}
|
||||
|
||||
if($default)
|
||||
|
@ -372,7 +372,7 @@ function var_reset($name, \mtgType $type, $default = null)
|
|||
}
|
||||
}
|
||||
else
|
||||
throw new Exception("Bad type '$type'");
|
||||
throw new Exception("Bad type '{$type->getName()}'");
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
@ -388,39 +388,39 @@ function var_sync($fname, \mtgType $type, $buf, array $tokens, $opts)
|
|||
$str = '';
|
||||
if($type instanceof \mtgBuiltinType)
|
||||
{
|
||||
$str .= "MetaSync.Sync({$buf}, ref {$fname}, \"{$key_name}\", {$opts});\n";
|
||||
$str .= "MetaIO.Sync({$buf}, ref {$fname}, \"{$key_name}\", {$opts});\n";
|
||||
}
|
||||
else if($type instanceof \mtgMetaStruct)
|
||||
{
|
||||
if(array_key_exists('virtual', $tokens))
|
||||
$str .= "{$fname} = MetaSync.SyncGeneric({$buf}, {$fname}, \"{$key_name}\", {$opts});\n";
|
||||
$str .= "{$fname} = MetaIO.SyncGeneric({$buf}, {$fname}, \"{$key_name}\", {$opts});\n";
|
||||
else
|
||||
$str .= "MetaSync.Sync({$buf}, ref {$fname}, \"{$key_name}\", {$opts});\n";
|
||||
$str .= "MetaIO.Sync({$buf}, ref {$fname}, \"{$key_name}\", {$opts});\n";
|
||||
}
|
||||
else if($type instanceof \mtgMetaEnum)
|
||||
{
|
||||
$str .= "int __tmp_{$fname} = (int)$fname;\n";
|
||||
$str .= "MetaSync.Sync({$buf}, ref __tmp_{$fname}, \"{$key_name}\", {$opts});\n";
|
||||
$str .= "MetaIO.Sync({$buf}, ref __tmp_{$fname}, \"{$key_name}\", {$opts});\n";
|
||||
$str .= "if($buf.is_read) {$fname} = ({$type->getName()})__tmp_{$fname};\n";
|
||||
}
|
||||
else if($type instanceof \mtgArrType)
|
||||
{
|
||||
if(array_key_exists('virtual', $tokens))
|
||||
$str .= "MetaSync.SyncGeneric({$buf}, {$fname}, \"{$key_name}\", {$opts});\n";
|
||||
$str .= "MetaIO.SyncGeneric({$buf}, {$fname}, \"{$key_name}\", {$opts});\n";
|
||||
else
|
||||
{
|
||||
if($type->getValue() instanceof \mtgMetaEnum)
|
||||
{
|
||||
$str .= "MetaSync.tmp_enums_list.Clear(); if(!{$buf}.is_read) { foreach(var _enum_tmp in {$fname}) MetaSync.tmp_enums_list.Add((int)_enum_tmp); }\n";
|
||||
$str .= "MetaSync.Sync({$buf}, MetaSync.tmp_enums_list, \"{$key_name}\", {$opts});\n";
|
||||
$str .= "if({$buf}.is_read) foreach(var _int_tmp in MetaSync.tmp_enums_list) { {$fname}.Add(({$type->getValue()->getName()}) _int_tmp); }\n";
|
||||
$str .= "MetaIO.tmp_enums_list.Clear(); if(!{$buf}.is_read) { foreach(var _enum_tmp in {$fname}) MetaIO.tmp_enums_list.Add((int)_enum_tmp); }\n";
|
||||
$str .= "MetaIO.Sync({$buf}, MetaIO.tmp_enums_list, \"{$key_name}\", {$opts});\n";
|
||||
$str .= "if({$buf}.is_read) foreach(var _int_tmp in MetaIO.tmp_enums_list) { {$fname}.Add(({$type->getValue()->getName()}) _int_tmp); }\n";
|
||||
}
|
||||
else
|
||||
$str .= "MetaSync.Sync({$buf}, {$fname}, \"{$key_name}\", {$opts});\n";
|
||||
$str .= "MetaIO.Sync({$buf}, {$fname}, \"{$key_name}\", {$opts});\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
throw new Exception("Unknown type '$type'");
|
||||
throw new Exception("Unknown type '{$type->getName()}'");
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
|
|
@ -44,11 +44,11 @@ public {{_self.struct_type(o)}} {{o.name}} {{_self.base_struct_class(o)}}
|
|||
{{_self.comment_POD_begin(o)}}
|
||||
public {{o.name}}()
|
||||
{
|
||||
reset();
|
||||
Reset();
|
||||
}
|
||||
{{_self.comment_POD_end(o)}}
|
||||
|
||||
public {{_self.override(o)}} void reset()
|
||||
public {{_self.override(o)}} void Reset()
|
||||
{
|
||||
{{_self.struct_fields_reset(o)}}
|
||||
}
|
||||
|
@ -56,10 +56,10 @@ public {{_self.struct_type(o)}} {{o.name}} {{_self.base_struct_class(o)}}
|
|||
{{_self.comment_non_cloneable_begin(o)}}
|
||||
public void CloneTo(ref {{o.name}} dst)
|
||||
{
|
||||
MetaSync.Clone(this, ref dst, AutogenBundle.createById);
|
||||
MetaIO.Clone(this, ref dst, AutogenBundle.createById);
|
||||
}
|
||||
|
||||
public {{_self.virtual_clone(o)}} IMetaStruct clone()
|
||||
public {{_self.virtual_clone(o)}} IMetaStruct Clone()
|
||||
{
|
||||
var dst = new {{o.name}}();
|
||||
CloneTo(ref dst);
|
||||
|
@ -67,22 +67,22 @@ public {{_self.struct_type(o)}} {{o.name}} {{_self.base_struct_class(o)}}
|
|||
}
|
||||
{{_self.comment_non_cloneable_end(o)}}
|
||||
|
||||
public {{_self.override(o)}} void syncFields(MetaSyncContext ctx)
|
||||
public {{_self.override(o)}} void SyncFields(MetaSyncContext ctx)
|
||||
{
|
||||
{{_self.sync_fields(o)}}
|
||||
}
|
||||
|
||||
public {{_self.override(o)}} int getFieldsCount()
|
||||
public {{_self.override(o)}} int GetFieldsCount()
|
||||
{
|
||||
return {{fields_count(o)}};
|
||||
}
|
||||
|
||||
public {{_self.override(o)}} int getDirtyFieldsCount()
|
||||
public {{_self.override(o)}} int GetDirtyFieldsCount()
|
||||
{
|
||||
{%~ if has_token(o, 'bitfields') ~%}
|
||||
return fields_mask.GetDirtyFieldsCount();
|
||||
{% else %}
|
||||
return getFieldsCount();
|
||||
return GetFieldsCount();
|
||||
{%- endif ~%}
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ public {{f.type|cs_type|obscure_type(f)}} {{f.name}} {% if not has_token(o, 'POD
|
|||
|
||||
{% macro struct_fields_reset(o) %}
|
||||
{%- if o.parent ~%}
|
||||
base.reset();
|
||||
base.Reset();
|
||||
{%- endif -%}
|
||||
{%- for f in o.fields ~%}
|
||||
{{var_reset(f.name, f.type, token_or(f, 'default', null))}}
|
||||
|
@ -254,11 +254,11 @@ override
|
|||
|
||||
{%- macro sync_fields(o) -%}
|
||||
{%- if has_token(o, 'bitfields') ~%}
|
||||
var bitctx = new MetaSync.BitfieldsContext(ctx, fields_mask);
|
||||
var bitctx = new MetaIO.BitfieldsContext(ctx, fields_mask);
|
||||
bitctx.SyncMaskHeader();
|
||||
{%- endif -%}
|
||||
{%- if o.parent ~%}
|
||||
base.syncFields(ctx);
|
||||
base.SyncFields(ctx);
|
||||
{%- endif -%}
|
||||
{%- for f in o.fields ~%}
|
||||
{{var_sync(f.name, f.type, 'ctx', f.tokens, get_sync_opts(o, 'bitctx'))}}
|
||||
|
@ -276,7 +276,7 @@ base.syncFields(ctx);
|
|||
{
|
||||
{%- for f in o.fields ~%}
|
||||
{%- if is_primary_field(o, f) ~%}
|
||||
MetaSync.SetFieldDirty(ref fields_mask, {{loop.index0}});
|
||||
MetaIO.SetFieldDirty(ref fields_mask, {{loop.index0}});
|
||||
{%- endif -%}
|
||||
{%- endfor ~%}
|
||||
}
|
||||
|
@ -328,27 +328,27 @@ public class {{o.name}} : IRpc
|
|||
public {{o.req.name}} req = new {{o.req.name}}();
|
||||
public {{o.rsp.name}} rsp = new {{o.rsp.name}}();
|
||||
|
||||
public int getCode()
|
||||
public int GetCode()
|
||||
{
|
||||
return {{o.code}};
|
||||
}
|
||||
|
||||
public void setError(IRpcError error)
|
||||
public void SetError(IRpcError error)
|
||||
{
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
public IRpcError getError()
|
||||
public IRpcError GetError()
|
||||
{
|
||||
return error;
|
||||
}
|
||||
|
||||
public IMetaStruct getRequest()
|
||||
public IMetaStruct GetRequest()
|
||||
{
|
||||
return req as IMetaStruct;
|
||||
}
|
||||
|
||||
public IMetaStruct getResponse()
|
||||
public IMetaStruct GetResponse()
|
||||
{
|
||||
return rsp as IMetaStruct;
|
||||
}
|
||||
|
@ -361,9 +361,9 @@ public class {{o.name}} : IRpc
|
|||
public bool GetDiff({{o.name}} old, {{o.name}} diff = null, {{o.name}}RemovedIds removed = null)
|
||||
{
|
||||
if(diff != null)
|
||||
diff.reset();
|
||||
diff.Reset();
|
||||
if(removed != null)
|
||||
removed.reset();
|
||||
removed.Reset();
|
||||
bool no_changes = true;
|
||||
|
||||
{% set field_idx = -1 %}
|
||||
|
@ -452,9 +452,9 @@ public class {{o.name}} : IRpc
|
|||
}
|
||||
|
||||
//if(changed.Count > 0)
|
||||
// MetaSync.LogDebug("Changed in collection {{u.name}}");
|
||||
// MetaIO.LogDebug("Changed in collection {{u.name}}");
|
||||
//if(removed_ids.Count > 0)
|
||||
// MetaSync.LogDebug("Removed in collection {{u.name}}");
|
||||
// MetaIO.LogDebug("Removed in collection {{u.name}}");
|
||||
|
||||
return has_diff;
|
||||
}
|
||||
|
@ -511,7 +511,7 @@ public class {{o.name}} : IRpc
|
|||
!= (b.{{f.name}} == null ? "" : b.{{f.name}}))
|
||||
{% if has_token(o, 'bitfields') ~%}
|
||||
{
|
||||
MetaSync.SetFieldDirty(ref a.fields_mask, {{field_idx}});
|
||||
MetaIO.SetFieldDirty(ref a.fields_mask, {{field_idx}});
|
||||
is_equal = false;
|
||||
}
|
||||
{% else ~%}
|
||||
|
@ -521,7 +521,7 @@ public class {{o.name}} : IRpc
|
|||
if(a.{{f.name}} != b.{{f.name}})
|
||||
{% if has_token(o, 'bitfields') ~%}
|
||||
{
|
||||
MetaSync.SetFieldDirty(ref a.fields_mask, {{field_idx}});
|
||||
MetaIO.SetFieldDirty(ref a.fields_mask, {{field_idx}});
|
||||
is_equal = false;
|
||||
}
|
||||
{% else ~%}
|
||||
|
@ -546,7 +546,7 @@ public class {{o.name}} : IRpc
|
|||
if(diff != null)
|
||||
{
|
||||
diff.{{f.name}} = __tmp;
|
||||
MetaSync.SetFieldDirty(ref diff.fields_mask, {{field_idx}});
|
||||
MetaIO.SetFieldDirty(ref diff.fields_mask, {{field_idx}});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -562,9 +562,9 @@ public class {{o.name}} : IRpc
|
|||
{
|
||||
no_changes &= false;
|
||||
if(diff != null)
|
||||
MetaSync.SetFieldDirty(ref diff.fields_mask, {{field_idx}});
|
||||
MetaIO.SetFieldDirty(ref diff.fields_mask, {{field_idx}});
|
||||
if(removed != null && removed.{{f.name}}.Count > 0)
|
||||
MetaSync.SetFieldDirty(ref removed.fields_mask, {{field_idx}});
|
||||
MetaIO.SetFieldDirty(ref removed.fields_mask, {{field_idx}});
|
||||
}
|
||||
{% elseif f.type is instanceof('\\mtgBuiltinType') %}
|
||||
if(diff != null)
|
||||
|
@ -574,7 +574,7 @@ public class {{o.name}} : IRpc
|
|||
{
|
||||
no_changes &= false;
|
||||
if(diff != null)
|
||||
MetaSync.SetFieldDirty(ref diff.fields_mask, {{field_idx}});
|
||||
MetaIO.SetFieldDirty(ref diff.fields_mask, {{field_idx}});
|
||||
}
|
||||
{% else %}
|
||||
Error("Diff for field '"~ f.name ~"' is not supported");
|
||||
|
|
Loading…
Reference in New Issue