[Wheat-cvs] r1/wheat filemedia.cpp,1.9,1.10 media-test.cpp,1.12,1.13 media.cpp,1.10,1.11 media.hpp,1
Status: Pre-Alpha
Brought to you by:
mark_lentczner
From: Jim K. <ki...@us...> - 2005-06-03 22:54:23
|
Update of /cvsroot/wheat/r1/wheat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7291/wheat Modified Files: filemedia.cpp media-test.cpp media.cpp media.hpp memobject-test.cpp memobject.cpp tempmedia.cpp xmlmedia-test.cpp xmlmedia.cpp xmlutil-test.cpp Log Message: Relative paths in prototype now get absolutified when object is created. Mounts now have an initialize method, so XMLMedia reads in the file when we call initialize, not in the constructor (that is, after it is mounted into the tree). Index: xmlmedia-test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/xmlmedia-test.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- xmlmedia-test.cpp 18 Feb 2005 16:10:43 -0000 1.15 +++ xmlmedia-test.cpp 3 Jun 2005 22:54:14 -0000 1.16 @@ -7,6 +7,9 @@ */ #include "xmlmedia.hpp" +#include "reference.hpp" +#include "frame.hpp" +#include "value.hpp" #include "test.h" #include "testutil.hpp" @@ -293,6 +296,33 @@ checkpart(HERE, bottom, 100, true, "water"); } +TEST(xmlmedia, relativePrototype) +{ + static const char xml[] = + "<?xml version='1.0' encoding='UTF-8'?>" + "<wheatobject version='1.0'>" + "<object>" + "<object name='stream'/>" + "<object name='encrypted-stream' prototype='stream'/>" + "</object>" + "</wheatobject>"; + + /* For now, just test that TestUtil::Setup does things right. + But of course we might want a test that more closely resembles + what happens for xmlmedia mentioned in the config file. */ + TestUtil::Setup setup("/test/xml", xml); + + Thread t; + Frame& f = t.topFrame(); + + Local copy(f); + copy = setup.topLink(); + copy = copy.send("encrypted-stream"); + + CHECK_SAME("/test/xml/stream", copy.prototype().asString()); +} + + /* things to test: empty object and array Index: filemedia.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/filemedia.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- filemedia.cpp 7 Feb 2005 05:05:24 -0000 1.9 +++ filemedia.cpp 3 Jun 2005 22:54:14 -0000 1.10 @@ -399,6 +399,8 @@ { public: FileMount(const FileUtil::HostPath& rootPath); + + virtual void initialize(); virtual ObjectPointer root(); virtual void persist(); @@ -412,6 +414,10 @@ FileMount::FileMount(const FileUtil::HostPath& rootPath) : mObjectManager(*this, rootPath) { } + + void + FileMount::initialize() + { } ObjectPointer FileMount::root() Index: xmlmedia.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/xmlmedia.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- xmlmedia.cpp 18 Feb 2005 16:10:43 -0000 1.11 +++ xmlmedia.cpp 3 Jun 2005 22:54:14 -0000 1.12 @@ -45,6 +45,8 @@ public: XMLMount(ref_ptr<XMLStorage> storage, bool readOnly, bool persistent); ~XMLMount(); + + virtual void initialize(); virtual ObjectPointer root(); virtual void persist(); @@ -64,7 +66,11 @@ mReadOnly(readOnly), mPersistent(persistent) { mReadOnly |= mStorage->isReadOnly(); - + } + + void + XMLMount::initialize() + { ref_ptr<XMLStorageNode> firstNode = mStorage->readStorage(); XMLTaskStack taskStack; Index: media-test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/media-test.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- media-test.cpp 18 Feb 2005 16:10:40 -0000 1.12 +++ media-test.cpp 3 Jun 2005 22:54:14 -0000 1.13 @@ -41,6 +41,7 @@ public: TestMount(const pt::string&); + virtual void initialize(); virtual ObjectPointer root(); virtual void persist(); @@ -100,6 +101,10 @@ : mObjectManager(str, *this) { } + void + TestMount::initialize() + { } + ObjectPointer TestMount::root() { Index: memobject.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/memobject.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- memobject.cpp 18 Feb 2005 16:10:40 -0000 1.17 +++ memobject.cpp 3 Jun 2005 22:54:14 -0000 1.18 @@ -358,8 +358,16 @@ clearValue(v); MemoryObject* m = new MemoryObject; - m->prototype = - prototype.isEmpty() ? standardPrototype(TypeObject) : prototype; + + if (prototype.isEmpty()) { + m->prototype = standardPrototype(TypeObject); + } + else { + Path base = NameSpace::pathTo(p.container()); + Path absolute(base, prototype); + m->prototype = absolute; + } + m->capacity = 0; m->keySize = 0; m->arraySize = 0; Index: media.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/media.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- media.cpp 18 Feb 2005 16:10:40 -0000 1.10 +++ media.cpp 3 Jun 2005 22:54:14 -0000 1.11 @@ -252,10 +252,13 @@ mountList.add(node); - while (node) { - ++node->subMounts; - node = node->container; + MountNode* walk = node; + while (walk) { + ++walk->subMounts; + walk = walk->container; } + + node->mount->initialize(); } Index: memobject-test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/memobject-test.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- memobject-test.cpp 18 Feb 2005 16:10:40 -0000 1.6 +++ memobject-test.cpp 3 Jun 2005 22:54:14 -0000 1.7 @@ -19,6 +19,8 @@ { public: SimpleMount() : mManager(*this) { } + + virtual void initialize() { } virtual ObjectPointer root() { return mManager.root(); } virtual void persist() { mManager.clearModified(); } Index: xmlutil-test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/xmlutil-test.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- xmlutil-test.cpp 18 Feb 2005 16:10:43 -0000 1.17 +++ xmlutil-test.cpp 3 Jun 2005 22:54:14 -0000 1.18 @@ -293,10 +293,12 @@ "<wheatobject version=\"1.0\">\n" " <object prototype=\"/test/xmlutil/top\">\n" " <object name=\"a\" prototype=\"/test/xmlutil/foo\">\n" - " <object name=\"x\" mode=\"rw------\" prototype=\"../xray\">\n" + " <object name=\"x\" mode=\"rw------\" prototype=\"/test/xmlutil/writer/xray\">\n" " </object>\n" " </object>\n" - " <array name=\"b\" prototype=\"../../bar\">\n" + // probably would rather have: + //" <array name=\"b\" prototype=\"../../bar\">\n" + " <array name=\"b\" prototype=\"/test/bar\">\n" " <object prototype=\"/test/xmlutil/zero\">\n" " </object>\n" " <object prototype=\"/test/xmlutil/one\">\n" Index: tempmedia.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/tempmedia.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- tempmedia.cpp 18 Feb 2005 16:10:43 -0000 1.6 +++ tempmedia.cpp 3 Jun 2005 22:54:14 -0000 1.7 @@ -19,6 +19,8 @@ { public: TempMount(); + + virtual void initialize(); virtual ObjectPointer root(); virtual void persist(); @@ -32,6 +34,10 @@ TempMount::TempMount() : mObjectManager(*this) { } + + void + TempMount::initialize() + { } ObjectPointer TempMount::root() Index: media.hpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/media.hpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- media.hpp 18 Feb 2005 16:10:40 -0000 1.5 +++ media.hpp 3 Jun 2005 22:54:14 -0000 1.6 @@ -47,6 +47,8 @@ virtual ~Mount(); public: + virtual void initialize() = 0; + virtual ObjectPointer root() = 0; virtual void persist() = 0; }; |