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

SVN commits to the Hydra project hydra-commits at lists.digium.com
Wed May 19 08:14:35 CDT 2010


Author: beagles
Date: Wed May 19 08:14:34 2010
New Revision: 622

URL: https://origsvn.digium.com/svn-view/hydra?view=rev&rev=622
Log:
Fixed:
 - Incorrect offset calculation. Slice size being written first was not being accounted for, so offsets were off by 4 bytes.
 - Added function to BasicStream to add a pending write object without actually writing the object to the encapsulation. This
   is required to allow proper id reassignment and capturing preserved objects if they occur only in the preserved slices.
 - Modified generated code according to the aforemenetioned change.

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

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=622&r1=621&r2=622
==============================================================================
--- ice/branches/preserve-graphs/cpp/include/Ice/BasicStream.h (original)
+++ ice/branches/preserve-graphs/cpp/include/Ice/BasicStream.h Wed May 19 08:14:34 2010
@@ -528,6 +528,7 @@
     // addresses.
     //
     void addPreservedPatcher(void*, Ice::Int);
+    Ice::Int addPendingObject(const Ice::ObjectPtr&);
 
     struct PatchEntry 
     {

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=622&r1=621&r2=622
==============================================================================
--- ice/branches/preserve-graphs/cpp/src/Ice/BasicStream.cpp (original)
+++ ice/branches/preserve-graphs/cpp/src/Ice/BasicStream.cpp Wed May 19 08:14:34 2010
@@ -277,7 +277,7 @@
     {
 	throw MarshalException(__FILE__, __LINE__, "slice offsets are only valid within slices");
     }
-    return b.size() - _writeSlice;
+    return b.size() - _writeSlice + sizeof(Int);
 }
 
 void
@@ -2224,6 +2224,56 @@
     e.patchFunc = preservedPatcher;
     e.patchAddr = patchAddr;
     p->second.push_back(e);
+    patchPointers(id, _currentReadEncaps->unmarshaledMap->end(), p);
+}
+
+Int
+IceInternal::BasicStream::addPendingObject(const Ice::ObjectPtr& v)
+{
+    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;
+    }
+
+    if(v)
+    {
+        //
+        // Look for this instance in the to-be-marshaled map.
+        //
+        PtrToIndexMap::iterator p = _currentWriteEncaps->toBeMarshaledMap->find(v);
+        if(p == _currentWriteEncaps->toBeMarshaledMap->end())
+        {
+            //
+            // Didn't find it, try the marshaled map next.
+            //
+            PtrToIndexMap::iterator q = _currentWriteEncaps->marshaledMap->find(v);
+            if(q == _currentWriteEncaps->marshaledMap->end())
+            {
+                //
+                // We haven't seen this instance previously, create a
+                // new index, and insert it into the to-be-marshaled
+                // map.
+                //
+                q = _currentWriteEncaps->toBeMarshaledMap->insert(
+                    _currentWriteEncaps->toBeMarshaledMap->end(),
+                    pair<const ObjectPtr, Int>(v, ++_currentWriteEncaps->writeIndex));
+            }
+            p = q;
+        }
+        //
+        // Write the index for the instance.
+        //
+	return p->second;
+    }
+    return 0;
 }
 
 void

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=622&r1=621&r2=622
==============================================================================
--- ice/branches/preserve-graphs/cpp/src/slice2cpp/Gen.cpp (original)
+++ ice/branches/preserve-graphs/cpp/src/slice2cpp/Gen.cpp Wed May 19 08:14:34 2010
@@ -879,10 +879,10 @@
 	    C << nl << "if(preservedObject != __objectMap.end())";
 	    C << sb;
 	    C << nl << "::Ice::ObjectIdOffset newId;";
-	    C << nl << "newId.id = __os->write(preservedObject->second->obj);";
+	    C << nl << "newId.id = __os->addPendingObject(preservedObject->second->obj);";
 	    C << nl << "newId.offset = j->offset;";
 	    C << nl << "offsetSeq.push_back(newId);";
-	    C << nl << "::Ice::updateObjectId(blob, newId.offset, newId.id);";
+	    C << nl << "::Ice::updateObjectId(blob, newId.offset, -newId.id);";
 	    C << eb;
 	    C << nl << "else";
 	    C << sb;
@@ -4372,10 +4372,10 @@
 	    C << nl << "if(preservedObject != __objectMap.end())";
 	    C << sb;
 	    C << nl << "::Ice::ObjectIdOffset newId;";
-	    C << nl << "newId.id = __os->write(preservedObject->second->obj);";
+	    C << nl << "newId.id = __os->addPendingObject(preservedObject->second->obj);";
 	    C << nl << "newId.offset = j->offset;";
 	    C << nl << "offsetSeq.push_back(newId);";
-	    C << nl << "::Ice::updateObjectId(blob, newId.offset, newId.id);";
+	    C << nl << "::Ice::updateObjectId(blob, newId.offset, -newId.id);";
 	    C << eb;
 	    C << nl << "else";
 	    C << sb;

Modified: ice/branches/preserve-graphs/cpp/test/Ice/slicing/objects/AllTests.cpp
URL: https://origsvn.digium.com/svn-view/hydra/ice/branches/preserve-graphs/cpp/test/Ice/slicing/objects/AllTests.cpp?view=diff&rev=622&r1=621&r2=622
==============================================================================
--- ice/branches/preserve-graphs/cpp/test/Ice/slicing/objects/AllTests.cpp (original)
+++ ice/branches/preserve-graphs/cpp/test/Ice/slicing/objects/AllTests.cpp Wed May 19 08:14:34 2010
@@ -407,7 +407,6 @@
 {
     Ice::ObjectPrx obj = communicator->stringToProxy("Test:default -p 12010");
     TestIntfPrx test = TestIntfPrx::checkedCast(obj);
-
     cout << "base as Object... " << flush;
     {
         Ice::ObjectPtr o;
@@ -1033,7 +1032,6 @@
         }
     }
     cout << "ok" << endl;
-
     cout << "return value unsliced for input params known first... " << flush;
     {
         try
@@ -1075,6 +1073,7 @@
 	catch(const Ice::Exception& ex)
 	{
 	    cout << ex << endl;
+	    test(false);
 	}
         catch(...)
         {





More information about the asterisk-scf-commits mailing list