summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2020-01-26 15:07:32 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2020-01-26 15:07:32 (GMT)
commit8d49c7c40e59970565872f666e2110755cac7828 (patch)
treee2fd095f7aa69d3768ad61ef54a8d99d3acc8cc3 /src
parentd0a664e8d46808df68fb6a29b2d76f4c6b22a85c (diff)
downloadDoxygen-8d49c7c40e59970565872f666e2110755cac7828.zip
Doxygen-8d49c7c40e59970565872f666e2110755cac7828.tar.gz
Doxygen-8d49c7c40e59970565872f666e2110755cac7828.tar.bz2
Move DocGroup inside CommentScanner instead of using a global
Diffstat (limited to 'src')
-rw-r--r--src/commentscan.h7
-rw-r--r--src/commentscan.l68
-rw-r--r--src/docgroup.cpp11
-rw-r--r--src/docgroup.h2
-rw-r--r--src/doxygen.cpp1
-rw-r--r--src/doxygen.h2
-rw-r--r--src/fortranscanner.l6
-rw-r--r--src/pyscanner.l10
-rw-r--r--src/scanner.l16
-rw-r--r--src/tclscanner.l12
-rw-r--r--src/vhdljjparser.cpp5
11 files changed, 95 insertions, 45 deletions
diff --git a/src/commentscan.h b/src/commentscan.h
index a0ad6d9..be92920 100644
--- a/src/commentscan.h
+++ b/src/commentscan.h
@@ -78,6 +78,13 @@ class CommentScanner
int &position,
bool &newEntryNeeded
);
+ void initGroupInfo(Entry *entry);
+ void enterFile(const char *fileName,int lineNr);
+ void leaveFile(const char *fileName,int lineNr);
+ void enterCompound(const char *fileName,int line,const char *name);
+ void leaveCompound(const char *fileName,int line,const char *name);
+ void open(Entry *e,const char *fileName,int line,bool implicit=false);
+ void close(Entry *e,const char *fileName,int line,bool foundInline,bool implicit=false);
private:
struct Private;
std::unique_ptr<Private> p;
diff --git a/src/commentscan.l b/src/commentscan.l
index a3741e5..a8c024f 100644
--- a/src/commentscan.l
+++ b/src/commentscan.l
@@ -52,6 +52,7 @@
#include "markdown.h"
#include "condparser.h"
#include "formula.h"
+#include "docgroup.h"
#define YY_NO_INPUT 1
#define YY_NO_UNISTD_H 1
@@ -453,6 +454,7 @@ struct commentscanYY_state
bool insideParBlock = FALSE;
bool inInternalDocs = FALSE;
int prevPosition = 0;
+ DocGroup docGroup;
};
//-----------------------------------------------------------------------------
@@ -786,12 +788,12 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
}
<Comment>{B}*{CMD}"{" { // begin of a group
//yyextra->langParser->handleGroupStartCommand(yyextra->memberGroupHeader);
- Doxygen::docGroup.open(yyextra->current,yyextra->fileName,yyextra->lineNr);
+ yyextra->docGroup.open(yyextra->current,yyextra->fileName,yyextra->lineNr);
}
<Comment>{B}*{CMD}"}" { // end of a group
//yyextra->langParser->handleGroupEndCommand();
- Doxygen::docGroup.close(yyextra->current,yyextra->fileName,yyextra->lineNr,TRUE);
- Doxygen::docGroup.clearHeader();
+ yyextra->docGroup.close(yyextra->current,yyextra->fileName,yyextra->lineNr,TRUE);
+ yyextra->docGroup.clearHeader();
yyextra->parseMore=TRUE;
yyextra->needNewEntry = TRUE;
#if YY_FLEX_MAJOR_VERSION>=2 && (YY_FLEX_MINOR_VERSION>5 || (YY_FLEX_MINOR_VERSION==5 && YY_FLEX_SUBMINOR_VERSION>=33))
@@ -1700,10 +1702,10 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
<NameParam>{LC} { // line continuation
yyextra->lineNr++;
addOutput(yyscanner,'\n');
- Doxygen::docGroup.appendHeader(' ');
+ yyextra->docGroup.appendHeader(' ');
}
<NameParam>. { // ignore other stuff
- Doxygen::docGroup.appendHeader(*yytext);
+ yyextra->docGroup.appendHeader(*yytext);
yyextra->current->name+=*yytext;
}
@@ -2164,11 +2166,11 @@ static bool handleName(yyscan_t yyscanner,const QCString &, const QCStringList &
bool stop=makeStructuralIndicator(yyscanner,Entry::MEMBERGRP_SEC);
if (!stop)
{
- Doxygen::docGroup.clearHeader();
+ yyextra->docGroup.clearHeader();
BEGIN( NameParam );
- if (!Doxygen::docGroup.isEmpty()) // end of previous member group
+ if (!yyextra->docGroup.isEmpty()) // end of previous member group
{
- Doxygen::docGroup.close(yyextra->current,yyextra->fileName,yyextra->lineNr,TRUE,true);
+ yyextra->docGroup.close(yyextra->current,yyextra->fileName,yyextra->lineNr,TRUE,true);
}
}
return stop;
@@ -2754,7 +2756,7 @@ static void initParser(yyscan_t yyscanner)
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
yyextra->sectionLabel.resize(0);
yyextra->sectionTitle.resize(0);
- Doxygen::docGroup.clearHeader();
+ yyextra->docGroup.clearHeader();
yyextra->insideParBlock = FALSE;
}
@@ -3322,9 +3324,9 @@ bool CommentScanner::parseCommentBlock(/* in */ OutlineParserInterface *pars
}
if (yyextra->current->section==Entry::MEMBERGRP_SEC &&
- Doxygen::docGroup.isEmpty()) // @name section but no group started yet
+ yyextra->docGroup.isEmpty()) // @name section but no group started yet
{
- Doxygen::docGroup.open(yyextra->current,yyextra->fileName,yyextra->lineNr,true);
+ yyextra->docGroup.open(yyextra->current,yyextra->fileName,yyextra->lineNr,true);
}
Debug::print(Debug::CommentScan,0,"-----------\nCommentScanner: %s:%d\noutput=[\n"
@@ -3338,7 +3340,7 @@ bool CommentScanner::parseCommentBlock(/* in */ OutlineParserInterface *pars
checkFormula(yyscanner);
prot = yyextra->protection;
- Doxygen::docGroup.addDocs(curEntry);
+ yyextra->docGroup.addDocs(curEntry);
newEntryNeeded = yyextra->needNewEntry;
@@ -3391,4 +3393,46 @@ static void handleGuard(yyscan_t yyscanner,const QCString &expr)
}
}
+void CommentScanner::initGroupInfo(Entry *entry)
+{
+ struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
+ yyextra->docGroup.initGroupInfo(entry);
+}
+
+void CommentScanner::enterFile(const char *fileName,int lineNr)
+{
+ struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
+ yyextra->docGroup.enterFile(fileName,lineNr);
+}
+
+void CommentScanner::leaveFile(const char *fileName,int lineNr)
+{
+ struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
+ yyextra->docGroup.leaveFile(fileName,lineNr);
+}
+
+void CommentScanner::enterCompound(const char *fileName,int lineNr,const char *name)
+{
+ struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
+ yyextra->docGroup.enterCompound(fileName,lineNr,name);
+}
+
+void CommentScanner::leaveCompound(const char *fileName,int lineNr,const char *name)
+{
+ struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
+ yyextra->docGroup.leaveCompound(fileName,lineNr,name);
+}
+
+void CommentScanner::open(Entry *e,const char *fileName,int lineNr,bool implicit)
+{
+ struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
+ yyextra->docGroup.open(e,fileName,lineNr,implicit);
+}
+
+void CommentScanner::close(Entry *e,const char *fileName,int lineNr,bool foundInline,bool implicit)
+{
+ struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
+ yyextra->docGroup.close(e,fileName,lineNr,foundInline,implicit);
+}
+
#include "commentscan.l.h"
diff --git a/src/docgroup.cpp b/src/docgroup.cpp
index fbdb842..d82d1b3 100644
--- a/src/docgroup.cpp
+++ b/src/docgroup.cpp
@@ -13,12 +13,14 @@
*
*/
+#include <atomic>
#include "doxygen.h"
#include "util.h"
#include "entry.h"
#include "message.h"
#include "docgroup.h"
+static std::atomic_int g_groupId;
void DocGroup::enterFile(const char *fileName,int)
{
@@ -84,7 +86,7 @@ void DocGroup::leaveCompound(const char *,int,const char * /*name*/)
m_compoundName.resize(0);
}
-int DocGroup::findExistingGroup(int &groupId,const MemberGroupInfo *info)
+int DocGroup::findExistingGroup(const MemberGroupInfo *info)
{
//printf("findExistingGroup %s:%s\n",info->header.data(),info->compoundName.data());
QIntDictIterator<MemberGroupInfo> di(Doxygen::memGrpInfoDict);
@@ -100,8 +102,7 @@ int DocGroup::findExistingGroup(int &groupId,const MemberGroupInfo *info)
return (int)di.currentKey(); // put the item in this group
}
}
- groupId++; // start new group
- return groupId;
+ return ++g_groupId; // start new group
}
void DocGroup::open(Entry *e,const char *,int, bool implicit)
@@ -118,12 +119,10 @@ void DocGroup::open(Entry *e,const char *,int, bool implicit)
//printf(" membergroup id=%d %s\n",m_memberGroupId,m_memberGroupHeader.data());
if (m_memberGroupId==DOX_NOGROUP) // no group started yet
{
- static int curGroupId=0;
-
MemberGroupInfo *info = new MemberGroupInfo;
info->header = m_memberGroupHeader.stripWhiteSpace();
info->compoundName = m_compoundName;
- m_memberGroupId = findExistingGroup(curGroupId,info);
+ m_memberGroupId = findExistingGroup(info);
//printf(" use membergroup %d\n",m_memberGroupId);
Doxygen::memGrpInfoDict.insert(m_memberGroupId,info);
diff --git a/src/docgroup.h b/src/docgroup.h
index 3ccef0d..c724348 100644
--- a/src/docgroup.h
+++ b/src/docgroup.h
@@ -41,7 +41,7 @@ class DocGroup
void addDocs(Entry *e);
private:
- int findExistingGroup(int &groupId,const MemberGroupInfo *info);
+ int findExistingGroup(const MemberGroupInfo *info);
int m_openCount = 0;
QCString m_memberGroupHeader;
int m_memberGroupId = 0;
diff --git a/src/doxygen.cpp b/src/doxygen.cpp
index ab159eb..49c4d5a 100644
--- a/src/doxygen.cpp
+++ b/src/doxygen.cpp
@@ -174,7 +174,6 @@ QCString Doxygen::spaces;
bool Doxygen::generatingXmlOutput = FALSE;
bool Doxygen::markdownSupport = TRUE;
GenericsSDict *Doxygen::genericsDict;
-DocGroup Doxygen::docGroup;
Preprocessor *Doxygen::preprocessor = 0;
// locally accessible globals
diff --git a/src/doxygen.h b/src/doxygen.h
index a23a678..b93ab27 100644
--- a/src/doxygen.h
+++ b/src/doxygen.h
@@ -27,7 +27,6 @@
#include "membergroup.h"
#include "dirdef.h"
#include "memberlist.h"
-#include "docgroup.h"
class RefList;
class PageSList;
@@ -152,7 +151,6 @@ class Doxygen
static bool generatingXmlOutput;
static bool markdownSupport;
static GenericsSDict *genericsDict;
- static DocGroup docGroup;
static Preprocessor *preprocessor;
};
diff --git a/src/fortranscanner.l b/src/fortranscanner.l
index 720548d..ab90996 100644
--- a/src/fortranscanner.l
+++ b/src/fortranscanner.l
@@ -2346,7 +2346,7 @@ static void initEntry(yyscan_t yyscanner)
yyextra->current->virt = Normal;
yyextra->current->stat = FALSE;
yyextra->current->lang = SrcLangExt_Fortran;
- Doxygen::docGroup.initGroupInfo(yyextra->current.get());
+ yyextra->commentScanner.initGroupInfo(yyextra->current.get());
}
/**
@@ -2725,7 +2725,7 @@ static void parseMain(yyscan_t yyscanner, const char *fileName,const char *fileB
yyextra->global_scope = rt.get();
startScope(yyscanner,rt.get()); // implies yyextra->current_root = rt
initParser(yyscanner);
- Doxygen::docGroup.enterFile(yyextra->fileName,yyextra->lineNr);
+ yyextra->commentScanner.enterFile(yyextra->fileName,yyextra->lineNr);
// add entry for the file
yyextra->current = std::make_shared<Entry>();
@@ -2742,7 +2742,7 @@ static void parseMain(yyscan_t yyscanner, const char *fileName,const char *fileB
}
fortranscannerYYlex(yyscanner);
- Doxygen::docGroup.leaveFile(yyextra->fileName,yyextra->lineNr);
+ yyextra->commentScanner.leaveFile(yyextra->fileName,yyextra->lineNr);
if (yyextra->global_scope && yyextra->global_scope != INVALID_ENTRY)
{
diff --git a/src/pyscanner.l b/src/pyscanner.l
index 97f7988..e5f4073 100644
--- a/src/pyscanner.l
+++ b/src/pyscanner.l
@@ -1465,7 +1465,7 @@ static void initEntry(yyscan_t yyscanner)
yyextra->current->virt = yyextra->virt;
yyextra->current->stat = yyextra->stat;
yyextra->current->lang = SrcLangExt_Python;
- Doxygen::docGroup.initGroupInfo(yyextra->current.get());
+ yyextra->commentScanner.initGroupInfo(yyextra->current.get());
yyextra->stat = FALSE;
}
@@ -1766,13 +1766,13 @@ static void parseCompounds(yyscan_t yyscanner,std::shared_ptr<Entry> rt)
initEntry(yyscanner);
QCString name = ce->name;
- Doxygen::docGroup.enterCompound(yyextra->yyFileName,yyextra->yyLineNr,name);
+ yyextra->commentScanner.enterCompound(yyextra->yyFileName,yyextra->yyLineNr,name);
pyscannerYYlex(yyscanner) ;
yyextra->lexInit=TRUE;
ce->program.resize(0);
- Doxygen::docGroup.leaveCompound(yyextra->yyFileName,yyextra->yyLineNr,name);
+ yyextra->commentScanner.leaveCompound(yyextra->yyFileName,yyextra->yyLineNr,name);
}
parseCompounds(yyscanner,ce);
@@ -1830,7 +1830,7 @@ static void parseMain(yyscan_t yyscanner, const char *fileName,const char *fileB
initParser(yyscanner);
- Doxygen::docGroup.enterFile(yyextra->yyFileName,yyextra->yyLineNr);
+ yyextra->commentScanner.enterFile(yyextra->yyFileName,yyextra->yyLineNr);
yyextra->current->reset();
initEntry(yyscanner);
@@ -1839,7 +1839,7 @@ static void parseMain(yyscan_t yyscanner, const char *fileName,const char *fileB
pyscannerYYlex(yyscanner);
yyextra->lexInit=TRUE;
- Doxygen::docGroup.leaveFile(yyextra->yyFileName,yyextra->yyLineNr);
+ yyextra->commentScanner.leaveFile(yyextra->yyFileName,yyextra->yyLineNr);
yyextra->current_root->program.resize(0);
diff --git a/src/scanner.l b/src/scanner.l
index 74a1464..b97eeb4 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -2484,12 +2484,12 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
if (yyextra->previous && yyextra->previous->section==Entry::GROUPDOC_SEC)
{
// link open command to the group defined in the yyextra->previous entry
- Doxygen::docGroup.open(yyextra->previous.get(),yyextra->yyFileName,yyextra->yyLineNr);
+ yyextra->commentScanner.open(yyextra->previous.get(),yyextra->yyFileName,yyextra->yyLineNr);
}
else
{
// link open command to the yyextra->current entry
- Doxygen::docGroup.open(yyextra->current.get(),yyextra->yyFileName,yyextra->yyLineNr);
+ yyextra->commentScanner.open(yyextra->current.get(),yyextra->yyFileName,yyextra->yyLineNr);
}
//yyextra->current = tmp;
initEntry(yyscanner);
@@ -2533,7 +2533,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
}
<FindMembers,FindFields,ReadInitializer>"//"([!/]){B}*{CMD}"}".*|"/*"([!*]){B}*{CMD}"}"[^*]*"*/" {
bool insideEnum = YY_START==FindFields || (YY_START==ReadInitializer && yyextra->lastInitializerContext==FindFields); // see bug746226
- Doxygen::docGroup.close(yyextra->current.get(),yyextra->yyFileName,yyextra->yyLineNr,insideEnum);
+ yyextra->commentScanner.close(yyextra->current.get(),yyextra->yyFileName,yyextra->yyLineNr,insideEnum);
lineCount(yyscanner);
}
<FindMembers>"=" { // in PHP code this could also be due to "<?="
@@ -6638,7 +6638,7 @@ static void initEntry(yyscan_t yyscanner)
yyextra->current->stat = yyextra->stat;
yyextra->current->lang = yyextra->language;
//printf("*** initEntry(yyscanner) yyextra->language=%d\n",yyextra->language);
- Doxygen::docGroup.initGroupInfo(yyextra->current.get());
+ yyextra->commentScanner.initGroupInfo(yyextra->current.get());
yyextra->isTypedef=FALSE;
}
@@ -7150,13 +7150,13 @@ static void parseCompounds(yyscan_t yyscanner,const std::shared_ptr<Entry> &rt)
//memberGroupRelates.resize(0);
//memberGroupInside.resize(0);
QCString name = ce->name;
- Doxygen::docGroup.enterCompound(yyextra->yyFileName,yyextra->yyLineNr,name);
+ yyextra->commentScanner.enterCompound(yyextra->yyFileName,yyextra->yyLineNr,name);
scannerYYlex(yyscanner);
yyextra->lexInit=TRUE;
//forceEndGroup();
- Doxygen::docGroup.leaveCompound(yyextra->yyFileName,yyextra->yyLineNr,name);
+ yyextra->commentScanner.leaveCompound(yyextra->yyFileName,yyextra->yyLineNr,name);
ce->program.resize(0);
@@ -7216,7 +7216,7 @@ static void parseMain(yyscan_t yyscanner,
yyextra->current_root = rt;
initParser(yyscanner);
- Doxygen::docGroup.enterFile(yyextra->yyFileName,yyextra->yyLineNr);
+ yyextra->commentScanner.enterFile(yyextra->yyFileName,yyextra->yyLineNr);
yyextra->current = std::make_shared<Entry>();
//printf("yyextra->current=%p yyextra->current_root=%p\n",yyextra->current,yyextra->current_root);
int sec=guessSection(yyextra->yyFileName);
@@ -7246,7 +7246,7 @@ static void parseMain(yyscan_t yyscanner,
}
//forceEndGroup();
- Doxygen::docGroup.leaveFile(yyextra->yyFileName,yyextra->yyLineNr);
+ yyextra->commentScanner.leaveFile(yyextra->yyFileName,yyextra->yyLineNr);
rt->program.resize(0);
diff --git a/src/tclscanner.l b/src/tclscanner.l
index f845aa9..a92b23e 100644
--- a/src/tclscanner.l
+++ b/src/tclscanner.l
@@ -419,7 +419,7 @@ typedef struct
} tcl_scan;
//* Structure containing all internal global variables.
-static struct
+struct tcl_struct
{
CodeOutputInterface * code; // if set then we are codifying the file
int code_line; // current line of code
@@ -462,7 +462,9 @@ static struct
Protection protection; // current protections state
const MemberDef *memberdef; // contain current MemberDef when codifying
bool collectXRefs;
-} tcl;
+};
+
+static tcl_struct tcl;
// scanner functions
static int yyread(char *buf,int max_size);
@@ -492,7 +494,7 @@ Entry* tcl_entry_new()
myEntry->inbodyFile = tcl.file_name;
myEntry->fileName = tcl.file_name;
myEntry->lang = SrcLangExt_Tcl;
- Doxygen::docGroup.initGroupInfo(myEntry);
+ tcl.commentScanner.initGroupInfo(myEntry);
// collect entries
if (!tcl.code)
{
@@ -2983,7 +2985,7 @@ tcl_inf("%s\n",fileName);
printlex(yy_flex_debug, TRUE, __FILE__, fileName);
msg("Parsing %s...\n",fileName);
- Doxygen::docGroup.enterFile(fileName,yylineno);
+ tcl.commentScanner.enterFile(fileName,yylineno);
tcl_init();
tcl.code = NULL;
@@ -2991,7 +2993,7 @@ tcl_inf("%s\n",fileName);
tcl.this_parser = this;
tcl.entry_main = root.get(); /* toplevel entry */
tcl_parse("","");
- Doxygen::docGroup.leaveFile(tcl.file_name,yylineno);
+ tcl.commentScanner.leaveFile(tcl.file_name,yylineno);
root->program.resize(0);
myFile.close();
printlex(yy_flex_debug, FALSE, __FILE__, fileName);
diff --git a/src/vhdljjparser.cpp b/src/vhdljjparser.cpp
index 2bbd4b5..6e5f318 100644
--- a/src/vhdljjparser.cpp
+++ b/src/vhdljjparser.cpp
@@ -159,9 +159,10 @@ void VHDLOutlineParser::parseInput(const char *fileName,const char *fileBuf,
p->oldEntry = 0;
s->current=std::make_shared<Entry>();
initEntry(s->current.get());
- Doxygen::docGroup.enterFile(fileName,p->yyLineNr);
+ p->commentScanner.enterFile(fileName,p->yyLineNr);
p->lineParse.reserve(200);
p->parseVhdlfile(fileName,fileBuf,inLine);
+ p->commentScanner.leaveFile(fileName,p->yyLineNr);
s->current.reset();
@@ -197,7 +198,7 @@ void VHDLOutlineParser::initEntry(Entry *e)
handleCommentBlock(p->str_doc.doc,p->str_doc.brief);
p->iDocLine=-1;
}
- Doxygen::docGroup.initGroupInfo(e);
+ p->commentScanner.initGroupInfo(e);
}
void VHDLOutlineParser::newEntry()