diff options
author | Noel Grandin <noel@peralex.com> | 2015-07-03 11:31:14 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2015-07-06 07:04:50 +0000 |
commit | e9c3583c2cc27fc88ee81047c236ec99dd51e8de (patch) | |
tree | b3e8394ca1ec402a31b227339366fc790124c1f8 /idl | |
parent | 89c77994d4638c86635c70535fab6508e2f3d900 (diff) |
improve the returnbyref loplugin
Change-Id: I1b510a6194282dfa4a9001d473127c5ebc8b44eb
Reviewed-on: https://gerrit.libreoffice.org/16731
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'idl')
-rw-r--r-- | idl/inc/database.hxx | 2 | ||||
-rw-r--r-- | idl/inc/lex.hxx | 2 | ||||
-rw-r--r-- | idl/source/objects/bastype.cxx | 8 | ||||
-rw-r--r-- | idl/source/objects/module.cxx | 20 | ||||
-rw-r--r-- | idl/source/objects/object.cxx | 11 | ||||
-rw-r--r-- | idl/source/objects/slot.cxx | 12 | ||||
-rw-r--r-- | idl/source/objects/types.cxx | 10 | ||||
-rw-r--r-- | idl/source/prj/database.cxx | 32 |
8 files changed, 47 insertions, 50 deletions
diff --git a/idl/inc/database.hxx b/idl/inc/database.hxx index 4a7effb53a1c..050f44ca8586 100644 --- a/idl/inc/database.hxx +++ b/idl/inc/database.hxx @@ -113,7 +113,7 @@ public: const OString& rErrorText, sal_uLong nRow = 0, sal_uLong nColumn = 0 ); void WriteError( SvTokenStream & rInStm ); - void SetError( const OString& rError, SvToken * pTok ); + void SetError( const OString& rError, SvToken& rTok ); void Push( SvMetaObject * pObj ); bool Pop( bool bOk, SvTokenStream & rInStm, sal_uInt32 nTokPos ) { diff --git a/idl/inc/lex.hxx b/idl/inc/lex.hxx index a11bd6183ea9..5f5b18908814 100644 --- a/idl/inc/lex.hxx +++ b/idl/inc/lex.hxx @@ -212,7 +212,7 @@ public: return GetToken_NextAll(); } - SvToken* GetToken() const { return &(*pCurToken); } + SvToken& GetToken() const { return *pCurToken; } bool Read( char cChar ) { diff --git a/idl/source/objects/bastype.cxx b/idl/source/objects/bastype.cxx index 5b1548526e19..ca84295c8eab 100644 --- a/idl/source/objects/bastype.cxx +++ b/idl/source/objects/bastype.cxx @@ -129,7 +129,7 @@ bool SvBOOL::ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ) bool bBraket = rInStm.Read( '(' ); if( bBraket || rInStm.Read( '=' ) ) { - pTok = rInStm.GetToken(); + pTok = &rInStm.GetToken(); if( pTok->IsBool() ) { *this = pTok->GetBool(); @@ -159,7 +159,7 @@ bool SvIdentifier::ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm bool bBraket = rInStm.Read( '(' ); if( bBraket || rInStm.Read( '=' ) ) { - pTok = rInStm.GetToken(); + pTok = &rInStm.GetToken(); if( pTok->IsIdentifier() ) { setString(pTok->GetString()); @@ -236,7 +236,7 @@ bool SvString::ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ) bool bBraket = rInStm.Read( '(' ); if( bBraket || rInStm.Read( '=' ) ) { - pTok = rInStm.GetToken(); + pTok = &rInStm.GetToken(); if( pTok->IsString() ) { setString(pTok->GetString()); @@ -281,7 +281,7 @@ bool SvUUId::ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ) bool bBraket = rInStm.Read( '(' ); if( bBraket || rInStm.Read( '=' ) ) { - pTok = rInStm.GetToken(); + pTok = &rInStm.GetToken(); if( pTok->IsString() ) { pTok = rInStm.GetToken_Next(); diff --git a/idl/source/objects/module.cxx b/idl/source/objects/module.cxx index 7246ca25a858..6bd316c73cc5 100644 --- a/idl/source/objects/module.cxx +++ b/idl/source/objects/module.cxx @@ -85,8 +85,8 @@ void SvMetaModule::ReadContextSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm ) { sal_uInt32 nTokPos = rInStm.Tell(); - if( rInStm.GetToken()->Is( SvHash_interface() ) - || rInStm.GetToken()->Is( SvHash_shell() ) ) + if( rInStm.GetToken().Is( SvHash_interface() ) + || rInStm.GetToken().Is( SvHash_shell() ) ) { SvMetaClassRef aClass = new SvMetaClass(); if( aClass->ReadSvIdl( rBase, rInStm ) ) @@ -96,7 +96,7 @@ void SvMetaModule::ReadContextSvIdl( SvIdlDataBase & rBase, rBase.GetClassList().push_back( aClass ); } } - else if( rInStm.GetToken()->Is( SvHash_enum() ) ) + else if( rInStm.GetToken().Is( SvHash_enum() ) ) { SvMetaTypeEnumRef aEnum = new SvMetaTypeEnum(); @@ -108,9 +108,9 @@ void SvMetaModule::ReadContextSvIdl( SvIdlDataBase & rBase, rBase.GetTypeList().push_back( aEnum ); } } - else if( rInStm.GetToken()->Is( SvHash_item() ) - || rInStm.GetToken()->Is( SvHash_struct() ) - || rInStm.GetToken()->Is( SvHash_typedef() ) ) + else if( rInStm.GetToken().Is( SvHash_item() ) + || rInStm.GetToken().Is( SvHash_struct() ) + || rInStm.GetToken().Is( SvHash_typedef() ) ) { SvMetaTypeRef xItem = new SvMetaType(); @@ -122,7 +122,7 @@ void SvMetaModule::ReadContextSvIdl( SvIdlDataBase & rBase, rBase.GetTypeList().push_back( xItem ); } } - else if( rInStm.GetToken()->Is( SvHash_include() ) ) + else if( rInStm.GetToken().Is( SvHash_include() ) ) { bool bOk = false; rInStm.GetToken_Next(); @@ -153,7 +153,7 @@ void SvMetaModule::ReadContextSvIdl( SvIdlDataBase & rBase, ReadContextSvIdl( rBase, aTokStm ); aTokStm.ReadDelemiter(); } - bOk = aTokStm.GetToken()->IsEof(); + bOk = aTokStm.GetToken().IsEof(); if( !bOk ) { rBase.WriteError( aTokStm ); @@ -165,14 +165,14 @@ void SvMetaModule::ReadContextSvIdl( SvIdlDataBase & rBase, { OStringBuffer aStr("cannot open file: "); aStr.append(OUStringToOString(aFullName, RTL_TEXTENCODING_UTF8)); - rBase.SetError(aStr.makeStringAndClear(), pTok); + rBase.SetError(aStr.makeStringAndClear(), *pTok); } } else { OStringBuffer aStr("cannot find file:"); aStr.append(OUStringToOString(aFullName, RTL_TEXTENCODING_UTF8)); - rBase.SetError(aStr.makeStringAndClear(), pTok); + rBase.SetError(aStr.makeStringAndClear(), *pTok); } } if( !bOk ) diff --git a/idl/source/objects/object.cxx b/idl/source/objects/object.cxx index 635f9019f288..fe9117da1979 100644 --- a/idl/source/objects/object.cxx +++ b/idl/source/objects/object.cxx @@ -72,8 +72,7 @@ void SvMetaClass::ReadContextSvIdl( SvIdlDataBase & rBase, if( xAutomationInterface.Is() ) { // set error - rBase.SetError( "Automation already set", - rInStm.GetToken() ); + rBase.SetError( "Automation already set", rInStm.GetToken() ); rBase.WriteError( rInStm ); } xAutomationInterface = pClass; @@ -89,12 +88,11 @@ void SvMetaClass::ReadContextSvIdl( SvIdlDataBase & rBase, else { // set error - rBase.SetError( "only attribute Automation allowed", - rInStm.GetToken() ); + rBase.SetError( "only attribute Automation allowed", rInStm.GetToken() ); rBase.WriteError( rInStm ); } } - pTok = rInStm.GetToken(); + pTok = &rInStm.GetToken(); if( pTok->IsString() ) { xEle->SetPrefix( pTok->GetString() ); @@ -159,8 +157,7 @@ bool SvMetaClass::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm ) if( !bOk ) { // set error - rBase.SetError( "unknown super class", - rInStm.GetToken() ); + rBase.SetError( "unknown super class", rInStm.GetToken() ); rBase.WriteError( rInStm ); } } diff --git a/idl/source/objects/slot.cxx b/idl/source/objects/slot.cxx index affaf4a04b32..8b1a2e1533d3 100644 --- a/idl/source/objects/slot.cxx +++ b/idl/source/objects/slot.cxx @@ -291,15 +291,15 @@ void SvMetaSlot::ReadAttributesSvIdl( SvIdlDataBase & rBase, { SvIdlDataBase::WriteError( "warning", OUStringToOString(rInStm.GetFileName(), RTL_TEXTENCODING_UTF8), "<Get> old style, use Readonly", - rInStm.GetToken()->GetLine(), - rInStm.GetToken()->GetColumn() ); + rInStm.GetToken().GetLine(), + rInStm.GetToken().GetColumn() ); } if( aSet.ReadSvIdl( SvHash_Set(), rInStm ) ) { SvIdlDataBase::WriteError( "warning", OUStringToOString(rInStm.GetFileName(), RTL_TEXTENCODING_UTF8), "<Set> old style, use method declaration", - rInStm.GetToken()->GetLine(), - rInStm.GetToken()->GetColumn() ); + rInStm.GetToken().GetLine(), + rInStm.GetToken().GetColumn() ); } if( aCachable.ReadSvIdl( SvHash_Cachable(), rInStm ) ) @@ -379,8 +379,8 @@ void SvMetaSlot::ReadAttributesSvIdl( SvIdlDataBase & rBase, } if( !aMethod.Is() ) { - SvToken * pTok = rInStm.GetToken(); - if( pTok->IsIdentifier() ) + SvToken& rTok = rInStm.GetToken(); + if( rTok.IsIdentifier() ) { aMethod = new SvMetaSlot(); sal_uInt32 nTokPos = rInStm.Tell(); diff --git a/idl/source/objects/types.cxx b/idl/source/objects/types.cxx index f7821911b6a0..95a04f0e50e9 100644 --- a/idl/source/objects/types.cxx +++ b/idl/source/objects/types.cxx @@ -151,8 +151,8 @@ bool SvMetaAttribute::ReadSvIdl( SvIdlDataBase & rBase, aSlotId.ReadSvIdl( rBase, rInStm ); bOk = true; - SvToken * pTok = rInStm.GetToken(); - if( bOk && pTok->IsChar() && pTok->GetChar() == '(' ) + SvToken& rTok = rInStm.GetToken(); + if( bOk && rTok.IsChar() && rTok.GetChar() == '(' ) { SvMetaTypeRef xT = new SvMetaType(); xT->SetRef( GetType() ); @@ -164,11 +164,11 @@ bool SvMetaAttribute::ReadSvIdl( SvIdlDataBase & rBase, } else { - SvToken *pTok = rInStm.GetToken(); + SvToken& rTok = rInStm.GetToken(); rBase.SetError( "unknown type of token. Each new SID needs an " "item statement in an SDI file, eg. " - "SfxVoidItem FooItem " + pTok->GetTokenAsString() + - " ... which describes the slot more fully", pTok ); + "SfxVoidItem FooItem " + rTok.GetTokenAsString() + + " ... which describes the slot more fully", rTok ); } if( !bOk ) diff --git a/idl/source/prj/database.cxx b/idl/source/prj/database.cxx index 8cdf10d34213..865332f7b0d8 100644 --- a/idl/source/prj/database.cxx +++ b/idl/source/prj/database.cxx @@ -81,15 +81,15 @@ SvMetaModule * SvIdlDataBase::GetModule( const OString& rName ) return NULL; } -void SvIdlDataBase::SetError( const OString& rError, SvToken * pTok ) +void SvIdlDataBase::SetError( const OString& rError, SvToken& rTok ) { - if( pTok->GetLine() > 10000 ) + if( rTok.GetLine() > 10000 ) aError.SetText( "line count overflow" ); - if( aError.nLine < pTok->GetLine() - || (aError.nLine == pTok->GetLine() && aError.nColumn < pTok->GetColumn()) ) + if( aError.nLine < rTok.GetLine() + || (aError.nLine == rTok.GetLine() && aError.nColumn < rTok.GetColumn()) ) { - aError = SvIdlError( pTok->GetLine(), pTok->GetColumn() ); + aError = SvIdlError( rTok.GetLine(), rTok.GetColumn() ); aError.SetText( rError ); } } @@ -159,7 +159,7 @@ bool SvIdlDataBase::ReadIdFile( const OUString & rFileName ) { OString aStr("unexpected token after define"); // set error - SetError( aStr, pTok ); + SetError( aStr, *pTok ); WriteError( aTokStm ); return false; } @@ -191,7 +191,7 @@ bool SvIdlDataBase::ReadIdFile( const OUString & rFileName ) aStr.append(pTok->GetChar()); aStr.append("'in define"); // set error - SetError( aStr.makeStringAndClear(), pTok ); + SetError( aStr.makeStringAndClear(), *pTok ); WriteError( aTokStm ); return false; } @@ -214,7 +214,7 @@ bool SvIdlDataBase::ReadIdFile( const OUString & rFileName ) if( !InsertId( aDefName, nVal ) ) { OString aStr("hash table overflow: "); - SetError( aStr, pTok ); + SetError( aStr, *pTok ); WriteError( aTokStm ); return false; } @@ -239,7 +239,7 @@ bool SvIdlDataBase::ReadIdFile( const OUString & rFileName ) { OString aStr("unexpected eof in #include"); // set error - SetError(aStr, pTok); + SetError(aStr, *pTok); WriteError( aTokStm ); return false; } @@ -249,7 +249,7 @@ bool SvIdlDataBase::ReadIdFile( const OUString & rFileName ) { OStringBuffer aStr("cannot read file: "); aStr.append(aName.makeStringAndClear()); - SetError(aStr.makeStringAndClear(), pTok); + SetError(aStr.makeStringAndClear(), *pTok); WriteError( aTokStm ); return false; } @@ -337,7 +337,7 @@ SvMetaType * SvIdlDataBase::ReadKnownType( SvTokenStream & rInStm ) } if( pType ) { - pTok = rInStm.GetToken(); + pTok = &rInStm.GetToken(); if( pTok->IsChar() ) { if( pTok->GetChar() == '&' || pTok->GetChar() == '*' ) @@ -345,7 +345,7 @@ SvMetaType * SvIdlDataBase::ReadKnownType( SvTokenStream & rInStm ) nCall0 = (pTok->GetChar() == '&') ? CALL_REFERENCE : CALL_POINTER; rInStm.GetToken_Next(); - pTok = rInStm.GetToken(); + pTok = &rInStm.GetToken(); if( pTok->GetChar() == '&' || pTok->GetChar() == '*' ) { nCall1 = (pTok->GetChar() == '&') ? CALL_REFERENCE : @@ -480,7 +480,7 @@ void SvIdlDataBase::WriteError( SvTokenStream & rInStm ) sal_uLong nRow = 0, nColumn = 0; rInStm.SeekEnd(); - SvToken *pTok = rInStm.GetToken(); + SvToken *pTok = &rInStm.GetToken(); // error position nRow = pTok->GetLine(); @@ -527,7 +527,7 @@ void SvIdlDataBase::WriteError( SvTokenStream & rInStm ) if( !pTok->IsIdentifier() ) { rInStm.GetToken_PrevAll(); - pTok = rInStm.GetToken(); + pTok = &rInStm.GetToken(); } if( pTok && pTok->IsIdentifier() ) { @@ -545,7 +545,7 @@ bool SvIdlWorkingBase::ReadSvIdl( SvTokenStream & rInStm, bool bImported, const { aPath = rPath; // only valid for this iteration bool bOk = true; - SvToken * pTok = rInStm.GetToken(); + SvToken * pTok = &rInStm.GetToken(); // only one import at the very beginning if( pTok->Is( SvHash_import() ) ) { @@ -578,7 +578,7 @@ bool SvIdlWorkingBase::ReadSvIdl( SvTokenStream & rInStm, bool bImported, const while( bOk && nBeginPos != rInStm.Tell() ) { nBeginPos = rInStm.Tell(); - pTok = rInStm.GetToken(); + pTok = &rInStm.GetToken(); if( pTok->IsEof() ) return true; if( pTok->IsEmpty() ) |