diff options
author | Bernard Normier <bernard@zeroc.com> | 2016-07-22 17:09:25 -0400 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2016-07-22 17:09:25 -0400 |
commit | 752e06b4eb63abb8a30bb958802eaedda72d3806 (patch) | |
tree | 7c2348544d202c310a55a62629abc4025daa03a5 /cpp/src/IceUtil | |
parent | Disable VS 2015 update 3 optimizer (diff) | |
download | ice-752e06b4eb63abb8a30bb958802eaedda72d3806.tar.bz2 ice-752e06b4eb63abb8a30bb958802eaedda72d3806.tar.xz ice-752e06b4eb63abb8a30bb958802eaedda72d3806.zip |
Added ICE_BUILDING_SRC to make builds
Ice::Dispatcher and Ice::LocalObject are now hidden with C++11
Reworked C++11 exception ice_clone, added ExceptionHelper
+ other C++ cleanups
Diffstat (limited to 'cpp/src/IceUtil')
-rw-r--r-- | cpp/src/IceUtil/CtrlCHandler.cpp | 21 | ||||
-rw-r--r-- | cpp/src/IceUtil/Options.cpp | 16 | ||||
-rw-r--r-- | cpp/src/IceUtil/ThreadException.cpp | 60 | ||||
-rw-r--r-- | cpp/src/IceUtil/UtilException.cpp | 109 |
4 files changed, 50 insertions, 156 deletions
diff --git a/cpp/src/IceUtil/CtrlCHandler.cpp b/cpp/src/IceUtil/CtrlCHandler.cpp index 6eac2e7e05a..4fd8fe406fd 100644 --- a/cpp/src/IceUtil/CtrlCHandler.cpp +++ b/cpp/src/IceUtil/CtrlCHandler.cpp @@ -51,7 +51,7 @@ Init init; } CtrlCHandlerException::CtrlCHandlerException(const char* file, int line) : - Exception(file, line) + ExceptionHelper<CtrlCHandlerException>(file, line) { } @@ -70,19 +70,13 @@ CtrlCHandlerException::ice_clone() const #endif void -CtrlCHandlerException::ice_throw() const -{ - throw *this; -} - -void CtrlCHandler::setCallback(CtrlCHandlerCallback callback) { IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(globalMutex); _callback = callback; } -CtrlCHandlerCallback +CtrlCHandlerCallback CtrlCHandler::getCallback() const { IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(globalMutex); @@ -140,10 +134,10 @@ CtrlCHandler::~CtrlCHandler() #else -extern "C" +extern "C" { -static void* +static void* sigwaitThread(void*) { sigset_t ctrlCLikeSignals; @@ -168,7 +162,7 @@ sigwaitThread(void*) continue; } assert(rc == 0); - + CtrlCHandlerCallback callback; { IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(globalMutex); @@ -211,11 +205,11 @@ CtrlCHandler::CtrlCHandler(CtrlCHandlerCallback callback) _handler = this; lock.release(); - + // We block these CTRL+C like signals in the main thread, // and by default all other threads will inherit this signal // mask. - + sigset_t ctrlCLikeSignals; sigemptyset(&ctrlCLikeSignals); sigaddset(&ctrlCLikeSignals, SIGHUP); @@ -265,4 +259,3 @@ CtrlCHandler::~CtrlCHandler() } #endif - diff --git a/cpp/src/IceUtil/Options.cpp b/cpp/src/IceUtil/Options.cpp index 55615665a11..88626de2d9a 100644 --- a/cpp/src/IceUtil/Options.cpp +++ b/cpp/src/IceUtil/Options.cpp @@ -16,7 +16,7 @@ using namespace std; using namespace IceUtil; IceUtilInternal::APIException::APIException(const char* file, int line, const string& r) - : IceUtil::Exception(file, line), reason(r) + : IceUtil::ExceptionHelper<APIException>(file, line), reason(r) { } @@ -50,12 +50,6 @@ IceUtilInternal::APIException::ice_clone() const } #endif -void -IceUtilInternal::APIException::ice_throw() const -{ - throw *this; -} - ostream& IceUtilInternal::operator<<(ostream& out, const IceUtilInternal::APIException& ex) { @@ -64,7 +58,7 @@ IceUtilInternal::operator<<(ostream& out, const IceUtilInternal::APIException& e } IceUtilInternal::BadOptException::BadOptException(const char* file, int line, const string& r) - : IceUtil::Exception(file, line), reason(r) + : IceUtil::ExceptionHelper<BadOptException>(file, line), reason(r) { } @@ -98,12 +92,6 @@ IceUtilInternal::BadOptException::ice_clone() const } #endif -void -IceUtilInternal::BadOptException::ice_throw() const -{ - throw *this; -} - ostream& IceUtilInternal::operator<<(ostream& out, const IceUtilInternal::BadOptException& ex) { diff --git a/cpp/src/IceUtil/ThreadException.cpp b/cpp/src/IceUtil/ThreadException.cpp index c41106820ce..ec75cc19bb5 100644 --- a/cpp/src/IceUtil/ThreadException.cpp +++ b/cpp/src/IceUtil/ThreadException.cpp @@ -11,8 +11,8 @@ using namespace std; -IceUtil::ThreadSyscallException::ThreadSyscallException(const char* file, int line, int err ): - SyscallException(file, line, err) +IceUtil::ThreadSyscallException::ThreadSyscallException(const char* file, int line, int err ): + SyscallExceptionHelper<ThreadSyscallException>(file, line, err) { } @@ -30,14 +30,8 @@ IceUtil::ThreadSyscallException::ice_clone() const } #endif -void -IceUtil::ThreadSyscallException::ice_throw() const -{ - throw *this; -} - IceUtil::ThreadLockedException::ThreadLockedException(const char* file, int line) : - Exception(file, line) + ExceptionHelper<ThreadLockedException>(file, line) { } @@ -55,14 +49,9 @@ IceUtil::ThreadLockedException::ice_clone() const } #endif -void -IceUtil::ThreadLockedException::ice_throw() const -{ - throw *this; -} IceUtil::ThreadStartedException::ThreadStartedException(const char* file, int line) : - Exception(file, line) + ExceptionHelper<ThreadStartedException>(file, line) { } @@ -80,14 +69,8 @@ IceUtil::ThreadStartedException::ice_clone() const } #endif -void -IceUtil::ThreadStartedException::ice_throw() const -{ - throw *this; -} - IceUtil::ThreadNotStartedException::ThreadNotStartedException(const char* file, int line) : - Exception(file, line) + ExceptionHelper<ThreadNotStartedException>(file, line) { } @@ -97,6 +80,7 @@ IceUtil::ThreadNotStartedException::ice_id() const return "::IceUtil::ThreadNotStartedException"; } + #ifndef ICE_CPP11_MAPPING IceUtil::ThreadNotStartedException* IceUtil::ThreadNotStartedException::ice_clone() const @@ -105,15 +89,9 @@ IceUtil::ThreadNotStartedException::ice_clone() const } #endif -void -IceUtil::ThreadNotStartedException::ice_throw() const -{ - throw *this; -} - IceUtil::BadThreadControlException::BadThreadControlException(const char* file, int line) : - Exception(file, line) + ExceptionHelper<BadThreadControlException>(file, line) { } @@ -131,15 +109,9 @@ IceUtil::BadThreadControlException::ice_clone() const } #endif -void -IceUtil::BadThreadControlException::ice_throw() const -{ - throw *this; -} - -IceUtil::InvalidTimeoutException::InvalidTimeoutException(const char* file, int line, - const IceUtil::Time& timeout) : - Exception(file, line), +IceUtil::InvalidTimeoutException::InvalidTimeoutException(const char* file, int line, + const IceUtil::Time& timeout) : + ExceptionHelper<InvalidTimeoutException>(file, line), _timeout(timeout) { } @@ -150,13 +122,6 @@ IceUtil::InvalidTimeoutException::ice_id() const return "::IceUtil::InvalidTimeoutException"; } -void -IceUtil::InvalidTimeoutException::ice_print(ostream& os) const -{ - Exception::ice_print(os); - os << ":\ninvalid timeout: " << _timeout << " seconds"; -} - #ifndef ICE_CPP11_MAPPING IceUtil::InvalidTimeoutException* IceUtil::InvalidTimeoutException::ice_clone() const @@ -166,7 +131,8 @@ IceUtil::InvalidTimeoutException::ice_clone() const #endif void -IceUtil::InvalidTimeoutException::ice_throw() const +IceUtil::InvalidTimeoutException::ice_print(ostream& os) const { - throw *this; + Exception::ice_print(os); + os << ":\ninvalid timeout: " << _timeout << " seconds"; } diff --git a/cpp/src/IceUtil/UtilException.cpp b/cpp/src/IceUtil/UtilException.cpp index 734ae013e9d..50b5b7ce0f6 100644 --- a/cpp/src/IceUtil/UtilException.cpp +++ b/cpp/src/IceUtil/UtilException.cpp @@ -616,23 +616,7 @@ IceUtil::Exception::what() const ICE_NOEXCEPT return ""; } -#ifdef ICE_CPP11_MAPPING -exception_ptr -IceUtil::Exception::ice_clone() const -{ - try - { - ice_throw(); - } - catch(...) - { - return current_exception(); - } - assert(false); - return nullptr; // Make compilers happy -} -#else - +#ifndef ICE_CPP11_MAPPING string IceUtil::Exception::ice_name() const { @@ -658,6 +642,14 @@ IceUtil::Exception::ice_stackTrace() const return getStackTrace(_stackFrames); } +#ifdef ICE_CPP11_MAPPING +unique_ptr<IceUtil::Exception> +IceUtil::Exception::ice_clone() const +{ + return unique_ptr<Exception>(ice_cloneImpl()); +} +#endif + ostream& IceUtil::operator<<(ostream& out, const IceUtil::Exception& ex) { @@ -666,7 +658,7 @@ IceUtil::operator<<(ostream& out, const IceUtil::Exception& ex) } IceUtil::NullHandleException::NullHandleException(const char* file, int line) : - Exception(file, line) + ExceptionHelper<NullHandleException>(file, line) { if(IceUtilInternal::nullHandleAbort) { @@ -674,12 +666,6 @@ IceUtil::NullHandleException::NullHandleException(const char* file, int line) : } } -#ifndef ICE_CPP11_COMPILER -IceUtil::NullHandleException::~NullHandleException() throw() -{ -} -#endif - string IceUtil::NullHandleException::ice_id() const { @@ -694,19 +680,14 @@ IceUtil::NullHandleException::ice_clone() const } #endif -void -IceUtil::NullHandleException::ice_throw() const -{ - throw *this; -} IceUtil::IllegalArgumentException::IllegalArgumentException(const char* file, int line) : - Exception(file, line) + ExceptionHelper<IllegalArgumentException>(file, line) { } IceUtil::IllegalArgumentException::IllegalArgumentException(const char* file, int line, const string& r) : - Exception(file, line), + ExceptionHelper<IllegalArgumentException>(file, line), _reason(r) { } @@ -738,12 +719,6 @@ IceUtil::IllegalArgumentException::ice_clone() const } #endif -void -IceUtil::IllegalArgumentException::ice_throw() const -{ - throw *this; -} - string IceUtil::IllegalArgumentException::reason() const { @@ -754,14 +729,16 @@ IceUtil::IllegalArgumentException::reason() const // IllegalConversionException // IceUtil::IllegalConversionException::IllegalConversionException(const char* file, int line): - Exception(file, line) -{} + ExceptionHelper<IllegalConversionException>(file, line) +{ +} IceUtil::IllegalConversionException::IllegalConversionException(const char* file, int line, const string& reason): - Exception(file, line), + ExceptionHelper<IllegalConversionException>(file, line), _reason(reason) -{} +{ +} #ifndef ICE_CPP11_COMPILER IceUtil::IllegalConversionException::~IllegalConversionException() throw() @@ -791,12 +768,6 @@ IceUtil::IllegalConversionException::ice_clone() const } #endif -void -IceUtil::IllegalConversionException::ice_throw() const -{ - throw *this; -} - string IceUtil::IllegalConversionException::reason() const { @@ -806,11 +777,17 @@ IceUtil::IllegalConversionException::reason() const IceUtil::SyscallException::SyscallException(const char* file, int line, int err ): - Exception(file, line), + ExceptionHelper<SyscallException>(file, line), _error(err) { } +#ifndef ICE_CPP11_COMPILER +IceUtil::SyscallException::~SyscallException() throw() +{ +} +#endif + void IceUtil::SyscallException::ice_print(ostream& os) const { @@ -835,12 +812,6 @@ IceUtil::SyscallException::ice_clone() const } #endif -void -IceUtil::SyscallException::ice_throw() const -{ - throw *this; -} - int IceUtil::SyscallException::error() const { @@ -849,7 +820,7 @@ IceUtil::SyscallException::error() const IceUtil::FileLockException::FileLockException(const char* file, int line, int err, const string& path): - Exception(file, line), + ExceptionHelper<FileLockException>(file, line), _error(err), _path(path) { @@ -886,12 +857,6 @@ IceUtil::FileLockException::ice_clone() const } #endif -void -IceUtil::FileLockException::ice_throw() const -{ - throw *this; -} - int IceUtil::FileLockException::error() const { @@ -899,7 +864,7 @@ IceUtil::FileLockException::error() const } IceUtil::OptionalNotSetException::OptionalNotSetException(const char* file, int line) : - Exception(file, line) + ExceptionHelper<OptionalNotSetException>(file, line) { if(IceUtilInternal::nullHandleAbort) { @@ -907,12 +872,6 @@ IceUtil::OptionalNotSetException::OptionalNotSetException(const char* file, int } } -#ifndef ICE_CPP11_COMPILER -IceUtil::OptionalNotSetException::~OptionalNotSetException() throw() -{ -} -#endif - string IceUtil::OptionalNotSetException::ice_id() const { @@ -927,15 +886,9 @@ IceUtil::OptionalNotSetException::ice_clone() const } #endif -void -IceUtil::OptionalNotSetException::ice_throw() const -{ - throw *this; -} - #ifndef _WIN32 IceUtil::IconvInitializationException::IconvInitializationException(const char* file, int line, const string& reason) : - Exception(file, line), + ExceptionHelper<IconvInitializationException>(file, line), _reason(reason) { } @@ -967,12 +920,6 @@ IceUtil::IconvInitializationException::ice_clone() const } #endif -void -IceUtil::IconvInitializationException::ice_throw() const -{ - throw *this; -} - string IceUtil::IconvInitializationException::reason() const { |