From 4822b368d2ab75e0b27964d82f6e8c515d787f27 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Tue, 29 Feb 2000 23:28:09 +0000 Subject: [PATCH] use location exception --- src/libCom/cxxTemplates/resourceLib.h | 25 +++++-------------------- src/libCom/cxxTemplates/tsBTree.h | 7 ++----- src/libCom/cxxTemplates/tsSLList.h | 17 ++++++----------- src/libCom/fdmgr/fdManager.cpp | 9 +++------ src/libCom/fdmgr/fdmgr.cpp | 24 ++++-------------------- 5 files changed, 20 insertions(+), 62 deletions(-) diff --git a/src/libCom/cxxTemplates/resourceLib.h b/src/libCom/cxxTemplates/resourceLib.h index f8ad1c4e3..6b3b8e676 100644 --- a/src/libCom/cxxTemplates/resourceLib.h +++ b/src/libCom/cxxTemplates/resourceLib.h @@ -54,6 +54,7 @@ #include "tsSLList.h" #include "shareLib.h" +#include "locationException.h" typedef size_t resTableIndex; @@ -328,11 +329,7 @@ resTable::resTable (unsigned nHashTableEntries) : } if ( nbits > ID::maxIndexBitWidth () ) { -# ifdef noExceptionsFromCXX - assert (0); -# else - throw sizeExceedsMaxIndexWidth (); -# endif + throwWithLocation ( sizeExceedsMaxIndexWidth () ); } // @@ -349,11 +346,7 @@ resTable::resTable (unsigned nHashTableEntries) : this->nInUse = 0u; this->pTable = new tsSLList [1<pTable==0) { -# ifdef noExceptionsFromCXX - assert (0); -# else - throw dynamicMemoryAllocationFailed (); -# endif + throwWithLocation ( dynamicMemoryAllocationFailed () ); } } @@ -588,11 +581,7 @@ resTable::~resTable() if (this->pTable) { this->destroyAllEntries(); if (this->nInUse != 0u) { -# ifdef noExceptionsFromCXX - assert (0); -# else - throw entryDidntRespondToDestroyVirtualFunction (); -# endif + throwWithLocation ( entryDidntRespondToDestroyVirtualFunction () ); } delete [] this->pTable; } @@ -826,11 +815,7 @@ stringId::stringId (const char * idIn, allocationType typeIn) : memcpy ((void *)this->pStr, idIn, nChars); } else { -# ifdef noExceptionsFromCXX - assert (0); -# else - throw dynamicMemoryAllocationFailed (); -# endif + throwWithLocation ( dynamicMemoryAllocationFailed () ); } } else { diff --git a/src/libCom/cxxTemplates/tsBTree.h b/src/libCom/cxxTemplates/tsBTree.h index 25598fe38..87bc3cd11 100644 --- a/src/libCom/cxxTemplates/tsBTree.h +++ b/src/libCom/cxxTemplates/tsBTree.h @@ -1,5 +1,6 @@ #include +#include "locationException.h" // // tsBTreeRMRet @@ -100,11 +101,7 @@ private: } } else { -# ifdef noExceptionsFromCXX - assert (0); -# else - throw invalid_btCmp (); -# endif + throwWithLocation ( invalid_btCmp () ); } } diff --git a/src/libCom/cxxTemplates/tsSLList.h b/src/libCom/cxxTemplates/tsSLList.h index 62d77355b..076ba9a27 100644 --- a/src/libCom/cxxTemplates/tsSLList.h +++ b/src/libCom/cxxTemplates/tsSLList.h @@ -35,6 +35,9 @@ #include +#include + + // // the hp compiler complains about parameterized friend // class that has not been declared without this? @@ -368,11 +371,7 @@ template void tsSLIterRm::remove () { if (this->pCurrent==0) { -# ifdef noExceptionsFromCXX - assert (0); -# else - throw noCurrentItemInIterator (); -# endif + throwWithLocation ( noCurrentItemInIterator () ); } tsSLNode *pPrevNode; @@ -384,12 +383,8 @@ void tsSLIterRm::remove () // fail if it is an attempt to // delete twice without moving the iterator // - if (pPrevNode->pNext != this->pCurrent) { -# ifdef noExceptionsFromCXX - assert (0); -# else - throw noCurrentItemInIterator (); -# endif + if (pPrevNode->pNext != this->pCurrent) { + throwWithLocation ( noCurrentItemInIterator ()); } } else { diff --git a/src/libCom/fdmgr/fdManager.cpp b/src/libCom/fdmgr/fdManager.cpp index 8d0abd1f8..a38a6340f 100644 --- a/src/libCom/fdmgr/fdManager.cpp +++ b/src/libCom/fdmgr/fdManager.cpp @@ -52,7 +52,8 @@ #include "osiThread.h" #include "tsMinMax.h" #include "fdManager.h" - +#include "locationException.h" + // // if the compiler supports explicit instantiation of // template member functions @@ -316,11 +317,7 @@ epicsShareFunc void fdManager::installReg (fdReg ®) int status = this->fdTbl.add (reg); if (status!=0) { -# ifdef noExceptionsFromCXX - assert (0); -# else - throw fdInterestSubscriptionAlreadyExits (); -# endif + throwWithLocation ( fdInterestSubscriptionAlreadyExits () ); } } diff --git a/src/libCom/fdmgr/fdmgr.cpp b/src/libCom/fdmgr/fdmgr.cpp index 0aef6d62c..070ecafb5 100644 --- a/src/libCom/fdmgr/fdmgr.cpp +++ b/src/libCom/fdmgr/fdmgr.cpp @@ -117,22 +117,14 @@ epicsShareFunc fdRegForOldFdmgr::fdRegForOldFdmgr (const SOCKET fdIn, const fdRe pParam (pParamIn) { if (pFuncIn==NULL) { -# ifdef noExceptionsFromCXX - assert (0); -# else - throw noFunctionSpecified (); -# endif + throwWithLocation ( noFunctionSpecified () ); } } epicsShareFunc fdRegForOldFdmgr::~fdRegForOldFdmgr () { if (this->pFunc==NULL) { -# ifdef noExceptionsFromCXX - assert (0); -# else - throw doubleDelete (); -# endif + throwWithLocation ( doubleDelete () ); } } @@ -147,11 +139,7 @@ osiTimerForOldFdmgr::osiTimerForOldFdmgr (oldFdmgr &fdmgrIn, fdmgr (fdmgrIn), pFunc (pFuncIn), pParam(pParamIn) { if (pFuncIn==NULL) { -# ifdef noExceptionsFromCXX - assert (0); -# else - throw noFunctionSpecified (); -# endif + throwWithLocation ( noFunctionSpecified () ); } this->fdmgr.resTbl.add (*this); @@ -160,11 +148,7 @@ osiTimerForOldFdmgr::osiTimerForOldFdmgr (oldFdmgr &fdmgrIn, osiTimerForOldFdmgr::~osiTimerForOldFdmgr () { if (this->pFunc==NULL) { -# ifdef noExceptionsFromCXX - assert (0); -# else - throw doubleDelete (); -# endif + throwWithLocation ( doubleDelete () ); } this->pFunc = NULL;