diff options
author | Mark Spruiell <mes@zeroc.com> | 2006-12-05 01:10:47 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2006-12-05 01:10:47 +0000 |
commit | a20c5e42adb986c4ef3d715a6350479ca8e94b08 (patch) | |
tree | f9bfa54df8dd9d3ea41814981318296143087107 /cpp/src/FreezeScript/TransformAnalyzer.cpp | |
parent | More cleanup (diff) | |
download | ice-a20c5e42adb986c4ef3d715a6350479ca8e94b08.tar.bz2 ice-a20c5e42adb986c4ef3d715a6350479ca8e94b08.tar.xz ice-a20c5e42adb986c4ef3d715a6350479ca8e94b08.zip |
bug 1517: use catalog in FreezeScript tools
Diffstat (limited to 'cpp/src/FreezeScript/TransformAnalyzer.cpp')
-rw-r--r-- | cpp/src/FreezeScript/TransformAnalyzer.cpp | 88 |
1 files changed, 56 insertions, 32 deletions
diff --git a/cpp/src/FreezeScript/TransformAnalyzer.cpp b/cpp/src/FreezeScript/TransformAnalyzer.cpp index 359054bfdc3..20cbbbde639 100644 --- a/cpp/src/FreezeScript/TransformAnalyzer.cpp +++ b/cpp/src/FreezeScript/TransformAnalyzer.cpp @@ -27,8 +27,9 @@ class AnalyzeTransformVisitor : public ParserVisitor { public: - AnalyzeTransformVisitor(XMLOutput&, const UnitPtr&, const TypePtr&, const TypePtr&, const TypePtr&, const TypePtr&, - bool, vector<string>&, vector<string>&); + AnalyzeTransformVisitor(XMLOutput&, const UnitPtr&, bool, vector<string>&, vector<string>&); + + void addDatabase(const string&, const TypePtr&, const TypePtr&, const TypePtr&, const TypePtr&); virtual bool visitClassDefStart(const ClassDefPtr&); virtual bool visitStructStart(const StructPtr&); @@ -81,42 +82,58 @@ private: //////////////////////////////////// FreezeScript::AnalyzeTransformVisitor::AnalyzeTransformVisitor(XMLOutput& out, const UnitPtr& newUnit, - const TypePtr& oldKey, const TypePtr& newKey, - const TypePtr& oldValue, const TypePtr& newValue, bool ignoreTypeChanges, vector<string>& missingTypes, vector<string>& errors) : _out(out), _newUnit(newUnit), _ignoreTypeChanges(ignoreTypeChanges), _missingTypes(missingTypes), _errors(errors) { - out << se("database"); +} + +void +FreezeScript::AnalyzeTransformVisitor::addDatabase(const string& name, const TypePtr& oldKey, const TypePtr& newKey, + const TypePtr& oldValue, const TypePtr& newValue) +{ + _out << "\n"; + _out << se("database"); - string oldKeyName = typeToString(oldKey); - string newKeyName = typeToString(newKey); + if(!name.empty()) + { + _out << attr("name", name); + } + + string oldKeyName = oldKey ? typeToString(oldKey) : "UNKNOWN"; + string newKeyName = newKey ? typeToString(newKey) : "UNKNOWN"; if(oldKeyName == newKeyName) { - out << attr("key", oldKeyName); + _out << attr("key", oldKeyName); } else { - out << attr("key", oldKeyName + "," + newKeyName); + _out << attr("key", oldKeyName + "," + newKeyName); } - string oldValueName = typeToString(oldValue); - string newValueName = typeToString(newValue); + string oldValueName = oldValue ? typeToString(oldValue) : "UNKNOWN"; + string newValueName = newValue ? typeToString(newValue) : "UNKNOWN"; if(oldValueName == newValueName) { - out << attr("value", oldValueName); + _out << attr("value", oldValueName); } else { - out << attr("value", oldValueName + "," + newValueName); + _out << attr("value", oldValueName + "," + newValueName); } - out << se("record"); - compareTypes("database key", oldKey, newKey); - compareTypes("database value", oldValue, newValue); - out << ee; + _out << se("record"); + if(oldKey && newKey) + { + compareTypes("database key", oldKey, newKey); + } + if(oldValue && newValue) + { + compareTypes("database value", oldValue, newValue); + } + _out << ee; - out << ee; + _out << ee; } bool @@ -1112,27 +1129,34 @@ FreezeScript::AnalyzeInitVisitor::typeChange(const TypePtr& t, const string& sco } FreezeScript::TransformAnalyzer::TransformAnalyzer(const UnitPtr& oldUnit, const UnitPtr& newUnit, - bool ignoreTypeChanges) : - _old(oldUnit), _new(newUnit), _ignoreTypeChanges(ignoreTypeChanges) + bool ignoreTypeChanges, ostream& os, vector<string>& missingTypes, + vector<string>& errors) : + _old(oldUnit), _new(newUnit), _out(os), + _visitor(new AnalyzeTransformVisitor(_out, newUnit, ignoreTypeChanges, missingTypes, errors)) { + _out << se("transformdb"); } -void -FreezeScript::TransformAnalyzer::analyze(const TypePtr& oldKey, const TypePtr& newKey, const TypePtr& oldValue, - const TypePtr& newValue, ostream& os, vector<string>& missingTypes, - vector<string>& errors) +FreezeScript::TransformAnalyzer::~TransformAnalyzer() { - XMLOutput out(os); + delete _visitor; +} - out << se("transformdb"); +void +FreezeScript::TransformAnalyzer::addDatabase(const string& name, const TypePtr& oldKey, const TypePtr& newKey, + const TypePtr& oldValue, const TypePtr& newValue) +{ + _visitor->addDatabase(name, oldKey, newKey, oldValue, newValue); +} - AnalyzeTransformVisitor transformVisitor(out, _new, oldKey, newKey, oldValue, newValue, _ignoreTypeChanges, - missingTypes, errors); - _old->visit(&transformVisitor, false); +void +FreezeScript::TransformAnalyzer::finish() +{ + _old->visit(_visitor, false); - AnalyzeInitVisitor initVisitor(out, _old); + AnalyzeInitVisitor initVisitor(_out, _old); _new->visit(&initVisitor, false); - out << ee; - out << '\n'; + _out << ee; + _out << '\n'; } |