summaryrefslogtreecommitdiff
path: root/cpp/src/FreezeScript
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/FreezeScript')
-rw-r--r--cpp/src/FreezeScript/Data.cpp44
-rw-r--r--cpp/src/FreezeScript/DumpDB.cpp268
-rw-r--r--cpp/src/FreezeScript/DumpDescriptors.cpp24
-rw-r--r--cpp/src/FreezeScript/DumpDescriptors.h2
-rw-r--r--cpp/src/FreezeScript/Functions.cpp4
-rw-r--r--cpp/src/FreezeScript/Functions.h2
-rw-r--r--cpp/src/FreezeScript/TransformAnalyzer.cpp20
-rw-r--r--cpp/src/FreezeScript/TransformAnalyzer.h4
-rw-r--r--cpp/src/FreezeScript/Transformer.cpp82
-rw-r--r--cpp/src/FreezeScript/Transformer.h6
-rw-r--r--cpp/src/FreezeScript/Util.cpp42
-rw-r--r--cpp/src/FreezeScript/transformdb.cpp738
12 files changed, 618 insertions, 618 deletions
diff --git a/cpp/src/FreezeScript/Data.cpp b/cpp/src/FreezeScript/Data.cpp
index 3c4050f03ee..cc51a8a2d0e 100644
--- a/cpp/src/FreezeScript/Data.cpp
+++ b/cpp/src/FreezeScript/Data.cpp
@@ -2494,28 +2494,28 @@ FreezeScript::ObjectFactory::create(const string& id)
if(_factory)
{
- if(id == Ice::Object::ice_staticId())
- {
- result = new ObjectReader(_factory, _unit->builtin(Slice::Builtin::KindObject));
- }
- else
- {
- Slice::TypeList l = _unit->lookupTypeNoBuiltin(id);
- if(!l.empty())
- {
- Slice::ClassDeclPtr decl = Slice::ClassDeclPtr::dynamicCast(l.front());
- if(!decl)
- {
- _factory->getErrorReporter()->error("Slice definition for `" + id + "' is not a class");
- }
- Slice::ClassDefPtr def = decl->definition();
- if(!def)
- {
- _factory->getErrorReporter()->error("no class definition for `" + id + "'");
- }
- result = new ObjectReader(_factory, decl);
- }
- }
+ if(id == Ice::Object::ice_staticId())
+ {
+ result = new ObjectReader(_factory, _unit->builtin(Slice::Builtin::KindObject));
+ }
+ else
+ {
+ Slice::TypeList l = _unit->lookupTypeNoBuiltin(id);
+ if(!l.empty())
+ {
+ Slice::ClassDeclPtr decl = Slice::ClassDeclPtr::dynamicCast(l.front());
+ if(!decl)
+ {
+ _factory->getErrorReporter()->error("Slice definition for `" + id + "' is not a class");
+ }
+ Slice::ClassDefPtr def = decl->definition();
+ if(!def)
+ {
+ _factory->getErrorReporter()->error("no class definition for `" + id + "'");
+ }
+ result = new ObjectReader(_factory, decl);
+ }
+ }
}
return result;
diff --git a/cpp/src/FreezeScript/DumpDB.cpp b/cpp/src/FreezeScript/DumpDB.cpp
index de79afd89a3..dc08bfcbda9 100644
--- a/cpp/src/FreezeScript/DumpDB.cpp
+++ b/cpp/src/FreezeScript/DumpDB.cpp
@@ -54,7 +54,7 @@ class DescriptorHandler : public IceXML::Handler
public:
DescriptorHandler(const DataFactoryPtr&, const Slice::UnitPtr&, const ErrorReporterPtr&,
- const FreezeScript::ObjectFactoryPtr&);
+ const FreezeScript::ObjectFactoryPtr&);
virtual void startElement(const std::string&, const IceXML::Attributes&, int, int);
virtual void endElement(const std::string&, int, int);
@@ -108,13 +108,13 @@ printCatalogData(const string& dbName, const Freeze::CatalogData& data)
cout << dbName << ": ";
if(data.evictor)
{
- cout << "Evictor database" << endl;
+ cout << "Evictor database" << endl;
}
else
{
- cout << "Map database" << endl;
- cout << " key type = " << data.key << endl;
- cout << " value type = " << data.value << endl;
+ cout << "Map database" << endl;
+ cout << " key type = " << data.key << endl;
+ cout << " value type = " << data.value << endl;
}
}
@@ -159,98 +159,98 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
}
catch(const IceUtil::BadOptException& e)
{
- cerr << argv[0] << ": " << e.reason << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ cerr << argv[0] << ": " << e.reason << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(opts.isSet("h"))
{
- usage(argv[0]);
- return EXIT_SUCCESS;
+ usage(argv[0]);
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
if(opts.isSet("c"))
{
- if(args.empty())
- {
- cerr << argv[0] << ": no database environment specified." << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- else if(args.size() > 2)
- {
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- try
- {
- FreezeScript::CatalogDataMap catalog = FreezeScript::readCatalog(communicator, args[0]);
- if(args.size() == 1)
- {
- if(catalog.empty())
- {
- cout << "Catalog is empty." << endl;
- }
- else
- {
- cout << "Catalog contents:" << endl;
- for(FreezeScript::CatalogDataMap::const_iterator p = catalog.begin(); p != catalog.end(); ++p)
- {
- cout << endl;
- printCatalogData(p->first, p->second);
- }
- }
- }
- else
- {
- FreezeScript::CatalogDataMap::const_iterator p = catalog.find(args[1]);
- if(p == catalog.end())
- {
- cerr << argv[0] << ": database `" << args[1] << "' not found in environment `" << args[0] << "'."
- << endl;
- return EXIT_FAILURE;
- }
- else
- {
- printCatalogData(p->first, p->second);
- }
- }
- return EXIT_SUCCESS;
- }
- catch(const FreezeScript::FailureException& ex)
- {
- cerr << argv[0] << ": " << ex.reason() << endl;
- return EXIT_FAILURE;
- }
+ if(args.empty())
+ {
+ cerr << argv[0] << ": no database environment specified." << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ else if(args.size() > 2)
+ {
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ try
+ {
+ FreezeScript::CatalogDataMap catalog = FreezeScript::readCatalog(communicator, args[0]);
+ if(args.size() == 1)
+ {
+ if(catalog.empty())
+ {
+ cout << "Catalog is empty." << endl;
+ }
+ else
+ {
+ cout << "Catalog contents:" << endl;
+ for(FreezeScript::CatalogDataMap::const_iterator p = catalog.begin(); p != catalog.end(); ++p)
+ {
+ cout << endl;
+ printCatalogData(p->first, p->second);
+ }
+ }
+ }
+ else
+ {
+ FreezeScript::CatalogDataMap::const_iterator p = catalog.find(args[1]);
+ if(p == catalog.end())
+ {
+ cerr << argv[0] << ": database `" << args[1] << "' not found in environment `" << args[0] << "'."
+ << endl;
+ return EXIT_FAILURE;
+ }
+ else
+ {
+ printCatalogData(p->first, p->second);
+ }
+ }
+ return EXIT_SUCCESS;
+ }
+ catch(const FreezeScript::FailureException& ex)
+ {
+ cerr << argv[0] << ": " << ex.reason() << endl;
+ return EXIT_FAILURE;
+ }
}
if(opts.isSet("D"))
{
- vector<string> optargs = opts.argVec("D");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- cppArgs += " -D" + *i;
- }
+ vector<string> optargs = opts.argVec("D");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ cppArgs += " -D" + *i;
+ }
}
if(opts.isSet("U"))
{
- vector<string> optargs = opts.argVec("U");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- cppArgs += " -U" + *i;
- }
+ vector<string> optargs = opts.argVec("U");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ cppArgs += " -U" + *i;
+ }
}
if(opts.isSet("I"))
{
- vector<string> optargs = opts.argVec("I");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- cppArgs += " -I" + *i;
- }
+ vector<string> optargs = opts.argVec("I");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ cppArgs += " -I" + *i;
+ }
}
debug = opts.isSet("debug");
@@ -258,32 +258,32 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
if(opts.isSet("o"))
{
- outputFile = opts.optArg("o");
+ outputFile = opts.optArg("o");
}
if(opts.isSet("f"))
{
- inputFile = opts.optArg("f");
+ inputFile = opts.optArg("f");
}
if(opts.isSet("load"))
{
vector<string> optArgs = opts.argVec("load");
- for(vector<string>::const_iterator i = optArgs.begin(); i != optArgs.end(); ++i)
- {
- slice.push_back(*i);
- }
+ for(vector<string>::const_iterator i = optArgs.begin(); i != optArgs.end(); ++i)
+ {
+ slice.push_back(*i);
+ }
}
evictor = opts.isSet("e");
if(opts.isSet("key"))
{
- keyTypeName = opts.optArg("key");
+ keyTypeName = opts.optArg("key");
}
if(opts.isSet("value"))
{
- valueTypeName = opts.optArg("value");
+ valueTypeName = opts.optArg("value");
}
if(opts.isSet("select"))
{
- selectExpr = opts.optArg("select");
+ selectExpr = opts.optArg("select");
}
caseSensitive = opts.isSet("case-sensitive");
@@ -328,55 +328,55 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
string descriptors;
if(inputFile.empty())
{
- const string evictorKeyTypeName = "::Ice::Identity";
- const string evictorValueTypeName = "::Freeze::ObjectRecord";
-
- if((!keyTypeName.empty() && valueTypeName.empty()) || (keyTypeName.empty() && !valueTypeName.empty()))
- {
- cerr << argv[0] << ": a key type and a value type must be specified" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- else if(!evictor && keyTypeName.empty() && valueTypeName.empty())
- {
- try
- {
- FreezeScript::CatalogDataMap catalog = FreezeScript::readCatalog(communicator, dbEnvName);
- FreezeScript::CatalogDataMap::iterator p = catalog.find(dbName);
- if(p == catalog.end())
- {
- cerr << argv[0] << ": database `" << dbName << "' not found in catalog." << endl;
- cerr << "Current catalog databases:" << endl;
- for(p = catalog.begin(); p != catalog.end(); ++p)
- {
- cerr << " " << p->first << endl;
- }
- return EXIT_FAILURE;
- }
- else
- {
- if(p->second.evictor)
- {
- evictor = true;
- }
- else
- {
- keyTypeName = p->second.key;
- valueTypeName = p->second.value;
- }
- }
- }
- catch(const FreezeScript::FailureException& ex)
- {
- cerr << argv[0] << ": " << ex.reason() << endl;
- return EXIT_FAILURE;
- }
- }
+ const string evictorKeyTypeName = "::Ice::Identity";
+ const string evictorValueTypeName = "::Freeze::ObjectRecord";
+
+ if((!keyTypeName.empty() && valueTypeName.empty()) || (keyTypeName.empty() && !valueTypeName.empty()))
+ {
+ cerr << argv[0] << ": a key type and a value type must be specified" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ else if(!evictor && keyTypeName.empty() && valueTypeName.empty())
+ {
+ try
+ {
+ FreezeScript::CatalogDataMap catalog = FreezeScript::readCatalog(communicator, dbEnvName);
+ FreezeScript::CatalogDataMap::iterator p = catalog.find(dbName);
+ if(p == catalog.end())
+ {
+ cerr << argv[0] << ": database `" << dbName << "' not found in catalog." << endl;
+ cerr << "Current catalog databases:" << endl;
+ for(p = catalog.begin(); p != catalog.end(); ++p)
+ {
+ cerr << " " << p->first << endl;
+ }
+ return EXIT_FAILURE;
+ }
+ else
+ {
+ if(p->second.evictor)
+ {
+ evictor = true;
+ }
+ else
+ {
+ keyTypeName = p->second.key;
+ valueTypeName = p->second.value;
+ }
+ }
+ }
+ catch(const FreezeScript::FailureException& ex)
+ {
+ cerr << argv[0] << ": " << ex.reason() << endl;
+ return EXIT_FAILURE;
+ }
+ }
if(evictor)
{
- keyTypeName = evictorKeyTypeName;
- valueTypeName = evictorValueTypeName;
+ keyTypeName = evictorKeyTypeName;
+ valueTypeName = evictorValueTypeName;
}
Slice::TypePtr keyType, valueType;
@@ -744,7 +744,7 @@ FreezeScript::SliceVisitor::visitEnum(const Slice::EnumPtr& v)
//
FreezeScript::DescriptorHandler::DescriptorHandler(const DataFactoryPtr& factory, const Slice::UnitPtr& unit,
const ErrorReporterPtr& errorReporter,
- const FreezeScript::ObjectFactoryPtr& objectFactory) :
+ const FreezeScript::ObjectFactoryPtr& objectFactory) :
_factory(factory), _unit(unit), _errorReporter(errorReporter), _objectFactory(objectFactory)
{
}
diff --git a/cpp/src/FreezeScript/DumpDescriptors.cpp b/cpp/src/FreezeScript/DumpDescriptors.cpp
index fb947a16e47..8b2a15300cc 100644
--- a/cpp/src/FreezeScript/DumpDescriptors.cpp
+++ b/cpp/src/FreezeScript/DumpDescriptors.cpp
@@ -1239,7 +1239,7 @@ FreezeScript::RecordDescriptor::RecordDescriptor(const DescriptorPtr& parent, in
const ErrorReporterPtr& errorReporter,
const IceXML::Attributes& attributes,
const Slice::UnitPtr& unit,
- const FreezeScript::ObjectFactoryPtr& objectFactory) :
+ const FreezeScript::ObjectFactoryPtr& objectFactory) :
Descriptor(parent, line, factory, errorReporter),
ExecutableContainerDescriptor(parent, line, factory, errorReporter, attributes, "record"),
_unit(unit),
@@ -1322,7 +1322,7 @@ FreezeScript::RecordDescriptor::execute(const SymbolTablePtr& sym, ExecuteInfo*
{
dbc->close();
}
- _objectFactory->deactivate();
+ _objectFactory->deactivate();
throw;
}
@@ -1870,16 +1870,16 @@ FreezeScript::DumpVisitor::visitObject(const ObjectRefPtr& data)
ObjectDataPtr value = data->getValue();
if(value)
{
- set<const ObjectData*>::iterator p = _objectHistory.find(value.get());
- if(p == _objectHistory.end())
- {
- _objectHistory.insert(value.get());
- DataMemberMap& members = value->getMembers();
- for(DataMemberMap::iterator q = members.begin(); q != members.end(); ++q)
- {
- q->second->visit(*this);
- }
- }
+ set<const ObjectData*>::iterator p = _objectHistory.find(value.get());
+ if(p == _objectHistory.end())
+ {
+ _objectHistory.insert(value.get());
+ DataMemberMap& members = value->getMembers();
+ for(DataMemberMap::iterator q = members.begin(); q != members.end(); ++q)
+ {
+ q->second->visit(*this);
+ }
+ }
}
}
}
diff --git a/cpp/src/FreezeScript/DumpDescriptors.h b/cpp/src/FreezeScript/DumpDescriptors.h
index 4f8daf65b9c..f915c08ba1f 100644
--- a/cpp/src/FreezeScript/DumpDescriptors.h
+++ b/cpp/src/FreezeScript/DumpDescriptors.h
@@ -247,7 +247,7 @@ public:
RecordDescriptor(const DescriptorPtr&, int, const DataFactoryPtr&, const ErrorReporterPtr&,
const IceXML::Attributes&, const Slice::UnitPtr&,
- const FreezeScript::ObjectFactoryPtr&);
+ const FreezeScript::ObjectFactoryPtr&);
virtual void execute(const SymbolTablePtr&, ExecuteInfo*);
diff --git a/cpp/src/FreezeScript/Functions.cpp b/cpp/src/FreezeScript/Functions.cpp
index b96f237b3d0..4f38c91f935 100644
--- a/cpp/src/FreezeScript/Functions.cpp
+++ b/cpp/src/FreezeScript/Functions.cpp
@@ -15,8 +15,8 @@ using namespace std;
bool
FreezeScript::invokeGlobalFunction(const Ice::CommunicatorPtr& communicator, const string& name, const DataList& args,
- DataPtr& result, const DataFactoryPtr& factory,
- const ErrorReporterPtr& errorReporter)
+ DataPtr& result, const DataFactoryPtr& factory,
+ const ErrorReporterPtr& errorReporter)
{
//
// Global function.
diff --git a/cpp/src/FreezeScript/Functions.h b/cpp/src/FreezeScript/Functions.h
index b0a4b5eb441..0b5fff2b21b 100644
--- a/cpp/src/FreezeScript/Functions.h
+++ b/cpp/src/FreezeScript/Functions.h
@@ -16,7 +16,7 @@ namespace FreezeScript
{
bool invokeGlobalFunction(const Ice::CommunicatorPtr&, const std::string&, const DataList&, DataPtr&,
- const DataFactoryPtr&, const ErrorReporterPtr&);
+ const DataFactoryPtr&, const ErrorReporterPtr&);
bool invokeMemberFunction(const std::string&, const DataPtr&, const DataList&, DataPtr&, const DataFactoryPtr&,
const ErrorReporterPtr&);
diff --git a/cpp/src/FreezeScript/TransformAnalyzer.cpp b/cpp/src/FreezeScript/TransformAnalyzer.cpp
index fc9f6be8b66..4095b87007c 100644
--- a/cpp/src/FreezeScript/TransformAnalyzer.cpp
+++ b/cpp/src/FreezeScript/TransformAnalyzer.cpp
@@ -90,46 +90,46 @@ FreezeScript::AnalyzeTransformVisitor::AnalyzeTransformVisitor(XMLOutput& out, c
void
FreezeScript::AnalyzeTransformVisitor::addDatabase(const string& name, const TypePtr& oldKey, const TypePtr& newKey,
- const TypePtr& oldValue, const TypePtr& newValue)
+ const TypePtr& oldValue, const TypePtr& newValue)
{
_out << "\n";
_out << se("database");
if(!name.empty())
{
- _out << attr("name", name);
+ _out << attr("name", name);
}
string oldKeyName = oldKey ? typeToString(oldKey) : string("UNKNOWN");
string newKeyName = newKey ? typeToString(newKey) : string("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 = oldValue ? typeToString(oldValue) : string("UNKNOWN");
string newValueName = newValue ? typeToString(newValue) : string("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");
if(oldKey && newKey)
{
- compareTypes("database key", oldKey, newKey);
+ compareTypes("database key", oldKey, newKey);
}
if(oldValue && newValue)
{
- compareTypes("database value", oldValue, newValue);
+ compareTypes("database value", oldValue, newValue);
}
_out << ee;
@@ -1130,7 +1130,7 @@ FreezeScript::AnalyzeInitVisitor::typeChange(const TypePtr& t, const string& sco
FreezeScript::TransformAnalyzer::TransformAnalyzer(const UnitPtr& oldUnit, const UnitPtr& newUnit,
bool ignoreTypeChanges, ostream& os, vector<string>& missingTypes,
- vector<string>& errors) :
+ vector<string>& errors) :
_old(oldUnit), _new(newUnit), _out(os),
_visitor(new AnalyzeTransformVisitor(_out, newUnit, ignoreTypeChanges, missingTypes, errors))
{
@@ -1144,7 +1144,7 @@ FreezeScript::TransformAnalyzer::~TransformAnalyzer()
void
FreezeScript::TransformAnalyzer::addDatabase(const string& name, const TypePtr& oldKey, const TypePtr& newKey,
- const TypePtr& oldValue, const TypePtr& newValue)
+ const TypePtr& oldValue, const TypePtr& newValue)
{
_visitor->addDatabase(name, oldKey, newKey, oldValue, newValue);
}
diff --git a/cpp/src/FreezeScript/TransformAnalyzer.h b/cpp/src/FreezeScript/TransformAnalyzer.h
index 9af9c06126a..73539de5d67 100644
--- a/cpp/src/FreezeScript/TransformAnalyzer.h
+++ b/cpp/src/FreezeScript/TransformAnalyzer.h
@@ -24,11 +24,11 @@ class TransformAnalyzer
public:
TransformAnalyzer(const Slice::UnitPtr&, const Slice::UnitPtr&, bool, std::ostream&, std::vector<std::string>&,
- std::vector<std::string>&);
+ std::vector<std::string>&);
~TransformAnalyzer();
void addDatabase(const std::string&, const Slice::TypePtr&, const Slice::TypePtr&, const Slice::TypePtr&,
- const Slice::TypePtr&);
+ const Slice::TypePtr&);
void finish();
private:
diff --git a/cpp/src/FreezeScript/Transformer.cpp b/cpp/src/FreezeScript/Transformer.cpp
index 5b6926c75cd..148d3867f68 100644
--- a/cpp/src/FreezeScript/Transformer.cpp
+++ b/cpp/src/FreezeScript/Transformer.cpp
@@ -1911,7 +1911,7 @@ FreezeScript::RecordDescriptor::execute(const SymbolTablePtr& sym)
Ice::ByteSeq outKeyBytes, outValueBytes;
transformRecord(inKeyBytes, inValueBytes, outKeyBytes, outValueBytes);
Dbt dbNewKey(&outKeyBytes[0], static_cast<unsigned>(outKeyBytes.size())),
- dbNewValue(&outValueBytes[0], static_cast<unsigned>(outValueBytes.size()));
+ dbNewValue(&outValueBytes[0], static_cast<unsigned>(outValueBytes.size()));
if(_info->newDb->put(_info->newDbTxn, &dbNewKey, &dbNewValue, DB_NOOVERWRITE) == DB_KEYEXIST)
{
_info->errorReporter->error("duplicate key encountered");
@@ -1941,7 +1941,7 @@ FreezeScript::RecordDescriptor::execute(const SymbolTablePtr& sym)
{
dbc->close();
}
- _info->objectFactory->deactivate();
+ _info->objectFactory->deactivate();
throw;
}
@@ -2051,7 +2051,7 @@ FreezeScript::DatabaseDescriptor::DatabaseDescriptor(const DescriptorPtr& parent
p = attributes.find("name");
if(p != attributes.end())
{
- _name = p->second;
+ _name = p->second;
}
p = attributes.find("key");
@@ -2077,13 +2077,13 @@ FreezeScript::DatabaseDescriptor::DatabaseDescriptor(const DescriptorPtr& parent
}
if(pos == string::npos)
{
- _oldKeyName = keyTypes;
- _newKeyName = keyTypes;
+ _oldKeyName = keyTypes;
+ _newKeyName = keyTypes;
}
else
{
- _oldKeyName = keyTypes.substr(0, pos);
- _newKeyName = keyTypes.substr(pos + 1);
+ _oldKeyName = keyTypes.substr(0, pos);
+ _newKeyName = keyTypes.substr(pos + 1);
}
pos = valueTypes.find(',');
@@ -2093,13 +2093,13 @@ FreezeScript::DatabaseDescriptor::DatabaseDescriptor(const DescriptorPtr& parent
}
if(pos == string::npos)
{
- _oldValueName = valueTypes;
- _newValueName = valueTypes;
+ _oldValueName = valueTypes;
+ _newValueName = valueTypes;
}
else
{
- _oldValueName = valueTypes.substr(0, pos);
- _newValueName = valueTypes.substr(pos + 1);
+ _oldValueName = valueTypes.substr(0, pos);
+ _newValueName = valueTypes.substr(pos + 1);
}
}
@@ -2136,12 +2136,12 @@ FreezeScript::DatabaseDescriptor::execute(const SymbolTablePtr& st)
if(_info->connection != 0)
{
- Freeze::Catalog catalog(_info->connection, Freeze::catalogName());
- Freeze::CatalogData catalogData;
- catalogData.evictor = false;
- catalogData.key = _info->newKeyType->typeId();
- catalogData.value = _info->newValueType->typeId();
- catalog.put(Freeze::Catalog::value_type(_info->newDbName, catalogData));
+ Freeze::Catalog catalog(_info->connection, Freeze::catalogName());
+ Freeze::CatalogData catalogData;
+ catalogData.evictor = false;
+ catalogData.key = _info->newKeyType->typeId();
+ catalogData.value = _info->newValueType->typeId();
+ catalog.put(Freeze::Catalog::value_type(_info->newDbName, catalogData));
}
//
@@ -2182,24 +2182,24 @@ FreezeScript::TransformDBDescriptor::addChild(const DescriptorPtr& child)
if(db)
{
- string name = db->name();
- map<string, DatabaseDescriptorPtr>::iterator p = _databases.find(name);
- if(p != _databases.end())
- {
- if(name.empty())
- {
- _info->errorReporter->error("duplicate <database> element");
- }
- else
- {
- _info->errorReporter->error(string("duplicate <database> element for ") + name);
- }
- }
- else
- {
- _databases[name] = db;
- _children.push_back(db);
- }
+ string name = db->name();
+ map<string, DatabaseDescriptorPtr>::iterator p = _databases.find(name);
+ if(p != _databases.end())
+ {
+ if(name.empty())
+ {
+ _info->errorReporter->error("duplicate <database> element");
+ }
+ else
+ {
+ _info->errorReporter->error(string("duplicate <database> element for ") + name);
+ }
+ }
+ else
+ {
+ _databases[name] = db;
+ _children.push_back(db);
+ }
}
else if(transform)
{
@@ -2243,7 +2243,7 @@ FreezeScript::TransformDBDescriptor::validate()
if(_databases.empty())
{
- _info->errorReporter->error("no <database> element defined");
+ _info->errorReporter->error("no <database> element defined");
}
for(vector<DescriptorPtr>::iterator p = _children.begin(); p != _children.end(); ++p)
@@ -2258,12 +2258,12 @@ FreezeScript::TransformDBDescriptor::execute(const SymbolTablePtr& sym)
map<string, DatabaseDescriptorPtr>::iterator p = _databases.find(_info->newDbName);
if(p == _databases.end())
{
- p = _databases.find("");
+ p = _databases.find("");
}
if(p == _databases.end())
{
- _info->errorReporter->error("no <database> element found for `" + _info->newDbName + "'");
+ _info->errorReporter->error("no <database> element found for `" + _info->newDbName + "'");
}
p->second->execute(sym);
@@ -3000,11 +3000,11 @@ FreezeScript::assignOrTransform(const DataPtr& dest, const DataPtr& src, bool co
void
FreezeScript::transformDatabase(const Ice::CommunicatorPtr& communicator,
- const FreezeScript::ObjectFactoryPtr& objectFactory,
+ const FreezeScript::ObjectFactoryPtr& objectFactory,
const Slice::UnitPtr& oldUnit, const Slice::UnitPtr& newUnit,
Db* oldDb, Db* newDb, DbTxn* newDbTxn, const Freeze::ConnectionPtr& connection,
- const string& newDbName, const string& facetName, bool purgeObjects, ostream& errors,
- bool suppress, istream& is)
+ const string& newDbName, const string& facetName, bool purgeObjects, ostream& errors,
+ bool suppress, istream& is)
{
TransformInfoIPtr info = new TransformInfoI;
diff --git a/cpp/src/FreezeScript/Transformer.h b/cpp/src/FreezeScript/Transformer.h
index 3afc6b507f8..5f856507d78 100644
--- a/cpp/src/FreezeScript/Transformer.h
+++ b/cpp/src/FreezeScript/Transformer.h
@@ -23,10 +23,10 @@ namespace FreezeScript
void
transformDatabase(const Ice::CommunicatorPtr&,
- const FreezeScript::ObjectFactoryPtr& objectFactory,
- const Slice::UnitPtr&, const Slice::UnitPtr&,
+ const FreezeScript::ObjectFactoryPtr& objectFactory,
+ const Slice::UnitPtr&, const Slice::UnitPtr&,
Db*, Db*, DbTxn*, const Freeze::ConnectionPtr&, const std::string&, const std::string&, bool,
- std::ostream&, bool, std::istream&);
+ std::ostream&, bool, std::istream&);
} // End of namespace FreezeScript
diff --git a/cpp/src/FreezeScript/Util.cpp b/cpp/src/FreezeScript/Util.cpp
index 49585d72520..b8f5c17cfc8 100644
--- a/cpp/src/FreezeScript/Util.cpp
+++ b/cpp/src/FreezeScript/Util.cpp
@@ -218,36 +218,36 @@ FreezeScript::readCatalog(const Ice::CommunicatorPtr& communicator, const string
try
{
#ifdef _WIN32
- //
- // Berkeley DB may use a different C++ runtime.
- //
- dbEnv.set_alloc(::malloc, ::realloc, ::free);
+ //
+ // Berkeley DB may use a different C++ runtime.
+ //
+ dbEnv.set_alloc(::malloc, ::realloc, ::free);
#endif
- //
- // Open the database environment.
- //
- {
- u_int32_t flags = DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN | DB_CREATE | DB_THREAD | DB_RECOVER;
- dbEnv.open(dbEnvName.c_str(), flags, mode);
- }
+ //
+ // Open the database environment.
+ //
+ {
+ u_int32_t flags = DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN | DB_CREATE | DB_THREAD | DB_RECOVER;
+ dbEnv.open(dbEnvName.c_str(), flags, mode);
+ }
- Freeze::ConnectionPtr connection = Freeze::createConnection(communicator, dbEnvName, dbEnv);
- Freeze::Catalog catalog(connection, Freeze::catalogName());
- for(Freeze::Catalog::const_iterator p = catalog.begin(); p != catalog.end(); ++p)
- {
- result.insert(make_pair(p->first, p->second));
- }
+ Freeze::ConnectionPtr connection = Freeze::createConnection(communicator, dbEnvName, dbEnv);
+ Freeze::Catalog catalog(connection, Freeze::catalogName());
+ for(Freeze::Catalog::const_iterator p = catalog.begin(); p != catalog.end(); ++p)
+ {
+ result.insert(make_pair(p->first, p->second));
+ }
}
catch(const DbException& ex)
{
- dbEnv.close(0);
- throw FailureException(__FILE__, __LINE__, string("database error: ") + ex.what());
+ dbEnv.close(0);
+ throw FailureException(__FILE__, __LINE__, string("database error: ") + ex.what());
}
catch(...)
{
- dbEnv.close(0);
- throw FailureException(__FILE__, __LINE__, "unknown exception");
+ dbEnv.close(0);
+ throw FailureException(__FILE__, __LINE__, "unknown exception");
}
dbEnv.close(0);
diff --git a/cpp/src/FreezeScript/transformdb.cpp b/cpp/src/FreezeScript/transformdb.cpp
index 8f17b6e8d37..b3a5a6adec4 100644
--- a/cpp/src/FreezeScript/transformdb.cpp
+++ b/cpp/src/FreezeScript/transformdb.cpp
@@ -96,21 +96,21 @@ findType(const Slice::UnitPtr& u, const string& type)
string t;
if(type == "::Ice::Object")
{
- t = "Object";
+ t = "Object";
}
else if(type == "::Ice::Object*")
{
- t = "Object*";
+ t = "Object*";
}
else
{
- t = type;
+ t = type;
}
l = u->lookupType(t, false);
if(l.empty())
{
- return 0;
+ return 0;
}
return l.front();
@@ -118,97 +118,97 @@ findType(const Slice::UnitPtr& u, const string& type)
static void
transformDb(bool evictor, const Ice::CommunicatorPtr& communicator,
- const FreezeScript::ObjectFactoryPtr& objectFactory,
- DbEnv& dbEnv, DbEnv& dbEnvNew, const string& dbName,
- const Freeze::ConnectionPtr& connectionNew, vector<Db*>& dbs,
- const Slice::UnitPtr& oldUnit, const Slice::UnitPtr& newUnit,
- DbTxn* txnNew, bool purgeObjects, bool suppress, string descriptors)
+ const FreezeScript::ObjectFactoryPtr& objectFactory,
+ DbEnv& dbEnv, DbEnv& dbEnvNew, const string& dbName,
+ const Freeze::ConnectionPtr& connectionNew, vector<Db*>& dbs,
+ const Slice::UnitPtr& oldUnit, const Slice::UnitPtr& newUnit,
+ DbTxn* txnNew, bool purgeObjects, bool suppress, string descriptors)
{
if(evictor)
{
- //
- // The evictor database file contains multiple databases. We must first
- // determine the names of those databases, ignoring any whose names
- // begin with "$index:". Each database represents a separate facet, with
- // the facet name used as the database name. The database named "$default"
- // represents the main object.
- //
- vector<string> dbNames;
- {
- Db db(&dbEnv, 0);
- db.open(0, dbName.c_str(), 0, DB_UNKNOWN, DB_RDONLY, 0);
- Dbt dbKey, dbValue;
- dbKey.set_flags(DB_DBT_MALLOC);
- dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
-
- Dbc* dbc = 0;
- db.cursor(0, &dbc, 0);
-
- while(dbc->get(&dbKey, &dbValue, DB_NEXT) == 0)
- {
- string s(static_cast<char*>(dbKey.get_data()), dbKey.get_size());
- if(s.find("$index:") != 0)
- {
- dbNames.push_back(s);
- }
- free(dbKey.get_data());
- }
-
- dbc->close();
- db.close(0);
- }
-
- //
- // Transform each database. We must delay closing the new databases
- // until after the transaction is committed or aborted.
- //
- for(vector<string>::iterator p = dbNames.begin(); p != dbNames.end(); ++p)
- {
- string name = p->c_str();
-
- Db db(&dbEnv, 0);
- db.open(0, dbName.c_str(), name.c_str(), DB_BTREE, DB_RDONLY, FREEZE_SCRIPT_DB_MODE);
-
- Db* dbNew = new Db(&dbEnvNew, 0);
- dbs.push_back(dbNew);
- dbNew->open(txnNew, dbName.c_str(), name.c_str(), DB_BTREE, DB_CREATE | DB_EXCL, FREEZE_SCRIPT_DB_MODE);
-
- //
- // Execute the transformation descriptors.
- //
- istringstream istr(descriptors);
- string facet = (name == "$default" ? string("") : name);
- FreezeScript::transformDatabase(communicator, objectFactory, oldUnit, newUnit, &db, dbNew, txnNew, 0,
- dbName, facet, purgeObjects, cerr, suppress, istr);
-
- db.close(0);
- }
-
- Freeze::Catalog catalogNew(connectionNew, Freeze::catalogName());
- Freeze::CatalogData catalogData;
- catalogData.evictor = true;
- catalogNew.put(Freeze::Catalog::value_type(dbName, catalogData));
+ //
+ // The evictor database file contains multiple databases. We must first
+ // determine the names of those databases, ignoring any whose names
+ // begin with "$index:". Each database represents a separate facet, with
+ // the facet name used as the database name. The database named "$default"
+ // represents the main object.
+ //
+ vector<string> dbNames;
+ {
+ Db db(&dbEnv, 0);
+ db.open(0, dbName.c_str(), 0, DB_UNKNOWN, DB_RDONLY, 0);
+ Dbt dbKey, dbValue;
+ dbKey.set_flags(DB_DBT_MALLOC);
+ dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
+
+ Dbc* dbc = 0;
+ db.cursor(0, &dbc, 0);
+
+ while(dbc->get(&dbKey, &dbValue, DB_NEXT) == 0)
+ {
+ string s(static_cast<char*>(dbKey.get_data()), dbKey.get_size());
+ if(s.find("$index:") != 0)
+ {
+ dbNames.push_back(s);
+ }
+ free(dbKey.get_data());
+ }
+
+ dbc->close();
+ db.close(0);
+ }
+
+ //
+ // Transform each database. We must delay closing the new databases
+ // until after the transaction is committed or aborted.
+ //
+ for(vector<string>::iterator p = dbNames.begin(); p != dbNames.end(); ++p)
+ {
+ string name = p->c_str();
+
+ Db db(&dbEnv, 0);
+ db.open(0, dbName.c_str(), name.c_str(), DB_BTREE, DB_RDONLY, FREEZE_SCRIPT_DB_MODE);
+
+ Db* dbNew = new Db(&dbEnvNew, 0);
+ dbs.push_back(dbNew);
+ dbNew->open(txnNew, dbName.c_str(), name.c_str(), DB_BTREE, DB_CREATE | DB_EXCL, FREEZE_SCRIPT_DB_MODE);
+
+ //
+ // Execute the transformation descriptors.
+ //
+ istringstream istr(descriptors);
+ string facet = (name == "$default" ? string("") : name);
+ FreezeScript::transformDatabase(communicator, objectFactory, oldUnit, newUnit, &db, dbNew, txnNew, 0,
+ dbName, facet, purgeObjects, cerr, suppress, istr);
+
+ db.close(0);
+ }
+
+ Freeze::Catalog catalogNew(connectionNew, Freeze::catalogName());
+ Freeze::CatalogData catalogData;
+ catalogData.evictor = true;
+ catalogNew.put(Freeze::Catalog::value_type(dbName, catalogData));
}
else
{
- //
- // Transform a map database.
- //
- Db db(&dbEnv, 0);
- db.open(0, dbName.c_str(), 0, DB_BTREE, DB_RDONLY, FREEZE_SCRIPT_DB_MODE);
-
- Db* dbNew = new Db(&dbEnvNew, 0);
- dbs.push_back(dbNew);
- dbNew->open(txnNew, dbName.c_str(), 0, DB_BTREE, DB_CREATE | DB_EXCL, FREEZE_SCRIPT_DB_MODE);
-
- //
- // Execute the transformation descriptors.
- //
- istringstream istr(descriptors);
- FreezeScript::transformDatabase(communicator, objectFactory, oldUnit, newUnit, &db, dbNew, txnNew,
- connectionNew, dbName, "", purgeObjects, cerr, suppress, istr);
-
- db.close(0);
+ //
+ // Transform a map database.
+ //
+ Db db(&dbEnv, 0);
+ db.open(0, dbName.c_str(), 0, DB_BTREE, DB_RDONLY, FREEZE_SCRIPT_DB_MODE);
+
+ Db* dbNew = new Db(&dbEnvNew, 0);
+ dbs.push_back(dbNew);
+ dbNew->open(txnNew, dbName.c_str(), 0, DB_BTREE, DB_CREATE | DB_EXCL, FREEZE_SCRIPT_DB_MODE);
+
+ //
+ // Execute the transformation descriptors.
+ //
+ istringstream istr(descriptors);
+ FreezeScript::transformDatabase(communicator, objectFactory, oldUnit, newUnit, &db, dbNew, txnNew,
+ connectionNew, dbName, "", purgeObjects, cerr, suppress, istr);
+
+ db.close(0);
}
}
@@ -263,44 +263,44 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
}
catch(const IceUtil::BadOptException& e)
{
- cerr << argv[0] << ": " << e.reason << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ cerr << argv[0] << ": " << e.reason << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
- usage(argv[0]);
- return EXIT_SUCCESS;
+ usage(argv[0]);
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
if(opts.isSet("D"))
{
- vector<string> optargs = opts.argVec("D");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- oldCppArgs += " -D" + *i;
- newCppArgs += " -D" + *i;
- }
+ vector<string> optargs = opts.argVec("D");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ oldCppArgs += " -D" + *i;
+ newCppArgs += " -D" + *i;
+ }
}
if(opts.isSet("U"))
{
- vector<string> optargs = opts.argVec("U");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- oldCppArgs += " -U" + *i;
- newCppArgs += " -U" + *i;
- }
+ vector<string> optargs = opts.argVec("U");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ oldCppArgs += " -U" + *i;
+ newCppArgs += " -U" + *i;
+ }
}
debug = opts.isSet("debug");
if(opts.isSet("o"))
{
- outputFile = opts.optArg("o");
+ outputFile = opts.optArg("o");
}
ignoreTypeChanges = opts.isSet("i");
purgeObjects = opts.isSet("p");
@@ -308,102 +308,102 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
suppress = opts.isSet("w");
if(opts.isSet("f"))
{
- inputFile = opts.optArg("f");
+ inputFile = opts.optArg("f");
}
if(opts.isSet("include-old"))
{
- vector<string> optargs = opts.argVec("include-old");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- oldCppArgs += " -I" + *i;
- }
+ vector<string> optargs = opts.argVec("include-old");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ oldCppArgs += " -I" + *i;
+ }
}
if(opts.isSet("include-new"))
{
- vector<string> optargs = opts.argVec("include-new");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- newCppArgs += " -I" + *i;
- }
+ vector<string> optargs = opts.argVec("include-new");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ newCppArgs += " -I" + *i;
+ }
}
if(opts.isSet("old"))
{
- vector<string> optargs = opts.argVec("old");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- oldSlice.push_back(*i);
- }
+ vector<string> optargs = opts.argVec("old");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ oldSlice.push_back(*i);
+ }
}
if(opts.isSet("new"))
{
- vector<string> optargs = opts.argVec("new");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- newSlice.push_back(*i);
- }
+ vector<string> optargs = opts.argVec("new");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ newSlice.push_back(*i);
+ }
}
evictor = opts.isSet("e");
if(opts.isSet("key"))
{
- keyTypeNames = opts.optArg("key");
+ keyTypeNames = opts.optArg("key");
}
if(opts.isSet("value"))
{
- valueTypeNames = opts.optArg("value");
+ valueTypeNames = opts.optArg("value");
}
caseSensitive = opts.isSet("case-sensitive");
if(outputFile.empty())
{
- if(args.size() == 2)
- {
- allDb = true;
- }
- else if(args.size() != 3)
- {
- usage(argv[0]);
- return EXIT_FAILURE;
- }
+ if(args.size() == 2)
+ {
+ allDb = true;
+ }
+ else if(args.size() != 3)
+ {
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
}
else
{
- if(args.size() == 1)
- {
- allDb = true;
- }
- else if(args.size() != 0)
- {
- usage(argv[0]);
- return EXIT_FAILURE;
- }
+ if(args.size() == 1)
+ {
+ allDb = true;
+ }
+ else if(args.size() != 0)
+ {
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
}
if(allDb && (!keyTypeNames.empty() || !valueTypeNames.empty()))
{
- usage(argv[0]);
- return EXIT_FAILURE;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(inputFile.empty() && !allDb && !evictor && (keyTypeNames.empty() || valueTypeNames.empty()))
{
- usage(argv[0]);
- return EXIT_FAILURE;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(args.size() > 0)
{
- dbEnvName = args[0];
+ dbEnvName = args[0];
}
if(args.size() > 1)
{
- if(allDb)
- {
- dbEnvNameNew = args[1];
- }
- else
- {
- dbName = args[1];
- }
+ if(allDb)
+ {
+ dbEnvNameNew = args[1];
+ }
+ else
+ {
+ dbName = args[1];
+ }
}
if(args.size() > 2)
{
@@ -436,20 +436,20 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
FreezeScript::CatalogDataMap catalog;
if(allDb)
{
- try
- {
- catalog = FreezeScript::readCatalog(communicator, dbEnvName);
- }
- catch(const FreezeScript::FailureException& ex)
- {
- cerr << argv[0] << ": " << ex.reason() << endl;
- return EXIT_FAILURE;
- }
- if(catalog.empty())
- {
- cerr << argv[0] << ": no databases in environment `" << dbEnvName << "'" << endl;
- return EXIT_FAILURE;
- }
+ try
+ {
+ catalog = FreezeScript::readCatalog(communicator, dbEnvName);
+ }
+ catch(const FreezeScript::FailureException& ex)
+ {
+ cerr << argv[0] << ": " << ex.reason() << endl;
+ return EXIT_FAILURE;
+ }
+ if(catalog.empty())
+ {
+ cerr << argv[0] << ": no databases in environment `" << dbEnvName << "'" << endl;
+ return EXIT_FAILURE;
+ }
}
//
@@ -463,166 +463,166 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
vector<string> missingTypes;
vector<string> analyzeErrors;
- FreezeScript::TransformAnalyzer analyzer(oldUnit, newUnit, ignoreTypeChanges, out, missingTypes, analyzeErrors);
-
- const string evictorKeyName = "::Ice::Identity";
- const string evictorValueName = "::Freeze::ObjectRecord";
-
- if(allDb)
- {
- //
- // Add a <database> element for each database in the catalog.
- //
- for(FreezeScript::CatalogDataMap::iterator p = catalog.begin(); p != catalog.end(); ++p)
- {
- string keyName, valueName;
-
- if(p->second.evictor)
- {
- keyName = evictorKeyName;
- valueName = evictorValueName;
- }
- else
- {
- keyName = p->second.key;
- valueName = p->second.value;
- }
-
- //
- // Look up the key and value types in the old and new Slice definitions.
- //
- Slice::TypePtr oldKeyType = findType(oldUnit, keyName);
- if(!oldKeyType)
- {
- cerr << argv[0] << ": type `" << keyName << "' from database `" << p->first
- << "' not found in old Slice definitions" << endl;
- }
- Slice::TypePtr newKeyType = findType(newUnit, keyName);
- if(!newKeyType)
- {
- cerr << argv[0] << ": type `" << keyName << "' from database `" << p->first
- << "' not found in new Slice definitions" << endl;
- }
- Slice::TypePtr oldValueType = findType(oldUnit, valueName);
- if(!oldValueType)
- {
- cerr << argv[0] << ": type `" << valueName << "' from database `" << p->first
- << "' not found in old Slice definitions" << endl;
- }
- Slice::TypePtr newValueType = findType(newUnit, valueName);
- if(!newValueType)
- {
- cerr << argv[0] << ": type `" << valueName << "' from database `" << p->first
- << "' not found in new Slice definitions" << endl;
- }
-
- //
- // If we are generating an output file, we do not consider a missing type to be
- // an error. Since the type information comes from the catalog of the old
- // environment, it's possible that the key or value types are not present in
- // the new Slice definitions. Rather than abort at this point, we simply emit
- // a partially-defined <database> element that must be edited by the user.
- //
- // If we are not generating an output file, we have to stop now.
- //
- if(outputFile.empty() && (!oldKeyType || !newKeyType || !oldValueType || !newValueType))
- {
- return EXIT_FAILURE;
- }
-
- analyzer.addDatabase(p->first, oldKeyType, newKeyType, oldValueType, newValueType);
- }
- }
- else
- {
- string oldKeyName, newKeyName, oldValueName, newValueName;
-
- if(evictor)
- {
- oldKeyName = newKeyName = evictorKeyName;
- oldValueName = newValueName = evictorValueName;
- }
- else
- {
- string::size_type pos;
-
- if(keyTypeNames.empty() || valueTypeNames.empty())
- {
- usage(argv[0]);
- return EXIT_FAILURE;
- }
-
- pos = keyTypeNames.find(',');
- if(pos == 0 || pos == keyTypeNames.size())
- {
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- if(pos == string::npos)
- {
- oldKeyName = keyTypeNames;
- newKeyName = keyTypeNames;
- }
- else
- {
- oldKeyName = keyTypeNames.substr(0, pos);
- newKeyName = keyTypeNames.substr(pos + 1);
- }
-
- pos = valueTypeNames.find(',');
- if(pos == 0 || pos == valueTypeNames.size())
- {
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- if(pos == string::npos)
- {
- oldValueName = valueTypeNames;
- newValueName = valueTypeNames;
- }
- else
- {
- oldValueName = valueTypeNames.substr(0, pos);
- newValueName = valueTypeNames.substr(pos + 1);
- }
- }
-
- //
- // Look up the key and value types in the old and new Slice definitions.
- //
- Slice::TypePtr oldKeyType = findType(oldUnit, oldKeyName);
- if(!oldKeyType)
- {
- cerr << argv[0] << ": type `" << oldKeyName << "' not found in old Slice definitions" << endl;
- }
- Slice::TypePtr newKeyType = findType(newUnit, newKeyName);
- if(!newKeyType)
- {
- cerr << argv[0] << ": type `" << newKeyName << "' not found in new Slice definitions" << endl;
- }
- Slice::TypePtr oldValueType = findType(oldUnit, oldValueName);
- if(!oldValueType)
- {
- cerr << argv[0] << ": type `" << oldValueName << "' not found in old Slice definitions" << endl;
- }
- Slice::TypePtr newValueType = findType(newUnit, newValueName);
- if(!newValueType)
- {
- cerr << argv[0] << ": type `" << newValueName << "' not found in new Slice definitions" << endl;
- }
-
- //
- // Stop now if any of the types could not be found.
- //
- if(!oldKeyType || !newKeyType || !oldValueType || !newValueType)
- {
- return EXIT_FAILURE;
- }
-
- analyzer.addDatabase("", oldKeyType, newKeyType, oldValueType, newValueType);
- }
-
- analyzer.finish();
+ FreezeScript::TransformAnalyzer analyzer(oldUnit, newUnit, ignoreTypeChanges, out, missingTypes, analyzeErrors);
+
+ const string evictorKeyName = "::Ice::Identity";
+ const string evictorValueName = "::Freeze::ObjectRecord";
+
+ if(allDb)
+ {
+ //
+ // Add a <database> element for each database in the catalog.
+ //
+ for(FreezeScript::CatalogDataMap::iterator p = catalog.begin(); p != catalog.end(); ++p)
+ {
+ string keyName, valueName;
+
+ if(p->second.evictor)
+ {
+ keyName = evictorKeyName;
+ valueName = evictorValueName;
+ }
+ else
+ {
+ keyName = p->second.key;
+ valueName = p->second.value;
+ }
+
+ //
+ // Look up the key and value types in the old and new Slice definitions.
+ //
+ Slice::TypePtr oldKeyType = findType(oldUnit, keyName);
+ if(!oldKeyType)
+ {
+ cerr << argv[0] << ": type `" << keyName << "' from database `" << p->first
+ << "' not found in old Slice definitions" << endl;
+ }
+ Slice::TypePtr newKeyType = findType(newUnit, keyName);
+ if(!newKeyType)
+ {
+ cerr << argv[0] << ": type `" << keyName << "' from database `" << p->first
+ << "' not found in new Slice definitions" << endl;
+ }
+ Slice::TypePtr oldValueType = findType(oldUnit, valueName);
+ if(!oldValueType)
+ {
+ cerr << argv[0] << ": type `" << valueName << "' from database `" << p->first
+ << "' not found in old Slice definitions" << endl;
+ }
+ Slice::TypePtr newValueType = findType(newUnit, valueName);
+ if(!newValueType)
+ {
+ cerr << argv[0] << ": type `" << valueName << "' from database `" << p->first
+ << "' not found in new Slice definitions" << endl;
+ }
+
+ //
+ // If we are generating an output file, we do not consider a missing type to be
+ // an error. Since the type information comes from the catalog of the old
+ // environment, it's possible that the key or value types are not present in
+ // the new Slice definitions. Rather than abort at this point, we simply emit
+ // a partially-defined <database> element that must be edited by the user.
+ //
+ // If we are not generating an output file, we have to stop now.
+ //
+ if(outputFile.empty() && (!oldKeyType || !newKeyType || !oldValueType || !newValueType))
+ {
+ return EXIT_FAILURE;
+ }
+
+ analyzer.addDatabase(p->first, oldKeyType, newKeyType, oldValueType, newValueType);
+ }
+ }
+ else
+ {
+ string oldKeyName, newKeyName, oldValueName, newValueName;
+
+ if(evictor)
+ {
+ oldKeyName = newKeyName = evictorKeyName;
+ oldValueName = newValueName = evictorValueName;
+ }
+ else
+ {
+ string::size_type pos;
+
+ if(keyTypeNames.empty() || valueTypeNames.empty())
+ {
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ pos = keyTypeNames.find(',');
+ if(pos == 0 || pos == keyTypeNames.size())
+ {
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ if(pos == string::npos)
+ {
+ oldKeyName = keyTypeNames;
+ newKeyName = keyTypeNames;
+ }
+ else
+ {
+ oldKeyName = keyTypeNames.substr(0, pos);
+ newKeyName = keyTypeNames.substr(pos + 1);
+ }
+
+ pos = valueTypeNames.find(',');
+ if(pos == 0 || pos == valueTypeNames.size())
+ {
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ if(pos == string::npos)
+ {
+ oldValueName = valueTypeNames;
+ newValueName = valueTypeNames;
+ }
+ else
+ {
+ oldValueName = valueTypeNames.substr(0, pos);
+ newValueName = valueTypeNames.substr(pos + 1);
+ }
+ }
+
+ //
+ // Look up the key and value types in the old and new Slice definitions.
+ //
+ Slice::TypePtr oldKeyType = findType(oldUnit, oldKeyName);
+ if(!oldKeyType)
+ {
+ cerr << argv[0] << ": type `" << oldKeyName << "' not found in old Slice definitions" << endl;
+ }
+ Slice::TypePtr newKeyType = findType(newUnit, newKeyName);
+ if(!newKeyType)
+ {
+ cerr << argv[0] << ": type `" << newKeyName << "' not found in new Slice definitions" << endl;
+ }
+ Slice::TypePtr oldValueType = findType(oldUnit, oldValueName);
+ if(!oldValueType)
+ {
+ cerr << argv[0] << ": type `" << oldValueName << "' not found in old Slice definitions" << endl;
+ }
+ Slice::TypePtr newValueType = findType(newUnit, newValueName);
+ if(!newValueType)
+ {
+ cerr << argv[0] << ": type `" << newValueName << "' not found in new Slice definitions" << endl;
+ }
+
+ //
+ // Stop now if any of the types could not be found.
+ //
+ if(!oldKeyType || !newKeyType || !oldValueType || !newValueType)
+ {
+ return EXIT_FAILURE;
+ }
+
+ analyzer.addDatabase("", oldKeyType, newKeyType, oldValueType, newValueType);
+ }
+
+ analyzer.finish();
if(!analyzeErrors.empty())
{
@@ -717,7 +717,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
// Open the old database environment. Use DB_RECOVER_FATAL if -c is specified.
// No transaction is created for the old environment.
//
- // DB_THREAD is for compatibility with Freeze (the catalog)
+ // DB_THREAD is for compatibility with Freeze (the catalog)
{
u_int32_t flags = DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN | DB_CREATE | DB_THREAD;
if(catastrophicRecover)
@@ -734,42 +734,42 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
//
// Open the new database environment and start a transaction.
//
- //
- // DB_THREAD is for compatibility with Freeze (the catalog)
- //
+ //
+ // DB_THREAD is for compatibility with Freeze (the catalog)
+ //
{
u_int32_t flags = DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN | DB_RECOVER | DB_CREATE
- | DB_THREAD;
+ | DB_THREAD;
dbEnvNew.open(dbEnvNameNew.c_str(), flags, FREEZE_SCRIPT_DB_MODE);
}
- //
- // TODO: handle properly DbHome config (currently it will break if it's set for the new env)
- //
-
- //
- // Open the catalog of the new environment, and start a transaction.
- //
- Freeze::ConnectionPtr connectionNew = Freeze::createConnection(communicator, dbEnvNameNew, dbEnvNew);
- txNew = connectionNew->beginTransaction();
- DbTxn* txnNew = Freeze::getTxn(txNew);
-
- if(allDb)
- {
- //
- // Transform all databases in the old catalog.
- //
- for(FreezeScript::CatalogDataMap::iterator p = catalog.begin(); p != catalog.end(); ++p)
- {
- transformDb(p->second.evictor, communicator, objectFactory, dbEnv, dbEnvNew, p->first, connectionNew,
- dbs, oldUnit, newUnit, txnNew, purgeObjects, suppress, descriptors);
- }
- }
- else
- {
- transformDb(evictor, communicator, objectFactory, dbEnv, dbEnvNew, dbName, connectionNew, dbs,
- oldUnit, newUnit, txnNew, purgeObjects, suppress, descriptors);
- }
+ //
+ // TODO: handle properly DbHome config (currently it will break if it's set for the new env)
+ //
+
+ //
+ // Open the catalog of the new environment, and start a transaction.
+ //
+ Freeze::ConnectionPtr connectionNew = Freeze::createConnection(communicator, dbEnvNameNew, dbEnvNew);
+ txNew = connectionNew->beginTransaction();
+ DbTxn* txnNew = Freeze::getTxn(txNew);
+
+ if(allDb)
+ {
+ //
+ // Transform all databases in the old catalog.
+ //
+ for(FreezeScript::CatalogDataMap::iterator p = catalog.begin(); p != catalog.end(); ++p)
+ {
+ transformDb(p->second.evictor, communicator, objectFactory, dbEnv, dbEnvNew, p->first, connectionNew,
+ dbs, oldUnit, newUnit, txnNew, purgeObjects, suppress, descriptors);
+ }
+ }
+ else
+ {
+ transformDb(evictor, communicator, objectFactory, dbEnv, dbEnvNew, dbName, connectionNew, dbs,
+ oldUnit, newUnit, txnNew, purgeObjects, suppress, descriptors);
+ }
}
catch(const DbException& ex)
{