modified-attributes.conf: store attributes to modify in Internal.modified_attributes

This commit is contained in:
Alexander A. Klimov 2020-08-06 16:56:13 +02:00
parent a65f2d6b41
commit 9c00ae53b3
2 changed files with 8 additions and 10 deletions

View File

@ -36,7 +36,9 @@ INITIALIZE_ONCE_WITH_PRIORITY([]() {
l_StatsNS = new Namespace(true);
globalNS->Set("StatsFunctions", l_StatsNS, true);
globalNS->Set("Internal", new Namespace(), true);
Namespace::Ptr intNS = new Namespace();
intNS->Set("modified_attributes", new Dictionary(), true);
globalNS->Set("Internal", intNS, true);
}, InitializePriority::CreateNamespaces);
INITIALIZE_ONCE_WITH_PRIORITY([]() {

View File

@ -135,15 +135,11 @@ static void PersistModAttrHelper(AtomicFile& fp, ConfigObject::Ptr& previousObje
ConfigWriter::EmitRaw(fp, "\n}\n\n");
}
ConfigWriter::EmitRaw(fp, "var obj = ");
Array::Ptr args1 = new Array({
object->GetReflectionType()->GetName(),
object->GetName()
});
ConfigWriter::EmitFunctionCall(fp, "get_object", args1);
ConfigWriter::EmitRaw(fp, "\nif (obj) {\n");
ConfigWriter::EmitRaw(fp, "Internal.modified_attributes[");
ConfigWriter::EmitValue(fp, 0, object->GetReflectionType()->GetName());
ConfigWriter::EmitRaw(fp, "][");
ConfigWriter::EmitValue(fp, 0, object->GetName());
ConfigWriter::EmitRaw(fp, "] = obj => {\n");
}
ConfigWriter::EmitRaw(fp, "\tobj.");