From fa1af598d62a71f7e7054a0dcc7b209e91e58873 Mon Sep 17 00:00:00 2001 From: =?utf8?q?W=C5=82odzimierz=20Skiba?= Date: Tue, 31 May 2005 15:32:50 +0000 Subject: [PATCH] More warning and error fixes (work in progress with Tinderbox). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34457 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- utils/HelpGen/src/HelpGen.cpp | 17 +- utils/HelpGen/src/cjparser.cpp | 7 +- utils/HelpGen/src/ifcontext.cpp | 302 ++++++++++++++++---------------- utils/HelpGen/src/ifcontext.h | 74 ++++---- utils/HelpGen/src/srcparser.cpp | 39 ++--- utils/HelpGen/src/srcparser.h | 26 +-- 6 files changed, 232 insertions(+), 233 deletions(-) diff --git a/utils/HelpGen/src/HelpGen.cpp b/utils/HelpGen/src/HelpGen.cpp index d26af0382a..5410e243da 100644 --- a/utils/HelpGen/src/HelpGen.cpp +++ b/utils/HelpGen/src/HelpGen.cpp @@ -241,7 +241,7 @@ public: // return true if we ignore this class entirely bool IgnoreClass(const wxString& classname) const { - IgnoreListEntry ignore(classname, _T("")); + IgnoreListEntry ignore(classname, wxEmptyString); return m_ignore.Index(&ignore) != wxNOT_FOUND; } @@ -757,7 +757,7 @@ int main(int argc, char **argv) #ifdef __WXDEBUG__ if ( 0 && ctxTop ) - ctxTop->Dump(""); + ctxTop->Dump(wxEmptyString); #endif // __WXDEBUG__ } @@ -813,7 +813,7 @@ void HelpGenVisitor::Reset() m_funcName = m_textFunc = m_textStoredTypedefs = - m_textStoredFunctionComment = ""; + m_textStoredFunctionComment = wxEmptyString; m_arrayFuncDocs.Empty(); @@ -1318,7 +1318,7 @@ void HelpGenVisitor::VisitParameter( spParameter& param ) } m_textFunc << "\\param{" << param.m_Type << " }{" << param.GetName(); - wxString defvalue = param.mInitVal; + wxString defvalue = param.m_InitVal; if ( !defvalue.empty() ) { m_textFunc << " = " << defvalue; } @@ -1897,14 +1897,14 @@ bool DocManager::DumpDifferences(spContext *ctxTop) const continue; } - if ( param.GetDefValue() != ctxParam->mInitVal.c_str() ) { + if ( param.GetDefValue() != ctxParam->m_InitVal.c_str() ) { wxLogWarning("Default value of parameter '%s' of " "'%s::%s' should be '%s' and not " "'%s'.", ctxParam->m_Name.c_str(), nameClass.c_str(), nameMethod.c_str(), - ctxParam->mInitVal.c_str(), + ctxParam->m_InitVal.c_str(), param.GetDefValue().c_str()); } } @@ -2022,7 +2022,7 @@ bool IgnoreNamesHandler::AddNamesFromFile(const wxString& filename) } else { // entire class - m_ignore.Add(new IgnoreListEntry(line, "")); + m_ignore.Add(new IgnoreListEntry(line, wxEmptyString)); } } //else: comment @@ -2197,6 +2197,9 @@ static const wxString GetVersionString() /* $Log$ + Revision 1.42 2005/05/31 15:32:49 ABX + More warning and error fixes (work in progress with Tinderbox). + Revision 1.41 2005/05/30 13:06:15 ABX More warning and error fixes (work in progress with Tinderbox). diff --git a/utils/HelpGen/src/cjparser.cpp b/utils/HelpGen/src/cjparser.cpp index 27d2aa548d..db12882ae2 100644 --- a/utils/HelpGen/src/cjparser.cpp +++ b/utils/HelpGen/src/cjparser.cpp @@ -1734,7 +1734,7 @@ bool CJSourceParser::ParseArguments( char*& cur ) continue; } - pPar->mInitVal = string( blocks[nameBlock], blockSizes[nameBlock] ); + pPar->m_InitVal = wxString( blocks[nameBlock], blockSizes[nameBlock] ); nameBlock = nameBlock - 2; // skip '=' token and default value block typeBlock = nameBlock - 1; @@ -1880,12 +1880,11 @@ void CJSourceParser::ParseMemberVar( char*& cur ) // if comma, than variable list continues // otherwise the variable type reached - stop - if ( *cur == '=' ) + if ( *cur == _T('=') ) { // yes, we've mistaken, it was not a identifier, // but it's default value - pAttr->mInitVal = - pAttr->m_Name; + pAttr->m_InitVal = pAttr->m_Name; // skip default value and '=' symbol skip_next_token_back( cur ); diff --git a/utils/HelpGen/src/ifcontext.cpp b/utils/HelpGen/src/ifcontext.cpp index 85e73c04aa..32a1aae9fd 100644 --- a/utils/HelpGen/src/ifcontext.cpp +++ b/utils/HelpGen/src/ifcontext.cpp @@ -6,7 +6,7 @@ // Created: 27/12/98 // RCS-ID: $Id$ // Copyright: (c) Aleskandars Gluchovas -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -35,23 +35,25 @@ size_t spInterFileContext::GetFileNo( const string& fname ) { - size_t i; - for ( i = 0; i != mFiles.size(); ++i ) - if ( fname == mFiles[i] ) + for ( size_t i = 0; i != mFiles.size(); ++i ) + { + if ( fname == mFiles[i] ) return i; + } wxFAIL_MSG("File not found in array in function spInterFileContext::GetFileNo()"); - return 0; + + return 0; } size_t spInterFileContext::GetFileNoOfContext( spContext& ctx ) { - spContext* pCtx = ctx.GetEnclosingContext( SP_CTX_FILE ); + spContext* pCtx = ctx.GetEnclosingContext( SP_CTX_FILE ); - // DBG:: outer-file context should be present - wxASSERT( pCtx && pCtx->GetType() == SP_CTX_FILE ); + // DBG:: outer-file context should be present + wxASSERT( pCtx && pCtx->GetType() == SP_CTX_FILE ); - return GetFileNo( ((spFile*)pCtx)->mFileName ); + return GetFileNo( ((spFile*)pCtx)->mFileName ); } /*** public interface ***/ @@ -64,234 +66,232 @@ spInterFileContext::~spInterFileContext() void spInterFileContext::AddFile( const string& fname, const string& content ) { - mFiles.push_back( fname ); - mContents.push_back( content ); + mFiles.push_back( fname ); + mContents.push_back( content ); } void spInterFileContext::RemoveContext( spContext& ctx ) { - wxASSERT( ctx.PositionIsKnown() ); // DBG:: should be checked by-user code + wxASSERT( ctx.PositionIsKnown() ); // DBG:: should be checked by-user code - size_t fNo = GetFileNoOfContext( ctx ); + size_t fNo = GetFileNoOfContext( ctx ); - mDeletionMarks.push_back( spBookmark( ctx.mSrcOffset, ctx.mContextLength, fNo ) ); + mDeletionMarks.push_back( spBookmark( ctx.mSrcOffset, ctx.mContextLength, fNo ) ); } void spInterFileContext::InsertBookmarkSorted( BookmarkListT& lst, spBookmark& mark ) { - for( size_t i = 0; i != lst.size(); ++i ) - - if ( lst[i].mFrom > mark.mFrom ) - { - lst.insert( &lst[i], mark ); - return; - } + for( size_t i = 0; i != lst.size(); ++i ) - lst.push_back( mark ); -} + if ( lst[i].mFrom > mark.mFrom ) + { + lst.insert( &lst[i], mark ); + return; + } + + lst.push_back( mark ); +} void spInterFileContext::DoAppendSourceFragment( string& source, - string& result, - size_t pos, size_t len ) + string& result, + size_t pos, size_t len ) { - mFiltered.erase( mFiltered.begin(), mFiltered.end() ); + mFiltered.erase( mFiltered.begin(), mFiltered.end() ); - size_t i; + size_t i; + + for( i = 0; i != mDeletionMarks.size(); ++i ) + { + spBookmark& mark = mDeletionMarks[i]; - for( i = 0; i != mDeletionMarks.size(); ++i ) - { - spBookmark& mark = mDeletionMarks[i]; + if ( mark.mFileNo == mCurFileNo && + mark.mFrom >= pos && mark.mFrom < pos + len ) - if ( mark.mFileNo == mCurFileNo && - mark.mFrom >= pos && mark.mFrom < pos + len ) - - InsertBookmarkSorted( mFiltered, mark ); - } + InsertBookmarkSorted( mFiltered, mark ); + } - size_t cur = pos; - - for( i = 0; i != mFiltered.size(); ++ i ) - { - spBookmark& mark = mFiltered[i]; + size_t cur = pos; - result.append( source, cur, ( (size_t)mark.mFrom - cur ) ); + for( i = 0; i != mFiltered.size(); ++ i ) + { + spBookmark& mark = mFiltered[i]; - cur = size_t( mark.mFrom + mark.mLen ); + result.append( source, cur, ( (size_t)mark.mFrom - cur ) ); - if ( cur >= pos + len ) // check if we've overstepped the current source-fragment - { -// wxASSERT(0); // DBG:: with current imp. this should not happen - wxFAIL_MSG("Overstepped the current source fragment in function\nspInterFileContext::DoAppendSourceFragment()"); - cur = pos + len; break; - } - } + cur = size_t( mark.mFrom + mark.mLen ); - result.append( source, cur, ( pos + len ) - cur ); + if ( cur >= pos + len ) // check if we've overstepped the current source-fragment + { +// wxASSERT(0); // DBG:: with current imp. this should not happen + wxFAIL_MSG("Overstepped the current source fragment in function\nspInterFileContext::DoAppendSourceFragment()"); + cur = pos + len; break; + } + } + + result.append( source, cur, ( pos + len ) - cur ); } void spInterFileContext::GenerateContextBody( spContext& ctx, - string& source, - string& result, - size_t& lastSavedPos, - size_t& lastKnownPos ) + string& source, + string& result, + size_t& lastSavedPos, + size_t& lastKnownPos ) { - if ( ctx.PositionIsKnown() ) - - lastKnownPos = ctx.mSrcOffset; + if ( ctx.PositionIsKnown() ) + lastKnownPos = ctx.mSrcOffset; - if ( ctx.IsVirtualContext() ) - { - // add fragment accumulated before this context + if ( ctx.IsVirtualContext() ) + { + // add fragment accumulated before this context - DoAppendSourceFragment( source, result, - size_t(lastSavedPos), - size_t(lastKnownPos - lastSavedPos) ); + DoAppendSourceFragment( source, result, + size_t(lastSavedPos), + size_t(lastKnownPos - lastSavedPos) ); - // add context body + // add context body - result += ctx.GetVirtualContextBody(); + result += ctx.GetVirtualContextBody(); - lastSavedPos = lastKnownPos; + lastSavedPos = lastKnownPos; - if ( ctx.PositionIsKnown() ) - { - if ( ctx.VitualContextHasChildren() ) - { - lastKnownPos = ctx.mSrcOffset + ctx.mHeaderLength; + if ( ctx.PositionIsKnown() ) + { + if ( ctx.VitualContextHasChildren() ) + { + lastKnownPos = ctx.mSrcOffset + ctx.mHeaderLength; - lastSavedPos = lastKnownPos; - } - else - { - lastKnownPos = ctx.mSrcOffset + ctx.mContextLength; + lastSavedPos = lastKnownPos; + } + else + { + lastKnownPos = ctx.mSrcOffset + ctx.mContextLength; - lastSavedPos = lastKnownPos; + lastSavedPos = lastKnownPos; - return; // have not children - } - } - } + return; // have not children + } + } + } - MMemberListT& lst = ctx.GetMembers(); + MMemberListT& lst = ctx.GetMembers(); - for( size_t i = 0; i != lst.size(); ++i ) - - GenerateContextBody( *lst[i], source, result, lastSavedPos, lastKnownPos ); - - if ( ctx.IsVirtualContext() ) - { - if ( ctx.VitualContextHasChildren() && + for( size_t i = 0; i != lst.size(); ++i ) + { + GenerateContextBody( *lst[i], source, result, lastSavedPos, lastKnownPos ); + } - ctx.GetFooterOfVirtualContextBody() != "" ) - { - // append the reminder space after children of the context + if ( ctx.IsVirtualContext() ) + { + if ( ctx.VitualContextHasChildren() && !ctx.GetFooterOfVirtualContextBody().empty() ) + { + // append the reminder space after children of the context - DoAppendSourceFragment( result, source, - size_t(lastSavedPos), - size_t(lastKnownPos - lastSavedPos) ); + DoAppendSourceFragment( result, source, + size_t(lastSavedPos), + size_t(lastKnownPos - lastSavedPos) ); - // add footer - result += ctx.GetFooterOfVirtualContextBody(); + // add footer + result += ctx.GetFooterOfVirtualContextBody(); - lastKnownPos = ctx.mSrcOffset + ctx.mContextLength; + lastKnownPos = ctx.mSrcOffset + ctx.mContextLength; - lastSavedPos = lastKnownPos; - } - } + lastSavedPos = lastKnownPos; + } + } - if ( ctx.PositionIsKnown() ) + if ( ctx.PositionIsKnown() ) - lastKnownPos = ctx.mSrcOffset + ctx.mContextLength; + lastKnownPos = ctx.mSrcOffset + ctx.mContextLength; } void spInterFileContext::GenrateContents() { - MMemberListT& lst = GetMembers(); + MMemberListT& lst = GetMembers(); - for( size_t f = 0; f != lst.size(); ++f ) - { - string& fname = ((spFile*)lst[f])->mFileName; + for( size_t f = 0; f != lst.size(); ++f ) + { + string& fname = ((spFile*)lst[f])->mFileName; - size_t fileNo = GetFileNo( fname ); + size_t fileNo = GetFileNo( fname ); - string& source = mContents[ fileNo ]; + string& source = mContents[ fileNo ]; - string result; + string result; - size_t lastKnownPos = 0, // the begining of the file is always "known" - lastSavedPos = 0; + size_t lastKnownPos = 0, // the begining of the file is always "known" + lastSavedPos = 0; - mCurFileNo = fileNo; + mCurFileNo = fileNo; - GenerateContextBody( *lst[f], source, result, lastSavedPos, lastKnownPos ); + GenerateContextBody( *lst[f], source, result, lastSavedPos, lastKnownPos ); - // the end of file is always known + // the end of file is always known - lastKnownPos = mContents[ fileNo ].length(); + lastKnownPos = mContents[ fileNo ].length(); - // append the reminder + // append the reminder - DoAppendSourceFragment( source, result, - size_t(lastSavedPos), - size_t(lastKnownPos - lastSavedPos) ); + DoAppendSourceFragment( source, result, + size_t(lastSavedPos), + size_t(lastKnownPos - lastSavedPos) ); - // replace original contnet with newly generated one + // replace original contnet with newly generated one - mContents[ fileNo ] = result; - } + mContents[ fileNo ] = result; + } } void spInterFileContext::ParseContents( SourceParserPlugin* pPlugin ) { - mDeletionMarks.erase( mDeletionMarks.begin(), mDeletionMarks.end() ); + mDeletionMarks.erase( mDeletionMarks.begin(), mDeletionMarks.end() ); - RemoveChildren(); // clean up top-level context + RemoveChildren(); // clean up top-level context - mParser.SetPlugin( pPlugin ); + mParser.SetPlugin( pPlugin ); - for( size_t i = 0; i != mFiles.size(); ++i ) - { - char* s = (char*)(mContents[i].c_str()); + for( size_t i = 0; i != mFiles.size(); ++i ) + { + char* s = (char*)(mContents[i].c_str()); - spFile* pFCtx = mParser.Parse( s, s + mContents[i].length() ); + spFile* pFCtx = mParser.Parse( s, s + mContents[i].length() ); - pFCtx->mFileName = mFiles[i]; + pFCtx->mFileName = mFiles[i]; - AddMember( pFCtx ); - } + AddMember( pFCtx ); + } } void spInterFileContext::WriteToFiles() { - for( size_t i = 0; i != mFiles.size(); ++i ) - { - FILE* fp = fopen( mFiles[i].c_str(), "w+t" ); + for( size_t i = 0; i != mFiles.size(); ++i ) + { + FILE* fp = fopen( mFiles[i].c_str(), "w+t" ); - if ( fp != NULL ) - { - fwrite( mContents[i].c_str(), sizeof(char), mContents[i].length(), fp ); + if ( fp != NULL ) + { + fwrite( mContents[i].c_str(), sizeof(char), mContents[i].length(), fp ); - fclose( fp ); - } - } + fclose( fp ); + } + } } -string spInterFileContext::GetBody( spContext* pCtx ) +wxString spInterFileContext::GetBody( spContext* pCtx ) { - wxASSERT( pCtx->PositionIsKnown() ); // DBG:: should be checked by-user code + wxASSERT( pCtx->PositionIsKnown() ); // DBG:: should be checked by-user code - string& source = mContents[ GetFileNoOfContext( *pCtx ) ]; + wxString& source = mContents[ GetFileNoOfContext( *pCtx ) ]; - return string( source.c_str() + pCtx->mSrcOffset, pCtx->mContextLength ); + return wxString( source.c_str() + pCtx->mSrcOffset, pCtx->mContextLength ); } -string spInterFileContext::GetHeader( spContext* pCtx ) +wxString spInterFileContext::GetHeader( spContext* pCtx ) { - wxASSERT( pCtx->PositionIsKnown() ); // DBG:: should be checked by-user code + wxASSERT( pCtx->PositionIsKnown() ); // DBG:: should be checked by-user code - wxASSERT( pCtx->mHeaderLength != -1 ); // DBG:: -/- + wxASSERT( pCtx->mHeaderLength != -1 ); // DBG:: -/- - string& source = mContents[ GetFileNoOfContext( *pCtx ) ]; + wxString& source = mContents[ GetFileNoOfContext( *pCtx ) ]; - return string( source.c_str() + pCtx->mSrcOffset, pCtx->mHeaderLength ); + return wxString( source.c_str() + pCtx->mSrcOffset, pCtx->mHeaderLength ); } diff --git a/utils/HelpGen/src/ifcontext.h b/utils/HelpGen/src/ifcontext.h index 50f2eaded2..6377e88785 100644 --- a/utils/HelpGen/src/ifcontext.h +++ b/utils/HelpGen/src/ifcontext.h @@ -6,7 +6,7 @@ // Created: 27/12/98 // RCS-ID: $Id$ // Copyright: (c) Aleskandars Gluchovas -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef __IFCONTEXT_G__ @@ -18,24 +18,24 @@ class spBookmark { public: - size_t mFrom; - size_t mLen; - size_t mFileNo; + size_t mFrom; + size_t mLen; + size_t mFileNo; - inline spBookmark() {} + inline spBookmark() {} - inline spBookmark( int from, int len, int fileNo ) - : mFrom( from ), mLen( len ), mFileNo( fileNo ) - {} + inline spBookmark( int from, int len, int fileNo ) + : mFrom( from ), mLen( len ), mFileNo( fileNo ) + {} }; #if defined( wxUSE_TEMPLATE_STL ) - typedef vectorGetBody( ( pCtx != NULL ) ? pCtx : this ); else - return ""; // source-fragment cannot be found + return wxEmptyString; // source-fragment cannot be found } -string spContext::GetHeader( spContext* pCtx ) +wxString spContext::GetHeader( spContext* pCtx ) { if ( GetParent() ) - return GetParent()->GetHeader( ( pCtx != NULL ) ? pCtx : this ); else - return ""; // source-fragment cannot be found + return wxEmptyString; // source-fragment cannot be found } bool spContext::IsFirstOccurence() @@ -421,12 +418,12 @@ spOperation::spOperation() mHasDefinition = false; } -string spOperation::GetFullName(MarkupTagsT tags) +wxString spOperation::GetFullName(MarkupTagsT tags) { - string txt = tags[TAG_BOLD].start + m_RetType; - txt += " "; + wxString txt = tags[TAG_BOLD].start + m_RetType; + txt += _T(" "); txt += m_Name; - txt += "( "; + txt += _T("( "); txt += tags[TAG_BOLD].end; for( size_t i = 0; i != mMembers.size(); ++i ) @@ -437,7 +434,7 @@ string spOperation::GetFullName(MarkupTagsT tags) spParameter& param = *((spParameter*)mMembers[i]); if ( i != 0 ) - txt += ", "; + txt += _T(", "); txt += tags[TAG_BOLD].start; @@ -446,15 +443,15 @@ string spOperation::GetFullName(MarkupTagsT tags) txt += tags[TAG_BOLD].end; txt += tags[TAG_ITALIC].start; - txt += " "; + txt += _T(" "); txt += param.m_Name; - if ( param.mInitVal != "" ) + if ( !param.m_InitVal.empty() ) { - txt += " = "; + txt += _T(" = "); txt += tags[TAG_BOLD].start; - txt += param.mInitVal; + txt += param.m_InitVal; txt += tags[TAG_BOLD].end; } @@ -473,13 +470,13 @@ string spOperation::GetFullName(MarkupTagsT tags) /***** Implemenentation for class spPreprocessorLine *****/ -string spPreprocessorLine::CPP_GetIncludedFileNeme() const +wxString spPreprocessorLine::CPP_GetIncludedFileNeme() const { wxASSERT( GetStatementType() == SP_PREP_DEF_INCLUDE_FILE ); size_t i = 0; - while( i < m_Line.length() && m_Line[i] != '"' && m_Line[i] != '<' ) + while( i < m_Line.length() && m_Line[i] != _T('"') && m_Line[i] != _T('<') ) ++i; @@ -487,19 +484,19 @@ string spPreprocessorLine::CPP_GetIncludedFileNeme() const size_t start = i; - while( i < m_Line.length() && m_Line[i] != '"' && m_Line[i] != '>' ) + while( i < m_Line.length() && m_Line[i] != _T('"') && m_Line[i] != _T('>') ) ++i; if ( start < m_Line.length() ) { - string fname; + wxString fname; fname.append( m_Line, start, ( i - start ) ); return fname; } else - return ""; // syntax error probably + return wxEmptyString; // syntax error probably } diff --git a/utils/HelpGen/src/srcparser.h b/utils/HelpGen/src/srcparser.h index a22557eda2..3758eed9a3 100644 --- a/utils/HelpGen/src/srcparser.h +++ b/utils/HelpGen/src/srcparser.h @@ -233,23 +233,23 @@ public: class spComment { public: - wxString m_Text; - bool mIsMultiline; // multiline comments ar those with /**/'s + wxString m_Text; + bool mIsMultiline; // multiline comments ar those with /**/'s // true, if these was an empty empty // line above single line comment - bool mStartsPar; + bool mStartsPar; public: - bool IsMultiline() const; - bool StartsParagraph() const; + bool IsMultiline() const; + bool StartsParagraph() const; - string& GetText(); + wxString& GetText(); // contstant version of GetText() - string GetText() const; + wxString GetText() const; }; // abstract base class for common (to most languages) code @@ -369,9 +369,9 @@ public: // can be overriden by top-level context classes // to find-out ot the source-fragment of this // context using it's position information - virtual string GetBody( spContext* pCtx = NULL ); + virtual wxString GetBody( spContext* pCtx = NULL ); - virtual string GetHeader( spContext* pCtx = NULL ); + virtual wxString GetHeader( spContext* pCtx = NULL ); // true, if there is at least one entry // in the comment list of this context @@ -503,7 +503,7 @@ public: wxString m_Type; // "stringified" initial value - string mInitVal; + wxString m_InitVal; public: virtual int GetContextType() const { return SP_CTX_PARAMETER; } @@ -524,7 +524,7 @@ public: wxString m_Type; // it's initial value - string mInitVal; + wxString m_InitVal; // constantness bool mIsConstant; @@ -580,7 +580,7 @@ public: // the default implementation outputs name in // C++/Java syntax - virtual string GetFullName(MarkupTagsT tags); + virtual wxString GetFullName(MarkupTagsT tags); virtual int GetContextType() const { return SP_CTX_OPERATION; } @@ -609,7 +609,7 @@ public: virtual int GetStatementType() const { return mDefType; } - string CPP_GetIncludedFileNeme() const; + wxString CPP_GetIncludedFileNeme() const; virtual void AcceptVisitor( spVisitor& visitor ) { visitor.VisitPreprocessorLine( *this ); } -- 2.45.2