[hydra-commits] beagles: branch ice/preserve-graphs r626 - in /ice/branches/preserve-graphs/c...

SVN commits to the Hydra project hydra-commits at lists.digium.com
Wed May 19 10:48:47 CDT 2010


Author: beagles
Date: Wed May 19 10:48:46 2010
New Revision: 626

URL: https://origsvn.digium.com/svn-view/hydra?view=rev&rev=626
Log:
Fixing up exception test suite. Also removing the SliceHolder class and
BasicStream changes that use it. They are no longer necessary after recent
translator changes.


Modified:
    ice/branches/preserve-graphs/cpp/include/Ice/BasicStream.h
    ice/branches/preserve-graphs/cpp/include/Ice/SliceHolder.h
    ice/branches/preserve-graphs/cpp/src/Ice/BasicStream.cpp
    ice/branches/preserve-graphs/cpp/src/Ice/SliceHolder.cpp
    ice/branches/preserve-graphs/cpp/src/slice2cpp/Gen.cpp
    ice/branches/preserve-graphs/cpp/test/Ice/slicing/exceptions/AllTests.cpp
    ice/branches/preserve-graphs/cpp/test/Ice/slicing/exceptions/Test.ice
    ice/branches/preserve-graphs/cpp/test/Ice/slicing/exceptions/TestAMD.ice

Modified: ice/branches/preserve-graphs/cpp/include/Ice/BasicStream.h
URL: https://origsvn.digium.com/svn-view/hydra/ice/branches/preserve-graphs/cpp/include/Ice/BasicStream.h?view=diff&rev=626&r1=625&r2=626
==============================================================================
--- ice/branches/preserve-graphs/cpp/include/Ice/BasicStream.h (original)
+++ ice/branches/preserve-graphs/cpp/include/Ice/BasicStream.h Wed May 19 10:48:46 2010
@@ -671,9 +671,6 @@
     void writeInstance(const Ice::ObjectPtr&, Ice::Int);
     void patchPointers(Ice::Int, IndexToPtrMap::const_iterator, PatchMap::iterator);
 
-    void getSlicedObjects(std::vector<Ice::SlicedObject>&);
-    void writeSlicedObjects(const Ice::SlicedObjectsHolder*);
-
     int _traceSlicing;
     const char* _slicingCat;
 

Modified: ice/branches/preserve-graphs/cpp/include/Ice/SliceHolder.h
URL: https://origsvn.digium.com/svn-view/hydra/ice/branches/preserve-graphs/cpp/include/Ice/SliceHolder.h?view=diff&rev=626&r1=625&r2=626
==============================================================================
--- ice/branches/preserve-graphs/cpp/include/Ice/SliceHolder.h (original)
+++ ice/branches/preserve-graphs/cpp/include/Ice/SliceHolder.h Wed May 19 10:48:46 2010
@@ -13,24 +13,6 @@
 {
     std::string typeId;
     std::vector< ::Ice::Byte > slice;
-};
-
-struct ICE_API SlicedObject
-{
-    Int id;
-    std::vector<SkippedSlice> slices;
-};
-
-class ICE_API SlicedObjectsHolder
-{
-public:
-    virtual ~SlicedObjectsHolder() {}
-
-    virtual void store(std::vector<SlicedObject>&);
-    virtual const std::vector<SlicedObject>& get() const;
-
-protected:
-    std::vector<SlicedObject> _extra;
 };
 
 void ICE_API updateObjectId(std::vector<Byte>&, const Int, const Int);

Modified: ice/branches/preserve-graphs/cpp/src/Ice/BasicStream.cpp
URL: https://origsvn.digium.com/svn-view/hydra/ice/branches/preserve-graphs/cpp/src/Ice/BasicStream.cpp?view=diff&rev=626&r1=625&r2=626
==============================================================================
--- ice/branches/preserve-graphs/cpp/src/Ice/BasicStream.cpp (original)
+++ ice/branches/preserve-graphs/cpp/src/Ice/BasicStream.cpp Wed May 19 10:48:46 2010
@@ -1958,18 +1958,8 @@
     }
     else
     {
-        const SlicedObjectsHolder* h = dynamic_cast<const SlicedObjectsHolder*>(&v);
-        if(h)
-	{
-	    write(true);
-	    v.__write(this);
-	    writeSlicedObjects(h);
-	}
-	else
-	{
-	    write(false);
-	    v.__write(this);
-	}
+	write(false);
+	v.__write(this);
     }
 }
 
