diff options
author | Jose <jose@zeroc.com> | 2016-01-11 17:21:46 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2016-01-11 17:21:46 +0100 |
commit | 6fece3700ac31712b6d8892108a17e01cb2614be (patch) | |
tree | 9cdcfed91e78c9bd226881ee594f58a09fba38a6 /cpp/src | |
parent | Fix Ice/location test failures with C++11 (diff) | |
download | ice-6fece3700ac31712b6d8892108a17e01cb2614be.tar.bz2 ice-6fece3700ac31712b6d8892108a17e01cb2614be.tar.xz ice-6fece3700ac31712b6d8892108a17e01cb2614be.zip |
Add ICE_RESET_EXCEPTION macro to simplify C++ builds
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Glacier2Lib/SessionHelper.cpp | 6 | ||||
-rw-r--r-- | cpp/src/Ice/AsyncResult.cpp | 43 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionI.cpp | 6 | ||||
-rw-r--r-- | cpp/src/Ice/LocatorInfo.cpp | 7 | ||||
-rw-r--r-- | cpp/src/Ice/Outgoing.cpp | 31 | ||||
-rw-r--r-- | cpp/src/Ice/Reference.cpp | 13 |
6 files changed, 22 insertions, 84 deletions
diff --git a/cpp/src/Glacier2Lib/SessionHelper.cpp b/cpp/src/Glacier2Lib/SessionHelper.cpp index bc0f625d503..2aebb4cfc30 100644 --- a/cpp/src/Glacier2Lib/SessionHelper.cpp +++ b/cpp/src/Glacier2Lib/SessionHelper.cpp @@ -507,11 +507,7 @@ public: _callback(callback), _session(session) { -#ifdef ICE_CPP11_MAPPING - _ex = ex.ice_clone(); -#else - _ex.reset(ex.ice_clone()); -#endif + ICE_RESET_EXCEPTION(_ex, ex.ice_clone()); } virtual void diff --git a/cpp/src/Ice/AsyncResult.cpp b/cpp/src/Ice/AsyncResult.cpp index 5848747810e..7387366cbed 100644 --- a/cpp/src/Ice/AsyncResult.cpp +++ b/cpp/src/Ice/AsyncResult.cpp @@ -50,7 +50,7 @@ AsyncResult::getCommunicator() const ConnectionPtr AsyncResult::getConnection() const { - return 0; + return ICE_NULLPTR; } ObjectPrxPtr @@ -299,11 +299,7 @@ AsyncResult::finished(const Ice::Exception& ex) { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); _state |= Done; -#ifdef ICE_CPP11_MAPPING - _exception = ex.ice_clone(); -#else - _exception.reset(ex.ice_clone()); -#endif + ICE_RESET_EXCEPTION(_exception, ex.ice_clone()); _cancellationHandler = 0; _observer.failed(ex.ice_name()); if(!_callback) @@ -438,55 +434,34 @@ AsyncResult::cancel(const Ice::LocalException& ex) CancellationHandlerPtr handler; { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); -#ifdef ICE_CPP11_MAPPING - _cancellationException = ex.ice_clone(); -#else - _cancellationException.reset(ex.ice_clone()); -#endif + ICE_RESET_EXCEPTION(_cancellationException, ex.ice_clone()); if(!_cancellationHandler) { return; } handler = _cancellationHandler; } -#ifdef ICE_CPP11_MAPPING - handler->asyncRequestCanceled(dynamic_pointer_cast<OutgoingAsyncBase>(shared_from_this()), ex); -#else - handler->asyncRequestCanceled(OutgoingAsyncBasePtr::dynamicCast(this), ex); -#endif + handler->asyncRequestCanceled(ICE_DYNAMIC_CAST(OutgoingAsyncBase, shared_from_this()), ex); } void AsyncResult::cancelable(const CancellationHandlerPtr& handler) { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); -#ifdef ICE_CPP11_MAPPING - if(_cancellationException) - { - try - { - rethrow_exception(_cancellationException); - } - catch(const Ice::Exception&) - { - _cancellationException = nullptr; - throw; - } - } -#else - if(_cancellationException.get()) + + + if(ICE_EXCEPTION_GET(_cancellationException)) { try { - _cancellationException->ice_throw(); + ICE_RETHROW_EXCEPTION(_cancellationException); } catch(const Ice::Exception&) { - _cancellationException.reset(0); + ICE_RESET_EXCEPTION(_cancellationException, ICE_NULLPTR); throw; } } -#endif _cancellationHandler = handler; } diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp index d3b54bfa386..cb7fcfc5d3f 100644 --- a/cpp/src/Ice/ConnectionI.cpp +++ b/cpp/src/Ice/ConnectionI.cpp @@ -2384,11 +2384,7 @@ Ice::ConnectionI::setState(State state, const LocalException& ex) // If we are in closed state, an exception must be set. // assert(_state != StateClosed); -#ifdef ICE_CPP11_MAPPING - _exception = ex.ice_clone(); -#else - _exception.reset(ex.ice_clone()); -#endif + ICE_RESET_EXCEPTION(_exception, ex.ice_clone()); // // We don't warn if we are not validated. // diff --git a/cpp/src/Ice/LocatorInfo.cpp b/cpp/src/Ice/LocatorInfo.cpp index ae3936fccb2..4bc0c4cc165 100644 --- a/cpp/src/Ice/LocatorInfo.cpp +++ b/cpp/src/Ice/LocatorInfo.cpp @@ -555,11 +555,8 @@ IceInternal::LocatorInfo::Request::exception(const Ice::Exception& ex) { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); _locatorInfo->finishRequest(_ref, _wellKnownRefs, 0, dynamic_cast<const Ice::UserException*>(&ex)); -#ifdef ICE_CPP11_MAPPING - _exception = ex.ice_clone(); -#else - _exception.reset(ex.ice_clone()); -#endif + + ICE_RESET_EXCEPTION(_exception, ex.ice_clone()); _monitor.notifyAll(); } for(vector<RequestCallbackPtr>::const_iterator p = _callbacks.begin(); p != _callbacks.end(); ++p) diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp index d3291ff1ddf..2a12baf84d9 100644 --- a/cpp/src/Ice/Outgoing.cpp +++ b/cpp/src/Ice/Outgoing.cpp @@ -86,11 +86,7 @@ ProxyOutgoingBase::completed(const Ice::Exception& ex) _childObserver.detach(); _state = StateFailed; -#ifdef ICE_CPP11_MAPPING - _exception = ex.ice_clone(); -#else - _exception.reset(ex.ice_clone()); -#endif + ICE_RESET_EXCEPTION(_exception, ex.ice_clone()); _monitor.notify(); } @@ -126,11 +122,7 @@ ProxyOutgoingBase::invokeImpl() } _state = StateInProgress; -#ifdef ICE_CPP11_MAPPING - _exception = nullptr; -#else - _exception.reset(0); -#endif + ICE_RESET_EXCEPTION(_exception, ICE_NULLPTR); _sent = false; _handler = _proxy->__getRequestHandler(); @@ -509,12 +501,7 @@ Outgoing::completed(BasicStream& is) ex->id = ident; ex->facet = facet; ex->operation = operation; -#ifdef ICE_CPP11_MAPPING - _exception = ex->ice_clone(); -#else - _exception.reset(ex); -#endif - + ICE_RESET_EXCEPTION(_exception, ex->ice_clone()); _state = StateLocalException; // The state must be set last, in case there is an exception. break; } @@ -561,11 +548,7 @@ Outgoing::completed(BasicStream& is) } ex->unknown = unknown; -#ifdef ICE_CPP11_MAPPING - _exception = ex->ice_clone(); -#else - _exception.reset(ex); -#endif + ICE_RESET_EXCEPTION(_exception, ex->ice_clone()); _state = StateLocalException; // The state must be set last, in case there is an exception. break; } @@ -699,11 +682,7 @@ ConnectionFlushBatch::completed(const Ice::Exception& ex) Monitor<Mutex>::Lock sync(_monitor); _childObserver.failed(ex.ice_name()); _childObserver.detach(); -#ifdef ICE_CPP11_MAPPING - _exception = ex.ice_clone(); -#else - _exception.reset(ex.ice_clone()); -#endif + ICE_RESET_EXCEPTION(_exception, ex.ice_clone()); _monitor.notify(); } diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp index 737d4bdbfe6..f002b8356f6 100644 --- a/cpp/src/Ice/Reference.cpp +++ b/cpp/src/Ice/Reference.cpp @@ -1777,12 +1777,12 @@ IceInternal::RoutableReference::createConnection(const vector<EndpointIPtr>& all virtual void setException(const Ice::LocalException& ex) { -#ifdef ICE_CPP11_MAPPING - if(!_exception) + if(!ICE_EXCEPTION_GET(_exception)) { - _exception = ex.ice_clone(); + ICE_RESET_EXCEPTION(_exception, ex.ice_clone()); } - + +#ifdef ICE_CPP11_MAPPING try { rethrow_exception(_exception); @@ -1796,11 +1796,6 @@ IceInternal::RoutableReference::createConnection(const vector<EndpointIPtr>& all } } #else - if(!_exception.get()) - { - _exception.reset(ex.ice_clone()); - } - if(++_i == _endpoints.size()) { _callback->setException(*_exception.get()); |