summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/include/Ice/Object.h4
-rw-r--r--cpp/src/Ice/Object.cpp33
-rw-r--r--cpp/src/slice2cpp/Gen.cpp28
-rw-r--r--cpp/test/Ice/objects/AllTests.cpp141
-rw-r--r--cpp/test/Ice/objects/Test.ice1
-rw-r--r--cpp/test/Ice/objects/TestI.cpp9
-rw-r--r--cpp/test/Ice/objects/TestI.h1
7 files changed, 210 insertions, 7 deletions
diff --git a/cpp/include/Ice/Object.h b/cpp/include/Ice/Object.h
index be150e1a4ec..b01a469f060 100644
--- a/cpp/include/Ice/Object.h
+++ b/cpp/include/Ice/Object.h
@@ -73,8 +73,8 @@ public:
virtual ::IceInternal::DispatchStatus __dispatch(::IceInternal::Incoming&, const std::string&);
virtual bool __isMutating(const std::string&);
- virtual void __write(::IceInternal::BasicStream*) const = 0;
- virtual void __read(::IceInternal::BasicStream*) = 0;
+ virtual void __write(::IceInternal::BasicStream*) const;
+ virtual void __read(::IceInternal::BasicStream*);
void _addFacet(const ObjectPtr&, const ::std::string&);
void _removeFacet(const ::std::string&);
diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp
index 82a527f4e5c..029d925f301 100644
--- a/cpp/src/Ice/Object.cpp
+++ b/cpp/src/Ice/Object.cpp
@@ -126,6 +126,39 @@ Ice::Object::__isMutating(const std::string& s)
}
void
+Ice::Object::__write(::IceInternal::BasicStream* __os) const
+{
+ JTCSyncT<JTCMutex> sync(_activeFacetMapMutex);
+
+ __os->write(Int(_activeFacetMap.size()));
+ for (map<string, ObjectPtr>::const_iterator p = _activeFacetMap.begin(); p != _activeFacetMap.end(); ++p)
+ {
+ __os->write(p->first);
+ __os->write(p->second);
+ }
+}
+
+void
+Ice::Object::__read(::IceInternal::BasicStream* __is)
+{
+ JTCSyncT<JTCMutex> sync(_activeFacetMapMutex);
+
+ Int sz;
+ __is->read(sz);
+
+ _activeFacetMap.clear();
+ _activeFacetMapHint = _activeFacetMap.end();
+
+ while (sz-- > 0)
+ {
+ pair<string, ObjectPtr> v;
+ __is->read(v.first);
+ __is->read("", v.second);
+ _activeFacetMapHint = _activeFacetMap.insert(_activeFacetMapHint, v);
+ }
+}
+
+void
Ice::Object::_addFacet(const ObjectPtr& facet, const string& name)
{
JTCSyncT<JTCMutex> sync(_activeFacetMapMutex);
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 204ac5b076d..156212eaed4 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -1741,6 +1741,20 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
C << nl << "#endif";
C.restoreIndent();
}
+ else
+ {
+ C.zeroIndent();
+ C << nl << "#ifdef WIN32"; // COMPILERBUG
+ C.restoreIndent();
+ C << nl << "Object::__write(__os);";
+ C.zeroIndent();
+ C << nl << "#else";
+ C.restoreIndent();
+ C << nl << "::Ice::Object::__write(__os);";
+ C.zeroIndent();
+ C << nl << "#endif";
+ C.restoreIndent();
+ }
C << eb;
C << sp;
C << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is)";
@@ -1762,6 +1776,20 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
C << nl << "#endif";
C.restoreIndent();
}
+ else
+ {
+ C.zeroIndent();
+ C << nl << "#ifdef WIN32"; // COMPILERBUG
+ C.restoreIndent();
+ C << nl << "Object::__read(__is);";
+ C.zeroIndent();
+ C << nl << "#else";
+ C.restoreIndent();
+ C << nl << "::Ice::Object::__read(__is);";
+ C.zeroIndent();
+ C << nl << "#endif";
+ C.restoreIndent();
+ }
C << eb;
}
H << eb << ';';
diff --git a/cpp/test/Ice/objects/AllTests.cpp b/cpp/test/Ice/objects/AllTests.cpp
index 7934e8cdc47..c78c56e0a22 100644
--- a/cpp/test/Ice/objects/AllTests.cpp
+++ b/cpp/test/Ice/objects/AllTests.cpp
@@ -29,25 +29,120 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(initial == base);
cout << "ok" << endl;
- cout << "getting first B... " << flush;
+ cout << "getting B1... " << flush;
BPtr b1 = initial->getB1();
test(b1);
cout << "ok" << endl;
-
- cout << "getting second B... " << flush;
+
+ cout << "getting B2... " << flush;
BPtr b2 = initial->getB2();
test(b2);
cout << "ok" << endl;
-
+
cout << "getting C... " << flush;
CPtr c = initial->getC();
test(c);
cout << "ok" << endl;
-
+
cout << "getting D... " << flush;
DPtr d = initial->getD();
test(d);
cout << "ok" << endl;
+
+ cout << "checking consistency... " << flush;
+ test(b1 != b2);
+ test(b1 != c);
+ test(b1 != d);
+ test(b2 != c);
+ test(b2 != d);
+ test(c != d);
+ test(b1->b == b1);
+ test(b1->c == 0);
+ test(BPtr::dynamicCast(b1->a));
+ test(BPtr::dynamicCast(b1->a)->a == b1->a);
+ test(BPtr::dynamicCast(b1->a)->b == b1);
+ test(CPtr::dynamicCast(BPtr::dynamicCast(b1->a)->c));
+ test(CPtr::dynamicCast(BPtr::dynamicCast(b1->a)->c)->b == b1->a);
+ // More tests possible for b2 and d, but I think this is already sufficient.
+ test(b2->a == b2);
+ test(d->c == 0);
+ cout << "ok" << endl;
+
+ cout << "getting B1, B2, C, and D all at once... " << flush;
+ initial->getAll(b1, b2, c, d);
+ test(b1);
+ test(b2);
+ test(c);
+ test(d);
+ cout << "ok" << endl;
+
+ cout << "checking consistency... " << flush;
+ test(b1 != b2);
+ test(b1 != c);
+ test(b1 != d);
+ test(b2 != c);
+ test(b2 != d);
+ test(c != d);
+ test(b1->a == b2);
+ test(b1->b == b1);
+ test(b1->c == 0);
+ test(b2->a == b2);
+ test(b2->b == b1);
+ test(b2->c == c);
+ test(c->b == b2);
+ test(d->a == b1);
+ test(d->b == b2);
+ test(d->c == 0);
+ cout << "ok" << endl;
+
+ cout << "adding facets to B1... " << flush;
+ initial->addFacetsToB1();
+ cout << "ok" << endl;
+
+ cout << "getting B1 with facets... " << flush;
+ b1 = initial->getB1();
+ test(b1);
+ cout << "ok" << endl;
+
+ cout << "checking consistency... " << flush;
+ test(b1->b == b1);
+ test(b1->c == 0);
+ test(BPtr::dynamicCast(b1->a));
+ test(BPtr::dynamicCast(b1->a)->a == b1->a);
+ test(BPtr::dynamicCast(b1->a)->b == b1);
+ test(CPtr::dynamicCast(BPtr::dynamicCast(b1->a)->c));
+ test(CPtr::dynamicCast(BPtr::dynamicCast(b1->a)->c)->b == b1->a);
+ cout << "ok" << endl;
+
+ cout << "checking facet consistency... " << flush;
+ BPtr fb1 = BPtr::dynamicCast(b1->_findFacet("b1"));
+ test(fb1);
+ BPtr fb2 = BPtr::dynamicCast(b1->_findFacet("b2"));
+ test(fb2);
+ CPtr fc = CPtr::dynamicCast(b1->_findFacet("c"));
+ test(fc);
+ DPtr fd = DPtr::dynamicCast(b1->_findFacet("d"));
+ test(fd);
+ test(b1 == fb1);
+ test(fb1->a == fb2);
+ test(fb1->b == fb1);
+ test(fb1->c == 0);
+ test(fb2->a == fb2);
+ test(fb2->b == fb1);
+ test(fb2->c == fc);
+ test(fc->b == fb2);
+ test(fd->a == fb1);
+ test(fd->b == fb2);
+ test(fd->c == 0);
+ cout << "ok" << endl;
+
+ cout << "getting B1 with facets, and B2, C, and D all at once... " << flush;
+ initial->getAll(b1, b2, c, d);
+ test(b1);
+ test(b2);
+ test(c);
+ test(d);
+ cout << "ok" << endl;
cout << "checking consistency... " << flush;
test(b1 != b2);
@@ -56,6 +151,42 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(b2 != c);
test(b2 != d);
test(c != d);
+ test(b1->a == b2);
+ test(b1->b == b1);
+ test(b1->c == 0);
+ test(b2->a == b2);
+ test(b2->b == b1);
+ test(b2->c == c);
+ test(c->b == b2);
+ test(d->a == b1);
+ test(d->b == b2);
+ test(d->c == 0);
+ cout << "ok" << endl;
+
+ cout << "checking facet consistency... " << flush;
+ fb1 = BPtr::dynamicCast(b1->_findFacet("b1"));
+ test(fb1);
+ fb2 = BPtr::dynamicCast(b1->_findFacet("b2"));
+ test(fb2);
+ fc = CPtr::dynamicCast(b1->_findFacet("c"));
+ test(fc);
+ fd = DPtr::dynamicCast(b1->_findFacet("d"));
+ test(fd);
+ test(b1 == fb1);
+ test(b2 == fb2);
+ test(c == fc);
+ test(d == fd);
+ test(fb1->a == fb2);
+ test(fb1->a == fb2);
+ test(fb1->b == fb1);
+ test(fb1->c == 0);
+ test(fb2->a == fb2);
+ test(fb2->b == fb1);
+ test(fb2->c == fc);
+ test(fc->b == fb2);
+ test(fd->a == fb1);
+ test(fd->b == fb2);
+ test(fd->c == 0);
cout << "ok" << endl;
return initial;
diff --git a/cpp/test/Ice/objects/Test.ice b/cpp/test/Ice/objects/Test.ice
index 50f637f6e87..43a5cebad08 100644
--- a/cpp/test/Ice/objects/Test.ice
+++ b/cpp/test/Ice/objects/Test.ice
@@ -45,6 +45,7 @@ class Initial
C getC();
D getD();
void getAll(; B b1, B b2, C c, D d);
+ void addFacetsToB1();
};
#endif
diff --git a/cpp/test/Ice/objects/TestI.cpp b/cpp/test/Ice/objects/TestI.cpp
index 267e389be21..124e136fba3 100644
--- a/cpp/test/Ice/objects/TestI.cpp
+++ b/cpp/test/Ice/objects/TestI.cpp
@@ -95,3 +95,12 @@ InitialI::getAll(BPtr& b1, BPtr& b2, CPtr& c, DPtr& d)
c = _c;
d = _d;
}
+
+void
+InitialI::addFacetsToB1()
+{
+ _b1->_addFacet(_b1, "b1");
+ _b1->_addFacet(_b2, "b2");
+ _b1->_addFacet(_c, "c");
+ _b1->_addFacet(_d, "d");
+}
diff --git a/cpp/test/Ice/objects/TestI.h b/cpp/test/Ice/objects/TestI.h
index 18730222e03..fd4b17e1d16 100644
--- a/cpp/test/Ice/objects/TestI.h
+++ b/cpp/test/Ice/objects/TestI.h
@@ -25,6 +25,7 @@ public:
virtual CPtr getC();
virtual DPtr getD();
virtual void getAll(BPtr&, BPtr&, CPtr&, DPtr&);
+ virtual void addFacetsToB1();
private: