summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2017-07-05 12:10:49 +0200
committerBenoit Foucher <benoit@zeroc.com>2017-07-05 12:10:49 +0200
commite706fb2ceb23b1ee3c225f6d9569c58359b4ee72 (patch)
tree56d6d90d0a079d89ee7b2ab1c1013055cdca6e29 /cpp/src
parentICE-8218 - Windows OpenSSL test build failure with parallel builds (diff)
downloadice-e706fb2ceb23b1ee3c225f6d9569c58359b4ee72.tar.bz2
ice-e706fb2ceb23b1ee3c225f6d9569c58359b4ee72.tar.xz
ice-e706fb2ceb23b1ee3c225f6d9569c58359b4ee72.zip
Fixed ICE-8217 - added ice_getSlicedData method to Ice values and Ice::SlicedData::clear method to break cyclic references
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/Object.cpp6
-rw-r--r--cpp/src/Ice/SlicedData.cpp31
-rw-r--r--cpp/src/Ice/Value.cpp8
-rw-r--r--cpp/src/slice2cpp/Gen.cpp16
-rw-r--r--cpp/src/slice2cs/Gen.cpp9
-rw-r--r--cpp/src/slice2java/Gen.cpp7
-rw-r--r--cpp/src/slice2java/GenCompat.cpp6
-rw-r--r--cpp/src/slice2objc/Gen.cpp5
8 files changed, 79 insertions, 9 deletions
diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp
index a0fb5b5c9da..a24aa01b3f7 100644
--- a/cpp/src/Ice/Object.cpp
+++ b/cpp/src/Ice/Object.cpp
@@ -120,6 +120,12 @@ Ice::Object::ice_clone() const
throw CloneNotImplementedException(__FILE__, __LINE__);
return 0; // avoid warning with some compilers
}
+
+Ice::SlicedDataPtr
+Ice::Object::ice_getSlicedData() const
+{
+ return 0;
+}
#endif
bool
diff --git a/cpp/src/Ice/SlicedData.cpp b/cpp/src/Ice/SlicedData.cpp
index 99871f5bafa..e9519d73d7d 100644
--- a/cpp/src/Ice/SlicedData.cpp
+++ b/cpp/src/Ice/SlicedData.cpp
@@ -30,6 +30,24 @@ Ice::SlicedData::SlicedData(const SliceInfoSeq& seq) :
{
}
+void
+Ice::SlicedData::clear()
+{
+ SliceInfoSeq tmp;
+ tmp.swap(const_cast<SliceInfoSeq&>(slices));
+ for(SliceInfoSeq::const_iterator p = tmp.begin(); p != tmp.end(); ++p)
+ {
+ for(vector<ValuePtr>::const_iterator q = (*p)->instances.begin(); q != (*p)->instances.end(); ++q)
+ {
+ Ice::SlicedDataPtr slicedData = (*q)->ice_getSlicedData();
+ if(slicedData)
+ {
+ slicedData->clear();
+ }
+ }
+ }
+}
+
#ifndef ICE_CPP11_MAPPING
void
Ice::SlicedData::_iceGcVisitMembers(IceInternal::GCVisitor& visitor)
@@ -57,7 +75,6 @@ Ice::UnknownSlicedValue::_iceGcVisitMembers(IceInternal::GCVisitor& _v)
_slicedData->_iceGcVisitMembers(_v);
}
}
-
#endif
Ice::UnknownSlicedValue::UnknownSlicedValue(const string& unknownTypeId) : _unknownTypeId(unknownTypeId)
@@ -70,12 +87,6 @@ Ice::UnknownSlicedValue::getUnknownTypeId() const
return _unknownTypeId;
}
-SlicedDataPtr
-Ice::UnknownSlicedValue::getSlicedData() const
-{
- return _slicedData;
-}
-
void
Ice::UnknownSlicedValue::_iceWrite(Ice::OutputStream* ostr) const
{
@@ -90,6 +101,12 @@ Ice::UnknownSlicedValue::_iceRead(Ice::InputStream* istr)
_slicedData = istr->endValue(true);
}
+SlicedDataPtr
+Ice::UnknownSlicedValue::ice_getSlicedData() const
+{
+ return _slicedData;
+}
+
#ifdef ICE_CPP11_MAPPING
string
diff --git a/cpp/src/Ice/Value.cpp b/cpp/src/Ice/Value.cpp
index 23e8beb1699..9b0a4ee5900 100644
--- a/cpp/src/Ice/Value.cpp
+++ b/cpp/src/Ice/Value.cpp
@@ -66,10 +66,16 @@ Ice::Value::ice_staticId()
return object_ids[0];
}
-ValuePtr
+shared_ptr<Value>
Ice::Value::ice_clone() const
{
return cloneImpl();
}
+shared_ptr<SlicedData>
+Ice::Value::ice_getSlicedData() const
+{
+ return nullptr;
+}
+
#endif
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 990ddd57d47..f017ad66b4b 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -2691,6 +2691,8 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
if(preserved && !basePreserved)
{
+ H << sp << nl << "virtual ::Ice::SlicedDataPtr ice_getSlicedData() const;";
+
H << sp;
H << nl << "virtual void _iceWrite(::Ice::OutputStream*) const;";
H << nl << "virtual void _iceRead(::Ice::InputStream*);";
@@ -2707,6 +2709,12 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
if(preserved && !basePreserved)
{
C << sp;
+ C << nl << "::Ice::SlicedDataPtr" << nl << scoped.substr(2) << "::ice_getSlicedData() const";
+ C << sb;
+ C << nl << "return _iceSlicedData;";
+ C << eb;
+
+ C << sp;
C << nl << "void" << nl << scoped.substr(2) << "::_iceWrite(::Ice::OutputStream* ostr) const";
C << sb;
C << nl << "ostr->startValue(_iceSlicedData);";
@@ -7314,6 +7322,14 @@ Slice::Gen::Cpp11ValueVisitor::visitClassDefEnd(const ClassDefPtr& p)
if(preserved && !basePreserved)
{
+ H << sp << nl << "virtual ::std::shared_ptr<::Ice::SlicedData> ice_getSlicedData() const override;";
+
+ C << sp;
+ C << nl << "::std::shared_ptr<::Ice::SlicedData>" << nl << scoped.substr(2) << "::ice_getSlicedData() const";
+ C << sb;
+ C << nl << "return _iceSlicedData;";
+ C << eb;
+
H << sp;
H << nl << "virtual void _iceWrite(::Ice::OutputStream*) const override;";
H << nl << "virtual void _iceRead(::Ice::InputStream*) override;";
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index ac8cee55560..1d8f88797e3 100644
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -774,7 +774,16 @@ Slice::CsVisitor::writeMarshaling(const ClassDefPtr& p)
{
emitGeneratedCodeAttribute();
}
+ _out << nl << "public override Ice.SlicedData ice_getSlicedData()";
+ _out << sb;
+ _out << nl << "return iceSlicedData_;";
+ _out << eb;
+ _out << sp;
+ if(!p->isInterface())
+ {
+ emitGeneratedCodeAttribute();
+ }
_out << nl << "public override void iceWrite(Ice.OutputStream ostr_)";
_out << sb;
_out << nl << "ostr_.startValue(iceSlicedData_);";
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index f5c1b430e67..15b2a939e23 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -1500,6 +1500,13 @@ Slice::JavaVisitor::writeMarshaling(Output& out, const ClassDefPtr& p)
{
out << sp;
out << nl << "@Override";
+ out << nl << "public com.zeroc.Ice.SlicedData ice_getSlicedData()";
+ out << sb;
+ out << nl << "return _iceSlicedData;";
+ out << eb;
+
+ out << sp;
+ out << nl << "@Override";
out << nl << "public void _iceWrite(com.zeroc.Ice.OutputStream ostr)";
out << sb;
out << nl << "ostr.startValue(_iceSlicedData);";
diff --git a/cpp/src/slice2java/GenCompat.cpp b/cpp/src/slice2java/GenCompat.cpp
index ff59af9df2a..14279536038 100644
--- a/cpp/src/slice2java/GenCompat.cpp
+++ b/cpp/src/slice2java/GenCompat.cpp
@@ -1680,6 +1680,11 @@ Slice::JavaCompatVisitor::writeDispatchAndMarshalling(Output& out, const ClassDe
if(preserved && !basePreserved)
{
+ out << sp << nl << "public Ice.SlicedData ice_getSlicedData()";
+ out << sb;
+ out << nl << "return _iceSlicedData;";
+ out << eb;
+
out << sp << nl << "public void _iceWrite(Ice.OutputStream ostr)";
out << sb;
out << nl << "ostr.startValue(_iceSlicedData);";
@@ -3417,7 +3422,6 @@ Slice::GenCompat::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
if(preserved && !basePreserved)
{
-
out << sp << nl << "public void" << nl << "_write(Ice.OutputStream ostr)";
out << sb;
out << nl << "ostr.startException(_slicedData);";
diff --git a/cpp/src/slice2objc/Gen.cpp b/cpp/src/slice2objc/Gen.cpp
index 17a91efac8e..3aba530c16b 100644
--- a/cpp/src/slice2objc/Gen.cpp
+++ b/cpp/src/slice2objc/Gen.cpp
@@ -1155,6 +1155,11 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
if(preserved && !basePreserved)
{
+ _M << nl << "-(id<ICESlicedData>) ice_getSlicedData";
+ _M << sb;
+ _M << nl << "return iceSlicedData_;";
+ _M << eb;
+
_M << nl << "-(void) iceWrite:(id<ICEOutputStream>)ostr";
_M << sb;
_M << nl << "[ostr startValue:iceSlicedData_];";