Kaydet (Commit) 21103976 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Michael Stahl

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
üst 56366fa0
...@@ -32,8 +32,6 @@ ...@@ -32,8 +32,6 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
SV_IMPL_PTRARR(SbiSymbols,SbiSymDef*)
// All symbol names are laid down int the symbol-pool's stringpool, so that // 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 // all symbols are handled in the same case. On saving the code-image, the
// global stringpool with the respective symbols is also saved. // global stringpool with the respective symbols is also saved.
...@@ -118,35 +116,33 @@ SbiSymDef* SbiSymPool::First() ...@@ -118,35 +116,33 @@ SbiSymDef* SbiSymPool::First()
SbiSymDef* SbiSymPool::Next() SbiSymDef* SbiSymPool::Next()
{ {
if( ++nCur >= aData.Count() ) if( ++nCur >= aData.size() )
return NULL; return NULL;
else else
return aData.GetObject( nCur ); return aData[ nCur ];
} }
SbiSymDef* SbiSymPool::AddSym( const String& rName ) SbiSymDef* SbiSymPool::AddSym( const String& rName )
{ {
SbiSymDef* p = new SbiSymDef( rName ); SbiSymDef* p = new SbiSymDef( rName );
p->nPos = aData.Count(); p->nPos = aData.size();
p->nId = rStrings.Add( rName ); p->nId = rStrings.Add( rName );
p->nProcId = nProcId; p->nProcId = nProcId;
p->pIn = this; p->pIn = this;
const SbiSymDef* q = p; aData.insert( aData.begin() + p->nPos, p );
aData.Insert( q, q->nPos );
return p; return p;
} }
SbiProcDef* SbiSymPool::AddProc( const String& rName ) SbiProcDef* SbiSymPool::AddProc( const String& rName )
{ {
SbiProcDef* p = new SbiProcDef( pParser, rName ); SbiProcDef* p = new SbiProcDef( pParser, rName );
p->nPos = aData.Count(); p->nPos = aData.size();
p->nId = rStrings.Add( rName ); p->nId = rStrings.Add( rName );
// procs are always local // procs are always local
p->nProcId = 0; p->nProcId = 0;
p->pIn = this; p->pIn = this;
const SbiSymDef* q = p; aData.insert( aData.begin() + p->nPos, p );
aData.Insert( q, q->nPos );
return p; return p;
} }
...@@ -165,7 +161,7 @@ void SbiSymPool::Add( SbiSymDef* pDef ) ...@@ -165,7 +161,7 @@ void SbiSymPool::Add( SbiSymDef* pDef )
return; return;
} }
pDef->nPos = aData.Count(); pDef->nPos = aData.size();
if( !pDef->nId ) if( !pDef->nId )
{ {
// A unique name must be created in the string pool // A unique name must be created in the string pool
...@@ -183,18 +179,17 @@ void SbiSymPool::Add( SbiSymDef* pDef ) ...@@ -183,18 +179,17 @@ void SbiSymPool::Add( SbiSymDef* pDef )
if( !pDef->GetProcDef() ) if( !pDef->GetProcDef() )
pDef->nProcId = nProcId; pDef->nProcId = nProcId;
pDef->pIn = this; pDef->pIn = this;
const SbiSymDef* q = pDef; aData.insert( aData.begin() + pDef->nPos, pDef );
aData.Insert( q, q->nPos );
} }
} }
SbiSymDef* SbiSymPool::Find( const String& rName ) const 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++ ) 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 ) ) if( ( !p->nProcId || ( p->nProcId == nProcId ) )
&& ( p->aName.EqualsIgnoreCaseAscii( rName ) ) ) && ( p->aName.EqualsIgnoreCaseAscii( rName ) ) )
return p; return p;
...@@ -208,9 +203,9 @@ SbiSymDef* SbiSymPool::Find( const String& rName ) const ...@@ -208,9 +203,9 @@ SbiSymDef* SbiSymPool::Find( const String& rName ) const
SbiSymDef* SbiSymPool::FindId( sal_uInt16 n ) 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 ) ) ) if( p->nId == n && ( !p->nProcId || ( p->nProcId == nProcId ) ) )
return p; return p;
} }
...@@ -224,10 +219,10 @@ SbiSymDef* SbiSymPool::FindId( sal_uInt16 n ) const ...@@ -224,10 +219,10 @@ SbiSymDef* SbiSymPool::FindId( sal_uInt16 n ) const
SbiSymDef* SbiSymPool::Get( sal_uInt16 n ) const SbiSymDef* SbiSymPool::Get( sal_uInt16 n ) const
{ {
if( n >= aData.Count() ) if( n >= aData.size() )
return NULL; return NULL;
else else
return aData.GetObject( n ); return aData[ n ];
} }
sal_uInt32 SbiSymPool::Define( const String& rName ) sal_uInt32 SbiSymPool::Define( const String& rName )
...@@ -255,9 +250,9 @@ sal_uInt32 SbiSymPool::Reference( const String& rName ) ...@@ -255,9 +250,9 @@ sal_uInt32 SbiSymPool::Reference( const String& rName )
void SbiSymPool::CheckRefs() 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() ) if( !p->IsDefined() )
pParser->Error( SbERR_UNDEF_LABEL, p->GetName() ); pParser->Error( SbERR_UNDEF_LABEL, p->GetName() );
} }
...@@ -449,8 +444,7 @@ void SbiProcDef::Match( SbiProcDef* pOld ) ...@@ -449,8 +444,7 @@ void SbiProcDef::Match( SbiProcDef* pOld )
if( !pIn && pOld->pIn ) if( !pIn && pOld->pIn )
{ {
// Replace old entry with the new one // Replace old entry with the new one
SbiSymDef** pData = (SbiSymDef**) pOld->pIn->aData.GetData(); pOld->pIn->aData[ pOld->nPos ] = this;
pData[ pOld->nPos ] = this;
nPos = pOld->nPos; nPos = pOld->nPos;
nId = pOld->nId; nId = pOld->nId;
pIn = pOld->pIn; pIn = pOld->pIn;
...@@ -510,4 +504,11 @@ SbiConstDef* SbiConstDef::GetConstDef() ...@@ -510,4 +504,11 @@ SbiConstDef* SbiConstDef::GetConstDef()
return this; return this;
} }
SbiSymbols::~SbiSymbols()
{
for( const_iterator it = begin(); it != end(); ++it )
delete *it;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#ifndef _SYMTBL_HXX #ifndef _SYMTBL_HXX
#define _SYMTBL_HXX #define _SYMTBL_HXX
#include <vector>
class SbiConstDef; class SbiConstDef;
class SbiParser; class SbiParser;
class SbiProcDef; class SbiProcDef;
...@@ -57,7 +59,11 @@ public: ...@@ -57,7 +59,11 @@ public:
}; };
SV_DECL_PTRARR_DEL(SbiSymbols,SbiSymDef*,5) class SbiSymbols : public std::vector<SbiSymDef*>
{
public:
~SbiSymbols();
};
class SbiSymPool { class SbiSymPool {
friend class SbiSymDef; friend class SbiSymDef;
...@@ -76,7 +82,7 @@ public: ...@@ -76,7 +82,7 @@ public:
void SetParent( SbiSymPool* p ) { pParent = p; } void SetParent( SbiSymPool* p ) { pParent = p; }
void SetProcId( short n ) { nProcId = n; } 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; } SbiSymScope GetScope() const { return eScope; }
void SetScope( SbiSymScope s ) { eScope = s; } void SetScope( SbiSymScope s ) { eScope = s; }
SbiParser* GetParser() { return pParser; } SbiParser* GetParser() { return pParser; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment