[Libreoffice-commits] .: idl/inc idl/source
Thorsten Behrens
thorsten at kemper.freedesktop.org
Mon Apr 11 07:45:18 PDT 2011
idl/inc/lex.hxx | 102 +++++++++++++++++++++++++-------------------
idl/source/cmptools/lex.cxx | 26 +++--------
2 files changed, 67 insertions(+), 61 deletions(-)
New commits:
commit b76694d594b5e5dac861dd3d3cccff53c2f44afc
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Fri Mar 25 15:52:55 2011 -0430
Remove DECLARE_LIST( SvTokenList, SvToken * )
diff --git a/idl/inc/lex.hxx b/idl/inc/lex.hxx
index 461efb7..ac5a5a7 100644
--- a/idl/inc/lex.hxx
+++ b/idl/inc/lex.hxx
@@ -29,10 +29,11 @@
#ifndef _LEX_HXX
#define _LEX_HXX
+#include <boost/ptr_container/ptr_vector.hpp>
+
#include <hash.hxx>
#include <tools/gen.hxx>
#include <tools/stream.hxx>
-#include <tools/list.hxx>
enum SVTOKEN_ENUM { SVTOKEN_EMPTY, SVTOKEN_COMMENT,
SVTOKEN_INTEGER, SVTOKEN_STRING,
@@ -127,8 +128,6 @@ inline SvToken::SvToken( SVTOKEN_ENUM nTypeP, const ByteString & rStr )
inline SvToken::SvToken( SVTOKEN_ENUM nTypeP )
: nType( nTypeP ) {}
-DECLARE_LIST( SvTokenList, SvToken * )
-
class SvTokenStream
{
sal_uLong nLine, nColumn;
@@ -144,8 +143,8 @@ class SvTokenStream
SvFileStream * pInStream;
SvStream & rInStream;
String aFileName;
- SvTokenList aTokList;
- SvToken * pCurToken;
+ boost::ptr_vector<SvToken> aTokList;
+ boost::ptr_vector<SvToken>::iterator pCurToken;
void InitCtor();
@@ -192,30 +191,37 @@ public:
{ nTabSize = nTabSizeP; }
sal_uInt16 GetTabSize() const { return nTabSize; }
- SvToken * GetToken_PrevAll()
- {
- SvToken * pRetToken = pCurToken;
- if( NULL == (pCurToken = aTokList.Prev()) )
- // current pointer never null
- pCurToken = pRetToken;
+ SvToken* GetToken_PrevAll()
+ {
+ boost::ptr_vector<SvToken>::iterator pRetToken = pCurToken;
+
+ // current iterator always valid
+ if(pCurToken != aTokList.begin())
+ --pCurToken;
+
+ return &(*pRetToken);
+ }
+
+ SvToken* GetToken_NextAll()
+ {
+ boost::ptr_vector<SvToken>::iterator pRetToken = pCurToken++;
+
+ if (pCurToken == aTokList.end())
+ pCurToken = pRetToken;
+
+ SetMax();
+
+ return &(*pRetToken);
+ }
+
+ SvToken* GetToken_Next()
+ {
+ // comments get removed initially
+ return GetToken_NextAll();
+ }
+
+ SvToken* GetToken() const { return &(*pCurToken); }
- return pRetToken;
- }
- SvToken * GetToken_NextAll()
- {
- SvToken * pRetToken = pCurToken;
- if( NULL == (pCurToken = aTokList.Next()) )
- // current pointer never null
- pCurToken = pRetToken;
- SetMax();
- return pRetToken;
- }
- SvToken * GetToken_Next()
- {
- // comments get removed initially
- return GetToken_NextAll();
- }
- SvToken * GetToken() const { return pCurToken; }
sal_Bool Read( char cChar )
{
if( pCurToken->IsChar()
@@ -227,6 +233,7 @@ public:
else
return sal_False;
}
+
void ReadDelemiter()
{
if( pCurToken->IsChar()
@@ -237,22 +244,29 @@ public:
}
}
- sal_uInt32 Tell() const
- { return aTokList.GetCurPos(); }
- void Seek( sal_uInt32 nPos )
- {
- pCurToken = aTokList.Seek( nPos );
- SetMax();
- }
- void SeekRel( sal_Int32 nRelPos )
- {
- pCurToken = aTokList.Seek( Tell() + nRelPos );
- SetMax();
- }
- void SeekEnd()
- {
- pCurToken = aTokList.Seek( nMaxPos );
- }
+ sal_uInt32 Tell() const { return pCurToken-aTokList.begin(); }
+
+ void Seek( sal_uInt32 nPos )
+ {
+ pCurToken = aTokList.begin() + nPos;
+ SetMax();
+ }
+
+ void SeekRel( sal_uInt32 nRelPos )
+ {
+ sal_uInt32 relIdx = Tell() + nRelPos;
+
+ if ( relIdx < aTokList.size())
+ {
+ pCurToken = aTokList.begin()+ (Tell() + nRelPos );
+ SetMax();
+ }
+ }
+
+ void SeekEnd()
+ {
+ pCurToken = aTokList.begin()+nMaxPos;
+ }
};
diff --git a/idl/source/cmptools/lex.cxx b/idl/source/cmptools/lex.cxx
index 41775ab..33e1eef 100644
--- a/idl/source/cmptools/lex.cxx
+++ b/idl/source/cmptools/lex.cxx
@@ -105,7 +105,6 @@ void SvTokenStream::InitCtor()
nLine = nColumn = 0;
nBufPos = 0;
nTabSize = 4;
- pCurToken = NULL;
nMaxPos = 0;
c = GetNextChar();
FillTokenList();
@@ -115,7 +114,6 @@ SvTokenStream::SvTokenStream( const String & rFileName )
: pInStream( new SvFileStream( rFileName, STREAM_STD_READ | STREAM_NOCREATE ) )
, rInStream( *pInStream )
, aFileName( rFileName )
- , aTokList( 0x8000, 0x8000 )
{
InitCtor();
}
@@ -124,7 +122,6 @@ SvTokenStream::SvTokenStream( SvStream & rStream, const String & rFileName )
: pInStream( NULL )
, rInStream( rStream )
, aFileName( rFileName )
- , aTokList( 0x8000, 0x8000 )
{
InitCtor();
}
@@ -132,28 +129,23 @@ SvTokenStream::SvTokenStream( SvStream & rStream, const String & rFileName )
SvTokenStream::~SvTokenStream()
{
delete pInStream;
- SvToken * pTok = aTokList.Last();
- while( pTok )
- {
- delete pTok;
- pTok = aTokList.Prev();
- }
}
void SvTokenStream::FillTokenList()
{
SvToken * pToken = new SvToken();
- aTokList.Insert( pToken, LIST_APPEND );
+ aTokList.push_back(pToken);
do
{
if( !MakeToken( *pToken ) )
{
- SvToken * p = aTokList.Prev();
- *pToken = SvToken();
- if( p )
+ if (!aTokList.empty())
{
- pToken->SetLine( p->GetLine() );
- pToken->SetColumn( p->GetColumn() );
+ *pToken = SvToken();
+ boost::ptr_vector<SvToken>::const_iterator it = aTokList.begin();
+
+ pToken->SetLine(it->GetLine());
+ pToken->SetColumn(it->GetColumn());
}
break;
}
@@ -164,11 +156,11 @@ void SvTokenStream::FillTokenList()
else
{
pToken = new SvToken();
- aTokList.Insert( pToken, LIST_APPEND );
+ aTokList.push_back(pToken);
}
}
while( !pToken->IsEof() );
- pCurToken = aTokList.First();
+ pCurToken = aTokList.begin();
}
void SvTokenStream::SetCharSet( CharSet nSet )
More information about the Libreoffice-commits
mailing list