diff options
author | Noel Grandin <noel@peralex.com> | 2015-02-27 11:22:50 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-03-02 08:59:18 +0200 |
commit | e9beb264709a8d4a240bb66f6c1ee95658bab4c2 (patch) | |
tree | 8d6184b1b0b5a802ec60e7754db89aee1c34f9da /basic | |
parent | c9c1caa4f9ad955ae864aa2681f890c7706daad1 (diff) |
convert SBI_ constants to enum class
Change-Id: I65e706f4e1adfe242808293d9514c9db8d22cc12
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/classes/image.cxx | 10 | ||||
-rw-r--r-- | basic/source/classes/sbxmod.cxx | 2 | ||||
-rw-r--r-- | basic/source/comp/codegen.cxx | 6 | ||||
-rw-r--r-- | basic/source/inc/image.hxx | 25 | ||||
-rw-r--r-- | basic/source/inc/runtime.hxx | 3 | ||||
-rw-r--r-- | basic/source/runtime/methods.cxx | 8 | ||||
-rw-r--r-- | basic/source/runtime/runtime.cxx | 12 |
7 files changed, 39 insertions, 27 deletions
diff --git a/basic/source/classes/image.cxx b/basic/source/classes/image.cxx index 71930a3b23e5..338ed0218ec3 100644 --- a/basic/source/classes/image.cxx +++ b/basic/source/classes/image.cxx @@ -33,7 +33,7 @@ SbiImage::SbiImage() pStrings = NULL; pCode = NULL; pLegacyPCode = NULL; - nFlags = 0; + nFlags = SbiImageFlags::NONE; nStrings = 0; nStringSize= 0; nCodeSize = 0; @@ -61,7 +61,7 @@ void SbiImage::Clear() pStringOff = NULL; pStrings = NULL; pCode = NULL; - nFlags = 0; + nFlags = SbiImageFlags::NONE; nStrings = 0; nStringSize= 0; nLegacyCodeSize = 0; @@ -123,8 +123,10 @@ bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion ) bool bBadVer = false; if( nSign == B_MODULE ) { + sal_uInt16 nTmpFlags; r.ReadUInt32( nVersion ).ReadUInt32( nCharSet ).ReadUInt32( lDimBase ) - .ReadUInt16( nFlags ).ReadUInt16( nReserved1 ).ReadUInt32( nReserved2 ).ReadUInt32( nReserved3 ); + .ReadUInt16( nTmpFlags ).ReadUInt16( nReserved1 ).ReadUInt32( nReserved2 ).ReadUInt32( nReserved3 ); + nFlags = static_cast<SbiImageFlags>(nTmpFlags); eCharSet = nCharSet; eCharSet = GetSOLoadTextEncoding( eCharSet ); bBadVer = ( nVersion > B_CURVERSION ); @@ -287,7 +289,7 @@ bool SbiImage::Save( SvStream& r, sal_uInt32 nVer ) } r .WriteInt32( eCharSet ) .WriteInt32( nDimBase ) - .WriteInt16( nFlags ) + .WriteInt16( static_cast<sal_uInt16>(nFlags) ) .WriteInt16( 0 ) .WriteInt32( 0 ) .WriteInt32( 0 ); diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 09595a7b5737..cbeac3c979ce 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -1280,7 +1280,7 @@ void SbModule::RunInit() { if( pImage && !pImage->bInit - && pImage->GetFlag( SBIMG_INITCODE ) ) + && pImage->IsFlag( SbiImageFlags::INITCODE ) ) { // Set flag, so that RunInit get activ (Testtool) GetSbData()->bRunInit = true; diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx index 9d8ac5762584..785a9e0b18f3 100644 --- a/basic/source/comp/codegen.cxx +++ b/basic/source/comp/codegen.cxx @@ -137,14 +137,14 @@ void SbiCodeGen::Save() p->nDimBase = pParser->nBase; // OPTION take over the EXPLICIT-Flag if( pParser->bExplicit ) - p->SetFlag( SBIMG_EXPLICIT ); + p->SetFlag( SbiImageFlags::EXPLICIT ); int nIfaceCount = 0; if( rMod.mnType == com::sun::star::script::ModuleType::CLASS ) { OSL_TRACE("COdeGen::save() classmodule processing"); rMod.bIsProxyModule = true; - p->SetFlag( SBIMG_CLASSMODULE ); + p->SetFlag( SbiImageFlags::CLASSMODULE ); GetSbData()->pClassFac->AddClassModule( &rMod ); nIfaceCount = pParser->aIfaceVector.size(); @@ -178,7 +178,7 @@ void SbiCodeGen::Save() // GlobalCode-Flag if( pParser->HasGlobalCode() ) { - p->SetFlag( SBIMG_INITCODE ); + p->SetFlag( SbiImageFlags::INITCODE ); } // Die Entrypoints: for( SbiSymDef* pDef = pParser->aPublics.First(); pDef; diff --git a/basic/source/inc/image.hxx b/basic/source/inc/image.hxx index 095c715b1516..0061a072531a 100644 --- a/basic/source/inc/image.hxx +++ b/basic/source/inc/image.hxx @@ -23,10 +23,24 @@ #include "sbintern.hxx" #include <rtl/ustring.hxx> #include <filefmt.hxx> +#include <o3tl/typed_flags_set.hxx> // This class reads in the image that's been produced by the compiler // and manages the access to the single elements. +enum class SbiImageFlags +{ + NONE = 0, + EXPLICIT = 0x0001, // OPTION EXPLICIT is active + COMPARETEXT = 0x0002, // OPTION COMPARE TEXT is active + INITCODE = 0x0004, // Init-Code does exist + CLASSMODULE = 0x0008, // OPTION ClassModule is active +}; +namespace o3tl +{ + template<> struct typed_flags<SbiImageFlags> : is_typed_flags<SbiImageFlags, 0xf> {}; +} + class SbiImage { friend class SbiCodeGen; // compiler classes, that the private- @@ -37,7 +51,7 @@ class SbiImage { char* pCode; // Code-Image char* pLegacyPCode; // Code-Image bool bError; - sal_uInt16 nFlags; + SbiImageFlags nFlags; short nStrings; sal_uInt32 nStringSize; sal_uInt32 nCodeSize; @@ -79,19 +93,14 @@ public: SbxArrayRef GetEnums() { return rEnums; } - void SetFlag( sal_uInt16 n ) { nFlags |= n; } - sal_uInt16 GetFlag( sal_uInt16 n ) const { return nFlags & n; } + void SetFlag( SbiImageFlags n ) { nFlags |= n; } + bool IsFlag( SbiImageFlags n ) const { return bool(nFlags & n); } sal_uInt16 CalcLegacyOffset( sal_Int32 nOffset ); sal_uInt32 CalcNewOffset( sal_Int16 nOffset ); void ReleaseLegacyBuffer(); bool ExceedsLegacyLimits(); }; -#define SBIMG_EXPLICIT 0x0001 // OPTION EXPLICIT is active -#define SBIMG_COMPARETEXT 0x0002 // OPTION COMPARE TEXT is active -#define SBIMG_INITCODE 0x0004 // Init-Code does exist -#define SBIMG_CLASSMODULE 0x0008 // OPTION ClassModule is active - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/runtime.hxx b/basic/source/inc/runtime.hxx index b56a340c3461..c7d6ba86195e 100644 --- a/basic/source/inc/runtime.hxx +++ b/basic/source/inc/runtime.hxx @@ -45,6 +45,7 @@ class SbiIoSystem; class SbiDdeControl; class SbiDllMgr; class SvNumberFormatter; // time/date functions +enum class SbiImageFlags; enum ForType { @@ -382,7 +383,7 @@ class SbiRuntime void implHandleSbxFlags( SbxVariable* pVar, SbxDataType t, sal_uInt32 nOp2 ); public: void SetVBAEnabled( bool bEnabled ); - sal_uInt16 GetImageFlag( sal_uInt16 n ) const; + bool IsImageFlag( SbiImageFlags n ) const; sal_uInt16 GetBase(); sal_Int32 nLine,nCol1,nCol2; SbiRuntime* pNext; // Stack-Chain diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 713611c245d4..e8502f45d3ed 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -925,7 +925,7 @@ RTLFUNC(InStr) if( bCompatibility ) { SbiRuntime* pRT = pInst->pRun; - bTextMode = pRT ? pRT->GetImageFlag( SBIMG_COMPARETEXT ) : sal_False; + bTextMode = pRT ? pRT->IsImageFlag( SbiImageFlags::COMPARETEXT ) : sal_False; } else { @@ -1000,7 +1000,7 @@ RTLFUNC(InStrRev) if( bCompatibility ) { SbiRuntime* pRT = pInst->pRun; - bTextMode = pRT ? pRT->GetImageFlag( SBIMG_COMPARETEXT ) : sal_False; + bTextMode = pRT ? pRT->IsImageFlag( SbiImageFlags::COMPARETEXT ) : sal_False; } else { @@ -1381,7 +1381,7 @@ RTLFUNC(Replace) if( bCompatibility ) { SbiRuntime* pRT = pInst->pRun; - bTextMode = pRT ? pRT->GetImageFlag( SBIMG_COMPARETEXT ) : sal_False; + bTextMode = pRT ? pRT->IsImageFlag( SbiImageFlags::COMPARETEXT ) : sal_False; } else { @@ -1642,7 +1642,7 @@ RTLFUNC(StrComp) if( bCompatibility ) { SbiRuntime* pRT = pInst->pRun; - nTextCompare = pRT && pRT->GetImageFlag( SBIMG_COMPARETEXT ); + nTextCompare = pRT && pRT->IsImageFlag( SbiImageFlags::COMPARETEXT ); } else { diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index 0334521a0f7d..29c1913c69bf 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -1320,9 +1320,9 @@ void SbiRuntime::DllCall PushVar( pRes ); } -sal_uInt16 SbiRuntime::GetImageFlag( sal_uInt16 n ) const +bool SbiRuntime::IsImageFlag( SbiImageFlags n ) const { - return pImg->GetFlag( n ); + return pImg->IsFlag( n ); } sal_uInt16 SbiRuntime::GetBase() @@ -1579,7 +1579,7 @@ void SbiRuntime::StepLIKE() bool bCompatibility = ( GetSbData()->pInst && GetSbData()->pInst->IsCompatibility() ); if( bCompatibility ) { - bTextMode = GetImageFlag( SBIMG_COMPARETEXT ); + bTextMode = IsImageFlag( SbiImageFlags::COMPARETEXT ); } if( bTextMode ) { @@ -3501,7 +3501,7 @@ SbxVariable* SbiRuntime::FindElement( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt } // else, if there are parameters, use different error code - if( !bLocal || pImg->GetFlag( SBIMG_EXPLICIT ) ) + if( !bLocal || pImg->IsFlag( SbiImageFlags::EXPLICIT ) ) { // #39108 if explicit and as ELEM always a fatal error bFatalError = true; @@ -4594,7 +4594,7 @@ void SbiRuntime::StepPUBLIC_P( sal_uInt32 nOp1, sal_uInt32 nOp2 ) // between invocations ( for VBASupport & document basic only ) if( pMod->pImage->bFirstInit ) { - bool bUsedForClassModule = pImg->GetFlag( SBIMG_CLASSMODULE ); + bool bUsedForClassModule = pImg->IsFlag( SbiImageFlags::CLASSMODULE ); StepPUBLIC_Impl( nOp1, nOp2, bUsedForClassModule ); } } @@ -4603,7 +4603,7 @@ void SbiRuntime::StepPUBLIC_P( sal_uInt32 nOp1, sal_uInt32 nOp2 ) void SbiRuntime::StepGLOBAL( sal_uInt32 nOp1, sal_uInt32 nOp2 ) { - if( pImg->GetFlag( SBIMG_CLASSMODULE ) ) + if( pImg->IsFlag( SbiImageFlags::CLASSMODULE ) ) { StepPUBLIC_Impl( nOp1, nOp2, true ); } |