@@ -2007,28 +1997,9 @@
             {
                 ex.__read(this, false);
                 
-                if(usesClasses)
+                if(usesClasses || ex.__usesClasses())
                 {
-                    if(ex.__usesClasses())
-                    {
-                        readPendingObjects();
-                    }
-                    else
-                    {
-                        //
-                        // At this point, the exception on the wire has enclosed objects but the type that is being
-                        // thrown doesn't. We need to capture the rest of the data, but care needs to be taken not to break
-                        // the encapsulation. We can't do use readPendingObjects because it will attempt to locate factories
-                        // and instantiate the pieces but there cannot be an ownership relationship.
-                        //
-                        SlicedObjectsHolder* h = dynamic_cast<SlicedObjectsHolder*>(&ex);
-                        if(h)
-                        {
-                            vector<SlicedObject> slicedObjects;
-                            getSlicedObjects(slicedObjects);
-                            h->store(slicedObjects);
-                        }
-                    }
+		    readPendingObjects();
                 }
                 ex.ice_throw();
             }
@@ -2381,93 +2352,3 @@
     //
     _currentReadEncaps->patchMap->erase(patchPos);
 }
-
-void
-IceInternal::BasicStream::getSlicedObjects(vector<SlicedObject>& objs)
-{
-    Int num  = 1;
-    if(b.end() - i < 1)
-    {
-        return;
-    }
-    readSize(num);
-
-    if(num > 0)
-    {
-	if(!_currentReadEncaps) // Lazy initialization.
-	{
-	    _currentReadEncaps = &_preAllocatedReadEncaps;
-	}
-
-	if(!_currentReadEncaps->patchMap) // Lazy initialization.
-	{
-	    _currentReadEncaps->patchMap = new PatchMap;
-	    _currentReadEncaps->unmarshaledMap = new IndexToPtrMap;
-	    _currentReadEncaps->typeIdMap = new TypeIdReadMap;
-	}
-    }
-
-    while(num > 0)
-    {
-	for(Int n = 0; n < num; ++n)
-	{
-	    SlicedObject obj;
-	    Int id;
-	    read(id);
-	    obj.id = id;
-
-	    string typeId;
-	    readTypeId(typeId);
-	    _currentObjectStart = i;
-	    while(true)
-	    {
-		if(typeId == Ice::Object::ice_staticId())
-		{
-		    // Last slice!
-		    skipSlice(typeId);
-		    break;
-		}
-		skipSlice(typeId);
-		readTypeId(typeId);
-		_currentObjectStart = i;
-	    }
-	    getSkippedSlices(obj.slices);
-	    objs.push_back(obj);
-	}
-	readSize(num);
-    }
-}
-
-void
-IceInternal::BasicStream::writeSlicedObjects(const SlicedObjectsHolder* holder)
-{
-    if(!_currentWriteEncaps) // Lazy initialization.
-    {
-	_currentWriteEncaps = &_preAllocatedWriteEncaps;
-	_currentWriteEncaps->start = b.size();
-    }
-
-    if(!_currentWriteEncaps->toBeMarshaledMap) // Lazy initialization.
-    {
-	_currentWriteEncaps->toBeMarshaledMap = new PtrToIndexMap;
-	_currentWriteEncaps->marshaledMap = new PtrToIndexMap;
-	_currentWriteEncaps->typeIdMap = new TypeIdWriteMap;
-    }
-
-    vector<SlicedObject> held(holder->get());
-    Int currentSize = static_cast<Int>(held.size());
-    if(held.size() > 0)
-    {
-	writeSize(currentSize);
-    }
-    for(vector<SlicedObject>::const_iterator i = held.begin(); i != held.end(); ++i)
-    {
-	write(i->id);
-	for(vector<SkippedSlice>::const_iterator j = i->slices.begin(); j != i->slices.end(); ++j)
-	{
-	    writeTypeId(j->typeId);
-	    writeBlob(j->slice);
-	}
-    }
-    writeSize(0);
-}

