From 3867926d7162704c8232af95316dbc14e313f9c3 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Fri, 1 Jan 2021 11:47:41 +0100 Subject: Refactoring: modernise Doxygen::clangUsrMap --- src/clangparser.cpp | 25 +++++++++++++++---------- src/clangparser.h | 18 +++++++++--------- src/definition.cpp | 2 +- src/doxygen.cpp | 4 ++-- src/doxygen.h | 6 ++---- src/membergroup.h | 3 ++- 6 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/clangparser.cpp b/src/clangparser.cpp index 2593d27..fc31639 100644 --- a/src/clangparser.cpp +++ b/src/clangparser.cpp @@ -350,7 +350,7 @@ ClangTUParser::~ClangTUParser() p->tu = 0; } -void ClangTUParser::switchToFile(FileDef *fd) +void ClangTUParser::switchToFile(const FileDef *fd) { //printf("ClangTUParser::switchToFile(%s) this=%p\n",qPrint(fd->absFilePath()),this); if (p->tu) @@ -490,7 +490,7 @@ QCString ClangTUParser::lookup(uint line,const char *symbol) } -void ClangTUParser::writeLineNumber(CodeOutputInterface &ol,FileDef *fd,uint line) +void ClangTUParser::writeLineNumber(CodeOutputInterface &ol,const FileDef *fd,uint line) { Definition *d = fd ? fd->getSourceDefinition(line) : 0; if (d && d->isLinkable()) @@ -536,7 +536,7 @@ void ClangTUParser::writeLineNumber(CodeOutputInterface &ol,FileDef *fd,uint lin //printf("writeLineNumber(%d) g_searchForBody=%d\n",line,g_searchForBody); } -void ClangTUParser::codifyLines(CodeOutputInterface &ol,FileDef *fd,const char *text, +void ClangTUParser::codifyLines(CodeOutputInterface &ol,const FileDef *fd,const char *text, uint &line,uint &column,const char *fontClass) { if (fontClass) ol.startFontClass(fontClass); @@ -573,8 +573,8 @@ void ClangTUParser::codifyLines(CodeOutputInterface &ol,FileDef *fd,const char * } void ClangTUParser::writeMultiLineCodeLink(CodeOutputInterface &ol, - FileDef *fd,uint &line,uint &column, - Definition *d, + const FileDef *fd,uint &line,uint &column, + const Definition *d, const char *text) { static bool sourceTooltips = Config_getBool(SOURCE_TOOLTIPS); @@ -613,7 +613,7 @@ void ClangTUParser::writeMultiLineCodeLink(CodeOutputInterface &ol, } } -void ClangTUParser::linkInclude(CodeOutputInterface &ol,FileDef *fd, +void ClangTUParser::linkInclude(CodeOutputInterface &ol,const FileDef *fd, uint &line,uint &column,const char *text) { QCString incName = text; @@ -647,7 +647,7 @@ void ClangTUParser::linkInclude(CodeOutputInterface &ol,FileDef *fd, } } -void ClangTUParser::linkMacro(CodeOutputInterface &ol,FileDef *fd, +void ClangTUParser::linkMacro(CodeOutputInterface &ol,const FileDef *fd, uint &line,uint &column,const char *text) { MemberName *mn=Doxygen::functionNameLinkedMap->find(text); @@ -666,7 +666,7 @@ void ClangTUParser::linkMacro(CodeOutputInterface &ol,FileDef *fd, } -void ClangTUParser::linkIdentifier(CodeOutputInterface &ol,FileDef *fd, +void ClangTUParser::linkIdentifier(CodeOutputInterface &ol,const FileDef *fd, uint &line,uint &column,const char *text,int tokenIndex) { CXCursor c = p->cursors[tokenIndex]; @@ -683,7 +683,12 @@ void ClangTUParser::linkIdentifier(CodeOutputInterface &ol,FileDef *fd, CXString usr = clang_getCursorUSR(c); const char *usrStr = clang_getCString(usr); - Definition *d = usrStr ? Doxygen::clangUsrMap->find(usrStr) : 0; + const Definition *d = 0; + auto kv = Doxygen::clangUsrMap->find(usrStr); + if (kv!=Doxygen::clangUsrMap->end()) + { + d = kv->second; + } //CXCursorKind kind = clang_getCursorKind(c); //if (d==0) //{ @@ -743,7 +748,7 @@ void ClangTUParser::detectFunctionBody(const char *s) } } -void ClangTUParser::writeSources(CodeOutputInterface &ol,FileDef *fd) +void ClangTUParser::writeSources(CodeOutputInterface &ol,const FileDef *fd) { // (re)set global parser state p->currentMemberDef=0; diff --git a/src/clangparser.h b/src/clangparser.h index f948c33..83aafdd 100644 --- a/src/clangparser.h +++ b/src/clangparser.h @@ -32,7 +32,7 @@ class ClangTUParser /** Switches to another file within the translation unit started with start(). * @param[in] fd The file definition with the name of the file to switch to. */ - void switchToFile(FileDef *fd); + void switchToFile(const FileDef *fd); /** Returns the list of files for this translation unit */ StringVector filesInSameTU() const; @@ -46,23 +46,23 @@ class ClangTUParser * @param[out] ol The output generator list to write to. * @param[in] fd The file to write sources for. */ - void writeSources(CodeOutputInterface &ol,FileDef *fd); + void writeSources(CodeOutputInterface &ol,const FileDef *fd); private: void detectFunctionBody(const char *s); - void writeLineNumber(CodeOutputInterface &ol,FileDef *fd,uint line); - void codifyLines(CodeOutputInterface &ol,FileDef *fd,const char *text, + void writeLineNumber(CodeOutputInterface &ol,const FileDef *fd,uint line); + void codifyLines(CodeOutputInterface &ol,const FileDef *fd,const char *text, uint &line,uint &column,const char *fontClass=0); void writeMultiLineCodeLink(CodeOutputInterface &ol, - FileDef *fd,uint &line,uint &column, - Definition *d, const char *text); - void linkIdentifier(CodeOutputInterface &ol,FileDef *fd, + const FileDef *fd,uint &line,uint &column, + const Definition *d, const char *text); + void linkIdentifier(CodeOutputInterface &ol,const FileDef *fd, uint &line,uint &column, const char *text,int tokenIndex); - void linkMacro(CodeOutputInterface &ol,FileDef *fd, + void linkMacro(CodeOutputInterface &ol,const FileDef *fd, uint &line,uint &column, const char *text); - void linkInclude(CodeOutputInterface &ol,FileDef *fd, + void linkInclude(CodeOutputInterface &ol,const FileDef *fd, uint &line,uint &column, const char *text); ClangTUParser(const ClangTUParser &) = delete; diff --git a/src/definition.cpp b/src/definition.cpp index fa3d521..3a47f67 100644 --- a/src/definition.cpp +++ b/src/definition.cpp @@ -314,7 +314,7 @@ void DefinitionImpl::setId(const char *id) if (Doxygen::clangUsrMap) { //printf("DefinitionImpl::setId '%s'->'%s'\n",id,m_impl->name.data()); - Doxygen::clangUsrMap->insert(id,m_impl->def); + Doxygen::clangUsrMap->insert(std::make_pair(id,m_impl->def)); } } diff --git a/src/doxygen.cpp b/src/doxygen.cpp index 4c66014..dea5cac 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -144,7 +144,7 @@ NamespaceDefMutable *Doxygen::globalScope = 0; bool Doxygen::parseSourcesNeeded = FALSE; SearchIndexIntf *Doxygen::searchIndex=0; SymbolMap Doxygen::symbolMap; -QDict *Doxygen::clangUsrMap = 0; +ClangUsrMap *Doxygen::clangUsrMap = 0; bool Doxygen::outputToWizard=FALSE; Cache *Doxygen::lookupCache; DirLinkedMap *Doxygen::dirLinkedMap; @@ -10141,7 +10141,7 @@ void initDoxygen() initFileMemberIndices(); #ifdef USE_LIBCLANG - Doxygen::clangUsrMap = new QDict(50177); + Doxygen::clangUsrMap = new ClangUsrMap; #endif Doxygen::memberNameLinkedMap = new MemberNameLinkedMap; Doxygen::functionNameLinkedMap = new MemberNameLinkedMap; diff --git a/src/doxygen.h b/src/doxygen.h index 2ce27bd..b174698 100644 --- a/src/doxygen.h +++ b/src/doxygen.h @@ -85,9 +85,7 @@ struct LookupInfo QCString resolvedType; }; -extern QCString g_spaces; - -using MemberGroupInfoMap = std::unordered_map< int,std::unique_ptr >; +using ClangUsrMap = std::unordered_map; /*! \brief This class serves as a namespace for global variables used by doxygen. * @@ -124,7 +122,7 @@ class Doxygen static bool parseSourcesNeeded; static SearchIndexIntf *searchIndex; static SymbolMap symbolMap; - static QDict *clangUsrMap; + static ClangUsrMap *clangUsrMap; static bool outputToWizard; static Cache *lookupCache; static DirLinkedMap *dirLinkedMap; diff --git a/src/membergroup.h b/src/membergroup.h index 72e25ed..5b0c621 100644 --- a/src/membergroup.h +++ b/src/membergroup.h @@ -108,7 +108,6 @@ class MemberGroup }; using MemberGroupRefList = std::vector; -//using MemberGroupMap = std::map< int, std::unique_ptr >; using MemberGroupList = std::vector< std::unique_ptr >; /** Data collected for a member group */ @@ -123,4 +122,6 @@ struct MemberGroupInfo RefItemVector m_sli; }; +using MemberGroupInfoMap = std::unordered_map< int,std::unique_ptr >; + #endif -- cgit v0.12