diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-11-24 13:39:18 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-11-25 09:07:48 +0200 |
commit | bd7c9afb8b3c49cae80593414eeb262f2e1fb643 (patch) | |
tree | 4b24641a73341334888ff86c97b0be2ed3e6d3f1 /rsc | |
parent | a0ee31da5cb12e353da745455f1b4e9f147410da (diff) |
convert VAR constants to o3tl::typed_flags
and drop the unused EXTENDABLE
Change-Id: Iddb2d4c1f3a3f76e4687ad002c0c4b9f7e6ca055
Diffstat (limited to 'rsc')
-rw-r--r-- | rsc/inc/rscclass.hxx | 2 | ||||
-rw-r--r-- | rsc/inc/rsctop.hxx | 25 | ||||
-rw-r--r-- | rsc/source/parser/rscicpx.cxx | 48 | ||||
-rw-r--r-- | rsc/source/parser/rscinit.cxx | 2 | ||||
-rw-r--r-- | rsc/source/res/rscclass.cxx | 84 |
5 files changed, 69 insertions, 92 deletions
diff --git a/rsc/inc/rscclass.hxx b/rsc/inc/rscclass.hxx index bc9b31237d7f..31bf1fd0e337 100644 --- a/rsc/inc/rscclass.hxx +++ b/rsc/inc/rscclass.hxx @@ -62,7 +62,7 @@ public: void Pre_dtor() override; ERRTYPE SetVariable( Atom nVarName, RscTop * pClass, RSCINST * pDflt = nullptr, - RSCVAR nVarType = 0, sal_uInt32 nMask = 0, + RSCVAR nVarType = RSCVAR::NONE, sal_uInt32 nMask = 0, Atom nDataBaseName = InvalidAtom ) override; virtual void EnumVariables( void * pData, VarEnumCallbackProc ) override; RSCINST GetVariable( const RSCINST & rInst, Atom nVarName, diff --git a/rsc/inc/rsctop.hxx b/rsc/inc/rsctop.hxx index b4feec0166f8..24d4082404b7 100644 --- a/rsc/inc/rsctop.hxx +++ b/rsc/inc/rsctop.hxx @@ -24,15 +24,20 @@ #include <rschash.hxx> #include <rscclobj.hxx> #include <rsc/rscsfx.hxx> - -typedef sal_uInt32 RSCVAR; -#define VAR_POINTER 0x0001 -#define VAR_HIDDEN 0x0002 -#define VAR_NODATAINST 0x0004 -#define VAR_NORC 0x0008 -#define VAR_SVDYNAMIC 0x0010 -#define VAR_NOENUM 0x0020 -#define VAR_EXTENDABLE 0x0040 /* class derivation can all be given */ +#include <o3tl/typed_flags_set.hxx> + +enum class RSCVAR { + NONE = 0x0000, + Pointer = 0x0001, + Hidden = 0x0002, + NoDataInst = 0x0004, + NoRc = 0x0008, + SvDynamic = 0x0010, + NoEnum = 0x0020 +}; +namespace o3tl { + template<> struct typed_flags<RSCVAR> : is_typed_flags<RSCVAR, 0x007f> {}; +} class RscTop : public RefNode { @@ -83,7 +88,7 @@ public: // sets the variable virtual ERRTYPE SetVariable( Atom nVarName, RscTop * pClass, RSCINST * pDflt = nullptr, - RSCVAR nVarType = 0, sal_uInt32 nMask = 0, + RSCVAR nVarType = RSCVAR::NONE, sal_uInt32 nMask = 0, Atom nDataBaseName = InvalidAtom ); // enumerate all variables diff --git a/rsc/source/parser/rscicpx.cxx b/rsc/source/parser/rscicpx.cxx index e03ce1e04422..05a692043d14 100644 --- a/rsc/source/parser/rscicpx.cxx +++ b/rsc/source/parser/rscicpx.cxx @@ -57,7 +57,7 @@ RscTop * RscTypCont::InitClassMgr() pClassMgr->SetVariable( nId, pCont ); }; nId = aNmTb.Put( "Comment", VARNAME ); - pClassMgr->SetVariable( nId, &aString, nullptr, VAR_NORC ); + pClassMgr->SetVariable( nId, &aString, nullptr, RSCVAR::NoRc ); pClass->SetTypeClass( pClassMgr ); @@ -92,7 +92,7 @@ RscTop * RscTypCont::InitClassBitmap( RscTop * pSuper ) // the class RscSysDepend handles variables "FILE" in a specific way nId = aNmTb.Put( "File", VARNAME ); - pClassBitmap->SetVariable( nId, &aLangString, nullptr, VAR_NORC ); + pClassBitmap->SetVariable( nId, &aLangString, nullptr, RSCVAR::NoRc ); return pClassBitmap; } @@ -110,7 +110,7 @@ RscTop * RscTypCont::InitClassImage( RscTop * pSuper, RscTop * pClassBitmap ) // initialize variables nId = aNmTb.Put( "ImageBitmap", VARNAME ); - pClassImage->SetVariable( nId, pClassBitmap, nullptr, 0, (sal_uInt32)RscImageFlags::ImageBitmap ); + pClassImage->SetVariable( nId, pClassBitmap, nullptr, RSCVAR::NONE, (sal_uInt32)RscImageFlags::ImageBitmap ); return pClassImage; } @@ -133,14 +133,14 @@ RscTop * RscTypCont::InitClassImageList( RscTop * pSuper, RscCont * pStrLst ) pCont->SetTypeClass( &aIdUShort ); aBaseLst.push_back( pCont ); nId = aNmTb.Put( "IdList", VARNAME ); - pClassImageList->SetVariable( nId, pCont, nullptr, 0, + pClassImageList->SetVariable( nId, pCont, nullptr, RSCVAR::NONE, (sal_uInt32)RscImageListFlags::IdList ); nId = aNmTb.Put( "FileList", VARNAME ); pClassImageList->SetVariable( nId, pStrLst ); nId = aNmTb.Put( "IdCount", VARNAME ); - pClassImageList->SetVariable( nId, &aUShort, nullptr, 0, + pClassImageList->SetVariable( nId, &aUShort, nullptr, RSCVAR::NONE, (sal_uInt32)RscImageListFlags::IdCount ); return pClassImageList; } @@ -177,7 +177,7 @@ RscTop * RscTypCont::InitClassKeyCode( RscTop * pSuper, RscEnum * pKey ) // add variable nVarId = aNmTb.Put( "_ModifierFlags", VARNAME ); pClassKeyCode->SetVariable( nVarId, pFlag, nullptr, - VAR_HIDDEN | VAR_NOENUM ); + RSCVAR::Hidden | RSCVAR::NoEnum ); // add client variables aBaseLst.push_back( @@ -185,14 +185,14 @@ RscTop * RscTypCont::InitClassKeyCode( RscTop * pSuper, RscEnum * pKey ) ); nId = aNmTb.Put( "Shift", VARNAME ); pClassKeyCode->SetVariable( nId, pClient, nullptr, - VAR_NODATAINST, 0, nVarId ); + RSCVAR::NoDataInst, 0, nVarId ); aBaseLst.push_back( pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, pFlag, nMod1Id ) ); nId = aNmTb.Put( "Modifier1", VARNAME ); pClassKeyCode->SetVariable( nId, pClient, nullptr, - VAR_NODATAINST, 0, nVarId ); + RSCVAR::NoDataInst, 0, nVarId ); aBaseLst.push_back( @@ -200,7 +200,7 @@ RscTop * RscTypCont::InitClassKeyCode( RscTop * pSuper, RscEnum * pKey ) ); nId = aNmTb.Put( "Modifier2", VARNAME ); pClassKeyCode->SetVariable( nId, pClient, nullptr, - VAR_NODATAINST, 0, nVarId ); + RSCVAR::NoDataInst, 0, nVarId ); } { Atom nVarId; @@ -247,10 +247,10 @@ RscTop * RscTypCont::InitClassMenuItem( RscTop * pSuper ) // initialize variables nId = aNmTb.Put( "Separator", VARNAME ); - pClassMenuItem->SetVariable( nId, &aBool, nullptr, 0, + pClassMenuItem->SetVariable( nId, &aBool, nullptr, RSCVAR::NONE, (sal_uInt32)RscMenuItem::Separator ); nId = aNmTb.Put( "Identifier", VARNAME ); - pClassMenuItem->SetVariable( nId, &aIdNoZeroUShort, nullptr, 0, + pClassMenuItem->SetVariable( nId, &aIdNoZeroUShort, nullptr, RSCVAR::NONE, (sal_uInt32)RscMenuItem::Id ); { RscFlag * pFlag; @@ -275,7 +275,7 @@ RscTop * RscTypCont::InitClassMenuItem( RscTop * pSuper ) // add variable nVarId = aNmTb.Put( "_MenuItemFlags", VARNAME ); pClassMenuItem->SetVariable( nVarId, pFlag, nullptr, - VAR_HIDDEN | VAR_NOENUM, + RSCVAR::Hidden | RSCVAR::NoEnum, (sal_uInt32)RscMenuItem::Status ); // add client variables @@ -284,51 +284,51 @@ RscTop * RscTypCont::InitClassMenuItem( RscTop * pSuper ) ); nId = aNmTb.Put( "Checkable", VARNAME ); pClassMenuItem->SetVariable( nId, pClient, nullptr, - VAR_NODATAINST, 0, nVarId ); + RSCVAR::NoDataInst, 0, nVarId ); aBaseLst.push_back( pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, pFlag, nAutoCheckId ) ); nId = aNmTb.Put( "AutoCheck", VARNAME ); pClassMenuItem->SetVariable( nId, pClient, nullptr, - VAR_NODATAINST, 0, nVarId ); + RSCVAR::NoDataInst, 0, nVarId ); aBaseLst.push_back( pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, pFlag, nRadioCheckId ) ); nId = aNmTb.Put( "RadioCheck", VARNAME ); pClassMenuItem->SetVariable( nId, pClient, nullptr, - VAR_NODATAINST, 0, nVarId ); + RSCVAR::NoDataInst, 0, nVarId ); aBaseLst.push_back( pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, pFlag, nAboutId ) ); nId = aNmTb.Put( "About", VARNAME ); pClassMenuItem->SetVariable( nId, pClient, nullptr, - VAR_NODATAINST, 0, nVarId ); + RSCVAR::NoDataInst, 0, nVarId ); aBaseLst.push_back( pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, pFlag, nHelpId ) ); nId = aNmTb.Put( "Help", VARNAME ); pClassMenuItem->SetVariable( nId, pClient, nullptr, - VAR_NODATAINST, 0, nVarId ); + RSCVAR::NoDataInst, 0, nVarId ); } nId = aNmTb.Put( "Text", VARNAME ); - pClassMenuItem->SetVariable( nId, &aLangString, nullptr, 0, + pClassMenuItem->SetVariable( nId, &aLangString, nullptr, RSCVAR::NONE, (sal_uInt32)RscMenuItem::Text ); nId = aNmTb.Put( "HelpText", VARNAME ); - pClassMenuItem->SetVariable( nId, &aLangString, nullptr, 0, + pClassMenuItem->SetVariable( nId, &aLangString, nullptr, RSCVAR::NONE, (sal_uInt32)RscMenuItem::HelpText ); nId = aNmTb.Put( "HelpID", VARNAME ); - pClassMenuItem->SetVariable( nId, &aStringLiteral, nullptr, 0, + pClassMenuItem->SetVariable( nId, &aStringLiteral, nullptr, RSCVAR::NONE, (sal_uInt32)RscMenuItem::HelpId ); nId = aNmTb.Put( "Disable", VARNAME ); - pClassMenuItem->SetVariable( nId, &aBool, nullptr, 0, + pClassMenuItem->SetVariable( nId, &aBool, nullptr, RSCVAR::NONE, (sal_uInt32)RscMenuItem::Disable ); nId = aNmTb.Put( "Command", VARNAME ); - pClassMenuItem->SetVariable( nId, &aString, nullptr, 0, + pClassMenuItem->SetVariable( nId, &aString, nullptr, RSCVAR::NONE, (sal_uInt32)RscMenuItem::Command ); return pClassMenuItem; @@ -353,10 +353,10 @@ RscTop * RscTypCont::InitClassMenu( RscTop * pSuper, aBaseLst.push_back( pCont = new RscCont( pHS->getID( "ContMenuItem" ), RSC_NOTYPE ) ); pCont->SetTypeClass( pClassMenuItem ); nId = aNmTb.Put( "ItemList", VARNAME ); - pClassMenu->SetVariable( nId, pCont, nullptr, 0, (sal_uInt32)RscMenu::Items ); + pClassMenu->SetVariable( nId, pCont, nullptr, RSCVAR::NONE, (sal_uInt32)RscMenu::Items ); } nId = aNmTb.Put( "Text", VARNAME ); - pClassMenu->SetVariable( nId, &aLangString, nullptr, 0, (sal_uInt32)RscMenu::Text ); + pClassMenu->SetVariable( nId, &aLangString, nullptr, RSCVAR::NONE, (sal_uInt32)RscMenu::Text ); return pClassMenu; } diff --git a/rsc/source/parser/rscinit.cxx b/rsc/source/parser/rscinit.cxx index 13b8859ab35a..18b96a80fa0b 100644 --- a/rsc/source/parser/rscinit.cxx +++ b/rsc/source/parser/rscinit.cxx @@ -138,7 +138,7 @@ void RscTypCont::Init() // pClassMenu is only completely defined here nId = aNmTb.Put( "SubMenu", VARNAME ); - pClassMenuItem->SetVariable( nId, pClassMenu, nullptr, VAR_SVDYNAMIC, + pClassMenuItem->SetVariable( nId, pClassMenu, nullptr, RSCVAR::SvDynamic, (sal_uInt32)RscMenuItem::Menu ); } diff --git a/rsc/source/res/rscclass.cxx b/rsc/source/res/rscclass.cxx index 3e6e802b7ae6..fc1d08e1a967 100644 --- a/rsc/source/res/rscclass.cxx +++ b/rsc/source/res/rscclass.cxx @@ -78,7 +78,7 @@ RSCINST RscClass::GetInstData aInst.pClass = pVarTypeList[ nEle ].pClass; if( pData ) { - if( VAR_NODATAINST & pVarTypeList[ nEle ].nVarType ) + if( RSCVAR::NoDataInst & pVarTypeList[ nEle ].nVarType ) { RSCINST aTmpI; @@ -96,12 +96,9 @@ RSCINST RscClass::GetInstData RSCINST() ).pData; } - else if( VAR_POINTER & pVarTypeList[ nEle ].nVarType ) + else if( RSCVAR::Pointer & pVarTypeList[ nEle ].nVarType ) { - if( VAR_EXTENDABLE & pVarTypeList[ nEle ].nVarType ) - aInst = *reinterpret_cast<RSCINST *>(pData + pVarTypeList[ nEle ].nOffset); - else - aInst.pData = *reinterpret_cast<CLASS_DATA *>(pData + pVarTypeList[ nEle ].nOffset); + aInst.pData = *reinterpret_cast<CLASS_DATA *>(pData + pVarTypeList[ nEle ].nOffset); } else aInst.pData = pData + pVarTypeList[ nEle ].nOffset; @@ -167,19 +164,10 @@ RSCINST RscClass::Create( RSCINST * pInst, { aDfltI = GetInstData( bOwnClass ? rDflt.pData : nullptr, i, true ); - if( (VAR_POINTER & pVarTypeList[ i ].nVarType) && - !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) ) + if( (RSCVAR::Pointer & pVarTypeList[ i ].nVarType) && + !(RSCVAR::NoDataInst & pVarTypeList[ i ].nVarType) ) { - CLASS_DATA * ppData; - if( VAR_EXTENDABLE & pVarTypeList[ i ].nVarType ) - { - RSCINST * pInstance = reinterpret_cast<RSCINST *>(aInst.pData + pVarTypeList[ i ].nOffset ); - pInstance->pClass = pVarTypeList[ i ].pClass; - ppData = &pInstance->pData; - } - else - ppData = reinterpret_cast<CLASS_DATA*>(aInst.pData + pVarTypeList[ i ].nOffset ); - + CLASS_DATA * ppData = reinterpret_cast<CLASS_DATA*>(aInst.pData + pVarTypeList[ i ].nOffset ); *ppData = nullptr; if( aDfltI.IsInst() ) { @@ -205,7 +193,7 @@ void RscClass::Destroy( const RSCINST & rInst ) for( i = 0; i < nEntries; i++ ) { - if( !(pVarTypeList[ i ].nVarType & VAR_NODATAINST) ) + if( !(pVarTypeList[ i ].nVarType & RSCVAR::NoDataInst) ) { RSCINST aTmpI; @@ -214,7 +202,7 @@ void RscClass::Destroy( const RSCINST & rInst ) { // destroy object aTmpI.pClass->Destroy( aTmpI ); - if( pVarTypeList[ i ].nVarType & VAR_POINTER ) + if( pVarTypeList[ i ].nVarType & RSCVAR::Pointer ) { // free memory rtl_freeMemory( aTmpI.pData ); @@ -251,18 +239,15 @@ ERRTYPE RscClass::SetVariable( Atom nVarName, else pVarTypeList[ nEntries ].pDefault = nullptr; - pVarTypeList[ nEntries ].nVarType = ~VAR_POINTER & nVarType; - if( pClass->Size() > 10 || (nVarType & VAR_EXTENDABLE) ) - pVarTypeList[ nEntries ].nVarType |= VAR_POINTER; + pVarTypeList[ nEntries ].nVarType = ~RSCVAR::Pointer & nVarType; + if( pClass->Size() > 10 ) + pVarTypeList[ nEntries ].nVarType |= RSCVAR::Pointer; - if( !(pVarTypeList[ nEntries ].nVarType & VAR_NODATAINST) ) + if( !(pVarTypeList[ nEntries ].nVarType & RSCVAR::NoDataInst) ) { - if( pVarTypeList[ nEntries ].nVarType & VAR_POINTER ) + if( pVarTypeList[ nEntries ].nVarType & RSCVAR::Pointer ) { - if( pVarTypeList[ nEntries ].nVarType & VAR_EXTENDABLE ) - nSize += sizeof( RSCINST ); - else - nSize += sizeof( CLASS_DATA ); + nSize += sizeof( CLASS_DATA ); } else nSize += pClass->Size(); @@ -284,7 +269,7 @@ void RscClass::EnumVariables( void * pData, VarEnumCallbackProc pProc ) RscTop::EnumVariables( pData, pProc ); for( i = 0; i < nEntries; i ++ ) { - if( !(pVarTypeList[ i ].nVarType & VAR_NOENUM) ) + if( !(pVarTypeList[ i ].nVarType & RSCVAR::NoEnum) ) (*pProc)( pData, pVarTypeList[ i ].pClass->GetClassType(), pVarTypeList[ i ].nVarName ); } } @@ -303,7 +288,7 @@ RSCINST RscClass::GetVariable( const RSCINST & rInst, if( i < nEntries ) { - if( VAR_NODATAINST & pVarTypeList[ i ].nVarType ) + if( RSCVAR::NoDataInst & pVarTypeList[ i ].nVarType ) { aTmpI = GetVariable( rInst, pVarTypeList[ i ].nDataBaseName, @@ -332,23 +317,10 @@ RSCINST RscClass::GetVariable( const RSCINST & rInst, } else { // is provided via pointer - if( VAR_EXTENDABLE & pVarTypeList[ i ].nVarType ) - { - RSCINST * pInst = reinterpret_cast<RSCINST *> - (rInst.pData + pVarTypeList[ i ].nOffset ); - if( pCreateClass && pCreateClass->InHierarchy( aTmpI.pClass ) ) - *pInst = pCreateClass->Create( nullptr, aDefInst ); - else - *pInst = aTmpI.pClass->Create( nullptr, aDefInst ); - aTmpI = *pInst; - } - else - { - CLASS_DATA * ppData - = reinterpret_cast<CLASS_DATA *>(rInst.pData + pVarTypeList[ i ].nOffset); - aTmpI = aTmpI.pClass->Create( nullptr, aDefInst ); - *ppData = aTmpI.pData; - } + CLASS_DATA * ppData + = reinterpret_cast<CLASS_DATA *>(rInst.pData + pVarTypeList[ i ].nOffset); + aTmpI = aTmpI.pClass->Create( nullptr, aDefInst ); + *ppData = aTmpI.pData; } } // set as non default @@ -370,7 +342,7 @@ RSCINST RscClass::GetCopyVar( const RSCINST & rInst, Atom nVarName) if( i < nEntries ) { - if( VAR_NODATAINST & pVarTypeList[ i ].nVarType ) + if( RSCVAR::NoDataInst & pVarTypeList[ i ].nVarType ) { aVarI = GetCopyVar( rInst, pVarTypeList[ i ].nDataBaseName ); aVarI.pClass = pVarTypeList[ i ].pClass; @@ -403,7 +375,7 @@ bool RscClass::IsConsistent( const RSCINST & rInst ) for( i = 0; i < nEntries; i++ ) { - if( !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) ) + if( !(RSCVAR::NoDataInst & pVarTypeList[ i ].nVarType) ) { aTmpI = GetInstData( rInst.pData, i, true ); @@ -427,7 +399,7 @@ void RscClass::SetToDefault( const RSCINST & rInst ) for( i = 0; i < nEntries; i++ ) { // variables without own memory are set from "data server" to default - if( !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) ) + if( !(RSCVAR::NoDataInst & pVarTypeList[ i ].nVarType) ) { aTmpI = GetInstData( rInst.pData, i, true ); if( aTmpI.IsInst() ) @@ -447,7 +419,7 @@ bool RscClass::IsDefault( const RSCINST & rInst ) for( i = 0; i < nEntries; i++ ) { // variables without own memory are looked for default in "data server" - if( !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) ) + if( !(RSCVAR::NoDataInst & pVarTypeList[ i ].nVarType) ) if( !IsDflt( rInst.pData, i ) ) return false; } @@ -483,7 +455,7 @@ bool RscClass::IsValueDflt( CLASS_DATA pData, sal_uInt32 nEle ) if( aTmpI.IsInst() ) { - if( VAR_SVDYNAMIC & pVarTypeList[ nEle ].nVarType ) + if( RSCVAR::SvDynamic & pVarTypeList[ nEle ].nVarType ) return false; if( aTmpI.pClass == pVarTypeList[ nEle ].pClass ) @@ -566,7 +538,7 @@ void RscClass::WriteSrc( const RSCINST & rInst, for( i = 0; i < nEntries; i++ ) { - if( !(VAR_HIDDEN & pVarTypeList[ i ].nVarType) ) + if( !(RSCVAR::Hidden & pVarTypeList[ i ].nVarType) ) { if( !IsDflt( rInst.pData, i ) && !IsValueDflt( rInst.pData, i ) ) { @@ -616,7 +588,7 @@ ERRTYPE RscClass::WriteInstRc( const RSCINST & rInst, for( i = 0; i < nEntries && aError.IsOk(); i++ ) { - if( !((VAR_NODATAINST | VAR_NORC) & pVarTypeList[ i ].nVarType )) + if( !((RSCVAR::NoDataInst | RSCVAR::NoRc) & pVarTypeList[ i ].nVarType )) { if( pVarTypeList[ i ].nMask ) { @@ -749,7 +721,7 @@ void RscTupel::WriteSrc( const RSCINST & rInst, FILE * fOutput, fprintf( fOutput, "< " ); for( i = 0; i < nEntries; i++ ) { - if( !(VAR_HIDDEN & pVarTypeList[ i ].nVarType) ) + if( !(RSCVAR::Hidden & pVarTypeList[ i ].nVarType) ) { if( !IsDflt( rInst.pData, i ) && !IsValueDflt( rInst.pData, i ) ) |