diff options
author | Benoit Foucher <benoit@zeroc.com> | 2017-07-05 12:10:49 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2017-07-05 12:10:49 +0200 |
commit | e706fb2ceb23b1ee3c225f6d9569c58359b4ee72 (patch) | |
tree | 56d6d90d0a079d89ee7b2ab1c1013055cdca6e29 /cpp | |
parent | ICE-8218 - Windows OpenSSL test build failure with parallel builds (diff) | |
download | ice-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')
-rw-r--r-- | cpp/include/Ice/Object.h | 3 | ||||
-rw-r--r-- | cpp/include/Ice/SlicedData.h | 11 | ||||
-rw-r--r-- | cpp/include/Ice/Value.h | 3 | ||||
-rw-r--r-- | cpp/src/Ice/Object.cpp | 6 | ||||
-rw-r--r-- | cpp/src/Ice/SlicedData.cpp | 31 | ||||
-rw-r--r-- | cpp/src/Ice/Value.cpp | 8 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 16 | ||||
-rw-r--r-- | cpp/src/slice2cs/Gen.cpp | 9 | ||||
-rw-r--r-- | cpp/src/slice2java/Gen.cpp | 7 | ||||
-rw-r--r-- | cpp/src/slice2java/GenCompat.cpp | 6 | ||||
-rw-r--r-- | cpp/src/slice2objc/Gen.cpp | 5 | ||||
-rw-r--r-- | cpp/test/Ice/slicing/objects/AllTests.cpp | 9 | ||||
-rw-r--r-- | cpp/test/ios/controller/C++ Test Controller.xcodeproj/xcshareddata/xcschemes/C++11 Test Controller.xcscheme | 2 | ||||
-rw-r--r-- | cpp/test/ios/controller/C++ Test Controller.xcodeproj/xcshareddata/xcschemes/C++98 Test Controller.xcscheme | 2 |
14 files changed, 105 insertions, 13 deletions
diff --git a/cpp/include/Ice/Object.h b/cpp/include/Ice/Object.h index 94418425359..f506d9c6e7c 100644 --- a/cpp/include/Ice/Object.h +++ b/cpp/include/Ice/Object.h @@ -15,6 +15,7 @@ #include <Ice/ObjectF.h> #include <Ice/ProxyF.h> #include <Ice/IncomingAsyncF.h> +#include <Ice/SlicedDataF.h> #include <Ice/Current.h> #include <Ice/Format.h> @@ -134,6 +135,8 @@ public: virtual ObjectPtr ice_clone() const; + virtual SlicedDataPtr ice_getSlicedData() const; + virtual bool ice_dispatch(Ice::Request&, const DispatchInterceptorAsyncCallbackPtr& = 0); virtual bool _iceDispatch(IceInternal::Incoming&, const Current&); diff --git a/cpp/include/Ice/SlicedData.h b/cpp/include/Ice/SlicedData.h index 6774885028f..a97b385200e 100644 --- a/cpp/include/Ice/SlicedData.h +++ b/cpp/include/Ice/SlicedData.h @@ -73,9 +73,16 @@ public: SlicedData(const SliceInfoSeq&); const SliceInfoSeq slices; + + // + // Clear the slices to break potential cyclic references. + // + void clear(); + #ifndef ICE_CPP11_MAPPING void _iceGcVisitMembers(IceInternal::GCVisitor&); #endif + }; // @@ -94,11 +101,10 @@ public: const std::string& getUnknownTypeId() const; - SlicedDataPtr getSlicedData() const; - #ifdef ICE_CPP11_MAPPING virtual void _iceWrite(::Ice::OutputStream*) const override; virtual void _iceRead(::Ice::InputStream*) override; + virtual SlicedDataPtr ice_getSlicedData() const override; virtual std::string ice_id() const override; std::shared_ptr<UnknownSlicedValue> ice_clone() const; @@ -111,6 +117,7 @@ protected: virtual void _iceWrite(::Ice::OutputStream*) const; virtual void _iceRead(::Ice::InputStream*); + virtual SlicedDataPtr ice_getSlicedData() const; #endif private: diff --git a/cpp/include/Ice/Value.h b/cpp/include/Ice/Value.h index 7687d27b02f..d2dcf22052e 100644 --- a/cpp/include/Ice/Value.h +++ b/cpp/include/Ice/Value.h @@ -13,6 +13,7 @@ #ifdef ICE_CPP11_MAPPING // C++11 mapping #include <Ice/ValueF.h> +#include <Ice/SlicedDataF.h> #include <Ice/OutputStream.h> #include <Ice/InputStream.h> @@ -46,6 +47,8 @@ public: std::shared_ptr<Value> ice_clone() const; + virtual std::shared_ptr<SlicedData> ice_getSlicedData() const; + protected: virtual std::shared_ptr<Value> cloneImpl() const = 0; 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_];"; diff --git a/cpp/test/Ice/slicing/objects/AllTests.cpp b/cpp/test/Ice/slicing/objects/AllTests.cpp index ee1600970fa..1ebd464f721 100644 --- a/cpp/test/Ice/slicing/objects/AllTests.cpp +++ b/cpp/test/Ice/slicing/objects/AllTests.cpp @@ -579,6 +579,7 @@ testUOO(const TestIntfPrxPtr& test) test(test->ice_getEncodingVersion() != Ice::Encoding_1_0); test(ICE_DYNAMIC_CAST(Ice::UnknownSlicedValue, o)); test(ICE_DYNAMIC_CAST(Ice::UnknownSlicedValue, o)->getUnknownTypeId() == "::Test::SUnknown"); + test(ICE_DYNAMIC_CAST(Ice::UnknownSlicedValue, o)->ice_getSlicedData()); test->checkSUnknown(o); } catch(const Ice::NoValueFactoryException&) @@ -2646,8 +2647,16 @@ allTests(const Ice::CommunicatorPtr& communicator) test->checkPBSUnknown(p); if(test->ice_getEncodingVersion() != Ice::Encoding_1_0) { + Ice::SlicedDataPtr slicedData = p->ice_getSlicedData(); + test(slicedData); + test(slicedData->slices.size() == 1); + test(slicedData->slices[0]->typeId == "::Test::PSUnknown"); test->ice_encodingVersion(Ice::Encoding_1_0)->checkPBSUnknown(p); } + else + { + test(!p->ice_getSlicedData()); + } } catch(const Ice::OperationNotExistException&) { diff --git a/cpp/test/ios/controller/C++ Test Controller.xcodeproj/xcshareddata/xcschemes/C++11 Test Controller.xcscheme b/cpp/test/ios/controller/C++ Test Controller.xcodeproj/xcshareddata/xcschemes/C++11 Test Controller.xcscheme index 307192b951e..ac70bec4ac2 100644 --- a/cpp/test/ios/controller/C++ Test Controller.xcodeproj/xcshareddata/xcschemes/C++11 Test Controller.xcscheme +++ b/cpp/test/ios/controller/C++ Test Controller.xcodeproj/xcshareddata/xcschemes/C++11 Test Controller.xcscheme @@ -65,7 +65,7 @@ </AdditionalOptions> </LaunchAction> <ProfileAction - buildConfiguration = "Release" + buildConfiguration = "Debug" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" diff --git a/cpp/test/ios/controller/C++ Test Controller.xcodeproj/xcshareddata/xcschemes/C++98 Test Controller.xcscheme b/cpp/test/ios/controller/C++ Test Controller.xcodeproj/xcshareddata/xcschemes/C++98 Test Controller.xcscheme index 4bf4f93f1ba..8f0e6376bcb 100644 --- a/cpp/test/ios/controller/C++ Test Controller.xcodeproj/xcshareddata/xcschemes/C++98 Test Controller.xcscheme +++ b/cpp/test/ios/controller/C++ Test Controller.xcodeproj/xcshareddata/xcschemes/C++98 Test Controller.xcscheme @@ -65,7 +65,7 @@ </AdditionalOptions> </LaunchAction> <ProfileAction - buildConfiguration = "Release" + buildConfiguration = "Debug" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" |