Modified: ice/branches/preserve-graphs/cpp/src/Ice/SliceHolder.cpp
URL: https://origsvn.digium.com/svn-view/hydra/ice/branches/preserve-graphs/cpp/src/Ice/SliceHolder.cpp?view=diff&rev=626&r1=625&r2=626
==============================================================================
--- ice/branches/preserve-graphs/cpp/src/Ice/SliceHolder.cpp (original)
+++ ice/branches/preserve-graphs/cpp/src/Ice/SliceHolder.cpp Wed May 19 10:48:46 2010
@@ -1,17 +1,5 @@
 #include <Ice/SliceHolder.h>
 #include <Ice/LocalException.h>
-
-void
-Ice::SlicedObjectsHolder::store(std::vector<Ice::SlicedObject>& extra)
-{
-    _extra.swap(extra);
-}
-
-const std::vector<Ice::SlicedObject>&
-Ice::SlicedObjectsHolder::get() const
-{
-    return _extra;
-}
 
 void
 ::Ice::updateObjectId(std::vector< ::Ice::Byte>& b, ::Ice::Int offset, Int id)

Modified: ice/branches/preserve-graphs/cpp/src/slice2cpp/Gen.cpp
URL: https://origsvn.digium.com/svn-view/hydra/ice/branches/preserve-graphs/cpp/src/slice2cpp/Gen.cpp?view=diff&rev=626&r1=625&r2=626
==============================================================================
--- ice/branches/preserve-graphs/cpp/src/slice2cpp/Gen.cpp (original)
+++ ice/branches/preserve-graphs/cpp/src/slice2cpp/Gen.cpp Wed May 19 10:48:46 2010
@@ -643,10 +643,6 @@
     else
     {
         H << fixKwd(base->scoped());
-    }
-    if(switchWrites)
-    {
-        H << ", public ::Ice::SlicedObjectsHolder";
     }
     H.restoreIndent();
     H << sb;
@@ -918,7 +914,10 @@
         }
 	if(genOffsets)
 	{
+	    C << nl << "if(!offsetSeq.empty())";
+	    C << sb;
 	    C << nl << "idMap.insert(std::pair<std::string, ::Ice::ObjectIdOffsets>(\"" << scoped << "\", offsetSeq));";
+	    C << eb;
 	}
 	if(switchWrites)
 	{
@@ -1079,10 +1078,19 @@
                 C << sp << nl << "bool";
                 C << nl << scoped.substr(2) << "::__usesClasses() const";
                 C << sb;
-                C << nl << "return true;";
+		C << nl << "return true;";
                 C << eb;
             }
         }
+	else if(switchWrites)
+	{
+	    H << nl << "virtual bool __usesClasses() const;";
+	    C << sp << nl << "bool";
+	    C << nl << scoped.substr(2) << "::__usesClasses() const";
+	    C << sb;
+	    C << nl << "return !__objectIdMap.empty();";
+	    C << eb;
+	}
 
         factoryName = "__F" + p->flattenedScope() + p->name();
 

