diff options
author | Mark Spruiell <mes@zeroc.com> | 2004-04-12 19:39:53 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2004-04-12 19:39:53 +0000 |
commit | e9fb104368ac5aa34d0901b22af01e881237b094 (patch) | |
tree | 24becd70eac8666968a19475418047bf25ab6384 /cpp | |
parent | Switched to a single database file with multiple databases (diff) | |
download | ice-e9fb104368ac5aa34d0901b22af01e881237b094.tar.bz2 ice-e9fb104368ac5aa34d0901b22af01e881237b094.tar.xz ice-e9fb104368ac5aa34d0901b22af01e881237b094.zip |
facet fixes for FreezeScript
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/FreezeScript/Data.cpp | 27 | ||||
-rw-r--r-- | cpp/src/FreezeScript/DumpDB.cpp | 3 | ||||
-rw-r--r-- | cpp/src/FreezeScript/Print.cpp | 9 | ||||
-rw-r--r-- | cpp/src/FreezeScript/Util.cpp | 70 | ||||
-rw-r--r-- | cpp/src/FreezeScript/Util.h | 1 | ||||
-rw-r--r-- | cpp/src/FreezeScript/transformdb.cpp | 6 | ||||
-rw-r--r-- | cpp/test/FreezeScript/dbmap/check.xml | 4 | ||||
-rw-r--r-- | cpp/test/FreezeScript/dbmap/init.xml | 4 | ||||
-rwxr-xr-x | cpp/test/FreezeScript/dbmap/run.py | 19 | ||||
-rw-r--r-- | cpp/test/FreezeScript/evictor/check.xml | 2 | ||||
-rwxr-xr-x | cpp/test/FreezeScript/evictor/run.py | 12 | ||||
-rw-r--r-- | cpp/test/FreezeScript/evictor/transform.xml | 2 |
12 files changed, 49 insertions, 110 deletions
diff --git a/cpp/src/FreezeScript/Data.cpp b/cpp/src/FreezeScript/Data.cpp index 9c0dc9911eb..9435add2f95 100644 --- a/cpp/src/FreezeScript/Data.cpp +++ b/cpp/src/FreezeScript/Data.cpp @@ -32,7 +32,7 @@ public: ObjectWriter(const ObjectDataPtr&); - virtual void __write(IceInternal::BasicStream*, bool) const; + virtual void __write(IceInternal::BasicStream*) const; virtual void __read(IceInternal::BasicStream*, bool = true); private: @@ -49,7 +49,7 @@ public: ObjectReader(const DataFactoryPtr&, const Slice::TypePtr&); - virtual void __write(IceInternal::BasicStream*, bool) const; + virtual void __write(IceInternal::BasicStream*) const; virtual void __read(IceInternal::BasicStream*, bool = true); ObjectDataPtr getValue() const; @@ -73,7 +73,7 @@ FreezeScript::ObjectWriter::ObjectWriter(const ObjectDataPtr& value) : } void -FreezeScript::ObjectWriter::__write(IceInternal::BasicStream* os, bool) const +FreezeScript::ObjectWriter::__write(IceInternal::BasicStream* os) const { Slice::ClassDeclPtr decl = Slice::ClassDeclPtr::dynamicCast(_value->_type); Slice::ClassDefPtr type; @@ -110,7 +110,7 @@ FreezeScript::ObjectWriter::__write(IceInternal::BasicStream* os, bool) const // os->writeTypeId(Ice::Object::ice_staticId()); os->startWriteSlice(); - _value->_facetMap->marshal(*os); + os->writeSize(0); // For compatibility with the old AFM. os->endWriteSlice(); } @@ -129,7 +129,7 @@ FreezeScript::ObjectReader::ObjectReader(const DataFactoryPtr& factory, const Sl } void -FreezeScript::ObjectReader::__write(IceInternal::BasicStream*, bool) const +FreezeScript::ObjectReader::__write(IceInternal::BasicStream*) const { assert(false); } @@ -189,7 +189,13 @@ FreezeScript::ObjectReader::__read(IceInternal::BasicStream* is, bool rid) } } is->startReadSlice(); - _value->_facetMap->unmarshal(*is); + // For compatibility with the old AFM. + Ice::Int sz; + is->readSize(sz); + if(sz != 0) + { + throw Ice::MarshalException(__FILE__, __LINE__); + } is->endReadSlice(); } @@ -2129,15 +2135,6 @@ FreezeScript::DictionaryData::getElements() FreezeScript::ObjectData::ObjectData(const DataFactoryPtr& factory, const Slice::TypePtr& type, bool readOnly) : Data(factory->getErrorReporter(), readOnly), _type(type), _refCount(0) { - // - // Create a Data object for the facet map. We add this to the _members map so that - // the `ice_facets' member is handled like all other members. - // - Slice::TypeList l = _type->unit()->lookupType("::_FacetMap", false); - assert(!l.empty()); - _facetMap = factory->create(l.front(), readOnly); - _members["ice_facets"] = _facetMap; - Slice::ClassDeclPtr decl = Slice::ClassDeclPtr::dynamicCast(type); if(decl) { diff --git a/cpp/src/FreezeScript/DumpDB.cpp b/cpp/src/FreezeScript/DumpDB.cpp index c5d16bf7db8..67f30332d52 100644 --- a/cpp/src/FreezeScript/DumpDB.cpp +++ b/cpp/src/FreezeScript/DumpDB.cpp @@ -331,7 +331,6 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator) return EXIT_FAILURE; } - FreezeScript::createCoreSliceTypes(unit); FreezeScript::createEvictorSliceTypes(unit); // @@ -342,7 +341,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator) { if(evictor) { - keyTypeName = "::Freeze::EvictorStorageKey"; + keyTypeName = "::Ice::Identity"; valueTypeName = "::Freeze::ObjectRecord"; } else if(keyTypeName.empty() || valueTypeName.empty()) diff --git a/cpp/src/FreezeScript/Print.cpp b/cpp/src/FreezeScript/Print.cpp index e35be8f762a..e6773848313 100644 --- a/cpp/src/FreezeScript/Print.cpp +++ b/cpp/src/FreezeScript/Print.cpp @@ -195,14 +195,11 @@ FreezeScript::PrintVisitor::visitObject(const ObjectRefPtr& data) _objectCount++; _out << sb; + DataMemberMap members = value->getMembers(); + // - // Print Ice::Object members. + // If Ice::Object had any members, this is where we would print them. // - DataMemberMap members = value->getMembers(); - DataMemberMap::const_iterator q = members.find("ice_facets"); - assert(q != members.end()); - _out << nl << q->first << " = "; - q->second->visit(*this); if(decl) { diff --git a/cpp/src/FreezeScript/Util.cpp b/cpp/src/FreezeScript/Util.cpp index d263e4f3c85..9a9db346b69 100644 --- a/cpp/src/FreezeScript/Util.cpp +++ b/cpp/src/FreezeScript/Util.cpp @@ -49,42 +49,15 @@ FreezeScript::ignoreType(const string& type) // static const string ignoreTypeList[] = { - "::Freeze::EvictorStorageKey", "::Freeze::ObjectRecord", "::Freeze::Statistics", - "::Ice::FacetPath", - "::Ice::Identity", - "::_FacetMap" + "::Ice::Identity" }; return binary_search(&ignoreTypeList[0], &ignoreTypeList[sizeof(ignoreTypeList) / sizeof(*ignoreTypeList)], type); } void -FreezeScript::createCoreSliceTypes(const Slice::UnitPtr& unit) -{ - string scoped; - Slice::TypeList l; - Slice::ContainedList c; - - // - // Create the Slice definition for _FacetMap if it doesn't exist. This type is - // necessary for marshaling an object's facet map. - // - l = unit->lookupTypeNoBuiltin("::_FacetMap", false); - if(l.empty()) - { - Slice::TypePtr str = unit->builtin(Slice::Builtin::KindString); - Slice::TypePtr obj = unit->builtin(Slice::Builtin::KindObject); - unit->createDictionary("_FacetMap", str, obj, false); - } - else - { - assert(Slice::DictionaryPtr::dynamicCast(l.front())); - } -} - -void FreezeScript::createEvictorSliceTypes(const Slice::UnitPtr& unit) { string scoped; @@ -133,27 +106,6 @@ FreezeScript::createEvictorSliceTypes(const Slice::UnitPtr& unit) } // - // Create the Slice definition for Ice::FacetPath if it doesn't exist. - // - scoped = "::Ice::FacetPath"; - l = unit->lookupTypeNoBuiltin(scoped, false); - Slice::SequencePtr facetPath; - if(l.empty()) - { - Slice::TypePtr str = unit->builtin(Slice::Builtin::KindString); - facetPath = ice->createSequence("FacetPath", str, false); - } - else - { - facetPath = Slice::SequencePtr::dynamicCast(l.front()); - if(!facetPath) - { - throw FailureException(__FILE__, __LINE__, - "the symbol `::Ice::FacetPath' is defined in Slice but is not a sequence"); - } - } - - // // Create the Freeze module if necessary. // c = unit->lookupContained("Freeze", false); @@ -173,26 +125,6 @@ FreezeScript::createEvictorSliceTypes(const Slice::UnitPtr& unit) } // - // Create the Slice definition for Freeze::EvictorStorageKey if it doesn't exist. - // - scoped = "::Freeze::EvictorStorageKey"; - l = unit->lookupTypeNoBuiltin(scoped, false); - if(l.empty()) - { - Slice::StructPtr esk = freeze->createStruct("EvictorStorageKey", false); - esk->createDataMember("identity", identity); - esk->createDataMember("facet", facetPath); - } - else - { - if(!Slice::StructPtr::dynamicCast(l.front())) - { - throw FailureException(__FILE__, __LINE__, "the symbol `::Freeze::EvictorStorageKey' is defined in " - "Slice but is not a struct"); - } - } - - // // Create the Slice definition for Freeze::Statistics if it doesn't exist. // scoped = "::Freeze::Statistics"; diff --git a/cpp/src/FreezeScript/Util.h b/cpp/src/FreezeScript/Util.h index e180c775e1f..5822bdf004b 100644 --- a/cpp/src/FreezeScript/Util.h +++ b/cpp/src/FreezeScript/Util.h @@ -57,7 +57,6 @@ private: std::string typeName(const Slice::TypePtr&); std::string typeToString(const Slice::TypePtr&); bool ignoreType(const std::string&); -void createCoreSliceTypes(const Slice::UnitPtr&); void createEvictorSliceTypes(const Slice::UnitPtr&); bool parseSlice(const std::string&, const Slice::UnitPtr&, const std::vector<std::string>&, const std::string&, bool); diff --git a/cpp/src/FreezeScript/transformdb.cpp b/cpp/src/FreezeScript/transformdb.cpp index 7ba7e07dec2..5e240d999b2 100644 --- a/cpp/src/FreezeScript/transformdb.cpp +++ b/cpp/src/FreezeScript/transformdb.cpp @@ -372,11 +372,9 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator) } // - // Install the core types in the Slice units. + // Install the evictor types in the Slice units. // - FreezeScript::createCoreSliceTypes(oldUnit); FreezeScript::createEvictorSliceTypes(oldUnit); - FreezeScript::createCoreSliceTypes(newUnit); FreezeScript::createEvictorSliceTypes(newUnit); // @@ -392,7 +390,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator) string oldKeyName, newKeyName, oldValueName, newValueName; if(evictor) { - oldKeyName = newKeyName = "::Freeze::EvictorStorageKey"; + oldKeyName = newKeyName = "::Ice::Identity"; oldValueName = newValueName = "::Freeze::ObjectRecord"; } else diff --git a/cpp/test/FreezeScript/dbmap/check.xml b/cpp/test/FreezeScript/dbmap/check.xml index d21fb8ca32d..c8cfcd1331e 100644 --- a/cpp/test/FreezeScript/dbmap/check.xml +++ b/cpp/test/FreezeScript/dbmap/check.xml @@ -303,10 +303,6 @@ <fail test="new.dObject.stringToByteSeq[0] != 0"/> <fail test="new.dObject.stringToByteSeq[1] != 255"/> <fail test="new.dObject.obj.ice_id != '::C'"/> - <fail test="new.dObject.ice_facets.length != 1"/> - <fail test="new.dObject.ice_facets['facet1'].stringToEnumSeq.length != 2"/> - <fail test="new.dObject.ice_facets['facet1'].stringToEnumSeq[0] != ::New::E1"/> - <fail test="new.dObject.ice_facets['facet1'].stringToEnumSeq[1] != ::New::E3"/> </transform> </transformdb> diff --git a/cpp/test/FreezeScript/dbmap/init.xml b/cpp/test/FreezeScript/dbmap/init.xml index c82b6ce3dfd..90edf3ab68a 100644 --- a/cpp/test/FreezeScript/dbmap/init.xml +++ b/cpp/test/FreezeScript/dbmap/init.xml @@ -292,10 +292,6 @@ <set target="new.dObject.stringToByteSeq[0]" value="'0'"/> <set target="new.dObject.stringToByteSeq[1]" value="'255'"/> <set target="new.dObject.obj" value="new.cObject"/> - <add target="new.dObject.ice_facets" key="'facet1'" type="::F"/> - <set target="new.dObject.ice_facets['facet1'].stringToEnumSeq" length="2"/> - <set target="new.dObject.ice_facets['facet1'].stringToEnumSeq[0]" value="'E1'"/> - <set target="new.dObject.ice_facets['facet1'].stringToEnumSeq[1]" value="'E3'"/> </transform> </transformdb> diff --git a/cpp/test/FreezeScript/dbmap/run.py b/cpp/test/FreezeScript/dbmap/run.py index 1869f93273a..cfc160e777f 100755 --- a/cpp/test/FreezeScript/dbmap/run.py +++ b/cpp/test/FreezeScript/dbmap/run.py @@ -89,24 +89,39 @@ for oldfile in files: print "ok" -print "testing default transformations... ", +print "creating test database... ", sys.stdout.flush() makedb = os.path.join(directory, "makedb") + " " + directory os.system(makedb) +print "ok" + testold = os.path.join(directory, "TestOld.ice") testnew = os.path.join(directory, "TestNew.ice") initxml = os.path.join(directory, "init.xml") checkxml = os.path.join(directory, "check.xml") +print "initializing test database... ", +sys.stdout.flush() + command = transformdb + " --old " + testold + " --new " + testold + " -f " + initxml + " " + dbdir + " default.db " + init_dbdir os.system(command) +print "ok" + +print "executing default transformations... ", +sys.stdout.flush() + command = transformdb + " --old " + testold + " --new " + testnew + " --key int --value ::S " + init_dbdir + " default.db " + check_dbdir stdin, stdout, stderr = os.popen3(command) - stderr.readlines() + +print "ok" + +print "validating database... ", +sys.stdout.flush() + command = transformdb + " --old " + testnew + " --new " + testnew + " -f " + checkxml + " " + check_dbdir + " default.db " + tmp_dbdir os.system(command) diff --git a/cpp/test/FreezeScript/evictor/check.xml b/cpp/test/FreezeScript/evictor/check.xml index f959038c404..c963acdb765 100644 --- a/cpp/test/FreezeScript/evictor/check.xml +++ b/cpp/test/FreezeScript/evictor/check.xml @@ -1,5 +1,5 @@ <transformdb> - <database key="::Freeze::EvictorStorageKey" value="::Freeze::ObjectRecord"> + <database key="::Ice::Identity" value="::Freeze::ObjectRecord"> <record> <fail test="newvalue.servant.ice_id == '::DerivedMainObject'"/> <fail test="newvalue.servant.ice_id == '::DerivedFacetObject'"/> diff --git a/cpp/test/FreezeScript/evictor/run.py b/cpp/test/FreezeScript/evictor/run.py index f48196c45b5..6fa0fac5159 100755 --- a/cpp/test/FreezeScript/evictor/run.py +++ b/cpp/test/FreezeScript/evictor/run.py @@ -41,21 +41,31 @@ if os.path.exists(tmp_dbdir): shutil.rmtree(tmp_dbdir) os.mkdir(tmp_dbdir) -print "testing evictor transformations... ", +print "creating test database... ", sys.stdout.flush() makedb = os.path.join(directory, "makedb") + " " + directory os.system(makedb) +print "ok" + testold = os.path.join(directory, "TestOld.ice") testnew = os.path.join(directory, "TestNew.ice") transformxml = os.path.join(directory, "transform.xml") checkxml = os.path.join(directory, "check.xml") +print "executing evictor transformations... ", +sys.stdout.flush() + command = transformdb + " -p --old " + testold + " --new " + testnew + " -f " + transformxml + " " + dbdir + " evictor.db " + check_dbdir stdin, stdout, stderr = os.popen3(command) stderr.readlines() +print "ok" + +print "validating database... ", +sys.stdout.flush() + command = transformdb + " --old " + testnew + " --new " + testnew + " -f " + checkxml + " " + check_dbdir + " evictor.db " + tmp_dbdir os.system(command) diff --git a/cpp/test/FreezeScript/evictor/transform.xml b/cpp/test/FreezeScript/evictor/transform.xml index 84a68bb8c48..8e65ba7d749 100644 --- a/cpp/test/FreezeScript/evictor/transform.xml +++ b/cpp/test/FreezeScript/evictor/transform.xml @@ -1,5 +1,5 @@ <transformdb> - <database key="::Freeze::EvictorStorageKey" value="::Freeze::ObjectRecord"> + <database key="::Ice::Identity" value="::Freeze::ObjectRecord"> <record/> </database> |