Skip to content

Commit

Permalink
Replaced QList<BaseInfo> with std::vector<BaseInfo>
Browse files Browse the repository at this point in the history
  • Loading branch information
doxygen committed Oct 29, 2019
1 parent e8efa15 commit 94e8899
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 78 deletions.
10 changes: 5 additions & 5 deletions src/commentscan.l
Original file line number Diff line number Diff line change
Expand Up @@ -1824,7 +1824,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
addOutput(yytext);
// we add subpage labels as a kind of "inheritance" relation to prevent
// needing to add another list to the Entry class.
current->extends->append(new BaseInfo(yytext,Public,Normal));
current->extends.push_back(BaseInfo(yytext,Public,Normal));
BEGIN(SubpageTitle);
}
<SubpageLabel>{DOCNL} { // missing argument
Expand Down Expand Up @@ -2224,8 +2224,8 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
/* ----- handle argument of inherit command ------- */

<InheritParam>({ID}("::"|"."))*{ID} { // found argument
current->extends->append(
new BaseInfo(removeRedundantWhiteSpace(yytext),Public,Normal)
current->extends.push_back(
BaseInfo(removeRedundantWhiteSpace(yytext),Public,Normal)
);
BEGIN( Comment );
}
Expand All @@ -2247,8 +2247,8 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
/* ----- handle argument of extends and implements commands ------- */

<ExtendsParam>({ID}("::"|"."))*{ID} { // found argument
current->extends->append(
new BaseInfo(removeRedundantWhiteSpace(yytext),Public,Normal)
current->extends.push_back(
BaseInfo(removeRedundantWhiteSpace(yytext),Public,Normal)
);
BEGIN( Comment );
}
Expand Down
47 changes: 20 additions & 27 deletions src/doxygen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ static bool findClassRelation(
const Entry *root,
Definition *context,
ClassDef *cd,
BaseInfo *bi,
const BaseInfo *bi,
QDict<int> *templateNames,
/*bool insertUndocumented*/
FindBaseClassRelation_Mode mode,
Expand Down Expand Up @@ -502,11 +502,11 @@ static void addSTLClass(const std::unique_ptr<Entry> &root,const STLInfo *info)
}
if (info->baseClass1)
{
classEntry->extends->append(new BaseInfo(info->baseClass1,Public,info->virtualInheritance?Virtual:Normal));
classEntry->extends.push_back(BaseInfo(info->baseClass1,Public,info->virtualInheritance?Virtual:Normal));
}
if (info->baseClass2)
{
classEntry->extends->append(new BaseInfo(info->baseClass2,Public,info->virtualInheritance?Virtual:Normal));
classEntry->extends.push_back(BaseInfo(info->baseClass2,Public,info->virtualInheritance?Virtual:Normal));
}
if (info->iterators)
{
Expand Down Expand Up @@ -4340,20 +4340,18 @@ static void findBaseClassesForClass(
masterCd->setVisited(TRUE);
// The base class could ofcouse also be a non-nested class
const ArgumentList &formalArgs = masterCd->templateArguments();
QListIterator<BaseInfo> bii(*root->extends);
BaseInfo *bi=0;
for (bii.toFirst();(bi=bii.current());++bii)
for (const BaseInfo &bi : root->extends)
{
//printf("masterCd=%s bi->name='%s' #actualArgs=%d\n",
// masterCd->localName().data(),bi->name.data(),actualArgs?(int)actualArgs->count():-1);
bool delTempNames=FALSE;
if (templateNames==0)
{
templateNames = getTemplateArgumentsInName(formalArgs,bi->name);
templateNames = getTemplateArgumentsInName(formalArgs,bi.name);
delTempNames=TRUE;
}
BaseInfo tbi(bi->name,bi->prot,bi->virt);
tbi.name = substituteTemplateArgumentsInString(bi->name,formalArgs,actualArgs);
BaseInfo tbi = bi;
tbi.name = substituteTemplateArgumentsInString(bi.name,formalArgs,actualArgs);
//printf("bi->name=%s tbi.name=%s\n",bi->name.data(),tbi.name.data());

if (mode==DocumentedOnly)
Expand Down Expand Up @@ -4550,7 +4548,7 @@ static bool findClassRelation(
const Entry *root,
Definition *context,
ClassDef *cd,
BaseInfo *bi,
const BaseInfo *bi,
QDict<int> *templateNames,
FindBaseClassRelation_Mode mode,
bool isArtificial
Expand Down Expand Up @@ -4778,13 +4776,13 @@ static bool findClassRelation(
usedName=biName;
//printf("***** usedName=%s templSpec=%s\n",usedName.data(),templSpec.data());
}
static bool sipSupport = Config_getBool(SIP_SUPPORT);
if (sipSupport) bi->prot=Public;
Protection prot = bi->prot;
if (Config_getBool(SIP_SUPPORT)) prot=Public;
if (!cd->isSubClass(baseClass)) // check for recursion, see bug690787
{
cd->insertBaseClass(baseClass,usedName,bi->prot,bi->virt,templSpec);
cd->insertBaseClass(baseClass,usedName,prot,bi->virt,templSpec);
// add this class as super class to the base class
baseClass->insertSubClass(cd,bi->prot,bi->virt,templSpec);
baseClass->insertSubClass(cd,prot,bi->virt,templSpec);
}
else
{
Expand Down Expand Up @@ -4916,8 +4914,8 @@ static bool isClassSection(const Entry *root)
else if (root->section & Entry::COMPOUNDDOC_MASK)
// is it a documentation block with inheritance info.
{
bool extends = root->extends->count()>0;
if (extends) return TRUE;
bool hasExtends = !root->extends.empty();
if (hasExtends) return TRUE;
}
}
return FALSE;
Expand Down Expand Up @@ -5047,18 +5045,15 @@ static void computeTemplateClassRelations()
QCString templSpec = tdi.currentKey();
ArgumentList templArgs;
stringToArgumentList(templSpec,templArgs);
QList<BaseInfo> *baseList=root->extends;
QListIterator<BaseInfo> it(*baseList);
BaseInfo *bi;
for (;(bi=it.current());++it) // for each base class of the template
for (const BaseInfo &bi : root->extends)
{
// check if the base class is a template argument
BaseInfo tbi(bi->name,bi->prot,bi->virt);
BaseInfo tbi = bi;
const ArgumentList &tl = cd->templateArguments();
if (!tl.empty())
{
QDict<int> *baseClassNames = tcd->getTemplateBaseClassNames();
QDict<int> *templateNames = getTemplateArgumentsInName(tl,bi->name);
QDict<int> *templateNames = getTemplateArgumentsInName(tl,bi.name);
// for each template name that we inherit from we need to
// substitute the formal with the actual arguments
QDict<int> *actualTemplateNames = new QDict<int>(17);
Expand All @@ -5085,7 +5080,7 @@ static void computeTemplateClassRelations()
}
delete templateNames;

tbi.name = substituteTemplateArgumentsInString(bi->name,tl,templArgs);
tbi.name = substituteTemplateArgumentsInString(bi.name,tl,templArgs);
// find a documented base class in the correct scope
if (!findClassRelation(root,cd,tcd,&tbi,actualTemplateNames,DocumentedOnly,FALSE))
{
Expand Down Expand Up @@ -8803,11 +8798,9 @@ static void computePageRelations(Entry *root)
Doxygen::mainPage;
if (pd)
{
QListIterator<BaseInfo> bii(*root->extends);
BaseInfo *bi;
for (bii.toFirst();(bi=bii.current());++bii)
for (const BaseInfo &bi : root->extends)
{
PageDef *subPd = Doxygen::pageSDict->find(bi->name);
PageDef *subPd = Doxygen::pageSDict->find(bi.name);
if (pd==subPd)
{
err("page defined at line %d of file %s with label %s is a direct "
Expand Down
15 changes: 2 additions & 13 deletions src/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ Entry::Entry()
num++;
m_parent=0;
section = EMPTY_SEC;
extends = new QList<BaseInfo>;
extends->setAutoDelete(TRUE);
groups = new QList<Grouping>;
groups->setAutoDelete(TRUE);
anchors = new QList<SectionInfo>; // Doxygen::sectionDict takes ownership of the items!
Expand Down Expand Up @@ -103,8 +101,6 @@ Entry::Entry(const Entry &e)
bodyLine = e.bodyLine;
endBodyLine = e.endBodyLine;
mGrpId = e.mGrpId;
extends = new QList<BaseInfo>;
extends->setAutoDelete(TRUE);
groups = new QList<Grouping>;
groups->setAutoDelete(TRUE);
anchors = new QList<SectionInfo>;
Expand Down Expand Up @@ -141,13 +137,7 @@ Entry::Entry(const Entry &e)
m_sublist.push_back(std::make_unique<Entry>(*cur));
}

// deep copy base class list
QListIterator<BaseInfo> bli(*e.extends);
BaseInfo *bi;
for (;(bi=bli.current());++bli)
{
extends->append(new BaseInfo(*bi));
}
extends = e.extends;

// deep copy group list
QListIterator<Grouping> gli(*e.groups);
Expand All @@ -174,7 +164,6 @@ Entry::~Entry()
//printf("Deleting entry %d name %s type %x children %d\n",
// num,name.data(),section,sublist->count());

delete extends;
delete groups;
delete anchors;
delete sli;
Expand Down Expand Up @@ -302,7 +291,7 @@ void Entry::reset()
id.resize(0);
metaData.resize(0);
m_sublist.clear();
extends->clear();
extends.clear();
groups->clear();
anchors->clear();
argList.clear();
Expand Down
2 changes: 1 addition & 1 deletion src/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ class Entry
int bodyLine; //!< line number of the definition in the source
int endBodyLine; //!< line number where the definition ends
int mGrpId; //!< member group id
QList<BaseInfo> *extends; //!< list of base classes
std::vector<BaseInfo> extends; //!< list of base classes
QList<Grouping> *groups; //!< list of groups this entry belongs to
QList<SectionInfo> *anchors; //!< list of anchors defined in this entry
QCString fileName; //!< file this entry was extracted from
Expand Down
2 changes: 1 addition & 1 deletion src/fortranscanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ abstract {
}
extends{ARGS} {
QCString basename = extractFromParens(yytext).lower();
current->extends->append(new BaseInfo(basename, Public, Normal));
current->extends.push_back(BaseInfo(basename, Public, Normal));
}
public {
current->protection = Public;
Expand Down
4 changes: 2 additions & 2 deletions src/pyscanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -1245,8 +1245,8 @@ STARTDOCSYMS "##"
}
{SCOPE} {
current->extends->append(
new BaseInfo(substitute(yytext,".","::"),Public,Normal)
current->extends.push_back(
BaseInfo(substitute(yytext,".","::"),Public,Normal)
);
//Has base class-do stuff
}
Expand Down
12 changes: 6 additions & 6 deletions src/scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -5476,8 +5476,8 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
// there can be only one base class here
if (!baseName.isEmpty())
{
current->extends->append(
new BaseInfo(baseName,Public,Normal));
current->extends.push_back(
BaseInfo(baseName,Public,Normal));
baseName.resize(0);
}
current_root->moveToSubEntryAndRefresh( current ) ;
Expand Down Expand Up @@ -6156,8 +6156,8 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
current->name = removeRedundantWhiteSpace(current->name);
if (!baseName.isEmpty())
{
current->extends->append(
new BaseInfo(baseName,baseProt,baseVirt)
current->extends.push_back(
BaseInfo(baseName,baseProt,baseVirt)
);
}
if ((current->spec & (Entry::Interface|Entry::Struct)) ||
Expand Down Expand Up @@ -6198,8 +6198,8 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
current->startColumn = yyColNr;
current->name = removeRedundantWhiteSpace(current->name);
if (!baseName.isEmpty())
current->extends->append(
new BaseInfo(baseName,baseProt,baseVirt)
current->extends.push_back(
BaseInfo(baseName,baseProt,baseVirt)
);
curlyCount=0;
if (insideObjC)
Expand Down
31 changes: 9 additions & 22 deletions src/tagreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ class TagClassInfo
{
public:
enum Kind { None=-1, Class, Struct, Union, Interface, Exception, Protocol, Category, Enum, Service, Singleton };
TagClassInfo() { bases=0, templateArguments=0; members.setAutoDelete(TRUE); isObjC=FALSE; kind = None; }
~TagClassInfo() { delete bases; delete templateArguments; }
TagClassInfo() { templateArguments=0; members.setAutoDelete(TRUE); isObjC=FALSE; kind = None; }
~TagClassInfo() { delete templateArguments; }
QCString name;
QCString filename;
QCString clangId;
QCString anchor;
TagAnchorInfoList docAnchors;
QList<BaseInfo> *bases;
std::vector<BaseInfo> bases;
QList<TagMemberInfo> members;
QList<QCString> *templateArguments;
QCStringList classList;
Expand Down Expand Up @@ -623,12 +623,7 @@ class TagFileParser : public QXmlDefaultHandler
{
virt = Virtual;
}
if (m_curClass->bases==0)
{
m_curClass->bases = new QList<BaseInfo>;
m_curClass->bases->setAutoDelete(TRUE);
}
m_curClass->bases->append(new BaseInfo(m_curString,prot,virt));
m_curClass->bases.push_back(BaseInfo(m_curString,prot,virt));
}
else
{
Expand All @@ -640,7 +635,7 @@ class TagFileParser : public QXmlDefaultHandler
{
if (m_state==InClass && m_curClass)
{
m_curClass->bases->getLast()->name = m_curString;
m_curClass->bases.back().name = m_curString;
}
else
{
Expand Down Expand Up @@ -990,14 +985,9 @@ void TagFileParser::dump()
{
msg("class '%s'\n",cd->name.data());
msg(" filename '%s'\n",cd->filename.data());
if (cd->bases)
for (const BaseInfo &bi : cd->bases)
{
QListIterator<BaseInfo> bii(*cd->bases);
BaseInfo *bi;
for ( bii.toFirst() ; (bi=bii.current()) ; ++bii)
{
msg( " base: %s \n", bi->name.data() );
}
msg( " base: %s \n", bi.name.data() );
}

QListIterator<TagMemberInfo> mci(cd->members);
Expand Down Expand Up @@ -1344,11 +1334,8 @@ void TagFileParser::buildLists(const std::unique_ptr<Entry> &root)
ce->id = tci->clangId;
ce->lang = tci->isObjC ? SrcLangExt_ObjC : SrcLangExt_Unknown;
// transfer base class list
if (tci->bases)
{
delete ce->extends;
ce->extends = tci->bases; tci->bases = 0;
}
ce->extends = tci->bases;
tci->bases.clear();
if (tci->templateArguments)
{
ArgumentList al;
Expand Down
2 changes: 1 addition & 1 deletion src/tclscanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -2700,7 +2700,7 @@ tcl_inf("->\n");
{
for (unsigned int i = 2; i < tcl.list_commandwords.count(); i = i + 2)
{
tcl.scan.at(0)->entry_cl->extends->append(new BaseInfo((*tcl.list_commandwords.at(i)),Public,Normal));
tcl.scan.at(0)->entry_cl->extends.push_back(BaseInfo((*tcl.list_commandwords.at(i)),Public,Normal));
}
}
goto command_end;
Expand Down

0 comments on commit 94e8899

Please sign in to comment.