summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2012-06-10 12:47:02 +0200
committerMichael Stahl <mstahl@redhat.com>2012-06-12 23:25:11 +0200
commit2110397670695991b3a5cd28a15ba0ffd2a3a611 (patch)
tree55baaa88f31e7b8220ec04255d9046393c62386a /basic
parent56366fa094fdeae8f62b55e0ba7b1ef06a582a84 (diff)
Convert SV_DECL_PTRARR_DEL(SbiSymbols) to std::vector
For reasons I don't understand, the compiler would get uncopy if I tried to declare the destructor in the header file. Change-Id: I67fa7941da2f0ee08ae10bf350fb1f3bf1397410
Diffstat (limited to 'basic')
-rw-r--r--basic/source/comp/symtbl.cxx47
-rw-r--r--basic/source/inc/symtbl.hxx10
2 files changed, 32 insertions, 25 deletions
diff --git a/basic/source/comp/symtbl.cxx b/basic/source/comp/symtbl.cxx
index 8144e76d13e2..7452033c7ab3 100644
--- a/basic/source/comp/symtbl.cxx
+++ b/basic/source/comp/symtbl.cxx
@@ -32,8 +32,6 @@
#include <string.h>
#include <ctype.h>
-SV_IMPL_PTRARR(SbiSymbols,SbiSymDef*)
-
// All symbol names are laid down int the symbol-pool's stringpool, so that
// all symbols are handled in the same case. On saving the code-image, the
// global stringpool with the respective symbols is also saved.
@@ -118,35 +116,33 @@ SbiSymDef* SbiSymPool::First()
SbiSymDef* SbiSymPool::Next()
{
- if( ++nCur >= aData.Count() )
+ if( ++nCur >= aData.size() )
return NULL;
else
- return aData.GetObject( nCur );
+ return aData[ nCur ];
}
SbiSymDef* SbiSymPool::AddSym( const String& rName )
{
SbiSymDef* p = new SbiSymDef( rName );
- p->nPos = aData.Count();
+ p->nPos = aData.size();
p->nId = rStrings.Add( rName );
p->nProcId = nProcId;
p->pIn = this;
- const SbiSymDef* q = p;
- aData.Insert( q, q->nPos );
+ aData.insert( aData.begin() + p->nPos, p );
return p;
}
SbiProcDef* SbiSymPool::AddProc( const String& rName )
{
SbiProcDef* p = new SbiProcDef( pParser, rName );
- p->nPos = aData.Count();
+ p->nPos = aData.size();
p->nId = rStrings.Add( rName );
// procs are always local
p->nProcId = 0;
p->pIn = this;
- const SbiSymDef* q = p;
- aData.Insert( q, q->nPos );
+ aData.insert( aData.begin() + p->nPos, p );
return p;
}
@@ -165,7 +161,7 @@ void SbiSymPool::Add( SbiSymDef* pDef )
return;
}
- pDef->nPos = aData.Count();
+ pDef->nPos = aData.size();
if( !pDef->nId )
{
// A unique name must be created in the string pool
@@ -183,18 +179,17 @@ void SbiSymPool::Add( SbiSymDef* pDef )
if( !pDef->GetProcDef() )
pDef->nProcId = nProcId;
pDef->pIn = this;
- const SbiSymDef* q = pDef;
- aData.Insert( q, q->nPos );
+ aData.insert( aData.begin() + pDef->nPos, pDef );
}
}
SbiSymDef* SbiSymPool::Find( const String& rName ) const
{
- sal_uInt16 nCount = aData.Count();
+ sal_uInt16 nCount = aData.size();
for( sal_uInt16 i = 0; i < nCount; i++ )
{
- SbiSymDef* p = aData.GetObject( nCount - i - 1 );
+ SbiSymDef* p = aData[ nCount - i - 1 ];
if( ( !p->nProcId || ( p->nProcId == nProcId ) )
&& ( p->aName.EqualsIgnoreCaseAscii( rName ) ) )
return p;
@@ -208,9 +203,9 @@ SbiSymDef* SbiSymPool::Find( const String& rName ) const
SbiSymDef* SbiSymPool::FindId( sal_uInt16 n ) const
{
- for( sal_uInt16 i = 0; i < aData.Count(); i++ )
+ for( sal_uInt16 i = 0; i < aData.size(); i++ )
{
- SbiSymDef* p = aData.GetObject( i );
+ SbiSymDef* p = aData[ i ];
if( p->nId == n && ( !p->nProcId || ( p->nProcId == nProcId ) ) )
return p;
}
@@ -224,10 +219,10 @@ SbiSymDef* SbiSymPool::FindId( sal_uInt16 n ) const
SbiSymDef* SbiSymPool::Get( sal_uInt16 n ) const
{
- if( n >= aData.Count() )
+ if( n >= aData.size() )
return NULL;
else
- return aData.GetObject( n );
+ return aData[ n ];
}
sal_uInt32 SbiSymPool::Define( const String& rName )
@@ -255,9 +250,9 @@ sal_uInt32 SbiSymPool::Reference( const String& rName )
void SbiSymPool::CheckRefs()
{
- for( sal_uInt16 i = 0; i < aData.Count(); i++ )
+ for( sal_uInt16 i = 0; i < aData.size(); i++ )
{
- SbiSymDef* p = aData.GetObject( i );
+ SbiSymDef* p = aData[ i ];
if( !p->IsDefined() )
pParser->Error( SbERR_UNDEF_LABEL, p->GetName() );
}
@@ -449,8 +444,7 @@ void SbiProcDef::Match( SbiProcDef* pOld )
if( !pIn && pOld->pIn )
{
// Replace old entry with the new one
- SbiSymDef** pData = (SbiSymDef**) pOld->pIn->aData.GetData();
- pData[ pOld->nPos ] = this;
+ pOld->pIn->aData[ pOld->nPos ] = this;
nPos = pOld->nPos;
nId = pOld->nId;
pIn = pOld->pIn;
@@ -510,4 +504,11 @@ SbiConstDef* SbiConstDef::GetConstDef()
return this;
}
+SbiSymbols::~SbiSymbols()
+{
+ for( const_iterator it = begin(); it != end(); ++it )
+ delete *it;
+};
+
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/source/inc/symtbl.hxx b/basic/source/inc/symtbl.hxx
index a0263f9e7b3c..cc6320ff4179 100644
--- a/basic/source/inc/symtbl.hxx
+++ b/basic/source/inc/symtbl.hxx
@@ -29,6 +29,8 @@
#ifndef _SYMTBL_HXX
#define _SYMTBL_HXX
+#include <vector>
+
class SbiConstDef;
class SbiParser;
class SbiProcDef;
@@ -57,7 +59,11 @@ public:
};
-SV_DECL_PTRARR_DEL(SbiSymbols,SbiSymDef*,5)
+class SbiSymbols : public std::vector<SbiSymDef*>
+{
+public:
+ ~SbiSymbols();
+};
class SbiSymPool {
friend class SbiSymDef;
@@ -76,7 +82,7 @@ public:
void SetParent( SbiSymPool* p ) { pParent = p; }
void SetProcId( short n ) { nProcId = n; }
- sal_uInt16 GetSize() const { return aData.Count(); }
+ sal_uInt16 GetSize() const { return aData.size(); }
SbiSymScope GetScope() const { return eScope; }
void SetScope( SbiSymScope s ) { eScope = s; }
SbiParser* GetParser() { return pParser; }