diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-02-09 08:52:13 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-21 08:42:30 +0200 |
commit | 528632660b72b105345945c13c5b68060d94a91b (patch) | |
tree | 860508d482959abeb9175f0ce6b9e65954269f95 /basic/source | |
parent | aee66aa85e75f67135e5c6079a281e18402d261a (diff) |
convert ErrCode to strong typedef
would have preferred to re-use o3tl::strong_int, of which this
is a modified copy, but there are lots of convenience accessors
which are nice to define on the class.
Change-Id: I301b807aaf02fbced3bf75de1e1692cde6c0340a
Reviewed-on: https://gerrit.libreoffice.org/38497
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basic/source')
-rw-r--r-- | basic/source/basmgr/basmgr.cxx | 2 | ||||
-rw-r--r-- | basic/source/classes/sb.cxx | 43 | ||||
-rw-r--r-- | basic/source/comp/scanner.cxx | 11 | ||||
-rw-r--r-- | basic/source/runtime/ddectrl.cxx | 40 | ||||
-rw-r--r-- | basic/source/runtime/iosys.cxx | 37 | ||||
-rw-r--r-- | basic/source/runtime/runtime.cxx | 14 | ||||
-rw-r--r-- | basic/source/uno/scriptcont.cxx | 4 |
7 files changed, 66 insertions, 85 deletions
diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index e66cf58edf4a..47d09e629a44 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -318,7 +318,7 @@ void SAL_CALL BasMgrContainerListenerImpl::elementRemoved( const container::Cont } } -BasicError::BasicError( sal_uInt64 nId, BasicErrorReason nR ) +BasicError::BasicError( ErrCode nId, BasicErrorReason nR ) { nErrorId = nId; nReason = nR; diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 9e6e32a0d02a..af541630b8de 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -401,7 +401,7 @@ const SFX_VB_ErrorItem SFX_VB_ErrorTab[] = { 1005, ERRCODE_BASIC_SETPROP_FAILED }, { 1006, ERRCODE_BASIC_GETPROP_FAILED }, { 1007, ERRCODE_BASIC_COMPAT }, - { 0xFFFF, 0xFFFFFFFFL } // End mark + { 0xFFFF, ErrCode(0xFFFFFFFFUL) } // End mark }; // The StarBASIC factory is a hack. When a SbModule is created, its pointer @@ -1429,7 +1429,7 @@ SbModule* StarBASIC::GetActiveModule() BasicDebugFlags StarBASIC::BreakPoint( sal_Int32 l, sal_Int32 c1, sal_Int32 c2 ) { - SetErrorData( 0, l, c1, c2 ); + SetErrorData( ERRCODE_NONE, l, c1, c2 ); bBreak = true; if( GetSbData()->aBreakHdl.IsSet() ) { @@ -1443,7 +1443,7 @@ BasicDebugFlags StarBASIC::BreakPoint( sal_Int32 l, sal_Int32 c1, sal_Int32 c2 ) BasicDebugFlags StarBASIC::StepPoint( sal_Int32 l, sal_Int32 c1, sal_Int32 c2 ) { - SetErrorData( 0, l, c1, c2 ); + SetErrorData( ERRCODE_NONE, l, c1, c2 ); bBreak = false; if( GetSbData()->aBreakHdl.IsSet() ) { @@ -1483,23 +1483,20 @@ sal_uInt16 StarBASIC::GetVBErrorCode( ErrCode nError ) if( SbiRuntime::isVBAEnabled() ) { - switch( nError ) - { - case ERRCODE_BASIC_ARRAY_FIX: + if ( nError == ERRCODE_BASIC_ARRAY_FIX ) return 10; - case ERRCODE_BASIC_STRING_OVERFLOW: + else if ( nError == ERRCODE_BASIC_STRING_OVERFLOW ) return 14; - case ERRCODE_BASIC_EXPR_TOO_COMPLEX: + else if ( nError == ERRCODE_BASIC_EXPR_TOO_COMPLEX ) return 16; - case ERRCODE_BASIC_OPER_NOT_PERFORM: + else if ( nError == ERRCODE_BASIC_OPER_NOT_PERFORM ) return 17; - case ERRCODE_BASIC_TOO_MANY_DLL: + else if ( nError == ERRCODE_BASIC_TOO_MANY_DLL ) return 47; - case ERRCODE_BASIC_LOOP_NOT_INIT: + else if ( nError == ERRCODE_BASIC_LOOP_NOT_INIT ) return 92; - default: + else nRet = 0; - } } // search loop @@ -1521,7 +1518,7 @@ sal_uInt16 StarBASIC::GetVBErrorCode( ErrCode nError ) ErrCode StarBASIC::GetSfxFromVBError( sal_uInt16 nError ) { - ErrCode nRet = 0; + ErrCode nRet = ERRCODE_NONE; if( SbiRuntime::isVBAEnabled() ) { @@ -1533,7 +1530,7 @@ ErrCode StarBASIC::GetSfxFromVBError( sal_uInt16 nError ) case 8: case 12: case 73: - return 0; + return ERRCODE_NONE; case 10: return ERRCODE_BASIC_ARRAY_FIX; case 14: @@ -1547,7 +1544,7 @@ ErrCode StarBASIC::GetSfxFromVBError( sal_uInt16 nError ) case 92: return ERRCODE_BASIC_LOOP_NOT_INIT; default: - nRet = 0; + nRet = ERRCODE_NONE; } } const SFX_VB_ErrorItem* pErrItem; @@ -1588,7 +1585,7 @@ void StarBASIC::MakeErrorText( ErrCode nId, const OUString& aMsg ) // instantiate the help class ResStringArray aMyStringList(BasResId(RID_BASIC_START)); - sal_uInt32 nErrIdx = aMyStringList.FindIndex(sal_uInt16(nId & ERRCODE_RES_MASK)); + sal_uInt32 nErrIdx = aMyStringList.FindIndex(nId.GetRest()); if (nErrIdx != RESARRAY_INDEX_NOTFOUND) { // merge message with additional text @@ -1643,7 +1640,7 @@ bool StarBASIC::CError( ErrCode code, const OUString& rMsg, // Implementation of the code for the string transport to SFX-Error if( !rMsg.isEmpty() ) { - code = (ErrCode)*new StringErrorInfo( code, rMsg ); + code = *new StringErrorInfo( code, rMsg ); } SetErrorData( code, l, c1, c2 ); GetSbData()->bCompilerError = true; @@ -1665,9 +1662,9 @@ bool StarBASIC::RTError( ErrCode code, const OUString& rMsg, sal_Int32 l, sal_In SolarMutexGuard aSolarGuard; ErrCode c = code; - if( (c & ERRCODE_CLASS_MASK) == ERRCODE_CLASS_COMPILER ) + if( c.GetClass() == ERRCODE_CLASS_COMPILER ) { - c = 0; + c = ERRCODE_NONE; } MakeErrorText( c, rMsg ); @@ -1682,11 +1679,11 @@ bool StarBASIC::RTError( ErrCode code, const OUString& rMsg, sal_Int32 l, sal_In { OUString aTmp = "\'" + OUString::number(SbxErrObject::getUnoErrObject()->getNumber()) + "\'\n" + (!GetSbData()->aErrMsg.isEmpty() ? GetSbData()->aErrMsg : rMsg); - code = (ErrCode)*new StringErrorInfo( code, aTmp ); + code = *new StringErrorInfo( code, aTmp ); } else { - code = (ErrCode)*new StringErrorInfo( code, rMsg ); + code = *new StringErrorInfo( code, rMsg ); } } @@ -1738,7 +1735,7 @@ ErrCode StarBASIC::GetErrBasic() } else { - return 0; + return ERRCODE_NONE; } } diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx index e906cfb19c52..48072debbd15 100644 --- a/basic/source/comp/scanner.cxx +++ b/basic/source/comp/scanner.cxx @@ -85,15 +85,14 @@ void SbiScanner::GenError( ErrCode code ) // in case of EXPECTED or UNEXPECTED it always refers // to the last token, so take the Col1 over sal_Int32 nc = nColLock ? nSavedCol1 : nCol1; - switch( code ) + if ( code.anyOf( + ERRCODE_BASIC_EXPECTED, + ERRCODE_BASIC_UNEXPECTED, + ERRCODE_BASIC_SYMBOL_EXPECTED, + ERRCODE_BASIC_LABEL_EXPECTED) ) { - case ERRCODE_BASIC_EXPECTED: - case ERRCODE_BASIC_UNEXPECTED: - case ERRCODE_BASIC_SYMBOL_EXPECTED: - case ERRCODE_BASIC_LABEL_EXPECTED: nc = nCol1; if( nc > nCol2 ) nCol2 = nc; - break; } bRes = pBasic->CError( code, aError, nLine, nc, nCol2 ); } diff --git a/basic/source/runtime/ddectrl.cxx b/basic/source/runtime/ddectrl.cxx index 3c77fcbe26c0..adb2e7aebf2d 100644 --- a/basic/source/runtime/ddectrl.cxx +++ b/basic/source/runtime/ddectrl.cxx @@ -29,36 +29,36 @@ static const ErrCode nDdeErrMap[] = { - /* DMLERR_ADVACKTIMEOUT */ 0x4000, ERRCODE_BASIC_DDE_TIMEOUT, - /* DMLERR_BUSY */ 0x4001, ERRCODE_BASIC_DDE_BUSY, - /* DMLERR_DATAACKTIMEOUT */ 0x4002, ERRCODE_BASIC_DDE_TIMEOUT, - /* DMLERR_DLL_NOT_INITIALIZED */ 0x4003, ERRCODE_BASIC_DDE_ERROR, - /* DMLERR_DLL_USAGE */ 0x4004, ERRCODE_BASIC_DDE_ERROR, - /* DMLERR_EXECACKTIMEOUT */ 0x4005, ERRCODE_BASIC_DDE_TIMEOUT, - /* DMLERR_INVALIDPARAMETER */ 0x4006, ERRCODE_BASIC_DDE_ERROR, - /* DMLERR_LOW_MEMORY */ 0x4007, ERRCODE_BASIC_DDE_ERROR, - /* DMLERR_MEMORY_ERROR */ 0x4008, ERRCODE_BASIC_DDE_ERROR, - /* DMLERR_NOTPROCESSED */ 0x4009, ERRCODE_BASIC_DDE_NOTPROCESSED, - /* DMLERR_NO_CONV_ESTABLISHED */ 0x400a, ERRCODE_BASIC_DDE_NO_CHANNEL, - /* DMLERR_POKEACKTIMEOUT */ 0x400b, ERRCODE_BASIC_DDE_TIMEOUT, - /* DMLERR_POSTMSG_FAILED */ 0x400c, ERRCODE_BASIC_DDE_QUEUE_OVERFLOW, - /* DMLERR_REENTRANCY */ 0x400d, ERRCODE_BASIC_DDE_ERROR, - /* DMLERR_SERVER_DIED */ 0x400e, ERRCODE_BASIC_DDE_PARTNER_QUIT, - /* DMLERR_SYS_ERROR */ 0x400f, ERRCODE_BASIC_DDE_ERROR, - /* DMLERR_UNADVACKTIMEOUT */ 0x4010, ERRCODE_BASIC_DDE_TIMEOUT, - /* DMLERR_UNFOUND_QUEUE_ID */ 0x4011, ERRCODE_BASIC_DDE_NO_CHANNEL + /* DMLERR_ADVACKTIMEOUT */ ErrCode(0x4000), ERRCODE_BASIC_DDE_TIMEOUT, + /* DMLERR_BUSY */ ErrCode(0x4001), ERRCODE_BASIC_DDE_BUSY, + /* DMLERR_DATAACKTIMEOUT */ ErrCode(0x4002), ERRCODE_BASIC_DDE_TIMEOUT, + /* DMLERR_DLL_NOT_INITIALIZED */ ErrCode(0x4003), ERRCODE_BASIC_DDE_ERROR, + /* DMLERR_DLL_USAGE */ ErrCode(0x4004), ERRCODE_BASIC_DDE_ERROR, + /* DMLERR_EXECACKTIMEOUT */ ErrCode(0x4005), ERRCODE_BASIC_DDE_TIMEOUT, + /* DMLERR_INVALIDPARAMETER */ ErrCode(0x4006), ERRCODE_BASIC_DDE_ERROR, + /* DMLERR_LOW_MEMORY */ ErrCode(0x4007), ERRCODE_BASIC_DDE_ERROR, + /* DMLERR_MEMORY_ERROR */ ErrCode(0x4008), ERRCODE_BASIC_DDE_ERROR, + /* DMLERR_NOTPROCESSED */ ErrCode(0x4009), ERRCODE_BASIC_DDE_NOTPROCESSED, + /* DMLERR_NO_CONV_ESTABLISHED */ ErrCode(0x400a), ERRCODE_BASIC_DDE_NO_CHANNEL, + /* DMLERR_POKEACKTIMEOUT */ ErrCode(0x400b), ERRCODE_BASIC_DDE_TIMEOUT, + /* DMLERR_POSTMSG_FAILED */ ErrCode(0x400c), ERRCODE_BASIC_DDE_QUEUE_OVERFLOW, + /* DMLERR_REENTRANCY */ ErrCode(0x400d), ERRCODE_BASIC_DDE_ERROR, + /* DMLERR_SERVER_DIED */ ErrCode(0x400e), ERRCODE_BASIC_DDE_PARTNER_QUIT, + /* DMLERR_SYS_ERROR */ ErrCode(0x400f), ERRCODE_BASIC_DDE_ERROR, + /* DMLERR_UNADVACKTIMEOUT */ ErrCode(0x4010), ERRCODE_BASIC_DDE_TIMEOUT, + /* DMLERR_UNFOUND_QUEUE_ID */ ErrCode(0x4011), ERRCODE_BASIC_DDE_NO_CHANNEL }; ErrCode SbiDdeControl::GetLastErr( DdeConnection* pConv ) { if( !pConv ) { - return 0; + return ERRCODE_NONE; } long nErr = pConv->GetError(); if( !nErr ) { - return 0; + return ERRCODE_NONE; } if( nErr < DDE_FIRSTERR || nErr > DDE_LASTERR ) { diff --git a/basic/source/runtime/iosys.cxx b/basic/source/runtime/iosys.cxx index 472c4321e0ec..fca1a1c17cc7 100644 --- a/basic/source/runtime/iosys.cxx +++ b/basic/source/runtime/iosys.cxx @@ -141,33 +141,23 @@ void SbiStream::MapError() { if( pStrm ) { - switch( pStrm->GetError() ) - { - case ERRCODE_NONE: - nError = 0; - break; - case SVSTREAM_FILE_NOT_FOUND: + ErrCode nEC = pStrm->GetError(); + if (nEC == ERRCODE_NONE) + nError = ERRCODE_NONE; + else if (nEC == SVSTREAM_FILE_NOT_FOUND) nError = ERRCODE_BASIC_FILE_NOT_FOUND; - break; - case SVSTREAM_PATH_NOT_FOUND: + else if (nEC ==SVSTREAM_PATH_NOT_FOUND) nError = ERRCODE_BASIC_PATH_NOT_FOUND; - break; - case SVSTREAM_TOO_MANY_OPEN_FILES: + else if (nEC ==SVSTREAM_TOO_MANY_OPEN_FILES) nError = ERRCODE_BASIC_TOO_MANY_FILES; - break; - case SVSTREAM_ACCESS_DENIED: + else if (nEC ==SVSTREAM_ACCESS_DENIED) nError = ERRCODE_BASIC_ACCESS_DENIED; - break; - case SVSTREAM_INVALID_PARAMETER: + else if (nEC ==SVSTREAM_INVALID_PARAMETER) nError = ERRCODE_BASIC_BAD_ARGUMENT; - break; - case SVSTREAM_OUTOFMEMORY: + else if (nEC ==SVSTREAM_OUTOFMEMORY) nError = ERRCODE_BASIC_NO_MEMORY; - break; - default: + else nError = ERRCODE_BASIC_IO_ERROR; - break; - } } } @@ -656,7 +646,7 @@ SbiIoSystem::SbiIoSystem() i = nullptr; } nChan = 0; - nError = 0; + nError = ERRCODE_NONE; } SbiIoSystem::~SbiIoSystem() @@ -666,13 +656,14 @@ SbiIoSystem::~SbiIoSystem() ErrCode SbiIoSystem::GetError() { - ErrCode n = nError; nError = 0; + ErrCode n = nError; + nError = ERRCODE_NONE; return n; } void SbiIoSystem::Open(short nCh, const OString& rName, StreamMode nMode, SbiStreamFlags nFlags, short nLen) { - nError = 0; + nError = ERRCODE_NONE; if( nCh >= CHANNELS || !nCh ) { nError = ERRCODE_BASIC_BAD_CHANNEL; diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index d33e584dce20..f8c8ed9aec2d 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -480,7 +480,7 @@ void SbiInstance::ErrorVB( sal_Int32 nVBNumber, const OUString& rMsg ) ErrCode n = StarBASIC::GetSfxFromVBError( static_cast< sal_uInt16 >( nVBNumber ) ); if ( !n ) { - n = nVBNumber; // force orig number, probably should have a specific table of vb ( localized ) errors + n = ErrCode(nVBNumber); // force orig number, probably should have a specific table of vb ( localized ) errors } aErrorMsg = rMsg; SbiRuntime::translateErrorToVba( n, aErrorMsg ); @@ -494,7 +494,7 @@ void SbiInstance::setErrorVB( sal_Int32 nVBNumber ) ErrCode n = StarBASIC::GetSfxFromVBError( static_cast< sal_uInt16 >( nVBNumber ) ); if( !n ) { - n = nVBNumber; // force orig number, probably should have a specific table of vb ( localized ) errors + n = ErrCode(nVBNumber); // force orig number, probably should have a specific table of vb ( localized ) errors } aErrorMsg = OUString(); SbiRuntime::translateErrorToVba( n, aErrorMsg ); @@ -773,7 +773,7 @@ bool SbiRuntime::Step() } ErrCode nErrCode = SbxBase::GetError(); - Error( ERRCODE_TOERROR(nErrCode) ); + Error( nErrCode.IgnoreWarning() ); // from 13.2.1997, new error handling: // ATTENTION: nError can be set already even if !nErrCode @@ -931,12 +931,6 @@ sal_Int32 SbiRuntime::translateErrorToVba( ErrCode nError, OUString& rMsg ) // we really need a new vba compatible error list if ( rMsg.isEmpty() ) { - // TEST, has to be vb here always -#ifdef DBG_UTIL - ErrCode nTmp = StarBASIC::GetSfxFromVBError( (sal_uInt16)nError ); - SAL_WARN_IF( nTmp == 0, "basic", "No VB error!" ); -#endif - StarBASIC::MakeErrorText( nError, rMsg ); rMsg = StarBASIC::GetErrorText(); if ( rMsg.isEmpty() ) // no message for err no, need localized resource here @@ -946,7 +940,7 @@ sal_Int32 SbiRuntime::translateErrorToVba( ErrCode nError, OUString& rMsg ) } // no num? most likely then it *is* really a vba err sal_uInt16 nVBErrorCode = StarBASIC::GetVBErrorCode( nError ); - sal_Int32 nVBAErrorNumber = ( nVBErrorCode == 0 ) ? nError : nVBErrorCode; + sal_Int32 nVBAErrorNumber = ( nVBErrorCode == 0 ) ? sal_uInt32(nError) : nVBErrorCode; return nVBAErrorNumber; } diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx index 327e9d33fd01..4346a091ff01 100644 --- a/basic/source/uno/scriptcont.cxx +++ b/basic/source/uno/scriptcont.cxx @@ -914,7 +914,7 @@ bool SfxScriptLibraryContainer::implLoadPasswordLibrary std::unique_ptr<SvStream> pStream(::utl::UcbStreamHelper::CreateStream( xCodeStream )); if ( !pStream || pStream->GetError() ) { - sal_Int32 nError = pStream ? pStream->GetError() : ERRCODE_IO_GENERAL; + sal_uInt32 nError = sal_uInt32(pStream ? pStream->GetError() : ERRCODE_IO_GENERAL); throw task::ErrorCodeIOException( ("utl::UcbStreamHelper::CreateStream failed for \"" + aCodeStreamName + "\": 0x" @@ -1026,7 +1026,7 @@ bool SfxScriptLibraryContainer::implLoadPasswordLibrary std::unique_ptr<SvStream> pStream(::utl::UcbStreamHelper::CreateStream( xCodeStream )); if ( !pStream || pStream->GetError() ) { - sal_Int32 nError = pStream ? pStream->GetError() : ERRCODE_IO_GENERAL; + sal_uInt32 nError = sal_uInt32(pStream ? pStream->GetError() : ERRCODE_IO_GENERAL); throw task::ErrorCodeIOException( ("utl::UcbStreamHelper::CreateStream failed" " for code.bin: 0x" |