From 20276795b7a3b968fca873f29bbb971afc9fc0a8 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 22 Feb 2016 15:59:13 +0200 Subject: small cleanups in .SDI parser Change-Id: Ic7122e3ecfe2914e27945fd508199f7ec1d6bdab --- idl/inc/database.hxx | 5 +++-- idl/source/objects/slot.cxx | 2 +- idl/source/prj/database.cxx | 32 +++++++++++++++++++------------- idl/source/prj/parser.cxx | 13 +++++++------ 4 files changed, 30 insertions(+), 22 deletions(-) (limited to 'idl') diff --git a/idl/inc/database.hxx b/idl/inc/database.hxx index 71e77b4f2b71..eb43e5f54281 100644 --- a/idl/inc/database.hxx +++ b/idl/inc/database.hxx @@ -123,7 +123,7 @@ public: sal_uInt32 GetUniqueId() { return ++nUniqueId; } bool FindId( const OString& rIdName, sal_uLong * pVal ); bool InsertId( const OString& rIdName, sal_uLong nVal ); - bool ReadIdFile( const OUString & rFileName ); + bool ReadIdFile( const OString& rFileName ); SvMetaType * FindType( const OString& rName ); static SvMetaType * FindType( const SvMetaType *, SvRefMemberList& ); @@ -131,8 +131,9 @@ public: SvMetaType * ReadKnownType( SvTokenStream & rInStm ); SvMetaAttribute * ReadKnownAttr( SvTokenStream & rInStm, SvMetaType * pType = nullptr ); - SvMetaAttribute * SearchKnownAttr( const SvIdentifier& ); + SvMetaAttribute * FindKnownAttr( const SvIdentifier& ); SvMetaClass * ReadKnownClass( SvTokenStream & rInStm ); + SvMetaClass * FindKnownClass( const OString& aName ); void AddDepFile(OUString const& rFileName); void WriteDepFile(SvFileStream & rStream, OUString const& rTarget); }; diff --git a/idl/source/objects/slot.cxx b/idl/source/objects/slot.cxx index 35920f92f514..2b2e23c55f0e 100644 --- a/idl/source/objects/slot.cxx +++ b/idl/source/objects/slot.cxx @@ -377,7 +377,7 @@ bool SvMetaSlot::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm ) { bOk = SvMetaAttribute::ReadSvIdl( rBase, rInStm ); - SvMetaAttribute *pAttr2 = rBase.SearchKnownAttr( GetSlotId() ); + SvMetaAttribute *pAttr2 = rBase.FindKnownAttr( GetSlotId() ); if( pAttr2 ) { // for testing purposes: reference in case of complete definition diff --git a/idl/source/prj/database.cxx b/idl/source/prj/database.cxx index 00f2ab18b9c1..4926b59869fa 100644 --- a/idl/source/prj/database.cxx +++ b/idl/source/prj/database.cxx @@ -139,8 +139,9 @@ bool SvIdlDataBase::InsertId( const OString& rIdName, sal_uLong nVal ) return false; } -bool SvIdlDataBase::ReadIdFile( const OUString & rFileName ) +bool SvIdlDataBase::ReadIdFile( const OString& rOFileName ) { + OUString rFileName = OStringToOUString(rOFileName, RTL_TEXTENCODING_ASCII_US); OUString aFullName; osl::File::searchFileURL( rFileName, GetPath(), aFullName); osl::FileBase::getSystemPathFromFileURL( aFullName, aFullName ); @@ -236,8 +237,7 @@ bool SvIdlDataBase::ReadIdFile( const OUString & rFileName ) throw SvParseException("unexpected eof in #include", rTok); } } - if (!ReadIdFile(OStringToOUString(aName.toString(), - RTL_TEXTENCODING_ASCII_US))) + if (!ReadIdFile(aName.toString())) { throw SvParseException("cannot read file: " + aName, rTok); } @@ -328,10 +328,7 @@ SvMetaAttribute * SvIdlDataBase::ReadKnownAttr return nullptr; } -SvMetaAttribute* SvIdlDataBase::SearchKnownAttr -( - const SvIdentifier& rId -) +SvMetaAttribute* SvIdlDataBase::FindKnownAttr( const SvIdentifier& rId ) { sal_uLong n; if( FindId( rId.getString(), &n ) ) @@ -353,17 +350,26 @@ SvMetaClass * SvIdlDataBase::ReadKnownClass( SvTokenStream & rInStm ) SvToken& rTok = rInStm.GetToken_Next(); if( rTok.IsIdentifier() ) - for( sal_uLong n = 0; n < aClassList.size(); n++ ) - { - SvMetaClass * pClass = aClassList[n]; - if( pClass->GetName().equals(rTok.GetString()) ) - return pClass; - } + { + SvMetaClass* p = FindKnownClass(rTok.GetString()); + if (p) + return p; + } rInStm.Seek( nTokPos ); return nullptr; } +SvMetaClass * SvIdlDataBase::FindKnownClass( const OString& aName ) +{ + for( sal_uLong n = 0; n < aClassList.size(); n++ ) + { + SvMetaClass * pClass = aClassList[n]; + if( pClass->GetName() == aName ) + return pClass; + } + return nullptr; +} void SvIdlDataBase::Write(const OString& rText) { if( nVerbosity != 0 ) diff --git a/idl/source/prj/parser.cxx b/idl/source/prj/parser.cxx index fe1e2b93e511..b8899313c586 100644 --- a/idl/source/prj/parser.cxx +++ b/idl/source/prj/parser.cxx @@ -47,8 +47,8 @@ void SvIdlParser::ReadSvIdl( bool bImported, const OUString & rPath ) void SvIdlParser::ReadModuleHeader(SvMetaModule& rModule) { OString aName = ReadIdentifier(); - rBase.Push( &rModule ); // onto the context stack rModule.SetName( aName ); + rBase.Push( &rModule ); // onto the context stack ReadModuleBody(rModule); rBase.GetStack().pop_back(); // remove from stack } @@ -62,7 +62,7 @@ void SvIdlParser::ReadModuleBody(SvMetaModule& rModule) OString aSlotIdFile; if( !ReadStringSvIdl( SvHash_SlotIdFile(), rInStm, aSlotIdFile ) ) break; - if( !rBase.ReadIdFile( OStringToOUString(aSlotIdFile, RTL_TEXTENCODING_ASCII_US)) ) + if( !rBase.ReadIdFile( aSlotIdFile ) ) { throw SvParseException( rInStm, "cannot read file: " + aSlotIdFile ); } @@ -368,7 +368,7 @@ bool SvIdlParser::ReadInterfaceOrShellSlot(SvMetaSlot& rSlot) else { bOk = rSlot.SvMetaAttribute::ReadSvIdl( rBase, rInStm ); - SvMetaAttribute *pAttr2 = rBase.SearchKnownAttr( rSlot.GetSlotId() ); + SvMetaAttribute *pAttr2 = rBase.FindKnownAttr( rSlot.GetSlotId() ); if( pAttr2 ) { SvMetaSlot * pKnownSlot = dynamic_cast( pAttr2 ); @@ -419,7 +419,7 @@ bool SvIdlParser::ReadInterfaceOrShellMethodOrAttribute( SvMetaAttribute& rAttr } Read( ')' ); rAttr.aType->SetType( MetaTypeType::Method ); - } + } if( bOk && ReadIf( '[' ) ) { Read( ']' ); @@ -432,7 +432,8 @@ bool SvIdlParser::ReadInterfaceOrShellMethodOrAttribute( SvMetaAttribute& rAttr SvMetaClass * SvIdlParser::ReadKnownClass() { - SvMetaClass* pClass = rBase.ReadKnownClass( rInStm ); + OString aName(ReadIdentifier()); + SvMetaClass* pClass = rBase.FindKnownClass( aName ); if( !pClass ) throw SvParseException( rInStm, "unknown class" ); return pClass; @@ -443,7 +444,7 @@ SvMetaType * SvIdlParser::ReadKnownType() OString aName = ReadIdentifier(); for( const auto& aType : rBase.GetTypeList() ) { - if( aType->GetName().equals(aName) ) + if( aType->GetName() == aName ) { return aType; } -- cgit v1.2.3