From 3a40d3de89f0b1252974c98e5a5382d6eca67025 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 15 Jan 2018 09:07:14 +0100 Subject: More loplugin:cstylecast: basic Change-Id: I0bb219632da384ab047a2b1fc3f2b041dacaf2cb --- basic/source/classes/sbunoobj.cxx | 10 +++++----- basic/source/classes/sbxmod.cxx | 2 +- basic/source/comp/codegen.cxx | 18 +++++++++--------- basic/source/comp/token.cxx | 2 +- basic/source/runtime/methods.cxx | 12 ++++++------ basic/source/runtime/methods1.cxx | 2 +- basic/source/runtime/runtime.cxx | 30 +++++++++++++++--------------- basic/source/sbx/sbxarray.cxx | 2 +- basic/source/sbx/sbxbase.cxx | 2 +- basic/source/sbx/sbxobj.cxx | 6 +++--- basic/source/sbx/sbxvalue.cxx | 6 +++--- basic/source/sbx/sbxvar.cxx | 2 +- 12 files changed, 47 insertions(+), 47 deletions(-) (limited to 'basic') diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index d622d887ce21..fc2b6fac29ef 100644 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -488,7 +488,7 @@ SbxDataType unoToSbxType( TypeClass eType ) case TypeClass_ENUM: eRetType = SbxLONG; break; case TypeClass_SEQUENCE: - eRetType = (SbxDataType) ( SbxOBJECT | SbxARRAY ); + eRetType = SbxDataType( SbxOBJECT | SbxARRAY ); break; @@ -867,7 +867,7 @@ Type getUnoTypeForSbxValue( const SbxValue* pVal ) if( auto pArray = dynamic_cast( xObj.get() ) ) { short nDims = pArray->GetDims(); - Type aElementType = getUnoTypeForSbxBaseType( (SbxDataType)(pArray->GetType() & 0xfff) ); + Type aElementType = getUnoTypeForSbxBaseType( static_cast(pArray->GetType() & 0xfff) ); TypeClass eElementTypeClass = aElementType.getTypeClass(); // Normal case: One dimensional array @@ -1861,7 +1861,7 @@ OUString Impl_DumpProperties(SbUnoObject& rUnoObj) { Type aType = rProp.Type; if( aType.getTypeClass() == TypeClass_SEQUENCE ) - eType = (SbxDataType) ( SbxOBJECT | SbxARRAY ); + eType = SbxDataType( SbxOBJECT | SbxARRAY ); } } aPropStr.append( Dbg_SbxDataType2String( eType ) ); @@ -1930,7 +1930,7 @@ OUString Impl_DumpMethods(SbUnoObject& rUnoObj) { Reference< XIdlClass > xClass = rxMethod->getReturnType(); if( xClass.is() && xClass->getTypeClass() == TypeClass_SEQUENCE ) - eType = (SbxDataType) ( SbxOBJECT | SbxARRAY ); + eType = SbxDataType( SbxOBJECT | SbxARRAY ); } // output the name and the type aRet.append( Dbg_SbxDataType2String( eType ) ); @@ -4793,7 +4793,7 @@ OUString SbUnoStructRefObject::Impl_DumpProperties() { if( rPropInfo.getTypeClass() == TypeClass_SEQUENCE ) { - eType = (SbxDataType) ( SbxOBJECT | SbxARRAY ); + eType = SbxDataType( SbxOBJECT | SbxARRAY ); } } } diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 3c28f7a5b765..d83cd2b59874 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -1451,7 +1451,7 @@ const sal_uInt8* SbModule::FindNextStmnt( const sal_uInt8* p, sal_uInt16& nLine, sal_uInt32 nPC = static_cast( p - reinterpret_cast(pImage->GetCode()) ); while( nPC < pImage->GetCodeSize() ) { - SbiOpcode eOp = (SbiOpcode ) ( *p++ ); + SbiOpcode eOp = static_cast( *p++ ); nPC++; if( bFollowJumps && eOp == SbiOpcode::JUMP_ && pImg ) { diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx index e1ad56d7efde..aa587ba0e5b5 100644 --- a/basic/source/comp/codegen.cxx +++ b/basic/source/comp/codegen.cxx @@ -89,7 +89,7 @@ sal_uInt32 SbiCodeGen::Gen( SbiOpcode eOpcode ) pParser->Error( ERRCODE_BASIC_INTERNAL_ERROR, "OPCODE1" ); #endif GenStmnt(); - aCode += (sal_uInt8) eOpcode; + aCode += static_cast(eOpcode); return GetPC(); } @@ -103,7 +103,7 @@ sal_uInt32 SbiCodeGen::Gen( SbiOpcode eOpcode, sal_uInt32 nOpnd ) pParser->Error( ERRCODE_BASIC_INTERNAL_ERROR, "OPCODE2" ); #endif GenStmnt(); - aCode += (sal_uInt8) eOpcode; + aCode += static_cast(eOpcode); sal_uInt32 n = GetPC(); aCode += nOpnd; return n; @@ -119,7 +119,7 @@ sal_uInt32 SbiCodeGen::Gen( SbiOpcode eOpcode, sal_uInt32 nOpnd1, sal_uInt32 nOp pParser->Error( ERRCODE_BASIC_INTERNAL_ERROR, "OPCODE3" ); #endif GenStmnt(); - aCode += (sal_uInt8) eOpcode; + aCode += static_cast(eOpcode); sal_uInt32 n = GetPC(); aCode += nOpnd1; aCode += nOpnd2; @@ -306,11 +306,11 @@ void SbiCodeGen::Save() SbxDataType t = pPar->GetType(); if( !pPar->IsByVal() ) { - t = (SbxDataType) ( t | SbxBYREF ); + t = static_cast( t | SbxBYREF ); } if( pPar->GetDims() ) { - t = (SbxDataType) ( t | SbxARRAY ); + t = static_cast( t | SbxARRAY ); } // #33677 hand-over an Optional-Info SbxFlagBits nFlags = SbxFlagBits::Read; @@ -428,7 +428,7 @@ public: T nOp1 = 0, nOp2 = 0; for( ; pCode < pEnd; ) { - SbiOpcode eOp = (SbiOpcode)(*pCode++); + SbiOpcode eOp = static_cast(*pCode++); if ( eOp <= SbiOpcode::SbOP0_END ) visitor.processOpCode0( eOp ); @@ -498,11 +498,11 @@ public: virtual void start( const sal_uInt8* pStart ) override { m_pStart = pStart; } virtual void processOpCode0( SbiOpcode eOp ) override { - m_ConvertedBuf += (sal_uInt8)eOp; + m_ConvertedBuf += static_cast(eOp); } virtual void processOpCode1( SbiOpcode eOp, T nOp1 ) override { - m_ConvertedBuf += (sal_uInt8)eOp; + m_ConvertedBuf += static_cast(eOp); switch( eOp ) { case SbiOpcode::JUMP_: @@ -527,7 +527,7 @@ public: } virtual void processOpCode2( SbiOpcode eOp, T nOp1, T nOp2 ) override { - m_ConvertedBuf += (sal_uInt8)eOp; + m_ConvertedBuf += static_cast(eOp); if ( eOp == SbiOpcode::CASEIS_ ) if ( nOp1 ) nOp1 = static_cast( convertBufferOffSet(m_pStart, nOp1) ); diff --git a/basic/source/comp/token.cxx b/basic/source/comp/token.cxx index 371c9bb4269f..60d10ab6a11b 100644 --- a/basic/source/comp/token.cxx +++ b/basic/source/comp/token.cxx @@ -407,7 +407,7 @@ SbiToken SbiTokenizer::Next() sal_Unicode ch = aSym[0]; if( !BasicCharClass::isAlpha( ch, bCompatible ) && !bSymbol ) { - return eCurTok = (SbiToken) (ch & 0x00FF); + return eCurTok = static_cast(ch & 0x00FF); } return eCurTok = SYMBOL; } diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 05adf06d3049..17ee2b4f969d 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -2971,15 +2971,15 @@ void SbRtl_GetAttr(StarBASIC * pBasic, SbxArray & rPar, bool bWrite) bool bDirectory = xSFI->isFolder( aPath ); if( bReadOnly ) { - nFlags |= (sal_uInt16)SbAttributes::READONLY; + nFlags |= sal_uInt16(SbAttributes::READONLY); } if( bHidden ) { - nFlags |= (sal_uInt16)SbAttributes::HIDDEN; + nFlags |= sal_uInt16(SbAttributes::HIDDEN); } if( bDirectory ) { - nFlags |= (sal_uInt16)SbAttributes::DIRECTORY; + nFlags |= sal_uInt16(SbAttributes::DIRECTORY); } } catch(const Exception & ) @@ -3001,11 +3001,11 @@ void SbRtl_GetAttr(StarBASIC * pBasic, SbxArray & rPar, bool bWrite) bool bDirectory = isFolder( aType ); if( bReadOnly ) { - nFlags |= (sal_uInt16)SbAttributes::READONLY; + nFlags |= sal_uInt16(SbAttributes::READONLY); } if( bDirectory ) { - nFlags |= (sal_uInt16)SbAttributes::DIRECTORY; + nFlags |= sal_uInt16(SbAttributes::DIRECTORY); } } rPar.Get(0)->PutInteger( nFlags ); @@ -3150,7 +3150,7 @@ void SbRtl_FileAttr(StarBASIC *, SbxArray & rPar, bool) sal_Int16 nRet; if ( rPar.Get(2)->GetInteger() == 1 ) { - nRet = (sal_Int16)(pSbStrm->GetMode()); + nRet = static_cast(pSbStrm->GetMode()); } else { diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx index aa7d009be0a8..68dfb503f572 100644 --- a/basic/source/runtime/methods1.cxx +++ b/basic/source/runtime/methods1.cxx @@ -1004,7 +1004,7 @@ static bool lcl_ReadSbxVariable( SbxVariable& rVar, SvStream* pStrm, { sal_uInt16 nTemp; pStrm->ReadUInt16( nTemp ); - eSrcType = (SbxDataType)nTemp; + eSrcType = static_cast(nTemp); } switch( eSrcType ) diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index 63fe8c580ad8..db68c4988f98 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -661,10 +661,10 @@ void SbiRuntime::SetParameters( SbxArray* pParams ) if( p ) { bByVal |= ( p->eType & SbxBYREF ) == 0; - t = (SbxDataType) ( p->eType & 0x0FFF ); + t = static_cast( p->eType & 0x0FFF ); if( !bByVal && t != SbxVARIANT && - (!v->IsFixed() || (SbxDataType)(v->GetType() & 0x0FFF ) != t) ) + (!v->IsFixed() || static_cast(v->GetType() & 0x0FFF ) != t) ) { bByVal = true; } @@ -748,7 +748,7 @@ bool SbiRuntime::Step() } } - SbiOpcode eOp = (SbiOpcode ) ( *pCode++ ); + SbiOpcode eOp = static_cast( *pCode++ ); sal_uInt32 nOp1, nOp2; if (eOp <= SbiOpcode::SbOP0_END) { @@ -2813,7 +2813,7 @@ void SbiRuntime::StepARGTYP( sal_uInt32 nOp1 ) else { bool bByVal = (nOp1 & 0x8000) != 0; // Is BYVAL requested? - SbxDataType t = (SbxDataType) (nOp1 & 0x7FFF); + SbxDataType t = static_cast(nOp1 & 0x7FFF); SbxVariable* pVar = refArgv->Get( refArgv->Count() - 1 ); // last Arg // check BYVAL @@ -3310,7 +3310,7 @@ SbxVariable* SbiRuntime::FindElement( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt else { bool bFatalError = false; - SbxDataType t = (SbxDataType) nOp2; + SbxDataType t = static_cast(nOp2); OUString aName( pImg->GetString( static_cast( nOp1 & 0x7FFF ) ) ); // Hacky capture of Evaluate [] syntax // this should be tackled I feel at the pcode level @@ -3991,7 +3991,7 @@ void SbiRuntime::StepELEM( sal_uInt32 nOp1, sal_uInt32 nOp2 ) void SbiRuntime::StepPARAM( sal_uInt32 nOp1, sal_uInt32 nOp2 ) { sal_uInt16 i = static_cast( nOp1 & 0x7FFF ); - SbxDataType t = (SbxDataType) nOp2; + SbxDataType t = static_cast(nOp2); SbxVariable* p; // #57915 solve missing in a cleaner way @@ -4055,7 +4055,7 @@ void SbiRuntime::StepPARAM( sal_uInt32 nOp1, sal_uInt32 nOp2 ) Error( ERRCODE_BASIC_NOT_OPTIONAL ); } } - else if( t != SbxVARIANT && (SbxDataType)(p->GetType() & 0x0FFF ) != t ) + else if( t != SbxVARIANT && static_cast(p->GetType() & 0x0FFF ) != t ) { SbxVariable* q = new SbxVariable( t ); aRefSaved.emplace_back(q ); @@ -4082,7 +4082,7 @@ void SbiRuntime::StepCASEIS( sal_uInt32 nOp1, sal_uInt32 nOp2 ) { SbxVariableRef xComp = PopVar(); SbxVariableRef xCase = refCaseStk->Get( refCaseStk->Count() - 1 ); - if( xCase->Compare( (SbxOperator) nOp2, *xComp ) ) + if( xCase->Compare( static_cast(nOp2), *xComp ) ) { StepJUMP( nOp1 ); } @@ -4100,7 +4100,7 @@ void SbiRuntime::StepCALL( sal_uInt32 nOp1, sal_uInt32 nOp2 ) { pArgs = refArgv.get(); } - DllCall( aName, aLibName, pArgs, (SbxDataType) nOp2, false ); + DllCall( aName, aLibName, pArgs, static_cast(nOp2), false ); aLibName.clear(); if( nOp1 & 0x8000 ) { @@ -4118,7 +4118,7 @@ void SbiRuntime::StepCALLC( sal_uInt32 nOp1, sal_uInt32 nOp2 ) { pArgs = refArgv.get(); } - DllCall( aName, aLibName, pArgs, (SbxDataType) nOp2, true ); + DllCall( aName, aLibName, pArgs, static_cast(nOp2), true ); aLibName.clear(); if( nOp1 & 0x8000 ) { @@ -4458,7 +4458,7 @@ void SbiRuntime::StepLOCAL( sal_uInt32 nOp1, sal_uInt32 nOp2 ) OUString aName( pImg->GetString( static_cast( nOp1 ) ) ); if( refLocals->Find( aName, SbxClassType::DontCare ) == nullptr ) { - SbxDataType t = (SbxDataType)(nOp2 & 0xffff); + SbxDataType t = static_cast(nOp2 & 0xffff); SbxVariable* p = new SbxVariable( t ); p->SetName( aName ); implHandleSbxFlags( p, t, nOp2 ); @@ -4471,7 +4471,7 @@ void SbiRuntime::StepLOCAL( sal_uInt32 nOp1, sal_uInt32 nOp2 ) void SbiRuntime::StepPUBLIC_Impl( sal_uInt32 nOp1, sal_uInt32 nOp2, bool bUsedForClassModule ) { OUString aName( pImg->GetString( static_cast( nOp1 ) ) ); - SbxDataType t = (SbxDataType)(nOp2 & 0xffff); + SbxDataType t = static_cast(nOp2 & 0xffff); bool bFlag = pMod->IsSet( SbxFlagBits::NoModify ); pMod->SetFlag( SbxFlagBits::NoModify ); SbxVariableRef p = pMod->Find( aName, SbxClassType::Property ); @@ -4523,7 +4523,7 @@ void SbiRuntime::StepGLOBAL( sal_uInt32 nOp1, sal_uInt32 nOp2 ) StepPUBLIC_Impl( nOp1, nOp2, true ); } OUString aName( pImg->GetString( static_cast( nOp1 ) ) ); - SbxDataType t = (SbxDataType)(nOp2 & 0xffff); + SbxDataType t = static_cast(nOp2 & 0xffff); // Store module scope variables at module scope // in non vba mode these are stored at the library level :/ @@ -4581,7 +4581,7 @@ void SbiRuntime::StepFIND_G( sal_uInt32 nOp1, sal_uInt32 nOp2 ) else { // Return dummy variable - SbxDataType t = (SbxDataType) nOp2; + SbxDataType t = static_cast(nOp2); OUString aName( pImg->GetString( static_cast( nOp1 & 0x7FFF ) ) ); SbxVariable* pDummyVar = new SbxVariable( t ); @@ -4616,7 +4616,7 @@ SbxVariable* SbiRuntime::StepSTATIC_Impl( void SbiRuntime::StepSTATIC( sal_uInt32 nOp1, sal_uInt32 nOp2 ) { OUString aName( pImg->GetString( static_cast( nOp1 ) ) ); - SbxDataType t = (SbxDataType) (nOp2 & 0xffff); + SbxDataType t = static_cast(nOp2 & 0xffff); StepSTATIC_Impl( aName, t, nOp2 ); } diff --git a/basic/source/sbx/sbxarray.cxx b/basic/source/sbx/sbxarray.cxx index a082c1c523e4..8d3c5515cc8a 100644 --- a/basic/source/sbx/sbxarray.cxx +++ b/basic/source/sbx/sbxarray.cxx @@ -84,7 +84,7 @@ SbxArray::~SbxArray() SbxDataType SbxArray::GetType() const { - return (SbxDataType) ( eType | SbxARRAY ); + return static_cast( eType | SbxARRAY ); } SbxClassType SbxArray::GetClass() const diff --git a/basic/source/sbx/sbxbase.cxx b/basic/source/sbx/sbxbase.cxx index 1b5a6b8eb228..a99a26751dac 100644 --- a/basic/source/sbx/sbxbase.cxx +++ b/basic/source/sbx/sbxbase.cxx @@ -315,7 +315,7 @@ void SbxInfo::LoadData( SvStream& rStrm, sal_uInt16 nVer ) SbxFlagBits nFlags = static_cast(nFlagsTmp); if( nVer > 1 ) rStrm.ReadUInt32( nUserData ); - AddParam( aName, (SbxDataType) nType, nFlags ); + AddParam( aName, static_cast(nType), nFlags ); SbxParamInfo& p(*m_Params.back()); p.nUserData = nUserData; } diff --git a/basic/source/sbx/sbxobj.cxx b/basic/source/sbx/sbxobj.cxx index 5fa4023f9a23..e241b53c0387 100644 --- a/basic/source/sbx/sbxobj.cxx +++ b/basic/source/sbx/sbxobj.cxx @@ -215,7 +215,7 @@ SbxVariable* SbxObject::Find( const OUString& rName, SbxClassType t ) "basic.sbx", "search" << std::setw(nLvl) << " " << (t >= SbxClassType::DontCare && t <= SbxClassType::Object - ? pCls[(int)t - 1] : "Unknown class") + ? pCls[static_cast(t) - 1] : "Unknown class") << " " << rName << " in " << SbxVariable::GetName()); ++nLvl; #endif @@ -470,7 +470,7 @@ void SbxObject::Insert( SbxVariable* pVar ) "insert " << ((pVar->GetClass() >= SbxClassType::DontCare && pVar->GetClass() <= SbxClassType::Object) - ? pCls[(int)pVar->GetClass() - 1] : "Unknown class") + ? pCls[static_cast(pVar->GetClass()) - 1] : "Unknown class") << " " << aVarName << " in " << SbxVariable::GetName()); #endif } @@ -514,7 +514,7 @@ void SbxObject::QuickInsert( SbxVariable* pVar ) "insert " << ((pVar->GetClass() >= SbxClassType::DontCare && pVar->GetClass() <= SbxClassType::Object) - ? pCls[(int)pVar->GetClass() - 1] : "Unknown class") + ? pCls[static_cast(pVar->GetClass()) - 1] : "Unknown class") << " " << aVarName << " in " << SbxVariable::GetName()); #endif } diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx index 70fdfe31c512..dcf336544c3e 100644 --- a/basic/source/sbx/sbxvalue.cxx +++ b/basic/source/sbx/sbxvalue.cxx @@ -430,7 +430,7 @@ bool SbxValue::Put( const SbxValues& rVal ) { if( !p->CanWrite() ) SetError( ERRCODE_BASIC_PROP_READONLY ); - else if( p->IsFixed() || p->SetType( (SbxDataType) ( rVal.eType & 0x0FFF ) ) ) + else if( p->IsFixed() || p->SetType( static_cast( rVal.eType & 0x0FFF ) ) ) switch( rVal.eType & 0x0FFF ) { case SbxEMPTY: @@ -1525,9 +1525,9 @@ bool SbxValue::LoadData( SvStream& r, sal_uInt16 ) r.WriteInt32( aData.nLong ); break; case SbxDATE: // #49935: Save as double, otherwise an error during the read in - const_cast(this)->aData.eType = (SbxDataType)( ( nType & 0xF000 ) | SbxDOUBLE ); + const_cast(this)->aData.eType = static_cast( ( nType & 0xF000 ) | SbxDOUBLE ); write_uInt16_lenPrefixed_uInt8s_FromOUString(r, GetCoreString(), RTL_TEXTENCODING_ASCII_US); - const_cast(this)->aData.eType = (SbxDataType)nType; + const_cast(this)->aData.eType = static_cast(nType); break; case SbxSINGLE: case SbxDOUBLE: diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx index dba13358febd..17db37db5c37 100644 --- a/basic/source/sbx/sbxvar.cxx +++ b/basic/source/sbx/sbxvar.cxx @@ -489,7 +489,7 @@ bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer ) SbxValues aTmp; OUString aTmpString; OUString aVal; - aTmp.eType = aData.eType = (SbxDataType) nType; + aTmp.eType = aData.eType = static_cast(nType); aTmp.pOUString = &aVal; switch( nType ) { -- cgit