summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2020-04-29 19:25:24 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2020-04-29 19:25:24 (GMT)
commit6ca67aa0e617816789f2a662c86ad82426377b71 (patch)
tree77a589554e5c9b6df1caefc3a72bb6213ecbf731 /src
parente0e5f733ca5b41365ca76bbba1b7529cd1f24b66 (diff)
downloadDoxygen-6ca67aa0e617816789f2a662c86ad82426377b71.zip
Doxygen-6ca67aa0e617816789f2a662c86ad82426377b71.tar.gz
Doxygen-6ca67aa0e617816789f2a662c86ad82426377b71.tar.bz2
Refactoring: replace Doxygen::namespaceAliasDict by Doxygen::namespaceAliasMap
Diffstat (limited to 'src')
-rw-r--r--src/doxygen.cpp12
-rw-r--r--src/doxygen.h5
-rw-r--r--src/scanner.l16
-rw-r--r--src/util.cpp24
4 files changed, 26 insertions, 31 deletions
diff --git a/src/doxygen.cpp b/src/doxygen.cpp
index dde0f1d..8c72b65 100644
--- a/src/doxygen.cpp
+++ b/src/doxygen.cpp
@@ -134,7 +134,7 @@ FileNameLinkedMap *Doxygen::imageNameLinkedMap = 0; // images
FileNameLinkedMap *Doxygen::dotFileNameLinkedMap = 0; // dot files
FileNameLinkedMap *Doxygen::mscFileNameLinkedMap = 0; // msc files
FileNameLinkedMap *Doxygen::diaFileNameLinkedMap = 0; // dia files
-StringDict Doxygen::namespaceAliasDict(257); // all namespace aliases
+StringMap Doxygen::namespaceAliasMap; // all namespace aliases
StringDict Doxygen::tagDestinationDict(257); // all tag locations
std::unordered_set<std::string> Doxygen::expandAsDefinedSet; // all macros that should be expanded
QIntDict<MemberGroupInfo> Doxygen::memGrpInfoDict(1009); // dictionary of the member groups heading
@@ -267,9 +267,6 @@ void statistics()
//g_excludeNameDict.statistics();
fprintf(stderr,"--- aliasDict stats ----\n");
Doxygen::aliasDict.statistics();
- fprintf(stderr,"--- typedefDict stats ----\n");
- fprintf(stderr,"--- namespaceAliasDict stats ----\n");
- Doxygen::namespaceAliasDict.statistics();
fprintf(stderr,"--- tagDestinationDict stats ----\n");
Doxygen::tagDestinationDict.statistics();
fprintf(stderr,"--- g_compoundKeywordDict stats ----\n");
@@ -4430,10 +4427,10 @@ static bool findClassRelation(
{
// for PHP the "use A\B as C" construct map class C to A::B, so we lookup
// the class name also in the alias mapping.
- QCString *aliasName = Doxygen::namespaceAliasDict[baseClassName];
- if (aliasName) // see if it is indeed a class.
+ auto it = Doxygen::namespaceAliasMap.find(baseClassName.data());
+ if (it!=Doxygen::namespaceAliasMap.end()) // see if it is indeed a class.
{
- baseClass=getClass(*aliasName);
+ baseClass=getClass(it->second.c_str());
found = baseClass!=0 && baseClass!=cd;
}
}
@@ -9722,7 +9719,6 @@ void initDoxygen()
Doxygen::exampleSDict->setAutoDelete(TRUE);
Doxygen::memGrpInfoDict.setAutoDelete(TRUE);
Doxygen::tagDestinationDict.setAutoDelete(TRUE);
- Doxygen::namespaceAliasDict.setAutoDelete(TRUE);
Doxygen::dirRelations.setAutoDelete(TRUE);
Doxygen::genericsDict = new GenericsSDict;
Doxygen::indexList = new IndexList;
diff --git a/src/doxygen.h b/src/doxygen.h
index 8e1354a..30d136f 100644
--- a/src/doxygen.h
+++ b/src/doxygen.h
@@ -24,6 +24,7 @@
#include <set>
#include <unordered_set>
+#include <unordered_map>
#include "ftextstream.h"
#include "sortdict.h"
@@ -84,6 +85,8 @@ struct LookupInfo
QCString resolvedType;
};
+using StringMap = std::unordered_map<std::string,std::string>;
+
extern QCString g_spaces;
/*! \brief This class serves as a namespace for global variables used by doxygen.
@@ -110,7 +113,7 @@ class Doxygen
static MemberNameLinkedMap *memberNameLinkedMap;
static MemberNameLinkedMap *functionNameLinkedMap;
static QStrList tagfileList;
- static StringDict namespaceAliasDict;
+ static StringMap namespaceAliasMap;
static GroupSDict *groupSDict;
static NamespaceSDict *namespaceSDict;
static StringDict tagDestinationDict;
diff --git a/src/scanner.l b/src/scanner.l
index dff6f54..8ceb4ad 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -1642,17 +1642,9 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
}
<NSAliasArg>({ID}"::")*{ID} {
//printf("Inserting namespace alias %s::%s->%s\n",yyextra->current_root->name.data(),yyextra->aliasName.data(),yytext);
- //if (yyextra->current_root->name.isEmpty())
- //{
// TODO: namespace aliases are now treated as global entities
// while they should be aware of the scope they are in
- Doxygen::namespaceAliasDict.insert(yyextra->aliasName,new QCString(yytext));
- //}
- //else
- //{
- // Doxygen::namespaceAliasDict.insert(yyextra->current_root->name+"::"+yyextra->aliasName,
- // new QCString(yyextra->current_root->name+"::"+yytext));
- //}
+ Doxygen::namespaceAliasMap.insert({yyextra->aliasName.data(),std::string(yytext)});
}
<NSAliasArg>";" {
BEGIN( FindMembers );
@@ -1685,9 +1677,9 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
//printf("PHP: adding use as relation: %s->%s\n",yytext,yyextra->aliasName.data());
if (!yyextra->aliasName.isEmpty())
{
- Doxygen::namespaceAliasDict.insert(yytext,
- new QCString(removeRedundantWhiteSpace(
- substitute(yyextra->aliasName,"\\","::"))));
+ Doxygen::namespaceAliasMap.insert({yytext,
+ std::string(removeRedundantWhiteSpace(
+ substitute(yyextra->aliasName,"\\","::")).data())});
}
yyextra->aliasName.resize(0);
}
diff --git a/src/util.cpp b/src/util.cpp
index 429d3b0..9e6605a 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -482,21 +482,22 @@ ClassDef *getClass(const char *n)
NamespaceDef *getResolvedNamespace(const char *name)
{
if (name==0 || name[0]=='\0') return 0;
- QCString *subst = Doxygen::namespaceAliasDict[name];
- if (subst)
+ auto it = Doxygen::namespaceAliasMap.find(name);
+ if (it!=Doxygen::namespaceAliasMap.end())
{
int count=0; // recursion detection guard
- QCString *newSubst;
- while ((newSubst=Doxygen::namespaceAliasDict[*subst]) && count<10)
+ StringMap::iterator it2;
+ while ((it2=Doxygen::namespaceAliasMap.find(it->second))!=Doxygen::namespaceAliasMap.end() &&
+ count<10)
{
- subst=newSubst;
+ it=it2;
count++;
}
if (count==10)
{
warn_uncond("possible recursive namespace alias detected for %s!\n",name);
}
- return Doxygen::namespaceSDict->find(subst->data());
+ return Doxygen::namespaceSDict->find(it->second.data());
}
else
{
@@ -6619,11 +6620,14 @@ void replaceNamespaceAliases(QCString &scope,int i)
while (i>0)
{
QCString ns = scope.left(i);
- QCString *s = Doxygen::namespaceAliasDict[ns];
- if (s)
+ if (!ns.isEmpty())
{
- scope=*s+scope.right(scope.length()-i);
- i=s->length();
+ auto it = Doxygen::namespaceAliasMap.find(ns.data());
+ if (it!=Doxygen::namespaceAliasMap.end())
+ {
+ scope=it->second.data()+scope.right(scope.length()-i);
+ i=it->second.length();
+ }
}
if (i>0 && ns==scope.left(i)) break;
}