diff options
author | baltasarq <baltasarq@gmail.com> | 2016-03-01 13:14:39 +0100 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-03-02 12:42:24 +0000 |
commit | d9dacecd9068f8ba2be8b92cdd881dbb17a59cfb (patch) | |
tree | d11182861518872cbe25ee8121089b89cfd65388 | |
parent | 87629f39bbae1ad774d588c50d030bff0ba8d8a2 (diff) |
tdf#84938 Change average enum for scoped enum
This is a [partial] patch for tdf#84938, involving the substitution of an average enum for a scoped one.
Change-Id: I4b3a19914d30a14dec2640355ba392b943e1ddd7
Reviewed-on: https://gerrit.libreoffice.org/22808
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
-rw-r--r-- | basic/source/inc/runtime.hxx | 23 | ||||
-rw-r--r-- | basic/source/runtime/runtime.cxx | 25 |
2 files changed, 25 insertions, 23 deletions
diff --git a/basic/source/inc/runtime.hxx b/basic/source/inc/runtime.hxx index e3fabf3e0bad..5c082ee55c32 100644 --- a/basic/source/inc/runtime.hxx +++ b/basic/source/inc/runtime.hxx @@ -48,12 +48,11 @@ class SbiDllMgr; class SvNumberFormatter; // time/date functions enum class SbiImageFlags; -enum ForType -{ - FOR_TO, - FOR_EACH_ARRAY, - FOR_EACH_COLLECTION, - FOR_EACH_XENUMERATION +enum class ForType { + To, + EachArray, + EachCollection, + EachXEnumeration }; struct SbiForStack { // for/next stack: @@ -63,7 +62,7 @@ struct SbiForStack { // for/next stack: SbxVariableRef refInc; // increment expression // For each support - ForType eForType; + ForType eForType; sal_Int32 nCurCollectionIndex; sal_Int32* pArrayCurIndices; sal_Int32* pArrayLowerBounds; @@ -72,12 +71,13 @@ struct SbiForStack { // for/next stack: SbiForStack() : pNext(nullptr) - , eForType(FOR_TO) + , eForType(ForType::To) , nCurCollectionIndex(0) , pArrayCurIndices(nullptr) , pArrayLowerBounds(nullptr) , pArrayUpperBounds(nullptr) {} + ~SbiForStack() { delete[] pArrayCurIndices; @@ -86,13 +86,14 @@ struct SbiForStack { // for/next stack: } }; +#define MAXRECURSION 500 + struct SbiGosubStack { // GOSUB-Stack: SbiGosubStack* pNext; // Chain - const sal_uInt8* pCode; // Return-Pointer - sal_uInt16 nStartForLvl; // #118235: For Level in moment of gosub + const sal_uInt8* pCode; // Return-Pointer + sal_uInt16 nStartForLvl; // #118235: For Level in moment of gosub }; -#define MAXRECURSION 500 #define Sb_ATTR_READONLY 0x0001 #define Sb_ATTR_HIDDEN 0x0002 diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index b4ce32ca21d5..73807548bf23 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -1139,7 +1139,7 @@ void SbiRuntime::ClearArgvStack() void SbiRuntime::PushFor() { SbiForStack* p = new SbiForStack; - p->eForType = FOR_TO; + p->eForType = ForType::To; p->pNext = pForStk; pForStk = p; @@ -1168,7 +1168,7 @@ void SbiRuntime::PushForEach() bool bError_ = false; if (SbxDimArray* pArray = dynamic_cast<SbxDimArray*>(pObj)) { - p->eForType = FOR_EACH_ARRAY; + p->eForType = ForType::EachArray; p->refEnd = reinterpret_cast<SbxVariable*>(pArray); short nDims = pArray->GetDims(); @@ -1185,7 +1185,7 @@ void SbiRuntime::PushForEach() } else if (BasicCollection* pCollection = dynamic_cast<BasicCollection*>(pObj)) { - p->eForType = FOR_EACH_COLLECTION; + p->eForType = ForType::EachCollection; p->refEnd = pCollection; p->nCurCollectionIndex = 0; } @@ -1197,7 +1197,7 @@ void SbiRuntime::PushForEach() if( (aAny >>= xEnumerationAccess) ) { p->xEnumeration = xEnumerationAccess->createEnumeration(); - p->eForType = FOR_EACH_XENUMERATION; + p->eForType = ForType::EachXEnumeration; } else if ( isVBAEnabled() && pUnoObj->isNativeCOMObject() ) { @@ -1207,7 +1207,7 @@ void SbiRuntime::PushForEach() try { p->xEnumeration = new ComEnumerationWrapper( xInvocation ); - p->eForType = FOR_EACH_XENUMERATION; + p->eForType = ForType::EachXEnumeration; } catch(const uno::Exception& ) {} @@ -1264,8 +1264,9 @@ SbiForStack* SbiRuntime::FindForStackItemForCollection( class BasicCollection* p for (SbiForStack *p = pForStk; p; p = p->pNext) { SbxVariable* pVar = p->refEnd.Is() ? p->refEnd.get() : nullptr; - if( p->eForType == FOR_EACH_COLLECTION && pVar != nullptr && - dynamic_cast<BasicCollection*>( pVar) == pCollection ) + if( p->eForType == ForType::EachCollection + && pVar != nullptr + && dynamic_cast<BasicCollection*>( pVar) == pCollection ) { return p; } @@ -2604,7 +2605,7 @@ void SbiRuntime::StepNEXT() StarBASIC::FatalError( ERRCODE_BASIC_INTERNAL_ERROR ); return; } - if( pForStk->eForType == FOR_TO ) + if( pForStk->eForType == ForType::To ) { pForStk->refVar->Compute( SbxPLUS, *pForStk->refInc ); } @@ -3018,14 +3019,14 @@ void SbiRuntime::StepTESTFOR( sal_uInt32 nOp1 ) bool bEndLoop = false; switch( pForStk->eForType ) { - case FOR_TO: + case ForType::To: { SbxOperator eOp = ( pForStk->refInc->GetDouble() < 0 ) ? SbxLT : SbxGT; if( pForStk->refVar->Compare( eOp, *pForStk->refEnd ) ) bEndLoop = true; break; } - case FOR_EACH_ARRAY: + case ForType::EachArray: { SbiForStack* p = pForStk; if( p->pArrayCurIndices == nullptr ) @@ -3066,7 +3067,7 @@ void SbiRuntime::StepTESTFOR( sal_uInt32 nOp1 ) } break; } - case FOR_EACH_COLLECTION: + case ForType::EachCollection: { BasicCollection* pCollection = static_cast<BasicCollection*>(static_cast<SbxVariable*>(pForStk->refEnd)); SbxArrayRef xItemArray = pCollection->xItemArray; @@ -3083,7 +3084,7 @@ void SbiRuntime::StepTESTFOR( sal_uInt32 nOp1 ) } break; } - case FOR_EACH_XENUMERATION: + case ForType::EachXEnumeration: { SbiForStack* p = pForStk; if( p->xEnumeration->hasMoreElements() ) |