idl/inc/basobj.hxx | 36 ++++++++++-------------------------- idl/inc/database.hxx | 16 ++++++++-------- idl/inc/object.hxx | 11 ++--------- idl/inc/types.hxx | 5 ++--- idl/source/objects/module.cxx | 4 ++-- idl/source/objects/object.cxx | 41 +++++++++++++++++------------------------ idl/source/objects/slot.cxx | 38 +++++++++++++++++++------------------- idl/source/prj/database.cxx | 22 +++++++++++----------- 8 files changed, 71 insertions(+), 102 deletions(-)
New commits: commit 3c14d8fd4c0ca3fb034a137436d0b0e584e2ab2e Author: Noel Grandin <[email protected]> Date: Tue Feb 9 09:37:20 2016 +0200 rename aAttrList to aSlotList since that is a more accurate reflection of it's use Change-Id: Ic5933e5cdeefac7363975a5767be3ee5db99bd56 diff --git a/idl/inc/database.hxx b/idl/inc/database.hxx index e0bb7e2..680f569 100644 --- a/idl/inc/database.hxx +++ b/idl/inc/database.hxx @@ -65,7 +65,7 @@ class SvIdlDataBase SvRefMemberList<SvMetaType *> aTypeList; SvRefMemberList<SvMetaClass *> aClassList; SvRefMemberList<SvMetaModule *> aModuleList; - SvRefMemberList<SvMetaAttribute *> aAttrList; + SvRefMemberList<SvMetaSlot *> aSlotList; SvRefMemberList<SvMetaType *> aTmpTypeList; // not persistent SvRefMemberList<SvMetaObject *> aContextStack; @@ -84,10 +84,10 @@ public: explicit SvIdlDataBase( const SvCommand& rCmd ); ~SvIdlDataBase(); - SvRefMemberList<SvMetaAttribute *>& GetAttrList() { return aAttrList; } - SvRefMemberList<SvMetaType *>& GetTypeList(); - SvRefMemberList<SvMetaClass *>& GetClassList() { return aClassList; } - SvRefMemberList<SvMetaModule *>& GetModuleList() { return aModuleList; } + SvRefMemberList<SvMetaSlot *>& GetSlotList() { return aSlotList; } + SvRefMemberList<SvMetaType *>& GetTypeList(); + SvRefMemberList<SvMetaClass *>& GetClassList() { return aClassList; } + SvRefMemberList<SvMetaModule *>& GetModuleList() { return aModuleList; } // list of used types while writing SvRefMemberList<SvMetaType *> aUsedTypes; @@ -96,7 +96,7 @@ public: void StartNewFile( const OUString& rName ); void SetExportFile( const OUString& rName ) { aExportFile = rName; } - void AppendAttr( SvMetaAttribute *pSlot ); + void AppendSlot( SvMetaSlot *pSlot ); const SvIdlError & GetError() const { return aError; } void SetError( const SvIdlError & r ) { aError = r; } diff --git a/idl/source/objects/module.cxx b/idl/source/objects/module.cxx index 524a6d7..ad339b7 100644 --- a/idl/source/objects/module.cxx +++ b/idl/source/objects/module.cxx @@ -154,7 +154,7 @@ void SvMetaModule::ReadContextSvIdl( SvIdlDataBase & rBase, if( xSlot->Test( rBase, rInStm ) ) { // announce globally - rBase.AppendAttr( xSlot ); + rBase.AppendSlot( xSlot ); } } } diff --git a/idl/source/objects/slot.cxx b/idl/source/objects/slot.cxx index 06b0695..4717f5d 100644 --- a/idl/source/objects/slot.cxx +++ b/idl/source/objects/slot.cxx @@ -502,9 +502,9 @@ void SvMetaSlot::Insert( SvSlotElementList& rList, const OString& rPrefix, OString aSId = aBuf.makeStringAndClear(); xEnumSlot = nullptr; - for( m=0; m<rBase.GetAttrList().size(); m++ ) + for( m=0; m<rBase.GetSlotList().size(); m++ ) { - SvMetaAttribute * pAttr = rBase.GetAttrList()[m]; + SvMetaSlot * pAttr = rBase.GetSlotList()[m]; if (aSId.equals(pAttr->GetSlotId().getString())) { SvMetaSlot& rSlot = dynamic_cast<SvMetaSlot&>(*pAttr); @@ -513,7 +513,7 @@ void SvMetaSlot::Insert( SvSlotElementList& rList, const OString& rPrefix, } } - if ( m == rBase.GetAttrList().size() ) + if ( m == rBase.GetSlotList().size() ) { OSL_FAIL("Invalid EnumSlot!"); xEnumSlot = Clone(); diff --git a/idl/source/prj/database.cxx b/idl/source/prj/database.cxx index 52f3751..865ad47 100644 --- a/idl/source/prj/database.cxx +++ b/idl/source/prj/database.cxx @@ -332,11 +332,11 @@ SvMetaAttribute * SvIdlDataBase::ReadKnownAttr sal_uLong n; if( FindId( pTok->GetString(), &n ) ) { - for( sal_uLong i = 0; i < aAttrList.size(); i++ ) + for( sal_uLong i = 0; i < aSlotList.size(); i++ ) { - SvMetaAttribute * pAttr = aAttrList[i]; - if( pAttr->GetSlotId().getString().equals(pTok->GetString()) ) - return pAttr; + SvMetaSlot * pSlot = aSlotList[i]; + if( pSlot->GetSlotId().getString().equals(pTok->GetString()) ) + return pSlot; } } @@ -358,11 +358,11 @@ SvMetaAttribute* SvIdlDataBase::SearchKnownAttr sal_uLong n; if( FindId( rId.getString(), &n ) ) { - for( sal_uLong i = 0; i < aAttrList.size(); i++ ) + for( sal_uLong i = 0; i < aSlotList.size(); i++ ) { - SvMetaAttribute * pAttr = aAttrList[i]; - if( pAttr->GetSlotId().getString() == rId.getString() ) - return pAttr; + SvMetaSlot * pSlot = aSlotList[i]; + if( pSlot->GetSlotId().getString() == rId.getString() ) + return pSlot; } } @@ -572,9 +572,9 @@ void SvIdlDataBase::StartNewFile( const OUString& rName ) assert ( !bExport ); } -void SvIdlDataBase::AppendAttr( SvMetaAttribute *pAttr ) +void SvIdlDataBase::AppendSlot( SvMetaSlot *pSlot ) { - aAttrList.push_back( pAttr ); + aSlotList.push_back( pSlot ); assert ( !bExport ); } commit cfa4ba4b2b7138f7b95fb725866ed37155ccceee Author: Noel Grandin <[email protected]> Date: Tue Feb 9 09:08:35 2016 +0200 simplify SvMetaObjectMemberStack Change-Id: I7c1ba85fcb21925f5e912fa48207411e4fc1fbb4 diff --git a/idl/inc/basobj.hxx b/idl/inc/basobj.hxx index dbec6b4..af85f47 100644 --- a/idl/inc/basobj.hxx +++ b/idl/inc/basobj.hxx @@ -107,24 +107,6 @@ public: virtual bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); }; -class SvMetaObjectMemberStack -{ - SvRefMemberList<SvMetaObject *> aList; -public: - SvMetaObjectMemberStack() {;} - - void Push( SvMetaObject * pObj ) - { aList.push_back( pObj ); } - void Pop() { aList.pop_back(); } - SvMetaObject * Get( std::function<bool ( const SvMetaObject* )> isSvMetaObject ) - { - for( SvRefMemberList<SvMetaObject *>::reverse_iterator it = aList.rbegin(); it != aList.rend(); ++it ) - if( isSvMetaObject(*it) ) - return *it; - return nullptr; - } -}; - class SvMetaReference : public SvMetaObject { protected: diff --git a/idl/inc/database.hxx b/idl/inc/database.hxx index c9259bf..e0bb7e2 100644 --- a/idl/inc/database.hxx +++ b/idl/inc/database.hxx @@ -67,10 +67,10 @@ class SvIdlDataBase SvRefMemberList<SvMetaModule *> aModuleList; SvRefMemberList<SvMetaAttribute *> aAttrList; SvRefMemberList<SvMetaType *> aTmpTypeList; // not persistent + SvRefMemberList<SvMetaObject *> aContextStack; protected: ::std::set< OUString > m_DepFiles; - SvMetaObjectMemberStack aContextStack; OUString aPath; SvIdlError aError; void WriteReset() @@ -102,7 +102,7 @@ public: { aError = r; } const OUString & GetPath() const { return aPath; } - SvMetaObjectMemberStack & GetStack() { return aContextStack; } + SvRefMemberList<SvMetaObject *>& GetStack() { return aContextStack; } void Write(const OString& rText); static void WriteError(const OString& rErrWrn, diff --git a/idl/source/objects/module.cxx b/idl/source/objects/module.cxx index 4324215..524a6d7 100644 --- a/idl/source/objects/module.cxx +++ b/idl/source/objects/module.cxx @@ -177,7 +177,7 @@ bool SvMetaModule::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm ) // set pointer to itself bOk = SvMetaObject::ReadSvIdl( rBase, rInStm ); } - rBase.GetStack().Pop(); // remove from stack + rBase.GetStack().pop_back(); // remove from stack } if( !bOk ) rInStm.Seek( nTokPos ); diff --git a/idl/source/prj/database.cxx b/idl/source/prj/database.cxx index a7f584f..52f3751 100644 --- a/idl/source/prj/database.cxx +++ b/idl/source/prj/database.cxx @@ -87,7 +87,7 @@ void SvIdlDataBase::SetError( const OString& rError, SvToken& rTok ) void SvIdlDataBase::Push( SvMetaObject * pObj ) { - GetStack().Push( pObj ); + GetStack().push_back( pObj ); } bool SvIdlDataBase::FindId( const OString& rIdName, sal_uLong * pVal ) commit 8bbcbcec91f723a3839bd80aa1d28e0420dfd1e6 Author: Noel Grandin <[email protected]> Date: Tue Feb 9 09:05:07 2016 +0200 simplify SvSlotElement Change-Id: I4699dca35c0197944df97005ff032e1d16139e5f diff --git a/idl/inc/basobj.hxx b/idl/inc/basobj.hxx index a2aa82a..dbec6b4 100644 --- a/idl/inc/basobj.hxx +++ b/idl/inc/basobj.hxx @@ -49,8 +49,8 @@ public: using typename base_t::reverse_iterator; using base_t::empty; - inline ~SvRefMemberList() { clear(); } - inline void clear() + ~SvRefMemberList() { clear(); } + void clear() { for( typename base_t::const_iterator it = base_t::begin(); it != base_t::end(); ++it ) { @@ -61,13 +61,19 @@ public: base_t::clear(); } - inline void push_back( T p ) + void push_back( T p ) { base_t::push_back( p ); p->AddFirstRef(); } - inline T pop_back() + void insert( typename base_t::iterator it, T p ) + { + base_t::insert( it, p ); + p->AddFirstRef(); + } + + T pop_back() { T p = base_t::back(); base_t::pop_back(); diff --git a/idl/inc/object.hxx b/idl/inc/object.hxx index 9859a3a..3967fa9 100644 --- a/idl/inc/object.hxx +++ b/idl/inc/object.hxx @@ -24,13 +24,6 @@ #include <slot.hxx> #include <vector> -struct SvSlotElement -{ - tools::SvRef<SvMetaSlot> xSlot; - SvSlotElement( SvMetaSlot * pS ) : xSlot( pS ) {} -}; -typedef std::vector< SvSlotElement* > SvSlotElementList; - class SvMetaClass; typedef ::std::vector< SvMetaClass* > SvMetaClassList; diff --git a/idl/inc/types.hxx b/idl/inc/types.hxx index ae229af..34f12d7 100644 --- a/idl/inc/types.hxx +++ b/idl/inc/types.hxx @@ -24,10 +24,9 @@ #include <tools/ref.hxx> #include <basobj.hxx> -struct SvSlotElement; -typedef std::vector< SvSlotElement* > SvSlotElementList; - class SvMetaType; +class SvMetaSlot; +typedef SvRefMemberList< SvMetaSlot* > SvSlotElementList; class SvMetaAttribute : public SvMetaReference { diff --git a/idl/source/objects/object.cxx b/idl/source/objects/object.cxx index eedc6eb..4f29c94 100644 --- a/idl/source/objects/object.cxx +++ b/idl/source/objects/object.cxx @@ -201,8 +201,7 @@ sal_uInt16 SvMetaClass::WriteSlotParamArray( SvIdlDataBase & rBase, sal_uInt16 nCount = 0; for ( size_t i = 0, n = rSlotList.size(); i < n; ++i ) { - SvSlotElement *pEle = rSlotList[ i ]; - SvMetaSlot *pAttr = pEle->xSlot; + SvMetaSlot *pAttr = rSlotList[ i ]; nCount = nCount + pAttr->WriteSlotParamArray( rBase, rOutStm ); } @@ -217,8 +216,7 @@ sal_uInt16 SvMetaClass::WriteSlots( const OString& rShellName, sal_uInt16 nSCount = 0; for ( size_t i = 0, n = rSlotList.size(); i < n; ++i ) { - SvSlotElement * pEle = rSlotList[ i ]; - SvMetaSlot * pAttr = pEle->xSlot; + SvMetaSlot * pAttr = rSlotList[ i ]; nSCount = nSCount + pAttr->WriteSlotMap( rShellName, nCount + nSCount, rSlotList, i, rBase, rOutStm ); @@ -319,8 +317,7 @@ void SvMetaClass::WriteSlotStubs( const OString& rShellName, // write all attributes for ( size_t i = 0, n = rSlotList.size(); i < n; ++i ) { - SvSlotElement *pEle = rSlotList[ i ]; - SvMetaSlot *pAttr = pEle->xSlot; + SvMetaSlot *pAttr = rSlotList[ i ]; pAttr->WriteSlotStubs( rShellName, rList, rOutStm ); } } @@ -350,8 +347,7 @@ void SvMetaClass::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ) InsertSlots(aSlotList, aSuperList, classList, OString(), rBase); for ( size_t i = 0, n = aSlotList.size(); i < n; ++i ) { - SvSlotElement *pEle = aSlotList[ i ]; - SvMetaSlot *pSlot = pEle->xSlot; + SvMetaSlot *pSlot = aSlotList[ i ]; pSlot->SetListPos( i ); } @@ -402,13 +398,10 @@ void SvMetaClass::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ) for( size_t i = 0, n = aSlotList.size(); i < n; ++i ) { - SvSlotElement* pEle = aSlotList[ i ]; - SvMetaSlot* pAttr = pEle->xSlot; + SvMetaSlot* pAttr = aSlotList[ i ]; pAttr->ResetSlotPointer(); } - for( size_t i = 0, n = aSlotList.size(); i < n; ++i ) - delete aSlotList[ i ]; aSlotList.clear(); } diff --git a/idl/source/objects/slot.cxx b/idl/source/objects/slot.cxx index 5ed8b11..06b0695 100644 --- a/idl/source/objects/slot.cxx +++ b/idl/source/objects/slot.cxx @@ -423,7 +423,7 @@ void SvMetaSlot::Insert( SvSlotElementList& rList, const OString& rPrefix, if ( !nListCount ) nPos = 0; else if ( nListCount == 1 ) - nPos = rList[ 0 ]->xSlot->GetSlotId().GetValue() >= nId ? 0 : 1; + nPos = rList[ 0 ]->GetSlotId().GetValue() >= nId ? 0 : 1; else { sal_uInt16 nMid = 0, nLow = 0; @@ -433,7 +433,7 @@ void SvMetaSlot::Insert( SvSlotElementList& rList, const OString& rPrefix, { nMid = (nLow + nHigh) >> 1; DBG_ASSERT( nMid < nListCount, "bsearch ist buggy" ); - int nDiff = (int) nId - (int) rList[ nMid ]->xSlot->GetSlotId().GetValue(); + int nDiff = (int) nId - (int) rList[ nMid ]->GetSlotId().GetValue(); if ( nDiff < 0) { if ( nMid == 0 ) @@ -457,24 +457,24 @@ void SvMetaSlot::Insert( SvSlotElementList& rList, const OString& rPrefix, DBG_ASSERT( nPos <= nListCount, "nPos too large" ); DBG_ASSERT( nPos == nListCount || nId <= - (sal_uInt16) rList[ nPos ]->xSlot->GetSlotId().GetValue(), + (sal_uInt16) rList[ nPos ]->GetSlotId().GetValue(), "Successor has lower SlotId" ); DBG_ASSERT( nPos == 0 || nId > - (sal_uInt16) rList[ nPos-1 ]->xSlot->GetSlotId().GetValue(), + (sal_uInt16) rList[ nPos-1 ]->GetSlotId().GetValue(), "Predecessor has higher SlotId" ); DBG_ASSERT( nPos+1 >= nListCount || nId < - (sal_uInt16) rList[ nPos+1 ]->xSlot->GetSlotId().GetValue(), + (sal_uInt16) rList[ nPos+1 ]->GetSlotId().GetValue(), "Successor has lower SlotId" ); if ( nPos < rList.size() ) { SvSlotElementList::iterator it = rList.begin(); std::advance( it, nPos ); - rList.insert( it, new SvSlotElement( this ) ); + rList.insert( it, this ); } else { - rList.push_back( new SvSlotElement( this ) ); + rList.push_back( this ); } // iron out EnumSlots @@ -547,14 +547,14 @@ void SvMetaSlot::Insert( SvSlotElementList& rList, const OString& rPrefix, // concatenate slaves among themselves xEnumSlot = pFirstEnumSlot; size_t i = 0; - SvSlotElement *pEle; + SvMetaSlot* pEle; do { pEle = ( ++i < rList.size() ) ? rList[ i ] : nullptr; - if ( pEle && pEle->xSlot->pLinkedSlot == this ) + if ( pEle && pEle->pLinkedSlot == this ) { - xEnumSlot->pNextSlot = pEle->xSlot; - xEnumSlot = pEle->xSlot; + xEnumSlot->pNextSlot = pEle; + xEnumSlot = pEle; } } while ( pEle ); @@ -685,8 +685,8 @@ void SvMetaSlot::WriteSlot( const OString& rShellName, sal_uInt16 nCount, // look for the next slot with the same StateMethod like me // the slotlist is set to the current slot size_t i = nStart; - SvSlotElement* pEle = ( ++i < rSlotList.size() ) ? rSlotList[ i ] : nullptr; - pNextSlot = pEle ? &pEle->xSlot : nullptr; + SvMetaSlot* pEle = ( ++i < rSlotList.size() ) ? rSlotList[ i ] : nullptr; + pNextSlot = pEle; while ( pNextSlot ) { if ( !pNextSlot->pNextSlot && @@ -695,7 +695,7 @@ void SvMetaSlot::WriteSlot( const OString& rShellName, sal_uInt16 nCount, break; } pEle = ( ++i < rSlotList.size() ) ? rSlotList[ i ] : nullptr; - pNextSlot = pEle ? &pEle->xSlot : nullptr; + pNextSlot = pEle; } if ( !pNextSlot ) @@ -704,14 +704,14 @@ void SvMetaSlot::WriteSlot( const OString& rShellName, sal_uInt16 nCount, // So I search for the first slot with it (could be myself). i = 0; pEle = rSlotList.empty() ? nullptr : rSlotList[ i ]; - pNextSlot = pEle ? &pEle->xSlot : nullptr; + pNextSlot = pEle; while ( pNextSlot != this ) { if ( !pNextSlot->pEnumValue && pNextSlot->GetStateMethod() == GetStateMethod() ) break; pEle = ( ++i < rSlotList.size() ) ? rSlotList[ i ] : nullptr; - pNextSlot = pEle ? &pEle->xSlot : nullptr; + pNextSlot = pEle; } } commit 8d6e4896d9485aec0def2d23b90d02c750ffce01 Author: Noel Grandin <[email protected]> Date: Tue Feb 9 08:48:34 2016 +0200 simplify SvClassElement no need for it to be ref-counted Change-Id: I663266c9f59930b1f5bc53f1f27b594dbbc08b46 diff --git a/idl/inc/object.hxx b/idl/inc/object.hxx index c4c45f02..9859a3a 100644 --- a/idl/inc/object.hxx +++ b/idl/inc/object.hxx @@ -34,7 +34,7 @@ typedef std::vector< SvSlotElement* > SvSlotElementList; class SvMetaClass; typedef ::std::vector< SvMetaClass* > SvMetaClassList; -class SvClassElement : public SvRttiBase +class SvClassElement { OString aPrefix; tools::SvRef<SvMetaClass> xClass; @@ -56,7 +56,7 @@ public: class SvMetaClass : public SvMetaType { SvRefMemberList<SvMetaAttribute *> aAttrList; - SvRefMemberList<SvClassElement *> aClassList; + std::vector<SvClassElement> aClassElementList; tools::SvRef<SvMetaClass> aSuperClass; bool TestAttribute( SvIdlDataBase & rBase, SvTokenStream & rInStm, diff --git a/idl/source/objects/object.cxx b/idl/source/objects/object.cxx index bb39019..eedc6eb 100644 --- a/idl/source/objects/object.cxx +++ b/idl/source/objects/object.cxx @@ -50,14 +50,14 @@ void SvMetaClass::ReadContextSvIdl( SvIdlDataBase & rBase, SvMetaClass * pClass = rBase.ReadKnownClass( rInStm ); if( pClass ) { - tools::SvRef<SvClassElement> xEle = new SvClassElement(); - xEle->SetClass( pClass ); - aClassList.push_back( xEle ); + SvClassElement xEle; + xEle.SetClass( pClass ); + aClassElementList.push_back( xEle ); pTok = &rInStm.GetToken(); if( pTok->IsString() ) { - xEle->SetPrefix( pTok->GetString() ); + xEle.SetPrefix( pTok->GetString() ); rInStm.GetToken_Next(); } return; @@ -267,14 +267,14 @@ void SvMetaClass::InsertSlots( SvSlotElementList& rList, std::vector<sal_uLong>& // Write all attributes of the imported classes, as long as they have // not already been imported by the superclass. - for( n = 0; n < aClassList.size(); n++ ) + for( n = 0; n < aClassElementList.size(); n++ ) { - SvClassElement * pEle = aClassList[n]; - SvMetaClass * pCl = pEle->GetClass(); + SvClassElement& rElement = aClassElementList[n]; + SvMetaClass * pCl = rElement.GetClass(); OStringBuffer rPre(rPrefix); - if( !rPre.isEmpty() && !pEle->GetPrefix().isEmpty() ) + if( !rPre.isEmpty() && !rElement.GetPrefix().isEmpty() ) rPre.append('.'); - rPre.append(pEle->GetPrefix()); + rPre.append(rElement.GetPrefix()); // first of all write direct imported interfaces pCl->InsertSlots( rList, rSuperList, rClassList, @@ -298,10 +298,10 @@ void SvMetaClass::FillClasses( SvMetaClassList & rList ) rList.push_back( this ); // my imports - for( size_t n = 0; n < aClassList.size(); n++ ) + for( size_t n = 0; n < aClassElementList.size(); n++ ) { - SvClassElement * pEle = aClassList[n]; - SvMetaClass * pCl = pEle->GetClass(); + SvClassElement& rElement = aClassElementList[n]; + SvMetaClass * pCl = rElement.GetClass(); pCl->FillClasses( rList ); } commit e6693def6456878b1bb80678204835d3135f107b Author: Noel Grandin <[email protected]> Date: Tue Feb 9 08:22:01 2016 +0200 unused template method Change-Id: I4a91f42d2b370ca15958d01057e5e2a48d0342b3 diff --git a/idl/inc/basobj.hxx b/idl/inc/basobj.hxx index bcc3f0a..a2aa82a 100644 --- a/idl/inc/basobj.hxx +++ b/idl/inc/basobj.hxx @@ -100,10 +100,6 @@ public: virtual bool Test( SvIdlDataBase &, SvTokenStream & rInStm ); virtual bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); }; -template<class T> bool checkSvMetaObject(const SvMetaObject* pObject) -{ - return dynamic_cast<const T*>(pObject) != nullptr; -} class SvMetaObjectMemberStack { _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
