summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2017-07-06 00:18:03 +0200
committerBenoit Foucher <benoit@zeroc.com>2017-07-06 00:18:03 +0200
commit54d8f3fb0d3d53f851051980f1bc941c4e39a60f (patch)
tree0d8259f0cd48b3ba0a3792556821aa41d6f718a7 /cpp
parentFixed ICE-8223 - renamed cloneImpl to _iceCloneImpl (diff)
downloadice-54d8f3fb0d3d53f851051980f1bc941c4e39a60f.tar.bz2
ice-54d8f3fb0d3d53f851051980f1bc941c4e39a60f.tar.xz
ice-54d8f3fb0d3d53f851051980f1bc941c4e39a60f.zip
Added Ice::UserException::ice_getSlicedData and Ice::UnkownSlicedValue::ice_id methods
Diffstat (limited to 'cpp')
-rw-r--r--cpp/include/Ice/Exception.h12
-rw-r--r--cpp/include/Ice/SlicedData.h4
-rw-r--r--cpp/src/Ice/Exception.cpp8
-rw-r--r--cpp/src/Ice/SlicedData.cpp12
-rw-r--r--cpp/src/slice2cpp/Gen.cpp23
-rw-r--r--cpp/src/slice2cs/Gen.cpp7
-rw-r--r--cpp/src/slice2java/Gen.cpp7
-rw-r--r--cpp/src/slice2java/GenCompat.cpp6
-rw-r--r--cpp/src/slice2objc/Gen.cpp7
-rw-r--r--cpp/test/Ice/optional/AllTests.cpp12
-rw-r--r--cpp/test/Ice/slicing/exceptions/AllTests.cpp61
-rw-r--r--cpp/test/Ice/slicing/objects/AllTests.cpp6
12 files changed, 138 insertions, 27 deletions
diff --git a/cpp/include/Ice/Exception.h b/cpp/include/Ice/Exception.h
index cb50bd2a9c1..8c5803b9d24 100644
--- a/cpp/include/Ice/Exception.h
+++ b/cpp/include/Ice/Exception.h
@@ -16,6 +16,7 @@
#include <Ice/Handle.h>
#include <Ice/ObjectF.h>
#include <Ice/ValueF.h>
+#include <Ice/SlicedDataF.h>
namespace Ice
{
@@ -57,19 +58,20 @@ class ICE_API UserException : public IceUtil::Exception
{
public:
- virtual void _write(::Ice::OutputStream*) const;
- virtual void _read(::Ice::InputStream*);
-
- virtual bool _usesClasses() const;
-
#ifdef ICE_CPP11_MAPPING
std::unique_ptr<UserException> ice_clone() const;
#else
virtual UserException* ice_clone() const = 0;
#endif
+ virtual Ice::SlicedDataPtr ice_getSlicedData() const;
static const std::string& ice_staticId();
+ virtual void _write(::Ice::OutputStream*) const;
+ virtual void _read(::Ice::InputStream*);
+
+ virtual bool _usesClasses() const;
+
protected:
virtual void _writeImpl(::Ice::OutputStream*) const {}
diff --git a/cpp/include/Ice/SlicedData.h b/cpp/include/Ice/SlicedData.h
index bd3761840d9..b4837274b19 100644
--- a/cpp/include/Ice/SlicedData.h
+++ b/cpp/include/Ice/SlicedData.h
@@ -99,11 +99,8 @@ public:
UnknownSlicedValue(const std::string&);
- const std::string& getUnknownTypeId() const;
-
#ifdef ICE_CPP11_MAPPING
virtual SlicedDataPtr ice_getSlicedData() const override;
-
virtual std::string ice_id() const override;
std::shared_ptr<UnknownSlicedValue> ice_clone() const;
@@ -115,6 +112,7 @@ protected:
virtual std::shared_ptr<Value> _iceCloneImpl() const override;
#else
virtual SlicedDataPtr ice_getSlicedData() const;
+ virtual const std::string& ice_id(const Current& = Ice::emptyCurrent) const;
virtual void _iceGcVisitMembers(IceInternal::GCVisitor&);
virtual void _iceWrite(::Ice::OutputStream*) const;
diff --git a/cpp/src/Ice/Exception.cpp b/cpp/src/Ice/Exception.cpp
index 9faa0bddc71..968f9d3edbc 100644
--- a/cpp/src/Ice/Exception.cpp
+++ b/cpp/src/Ice/Exception.cpp
@@ -77,7 +77,7 @@ throwUOE(const string& expectedType, const ValuePtr& v)
UnknownSlicedValue* usv = dynamic_cast<UnknownSlicedValue*>(v.get());
if(usv)
{
- throw NoValueFactoryException(__FILE__, __LINE__, "", usv->getUnknownTypeId());
+ throw NoValueFactoryException(__FILE__, __LINE__, "", usv->ice_id());
}
string type = v->ice_id();
@@ -127,6 +127,12 @@ Ice::UserException::ice_clone() const
}
#endif
+Ice::SlicedDataPtr
+Ice::UserException::ice_getSlicedData() const
+{
+ return ICE_NULLPTR;
+}
+
void
Ice::UserException::_write(::Ice::OutputStream* os) const
{
diff --git a/cpp/src/Ice/SlicedData.cpp b/cpp/src/Ice/SlicedData.cpp
index 56b10f6aba1..ced50e1211c 100644
--- a/cpp/src/Ice/SlicedData.cpp
+++ b/cpp/src/Ice/SlicedData.cpp
@@ -72,12 +72,6 @@ Ice::UnknownSlicedValue::UnknownSlicedValue(const string& unknownTypeId) : _unkn
{
}
-const string&
-Ice::UnknownSlicedValue::getUnknownTypeId() const
-{
- return _unknownTypeId;
-}
-
SlicedDataPtr
Ice::UnknownSlicedValue::ice_getSlicedData() const
{
@@ -106,6 +100,12 @@ Ice::UnknownSlicedValue::_iceCloneImpl() const
#else
+const string&
+Ice::UnknownSlicedValue::ice_id(const Current&) const
+{
+ return _unknownTypeId;
+}
+
void
Ice::UnknownSlicedValue::_iceGcVisitMembers(IceInternal::GCVisitor& _v)
{
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index f017ad66b4b..81b0ef1dcc5 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -1193,7 +1193,11 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
if(preserved && !basePreserved)
{
- H << sp << nl << "virtual void _write(::Ice::OutputStream*) const;";
+ H << sp;
+ H << nl << "virtual ::Ice::SlicedDataPtr ice_getSlicedData() const;";
+
+ H << sp;
+ H << nl << "virtual void _write(::Ice::OutputStream*) const;";
H << nl << "virtual void _read(::Ice::InputStream*);";
string baseName = base ? fixKwd(base->scoped()) : string("::Ice::UserException");
@@ -1215,6 +1219,12 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
H << sp << nl << "::Ice::SlicedDataPtr _slicedData;";
+ C << sp;
+ C << nl << "::Ice::SlicedDataPtr" << nl << scoped.substr(2) << "::ice_getSlicedData() const";
+ C << sb;
+ C << nl << "return _slicedData;";
+ C << eb;
+
C << sp << nl << "void" << nl << scoped.substr(2) << "::_write(::Ice::OutputStream* ostr) const";
C << sb;
C << nl << "ostr->startException(_slicedData);";
@@ -5576,11 +5586,20 @@ Slice::Gen::Cpp11TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
if(preserved && !basePreserved)
{
- H << sp << nl << _dllMemberExport << "virtual void _write(::Ice::OutputStream*) const override;";
+ H << sp;
+ H << nl << _dllMemberExport << "virtual ::std::shared_ptr<::Ice::SlicedData> ice_getSlicedData() const override;";
+ H << sp;
+ H << nl << _dllMemberExport << "virtual void _write(::Ice::OutputStream*) const override;";
H << nl << _dllMemberExport << "virtual void _read(::Ice::InputStream*) override;";
H << sp << nl << "::std::shared_ptr<::Ice::SlicedData> _slicedData;";
+ C << sp;
+ C << nl << "::std::shared_ptr<::Ice::SlicedData>" << nl << scoped.substr(2) << "::ice_getSlicedData() const";
+ C << sb;
+ C << nl << "return _slicedData;";
+ C << eb;
+
C << sp << nl << "void" << nl << scoped.substr(2) << "::_write(::Ice::OutputStream* ostr) const";
C << sb;
C << nl << "ostr->startException(_slicedData);";
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index 1d8f88797e3..b70aae7be01 100644
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -2797,6 +2797,13 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
{
_out << sp;
emitGeneratedCodeAttribute();
+ _out << nl << "public override Ice.SlicedData ice_getSlicedData()";
+ _out << sb;
+ _out << nl << "return slicedData_;";
+ _out << eb;
+
+ _out << sp;
+ emitGeneratedCodeAttribute();
_out << nl << "public override void iceWrite(Ice.OutputStream ostr_)";
_out << sb;
_out << nl << "ostr_.startException(slicedData_);";
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index 15b2a939e23..e6a225a11a6 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -3136,6 +3136,13 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
{
out << sp;
out << nl << "@Override";
+ out << nl << "public com.zeroc.Ice.SlicedData ice_getSlicedData()";
+ out << sb;
+ out << nl << "return _slicedData;";
+ out << eb;
+
+ out << sp;
+ out << nl << "@Override";
out << nl << "public void _write(com.zeroc.Ice.OutputStream ostr)";
out << sb;
out << nl << "ostr.startException(_slicedData);";
diff --git a/cpp/src/slice2java/GenCompat.cpp b/cpp/src/slice2java/GenCompat.cpp
index 14279536038..e09db4c6c3b 100644
--- a/cpp/src/slice2java/GenCompat.cpp
+++ b/cpp/src/slice2java/GenCompat.cpp
@@ -3422,6 +3422,12 @@ Slice::GenCompat::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
if(preserved && !basePreserved)
{
+ out << sp;
+ out << nl << "public Ice.SlicedData " << nl << "ice_getSlicedData()";
+ out << sb;
+ out << nl << "return _slicedData;";
+ out << eb;
+
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 3aba530c16b..6e34a182f54 100644
--- a/cpp/src/slice2objc/Gen.cpp
+++ b/cpp/src/slice2objc/Gen.cpp
@@ -1157,7 +1157,7 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
{
_M << nl << "-(id<ICESlicedData>) ice_getSlicedData";
_M << sb;
- _M << nl << "return iceSlicedData_;";
+ _M << nl << "return ICE_AUTORELEASE(ICE_RETAIN(iceSlicedData_));";
_M << eb;
_M << nl << "-(void) iceWrite:(id<ICEOutputStream>)ostr";
@@ -1404,6 +1404,11 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
if(preserved && !basePreserved)
{
+ _M << nl << nl << "-(id<ICESlicedData>) ice_getSlicedData";
+ _M << sb;
+ _M << nl << "return ICE_AUTORELEASE(ICE_RETAIN(slicedData_));";
+ _M << eb;
+
_M << nl << nl << "-(void) iceWrite:(id<ICEOutputStream>)ostr";
_M << sb;
_M << nl << "[ostr startException:slicedData_];";
diff --git a/cpp/test/Ice/optional/AllTests.cpp b/cpp/test/Ice/optional/AllTests.cpp
index ba90f0a95a4..3b6963a0544 100644
--- a/cpp/test/Ice/optional/AllTests.cpp
+++ b/cpp/test/Ice/optional/AllTests.cpp
@@ -64,7 +64,7 @@ public:
protected:
- virtual std::shared_ptr<Value> cloneImpl() const
+ virtual std::shared_ptr<Value> _iceCloneImpl() const
{
assert(0); // not used
return nullptr;
@@ -101,7 +101,7 @@ public:
protected:
- virtual std::shared_ptr<Value> cloneImpl() const
+ virtual std::shared_ptr<Value> _iceCloneImpl() const
{
assert(0); // not used
return nullptr;
@@ -141,7 +141,7 @@ public:
protected:
- virtual std::shared_ptr<Value> cloneImpl() const
+ virtual std::shared_ptr<Value> _iceCloneImpl() const
{
assert(0); // not used
return nullptr;
@@ -194,7 +194,7 @@ public:
protected:
- virtual std::shared_ptr<Value> cloneImpl() const
+ virtual std::shared_ptr<Value> _iceCloneImpl() const
{
assert(0); // not used
return nullptr;
@@ -248,7 +248,7 @@ public:
protected:
- virtual std::shared_ptr<Value> cloneImpl() const
+ virtual std::shared_ptr<Value> _iceCloneImpl() const
{
assert(0); // not used
return nullptr;
@@ -294,7 +294,7 @@ public:
protected:
- virtual std::shared_ptr<Value> cloneImpl() const
+ virtual std::shared_ptr<Value> _iceCloneImpl() const
{
assert(0); // not used
return nullptr;
diff --git a/cpp/test/Ice/slicing/exceptions/AllTests.cpp b/cpp/test/Ice/slicing/exceptions/AllTests.cpp
index abc1692e45c..3a428d30440 100644
--- a/cpp/test/Ice/slicing/exceptions/AllTests.cpp
+++ b/cpp/test/Ice/slicing/exceptions/AllTests.cpp
@@ -1040,6 +1040,67 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "ok" << endl;
cout << "preserved exceptions... " << flush;
+ try
+ {
+ test->unknownPreservedAsBase();
+ test(false);
+ }
+ catch(const Base& ex)
+ {
+ if(test->ice_getEncodingVersion() == Ice::Encoding_1_0)
+ {
+ test(!ex.ice_getSlicedData());
+ }
+ else
+ {
+ Ice::SlicedDataPtr slicedData = ex.ice_getSlicedData();
+ test(slicedData);
+ test(slicedData->slices.size() == 2);
+ test(slicedData->slices[1]->typeId == "::Test::SPreserved1");
+ test(slicedData->slices[0]->typeId == "::Test::SPreserved2");
+ }
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ cerr << ex << endl;
+ test(false);
+ }
+ catch(...)
+ {
+ test(false);
+ }
+
+ try
+ {
+ test->unknownPreservedAsKnownPreserved();
+ test(false);
+ }
+ catch(const KnownPreserved& ex)
+ {
+ test(ex.kp == "preserved");
+ if(test->ice_getEncodingVersion() == Ice::Encoding_1_0)
+ {
+ test(!ex.ice_getSlicedData());
+ }
+ else
+ {
+ Ice::SlicedDataPtr slicedData = ex.ice_getSlicedData();
+ test(slicedData);
+ test(slicedData->slices.size() == 2);
+ test(slicedData->slices[1]->typeId == "::Test::SPreserved1");
+ test(slicedData->slices[0]->typeId == "::Test::SPreserved2");
+ }
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ cerr << ex << endl;
+ test(false);
+ }
+ catch(...)
+ {
+ test(false);
+ }
+
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("");
RelayPrxPtr relay = ICE_UNCHECKED_CAST(RelayPrx, adapter->addWithUUID(ICE_MAKE_SHARED(RelayI)));
adapter->activate();
diff --git a/cpp/test/Ice/slicing/objects/AllTests.cpp b/cpp/test/Ice/slicing/objects/AllTests.cpp
index 1ebd464f721..d2ca27a998f 100644
--- a/cpp/test/Ice/slicing/objects/AllTests.cpp
+++ b/cpp/test/Ice/slicing/objects/AllTests.cpp
@@ -130,7 +130,7 @@ public:
response_SUnknownAsObject11(const Ice::ObjectPtr& o)
{
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_id() == "::Test::SUnknown");
called();
}
@@ -578,7 +578,7 @@ testUOO(const TestIntfPrxPtr& test)
o = test->SUnknownAsObject();
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_id() == "::Test::SUnknown");
test(ICE_DYNAMIC_CAST(Ice::UnknownSlicedValue, o)->ice_getSlicedData());
test->checkSUnknown(o);
}
@@ -938,7 +938,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
{
shared_ptr<Ice::Value> v = f.get();
test(dynamic_pointer_cast<Ice::UnknownSlicedValue>(v));
- test(dynamic_pointer_cast<Ice::UnknownSlicedValue>(v)->getUnknownTypeId() == "::Test::SUnknown");
+ test(dynamic_pointer_cast<Ice::UnknownSlicedValue>(v)->ice_id() == "::Test::SUnknown");
}
catch(...)
{