Modified: ice/branches/preserve-graphs/cpp/test/Ice/slicing/exceptions/AllTests.cpp
URL: https://origsvn.digium.com/svn-view/hydra/ice/branches/preserve-graphs/cpp/test/Ice/slicing/exceptions/AllTests.cpp?view=diff&rev=626&r1=625&r2=626
==============================================================================
--- ice/branches/preserve-graphs/cpp/test/Ice/slicing/exceptions/AllTests.cpp (original)
+++ ice/branches/preserve-graphs/cpp/test/Ice/slicing/exceptions/AllTests.cpp Wed May 19 10:48:46 2010
@@ -329,38 +329,38 @@
 class ClientI : virtual public Test::ClientIntf
 {
 public:
-	virtual void baseAsBase(const Ice::Current&)
-	{
-		Base ex;
-		ex.b = "Base";
-		throw ex;
-	}
-
-	virtual void unknownDerivedAsBase(const Ice::Current&)
-	{
-		ClientUnknownDerived ex;
-		ex.ud = "UnknownDerived";
-		ex.b = "Base";
-		throw ex;
-	}
-
-	virtual void unsliceableDerivedAsBase(const Ice::Current&)
-	{
-		ClientUnsliceableDerived ex;
-		ex.ud = "UnsliceableDerived";
-		ex.b = "Base";
-		throw ex;
-	}
-
-	virtual void unsliceableWithInnerClass(const Ice::Current&)
-	{
-	    ClientUnsliceableWithClass ex;
-	    ex.b = "WithInnerClass";
-	    ex.myObj = new InnerClassDerived;
-	    ex.myObj->ic = "InnerClass";
-            ex.myObj->id = "InnerClassDerived"; 
-	    throw ex;
-	}
+    virtual void baseAsBase(const Ice::Current&)
+    {
+	Base ex;
+	ex.b = "Base";
+	throw ex;
+    }
+
+    virtual void unknownDerivedAsBase(const Ice::Current&)
+    {
+	ClientUnknownDerived ex;
+	ex.ud = "UnknownDerived";
+	ex.b = "Base";
+	throw ex;
+    }
+
+    virtual void unsliceableDerivedAsBase(const Ice::Current&)
+    {
+	ClientUnsliceableDerived ex;
+	ex.ud = "UnsliceableDerived";
+	ex.b = "Base";
+	throw ex;
+    }
+
+    virtual void unsliceableWithInnerClass(const Ice::Current&)
+    {
+	ClientUnsliceableWithClass ex;
+	ex.b = "WithInnerClass";
+	ex.myObj = new InnerClassDerived;
+	ex.myObj->ic = "InnerClass";
+	ex.myObj->id = "InnerClassDerived"; 
+	throw ex;
+    }
 };
 
 TestIntfPrx
@@ -837,7 +837,6 @@
         }
     }
     cout << "ok" << endl;
-
     cout << "unsliceable derived pass through server... " << flush;
     {
         try
@@ -850,6 +849,11 @@
 	    test(b.b == "Base");
             test(b.ice_name() =="Test::ClientUnsliceableDerived");	// *NOT* sliced by server
         }
+	catch(Ice::Exception& ex)
+	{
+	    std::cerr << ex << std::endl;
+	    throw;
+	}
 	catch(...)
 	{
             test(false);

Modified: ice/branches/preserve-graphs/cpp/test/Ice/slicing/exceptions/Test.ice
URL: https://origsvn.digium.com/svn-view/hydra/ice/branches/preserve-graphs/cpp/test/Ice/slicing/exceptions/Test.ice?view=diff&rev=626&r1=625&r2=626
==============================================================================
--- ice/branches/preserve-graphs/cpp/test/Ice/slicing/exceptions/Test.ice (original)
+++ ice/branches/preserve-graphs/cpp/test/Ice/slicing/exceptions/Test.ice Wed May 19 10:48:46 2010
@@ -38,6 +38,7 @@
 {
 };
 
+["preserve"]
 class InnerClass 
 {
     string ic;

Modified: ice/branches/preserve-graphs/cpp/test/Ice/slicing/exceptions/TestAMD.ice
URL: https://origsvn.digium.com/svn-view/hydra/ice/branches/preserve-graphs/cpp/test/Ice/slicing/exceptions/TestAMD.ice?view=diff&rev=626&r1=625&r2=626
==============================================================================
--- ice/branches/preserve-graphs/cpp/test/Ice/slicing/exceptions/TestAMD.ice (original)
+++ ice/branches/preserve-graphs/cpp/test/Ice/slicing/exceptions/TestAMD.ice Wed May 19 10:48:46 2010
@@ -38,6 +38,7 @@
 {
 };
 
+["preserve"]
 class InnerClass 
 {
     string ic;





More information about the asterisk-scf-commits mailing list