Using latest implementation of fields mask

This commit is contained in:
Pavel Shevaev 2022-12-08 18:42:58 +03:00
parent 94d6696f02
commit 125b81db18
1 changed files with 16 additions and 17 deletions

View File

@ -85,8 +85,7 @@ public {{_self.struct_type(o)}} {{o.name}} {{_self.base_struct_class(o)}}
public {{_self.override(o)}} int getWritableFieldsCount()
{
{%~ if has_token(o, 'bitfields') ~%}
return Meta.GetDirtyFieldsCount(fields_mask, fields_count: {{fields_count(o)}})
+ Meta.MASK_HEADER_FIELDS_COUNT;
return fields_mask.GetDirtyFieldsCount() + Meta.MASK_HEADER_FIELDS_COUNT;
{% else %}
return {{fields_count(o)}};
{%- endif ~%}
@ -118,7 +117,7 @@ public {{_self.struct_type(o)}} {{o.name}} {{_self.base_struct_class(o)}}
{%- macro decl_struct_fields(o) -%}
{%- if has_token(o, 'bitfields') ~%}
public long fields_mask;
public FieldsMask fields_mask;
{%- endif -%}
{%- for f in o.fields ~%}
{{_self.decl_struct_field(o, f)}}
@ -146,7 +145,7 @@ base.reset();
{{var_reset(f.name, f.type, token_or(f, 'default', null))}}
{%- endfor -%}
{%- if has_token(o, 'bitfields') ~%}
fields_mask = 0L;
ResetFieldMask();
{%- endif -%}
{% endmacro %}
@ -236,7 +235,7 @@ base.syncFields(ctx);
public void ResetFieldMask()
{
fields_mask = 0L;
fields_mask = FieldsMask.MakeClean(fields_amount: {{fields_count(o)}});
}
public void SetPrimaryFieldsChanged()
@ -250,27 +249,27 @@ base.syncFields(ctx);
public void SetDirtyMask()
{
fields_mask = ~0L;
fields_mask = FieldsMask.MakeDirty(fields_amount: {{fields_count(o)}});
}
public void SetDirtyMaskDeep()
{
SetDirtyMask();
public void SetDirtyMaskDeep()
{
SetDirtyMask();
{%- for f in o.fields ~%}
{%- if f.type is instanceof('\\mtgMetaStruct') and has_token(f.type, 'bitfields') ~%}
{{f.name}}.SetDirtyMaskDeep();
{{f.name}}.SetDirtyMaskDeep();
{%- elseif f.type is instanceof('\\mtgArrType') and f.type.value is instanceof('\\mtgMetaStruct') and has_token(f.type.value, "bitfields") ~%}
{
for(int i=0;i<{{f.name}}.Count;++i)
{
for(int i=0;i<{{f.name}}.Count;++i)
{
var __tmp = {{f.name}}[i];
__tmp.SetDirtyMaskDeep();
{{f.name}}[i] = __tmp;
}
var __tmp = {{f.name}}[i];
__tmp.SetDirtyMaskDeep();
{{f.name}}[i] = __tmp;
}
}
{%- endif -%}
{%- endfor ~%}
}
}
{%- endmacro -%}