diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2019-11-01 15:53:14 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-01 15:53:14 (GMT) |
commit | 33a02462fcadbf2e94381b88aff2d13d904d8529 (patch) | |
tree | a5ea5ecf6a82b16a366a6c881ce6d1a6067fd04f /src | |
parent | 23d8bd36a5b8eb1f4d913b50db31a567a63ad994 (diff) | |
parent | 0f01005b90986347e57a78c58585aea959da72a1 (diff) | |
download | Doxygen-33a02462fcadbf2e94381b88aff2d13d904d8529.zip Doxygen-33a02462fcadbf2e94381b88aff2d13d904d8529.tar.gz Doxygen-33a02462fcadbf2e94381b88aff2d13d904d8529.tar.bz2 |
Merge branch 'master' into feature/bug_param_missing_warn
Diffstat (limited to 'src')
70 files changed, 2833 insertions, 3932 deletions
diff --git a/src/arguments.cpp b/src/arguments.cpp index 6d3e13b..69636f5 100644 --- a/src/arguments.cpp +++ b/src/arguments.cpp @@ -1,39 +1,25 @@ +/***************************************************************************** + * Copyright (C) 1997-2019 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + * Documents produced by Doxygen are derivative works derived from the + * input used in their production; they are not affected by this license. + */ + +#include <algorithm> + #include "arguments.h" -#include <assert.h> /*! the argument list is documented if one of its - * arguments is documented + * arguments is documented */ bool ArgumentList::hasDocumentation() const { - bool hasDocs=FALSE; - ArgumentListIterator ali(*this); - Argument *a; - for (ali.toFirst();!hasDocs && (a=ali.current());++ali) - { - hasDocs = a->hasDocumentation(); - } - return hasDocs; -} - -ArgumentList *ArgumentList::deepCopy() const -{ - ArgumentList *argList = new ArgumentList; - argList->setAutoDelete(TRUE); - - QListIterator<Argument> ali(*this); - Argument *a; - for (;(a=ali.current());++ali) - { - argList->append(new Argument(*a)); - } - argList->constSpecifier = constSpecifier; - argList->volatileSpecifier = volatileSpecifier; - argList->pureSpecifier = pureSpecifier; - argList->trailingReturnType = trailingReturnType; - argList->isDeleted = isDeleted; - argList->refQualifier = refQualifier; - - return argList; + return std::any_of(begin(),end(),[](const Argument &a){ return a.hasDocumentation(); }); } diff --git a/src/arguments.h b/src/arguments.h index 7ef9642..3464def 100644 --- a/src/arguments.h +++ b/src/arguments.h @@ -16,45 +16,15 @@ #ifndef ARGUMENTS_H #define ARGUMENTS_H -#include <qlist.h> +#include <vector> #include <qcstring.h> -class StorageIntf; - /*! \brief This class contains the information about the argument of a * function or template * */ struct Argument { - /*! Construct a new argument. */ - Argument() {} - /*! Copy an argument (does a deep copy of all strings). */ - Argument(const Argument &a) - { - attrib=a.attrib; - type=a.type; - name=a.name; - array=a.array; - defval=a.defval; - docs=a.docs; - typeConstraint=a.typeConstraint; - } - /*! Assignment of an argument (does a deep copy of all strings). */ - Argument &operator=(const Argument &a) - { - if (this!=&a) - { - attrib=a.attrib; - type=a.type; - name=a.name; - array=a.array; - defval=a.defval; - docs=a.docs; - typeConstraint=a.typeConstraint; - } - return *this; - } /*! return TRUE if this argument is documentation and the argument has a * non empty name. */ @@ -86,37 +56,42 @@ enum RefQualifierType * put after the argument list, such as whether the member is const, * volatile or pure virtual. */ -class ArgumentList : public QList<Argument> +class ArgumentList : public std::vector<Argument> { public: - /*! Creates an empty argument list */ - ArgumentList() : QList<Argument>(), - constSpecifier(FALSE), - volatileSpecifier(FALSE), - pureSpecifier(FALSE), - isDeleted(FALSE), - refQualifier(RefQualifierNone) - { setAutoDelete(TRUE); } - /*! Destroys the argument list */ - ~ArgumentList() {} - /*! Makes a deep copy of this object */ - ArgumentList *deepCopy() const; /*! Does any argument of this list have documentation? */ bool hasDocumentation() const; - /*! Does the member modify the state of the class? default: FALSE. */ - bool constSpecifier; - /*! Is the member volatile? default: FALSE. */ - bool volatileSpecifier; - /*! Is this a pure virtual member? default: FALSE */ - bool pureSpecifier; + /*! Does this list have zero or more parameters */ + bool hasParameters() const + { + return !empty() || noParameters; + } + void reset() + { + clear(); + constSpecifier = FALSE; + volatileSpecifier = FALSE; + pureSpecifier = FALSE; + trailingReturnType.resize(0); + isDeleted = FALSE; + refQualifier = RefQualifierNone; + noParameters = FALSE; + } + + /*! Does the member modify the state of the class? */ + bool constSpecifier = FALSE; + /*! Is the member volatile? */ + bool volatileSpecifier = FALSE; + /*! Is this a pure virtual member? */ + bool pureSpecifier = FALSE; /*! C++11 style Trailing return type? */ QCString trailingReturnType; /*! method with =delete */ - bool isDeleted; + bool isDeleted = FALSE; /*! C++11 ref qualifier */ - RefQualifierType refQualifier; + RefQualifierType refQualifier = RefQualifierNone; + /*! is it an explicit empty list */ + bool noParameters = FALSE; }; -typedef QListIterator<Argument> ArgumentListIterator; - #endif diff --git a/src/cite.cpp b/src/cite.cpp index 42f695f..e3314ca 100644 --- a/src/cite.cpp +++ b/src/cite.cpp @@ -296,7 +296,7 @@ void CiteDict::generatePage() const // 7. add it as a page addRelatedPage(CiteConsts::fileName, - theTranslator->trCiteReferences(),doc,0,CiteConsts::fileName,1,0,0,0); + theTranslator->trCiteReferences(),doc,CiteConsts::fileName,1); // 8. for latex we just copy the bib files to the output and let // latex do this work. diff --git a/src/classdef.cpp b/src/classdef.cpp index 7548c6c..7ce6bf1 100644 --- a/src/classdef.cpp +++ b/src/classdef.cpp @@ -87,7 +87,7 @@ class ClassDefImpl : public DefinitionImpl, public ClassDef virtual bool isLinkable() const; virtual bool isVisibleInHierarchy() const; virtual bool visibleInParentsDeclList() const; - virtual ArgumentList *templateArguments() const; + virtual const ArgumentList &templateArguments() const; virtual NamespaceDef *getNamespaceDef() const; virtual FileDef *getFileDef() const; virtual MemberDef *getMemberByName(const QCString &) const; @@ -104,9 +104,9 @@ class ClassDefImpl : public DefinitionImpl, public ClassDef virtual ConstraintClassDict *templateTypeConstraints() const; virtual bool isTemplateArgument() const; virtual Definition *findInnerCompound(const char *name) const; - virtual void getTemplateParameterLists(QList<ArgumentList> &lists) const; + virtual std::vector<ArgumentList> getTemplateParameterLists() const; virtual QCString qualifiedNameWithTemplateParameters( - QList<ArgumentList> *actualParams=0,int *actualParamIndex=0) const; + const std::vector<ArgumentList> *actualParams=0,int *actualParamIndex=0) const; virtual bool isAbstract() const; virtual bool isObjectiveC() const; virtual bool isFortran() const; @@ -138,7 +138,7 @@ class ClassDefImpl : public DefinitionImpl, public ClassDef virtual QCString title() const; virtual QCString generatedFromFiles() const; virtual const FileList &usedFiles() const; - virtual const ArgumentList *typeConstraints() const; + virtual const ArgumentList &typeConstraints() const; virtual const ExampleSDict *exampleList() const; virtual bool hasExamples() const; virtual QCString getMemberListFileName() const; @@ -167,10 +167,10 @@ class ClassDefImpl : public DefinitionImpl, public ClassDef virtual void setCompoundType(CompoundType t); virtual void setClassName(const char *name); virtual void setClassSpecifier(uint64 spec); - virtual void setTemplateArguments(ArgumentList *al); + virtual void setTemplateArguments(const ArgumentList &al); virtual void setTemplateBaseClassNames(QDict<int> *templateNames); virtual void setTemplateMaster(const ClassDef *tm); - virtual void setTypeConstraints(ArgumentList *al); + virtual void setTypeConstraints(const ArgumentList &al); virtual void addMembersToTemplateInstance(const ClassDef *cd,const char *templSpec); virtual void makeTemplateArgument(bool b=TRUE); virtual void setCategoryOf(ClassDef *cd); @@ -332,7 +332,7 @@ class ClassDefAliasImpl : public DefinitionAliasImpl, public ClassDef { return getCdAlias()->isVisibleInHierarchy(); } virtual bool visibleInParentsDeclList() const { return getCdAlias()->visibleInParentsDeclList(); } - virtual ArgumentList *templateArguments() const + virtual const ArgumentList &templateArguments() const { return getCdAlias()->templateArguments(); } virtual NamespaceDef *getNamespaceDef() const { return getCdAlias()->getNamespaceDef(); } @@ -366,10 +366,10 @@ class ClassDefAliasImpl : public DefinitionAliasImpl, public ClassDef { return getCdAlias()->isTemplateArgument(); } virtual Definition *findInnerCompound(const char *name) const { return getCdAlias()->findInnerCompound(name); } - virtual void getTemplateParameterLists(QList<ArgumentList> &lists) const - { return getCdAlias()->getTemplateParameterLists(lists); } + virtual std::vector<ArgumentList> getTemplateParameterLists() const + { return getCdAlias()->getTemplateParameterLists(); } virtual QCString qualifiedNameWithTemplateParameters( - QList<ArgumentList> *actualParams=0,int *actualParamIndex=0) const + const std::vector<ArgumentList> *actualParams=0,int *actualParamIndex=0) const { return getCdAlias()->qualifiedNameWithTemplateParameters(actualParams,actualParamIndex); } virtual bool isAbstract() const { return getCdAlias()->isAbstract(); } @@ -433,7 +433,7 @@ class ClassDefAliasImpl : public DefinitionAliasImpl, public ClassDef { return getCdAlias()->generatedFromFiles(); } virtual const FileList &usedFiles() const { return getCdAlias()->usedFiles(); } - virtual const ArgumentList *typeConstraints() const + virtual const ArgumentList &typeConstraints() const { return getCdAlias()->typeConstraints(); } virtual const ExampleSDict *exampleList() const { return getCdAlias()->exampleList(); } @@ -470,10 +470,10 @@ class ClassDefAliasImpl : public DefinitionAliasImpl, public ClassDef virtual void setCompoundType(CompoundType t) {} virtual void setClassName(const char *name) {} virtual void setClassSpecifier(uint64 spec) {} - virtual void setTemplateArguments(ArgumentList *al) {} + virtual void setTemplateArguments(const ArgumentList &al) {} virtual void setTemplateBaseClassNames(QDict<int> *templateNames) {} virtual void setTemplateMaster(const ClassDef *tm) {} - virtual void setTypeConstraints(ArgumentList *al) {} + virtual void setTypeConstraints(const ArgumentList &al) {} virtual void addMembersToTemplateInstance(const ClassDef *cd,const char *templSpec) {} virtual void makeTemplateArgument(bool b=TRUE) {} virtual void setCategoryOf(ClassDef *cd) {} @@ -586,10 +586,10 @@ class ClassDefImpl::IMPL MemberNameInfoSDict *allMemberNameInfoSDict; /*! Template arguments of this class */ - ArgumentList *tempArgs; + ArgumentList tempArgs; /*! Type constraints for template parameters */ - ArgumentList *typeConstraints; + ArgumentList typeConstraints; /*! Files that were used for generating the class documentation. */ FileList files; @@ -710,8 +710,6 @@ void ClassDefImpl::IMPL::init(const char *defFileName, const char *name, inheritedBy = 0; allMemberNameInfoSDict = 0; incInfo=0; - tempArgs=0; - typeConstraints=0; prot=Public; nspace=0; fileDef=0; @@ -777,8 +775,6 @@ ClassDefImpl::IMPL::~IMPL() delete templateInstances; delete variableInstances; delete templBaseClassNames; - delete tempArgs; - delete typeConstraints; delete taggedInnerClasses; } @@ -1376,7 +1372,7 @@ void ClassDefImpl::setIncludeFile(FileDef *fd, //} static void searchTemplateSpecs(/*in*/ const Definition *d, - /*out*/ QList<ArgumentList> &result, + /*out*/ std::vector<ArgumentList> &result, /*out*/ QCString &name, /*in*/ SrcLangExt lang) { @@ -1395,9 +1391,9 @@ static void searchTemplateSpecs(/*in*/ const Definition *d, } name+=clName; bool isSpecialization = d->localName().find('<')!=-1; - if (cd->templateArguments()) + if (!cd->templateArguments().empty()) { - result.append(cd->templateArguments()); + result.push_back(cd->templateArguments()); if (!isSpecialization) { name+=tempArgListToString(cd->templateArguments(),lang); @@ -1413,35 +1409,32 @@ static void searchTemplateSpecs(/*in*/ const Definition *d, static void writeTemplateSpec(OutputList &ol,const Definition *d, const QCString &type,SrcLangExt lang) { - QList<ArgumentList> specs; + std::vector<ArgumentList> specs; QCString name; searchTemplateSpecs(d,specs,name,lang); - if (specs.count()>0) // class has template scope specifiers + if (!specs.empty()) // class has template scope specifiers { ol.startSubsubsection(); - QListIterator<ArgumentList> spi(specs); - ArgumentList *al; - for (spi.toFirst();(al=spi.current());++spi) + for (const ArgumentList &al : specs) { ol.docify("template<"); - QListIterator<Argument> ali(*al); - Argument *a; - while ((a=ali.current())) + auto it = al.begin(); + while (it!=al.end()) { - ol.docify(a->type); - if (!a->name.isEmpty()) + Argument a = *it; + ol.docify(a.type); + if (!a.name.isEmpty()) { ol.docify(" "); - ol.docify(a->name); + ol.docify(a.name); } - if (a->defval.length()!=0) + if (a.defval.length()!=0) { ol.docify(" = "); - ol.docify(a->defval); + ol.docify(a.defval); } - ++ali; - a=ali.current(); - if (a) ol.docify(", "); + ++it; + if (it!=al.end()) ol.docify(", "); } ol.docify(">"); ol.lineBreak(); @@ -2268,14 +2261,9 @@ void ClassDefImpl::writeTagFile(FTextStream &tagFile) { tagFile << " <clangid>" << convertToXML(idStr) << "</clangid>" << endl; } - if (m_impl->tempArgs) + for (const Argument &a : m_impl->tempArgs) { - ArgumentListIterator ali(*m_impl->tempArgs); - Argument *a; - for (;(a=ali.current());++ali) - { - tagFile << " <templarg>" << convertToXML(a->name) << "</templarg>" << endl; - } + tagFile << " <templarg>" << convertToXML(a.name) << "</templarg>" << endl; } if (m_impl->inherits) { @@ -2816,7 +2804,7 @@ QCString ClassDefImpl::title() const { pageTitle = theTranslator->trCompoundReferenceFortran(displayName(), m_impl->compType, - m_impl->tempArgs != 0); + !m_impl->tempArgs.empty()); } else if (lang==SrcLangExt_Slice) { @@ -2850,7 +2838,7 @@ QCString ClassDefImpl::title() const { pageTitle = theTranslator->trCompoundReference(displayName(), m_impl->compType == Interface && getLanguage()==SrcLangExt_ObjC ? Class : m_impl->compType, - m_impl->tempArgs != 0); + !m_impl->tempArgs.empty()); } } return pageTitle; @@ -3362,55 +3350,33 @@ void ClassDefImpl::addTypeConstraint(const QCString &typeConstraint,const QCStri // Java Type Constrains: A<T extends C & I> void ClassDefImpl::addTypeConstraints() { - if (m_impl->tempArgs) + for (const Argument &a : m_impl->tempArgs) { - ArgumentListIterator ali(*m_impl->tempArgs); - Argument *a; - for (;(a=ali.current());++ali) + if (!a.typeConstraint.isEmpty()) { - if (!a->typeConstraint.isEmpty()) + QCString typeConstraint; + int i=0,p=0; + while ((i=a.typeConstraint.find('&',p))!=-1) // typeConstraint="A &I" for C<T extends A & I> { - QCString typeConstraint; - int i=0,p=0; - while ((i=a->typeConstraint.find('&',p))!=-1) // typeConstraint="A &I" for C<T extends A & I> - { - typeConstraint = a->typeConstraint.mid(p,i-p).stripWhiteSpace(); - addTypeConstraint(typeConstraint,a->type); - p=i+1; - } - typeConstraint = a->typeConstraint.right(a->typeConstraint.length()-p).stripWhiteSpace(); - addTypeConstraint(typeConstraint,a->type); + typeConstraint = a.typeConstraint.mid(p,i-p).stripWhiteSpace(); + addTypeConstraint(typeConstraint,a.type); + p=i+1; } + typeConstraint = a.typeConstraint.right(a.typeConstraint.length()-p).stripWhiteSpace(); + addTypeConstraint(typeConstraint,a.type); } } } // C# Type Constraints: D<T> where T : C, I -void ClassDefImpl::setTypeConstraints(ArgumentList *al) +void ClassDefImpl::setTypeConstraints(const ArgumentList &al) { - if (al==0) return; - if (!m_impl->typeConstraints) delete m_impl->typeConstraints; - m_impl->typeConstraints = new ArgumentList; - ArgumentListIterator ali(*al); - Argument *a; - for (;(a=ali.current());++ali) - { - m_impl->typeConstraints->append(new Argument(*a)); - } + m_impl->typeConstraints = al; } -void ClassDefImpl::setTemplateArguments(ArgumentList *al) +void ClassDefImpl::setTemplateArguments(const ArgumentList &al) { - if (al==0) return; - if (m_impl->tempArgs) delete m_impl->tempArgs; // delete old list if needed - //printf("setting template args '%s' for '%s'\n",tempArgListToString(al,getLanguage()).data(),name().data()); - m_impl->tempArgs=new ArgumentList; - ArgumentListIterator ali(*al); - Argument *a; - for (;(a=ali.current());++ali) - { - m_impl->tempArgs->append(new Argument(*a)); - } + m_impl->tempArgs = al; } /*! Returns \c TRUE iff this class or a class inheriting from this class @@ -3704,8 +3670,8 @@ void ClassDefImpl::mergeMembers() if (srcCd==dstCd || dstCd->isBaseClass(srcCd,TRUE)) // member is in the same or a base class { - const ArgumentList *srcAl = srcMd->argumentList(); - const ArgumentList *dstAl = dstMd->argumentList(); + ArgumentList &srcAl = srcMd->argumentList(); + ArgumentList &dstAl = dstMd->argumentList(); found=matchArguments2( srcMd->getOuterScope(),srcMd->getFileDef(),srcAl, dstMd->getOuterScope(),dstMd->getFileDef(),dstAl, @@ -4099,203 +4065,6 @@ void ClassDefImpl::addUsedByClass(ClassDef *cd,const char *accessName, } -#if 0 -/*! Builds up a dictionary of all classes that are used by the state of this - * class (the "implementation"). - * Must be called before mergeMembers() is called! - */ - -void ClassDefImpl::determineImplUsageRelation() -{ - MemberNameInfoSDict::Iterator mnili(*m_impl->allMemberNameInfoSDict); - MemberNameInfo *mni; - for (;(mni=mnili.current());++mnili) - { - MemberNameInfoIterator mnii(*mni); - MemberInfo *mi; - for (mnii.toFirst();(mi=mnii.current());++mnii) - { - MemberDef *md=mi->memberDef; - if (md->isVariable()) // for each member variable in this class - { - QCString type=removeRedundantWhiteSpace(md->typeString()); - //printf("in class %s found var type='%s' name='%s'\n", - // name().data(),type.data(),md->name().data()); - int pos=0; - QCString usedClassName; - QCString templSpec; - bool found=FALSE; - while (extractClassNameFromType(type,pos,usedClassName,templSpec)!=-1 && !found) - { - //printf("usedClassName='%s' templSpec=%s\n",usedClassName.data(),templSpec.data()); - // check if usedClassName is a template argument of its class - ClassDef *cd=md->getClassDef(); - if (cd && cd->templateArguments()) - { - ArgumentListIterator ali(*cd->templateArguments()); - Argument *arg; - int count=0; - for (ali.toFirst();(arg=ali.current());++ali,++count) - { - if (arg->name==usedClassName) // type is a template argument - { - found=TRUE; - if (m_impl->usesImplClassDict==0) m_impl->usesImplClassDict = new UsesClassDict(257); - cd = new ClassDef(cd->getDefFileName(),cd->getDefLine(), - usedClassName,ClassDef::Class); - cd->setIsTemplateBaseClass(count); - UsesClassDef *ucd = new UsesClassDef(cd); - m_impl->usesImplClassDict->insert(cd->name(),ucd); - ucd->templSpecifiers = templSpec; - ucd->addAccessor(md->name()); - Doxygen::hiddenClasses.append(cd); - //printf("Adding used template argument %s to class %s\n", - // cd->name().data(),name().data()); - //printf("Adding accessor %s to class %s\n", - // md->name().data(),ucd->classDef->name().data()); - } - } - } - - if (!found) - { - cd=0; - if (getNamespaceDef()!=0) - { - cd=getResolvedClass(getNamespaceDef()->name()+"::"+usedClassName,0,&templSpec); - } - if (cd==0) cd=getResolvedClass(name()+"::"+usedClassName,0,&templSpec); - if (cd==0) cd=getResolvedClass(usedClassName,0,&templSpec); // TODO: also try in-between scopes! - //printf("Search for class %s result=%p\n",usedClassName.data(),cd); - if (cd) // class exists - { - found=TRUE; - if (m_impl->usesImplClassDict==0) - { - m_impl->usesImplClassDict = new UsesClassDict(257); - m_impl->usesImplClassDict->setAutoDelete(TRUE); - } - UsesClassDef *ucd=m_impl->usesImplClassDict->find(cd->name()); - if (ucd==0 || ucd->templSpecifiers!=templSpec) - { - ucd = new UsesClassDef(cd); - m_impl->usesImplClassDict->insert(cd->name(),ucd); - ucd->templSpecifiers = templSpec; - //printf("Adding used class %s to class %s\n", - // cd->name().data(),name().data()); - } - ucd->addAccessor(md->name()); - //printf("Adding accessor %s to class %s\n", - // md->name().data(),ucd->classDef->name().data()); - } - } - } - } - } - } -#ifdef DUMP - if (m_impl->usesClassDict) - { - msg("Class %s uses the following classes:\n",name().data()); - UsesClassDictIterator ucdi(*m_impl->usesClassDict); - UsesClassDef *ucd; - for (;(ucd=ucdi.current());++ucdi) - { - msg(" %s via ",ucd->classDef->name().data()); - QDictIterator<void> dvi(*ucd->accessors); - const char *s; - for (;(s=dvi.currentKey());++dvi) - { - msg("%s ",s); - } - msg("\n"); - } - } -#endif -} - -//---------------------------------------------------------------------------- - -// I have disabled this code because the graphs it renders quickly become -// too large to be of practical use. - -void ClassDefImpl::addUsedInterfaceClasses(MemberDef *md,const char *typeStr) -{ - QCString type = typeStr; - static const QRegExp re("[a-z_A-Z][a-z_A-Z0-9:]*"); - int p=0,i,l; - while ((i=re.match(type,p,&l))!=-1) // for each class name in the type - { - ClassDef *cd=getClass(name()+"::"+type.mid(i,l)); - if (cd==0) cd=getClass(type.mid(i,l)); // TODO: also try in-between scopes! - if (cd && cd!=this && !isBaseClass(cd)) - { - if (m_impl->usesIntfClassDict==0) - { - m_impl->usesIntfClassDict = new UsesClassDict(257); - } - UsesClassDef *ucd=m_impl->usesIntfClassDict->find(cd->name()); - if (ucd==0) - { - ucd = new UsesClassDef(cd); - m_impl->usesIntfClassDict->insert(cd->name(),ucd); - //printf("in class '%s' adding used intf class '%s'\n", - // name().data(),cd->name().data()); - } - ucd->addAccessor(md->name()); - //printf("in class '%s' adding accessor '%s' to class '%s'\n", - // name().data(),md->name().data(),ucd->classDef->name().data()); - } - p=i+l; - } -} - -void ClassDefImpl::determineIntfUsageRelation() -{ - MemberNameInfoSDict::Iterator mnili(*m_impl->allMemberNameInfoList); - MemberNameInfo *mni; - for (;(mni=mnili.current());++mnili) - { - MemberNameInfoIterator mnii(*mni); - MemberInfo *mi; - for (mnii.toFirst();(mi=mnii.current());++mnii) - { - MemberDef *md=mi->memberDef; - - // compute the protection level for this member - Protection protect=md->protection(); - if (mi->prot==Protected) // inherited protection - { - if (protect==Public) protect=Protected; - else if (protect==Protected) protect=Private; - } - - if (!md->name().isEmpty() && md->name()[0]!='@' && - (mi->prot!=Private && protect!=Private) - ) - { - // add classes found in the return type - addUsedInterfaceClasses(md,md->typeString()); - ArgumentList *al = md->argumentList(); - if (al) // member has arguments - { - // add classes found in the types of the argument list - ArgumentListIterator ali(*al); - Argument *a; - for (;(a=ali.current());++ali) - { - if (!a->type.isEmpty() && a->type.at(0)!='@') - { - addUsedInterfaceClasses(md,a->type); - } - } - } - } - } - } -} -#endif - QCString ClassDefImpl::compoundTypeString() const { if (getLanguage()==SrcLangExt_Fortran) @@ -4431,46 +4200,6 @@ Definition *ClassDefImpl::findInnerCompound(const char *name) const return result; } -//void ClassDefImpl::initTemplateMapping() -//{ -// m_impl->templateMapping->clear(); -// ArgumentList *al = templateArguments(); -// if (al) -// { -// ArgumentListIterator ali(*al); -// Argument *arg; -// for (ali.toFirst();(arg=ali.current());++ali) -// { -// setTemplateArgumentMapping(arg->name,arg->defval); -// } -// } -//} -//void ClassDefImpl::setTemplateArgumentMapping(const char *formal,const char *actual) -//{ -// //printf("ClassDefImpl::setTemplateArgumentMapping(%s,%s)\n",formal,actual); -// if (m_impl->templateMapping && formal) -// { -// if (m_impl->templateMapping->find(formal)) -// { -// m_impl->templateMapping->remove(formal); -// } -// m_impl->templateMapping->insert(formal,new QCString(actual)); -// } -//} -// -//QCString ClassDefImpl::getTemplateArgumentMapping(const char *formal) const -//{ -// if (m_impl->templateMapping && formal) -// { -// QCString *s = m_impl->templateMapping->find(formal); -// if (s) -// { -// return *s; -// } -// } -// return ""; -//} - ClassDef *ClassDefImpl::insertTemplateInstance(const QCString &fileName, int startLine, int startColumn, const QCString &templSpec,bool &freshInstance) const { @@ -4552,12 +4281,11 @@ void ClassDefImpl::addMembersToTemplateInstance(const ClassDef *cd,const char *t MemberInfo *mi; for (mnii.toFirst();(mi=mnii.current());++mnii) { - ArgumentList *actualArguments = new ArgumentList; + ArgumentList actualArguments; stringToArgumentList(templSpec,actualArguments); MemberDef *md = mi->memberDef; MemberDef *imd = md->createTemplateInstanceMember( cd->templateArguments(),actualArguments); - delete actualArguments; //printf("%s->setMemberClass(%p)\n",imd->name().data(),this); imd->setMemberClass(this); imd->setTemplateMaster(md); @@ -4607,25 +4335,24 @@ bool ClassDefImpl::isReference() const } } -void ClassDefImpl::getTemplateParameterLists(QList<ArgumentList> &lists) const +std::vector<ArgumentList> ClassDefImpl::getTemplateParameterLists() const { + std::vector<ArgumentList> result; Definition *d=getOuterScope(); - if (d) + while (d && d->definitionType()==Definition::TypeClass) { - if (d->definitionType()==Definition::TypeClass) - { - ClassDef *cd=dynamic_cast<ClassDef *>(d); - cd->getTemplateParameterLists(lists); - } + result.insert(result.begin(),dynamic_cast<ClassDef*>(d)->templateArguments()); + d = d->getOuterScope(); } - if (templateArguments()) + if (!templateArguments().empty()) { - lists.append(templateArguments()); + result.push_back(templateArguments()); } + return result; } QCString ClassDefImpl::qualifiedNameWithTemplateParameters( - QList<ArgumentList> *actualParams,int *actualParamIndex) const + const std::vector<ArgumentList> *actualParams,int *actualParamIndex) const { //static bool optimizeOutputJava = Config_getBool(OPTIMIZE_OUTPUT_JAVA); static bool hideScopeNames = Config_getBool(HIDE_SCOPE_NAMES); @@ -4659,12 +4386,11 @@ QCString ClassDefImpl::qualifiedNameWithTemplateParameters( //} //printf("m_impl->lang=%d clName=%s isSpecialization=%d\n",getLanguage(),clName.data(),isSpecialization); scName+=clName; - ArgumentList *al=0; - if (templateArguments()) + if (!templateArguments().empty()) { - if (actualParams && *actualParamIndex<(int)actualParams->count()) + if (actualParams && *actualParamIndex<(int)actualParams->size()) { - al = actualParams->at(*actualParamIndex); + const ArgumentList &al = actualParams->at(*actualParamIndex); if (!isSpecialization) { scName+=tempArgListToString(al,lang); @@ -4706,7 +4432,7 @@ void ClassDefImpl::addListReferences() if (!isLinkableInProject()) return; //printf("ClassDef(%s)::addListReferences()\n",name().data()); { - QList<ListItemInfo> *xrefItems = xrefListItems(); + const std::vector<ListItemInfo> &xrefItems = xrefListItems(); addRefItem(xrefItems, qualifiedName(), lang==SrcLangExt_Fortran ? theTranslator->trType(TRUE,TRUE) @@ -5238,7 +4964,7 @@ Protection ClassDefImpl::protection() const return m_impl->prot; } -ArgumentList *ClassDefImpl::templateArguments() const +const ArgumentList &ClassDefImpl::templateArguments() const { return m_impl->tempArgs; } @@ -5265,7 +4991,7 @@ const ClassDef *ClassDefImpl::templateMaster() const bool ClassDefImpl::isTemplate() const { - return m_impl->tempArgs!=0; + return !m_impl->tempArgs.empty(); } IncludeInfo *ClassDefImpl::includeInfo() const @@ -5551,7 +5277,7 @@ const FileList &ClassDefImpl::usedFiles() const return m_impl->files; } -const ArgumentList *ClassDefImpl::typeConstraints() const +const ArgumentList &ClassDefImpl::typeConstraints() const { return m_impl->typeConstraints; } diff --git a/src/classdef.h b/src/classdef.h index e64f0eb..c9cc806 100644 --- a/src/classdef.h +++ b/src/classdef.h @@ -18,6 +18,8 @@ #ifndef CLASSDEF_H #define CLASSDEF_H +#include <vector> + #include <qlist.h> #include <qdict.h> #include <qptrdict.h> @@ -154,10 +156,9 @@ class ClassDef : virtual public Definition /** show this class in the declaration section of its parent? */ virtual bool visibleInParentsDeclList() const = 0; - /** Returns the template arguments of this class - * Will return 0 if not applicable. + /** Returns the template arguments of this class */ - virtual ArgumentList *templateArguments() const = 0; + virtual const ArgumentList &templateArguments() const = 0; /** Returns the namespace this compound is in, or 0 if it has a global * scope. @@ -228,10 +229,10 @@ class ClassDef : virtual public Definition * will return a list with one ArgumentList containing one argument * with type="class" and name="T". */ - virtual void getTemplateParameterLists(QList<ArgumentList> &lists) const = 0; + virtual std::vector<ArgumentList> getTemplateParameterLists() const = 0; virtual QCString qualifiedNameWithTemplateParameters( - QList<ArgumentList> *actualParams=0,int *actualParamIndex=0) const = 0; + const std::vector<ArgumentList> *actualParams=0,int *actualParamIndex=0) const = 0; /** Returns TRUE if there is at least one pure virtual member in this * class. @@ -308,7 +309,7 @@ class ClassDef : virtual public Definition virtual QCString generatedFromFiles() const = 0; virtual const FileList &usedFiles() const = 0; - virtual const ArgumentList *typeConstraints() const = 0; + virtual const ArgumentList &typeConstraints() const = 0; virtual const ExampleSDict *exampleList() const = 0; virtual bool hasExamples() const = 0; virtual QCString getMemberListFileName() const = 0; @@ -331,10 +332,10 @@ class ClassDef : virtual public Definition virtual void setCompoundType(CompoundType t) = 0; virtual void setClassName(const char *name) = 0; virtual void setClassSpecifier(uint64 spec) = 0; - virtual void setTemplateArguments(ArgumentList *al) = 0; + virtual void setTemplateArguments(const ArgumentList &al) = 0; virtual void setTemplateBaseClassNames(QDict<int> *templateNames) = 0; virtual void setTemplateMaster(const ClassDef *tm) = 0; - virtual void setTypeConstraints(ArgumentList *al) = 0; + virtual void setTypeConstraints(const ArgumentList &al) = 0; virtual void setCategoryOf(ClassDef *cd) = 0; virtual void setUsedOnly(bool b) = 0; virtual void setTagLessReference(ClassDef *cd) = 0; diff --git a/src/classlist.cpp b/src/classlist.cpp index 93ae8aa..6928c52 100644 --- a/src/classlist.cpp +++ b/src/classlist.cpp @@ -167,8 +167,8 @@ void GenericsSDict::insert(const QCString &key,ClassDef *cd) int i=key.find('<'); if (i==-1) return; ArgumentList argList; - stringToArgumentList(key.mid(i),&argList); - int c = argList.count(); + stringToArgumentList(key.mid(i),argList); + int c = argList.size(); if (c==0) return; GenericsCollection *collection = m_dict.find(key.left(i)); if (collection==0) // new name @@ -200,8 +200,8 @@ ClassDef *GenericsSDict::find(const QCString &key) if (collection) { ArgumentList argList; - stringToArgumentList(key.mid(i),&argList); - int c = argList.count(); + stringToArgumentList(key.mid(i),argList); + int c = argList.size(); return collection->find(c); } } @@ -276,7 +276,7 @@ void VariableContext::addVariable(const QCString &type,const QCString &name) // otherwise look for global class definitions (varType=getResolvedClass(g_currentDefinition,g_sourceFileDef,typeName,0,0,TRUE,TRUE)) ) && // and it must be a template - varType->templateArguments()) + !varType->templateArguments().empty()) { newDef = varType->getVariableInstance( templateArgs ); } @@ -679,14 +679,10 @@ static void addUsingDirective(const char *name) static void setParameterList(const MemberDef *md) { g_classScope = md->getClassDef() ? md->getClassDef()->name().data() : ""; - const ArgumentList *al = md->argumentList(); - if (al==0) return; - ArgumentListIterator it(*al); - const Argument *a; - for (;(a=it.current());++it) - { - g_parmName = a->name.copy(); - g_parmType = a->type.copy(); + for (const Argument &a : md->argumentList()) + { + g_parmName = a.name; + g_parmType = a.type; int i = g_parmType.find('*'); if (i!=-1) g_parmType = g_parmType.left(i); i = g_parmType.find('&'); @@ -986,7 +982,7 @@ static void generateClassOrGlobalLink(CodeOutputInterface &ol,const char *clName } } const NamespaceDef *nd = getResolvedNamespace(className); - if (nd && nd->isLinkableInProject()) + if (nd && nd->isLinkable()) { g_theCallContext.setScope(nd); addToSearchIndex(className); @@ -2797,7 +2793,6 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" g_name.resize(0); } g_type.resize(0); - g_bracketCount=0; if (g_memCallContext==Body) { BEGIN(FuncCall); diff --git a/src/commentscan.l b/src/commentscan.l index f7a4e7d..6e7d373 100644 --- a/src/commentscan.l +++ b/src/commentscan.l @@ -415,11 +415,8 @@ static GuardType guardType; // kind of guard for conditional se static bool enabledSectionFound; static QCString functionProto; // function prototype static QStack<GuardedSection> guards; // tracks nested conditional sections (if,ifnot,..) -static Entry* current = 0 ; // working entry -//static Entry* current_root = 0 ; // parent of working entry +static Entry *current = 0; // working entry - -//static Entry* previous = 0 ; // TODO: remove need for this static bool needNewEntry; static QCString g_sectionLabel; @@ -533,11 +530,10 @@ static QCString stripQuotes(const char *s) static void addXRefItem(const char *listName,const char *itemTitle, const char *listTitle,bool append) { - Entry *docEntry = current; // inBody && previous ? previous : current; if (listName==0) return; //printf("addXRefItem(%s,%s,%s,%d)\n",listName,itemTitle,listTitle,append); - ListItemInfo *lii=0; + const ListItemInfo *lii=0; RefList *refList = Doxygen::xrefLists->find(listName); if (refList==0) // new list { @@ -545,16 +541,13 @@ static void addXRefItem(const char *listName,const char *itemTitle, Doxygen::xrefLists->insert(listName,refList); //printf("new list!\n"); } - if (docEntry->sli) + for (const ListItemInfo &item : current->sli) { - QListIterator<ListItemInfo> slii(*docEntry->sli); - for (slii.toLast();(lii=slii.current());--slii) + if (qstrcmp(item.type,listName)==0) { - if (qstrcmp(lii->type,listName)==0) - { - //printf("found %s lii->type=%s\n",listName,lii->type); - break; - } + //printf("found %s lii->type=%s\n",listName,lii->type); + lii = &item; + break; } } if (lii && append) // already found item of same type just before this one @@ -580,16 +573,16 @@ static void addXRefItem(const char *listName,const char *itemTitle, ASSERT(item!=0); item->text = outputXRef; item->listAnchor = anchorLabel; - docEntry->addSpecialListItem(listName,itemId); + current->addSpecialListItem(listName,itemId); QCString cmdString; cmdString.sprintf(" \\xrefitem %s %d.",listName,itemId); if (inBody) { - docEntry->inbodyDocs += cmdString; + current->inbodyDocs += cmdString; } else { - docEntry->doc += cmdString; + current->doc += cmdString; } SectionInfo *si = Doxygen::sectionDict->find(anchorLabel); if (si) @@ -609,7 +602,7 @@ static void addXRefItem(const char *listName,const char *itemTitle, g_sectionTitle,SectionInfo::Anchor, g_sectionLevel); Doxygen::sectionDict->append(anchorLabel,si); - docEntry->anchors->append(si); + current->anchors.push_back(si); } } outputXRef.resize(0); @@ -677,7 +670,7 @@ static void addSection() g_sectionTitle,sectionLevelToType(g_sectionLevel),g_sectionLevel); // add section to this entry - current->anchors->append(si); + current->anchors.push_back(si); // add section to the global dictionary Doxygen::sectionDict->append(g_sectionLabel,si); @@ -854,7 +847,7 @@ static void addAnchor(const char *anchor) { si = new SectionInfo(yyFileName,yyLineNr,anchor,0,SectionInfo::Anchor,0); Doxygen::sectionDict->append(anchor,si); - current->anchors->append(si); + current->anchors.push_back(si); } } @@ -1828,7 +1821,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 @@ -2145,8 +2138,8 @@ RCSTAG "$"{ID}":"[^\n$]+"$" /* ----- handle argument of ingroup command ------- */ <InGroupParam>{LABELID} { // group id - current->groups->append( - new Grouping(yytext, Grouping::GROUPING_INGROUP) + current->groups.push_back( + Grouping(yytext, Grouping::GROUPING_INGROUP) ); inGroupParamFound=TRUE; } @@ -2228,8 +2221,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 ); } @@ -2251,8 +2244,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 ); } diff --git a/src/configimpl.l b/src/configimpl.l index e657745..0cc5c88 100644 --- a/src/configimpl.l +++ b/src/configimpl.l @@ -1495,7 +1495,7 @@ void Config::checkAndCorrect() alias=alias.stripWhiteSpace(); if (alias.find(re1)!=0 && alias.find(re2)!=0) { - err("Illegal alias format '%s'. Use \"name=value\" or \"name(n)=value\", where n is the number of arguments\n", + err("Illegal alias format '%s'. Use \"name=value\" or \"name{n}=value\", where n is the number of arguments\n", alias.data()); } s=aliasList.next(); diff --git a/src/context.cpp b/src/context.cpp index 1933d43..361bfa2 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -2381,7 +2381,7 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private> addTemplateDecls(parent,tl); } const ClassDef *cd=dynamic_cast<const ClassDef *>(d); - if (cd->templateArguments()) + if (!cd->templateArguments().empty()) { ArgumentListContext *al = ArgumentListContext::alloc(cd->templateArguments(),cd,relPathAsString()); // since a TemplateVariant does take ownership of the object, we add it @@ -2422,10 +2422,10 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private> } TemplateVariant typeConstraints() const { - if (m_classDef->typeConstraints()) + if (!m_classDef->typeConstraints().empty()) { Cachable &cache = getCache(); - if (!cache.typeConstraints && m_classDef->typeConstraints()) + if (!cache.typeConstraints && !m_classDef->typeConstraints().empty()) { cache.typeConstraints.reset(ArgumentListContext::alloc(m_classDef->typeConstraints(),m_classDef,relPathAsString())); } @@ -4529,7 +4529,7 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private> TemplateVariant templateArgs() const { Cachable &cache = getCache(); - if (!cache.templateArgs && m_memberDef->templateArguments()) + if (!cache.templateArgs && !m_memberDef->templateArguments().empty()) { cache.templateArgs.reset(ArgumentListContext::alloc(m_memberDef->templateArguments(),m_memberDef,relPathAsString())); } @@ -4644,7 +4644,7 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private> return createLinkedText(m_memberDef,relPathAsString(), m_memberDef->displayDefinition()); } - const ArgumentList *getDefArgList() const + const ArgumentList &getDefArgList() const { return (m_memberDef->isDocsForDefinition()) ? m_memberDef->argumentList() : m_memberDef->declArgumentList(); @@ -4654,8 +4654,8 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private> Cachable &cache = getCache(); if (!cache.arguments) { - const ArgumentList *defArgList = getDefArgList(); - if (defArgList && !m_memberDef->isProperty()) + const ArgumentList &defArgList = getDefArgList(); + if (!m_memberDef->isProperty()) { cache.arguments.reset(ArgumentListContext::alloc(defArgList,m_memberDef,relPathAsString())); } @@ -4668,35 +4668,31 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private> } TemplateVariant hasParameters() const { - return getDefArgList()!=0; + return !getDefArgList().empty(); } TemplateVariant hasConstQualifier() const { - const ArgumentList *al = getDefArgList(); - return al ? al->constSpecifier : FALSE; + return getDefArgList().constSpecifier; } TemplateVariant hasVolatileQualifier() const { - const ArgumentList *al = getDefArgList(); - return al ? al->volatileSpecifier : FALSE; + return getDefArgList().volatileSpecifier; } TemplateVariant hasRefQualifierLValue() const { - const ArgumentList *al = getDefArgList(); - return al ? al->refQualifier==RefQualifierLValue : FALSE; + return getDefArgList().refQualifier==RefQualifierLValue; } TemplateVariant hasRefQualifierRValue() const { - const ArgumentList *al = getDefArgList(); - return al ? al->refQualifier==RefQualifierRValue : FALSE; + return getDefArgList().refQualifier==RefQualifierRValue; } TemplateVariant trailingReturnType() const { - const ArgumentList *al = getDefArgList(); - if (al && !al->trailingReturnType.isEmpty()) + const ArgumentList &al = getDefArgList(); + if (!al.trailingReturnType.isEmpty()) { return createLinkedText(m_memberDef,relPathAsString(), - al->trailingReturnType); + al.trailingReturnType); } else { @@ -4710,13 +4706,11 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private> void addTemplateDecls(TemplateList *tl) const { const ClassDef *cd=m_memberDef->getClassDef(); - if (m_memberDef->definitionTemplateParameterLists()) + if (!m_memberDef->definitionTemplateParameterLists().empty()) { - QListIterator<ArgumentList> ali(*m_memberDef->definitionTemplateParameterLists()); - ArgumentList *tal; - for (ali.toFirst();(tal=ali.current());++ali) + for (const ArgumentList &tal : m_memberDef->definitionTemplateParameterLists()) { - if (tal->count()>0) + if (!tal.empty()) { ArgumentListContext *al = ArgumentListContext::alloc(tal,m_memberDef,relPathAsString()); tl->append(al); @@ -4727,21 +4721,16 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private> { if (cd && !m_memberDef->isRelated() && !m_memberDef->isTemplateSpecialization()) { - QList<ArgumentList> tempParamLists; - cd->getTemplateParameterLists(tempParamLists); - //printf("#tempParamLists=%d\n",tempParamLists.count()); - QListIterator<ArgumentList> ali(tempParamLists); - ArgumentList *tal; - for (ali.toFirst();(tal=ali.current());++ali) + for (const ArgumentList &tal : cd->getTemplateParameterLists()) { - if (tal->count()>0) + if (!tal.empty()) { ArgumentListContext *al = ArgumentListContext::alloc(tal,m_memberDef,relPathAsString()); tl->append(al); } } } - if (m_memberDef->templateArguments()) // function template prefix + if (!m_memberDef->templateArguments().empty()) // function template prefix { ArgumentListContext *al = ArgumentListContext::alloc( m_memberDef->templateArguments(),m_memberDef,relPathAsString()); @@ -4785,18 +4774,15 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private> Cachable &cache = getCache(); if (!cache.paramDocs) { - if (m_memberDef->argumentList() && m_memberDef->argumentList()->hasDocumentation()) + if (m_memberDef->argumentList().hasDocumentation()) { QCString paramDocs; - ArgumentListIterator ali(*m_memberDef->argumentList()); - Argument *a; - // convert the parameter documentation into a list of @param commands - for (ali.toFirst();(a=ali.current());++ali) + for (Argument &a : m_memberDef->argumentList()) { - if (a->hasDocumentation()) + if (a.hasDocumentation()) { - QCString direction = extractDirection(a->docs); - paramDocs+="@param"+direction+" "+a->name+" "+a->docs; + QCString direction = extractDirection(a.docs); + paramDocs+="@param"+direction+" "+a.name+" "+a.docs; } } cache.paramDocs.reset(new TemplateVariant(parseDoc(m_memberDef, @@ -4929,7 +4915,7 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private> TemplateVariant typeConstraints() const { Cachable &cache = getCache(); - if (!cache.typeConstraints && m_memberDef->typeConstraints()) + if (cache.typeConstraints && !m_memberDef->typeConstraints().empty()) { cache.typeConstraints.reset(ArgumentListContext::alloc(m_memberDef->typeConstraints(),m_memberDef,relPathAsString())); } @@ -8446,7 +8432,7 @@ TemplateVariant NamespaceMembersIndexContext::get(const char *name) const //------------------------------------------------------------------------ -//%% struct InheritanceGraph: a connected graph reprenting part of the overall interitance tree +//%% struct InheritanceGraph: a connected graph reprenting part of the overall inheritance tree //%% { class InheritanceGraphContext::Private { @@ -9413,7 +9399,7 @@ TemplateListIntf::ConstIterator *InheritedMemberInfoListContext::createIterator( class ArgumentContext::Private { public: - Private(const Argument *arg,const Definition *def,const QCString &relPath) : + Private(const Argument &arg,const Definition *def,const QCString &relPath) : m_argument(arg), m_def(def), m_relPath(relPath) { static bool init=FALSE; @@ -9435,33 +9421,33 @@ class ArgumentContext::Private } TemplateVariant type() const { - return createLinkedText(m_def,m_relPath,m_argument->type); + return createLinkedText(m_def,m_relPath,m_argument.type); } TemplateVariant attrib() const { - return m_argument->attrib; + return m_argument.attrib; } TemplateVariant name() const { - return m_argument->name; + return m_argument.name; } TemplateVariant defVal() const { - return createLinkedText(m_def,m_relPath,m_argument->defval); + return createLinkedText(m_def,m_relPath,m_argument.defval); } TemplateVariant array() const { - return m_argument->array; + return m_argument.array; } TemplateVariant docs() const { if (!m_cache.docs && m_def) { - if (!m_argument->docs.isEmpty()) + if (!m_argument.docs.isEmpty()) { m_cache.docs.reset(new TemplateVariant( parseDoc(m_def,m_def->docFile(),m_def->docLine(), - m_relPath,m_argument->docs,TRUE))); + m_relPath,m_argument.docs,TRUE))); } else { @@ -9472,7 +9458,7 @@ class ArgumentContext::Private } TemplateVariant namePart() const { - QCString result = m_argument->attrib; + QCString result = m_argument.attrib; int l = result.length(); if (l>2 && result.at(0)=='[' && result.at(l-1)==']') { @@ -9482,7 +9468,7 @@ class ArgumentContext::Private return result; } private: - const Argument *m_argument; + const Argument &m_argument; const Definition *m_def; QCString m_relPath; struct Cachable @@ -9496,7 +9482,7 @@ class ArgumentContext::Private PropertyMapper<ArgumentContext::Private> ArgumentContext::Private::s_inst; -ArgumentContext::ArgumentContext(const Argument *al,const Definition *def,const QCString &relPath) : RefCountedContext("ArgumentContext") +ArgumentContext::ArgumentContext(const Argument &al,const Definition *def,const QCString &relPath) : RefCountedContext("ArgumentContext") { p = new Private(al,def,relPath); } @@ -9517,7 +9503,7 @@ TemplateVariant ArgumentContext::get(const char *name) const class ArgumentListContext::Private : public GenericNodeListContext { public: - void addArgument(const Argument *arg,const Definition *def,const QCString &relPath) + void addArgument(const Argument &arg,const Definition *def,const QCString &relPath) { append(ArgumentContext::alloc(arg,def,relPath)); } @@ -9528,18 +9514,13 @@ ArgumentListContext::ArgumentListContext() : RefCountedContext("ArgumentListCont p = new Private; } -ArgumentListContext::ArgumentListContext(const ArgumentList *list, +ArgumentListContext::ArgumentListContext(const ArgumentList &list, const Definition *def,const QCString &relPath) : RefCountedContext("ArgumentListContext") { p = new Private; - if (list) + for (const Argument &arg : list) { - ArgumentListIterator ali(*list); - const Argument *arg; - for (ali.toFirst();(arg=ali.current());++ali) - { - p->addArgument(arg,def,relPath); - } + p->addArgument(arg,def,relPath); } } diff --git a/src/context.h b/src/context.h index ecd1227..fc1278b 100644 --- a/src/context.h +++ b/src/context.h @@ -1138,7 +1138,7 @@ class AllMembersListContext : public RefCountedContext, public TemplateListIntf class ArgumentContext : public RefCountedContext, public TemplateStructIntf { public: - static ArgumentContext *alloc(const Argument *arg,const Definition *def,const QCString &relPath) + static ArgumentContext *alloc(const Argument &arg,const Definition *def,const QCString &relPath) { return new ArgumentContext(arg,def,relPath); } // TemplateStructIntf methods @@ -1147,7 +1147,7 @@ class ArgumentContext : public RefCountedContext, public TemplateStructIntf virtual int release() { return RefCountedContext::release(); } private: - ArgumentContext(const Argument *arg,const Definition *def,const QCString &relPath); + ArgumentContext(const Argument &arg,const Definition *def,const QCString &relPath); ~ArgumentContext(); class Private; Private *p; @@ -1159,7 +1159,7 @@ class ArgumentListContext : public RefCountedContext, public TemplateListIntf { public: static ArgumentListContext *alloc() { return new ArgumentListContext; } - static ArgumentListContext *alloc(const ArgumentList *al,const Definition *def,const QCString &relPath) + static ArgumentListContext *alloc(const ArgumentList &al,const Definition *def,const QCString &relPath) { return new ArgumentListContext(al,def,relPath); } // TemplateListIntf @@ -1171,7 +1171,7 @@ class ArgumentListContext : public RefCountedContext, public TemplateListIntf private: ArgumentListContext(); - ArgumentListContext(const ArgumentList *al,const Definition *def,const QCString &relPath); + ArgumentListContext(const ArgumentList &al,const Definition *def,const QCString &relPath); ~ArgumentListContext(); class Private; Private *p; diff --git a/src/defargs.h b/src/defargs.h index 34a19a2..1b08671 100644 --- a/src/defargs.h +++ b/src/defargs.h @@ -21,7 +21,7 @@ class ArgumentList; class QCString; -extern void stringToArgumentList(const char *argsString,ArgumentList* argList, +extern void stringToArgumentList(const char *argsString,ArgumentList& argList, QCString *extraTypeChars=0); #endif diff --git a/src/defargs.l b/src/defargs.l index 070103a..a213688 100644 --- a/src/defargs.l +++ b/src/defargs.l @@ -387,12 +387,12 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" int i=l-1; while (i>=0 && (isspace((uchar)g_curArgTypeName.at(i)) || g_curArgTypeName.at(i)=='.')) i--; while (i>=0 && (isId(g_curArgTypeName.at(i)) || g_curArgTypeName.at(i)=='$')) i--; - Argument *a = new Argument; - a->attrib = g_curArgAttrib.copy(); - a->typeConstraint = g_curTypeConstraint.stripWhiteSpace(); + Argument a; + a.attrib = g_curArgAttrib.copy(); + a.typeConstraint = g_curTypeConstraint.stripWhiteSpace(); //printf("a->type=%s a->name=%s i=%d l=%d\n", // a->type.data(),a->name.data(),i,l); - a->array.resize(0); + a.array.resize(0); if (i==l-1 && g_curArgTypeName.at(i)==')') // function argument { int bi=g_curArgTypeName.find('('); @@ -401,67 +401,67 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" while (fi>=0 && (isId(g_curArgTypeName.at(fi)) || g_curArgTypeName.at(fi)==':')) fi--; if (fi>=0) { - a->type = g_curArgTypeName.left(fi+1); - a->name = g_curArgTypeName.mid(fi+1,bi-fi-1).stripWhiteSpace(); - a->array = g_curArgTypeName.right(l-bi); + a.type = g_curArgTypeName.left(fi+1); + a.name = g_curArgTypeName.mid(fi+1,bi-fi-1).stripWhiteSpace(); + a.array = g_curArgTypeName.right(l-bi); } else { - a->type = g_curArgTypeName; + a.type = g_curArgTypeName; } } else if (i>=0 && g_curArgTypeName.at(i)!=':') { // type contains a name - a->type = removeRedundantWhiteSpace(g_curArgTypeName.left(i+1)).stripWhiteSpace(); - a->name = g_curArgTypeName.right(l-i-1).stripWhiteSpace(); + a.type = removeRedundantWhiteSpace(g_curArgTypeName.left(i+1)).stripWhiteSpace(); + a.name = g_curArgTypeName.right(l-i-1).stripWhiteSpace(); // if the type becomes a type specifier only then we make a mistake // and need to correct it to avoid seeing a nameless parameter // "struct A" as a parameter with type "struct" and name "A". int sv=0; - if (a->type.left(6)=="const ") sv=6; - else if (a->type.left(9)=="volatile ") sv=9; + if (a.type.left(6)=="const ") sv=6; + else if (a.type.left(9)=="volatile ") sv=9; - if (a->type.mid(sv)=="struct" || - a->type.mid(sv)=="union" || - a->type.mid(sv)=="class" || - a->type.mid(sv)=="typename" || - nameIsActuallyPartOfType(a->name) + if (a.type.mid(sv)=="struct" || + a.type.mid(sv)=="union" || + a.type.mid(sv)=="class" || + a.type.mid(sv)=="typename" || + nameIsActuallyPartOfType(a.name) ) { - a->type = a->type + " " + a->name; - a->name.resize(0); + a.type = a.type + " " + a.name; + a.name.resize(0); } //printf(" --> a->type='%s' a->name='%s'\n",a->type.data(),a->name.data()); } else // assume only the type was specified, try to determine name later { - a->type = removeRedundantWhiteSpace(g_curArgTypeName); + a.type = removeRedundantWhiteSpace(g_curArgTypeName); } - if (!a->type.isEmpty() && a->type.at(0)=='$') // typeless PHP name? + if (!a.type.isEmpty() && a.type.at(0)=='$') // typeless PHP name? { - a->name = a->type; - a->type = ""; + a.name = a.type; + a.type = ""; } - a->array += removeRedundantWhiteSpace(g_curArgArray); + a.array += removeRedundantWhiteSpace(g_curArgArray); //printf("array=%s\n",a->array.data()); - int alen = a->array.length(); - if (alen>2 && a->array.at(0)=='(' && - a->array.at(alen-1)==')') // fix-up for int *(a[10]) + int alen = a.array.length(); + if (alen>2 && a.array.at(0)=='(' && + a.array.at(alen-1)==')') // fix-up for int *(a[10]) { - int i=a->array.find('[')-1; - a->array = a->array.mid(1,alen-2); - if (i>0 && a->name.isEmpty()) + int i=a.array.find('[')-1; + a.array = a.array.mid(1,alen-2); + if (i>0 && a.name.isEmpty()) { - a->name = a->array.left(i).stripWhiteSpace(); - a->array = a->array.mid(i); + a.name = a.array.left(i).stripWhiteSpace(); + a.array = a.array.mid(i); } } - a->defval = g_curArgDefValue.copy(); + a.defval = g_curArgDefValue.copy(); //printf("a->type=%s a->name=%s a->defval=\"%s\"\n",a->type.data(),a->name.data(),a->defval.data()); - a->docs = g_curArgDocs.stripWhiteSpace(); + a.docs = g_curArgDocs.stripWhiteSpace(); //printf("Argument '%s' '%s' adding docs='%s'\n",a->type.data(),a->name.data(),a->docs.data()); - g_argList->append(a); + g_argList->push_back(a); } g_curArgAttrib.resize(0); g_curArgTypeName.resize(0); @@ -601,9 +601,8 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" * for complex types are written to */ -void stringToArgumentList(const char *argsString,ArgumentList* al,QCString *extraTypeChars) +void stringToArgumentList(const char *argsString,ArgumentList& al,QCString *extraTypeChars) { - if (al==0) return; if (argsString==0) return; printlex(yy_flex_debug, TRUE, __FILE__, NULL); @@ -623,10 +622,14 @@ void stringToArgumentList(const char *argsString,ArgumentList* al,QCString *extr g_curArgTypeName.resize(0); g_curArgDefValue.resize(0); g_curArgName.resize(0); - g_argList = al; + g_argList = &al; defargsYYrestart( defargsYYin ); BEGIN( Start ); defargsYYlex(); + if (g_argList->empty()) + { + g_argList->noParameters = TRUE; + } if (extraTypeChars) *extraTypeChars=g_extraTypeChars; //printf("stringToArgumentList(%s) result=%s\n",argsString,argListToString(al).data()); printlex(yy_flex_debug, FALSE, __FILE__, NULL); diff --git a/src/defgen.cpp b/src/defgen.cpp index aa9a1da..f5e12aa 100644 --- a/src/defgen.cpp +++ b/src/defgen.cpp @@ -144,71 +144,66 @@ void generateDEFForMember(MemberDef *md, if (isFunc) //function { - ArgumentList *declAl = new ArgumentList; - const ArgumentList *defAl = md->argumentList(); + const ArgumentList &defAl = md->argumentList(); + ArgumentList declAl; stringToArgumentList(md->argsString(),declAl); QCString fcnPrefix = " " + memPrefix + "param-"; - if (defAl && declAl->count()>0) + auto defIt = defAl.begin(); + for (const Argument &a : declAl) { - ArgumentListIterator declAli(*declAl); - ArgumentListIterator defAli(*defAl); - Argument *a; - for (declAli.toFirst();(a=declAli.current());++declAli) + const Argument *defArg = 0; + if (defIt!=defAl.end()) { - Argument *defArg = defAli.current(); - t << memPrefix << "param = {" << endl; - if (!a->attrib.isEmpty()) - { - t << fcnPrefix << "attributes = "; - writeDEFString(t,a->attrib); - t << ';' << endl; - } - if (!a->type.isEmpty()) - { - t << fcnPrefix << "type = <<_EnD_oF_dEf_TeXt_" << endl - << a->type << endl << "_EnD_oF_dEf_TeXt_;" << endl; - } - if (!a->name.isEmpty()) - { - t << fcnPrefix << "declname = "; - writeDEFString(t,a->name); - t << ';' << endl; - } - if (defArg && !defArg->name.isEmpty() && defArg->name!=a->name) - { - t << fcnPrefix << "defname = "; - writeDEFString(t,defArg->name); - t << ';' << endl; - } - if (!a->array.isEmpty()) - { - t << fcnPrefix << "array = "; - writeDEFString(t,a->array); - t << ';' << endl; - } - if (!a->defval.isEmpty()) - { - t << fcnPrefix << "defval = <<_EnD_oF_dEf_TeXt_" << endl - << a->defval << endl << "_EnD_oF_dEf_TeXt_;" << endl; - } - if (defArg) ++defAli; - t << " }; /*" << fcnPrefix << "-param */" << endl; + defArg = &(*defIt); + ++defIt; } + t << memPrefix << "param = {" << endl; + if (!a.attrib.isEmpty()) + { + t << fcnPrefix << "attributes = "; + writeDEFString(t,a.attrib); + t << ';' << endl; + } + if (!a.type.isEmpty()) + { + t << fcnPrefix << "type = <<_EnD_oF_dEf_TeXt_" << endl + << a.type << endl << "_EnD_oF_dEf_TeXt_;" << endl; + } + if (!a.name.isEmpty()) + { + t << fcnPrefix << "declname = "; + writeDEFString(t,a.name); + t << ';' << endl; + } + if (defArg && !defArg->name.isEmpty() && defArg->name!=a.name) + { + t << fcnPrefix << "defname = "; + writeDEFString(t,defArg->name); + t << ';' << endl; + } + if (!a.array.isEmpty()) + { + t << fcnPrefix << "array = "; + writeDEFString(t,a.array); + t << ';' << endl; + } + if (!a.defval.isEmpty()) + { + t << fcnPrefix << "defval = <<_EnD_oF_dEf_TeXt_" << endl + << a.defval << endl << "_EnD_oF_dEf_TeXt_;" << endl; + } + t << " }; /*" << fcnPrefix << "-param */" << endl; } - delete declAl; } else if ( md->memberType()==MemberType_Define && md->argsString()!=0) { - ArgumentListIterator ali(*md->argumentList()); - Argument *a; QCString defPrefix = " " + memPrefix + "def-"; - - for (ali.toFirst();(a=ali.current());++ali) + for (const Argument &a : md->argumentList()) { t << memPrefix << "param = {" << endl; - t << defPrefix << "name = '" << a->type << "';" << endl; + t << defPrefix << "name = '" << a.type << "';" << endl; t << " }; /*" << defPrefix << "-param */" << endl; } } diff --git a/src/definition.cpp b/src/definition.cpp index 3b5fea1..5b2136c 100644 --- a/src/definition.cpp +++ b/src/definition.cpp @@ -15,6 +15,7 @@ * */ +#include <algorithm> #include <ctype.h> #include <qregexp.h> #include "md5.h" @@ -59,7 +60,7 @@ class DefinitionImpl::IMPL MemberSDict *sourceRefByDict; MemberSDict *sourceRefsDict; - QList<ListItemInfo> *xrefListItems; + std::vector<ListItemInfo> xrefListItems; GroupList *partOfGroups; DocInfo *details; // not exported @@ -97,7 +98,7 @@ class DefinitionImpl::IMPL DefinitionImpl::IMPL::IMPL() : sectionDict(0), sourceRefByDict(0), sourceRefsDict(0), - xrefListItems(0), partOfGroups(0), + partOfGroups(0), details(0), inbodyDocs(0), brief(0), body(0), hidden(FALSE), isArtificial(FALSE), outerScope(0), lang(SrcLangExt_Unknown) { @@ -109,7 +110,6 @@ DefinitionImpl::IMPL::~IMPL() delete sourceRefByDict; delete sourceRefsDict; delete partOfGroups; - delete xrefListItems; delete brief; delete details; delete body; @@ -150,7 +150,6 @@ void DefinitionImpl::IMPL::init(const char *df, const char *n) sectionDict = 0, outerScope = Doxygen::globalScope; partOfGroups = 0; - xrefListItems = 0; hidden = FALSE; isArtificial = FALSE; lang = SrcLangExt_Unknown; @@ -327,7 +326,6 @@ DefinitionImpl::DefinitionImpl(const DefinitionImpl &d) m_impl->sourceRefByDict = 0; m_impl->sourceRefsDict = 0; m_impl->partOfGroups = 0; - m_impl->xrefListItems = 0; m_impl->brief = 0; m_impl->details = 0; m_impl->body = 0; @@ -371,10 +369,6 @@ DefinitionImpl::DefinitionImpl(const DefinitionImpl &d) makePartOfGroup(gd); } } - if (d.m_impl->xrefListItems) - { - setRefItems(d.m_impl->xrefListItems); - } if (d.m_impl->brief) { m_impl->brief = new BriefInfo(*d.m_impl->brief); @@ -420,7 +414,7 @@ void DefinitionImpl::setId(const char *id) m_impl->id = id; if (Doxygen::clangUsrMap) { - //printf("DefinitionImpl::setId '%s'->'%s'\n",id,m_name.data()); + //printf("DefinitionImpl::setId '%s'->'%s'\n",id,m_impl->name.data()); Doxygen::clangUsrMap->insert(id,this); } } @@ -430,13 +424,10 @@ QCString DefinitionImpl::id() const return m_impl->id; } -void DefinitionImpl::addSectionsToDefinition(QList<SectionInfo> *anchorList) +void DefinitionImpl::addSectionsToDefinition(const std::vector<const SectionInfo*> &anchorList) { - if (!anchorList) return; //printf("%s: addSectionsToDefinition(%d)\n",name().data(),anchorList->count()); - QListIterator<SectionInfo> it(*anchorList); - SectionInfo *si; - for (;(si=it.current());++it) + for (const SectionInfo *si : anchorList) { //printf("Add section '%s' to definition '%s'\n", // si->label.data(),name().data()); @@ -1617,76 +1608,47 @@ void DefinitionImpl::makePartOfGroup(GroupDef *gd) m_impl->partOfGroups->append(gd); } -void DefinitionImpl::setRefItems(const QList<ListItemInfo> *sli) +void DefinitionImpl::setRefItems(const std::vector<ListItemInfo> &sli) { - //printf("%s::setRefItems()\n",name().data()); - if (sli) - { - // deep copy the list - if (m_impl->xrefListItems==0) - { - m_impl->xrefListItems=new QList<ListItemInfo>; - m_impl->xrefListItems->setAutoDelete(TRUE); - } - QListIterator<ListItemInfo> slii(*sli); - ListItemInfo *lii; - for (slii.toFirst();(lii=slii.current());++slii) - { - m_impl->xrefListItems->append(new ListItemInfo(*lii)); - } - } + m_impl->xrefListItems = sli; } void DefinitionImpl::mergeRefItems(Definition *d) { - //printf("%s::mergeRefItems()\n",name().data()); - QList<ListItemInfo> *xrefList = d->xrefListItems(); - if (xrefList!=0) - { - // deep copy the list - if (m_impl->xrefListItems==0) - { - m_impl->xrefListItems=new QList<ListItemInfo>; - m_impl->xrefListItems->setAutoDelete(TRUE); - } - QListIterator<ListItemInfo> slii(*xrefList); - QListIterator<ListItemInfo> mlii(*m_impl->xrefListItems); - ListItemInfo *lii; - ListItemInfo *mii; - for (slii.toFirst();(lii=slii.current());++slii) - { - bool found = false; - for (mlii.toFirst();(mii=mlii.current());++mlii) - { - if ((qstrcmp(lii->type,mii->type)==0) && (lii->itemId == mii->itemId)) - { - found = true; - break; - } - } - if (!found) m_impl->xrefListItems->append(new ListItemInfo(*lii)); - } - } + auto otherXrefList = d->xrefListItems(); + + // append vectors + m_impl->xrefListItems.reserve(m_impl->xrefListItems.size()+otherXrefList.size()); + m_impl->xrefListItems.insert (m_impl->xrefListItems.end(), + otherXrefList.begin(),otherXrefList.end()); + + // sort results on itemId + std::sort(m_impl->xrefListItems.begin(),m_impl->xrefListItems.end(), + [](const ListItemInfo &left,const ListItemInfo &right) + { return left.itemId<right.itemId || + (left.itemId==right.itemId && qstrcmp(left.type,right.type)<0); + }); + + // filter out duplicates + auto last = std::unique(m_impl->xrefListItems.begin(),m_impl->xrefListItems.end(), + [](const ListItemInfo &left,const ListItemInfo &right) + { return left.itemId==right.itemId && left.type==right.type; }); + m_impl->xrefListItems.erase(last, m_impl->xrefListItems.end()); } int DefinitionImpl::_getXRefListId(const char *listName) const { - if (m_impl->xrefListItems) + for (const ListItemInfo &lii : m_impl->xrefListItems) { - QListIterator<ListItemInfo> slii(*m_impl->xrefListItems); - ListItemInfo *lii; - for (slii.toFirst();(lii=slii.current());++slii) + if (lii.type==listName) { - if (qstrcmp(lii->type,listName)==0) - { - return lii->itemId; - } + return lii.itemId; } } return -1; } -QList<ListItemInfo> *DefinitionImpl::xrefListItems() const +const std::vector<ListItemInfo> &DefinitionImpl::xrefListItems() const { return m_impl->xrefListItems; } diff --git a/src/definition.h b/src/definition.h index db9bbbc..d458683 100644 --- a/src/definition.h +++ b/src/definition.h @@ -18,6 +18,7 @@ #ifndef DEFINITION_H #define DEFINITION_H +#include <vector> #include <qlist.h> #include <qdict.h> @@ -257,7 +258,7 @@ class Definition : public DefinitionIntf virtual GroupList *partOfGroups() const = 0; virtual bool isLinkableViaGroup() const = 0; - virtual QList<ListItemInfo> *xrefListItems() const = 0; + virtual const std::vector<ListItemInfo> &xrefListItems() const = 0; virtual Definition *findInnerCompound(const char *name) const = 0; virtual Definition *getOuterScope() const = 0; @@ -313,7 +314,7 @@ class Definition : public DefinitionIntf virtual void setBodySegment(int bls,int ble) = 0; virtual void setBodyDef(FileDef *fd) = 0; - virtual void setRefItems(const QList<ListItemInfo> *sli) = 0; + virtual void setRefItems(const std::vector<ListItemInfo> &sli) = 0; virtual void setOuterScope(Definition *d) = 0; virtual void setHidden(bool b) = 0; @@ -331,7 +332,7 @@ class Definition : public DefinitionIntf /*! Add the list of anchors that mark the sections that are found in the * documentation. */ - virtual void addSectionsToDefinition(QList<SectionInfo> *anchorList) = 0; + virtual void addSectionsToDefinition(const std::vector<const SectionInfo*> &anchorList) = 0; virtual void addSourceReferencedBy(const MemberDef *d) = 0; virtual void addSourceReferences(const MemberDef *d) = 0; virtual void mergeRefItems(Definition *d) = 0; diff --git a/src/definitionimpl.h b/src/definitionimpl.h index 4dd324b..036c875 100644 --- a/src/definitionimpl.h +++ b/src/definitionimpl.h @@ -66,7 +66,7 @@ class DefinitionImpl : virtual public Definition virtual SrcLangExt getLanguage() const; virtual GroupList *partOfGroups() const; virtual bool isLinkableViaGroup() const; - virtual QList<ListItemInfo> *xrefListItems() const; + virtual const std::vector<ListItemInfo> &xrefListItems() const; virtual Definition *findInnerCompound(const char *name) const; virtual Definition *getOuterScope() const; virtual MemberSDict *getReferencesMembers() const; @@ -83,12 +83,12 @@ class DefinitionImpl : virtual public Definition virtual void setBriefDescription(const char *b,const char *briefFile,int briefLine); virtual void setInbodyDocumentation(const char *d,const char *docFile,int docLine); virtual void setReference(const char *r); - virtual void addSectionsToDefinition(QList<SectionInfo> *anchorList); + virtual void addSectionsToDefinition(const std::vector<const SectionInfo*> &anchorList); virtual void setBodySegment(int bls,int ble); virtual void setBodyDef(FileDef *fd); virtual void addSourceReferencedBy(const MemberDef *d); virtual void addSourceReferences(const MemberDef *d); - virtual void setRefItems(const QList<ListItemInfo> *sli); + virtual void setRefItems(const std::vector<ListItemInfo> &sli); virtual void mergeRefItems(Definition *d); virtual void addInnerCompound(const Definition *d); virtual void setOuterScope(Definition *d); @@ -210,7 +210,7 @@ class DefinitionAliasImpl : virtual public Definition { return m_def->partOfGroups(); } virtual bool isLinkableViaGroup() const { return m_def->isLinkableViaGroup(); } - virtual QList<ListItemInfo> *xrefListItems() const + virtual const std::vector<ListItemInfo> &xrefListItems() const { return m_def->xrefListItems(); } virtual Definition *findInnerCompound(const char *name) const { return m_def->findInnerCompound(name); } @@ -241,12 +241,12 @@ class DefinitionAliasImpl : virtual public Definition virtual void setBriefDescription(const char *b,const char *briefFile,int briefLine) {} virtual void setInbodyDocumentation(const char *d,const char *docFile,int docLine) {} virtual void setReference(const char *r) {} - virtual void addSectionsToDefinition(QList<SectionInfo> *anchorList) {} + virtual void addSectionsToDefinition(const std::vector<const SectionInfo*> &anchorList) {} virtual void setBodySegment(int bls,int ble) {} virtual void setBodyDef(FileDef *fd) {} virtual void addSourceReferencedBy(const MemberDef *d) {} virtual void addSourceReferences(const MemberDef *d) {} - virtual void setRefItems(const QList<ListItemInfo> *sli) {} + virtual void setRefItems(const std::vector<ListItemInfo> &sli) {} virtual void mergeRefItems(Definition *d) {} virtual void addInnerCompound(const Definition *d) {} virtual void setOuterScope(Definition *d) {} diff --git a/src/diagram.cpp b/src/diagram.cpp index 08b49ca..2dadc12 100644 --- a/src/diagram.cpp +++ b/src/diagram.cpp @@ -247,7 +247,7 @@ static void writeVectorBox(FTextStream &t,DiagramItem *di, float x,float y,bool children=FALSE) { if (di->virtualness()==Virtual) t << "dashed\n"; - t << " (" << di->label() << ") " << x << " " << y << " box\n"; + t << " (" << convertToPSString(di->label()) << ") " << x << " " << y << " box\n"; if (children) t << x << " " << y << " mark\n"; if (di->virtualness()==Virtual) t << "solid\n"; } @@ -1297,7 +1297,7 @@ void ClassDiagram::writeFigure(FTextStream &output,const char *path, for (;(di=rit.current());++rit) { done=di->isInList(); - t << "(" << di->label() << ") cw\n"; + t << "(" << convertToPSString(di->label()) << ") cw\n"; } } QListIterator<DiagramRow> sit(*super); @@ -1310,7 +1310,7 @@ void ClassDiagram::writeFigure(FTextStream &output,const char *path, for (;(di=rit.current());++rit) { done=di->isInList(); - t << "(" << di->label() << ") cw\n"; + t << "(" << convertToPSString(di->label()) << ") cw\n"; } } diff --git a/src/docgroup.cpp b/src/docgroup.cpp index 1f4fb6d..fbdb842 100644 --- a/src/docgroup.cpp +++ b/src/docgroup.cpp @@ -1,3 +1,18 @@ +/****************************************************************************** + * + * Copyright (C) 1997-2019 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + * Documents produced by Doxygen are derivative works derived from the + * input used in their production; they are not affected by this license. + * + */ + #include "doxygen.h" #include "util.h" #include "entry.h" @@ -8,7 +23,6 @@ void DocGroup::enterFile(const char *fileName,int) { m_openCount = 0; - m_autoGroupStack.setAutoDelete(TRUE); m_autoGroupStack.clear(); m_memberGroupId = DOX_NOGROUP; m_memberGroupDocs.resize(0); @@ -25,7 +39,7 @@ void DocGroup::leaveFile(const char *fileName,int line) m_memberGroupId=DOX_NOGROUP; m_memberGroupRelates.resize(0); m_memberGroupDocs.resize(0); - if (!m_autoGroupStack.isEmpty()) + if (!m_autoGroupStack.empty()) { warn(fileName,line,"end of file while inside a group"); } @@ -94,10 +108,10 @@ void DocGroup::open(Entry *e,const char *,int, bool implicit) { if (!implicit) m_openCount++; //printf("==> openGroup(name=%s,sec=%x) m_autoGroupStack=%d\n", - // e->name.data(),e->section,m_autoGroupStack.count()); + // e->name.data(),e->section,m_autoGroupStack.size()); if (e->section==Entry::GROUPDOC_SEC) // auto group { - m_autoGroupStack.push(new Grouping(e->name,e->groupingPri())); + m_autoGroupStack.push_back(Grouping(e->name,e->groupingPri())); } else // start of a member group { @@ -133,7 +147,7 @@ void DocGroup::close(Entry *e,const char *fileName,int line,bool foundInline,boo } } //printf("==> closeGroup(name=%s,sec=%x,file=%s,line=%d) m_autoGroupStack=%d\n", - // e->name.data(),e->section,fileName,line,m_autoGroupStack.count()); + // e->name.data(),e->section,fileName,line,m_autoGroupStack.size()); if (m_memberGroupId!=DOX_NOGROUP) // end of member group { MemberGroupInfo *info=Doxygen::memGrpInfoDict.find(m_memberGroupId); @@ -149,13 +163,13 @@ void DocGroup::close(Entry *e,const char *fileName,int line,bool foundInline,boo if (!foundInline) e->mGrpId=DOX_NOGROUP; //printf("new group id=%d\n",m_memberGroupId); } - else if (!m_autoGroupStack.isEmpty()) // end of auto group + else if (!m_autoGroupStack.empty()) // end of auto group { - Grouping *grp = m_autoGroupStack.pop(); + Grouping grp = m_autoGroupStack.back(); + m_autoGroupStack.pop_back(); // see bug577005: we should not remove the last group for e - if (!foundInline) e->groups->removeLast(); + if (!foundInline && !e->groups.empty()) e->groups.pop_back(); //printf("Removing %s e=%p\n",grp->groupname.data(),e); - delete grp; if (!foundInline) initGroupInfo(e); } } @@ -166,12 +180,12 @@ void DocGroup::initGroupInfo(Entry *e) // m_memberGroupRelates.data(),e); e->mGrpId = m_memberGroupId; e->relates = m_memberGroupRelates; - if (!m_autoGroupStack.isEmpty()) + if (!m_autoGroupStack.empty()) { //printf("Appending group %s to %s: count=%d entry=%p\n", // m_autoGroupStack.top()->groupname.data(), // e->name.data(),e->groups->count(),e); - e->groups->append(new Grouping(*m_autoGroupStack.top())); + e->groups.push_back(Grouping(m_autoGroupStack.back())); } } diff --git a/src/docgroup.h b/src/docgroup.h index 4775d90..47a0a3e 100644 --- a/src/docgroup.h +++ b/src/docgroup.h @@ -16,7 +16,7 @@ #ifndef DOCGROUP_H #define DOCGROUP_H -#include <qstack.h> +#include <vector> #include <qstring.h> #include "membergroup.h" @@ -47,7 +47,7 @@ class DocGroup int m_memberGroupId; QCString m_memberGroupRelates; QCString m_memberGroupDocs; - QStack<Grouping> m_autoGroupStack; + std::vector<Grouping> m_autoGroupStack; QCString m_compoundName; }; diff --git a/src/docparser.cpp b/src/docparser.cpp index 8f7c2d2..4f52393 100644 --- a/src/docparser.cpp +++ b/src/docparser.cpp @@ -413,12 +413,12 @@ static void checkArgumentName(const QCString &name) { if (!Config_getBool(WARN_IF_DOC_ERROR)) return; if (g_memberDef==0) return; // not a member - const ArgumentList *al=g_memberDef->isDocsForDefinition() ? + const ArgumentList &al=g_memberDef->isDocsForDefinition() ? g_memberDef->argumentList() : g_memberDef->declArgumentList(); SrcLangExt lang = g_memberDef->getLanguage(); //printf("isDocsForDefinition()=%d\n",g_memberDef->isDocsForDefinition()); - if (al==0) return; // no argument list + if (al.empty()) return; // no argument list static QRegExp re("$?[a-zA-Z0-9_\\x80-\\xFF]+\\.*"); int p=0,i=0,l; @@ -427,12 +427,10 @@ static void checkArgumentName(const QCString &name) QCString aName=name.mid(i,l); if (lang==SrcLangExt_Fortran) aName=aName.lower(); //printf("aName='%s'\n",aName.data()); - ArgumentListIterator ali(*al); - const Argument *a; bool found=FALSE; - for (ali.toFirst();(a=ali.current());++ali) + for (const Argument &a : al) { - QCString argName = g_memberDef->isDefine() ? a->type : a->name; + QCString argName = g_memberDef->isDefine() ? a.type : a.name; if (lang==SrcLangExt_Fortran) argName=argName.lower(); argName=argName.stripWhiteSpace(); //printf("argName='%s' aName=%s\n",argName.data(),aName.data()); @@ -460,7 +458,6 @@ static void checkArgumentName(const QCString &name) inheritedMd->docLine(),qPrint(inheritedMd->docFile())); docFile = g_memberDef->getDefFileName(); docLine = g_memberDef->getDefLine(); - } QCString alStr = argListToString(al); warn_doc_error(docFile,docLine, @@ -500,28 +497,26 @@ static void checkUnOrMultipleDocumentedParams() { if (g_memberDef && g_hasParamCommand && Config_getBool(WARN_IF_DOC_ERROR)) { - const ArgumentList *al=g_memberDef->isDocsForDefinition() ? + const ArgumentList &al=g_memberDef->isDocsForDefinition() ? g_memberDef->argumentList() : g_memberDef->declArgumentList(); SrcLangExt lang = g_memberDef->getLanguage(); - if (al!=0) + if (!al.empty()) { - ArgumentListIterator ali(*al); - const Argument *a; int notArgCnt=0; - for (ali.toFirst();(a=ali.current());++ali) + for (const Argument &a: al) { int count = 0; - QCString argName = g_memberDef->isDefine() ? a->type : a->name; + QCString argName = g_memberDef->isDefine() ? a.type : a.name; if (lang==SrcLangExt_Fortran) argName = argName.lower(); argName=argName.stripWhiteSpace(); QCString aName = argName; if (argName.right(3)=="...") argName=argName.left(argName.length()-3); if (lang==SrcLangExt_Python && (argName=="self" || argName=="cls")) - { + { // allow undocumented self / cls parameter for Python } - else if (!argName.isEmpty() && g_paramsFound.find(argName)==0 && a->docs.isEmpty()) + else if (!argName.isEmpty() && g_paramsFound.find(argName)==0 && a.docs.isEmpty()) { notArgCnt++; } @@ -550,20 +545,20 @@ static void checkUnOrMultipleDocumentedParams() QCString errMsg= "The following parameter"; errMsg+= (notArgCnt>1 ? "s" : ""); - errMsg+=" of "+ + errMsg+=" of "+ QCString(g_memberDef->qualifiedName()) + QCString(argListToString(al)) + (notArgCnt>1 ? " are" : " is") + " not documented:\n"; - for (ali.toFirst();(a=ali.current());++ali) + for (const Argument &a : al) { - QCString argName = g_memberDef->isDefine() ? a->type : a->name; + QCString argName = g_memberDef->isDefine() ? a.type : a.name; if (lang==SrcLangExt_Fortran) argName = argName.lower(); argName=argName.stripWhiteSpace(); if (lang==SrcLangExt_Python && (argName=="self" || argName=="cls")) - { + { // allow undocumented self / cls parameter for Python } - else if (!argName.isEmpty() && g_paramsFound.find(argName)==0) + else if (!argName.isEmpty() && g_paramsFound.find(argName)==0) { if (!first) { @@ -968,7 +963,7 @@ static int handleAHref(DocNode *parent,QList<DocNode> &children,const HtmlAttrib int retval = RetVal_OK; for (li.toFirst();(opt=li.current());++li,++index) { - if (opt->name=="name") // <a name=label> tag + if (opt->name=="name" || opt->name=="id") // <a name=label> or <a id=label> tag { if (!opt->value.isEmpty()) { @@ -5894,9 +5889,10 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &ta int retval=RetVal_OK; int tagId = Mappers::htmlTagMapper->map(tagName); if (g_token->emptyTag && !(tagId&XML_CmdMask) && - tagId!=HTML_UNKNOWN && tagId!=HTML_IMG && tagId!=HTML_BR) + tagId!=HTML_UNKNOWN && tagId!=HTML_IMG && tagId!=HTML_BR && tagId!=HTML_HR && tagId!=HTML_P) { - warn_doc_error(g_fileName,doctokenizerYYlineno,"HTML tags may not use the 'empty tag' XHTML syntax."); + warn_doc_error(g_fileName,doctokenizerYYlineno,"HTML tag ('<%s/>') may not use the 'empty tag' XHTML syntax.", + tagName.data()); } switch (tagId) { @@ -6441,7 +6437,7 @@ int DocPara::handleHtmlEndTag(const QCString &tagName) warn_doc_error(g_fileName,doctokenizerYYlineno,"Unexpected tag </img> found"); break; case HTML_HR: - warn_doc_error(g_fileName,doctokenizerYYlineno,"Unexpected tag </hr> found"); + warn_doc_error(g_fileName,doctokenizerYYlineno,"Illegal </hr> tag found\n"); break; case HTML_A: //warn_doc_error(g_fileName,doctokenizerYYlineno,"Unexpected tag </a> found"); diff --git a/src/dotgraph.cpp b/src/dotgraph.cpp index df64d66..bbffaf0 100644 --- a/src/dotgraph.cpp +++ b/src/dotgraph.cpp @@ -289,7 +289,7 @@ void DotGraph::writeGraphHeader(FTextStream &t,const QCString &title) { t << " // INTERACTIVE_SVG=YES\n"; } - t << " // LATEX_PDF_SIZE\n"; // write placeholder for LaTeX PDF bounding box size repacement + t << " // LATEX_PDF_SIZE\n"; // write placeholder for LaTeX PDF bounding box size replacement if (Config_getBool(DOT_TRANSPARENT)) { t << " bgcolor=\"transparent\";" << endl; diff --git a/src/doxygen.cpp b/src/doxygen.cpp index 953a5de..9c77086 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -33,6 +33,9 @@ #include <qptrdict.h> #include <qtextstream.h> +#include <unordered_map> +#include <memory> + #include "version.h" #include "doxygen.h" #include "scanner.h" @@ -105,13 +108,6 @@ // provided by the generated file resources.cpp extern void initResources(); -#define RECURSE_ENTRYTREE(func,var) \ - do { if (var->children()) { \ - EntryListIterator eli(*var->children()); \ - for (;eli.current();++eli) func(eli.current()); \ - } } while(0) - - #if !defined(_WIN32) || defined(__CYGWIN__) #include <signal.h> #define HAS_SIGNALS @@ -177,7 +173,7 @@ GenericsSDict *Doxygen::genericsDict; DocGroup Doxygen::docGroup; // locally accessible globals -static QDict<Entry> g_classEntries(1009); +static std::unordered_map< std::string, const Entry* > g_classEntries; static StringList g_inputFiles; static QDict<void> g_compoundKeywordDict(7); // keywords recognised as compounds static OutputList *g_outputList = 0; // list of output generating objects @@ -297,9 +293,12 @@ void statistics() -static void addMemberDocs(Entry *root,MemberDef *md, const char *funcDecl, - ArgumentList *al,bool over_load,NamespaceSDict *nl=0); -static void findMember(Entry *root, +static void addMemberDocs(const Entry *root,MemberDef *md, const char *funcDecl, + const ArgumentList *al,bool over_load,uint64 spec); +static void findMember(const Entry *root, + const QCString &relates, + const QCString &type, + const QCString &args, QCString funcDecl, bool overloaded, bool isFunc @@ -313,10 +312,10 @@ enum FindBaseClassRelation_Mode }; static bool findClassRelation( - Entry *root, + const Entry *root, Definition *context, ClassDef *cd, - BaseInfo *bi, + const BaseInfo *bi, QDict<int> *templateNames, /*bool insertUndocumented*/ FindBaseClassRelation_Mode mode, @@ -420,9 +419,9 @@ static STLInfo g_stlinfo[] = { 0, 0, 0, 0, 0, 0, 0, FALSE, FALSE } }; -static void addSTLMember(Entry *root,const char *type,const char *name) +static void addSTLMember(const std::unique_ptr<Entry> &root,const char *type,const char *name) { - Entry *memEntry = new Entry; + std::unique_ptr<Entry> memEntry = std::make_unique<Entry>(); memEntry->name = name; memEntry->type = type; memEntry->protection = Public; @@ -430,16 +429,12 @@ static void addSTLMember(Entry *root,const char *type,const char *name) memEntry->brief = "STL member"; memEntry->hidden = FALSE; memEntry->artificial = TRUE; - //memEntry->parent = root; - root->addSubEntry(memEntry); - //EntryNav *memEntryNav = new EntryNav(root,memEntry); - //memEntryNav->setEntry(memEntry); - //rootNav->addChild(memEntryNav); + root->moveToSubEntryAndKeep(memEntry); } -static void addSTLIterator(Entry *classEntry,const char *name) +static void addSTLIterator(const std::unique_ptr<Entry> &classEntry,const char *name) { - Entry *iteratorClassEntry = new Entry; + std::unique_ptr<Entry> iteratorClassEntry = std::make_unique<Entry>(); iteratorClassEntry->fileName = "[STL]"; iteratorClassEntry->startLine = 1; iteratorClassEntry->name = name; @@ -447,119 +442,109 @@ static void addSTLIterator(Entry *classEntry,const char *name) iteratorClassEntry->brief = "STL iterator class"; iteratorClassEntry->hidden = FALSE; iteratorClassEntry->artificial= TRUE; - classEntry->addSubEntry(iteratorClassEntry); - //EntryNav *iteratorClassEntryNav = new EntryNav(classEntryNav,iteratorClassEntry); - //iteratorClassEntryNav->setEntry(iteratorClassEntry); - //classEntryNav->addChild(iteratorClassEntryNav); + classEntry->moveToSubEntryAndKeep(iteratorClassEntry); +} + +static void addSTLClass(const std::unique_ptr<Entry> &root,const STLInfo *info) +{ + //printf("Adding STL class %s\n",info->className); + QCString fullName = info->className; + fullName.prepend("std::"); + + // add fake Entry for the class + std::unique_ptr<Entry> classEntry = std::make_unique<Entry>(); + classEntry->fileName = "[STL]"; + classEntry->startLine = 1; + classEntry->name = fullName; + classEntry->section = Entry::CLASS_SEC; + classEntry->brief = "STL class"; + classEntry->hidden = FALSE; + classEntry->artificial= TRUE; + + // add template arguments to class + if (info->templType1) + { + ArgumentList al; + Argument a; + a.type="typename"; + a.name=info->templType1; + al.push_back(a); + if (info->templType2) // another template argument + { + a.type="typename"; + a.name=info->templType2; + al.push_back(a); + } + classEntry->tArgLists.push_back(al); + } + // add member variables + if (info->templName1) + { + addSTLMember(classEntry,info->templType1,info->templName1); + } + if (info->templName2) + { + addSTLMember(classEntry,info->templType2,info->templName2); + } + if (fullName=="std::auto_ptr" || fullName=="std::smart_ptr" || fullName=="std::shared_ptr" || + fullName=="std::unique_ptr" || fullName=="std::weak_ptr") + { + std::unique_ptr<Entry> memEntry = std::make_unique<Entry>(); + memEntry->name = "operator->"; + memEntry->args = "()"; + memEntry->type = "T*"; + memEntry->protection = Public; + memEntry->section = Entry::FUNCTION_SEC; + memEntry->brief = "STL member"; + memEntry->hidden = FALSE; + memEntry->artificial = FALSE; + classEntry->moveToSubEntryAndKeep(memEntry); + } + if (info->baseClass1) + { + classEntry->extends.push_back(BaseInfo(info->baseClass1,Public,info->virtualInheritance?Virtual:Normal)); + } + if (info->baseClass2) + { + classEntry->extends.push_back(BaseInfo(info->baseClass2,Public,info->virtualInheritance?Virtual:Normal)); + } + if (info->iterators) + { + // add iterator class + addSTLIterator(classEntry,fullName+"::iterator"); + addSTLIterator(classEntry,fullName+"::const_iterator"); + addSTLIterator(classEntry,fullName+"::reverse_iterator"); + addSTLIterator(classEntry,fullName+"::const_reverse_iterator"); + } + root->moveToSubEntryAndKeep(classEntry); } -static void addSTLClasses(Entry *root) +static void addSTLClasses(const std::unique_ptr<Entry> &root) { - Entry *namespaceEntry = new Entry; + std::unique_ptr<Entry> namespaceEntry = std::make_unique<Entry>(); namespaceEntry->fileName = "[STL]"; namespaceEntry->startLine = 1; - //namespaceEntry->parent = rootNav->entry(); namespaceEntry->name = "std"; namespaceEntry->section = Entry::NAMESPACE_SEC; namespaceEntry->brief = "STL namespace"; namespaceEntry->hidden = FALSE; namespaceEntry->artificial= TRUE; - root->addSubEntry(namespaceEntry); - //EntryNav *namespaceEntryNav = new EntryNav(rootNav,namespaceEntry); - //namespaceEntryNav->setEntry(namespaceEntry); - //rootNav->addChild(namespaceEntryNav); STLInfo *info = g_stlinfo; while (info->className) { - //printf("Adding STL class %s\n",info->className); - QCString fullName = info->className; - fullName.prepend("std::"); - - // add fake Entry for the class - Entry *classEntry = new Entry; - classEntry->fileName = "[STL]"; - classEntry->startLine = 1; - classEntry->name = fullName; - classEntry->section = Entry::CLASS_SEC; - classEntry->brief = "STL class"; - classEntry->hidden = FALSE; - classEntry->artificial= TRUE; - namespaceEntry->addSubEntry(classEntry); - //EntryNav *classEntryNav = new EntryNav(namespaceEntryNav,classEntry); - //classEntryNav->setEntry(classEntry); - //namespaceEntryNav->addChild(classEntryNav); - - // add template arguments to class - if (info->templType1) - { - ArgumentList *al = new ArgumentList; - Argument *a=new Argument; - a->type="typename"; - a->name=info->templType1; - al->append(a); - if (info->templType2) // another template argument - { - a=new Argument; - a->type="typename"; - a->name=info->templType2; - al->append(a); - } - classEntry->tArgLists = new QList<ArgumentList>; - classEntry->tArgLists->setAutoDelete(TRUE); - classEntry->tArgLists->append(al); - } - // add member variables - if (info->templName1) - { - addSTLMember(classEntry,info->templType1,info->templName1); - } - if (info->templName2) - { - addSTLMember(classEntry,info->templType2,info->templName2); - } - if (fullName=="std::auto_ptr" || fullName=="std::smart_ptr" || fullName=="std::shared_ptr" || - fullName=="std::unique_ptr" || fullName=="std::weak_ptr") - { - Entry *memEntry = new Entry; - memEntry->name = "operator->"; - memEntry->args = "()"; - memEntry->type = "T*"; - memEntry->protection = Public; - memEntry->section = Entry::FUNCTION_SEC; - memEntry->brief = "STL member"; - memEntry->hidden = FALSE; - memEntry->artificial = FALSE; - classEntry->addSubEntry(memEntry); - //EntryNav *memEntryNav = new EntryNav(classEntryNav,memEntry); - //memEntryNav->setEntry(memEntry); - //classEntryNav->addChild(memEntryNav); - } - if (info->baseClass1) - { - classEntry->extends->append(new BaseInfo(info->baseClass1,Public,info->virtualInheritance?Virtual:Normal)); - } - if (info->baseClass2) - { - classEntry->extends->append(new BaseInfo(info->baseClass2,Public,info->virtualInheritance?Virtual:Normal)); - } - if (info->iterators) - { - // add iterator class - addSTLIterator(classEntry,fullName+"::iterator"); - addSTLIterator(classEntry,fullName+"::const_iterator"); - addSTLIterator(classEntry,fullName+"::reverse_iterator"); - addSTLIterator(classEntry,fullName+"::const_reverse_iterator"); - } + addSTLClass(namespaceEntry,info); info++; } + + root->moveToSubEntryAndKeep(namespaceEntry); } //---------------------------------------------------------------------------- static Definition *findScopeFromQualifiedName(Definition *startScope,const QCString &n, - FileDef *fileScope,TagInfo *tagInfo); + FileDef *fileScope,const TagInfo *tagInfo); static void addPageToContext(PageDef *pd,Entry *root) { @@ -572,7 +557,7 @@ static void addPageToContext(PageDef *pd,Entry *root) } scope = stripAnonymousNamespaceScope(scope); scope+="::"+pd->name(); - Definition *d = findScopeFromQualifiedName(Doxygen::globalScope,scope,0,root->tagInfo); + Definition *d = findScopeFromQualifiedName(Doxygen::globalScope,scope,0,root->tagInfo()); if (d) { pd->setPageScope(d); @@ -583,11 +568,9 @@ static void addPageToContext(PageDef *pd,Entry *root) static void addRelatedPage(Entry *root) { GroupDef *gd=0; - QListIterator<Grouping> gli(*root->groups); - Grouping *g; - for (;(g=gli.current());++gli) + for (const Grouping &g : root->groups) { - if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname))) break; + if (!g.groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g.groupname))) break; } //printf("---> addRelatedPage() %s gd=%p\n",root->name.data(),gd); QCString doc; @@ -600,10 +583,10 @@ static void addRelatedPage(Entry *root) doc=root->brief+"\n\n"+root->doc+root->inbodyDocs; } - PageDef *pd = addRelatedPage(root->name,root->args,doc,root->anchors, + PageDef *pd = addRelatedPage(root->name,root->args,doc, root->docFile,root->docLine, root->sli, - gd,root->tagInfo, + gd,root->tagInfo(), FALSE, root->lang ); @@ -616,11 +599,11 @@ static void addRelatedPage(Entry *root) } } -static void buildGroupListFiltered(Entry *root,bool additional, bool includeExternal) +static void buildGroupListFiltered(const Entry *root,bool additional, bool includeExternal) { if (root->section==Entry::GROUPDOC_SEC && !root->name.isEmpty() && - ((!includeExternal && root->tagInfo==0) || - ( includeExternal && root->tagInfo!=0)) + ((!includeExternal && root->tagInfo()==0) || + ( includeExternal && root->tagInfo()!=0)) ) { if ((root->groupDocType==Entry::GROUPDOC_NORMAL && !additional) || @@ -651,10 +634,10 @@ static void buildGroupListFiltered(Entry *root,bool additional, bool includeExte } else { - if (root->tagInfo) + if (root->tagInfo()) { - gd = createGroupDef(root->fileName,root->startLine,root->name,root->type,root->tagInfo->fileName); - gd->setReference(root->tagInfo->tagName); + gd = createGroupDef(root->fileName,root->startLine,root->name,root->type,root->tagInfo()->fileName); + gd->setReference(root->tagInfo()->tagName); } else { @@ -671,18 +654,10 @@ static void buildGroupListFiltered(Entry *root,bool additional, bool includeExte } } } - if (root->children()) - { - EntryListIterator eli(*root->children()); - Entry *e; - for (;(e=eli.current());++eli) - { - buildGroupListFiltered(e,additional,includeExternal); - } - } + for (const auto &e : root->children()) buildGroupListFiltered(e.get(),additional,includeExternal); } -static void buildGroupList(Entry *root) +static void buildGroupList(const Entry *root) { // --- first process only local groups // first process the @defgroups blocks @@ -697,7 +672,7 @@ static void buildGroupList(Entry *root) buildGroupListFiltered(root,TRUE,TRUE); } -static void findGroupScope(Entry *root) +static void findGroupScope(const Entry *root) { if (root->section==Entry::GROUPDOC_SEC && !root->name.isEmpty() && root->parent() && !root->parent()->name.isEmpty()) @@ -712,17 +687,17 @@ static void findGroupScope(Entry *root) } scope = stripAnonymousNamespaceScope(scope); scope+="::"+gd->name(); - Definition *d = findScopeFromQualifiedName(Doxygen::globalScope,scope,0,root->tagInfo); + Definition *d = findScopeFromQualifiedName(Doxygen::globalScope,scope,0,root->tagInfo()); if (d) { gd->setGroupScope(d); } } } - RECURSE_ENTRYTREE(findGroupScope,root); + for (const auto &e : root->children()) findGroupScope(e.get()); } -static void organizeSubGroupsFiltered(Entry *root,bool additional) +static void organizeSubGroupsFiltered(const Entry *root,bool additional) { if (root->section==Entry::GROUPDOC_SEC && !root->name.isEmpty()) { @@ -737,18 +712,10 @@ static void organizeSubGroupsFiltered(Entry *root,bool additional) } } } - if (root->children()) - { - EntryListIterator eli(*root->children()); - Entry *e; - for (;(e=eli.current());++eli) - { - organizeSubGroupsFiltered(e,additional); - } - } + for (const auto &e : root->children()) organizeSubGroupsFiltered(e.get(),additional); } -static void organizeSubGroups(Entry *root) +static void organizeSubGroups(const Entry *root) { //printf("Defining groups\n"); // first process the @defgroups blocks @@ -760,11 +727,11 @@ static void organizeSubGroups(Entry *root) //---------------------------------------------------------------------- -static void buildFileList(Entry *root) +static void buildFileList(const Entry *root) { if (((root->section==Entry::FILEDOC_SEC) || ((root->section & Entry::FILE_MASK) && Config_getBool(EXTRACT_ALL))) && - !root->name.isEmpty() && !root->tagInfo // skip any file coming from tag files + !root->name.isEmpty() && !root->tagInfo() // skip any file coming from tag files ) { bool ambig; @@ -790,12 +757,10 @@ static void buildFileList(Entry *root) fd->setBriefDescription(root->brief,root->briefFile,root->briefLine); fd->addSectionsToDefinition(root->anchors); fd->setRefItems(root->sli); - QListIterator<Grouping> gli(*root->groups); - Grouping *g; - for (;(g=gli.current());++gli) + for (const Grouping &g : root->groups) { GroupDef *gd=0; - if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname))) + if (!g.groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g.groupname))) { gd->addFile(fd); fd->makePartOfGroup(gd); @@ -824,10 +789,10 @@ static void buildFileList(Entry *root) warn(fn,root->startLine,text); } } - RECURSE_ENTRYTREE(buildFileList,root); + for (const auto &e : root->children()) buildFileList(e.get()); } -static void addIncludeFile(ClassDef *cd,FileDef *ifd,Entry *root) +static void addIncludeFile(ClassDef *cd,FileDef *ifd,const Entry *root) { if ( (!root->doc.stripWhiteSpace().isEmpty() || @@ -986,7 +951,7 @@ static Definition *findScope(Entry *root,int level=0) * not found and set the parent/child scope relation if the scope is found. */ static Definition *buildScopeFromQualifiedName(const QCString name, - int level,SrcLangExt lang,TagInfo *tagInfo) + int level,SrcLangExt lang,const TagInfo *tagInfo) { //printf("buildScopeFromQualifiedName(%s) level=%d\n",name.data(),level); int i=0; @@ -1045,7 +1010,7 @@ static Definition *buildScopeFromQualifiedName(const QCString name, } static Definition *findScopeFromQualifiedName(Definition *startScope,const QCString &n, - FileDef *fileScope,TagInfo *tagInfo) + FileDef *fileScope,const TagInfo *tagInfo) { //printf("<findScopeFromQualifiedName(%s,%s)\n",startScope ? startScope->name().data() : 0, n.data()); Definition *resultScope=startScope; @@ -1133,17 +1098,15 @@ static Definition *findScopeFromQualifiedName(Definition *startScope,const QCStr return resultScope; } -ArgumentList *getTemplateArgumentsFromName( +ArgumentList getTemplateArgumentsFromName( const QCString &name, - const QList<ArgumentList> *tArgLists) + const std::vector<ArgumentList> &tArgLists) { - if (tArgLists==0) return 0; - - QListIterator<ArgumentList> ali(*tArgLists); // for each scope fragment, check if it is a template and advance through // the list if so. int i,p=0; - while ((i=name.find("::",p))!=-1) + auto alIt = tArgLists.begin(); + while ((i=name.find("::",p))!=-1 && alIt!=tArgLists.end()) { NamespaceDef *nd = Doxygen::namespaceSDict->find(name.left(i)); if (nd==0) @@ -1151,15 +1114,15 @@ ArgumentList *getTemplateArgumentsFromName( ClassDef *cd = getClass(name.left(i)); if (cd) { - if (cd->templateArguments()) + if (!cd->templateArguments().empty()) { - ++ali; + ++alIt; } } } p=i+2; } - return ali.current(); + return alIt!=tArgLists.end() ? *alIt : ArgumentList(); } static @@ -1220,7 +1183,7 @@ ClassDef::CompoundType convertToCompoundType(int section,uint64 specifier) } -static void addClassToContext(Entry *root) +static void addClassToContext(const Entry *root) { FileDef *fd = root->fileDef(); @@ -1268,13 +1231,12 @@ static void addClassToContext(Entry *root) } //cd->setName(fullName); // change name to match docs - if (cd->templateArguments()==0 || (cd->isForwardDeclared() && (root->spec&Entry::ForwardDecl)==0)) + if (cd->templateArguments().empty() || (cd->isForwardDeclared() && (root->spec&Entry::ForwardDecl)==0)) { // this happens if a template class declared with @class is found // before the actual definition or if a forward declaration has different template // parameter names. - ArgumentList *tArgList = - getTemplateArgumentsFromName(cd->name(),root->tArgLists); + ArgumentList tArgList = getTemplateArgumentsFromName(cd->name(),root->tArgLists); cd->setTemplateArguments(tArgList); } @@ -1295,7 +1257,7 @@ static void addClassToContext(Entry *root) QCString tagName; QCString refFileName; - TagInfo *tagInfo = root->tagInfo; + const TagInfo *tagInfo = root->tagInfo(); int i; if (tagInfo) { @@ -1308,12 +1270,11 @@ static void addClassToContext(Entry *root) buildScopeFromQualifiedName(fullName,fullName.contains("::"),root->lang,tagInfo); } } - ArgumentList *tArgList = 0; + ArgumentList tArgList; if ((root->lang==SrcLangExt_CSharp || root->lang==SrcLangExt_Java) && (i=fullName.find('<'))!=-1) { // a Java/C# generic class looks like a C++ specialization, so we need to split the // name and template arguments here - tArgList = new ArgumentList; stringToArgumentList(fullName.mid(i),tArgList); fullName=fullName.left(i); } @@ -1324,7 +1285,7 @@ static void addClassToContext(Entry *root) cd=createClassDef(tagInfo?tagName:root->fileName,root->startLine,root->startColumn, fullName,sec,tagName,refFileName,TRUE,root->spec&Entry::Enum); Debug::print(Debug::Classes,0," New class '%s' (sec=0x%08x)! #tArgLists=%d tagInfo=%p\n", - qPrint(fullName),sec,root->tArgLists ? (int)root->tArgLists->count() : -1, tagInfo); + qPrint(fullName),sec,root->tArgLists.size(), tagInfo); cd->setDocumentation(root->doc,root->docFile,root->docLine); // copy docs to definition cd->setBriefDescription(root->brief,root->briefFile,root->briefLine); cd->setLanguage(root->lang); @@ -1386,7 +1347,7 @@ static void addClassToContext(Entry *root) //---------------------------------------------------------------------- // build a list of all classes mentioned in the documentation // and all classes that have a documentation block before their definition. -static void buildClassList(Entry *root) +static void buildClassList(const Entry *root) { if ( ((root->section & Entry::COMPOUND_MASK) || @@ -1395,10 +1356,10 @@ static void buildClassList(Entry *root) { addClassToContext(root); } - RECURSE_ENTRYTREE(buildClassList,root); + for (const auto &e : root->children()) buildClassList(e.get()); } -static void buildClassDocList(Entry *root) +static void buildClassDocList(const Entry *root) { if ( (root->section & Entry::COMPOUNDDOC_MASK) && !root->name.isEmpty() @@ -1406,7 +1367,7 @@ static void buildClassDocList(Entry *root) { addClassToContext(root); } - RECURSE_ENTRYTREE(buildClassDocList,root); + for (const auto &e : root->children()) buildClassDocList(e.get()); } static void resolveClassNestingRelations() @@ -1589,7 +1550,7 @@ static ClassDef *createTagLessInstance(ClassDef *rootCd,ClassDef *templ,const QC md->typeString(),md->name(),md->argsString(),md->excpString(), md->protection(),md->virtualness(),md->isStatic(),Member, md->memberType(), - 0,0,""); + ArgumentList(),ArgumentList(),""); imd->setMemberClass(cd); imd->setDocumentation(md->documentation(),md->docFile(),md->docLine()); imd->setBriefDescription(md->briefDescription(),md->briefFile(),md->briefLine()); @@ -1717,7 +1678,7 @@ static void findTagLessClasses() //---------------------------------------------------------------------- // build a list of all namespaces mentioned in the documentation // and all namespaces that have a documentation block before their definition. -static void buildNamespaceList(Entry *root) +static void buildNamespaceList(const Entry *root) { if ( (root->section==Entry::NAMESPACE_SEC || @@ -1751,7 +1712,7 @@ static void buildNamespaceList(Entry *root) { nd->setLanguage(root->lang); } - if (root->tagInfo==0) // if we found the namespace in a tag file + if (root->tagInfo()==0) // if we found the namespace in a tag file // and also in a project file, then remove // the tag file reference { @@ -1771,7 +1732,7 @@ static void buildNamespaceList(Entry *root) { QCString tagName; QCString tagFileName; - TagInfo *tagInfo = root->tagInfo; + const TagInfo *tagInfo = root->tagInfo(); if (tagInfo) { tagName = tagInfo->tagName; @@ -1847,7 +1808,7 @@ static void buildNamespaceList(Entry *root) } } } - RECURSE_ENTRYTREE(buildNamespaceList,root); + for (const auto &e : root->children()) buildNamespaceList(e.get()); } //---------------------------------------------------------------------- @@ -1871,7 +1832,7 @@ static const NamespaceDef *findUsedNamespace(const NamespaceSDict *unl, return usingNd; } -static void findUsingDirectives(Entry *root) +static void findUsingDirectives(const Entry *root) { if (root->section==Entry::USINGDIR_SEC) { @@ -1982,12 +1943,13 @@ static void findUsingDirectives(Entry *root) nd->setMetaData(root->metaData); nd->setInline((root->spec&Entry::Inline)!=0); - QListIterator<Grouping> gli(*root->groups); - Grouping *g; - for (;(g=gli.current());++gli) + //QListIterator<Grouping> gli(*root->groups); + //Grouping *g; + //for (;(g=gli.current());++gli) + for (const Grouping &g : root->groups) { GroupDef *gd=0; - if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname))) + if (!g.groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g.groupname))) gd->addNamespace(nd); } @@ -2007,12 +1969,12 @@ static void findUsingDirectives(Entry *root) } } } - RECURSE_ENTRYTREE(findUsingDirectives,root); + for (const auto &e : root->children()) findUsingDirectives(e.get()); } //---------------------------------------------------------------------- -static void buildListOfUsingDecls(Entry *root) +static void buildListOfUsingDecls(const Entry *root) { if (root->section==Entry::USINGDECL_SEC && !(root->parent()->section&Entry::COMPOUND_MASK) // not a class/struct member @@ -2029,11 +1991,11 @@ static void buildListOfUsingDecls(Entry *root) } } } - RECURSE_ENTRYTREE(buildListOfUsingDecls,root); + for (const auto &e : root->children()) buildListOfUsingDecls(e.get()); } -static void findUsingDeclarations(Entry *root) +static void findUsingDeclarations(const Entry *root) { if (root->section==Entry::USINGDECL_SEC && !(root->parent()->section&Entry::COMPOUND_MASK) // not a class/struct member @@ -2083,7 +2045,7 @@ static void findUsingDeclarations(Entry *root) if (usingCd==0) // definition not in the input => add an artificial class { Debug::print(Debug::Classes,0," New using class '%s' (sec=0x%08x)! #tArgLists=%d\n", - qPrint(name),root->section,root->tArgLists ? (int)root->tArgLists->count() : -1); + qPrint(name),root->section,root->tArgLists.size()); usingCd = createClassDef( "<using>",1,1, name, @@ -2113,12 +2075,12 @@ static void findUsingDeclarations(Entry *root) } } } - RECURSE_ENTRYTREE(findUsingDeclarations,root); + for (const auto &e : root->children()) findUsingDeclarations(e.get()); } //---------------------------------------------------------------------- -static void findUsingDeclImports(Entry *root) +static void findUsingDeclImports(const Entry *root) { if (root->section==Entry::USINGDECL_SEC && (root->parent()->section&Entry::COMPOUND_MASK) // in a class/struct member @@ -2159,12 +2121,12 @@ static void findUsingDeclImports(Entry *root) MemberDef *newMd = 0; { QCString fileName = root->fileName; - if (fileName.isEmpty() && root->tagInfo) + if (fileName.isEmpty() && root->tagInfo()) { - fileName = root->tagInfo->tagName; + fileName = root->tagInfo()->tagName; } - const ArgumentList *templAl = md->templateArguments(); - const ArgumentList *al = md->templateArguments(); + const ArgumentList &templAl = md->templateArguments(); + const ArgumentList &al = md->templateArguments(); newMd = createMemberDef( fileName,root->startLine,root->startColumn, md->typeString(),memName,md->argsString(), @@ -2211,7 +2173,7 @@ static void findUsingDeclImports(Entry *root) } } - RECURSE_ENTRYTREE(findUsingDeclImports,root); + for (const auto &e : root->children()) findUsingDeclImports(e.get()); } //---------------------------------------------------------------------- @@ -2250,10 +2212,12 @@ static void findIncludedUsingDirectives() //---------------------------------------------------------------------- static MemberDef *addVariableToClass( - Entry *root, + const Entry *root, ClassDef *cd, MemberType mtype, + const QCString &type, const QCString &name, + const QCString &args, bool fromAnnScope, MemberDef *fromAnnMemb, Protection prot, @@ -2270,38 +2234,38 @@ static MemberDef *addVariableToClass( Debug::print(Debug::Variables,0, " class variable:\n" " '%s' '%s'::'%s' '%s' prot=%d ann=%d init='%s'\n", - qPrint(root->type), + qPrint(type), qPrint(qualScope), qPrint(name), - qPrint(root->args), + qPrint(args), root->protection, fromAnnScope, qPrint(root->initializer) ); QCString def; - if (!root->type.isEmpty()) + if (!type.isEmpty()) { if (related || mtype==MemberType_Friend || Config_getBool(HIDE_SCOPE_NAMES)) { if (root->spec&Entry::Alias) // turn 'typedef B A' into 'using A = B' { - def="using "+name+" = "+root->type.mid(7); + def="using "+name+" = "+type.mid(7); } else { - def=root->type+" "+name+root->args; + def=type+" "+name+root->args; } } else { if (root->spec&Entry::Alias) // turn 'typedef B C::A' into 'using C::A = B' { - def="using "+qualScope+scopeSeparator+name+" = "+root->type.mid(7); + def="using "+qualScope+scopeSeparator+name+" = "+type.mid(7); } else { - def=root->type+" "+qualScope+scopeSeparator+name+root->args; + def=type+" "+qualScope+scopeSeparator+name+args; } } } @@ -2309,11 +2273,11 @@ static MemberDef *addVariableToClass( { if (Config_getBool(HIDE_SCOPE_NAMES)) { - def=name+root->args; + def=name+args; } else { - def=qualScope+scopeSeparator+name+root->args; + def=qualScope+scopeSeparator+name+args; } } def.stripPrefix("static "); @@ -2329,10 +2293,10 @@ static MemberDef *addVariableToClass( for (mni.toFirst();(md=mni.current());++mni) { //printf("md->getClassDef()=%p cd=%p type=[%s] md->typeString()=[%s]\n", - // md->getClassDef(),cd,root->type.data(),md->typeString()); + // md->getClassDef(),cd,type.data(),md->typeString()); if (!md->isAlias() && md->getClassDef()==cd && - removeRedundantWhiteSpace(root->type)==md->typeString()) + removeRedundantWhiteSpace(type)==md->typeString()) // member already in the scope { @@ -2344,7 +2308,7 @@ static MemberDef *addVariableToClass( md->setProtection(root->protection); cd->reclassifyMember(md,MemberType_Property); } - addMemberDocs(root,md,def,0,FALSE); + addMemberDocs(root,md,def,0,FALSE,root->spec); //printf(" Member already found!\n"); return md; } @@ -2352,18 +2316,19 @@ static MemberDef *addVariableToClass( } QCString fileName = root->fileName; - if (fileName.isEmpty() && root->tagInfo) + if (fileName.isEmpty() && root->tagInfo()) { - fileName = root->tagInfo->tagName; + fileName = root->tagInfo()->tagName; } // new member variable, typedef or enum value MemberDef *md=createMemberDef( fileName,root->startLine,root->startColumn, - root->type,name,root->args,root->exception, + type,name,args,root->exception, prot,Normal,root->stat,related, - mtype,root->tArgLists ? root->tArgLists->getLast() : 0,0, root->metaData); - md->setTagInfo(root->tagInfo); + mtype,!root->tArgLists.empty() ? root->tArgLists.back() : ArgumentList(), + ArgumentList(), root->metaData); + md->setTagInfo(root->tagInfo()); md->setMemberClass(cd); // also sets outer scope (i.e. getOuterScope()) //md->setDefFile(root->fileName); //md->setDefLine(root->startLine); @@ -2421,17 +2386,19 @@ static MemberDef *addVariableToClass( //TODO: insert FileDef instead of filename strings. cd->insertUsedFile(root->fileDef()); - root->changeSection(Entry::EMPTY_SEC); + root->markAsProcessed(); return md; } //---------------------------------------------------------------------- static MemberDef *addVariableToFile( - Entry *root, + const Entry *root, MemberType mtype, const QCString &scope, + const QCString &type, const QCString &name, + const QCString &args, bool fromAnnScope, /*int indentDepth,*/ MemberDef *fromAnnMemb) @@ -2440,10 +2407,10 @@ static MemberDef *addVariableToFile( " global variable:\n" " file='%s' type='%s' scope='%s' name='%s' args='%s' prot=`%d mtype=%d lang=%d\n", qPrint(root->fileName), - qPrint(root->type), + qPrint(type), qPrint(scope), qPrint(name), - qPrint(root->args), + qPrint(args), root->protection, mtype, root->lang @@ -2454,18 +2421,18 @@ static MemberDef *addVariableToFile( // see if we have a typedef that should hide a struct or union if (mtype==MemberType_Typedef && Config_getBool(TYPEDEF_HIDES_STRUCT)) { - QCString type = root->type; - type.stripPrefix("typedef "); - if (type.left(7)=="struct " || type.left(6)=="union ") + QCString ttype = type; + ttype.stripPrefix("typedef "); + if (ttype.left(7)=="struct " || ttype.left(6)=="union ") { - type.stripPrefix("struct "); - type.stripPrefix("union "); + ttype.stripPrefix("struct "); + ttype.stripPrefix("union "); static QRegExp re("[a-z_A-Z][a-z_A-Z0-9]*"); int l,s; - s = re.match(type,0,&l); + s = re.match(ttype,0,&l); if (s>=0) { - QCString typeValue = type.mid(s,l); + QCString typeValue = ttype.mid(s,l); ClassDef *cd = getClass(typeValue); if (cd) { @@ -2502,45 +2469,45 @@ static MemberDef *addVariableToFile( SrcLangExt lang = nd->getLanguage(); QCString sep=getLanguageSpecificSeparator(lang); - if (!root->type.isEmpty()) + if (!type.isEmpty()) { if (root->spec&Entry::Alias) // turn 'typedef B NS::A' into 'using NS::A = B' { - def="using "+nd->name()+sep+name+" = "+root->type; + def="using "+nd->name()+sep+name+" = "+type; } else // normal member { - def=root->type+" "+nd->name()+sep+name+root->args; + def=type+" "+nd->name()+sep+name+args; } } else { - def=nd->name()+sep+name+root->args; + def=nd->name()+sep+name+args; } } else { - if (!root->type.isEmpty() && !root->name.isEmpty()) + if (!type.isEmpty() && !root->name.isEmpty()) { if (name.at(0)=='@') // dummy variable representing anonymous union { - def=root->type; + def=type; } else { if (root->spec&Entry::Alias) // turn 'typedef B A' into 'using A = B' { - def="using "+root->name+" = "+root->type.mid(7); + def="using "+root->name+" = "+type.mid(7); } else // normal member { - def=root->type+" "+name+root->args; + def=type+" "+name+args; } } } else { - def=name+root->args; + def=name+args; } } def.stripPrefix("static "); @@ -2571,8 +2538,8 @@ static MemberDef *addVariableToFile( // variable already in the scope { bool isPHPArray = md->getLanguage()==SrcLangExt_PHP && - md->argsString()!=root->args && - root->args.find('[')!=-1; + md->argsString()!=args && + args.find('[')!=-1; bool staticsInDifferentFiles = root->stat && md->isStatic() && root->fileName!=md->getDefFileName(); @@ -2585,10 +2552,10 @@ static MemberDef *addVariableToFile( { Debug::print(Debug::Variables,0, " variable already found: scope=%s\n",qPrint(md->getOuterScope()->name())); - addMemberDocs(root,md,def,0,FALSE); + addMemberDocs(root,md,def,0,FALSE,root->spec); md->setRefItems(root->sli); // if md is a variable forward declaration and root is the definition that - // turn md into the defintion + // turn md into the definition if (!root->explicitExternal && md->isExternal()) { md->setDeclFile(md->getDefFileName(),md->getDefLine(),md->getDefColumn()); @@ -2607,20 +2574,21 @@ static MemberDef *addVariableToFile( } QCString fileName = root->fileName; - if (fileName.isEmpty() && root->tagInfo) + if (fileName.isEmpty() && root->tagInfo()) { - fileName = root->tagInfo->tagName; + fileName = root->tagInfo()->tagName; } Debug::print(Debug::Variables,0, - " new variable, nd=%s tagInfo=%p!\n",nd?qPrint(nd->name()):"<global>",root->tagInfo); + " new variable, nd=%s tagInfo=%p!\n",nd?qPrint(nd->name()):"<global>",root->tagInfo()); // new global variable, enum value or typedef MemberDef *md=createMemberDef( fileName,root->startLine,root->startColumn, - root->type,name,root->args,0, + type,name,args,0, root->protection, Normal,root->stat,Member, - mtype,root->tArgLists ? root->tArgLists->getLast() : 0,0, root->metaData); - md->setTagInfo(root->tagInfo); + mtype,!root->tArgLists.empty() ? root->tArgLists.back() : ArgumentList(), + ArgumentList(), root->metaData); + md->setTagInfo(root->tagInfo()); md->setMemberSpecifiers(root->spec); md->setDocumentation(root->doc,root->docFile,root->docLine); md->setBriefDescription(root->brief,root->briefFile,root->briefLine); @@ -2673,7 +2641,7 @@ static MemberDef *addVariableToFile( mn->append(md); Doxygen::functionNameSDict->append(name,mn); } - root->changeSection(Entry::EMPTY_SEC); + root->markAsProcessed(); return md; } @@ -2714,7 +2682,7 @@ static int findFunctionPtr(const QCString &type,int lang, int *pLength=0) /*! Returns TRUE iff \a type is a class within scope \a context. * Used to detect variable declarations that look like function prototypes. */ -static bool isVarWithConstructor(Entry *root) +static bool isVarWithConstructor(const Entry *root) { static QRegExp initChars("[0-9\"'&*!^]+"); static QRegExp idChars("[a-z_A-Z][a-z_A-Z0-9]*"); @@ -2763,19 +2731,16 @@ static bool isVarWithConstructor(Entry *root) // we need to rely on heuristics :-( { //printf("typeIsClass\n"); - ArgumentList *al = root->argList; - if (al==0 || al->isEmpty()) + if (root->argList.empty()) { result=FALSE; // empty arg list -> function prototype. goto done; } - ArgumentListIterator ali(*al); - Argument *a; - for (ali.toFirst();(a=ali.current());++ali) + for (const Argument &a : root->argList) { - if (!a->name.isEmpty() || !a->defval.isEmpty()) + if (!a.name.isEmpty() || !a.defval.isEmpty()) { - if (a->name.find(initChars)==0) + if (a.name.find(initChars)==0) { result=TRUE; } @@ -2785,31 +2750,31 @@ static bool isVarWithConstructor(Entry *root) } goto done; } - if (a->type.isEmpty() || getResolvedClass(ctx,fd,a->type)!=0) + if (a.type.isEmpty() || getResolvedClass(ctx,fd,a.type)!=0) { result=FALSE; // arg type is a known type goto done; } - if (checkIfTypedef(ctx,fd,a->type)) + if (checkIfTypedef(ctx,fd,a.type)) { //printf("%s:%d: false (arg is typedef)\n",__FILE__,__LINE__); result=FALSE; // argument is a typedef goto done; } - if (a->type.at(a->type.length()-1)=='*' || - a->type.at(a->type.length()-1)=='&') + if (a.type.at(a.type.length()-1)=='*' || + a.type.at(a.type.length()-1)=='&') // type ends with * or & => pointer or reference { result=FALSE; goto done; } - if (a->type.find(initChars)==0) + if (a.type.find(initChars)==0) { result=TRUE; // argument type starts with typical initializer char goto done; } - QCString resType=resolveTypeDef(ctx,a->type); - if (resType.isEmpty()) resType=a->type; + QCString resType=resolveTypeDef(ctx,a.type); + if (resType.isEmpty()) resType=a.type; int len; if (idChars.match(resType,0,&len)==0) // resType starts with identifier { @@ -2833,7 +2798,7 @@ done: return result; } -static void addVariable(Entry *root,int isFuncPtr=-1) +static void addVariable(const Entry *root,int isFuncPtr=-1) { static bool sliceOpt = Config_getBool(OPTIMIZE_OUTPUT_SLICE); @@ -2849,48 +2814,52 @@ static void addVariable(Entry *root,int isFuncPtr=-1) ); //printf("root->parent->name=%s\n",root->parent->name.data()); - if (root->type.isEmpty() && root->name.find("operator")==-1 && - (root->name.find('*')!=-1 || root->name.find('&')!=-1)) + QCString type = root->type; + QCString name = root->name; + QCString args = root->args; + if (type.isEmpty() && name.find("operator")==-1 && + (name.find('*')!=-1 || name.find('&')!=-1)) { // recover from parse error caused by redundant braces // like in "int *(var[10]);", which is parsed as // type="" name="int *" args="(var[10])" - root->type=root->name; + type=name; static const QRegExp reName("[a-z_A-Z][a-z_A-Z0-9]*"); int l=0; - int i=root->args.isEmpty() ? -1 : reName.match(root->args,0,&l); + int i=args.isEmpty() ? -1 : reName.match(args,0,&l); if (i!=-1) { - root->name=root->args.mid(i,l); - root->args=root->args.mid(i+l,root->args.find(')',i+l)-i-l); + name=args.mid(i,l); + args=args.mid(i+l,args.find(')',i+l)-i-l); } //printf("new: type='%s' name='%s' args='%s'\n", - // root->type.data(),root->name.data(),root->args.data()); + // type.data(),name.data(),args.data()); } else { int i=isFuncPtr; - if (i==-1 && (root->spec&Entry::Alias)==0) i=findFunctionPtr(root->type,root->lang); // for typedefs isFuncPtr is not yet set + if (i==-1 && (root->spec&Entry::Alias)==0) i=findFunctionPtr(type,root->lang); // for typedefs isFuncPtr is not yet set Debug::print(Debug::Variables,0," functionPtr? %s\n",i!=-1?"yes":"no"); if (i!=-1) // function pointer { - int ai = root->type.find('[',i); + int ai = type.find('[',i); if (ai>i) // function pointer array { - root->args.prepend(root->type.right(root->type.length()-ai)); - root->type=root->type.left(ai); + args.prepend(type.right(type.length()-ai)); + type=type.left(ai); } - else if (root->type.find(')',i)!=-1) // function ptr, not variable like "int (*bla)[10]" + else if (type.find(')',i)!=-1) // function ptr, not variable like "int (*bla)[10]" { - root->type=root->type.left(root->type.length()-1); - root->args.prepend(") "); - //printf("root->type=%s root->args=%s\n",root->type.data(),root->args.data()); + type=type.left(type.length()-1); + args.prepend(") "); + //printf("type=%s args=%s\n",type.data(),args.data()); } } } - QCString scope,name=removeRedundantWhiteSpace(root->name); + QCString scope; + name=removeRedundantWhiteSpace(name); // find the scope of this variable Entry *p = root->parent(); @@ -2906,7 +2875,7 @@ static void addVariable(Entry *root,int isFuncPtr=-1) } MemberType mtype; - QCString type=root->type.stripWhiteSpace(); + type=type.stripWhiteSpace(); ClassDef *cd=0; bool isRelated=FALSE; bool isMemberOf=FALSE; @@ -2915,10 +2884,10 @@ static void addVariable(Entry *root,int isFuncPtr=-1) classScope=stripTemplateSpecifiersFromScope(classScope,FALSE); QCString annScopePrefix=scope.left(scope.length()-classScope.length()); - if (root->name.findRev("::")!=-1) + if (name.findRev("::")!=-1) { - if (root->type=="friend class" || root->type=="friend struct" || - root->type=="friend union") + if (type=="friend class" || type=="friend struct" || + type=="friend union") { cd=getClass(scope); if (cd) @@ -2926,7 +2895,9 @@ static void addVariable(Entry *root,int isFuncPtr=-1) addVariableToClass(root, // entry cd, // class to add member to MemberType_Friend, // type of member - name, // name of the member + type, // type value as string + name, // name of the member + args, // arguments as string FALSE, // from Anonymous scope 0, // anonymous member Public, // protection @@ -3001,7 +2972,9 @@ static void addVariable(Entry *root,int isFuncPtr=-1) md=addVariableToClass(root, // entry pcd, // class to add member to mtype, // member type + type, // type value as string name, // member name + args, // arguments as string TRUE, // from anonymous scope 0, // from anonymous member root->protection, @@ -3013,7 +2986,7 @@ static void addVariable(Entry *root,int isFuncPtr=-1) { if (mtype==MemberType_Variable) { - md=addVariableToFile(root,mtype,pScope,name,TRUE,0); + md=addVariableToFile(root,mtype,pScope,type,name,args,TRUE,0); } //added=TRUE; } @@ -3026,7 +2999,9 @@ static void addVariable(Entry *root,int isFuncPtr=-1) addVariableToClass(root, // entry cd, // class to add member to mtype, // member type + type, // type value as string name, // name of the member + args, // arguments as string FALSE, // from anonymous scope md, // from anonymous member root->protection, @@ -3035,7 +3010,7 @@ static void addVariable(Entry *root,int isFuncPtr=-1) else if (!name.isEmpty()) // global variable { //printf("Inserting member in global scope %s!\n",scope.data()); - addVariableToFile(root,mtype,scope,name,FALSE,/*0,*/0); + addVariableToFile(root,mtype,scope,type,name,args,FALSE,/*0,*/0); } } @@ -3043,7 +3018,7 @@ static void addVariable(Entry *root,int isFuncPtr=-1) //---------------------------------------------------------------------- // Searches the Entry tree for typedef documentation sections. // If found they are stored in their class or in the global list. -static void buildTypedefList(Entry *root) +static void buildTypedefList(const Entry *root) { //printf("buildVarList(%s)\n",rootNav->name().data()); if (!root->name.isEmpty() && @@ -3053,24 +3028,15 @@ static void buildTypedefList(Entry *root) { addVariable(root); } - if (root->children()) - { - EntryListIterator eli(*root->children()); - Entry *e; - for (;(e=eli.current());++eli) - { - if (e->section!=Entry::ENUM_SEC) - { - buildTypedefList(e); - } - } - } + for (const auto &e : root->children()) + if (e->section!=Entry::ENUM_SEC) + buildTypedefList(e.get()); } //---------------------------------------------------------------------- // Searches the Entry tree for sequence documentation sections. // If found they are stored in the global list. -static void buildSequenceList(Entry *root) +static void buildSequenceList(const Entry *root) { if (!root->name.isEmpty() && root->section==Entry::VARIABLE_SEC && @@ -3079,24 +3045,15 @@ static void buildSequenceList(Entry *root) { addVariable(root); } - if (root->children()) - { - EntryListIterator eli(*root->children()); - Entry *e; - for (;(e=eli.current());++eli) - { - if (e->section!=Entry::ENUM_SEC) - { - buildSequenceList(e); - } - } - } + for (const auto &e : root->children()) + if (e->section!=Entry::ENUM_SEC) + buildSequenceList(e.get()); } //---------------------------------------------------------------------- // Searches the Entry tree for dictionary documentation sections. // If found they are stored in the global list. -static void buildDictionaryList(Entry *root) +static void buildDictionaryList(const Entry *root) { if (!root->name.isEmpty() && root->section==Entry::VARIABLE_SEC && @@ -3105,25 +3062,16 @@ static void buildDictionaryList(Entry *root) { addVariable(root); } - if (root->children()) - { - EntryListIterator eli(*root->children()); - Entry *e; - for (;(e=eli.current());++eli) - { - if (e->section!=Entry::ENUM_SEC) - { - buildDictionaryList(e); - } - } - } + for (const auto &e : root->children()) + if (e->section!=Entry::ENUM_SEC) + buildDictionaryList(e.get()); } //---------------------------------------------------------------------- // Searches the Entry tree for Variable documentation sections. // If found they are stored in their class or in the global list. -static void buildVarList(Entry *root) +static void buildVarList(const Entry *root) { //printf("buildVarList(%s) section=%08x\n",rootNav->name().data(),rootNav->section()); int isFuncPtr=-1; @@ -3143,18 +3091,9 @@ static void buildVarList(Entry *root) { addVariable(root,isFuncPtr); } - if (root->children()) - { - EntryListIterator eli(*root->children()); - Entry *e; - for (;(e=eli.current());++eli) - { - if (e->section!=Entry::ENUM_SEC) - { - buildVarList(e); - } - } - } + for (const auto &e : root->children()) + if (e->section!=Entry::ENUM_SEC) + buildVarList(e.get()); } //---------------------------------------------------------------------- @@ -3163,7 +3102,7 @@ static void buildVarList(Entry *root) // static void addInterfaceOrServiceToServiceOrSingleton( - Entry *const root, + const Entry *root, ClassDef *const cd, QCString const& rname) { @@ -3172,15 +3111,15 @@ static void addInterfaceOrServiceToServiceOrSingleton( ? MemberType_Interface : MemberType_Service; QCString fileName = root->fileName; - if (fileName.isEmpty() && root->tagInfo) + if (fileName.isEmpty() && root->tagInfo()) { - fileName = root->tagInfo->tagName; + fileName = root->tagInfo()->tagName; } MemberDef *const md = createMemberDef( fileName, root->startLine, root->startColumn, root->type, rname, "", "", root->protection, root->virt, root->stat, Member, - type, 0, root->argList, root->metaData); - md->setTagInfo(root->tagInfo); + type, ArgumentList(), root->argList, root->metaData); + md->setTagInfo(root->tagInfo()); md->setMemberClass(cd); md->setDocumentation(root->doc,root->docFile,root->docLine); md->setDocsForDefinition(false); @@ -3235,11 +3174,11 @@ static void addInterfaceOrServiceToServiceOrSingleton( cd->insertUsedFile(fd); addMemberToGroups(root,md); - root->changeSection(Entry::EMPTY_SEC); + root->markAsProcessed(); md->setRefItems(root->sli); } -static void buildInterfaceAndServiceList(Entry *root) +static void buildInterfaceAndServiceList(const Entry *root) { if (root->section==Entry::EXPORTED_INTERFACE_SEC || root->section==Entry::INCLUDED_SERVICE_SEC) @@ -3256,7 +3195,7 @@ static void buildInterfaceAndServiceList(Entry *root) qPrint(root->fileName), root->startLine, root->bodyLine, - root->tArgLists ? (int)root->tArgLists->count() : -1, + root->tArgLists.size(), root->mGrpId, root->spec, root->proto, @@ -3292,7 +3231,7 @@ static void buildInterfaceAndServiceList(Entry *root) { case SrcLangExt_Unknown: // fall through (root node always is Unknown) case SrcLangExt_IDL: - RECURSE_ENTRYTREE(buildInterfaceAndServiceList,root); + for (const auto &e : root->children()) buildInterfaceAndServiceList(e.get()); break; default: return; // nothing to do here @@ -3304,26 +3243,32 @@ static void buildInterfaceAndServiceList(Entry *root) // Searches the Entry tree for Function sections. // If found they are stored in their class or in the global list. -static void addMethodToClass(Entry *root,ClassDef *cd, - const QCString &rname,bool isFriend) +static void addMethodToClass(const Entry *root,ClassDef *cd, + const QCString &rtype,const QCString &rname,const QCString &rargs, + bool isFriend, + Protection protection,bool stat,Specifier virt,uint64 spec, + const QCString &relates + ) { FileDef *fd=root->fileDef(); int l; static QRegExp re("([a-z_A-Z0-9: ]*[ &*]+[ ]*"); - int ts=root->type.find('<'); - int te=root->type.findRev('>'); - int i=re.match(root->type,0,&l); + QCString type = rtype; + QCString args = rargs; + int ts=type.find('<'); + int te=type.findRev('>'); + int i=re.match(type,0,&l); if (i!=-1 && ts!=-1 && ts<te && ts<i && i<te) // avoid changing A<int(int*)>, see bug 677315 { i=-1; } if (cd->getLanguage()==SrcLangExt_Cpp && // only C has pointers - !root->type.isEmpty() && (root->spec&Entry::Alias)==0 && i!=-1) // function variable + !type.isEmpty() && (root->spec&Entry::Alias)==0 && i!=-1) // function variable { - root->args+=root->type.right(root->type.length()-i-l); - root->type=root->type.left(i+l); + args+=type.right(type.length()-i-l); + type=type.left(i+l); } QCString name=removeRedundantWhiteSpace(rname); @@ -3344,32 +3289,33 @@ static void addMethodToClass(Entry *root,ClassDef *cd, } QCString fileName = root->fileName; - if (fileName.isEmpty() && root->tagInfo) + if (fileName.isEmpty() && root->tagInfo()) { - fileName = root->tagInfo->tagName; + fileName = root->tagInfo()->tagName; } - //printf("root->name='%s; root->args='%s' root->argList='%s'\n", - // root->name.data(),root->args.data(),argListToString(root->argList).data() + //printf("root->name='%s; args='%s' root->argList='%s'\n", + // root->name.data(),args.data(),argListToString(root->argList).data() // ); // adding class member MemberDef *md=createMemberDef( fileName,root->startLine,root->startColumn, - root->type,name,root->args,root->exception, - root->protection,root->virt, - root->stat && root->relatesType != MemberOf, - root->relates.isEmpty() ? Member : + type,name,args,root->exception, + protection,virt, + stat && root->relatesType != MemberOf, + relates.isEmpty() ? Member : root->relatesType == MemberOf ? Foreign : Related, - mtype,root->tArgLists ? root->tArgLists->getLast() : 0,root->argList, root->metaData); - md->setTagInfo(root->tagInfo); + mtype,!root->tArgLists.empty() ? root->tArgLists.back() : ArgumentList(), + root->argList, root->metaData); + md->setTagInfo(root->tagInfo()); md->setMemberClass(cd); md->setDocumentation(root->doc,root->docFile,root->docLine); md->setDocsForDefinition(!root->proto); md->setBriefDescription(root->brief,root->briefFile,root->briefLine); md->setInbodyDocumentation(root->inbodyDocs,root->inbodyFile,root->inbodyLine); md->setBodySegment(root->bodyLine,root->endBodyLine); - md->setMemberSpecifiers(root->spec); + md->setMemberSpecifiers(spec); md->setMemberGroupId(root->mGrpId); md->setTypeConstraints(root->typeConstr); md->setLanguage(root->lang); @@ -3391,54 +3337,27 @@ static void addMethodToClass(Entry *root,ClassDef *cd, // for PHP we use Class::method and Namespace\method scopeSeparator="::"; } - if (!root->relates.isEmpty() || isFriend || Config_getBool(HIDE_SCOPE_NAMES)) +// QCString optArgs = root->argList.empty() ? args : QCString(); + if (!relates.isEmpty() || isFriend || Config_getBool(HIDE_SCOPE_NAMES)) { - if (!root->type.isEmpty()) + if (!type.isEmpty()) { - if (root->argList) - { - def=root->type+" "+name; - } - else - { - def=root->type+" "+name+root->args; - } + def=type+" "+name; //+optArgs; } else { - if (root->argList) - { - def=name; - } - else - { - def=name+root->args; - } + def=name; //+optArgs; } } else { - if (!root->type.isEmpty()) + if (!type.isEmpty()) { - if (root->argList) - { - def=root->type+" "+qualScope+scopeSeparator+name; - } - else - { - def=root->type+" "+qualScope+scopeSeparator+name+root->args; - } + def=type+" "+qualScope+scopeSeparator+name; //+optArgs; } else { - if (root->argList) - { - def=qualScope+scopeSeparator+name; - } - else - { - def=qualScope+scopeSeparator+name+root->args; - } + def=qualScope+scopeSeparator+name; //+optArgs; } } if (def.left(7)=="friend ") def=def.right(def.length()-7); @@ -3452,10 +3371,10 @@ static void addMethodToClass(Entry *root,ClassDef *cd, " Func Member:\n" " '%s' '%s'::'%s' '%s' proto=%d\n" " def='%s'\n", - qPrint(root->type), + qPrint(type), qPrint(qualScope), qPrint(rname), - qPrint(root->args), + qPrint(args), root->proto, qPrint(def) ); @@ -3480,12 +3399,12 @@ static void addMethodToClass(Entry *root,ClassDef *cd, cd->insertUsedFile(fd); addMemberToGroups(root,md); - root->changeSection(Entry::EMPTY_SEC); + root->markAsProcessed(); md->setRefItems(root->sli); } -static void buildFunctionList(Entry *root) +static void buildFunctionList(const Entry *root) { if (root->section==Entry::FUNCTION_SEC) { @@ -3501,7 +3420,7 @@ static void buildFunctionList(Entry *root) qPrint(root->fileName), root->startLine, root->bodyLine, - root->tArgLists ? (int)root->tArgLists->count() : -1, + root->tArgLists.size(), root->mGrpId, root->spec, root->proto, @@ -3576,7 +3495,8 @@ static void buildFunctionList(Entry *root) { Debug::print(Debug::Functions,0," --> member %s of class %s!\n", qPrint(rname),qPrint(cd->name())); - addMethodToClass(root,cd,rname,isFriend); + addMethodToClass(root,cd,root->type,rname,root->args,isFriend, + root->protection,root->stat,root->virt,root->spec,root->relates); } else if (!((root->parent()->section & Entry::COMPOUND_MASK) || root->parent()->section==Entry::OBJCIMPL_SEC @@ -3620,16 +3540,16 @@ static void buildFunctionList(Entry *root) if (rnd) rnsName = rnd->name().copy(); //printf("matching arguments for %s%s %s%s\n", // md->name().data(),md->argsString(),rname.data(),argListToString(root->argList).data()); - ArgumentList *mdAl = md->argumentList(); - const ArgumentList *mdTempl = md->templateArguments(); + ArgumentList &mdAl = md->argumentList(); + const ArgumentList &mdTempl = md->templateArguments(); // in case of template functions, we need to check if the // functions have the same number of template parameters bool sameNumTemplateArgs = TRUE; bool matchingReturnTypes = TRUE; - if (mdTempl!=0 && root->tArgLists) + if (!mdTempl.empty() && !root->tArgLists.empty()) { - if (mdTempl->count()!=root->tArgLists->getLast()->count()) + if (mdTempl.size()!=root->tArgLists.back().size()) { sameNumTemplateArgs = FALSE; } @@ -3652,9 +3572,9 @@ static void buildFunctionList(Entry *root) ) { GroupDef *gd=0; - if (root->groups->getFirst() && !root->groups->getFirst()->groupname.isEmpty()) + if (!root->groups.empty() && !root->groups.front().groupname.isEmpty()) { - gd = Doxygen::groupSDict->find(root->groups->getFirst()->groupname); + gd = Doxygen::groupSDict->find(root->groups.front().groupname); } //printf("match!\n"); //printf("mnd=%p rnd=%p nsName=%s rnsName=%s\n",mnd,rnd,nsName.data(),rnsName.data()); @@ -3677,11 +3597,12 @@ static void buildFunctionList(Entry *root) if (found) { // merge argument lists - mergeArguments(mdAl,root->argList,!root->doc.isEmpty()); + ArgumentList mergedArgList = root->argList; + mergeArguments(mdAl,mergedArgList,!root->doc.isEmpty()); // merge documentation if (md->documentation().isEmpty() && !root->doc.isEmpty()) { - ArgumentList *argList = new ArgumentList; + ArgumentList argList; stringToArgumentList(root->args,argList); if (root->proto) { @@ -3717,16 +3638,15 @@ static void buildFunctionList(Entry *root) md->enableReferencesRelation(md->hasReferencesRelation() || root->referencesRelation); // merge ingroup specifiers - if (md->getGroupDef()==0 && root->groups->getFirst()!=0) + if (md->getGroupDef()==0 && !root->groups.empty()) { addMemberToGroups(root,md); } - else if (md->getGroupDef()!=0 && root->groups->count()==0) + else if (md->getGroupDef()!=0 && root->groups.empty()) { //printf("existing member is grouped, new member not\n"); - root->groups->append(new Grouping(md->getGroupDef()->name(), md->getGroupPri())); } - else if (md->getGroupDef()!=0 && root->groups->getFirst()!=0) + else if (md->getGroupDef()!=0 && !root->groups.empty()) { //printf("both members are grouped\n"); } @@ -3755,15 +3675,16 @@ static void buildFunctionList(Entry *root) // root->type.data(),rname.data(),root->args.data(),root->bodyLine); // new global function - ArgumentList *tArgList = root->tArgLists ? root->tArgLists->getLast() : 0; QCString name=removeRedundantWhiteSpace(rname); md=createMemberDef( root->fileName,root->startLine,root->startColumn, root->type,name,root->args,root->exception, root->protection,root->virt,root->stat,Member, - MemberType_Function,tArgList,root->argList,root->metaData); + MemberType_Function, + !root->tArgLists.empty() ? root->tArgLists.back() : ArgumentList(), + root->argList,root->metaData); - md->setTagInfo(root->tagInfo); + md->setTagInfo(root->tagInfo()); md->setLanguage(root->lang); md->setId(root->id); //md->setDefFile(root->fileName); @@ -3805,27 +3726,14 @@ static void buildFunctionList(Entry *root) } QCString def; + //QCString optArgs = root->argList.empty() ? QCString() : root->args; if (!root->type.isEmpty()) { - if (root->argList) - { - def=root->type+" "+scope+name; - } - else - { - def=root->type+" "+scope+name+root->args; - } + def=root->type+" "+scope+name; //+optArgs; } else { - if (root->argList) - { - def=scope+name.copy(); - } - else - { - def=scope+name+root->args; - } + def=scope+name; //+optArgs; } Debug::print(Debug::Functions,0, " Global Function:\n" @@ -3880,9 +3788,7 @@ static void buildFunctionList(Entry *root) if (root->relatesType == Simple) // if this is a relatesalso command, // allow find Member to pick it up { - root->changeSection(Entry::EMPTY_SEC); // Otherwise we have finished - // with this entry. - + root->markAsProcessed(); // Otherwise we have finished with this entry. } } else @@ -3911,7 +3817,7 @@ static void buildFunctionList(Entry *root) ); } } - RECURSE_ENTRYTREE(buildFunctionList,root); + for (const auto &e : root->children()) buildFunctionList(e.get()); } //---------------------------------------------------------------------- @@ -3951,8 +3857,8 @@ static void findFriends() ) // if the member is related and the arguments match then the // function is actually a friend. { - ArgumentList *mmdAl = mmd->argumentList(); - ArgumentList *fmdAl = fmd->argumentList(); + ArgumentList &mmdAl = mmd->argumentList(); + ArgumentList &fmdAl = fmd->argumentList(); mergeArguments(mmdAl,fmdAl); if (!fmd->documentation().isEmpty()) { @@ -4033,7 +3939,7 @@ static void transferFunctionDocumentation() MemberNameIterator mni2(*mn); for (;(mdef=mni2.current());++mni2) { - if (!mdec->isAlias() && !mdef->isAlias()) + if (mdec!=mdef && !mdec->isAlias() && !mdef->isAlias()) { combineDeclarationAndDefinition(mdec,mdef); } @@ -4068,8 +3974,8 @@ static void transferFunctionReferences() } if (mdef && mdec) { - ArgumentList *mdefAl = mdef->argumentList(); - ArgumentList *mdecAl = mdec->argumentList(); + ArgumentList &mdefAl = mdef->argumentList(); + ArgumentList &mdecAl = mdec->argumentList(); if ( matchArguments2(mdef->getOuterScope(),mdef->getFileDef(),mdefAl, mdec->getOuterScope(),mdec->getFileDef(),mdecAl, @@ -4189,31 +4095,26 @@ static void transferRelatedFunctionDocumentation() * Example: A template class A with template arguments <R,S,T> * that inherits from B<T,T,S> will have T and S in the dictionary. */ -static QDict<int> *getTemplateArgumentsInName(ArgumentList *templateArguments,const QCString &name) +static QDict<int> *getTemplateArgumentsInName(const ArgumentList &templateArguments,const QCString &name) { QDict<int> *templateNames = new QDict<int>(17); templateNames->setAutoDelete(TRUE); static QRegExp re("[a-z_A-Z][a-z_A-Z0-9:]*"); - if (templateArguments) + int count=0; + for (const Argument &arg : templateArguments) { - ArgumentListIterator ali(*templateArguments); - Argument *arg; - int count=0; - for (ali.toFirst();(arg=ali.current());++ali,count++) + int i,p=0,l; + while ((i=re.match(name,p,&l))!=-1) { - int i,p=0,l; - while ((i=re.match(name,p,&l))!=-1) + QCString n = name.mid(i,l); + if (n==arg.name) { - QCString n = name.mid(i,l); - if (n==arg->name) + if (templateNames->find(n)==0) { - if (templateNames->find(n)==0) - { - templateNames->insert(n,new int(count)); - } + templateNames->insert(n,new int(count)); } - p=i+l; } + p=i+l; } } return templateNames; @@ -4259,17 +4160,17 @@ static ClassDef *findClassWithinClassContext(Definition *context,ClassDef *cd,co } -static void findUsedClassesForClass(Entry *root, +static void findUsedClassesForClass(const Entry *root, Definition *context, ClassDef *masterCd, ClassDef *instanceCd, bool isArtificial, - ArgumentList *actualArgs=0, + const ArgumentList &actualArgs=ArgumentList(), QDict<int> *templateNames=0 ) { masterCd->setVisited(TRUE); - ArgumentList *formalArgs = masterCd->templateArguments(); + const ArgumentList &formalArgs = masterCd->templateArguments(); if (masterCd->memberNameInfoSDict()) { MemberNameInfoSDict::Iterator mnili(*masterCd->memberNameInfoSDict()); @@ -4295,10 +4196,7 @@ static void findUsedClassesForClass(Entry *root, QCString templSpec; bool found=FALSE; // the type can contain template variables, replace them if present - if (actualArgs) - { - type = substituteTemplateArgumentsInString(type,formalArgs,actualArgs); - } + type = substituteTemplateArgumentsInString(type,formalArgs,actualArgs); //printf(" template substitution gives=%s\n",type.data()); while (!found && extractClassNameFromType(type,pos,usedClassName,templSpec,root->lang)!=-1) @@ -4338,37 +4236,32 @@ static void findUsedClassesForClass(Entry *root, BaseInfo bi(usedName,Public,Normal); findClassRelation(root,context,instanceCd,&bi,templateNames,TemplateInstances,isArtificial); - if (masterCd->templateArguments()) + int count=0; + for (const Argument &arg : masterCd->templateArguments()) { - ArgumentListIterator ali(*masterCd->templateArguments()); - Argument *arg; - int count=0; - for (ali.toFirst();(arg=ali.current());++ali,++count) + if (arg.name==usedName) // type is a template argument { - if (arg->name==usedName) // type is a template argument - { - found=TRUE; - Debug::print(Debug::Classes,0," New used class '%s'\n", qPrint(usedName)); + found=TRUE; + Debug::print(Debug::Classes,0," New used class '%s'\n", qPrint(usedName)); - ClassDef *usedCd = Doxygen::hiddenClasses->find(usedName); - if (usedCd==0) - { - usedCd = createClassDef( - masterCd->getDefFileName(),masterCd->getDefLine(), - masterCd->getDefColumn(), - usedName, - ClassDef::Class); - //printf("making %s a template argument!!!\n",usedCd->name().data()); - usedCd->makeTemplateArgument(); - usedCd->setUsedOnly(TRUE); - usedCd->setLanguage(masterCd->getLanguage()); - Doxygen::hiddenClasses->append(usedName,usedCd); - } - if (isArtificial) usedCd->setArtificial(TRUE); - Debug::print(Debug::Classes,0," Adding used class '%s' (1)\n", qPrint(usedCd->name())); - instanceCd->addUsedClass(usedCd,md->name(),md->protection()); - usedCd->addUsedByClass(instanceCd,md->name(),md->protection()); + ClassDef *usedCd = Doxygen::hiddenClasses->find(usedName); + if (usedCd==0) + { + usedCd = createClassDef( + masterCd->getDefFileName(),masterCd->getDefLine(), + masterCd->getDefColumn(), + usedName, + ClassDef::Class); + //printf("making %s a template argument!!!\n",usedCd->name().data()); + usedCd->makeTemplateArgument(); + usedCd->setUsedOnly(TRUE); + usedCd->setLanguage(masterCd->getLanguage()); + Doxygen::hiddenClasses->append(usedName,usedCd); } + if (isArtificial) usedCd->setArtificial(TRUE); + Debug::print(Debug::Classes,0," Adding used class '%s' (1)\n", qPrint(usedCd->name())); + instanceCd->addUsedClass(usedCd,md->name(),md->protection()); + usedCd->addUsedByClass(instanceCd,md->name(),md->protection()); } } @@ -4429,37 +4322,32 @@ static void findUsedClassesForClass(Entry *root, } static void findBaseClassesForClass( - Entry *root, + const Entry *root, Definition *context, ClassDef *masterCd, ClassDef *instanceCd, FindBaseClassRelation_Mode mode, bool isArtificial, - ArgumentList *actualArgs=0, + const ArgumentList &actualArgs=ArgumentList(), QDict<int> *templateNames=0 ) { //if (masterCd->visited) return; masterCd->setVisited(TRUE); // The base class could ofcouse also be a non-nested class - ArgumentList *formalArgs = masterCd->templateArguments(); - QListIterator<BaseInfo> bii(*root->extends); - BaseInfo *bi=0; - for (bii.toFirst();(bi=bii.current());++bii) + const ArgumentList &formalArgs = masterCd->templateArguments(); + 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); - if (actualArgs) // substitute the formal template arguments of the base class - { - 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) @@ -4491,7 +4379,7 @@ static void findBaseClassesForClass( //---------------------------------------------------------------------- -static bool findTemplateInstanceRelation(Entry *root, +static bool findTemplateInstanceRelation(const Entry *root, Definition *context, ClassDef *templateClass,const QCString &templSpec, QDict<int> *templateNames, @@ -4531,19 +4419,19 @@ static bool findTemplateInstanceRelation(Entry *root, // search for new template instances caused by base classes of // instanceClass - Entry *templateRoot = g_classEntries.find(templateClass->name()); - if (templateRoot) + auto it = g_classEntries.find(templateClass->name().data()); + if (it!=g_classEntries.end()) { + const Entry *templateRoot = it->second; Debug::print(Debug::Classes,0," template root found %s templSpec=%s!\n", qPrint(templateRoot->name),qPrint(templSpec)); - ArgumentList *templArgs = new ArgumentList; + ArgumentList templArgs; stringToArgumentList(templSpec,templArgs); findBaseClassesForClass(templateRoot,context,templateClass,instanceClass, TemplateInstances,isArtificial,templArgs,templateNames); findUsedClassesForClass(templateRoot,context,templateClass,instanceClass, isArtificial,templArgs,templateNames); - delete templArgs; } else { @@ -4653,10 +4541,10 @@ static int findEndOfTemplate(const QCString &s,int startPos) } static bool findClassRelation( - Entry *root, + const Entry *root, Definition *context, ClassDef *cd, - BaseInfo *bi, + const BaseInfo *bi, QDict<int> *templateNames, FindBaseClassRelation_Mode mode, bool isArtificial @@ -4884,13 +4772,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 { @@ -4939,7 +4827,7 @@ static bool findClassRelation( int si = baseClassName.findRev("::"); if (si!=-1) // class is nested { - Definition *sd = findScopeFromQualifiedName(Doxygen::globalScope,baseClassName.left(si),0,root->tagInfo); + Definition *sd = findScopeFromQualifiedName(Doxygen::globalScope,baseClassName.left(si),0,root->tagInfo()); if (sd==0 || sd==Doxygen::globalScope) // outer scope not found { baseClass->setArtificial(TRUE); // see bug678139 @@ -5010,7 +4898,7 @@ static bool findClassRelation( //---------------------------------------------------------------------- // Computes the base and super classes for each class in the tree -static bool isClassSection(Entry *root) +static bool isClassSection(const Entry *root) { if ( !root->name.isEmpty() ) { @@ -5022,8 +4910,8 @@ static bool isClassSection(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; @@ -5032,16 +4920,16 @@ static bool isClassSection(Entry *root) /*! Builds a dictionary of all entry nodes in the tree starting with \a root */ -static void findClassEntries(Entry *root) +static void findClassEntries(const Entry *root) { if (isClassSection(root)) { - g_classEntries.insert(root->name,root); + g_classEntries.insert({root->name.data(),root}); } - RECURSE_ENTRYTREE(findClassEntries,root); + for (const auto &e : root->children()) findClassEntries(e.get()); } -static QCString extractClassName(Entry *root) +static QCString extractClassName(const Entry *root) { // strip any anonymous scopes first QCString bName=stripAnonymousNamespaceScope(root->name); @@ -5066,10 +4954,9 @@ static void findInheritedTemplateInstances() { ClassSDict::Iterator cli(*Doxygen::classSDict); for (cli.toFirst();cli.current();++cli) cli.current()->setVisited(FALSE); - QDictIterator<Entry> edi(g_classEntries); - Entry *root; - for (;(root=edi.current());++edi) + for (const auto &kv : g_classEntries) { + const Entry *root = kv.second; ClassDef *cd; QCString bName = extractClassName(root); Debug::print(Debug::Classes,0," Inheritance: Class %s : \n",qPrint(bName)); @@ -5085,10 +4972,9 @@ static void findUsedTemplateInstances() { ClassSDict::Iterator cli(*Doxygen::classSDict); for (cli.toFirst();cli.current();++cli) cli.current()->setVisited(FALSE); - QDictIterator<Entry> edi(g_classEntries); - Entry *root; - for (;(root=edi.current());++edi) + for (const auto &kv : g_classEntries) { + const Entry *root = kv.second; ClassDef *cd; QCString bName = extractClassName(root); Debug::print(Debug::Classes,0," Usage: Class %s : \n",qPrint(bName)); @@ -5104,10 +4990,9 @@ static void computeClassRelations() { ClassSDict::Iterator cli(*Doxygen::classSDict); for (cli.toFirst();cli.current();++cli) cli.current()->setVisited(FALSE); - QDictIterator<Entry> edi(g_classEntries); - Entry *root; - for (;(root=edi.current());++edi) + for (const auto &kv : g_classEntries) { + const Entry *root = kv.second; ClassDef *cd; QCString bName = extractClassName(root); @@ -5137,10 +5022,9 @@ static void computeClassRelations() static void computeTemplateClassRelations() { - QDictIterator<Entry> edi(g_classEntries); - Entry *root; - for (;(root=edi.current());++edi) + for (const auto &kv : g_classEntries) { + const Entry *root = kv.second; QCString bName=stripAnonymousNamespaceScope(root->name); bName=stripTemplateSpecifiersFromScope(bName); ClassDef *cd=getClass(bName); @@ -5155,20 +5039,17 @@ static void computeTemplateClassRelations() { Debug::print(Debug::Classes,0," Template instance %s : \n",qPrint(tcd->name())); QCString templSpec = tdi.currentKey(); - ArgumentList *templArgs = new ArgumentList; + 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); - ArgumentList *tl = cd->templateArguments(); - if (tl) + 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); @@ -5177,23 +5058,25 @@ static void computeTemplateClassRelations() for (qdi.toFirst();qdi.current();++qdi) { int templIndex = *qdi.current(); - Argument *actArg = 0; - if (templIndex<(int)templArgs->count()) + Argument actArg; + bool hasActArg=FALSE; + if (templIndex<(int)templArgs.size()) { - actArg=templArgs->at(templIndex); + actArg=templArgs.at(templIndex); + hasActArg=TRUE; } - if (actArg!=0 && + if (hasActArg && baseClassNames!=0 && - baseClassNames->find(actArg->type)!=0 && - actualTemplateNames->find(actArg->type)==0 + baseClassNames->find(actArg.type)!=0 && + actualTemplateNames->find(actArg.type)==0 ) { - actualTemplateNames->insert(actArg->type,new int(templIndex)); + actualTemplateNames->insert(actArg.type,new int(templIndex)); } } 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)) { @@ -5203,7 +5086,6 @@ static void computeTemplateClassRelations() delete actualTemplateNames; } } - delete templArgs; } // class has no base classes } } @@ -5298,7 +5180,7 @@ static void addListReferences() name = pd->getGroupDef()->getOutputFileBase(); } { - QList<ListItemInfo> *xrefItems = pd->xrefListItems(); + const std::vector<ListItemInfo> &xrefItems = pd->xrefListItems(); addRefItem(xrefItems, name, theTranslator->trPage(TRUE,TRUE), @@ -5315,7 +5197,7 @@ static void addListReferences() //{ // name = dd->getGroupDef()->getOutputFileBase(); //} - QList<ListItemInfo> *xrefItems = dd->xrefListItems(); + const std::vector<ListItemInfo> &xrefItems = dd->xrefListItems(); addRefItem(xrefItems, name, theTranslator->trDir(TRUE,TRUE), @@ -5340,15 +5222,15 @@ static void generateXRefPages() // set the function declaration of the member to 'funcDecl'. If the boolean // over_load is set the standard overload text is added. -static void addMemberDocs(Entry *root, +static void addMemberDocs(const Entry *root, MemberDef *md, const char *funcDecl, - ArgumentList *al, + const ArgumentList *al, bool over_load, - NamespaceSDict * + uint64 spec ) { - //printf("addMemberDocs: '%s'::'%s' '%s' funcDecl='%s' mSpec=%d\n", - // root->parent->name.data(),md->name().data(),md->argsString(),funcDecl,root->spec); + //printf("addMemberDocs: '%s'::'%s' '%s' funcDecl='%s' mSpec=%lld\n", + // root->parent()->name.data(),md->name().data(),md->argsString(),funcDecl,spec); QCString fDecl=funcDecl; // strip extern specifier fDecl.stripPrefix("extern "); @@ -5372,11 +5254,12 @@ static void addMemberDocs(Entry *root, // TODO determine scope based on root not md Definition *rscope = md->getOuterScope(); - ArgumentList *mdAl = md->argumentList(); + ArgumentList &mdAl = md->argumentList(); if (al) { + ArgumentList mergedAl = *al; //printf("merging arguments (1) docs=%d\n",root->doc.isEmpty()); - mergeArguments(mdAl,al,!root->doc.isEmpty()); + mergeArguments(mdAl,mergedAl,!root->doc.isEmpty()); } else { @@ -5388,7 +5271,8 @@ static void addMemberDocs(Entry *root, ) { //printf("merging arguments (2)\n"); - mergeArguments(mdAl,root->argList,!root->doc.isEmpty()); + ArgumentList mergedArgList = root->argList; + mergeArguments(mdAl,mergedArgList,!root->doc.isEmpty()); } } if (over_load) // the \overload keyword was used @@ -5452,7 +5336,7 @@ static void addMemberDocs(Entry *root, md->enableReferencedByRelation(md->hasReferencedByRelation() || root->referencedByRelation); md->enableReferencesRelation(md->hasReferencesRelation() || root->referencesRelation); - md->mergeMemberSpecifiers(root->spec); + md->mergeMemberSpecifiers(spec); md->addSectionsToDefinition(root->anchors); addMemberToGroups(root,md); if (cd) cd->insertUsedFile(rfd); @@ -5496,13 +5380,14 @@ static const ClassDef *findClassDefinition(FileDef *fd,NamespaceDef *nd, // with name 'name' and argument list 'args' (for overloading) and // function declaration 'decl' to the corresponding member definition. -static bool findGlobalMember(Entry *root, +static bool findGlobalMember(const Entry *root, const QCString &namespaceName, const char *type, const char *name, const char *tempArg, const char *, - const char *decl) + const char *decl, + uint64 spec) { Debug::print(Debug::FindMembers,0, "2. findGlobalMember(namespace=%s,type=%s,name=%s,tempArg=%s,decl=%s)\n", @@ -5558,9 +5443,9 @@ static bool findGlobalMember(Entry *root, NamespaceDef *rnd = 0; if (!namespaceName.isEmpty()) rnd = Doxygen::namespaceSDict->find(namespaceName); - const ArgumentList *mdAl = const_cast<const MemberDef *>(md)->argumentList(); + const ArgumentList &mdAl = const_cast<const MemberDef *>(md)->argumentList(); bool matching= - (mdAl==0 && root->argList->count()==0) || + (mdAl.empty() && root->argList.empty()) || md->isVariable() || md->isTypedef() || /* in case of function pointers */ matchArguments2(md->getOuterScope(),const_cast<const MemberDef *>(md)->getFileDef(),mdAl, rnd ? rnd : Doxygen::globalScope,fd,root->argList, @@ -5569,15 +5454,12 @@ static bool findGlobalMember(Entry *root, // for template members we need to check if the number of // template arguments is the same, otherwise we are dealing with // different functions. - if (matching && root->tArgLists) + if (matching && !root->tArgLists.empty()) { - const ArgumentList *mdTempl = md->templateArguments(); - if (mdTempl) + const ArgumentList &mdTempl = md->templateArguments(); + if (root->tArgLists.back().size()!=mdTempl.size()) { - if (root->tArgLists->getLast()->count()!=mdTempl->count()) - { - matching=FALSE; - } + matching=FALSE; } } @@ -5597,11 +5479,11 @@ static bool findGlobalMember(Entry *root, } // for template member we also need to check the return type - if (md->templateArguments()!=0 && root->tArgLists!=0) + if (!md->templateArguments().empty() && !root->tArgLists.empty()) { //printf("Comparing return types '%s'<->'%s'\n", // md->typeString(),type); - if (md->templateArguments()->count()!=root->tArgLists->getLast()->count() || + if (md->templateArguments().size()!=root->tArgLists.back().size() || qstrcmp(md->typeString(),type)!=0) { //printf(" ---> no matching\n"); @@ -5612,7 +5494,7 @@ static bool findGlobalMember(Entry *root, if (matching) // add docs to the member { Debug::print(Debug::FindMembers,0,"5. Match found\n"); - addMemberDocs(root,md->resolveAlias(),decl,root->argList,FALSE); + addMemberDocs(root,md->resolveAlias(),decl,&root->argList,FALSE,root->spec); found=TRUE; } } @@ -5620,7 +5502,7 @@ static bool findGlobalMember(Entry *root, if (!found && root->relatesType != Duplicate && root->section==Entry::FUNCTION_SEC) // no match { QCString fullFuncDecl=decl; - if (root->argList) fullFuncDecl+=argListToString(root->argList,TRUE); + if (!root->argList.empty()) fullFuncDecl+=argListToString(root->argList,TRUE); QCString warnMsg = QCString("no matching file member found for \n")+substitute(fullFuncDecl,"%","%%"); if (mn->count()>0) @@ -5656,17 +5538,17 @@ static bool findGlobalMember(Entry *root, } static bool isSpecialization( - const QList<ArgumentList> &srcTempArgLists, - const QList<ArgumentList> &dstTempArgLists + const std::vector<ArgumentList> &srcTempArgLists, + const std::vector<ArgumentList> &dstTempArgLists ) { - QListIterator<ArgumentList> srclali(srcTempArgLists); - QListIterator<ArgumentList> dstlali(dstTempArgLists); - for (;srclali.current();++srclali,++dstlali) + auto srcIt = srcTempArgLists.begin(); + auto dstIt = dstTempArgLists.begin(); + while (srcIt!=srcTempArgLists.end() && dstIt!=dstTempArgLists.end()) { - ArgumentList *sal = srclali.current(); - ArgumentList *dal = dstlali.current(); - if (!(sal && dal && sal->count()==dal->count())) return TRUE; + if ((*srcIt).size()!=(*dstIt).size()) return TRUE; + ++srcIt; + ++dstIt; } return FALSE; } @@ -5676,15 +5558,15 @@ static bool scopeIsTemplate(const Definition *d) bool result=FALSE; if (d && d->definitionType()==Definition::TypeClass) { - result = (dynamic_cast<const ClassDef*>(d))->templateArguments() || scopeIsTemplate(d->getOuterScope()); + result = !(dynamic_cast<const ClassDef*>(d))->templateArguments().empty() || + scopeIsTemplate(d->getOuterScope()); } return result; } static QCString substituteTemplatesInString( - const QList<ArgumentList> &srcTempArgLists, - const QList<ArgumentList> &dstTempArgLists, - ArgumentList *funcTempArgList, // can be used to match template specializations + const std::vector<ArgumentList> &srcTempArgLists, + const std::vector<ArgumentList> &dstTempArgLists, const QCString &src ) { @@ -5698,61 +5580,59 @@ static QCString substituteTemplatesInString( dst+=src.mid(p,i-p); QCString name=src.mid(i,l); - QListIterator<ArgumentList> srclali(srcTempArgLists); - QListIterator<ArgumentList> dstlali(dstTempArgLists); - for (;srclali.current() && !found;++srclali,++dstlali) + auto srcIt = srcTempArgLists.begin(); + auto dstIt = dstTempArgLists.begin(); + while (srcIt!=srcTempArgLists.end() && !found) { - ArgumentListIterator tsali(*srclali.current()); - ArgumentListIterator tdali(*dstlali.current()); - ArgumentListIterator *fali=0; - Argument *tsa =0,*tda=0, *fa=0; - if (funcTempArgList) + const ArgumentList *tdAli = 0; + std::vector<Argument>::const_iterator tdaIt; + if (dstIt!=dstTempArgLists.end()) { - fali = new ArgumentListIterator(*funcTempArgList); - fa = fali->current(); + tdAli = &(*dstIt); + tdaIt = tdAli->begin(); + ++dstIt; } - for (tsali.toFirst();(tsa=tsali.current()) && !found;++tsali) + const ArgumentList &tsaLi = *srcIt; + for (auto tsaIt = tsaLi.begin(); tsaIt!=tsaLi.end() && !found; ++tsaIt) { - tda = tdali.current(); + Argument tsa = *tsaIt; + const Argument *tda = 0; + if (tdAli && tdaIt!=tdAli->end()) + { + tda = &(*tdaIt); + ++tdaIt; + } //if (tda) printf("tsa=%s|%s tda=%s|%s\n", - // tsa->type.data(),tsa->name.data(), + // tsa.type.data(),tsa.name.data(), // tda->type.data(),tda->name.data()); - if (name==tsa->name) + if (name==tsa.name) { if (tda && tda->name.isEmpty()) { + QCString tdaName = tda->name; + QCString tdaType = tda->type; int vc=0; - if (tda->type.left(6)=="class ") vc=6; - else if (tda->type.left(9)=="typename ") vc=9; + if (tdaType.left(6)=="class ") vc=6; + else if (tdaType.left(9)=="typename ") vc=9; if (vc>0) // convert type=="class T" to type=="class" name=="T" { - tda->name = tda->type.mid(vc); - tda->type = tda->type.left(vc-1); + tdaName = tdaType.mid(vc); + } + if (!tdaName.isEmpty()) + { + name=tdaName; // substitute + found=TRUE; } - } - if (tda && !tda->name.isEmpty()) - { - name=tda->name; // substitute - found=TRUE; - } - else if (fa) - { - name=fa->type; - found=TRUE; } } - if (tda) - ++tdali; - else if (fali) - { ++(*fali); fa=fali->current(); } } - delete fali; //printf(" srcList='%s' dstList='%s faList='%s'\n", // argListToString(srclali.current()).data(), // argListToString(dstlali.current()).data(), // funcTempArgList ? argListToString(funcTempArgList).data() : "<none>"); + ++srcIt; } dst+=name; p=i+l; @@ -5764,48 +5644,39 @@ static QCString substituteTemplatesInString( } static void substituteTemplatesInArgList( - const QList<ArgumentList> &srcTempArgLists, - const QList<ArgumentList> &dstTempArgLists, - ArgumentList *src, - ArgumentList *dst, - ArgumentList *funcTempArgs = 0 + const std::vector<ArgumentList> &srcTempArgLists, + const std::vector<ArgumentList> &dstTempArgLists, + const ArgumentList &src, + ArgumentList &dst ) { - ArgumentListIterator sali(*src); - ArgumentListIterator dali(*dst); - Argument *sa=0; - Argument *da=dali.current(); - - for (sali.toFirst();(sa=sali.current());++sali) // for each member argument + auto dstIt = dst.begin(); + for (const Argument &sa : src) { - QCString dstType = substituteTemplatesInString( - srcTempArgLists,dstTempArgLists,funcTempArgs, - sa->type); - QCString dstArray = substituteTemplatesInString( - srcTempArgLists,dstTempArgLists,funcTempArgs, - sa->array); - if (da==0) + QCString dstType = substituteTemplatesInString(srcTempArgLists,dstTempArgLists,sa.type); + QCString dstArray = substituteTemplatesInString(srcTempArgLists,dstTempArgLists,sa.array); + if (dstIt == dst.end()) { - da=new Argument(*sa); - dst->append(da); - da->type=dstType; - da->array=dstArray; - da=0; + Argument da = sa; + da.type = dstType; + da.array = dstArray; + dst.push_back(da); + dstIt = dst.end(); } else { - da->type=dstType; - da->type=dstArray; - ++dali; - da=dali.current(); + Argument da = *dstIt; + da.type = dstType; + da.array = dstArray; + ++dstIt; } } - dst->constSpecifier = src->constSpecifier; - dst->volatileSpecifier = src->volatileSpecifier; - dst->pureSpecifier = src->pureSpecifier; - dst->trailingReturnType = substituteTemplatesInString( + dst.constSpecifier = src.constSpecifier; + dst.volatileSpecifier = src.volatileSpecifier; + dst.pureSpecifier = src.pureSpecifier; + dst.trailingReturnType = substituteTemplatesInString( srcTempArgLists,dstTempArgLists, - funcTempArgs,src->trailingReturnType); + src.trailingReturnType); //printf("substituteTemplatesInArgList: replacing %s with %s\n", // argListToString(src).data(),argListToString(dst).data() // ); @@ -5822,7 +5693,10 @@ static void substituteTemplatesInArgList( * The boolean \a isFunc is a hint that indicates that this is a function * instead of a variable or typedef. */ -static void findMember(Entry *root, +static void findMember(const Entry *root, + const QCString &relates, + const QCString &type, + const QCString &args, QCString funcDecl, bool overloaded, bool isFunc @@ -5830,10 +5704,10 @@ static void findMember(Entry *root, { Debug::print(Debug::FindMembers,0, "findMember(root=%p,funcDecl='%s',related='%s',overload=%d," - "isFunc=%d mGrpId=%d tArgList=%p (#=%d) " + "isFunc=%d mGrpId=%d #tArgList=%d " "spec=%lld lang=%x\n", - root,qPrint(funcDecl),qPrint(root->relates),overloaded,isFunc,root->mGrpId, - root->tArgLists,root->tArgLists ? root->tArgLists->count() : 0, + root,qPrint(funcDecl),qPrint(relates),overloaded,isFunc,root->mGrpId, + root->tArgLists.size(), root->spec,root->lang ); @@ -5850,6 +5724,7 @@ static void findMember(Entry *root, bool isMemberOf=FALSE; bool isFriend=FALSE; bool done; + uint64 spec = root->spec; do { done=TRUE; @@ -5860,17 +5735,17 @@ static void findMember(Entry *root, } if (funcDecl.stripPrefix("inline ")) { - root->spec|=Entry::Inline; + spec|=Entry::Inline; done=FALSE; } if (funcDecl.stripPrefix("explicit ")) { - root->spec|=Entry::Explicit; + spec|=Entry::Explicit; done=FALSE; } if (funcDecl.stripPrefix("mutable ")) { - root->spec|=Entry::Mutable; + spec|=Entry::Mutable; done=FALSE; } if (funcDecl.stripPrefix("virtual ")) @@ -5926,21 +5801,21 @@ static void findMember(Entry *root, // related field. //printf("scopeName='%s' className='%s' namespaceName='%s'\n", // scopeName.data(),className.data(),namespaceName.data()); - if (!root->relates.isEmpty()) + if (!relates.isEmpty()) { // related member, prefix user specified scope isRelated=TRUE; isMemberOf=(root->relatesType == MemberOf); - if (getClass(root->relates)==0 && !scopeName.isEmpty()) + if (getClass(relates)==0 && !scopeName.isEmpty()) { - scopeName= mergeScopes(scopeName,root->relates); + scopeName= mergeScopes(scopeName,relates); } else { - scopeName = root->relates; + scopeName = relates; } } - if (root->relates.isEmpty() && root->parent() && + if (relates.isEmpty() && root->parent() && ((root->parent()->section&Entry::SCOPE_MASK) || (root->parent()->section==Entry::OBJCIMPL_SEC) ) && @@ -5989,9 +5864,8 @@ static void findMember(Entry *root, // empty while funcSpec is not empty we assume this is a // specialization of a method. If not, we clear the funcSpec and treat // this as a normal method of a template class. - if (!(root->tArgLists && - root->tArgLists->count()>0 && - root->tArgLists->getFirst()->count()==0 + if (!(root->tArgLists.size()>0 && + root->tArgLists.front().size()==0 ) ) { @@ -6015,7 +5889,7 @@ static void findMember(Entry *root, { scopeName=namespaceName; } - else if (!root->relates.isEmpty() || // relates command with explicit scope + else if (!relates.isEmpty() || // relates command with explicit scope !getClass(className)) // class name only exists in a namespace { scopeName=namespaceName+"::"+className; @@ -6038,7 +5912,7 @@ static void findMember(Entry *root, if (funcSpec.isEmpty()) { int argListIndex=0; - tempScopeName=cd->qualifiedNameWithTemplateParameters(root->tArgLists,&argListIndex); + tempScopeName=cd->qualifiedNameWithTemplateParameters(&root->tArgLists,&argListIndex); } else { @@ -6122,7 +5996,7 @@ static void findMember(Entry *root, " isFunc=%d\n\n", qPrint(namespaceName),qPrint(className), qPrint(funcType),qPrint(funcSpec),qPrint(funcName),qPrint(funcArgs),qPrint(funcTempList), - qPrint(funcDecl),qPrint(root->relates),qPrint(exceptions),isRelated,isMemberOf,isFriend, + qPrint(funcDecl),qPrint(relates),qPrint(exceptions),isRelated,isMemberOf,isFriend, isFunc ); @@ -6188,39 +6062,33 @@ static void findMember(Entry *root, "4. class definition %s found\n",cd->name().data()); // get the template parameter lists found at the member declaration - QList<ArgumentList> declTemplArgs; - cd->getTemplateParameterLists(declTemplArgs); - const ArgumentList *templAl = md->templateArguments(); - if (templAl) + std::vector<ArgumentList> declTemplArgs = cd->getTemplateParameterLists(); + const ArgumentList &templAl = md->templateArguments(); + if (!templAl.empty()) { - declTemplArgs.append(templAl); + declTemplArgs.push_back(templAl); } // get the template parameter lists found at the member definition - QList<ArgumentList> *defTemplArgs = root->tArgLists; + const std::vector<ArgumentList> &defTemplArgs = root->tArgLists; //printf("defTemplArgs=%p\n",defTemplArgs); // do we replace the decl argument lists with the def argument lists? bool substDone=FALSE; - ArgumentList *argList=0; + ArgumentList argList; /* substitute the occurrences of class template names in the * argument list before matching */ - ArgumentList *mdAl = md->argumentList(); - if (declTemplArgs.count()>0 && defTemplArgs && - declTemplArgs.count()==defTemplArgs->count() && - mdAl - ) + const ArgumentList &mdAl = md->argumentList(); + if (declTemplArgs.size()>0 && declTemplArgs.size()==defTemplArgs.size()) { /* the function definition has template arguments * and the class definition also has template arguments, so * we must substitute the template names of the class by that * of the function definition before matching. */ - argList = new ArgumentList; - substituteTemplatesInArgList(declTemplArgs,*defTemplArgs, - mdAl,argList); + substituteTemplatesInArgList(declTemplArgs,defTemplArgs,mdAl,argList); substDone=TRUE; } @@ -6237,7 +6105,7 @@ static void findMember(Entry *root, bool matching= md->isVariable() || md->isTypedef() || // needed for function pointers - (mdAl==0 && root->argList->count()==0) || + (mdAl.empty() && root->argList.empty()) || matchArguments2( md->getClassDef(),md->getFileDef(),argList, cd,fd,root->argList, @@ -6249,7 +6117,7 @@ static void findMember(Entry *root, } // for template member we also need to check the return type - if (md->templateArguments()!=0 && root->tArgLists!=0) + if (!md->templateArguments().empty() && !root->tArgLists.empty()) { QCString memType = md->typeString(); memType.stripPrefix("static "); // see bug700696 @@ -6260,8 +6128,8 @@ static void findMember(Entry *root, Debug::print(Debug::FindMembers,0, "5b. Comparing return types '%s'<->'%s' #args %d<->%d\n", qPrint(md->typeString()),qPrint(funcType), - md->templateArguments()->count(),root->tArgLists->getLast()->count()); - if (md->templateArguments()->count()!=root->tArgLists->getLast()->count() || + md->templateArguments().size(),root->tArgLists.back().size()); + if (md->templateArguments().size()!=root->tArgLists.back().size() || qstrcmp(memType,funcType)) { //printf(" ---> no matching\n"); @@ -6270,9 +6138,9 @@ static void findMember(Entry *root, } bool rootIsUserDoc = (root->section&Entry::MEMBERDOC_SEC)!=0; bool classIsTemplate = scopeIsTemplate(md->getClassDef()); - bool mdIsTemplate = md->templateArguments()!=0; + bool mdIsTemplate = md->templateArguments().hasParameters(); bool classOrMdIsTemplate = mdIsTemplate || classIsTemplate; - bool rootIsTemplate = root->tArgLists!=0; + bool rootIsTemplate = !root->tArgLists.empty(); //printf("classIsTemplate=%d mdIsTemplate=%d rootIsTemplate=%d\n",classIsTemplate,mdIsTemplate,rootIsTemplate); if (!rootIsUserDoc && // don't check out-of-line @fn references, see bug722457 (mdIsTemplate || rootIsTemplate) && // either md or root is a template @@ -6288,37 +6156,33 @@ static void findMember(Entry *root, Debug::print(Debug::FindMembers,0, - "6. match results of matchArguments2 = %d\n",matching); + "6. match results of matchArguments2 = %d substDone=%d\n",matching,substDone); if (substDone) // found a new argument list { if (matching) // replace member's argument list { md->setDefinitionTemplateParameterLists(root->tArgLists); - md->setArgumentList(argList); // new owner of the list => no delete + md->setArgumentList(argList); } else // no match { if (!funcTempList.isEmpty() && - isSpecialization(declTemplArgs,*defTemplArgs)) + isSpecialization(declTemplArgs,defTemplArgs)) { // check if we are dealing with a partial template // specialization. In this case we add it to the class // even though the member arguments do not match. - // TODO: copy other aspects? - root->protection=md->protection(); // copy protection level - root->stat=md->isStatic(); - root->virt=md->virtualness(); - addMethodToClass(root,cd,md->name(),isFriend); + addMethodToClass(root,cd,type,md->name(),args,isFriend, + md->protection(),md->isStatic(),md->virtualness(),spec,relates); return; } - delete argList; } } if (matching) { - addMemberDocs(root,md,funcDecl,0,overloaded,0/* TODO */); + addMemberDocs(root,md,funcDecl,0,overloaded,spec); count++; memFound=TRUE; } @@ -6349,15 +6213,13 @@ static void findMember(Entry *root, //printf("ccd->name()==%s className=%s\n",ccd->name().data(),className.data()); if (ccd!=0 && rightScopeMatch(ccd->name(),className)) { - const ArgumentList *templAl = md->templateArguments(); - if (root->tArgLists && templAl!=0 && - root->tArgLists->getLast()->count()<=templAl->count()) + const ArgumentList &templAl = md->templateArguments(); + if (!root->tArgLists.empty() && !templAl.empty() && + root->tArgLists.back().size()<=templAl.size()) { Debug::print(Debug::FindMembers,0,"7. add template specialization\n"); - root->protection=md->protection(); - root->stat=md->isStatic(); - root->virt=md->virtualness(); - addMethodToClass(root,ccd,md->name(),isFriend); + addMethodToClass(root,ccd,type,md->name(),args,isFriend, + root->protection,root->stat,root->virt,spec,relates); return; } if (md->argsString()==argListToString(root->argList,TRUE,FALSE)) @@ -6387,7 +6249,7 @@ static void findMember(Entry *root, { // we didn't find an actual match on argument lists, but there is only 1 member with this // name in the same scope, so that has to be the one. - addMemberDocs(root,umd,funcDecl,0,overloaded,0); + addMemberDocs(root,umd,funcDecl,0,overloaded,spec); return; } else if (candidates>1 && ecd && emd) @@ -6395,7 +6257,7 @@ static void findMember(Entry *root, // we didn't find a unique match using type resolution, // but one of the matches has the exact same signature so // we take that one. - addMemberDocs(root,emd,funcDecl,0,overloaded,0); + addMemberDocs(root,emd,funcDecl,0,overloaded,spec); return; } } @@ -6404,17 +6266,13 @@ static void findMember(Entry *root, if (noMatchCount>1) warnMsg+="uniquely "; warnMsg+="matching class member found for \n"; - if (root->tArgLists) + for (const ArgumentList &al : root->tArgLists) { - QListIterator<ArgumentList> alli(*root->tArgLists); - ArgumentList *al; - for (;(al=alli.current());++alli) - { - warnMsg+=" template "; - warnMsg+=tempArgListToString(al,root->lang); - warnMsg+='\n'; - } + warnMsg+=" template "; + warnMsg+=tempArgListToString(al,root->lang); + warnMsg+='\n'; } + QCString fullFuncDecl=funcDecl.copy(); if (isFunc) fullFuncDecl+=argListToString(root->argList,TRUE); @@ -6430,14 +6288,15 @@ static void findMember(Entry *root, const ClassDef *cd=md->getClassDef(); if (cd!=0 && rightScopeMatch(cd->name(),className)) { - const ArgumentList *templAl = md->templateArguments(); - if (templAl!=0) + const ArgumentList &templAl = md->templateArguments(); + warnMsg+=" '"; + if (templAl.hasParameters()) { - warnMsg+=" 'template "; + warnMsg+="template "; warnMsg+=tempArgListToString(templAl,root->lang); warnMsg+='\n'; + warnMsg+=" "; } - warnMsg+=" "; if (md->typeString()) { warnMsg+=md->typeString(); @@ -6453,6 +6312,8 @@ static void findMember(Entry *root, warnMsg+="' at line "+QCString().setNum(md->getDefLine()) + " of file "+md->getDefFileName(); } + else + warnMsg += "'"; warnMsg+='\n'; } @@ -6476,7 +6337,7 @@ static void findMember(Entry *root, } } MemberType mtype=MemberType_Function; - ArgumentList *tArgList = new ArgumentList; + ArgumentList tArgList; // getTemplateArgumentsFromName(cd->name()+"::"+funcName,root->tArgLists); md=createMemberDef( root->fileName,root->startLine,root->startColumn, @@ -6485,7 +6346,7 @@ static void findMember(Entry *root, root->virt,root->stat,Member, mtype,tArgList,root->argList,root->metaData); //printf("new specialized member %s args='%s'\n",md->name().data(),funcArgs.data()); - md->setTagInfo(root->tagInfo); + md->setTagInfo(root->tagInfo()); md->setLanguage(root->lang); md->setId(root->id); md->setMemberClass(cd); @@ -6505,12 +6366,11 @@ static void findMember(Entry *root, md->setBodySegment(root->bodyLine,root->endBodyLine); FileDef *fd=root->fileDef(); md->setBodyDef(fd); - md->setMemberSpecifiers(root->spec); + md->setMemberSpecifiers(spec); md->setMemberGroupId(root->mGrpId); mn->append(md); cd->insertMember(md); md->setRefItems(root->sli); - delete tArgList; } else { @@ -6545,7 +6405,7 @@ static void findMember(Entry *root, else mtype=MemberType_Function; // new overloaded member function - ArgumentList *tArgList = + ArgumentList tArgList = getTemplateArgumentsFromName(cd->name()+"::"+funcName,root->tArgLists); //printf("new related member %s args='%s'\n",md->name().data(),funcArgs.data()); MemberDef *md=createMemberDef( @@ -6553,7 +6413,7 @@ static void findMember(Entry *root, funcType,funcName,funcArgs,exceptions, root->protection,root->virt,root->stat,Related, mtype,tArgList,root->argList,root->metaData); - md->setTagInfo(root->tagInfo); + md->setTagInfo(root->tagInfo()); md->setLanguage(root->lang); md->setId(root->id); md->setTypeConstraints(root->typeConstr); @@ -6575,7 +6435,7 @@ static void findMember(Entry *root, md->setBodySegment(root->bodyLine,root->endBodyLine); FileDef *fd=root->fileDef(); md->setBodyDef(fd); - md->setMemberSpecifiers(root->spec); + md->setMemberSpecifiers(spec); md->setMemberGroupId(root->mGrpId); mn->append(md); cd->insertMember(md); @@ -6585,7 +6445,7 @@ static void findMember(Entry *root, } else // unrelated function with the same name as a member { - if (!findGlobalMember(root,namespaceName,funcType,funcName,funcTempList,funcArgs,funcDecl)) + if (!findGlobalMember(root,namespaceName,funcType,funcName,funcTempList,funcArgs,funcDecl,spec)) { QCString fullFuncDecl=funcDecl.copy(); if (isFunc) fullFuncDecl+=argListToString(root->argList,TRUE); @@ -6596,11 +6456,11 @@ static void findMember(Entry *root, } } } - else if (isRelated && !root->relates.isEmpty()) + else if (isRelated && !relates.isEmpty()) { Debug::print(Debug::FindMembers,0,"2. related function\n" " scopeName=%s className=%s\n",qPrint(scopeName),qPrint(className)); - if (className.isEmpty()) className=root->relates; + if (className.isEmpty()) className=relates; ClassDef *cd; //printf("scopeName='%s' className='%s'\n",scopeName.data(),className.data()); if ((cd=getClass(scopeName))) @@ -6636,7 +6496,7 @@ static void findMember(Entry *root, MemberDef *rmd; while ((rmd=mni.current()) && newMember) // see if we got another member with matching arguments { - ArgumentList *rmdAl = rmd->argumentList(); + const ArgumentList &rmdAl = rmd->argumentList(); newMember= className!=rmd->getOuterScope()->name() || @@ -6649,7 +6509,7 @@ static void findMember(Entry *root, { //printf("addMemberDocs for related member %s\n",root->name.data()); //rmd->setMemberDefTemplateArguments(root->mtArgList); - addMemberDocs(root,rmd,funcDecl,0,overloaded); + addMemberDocs(root,rmd,funcDecl,0,overloaded,spec); } } @@ -6691,8 +6551,9 @@ static void findMember(Entry *root, root->stat && !isMemberOf, isMemberOf ? Foreign : Related, mtype, - (root->tArgLists ? root->tArgLists->getLast() : 0), - funcArgs.isEmpty() ? 0 : root->argList,root->metaData); + (!root->tArgLists.empty() ? root->tArgLists.back() : ArgumentList()), + funcArgs.isEmpty() ? ArgumentList() : root->argList, + root->metaData); if (isDefine && mdDefine) { @@ -6712,7 +6573,7 @@ static void findMember(Entry *root, // md->setDefinitionTemplateParameterLists(root->tArgLists); - md->setTagInfo(root->tagInfo); + md->setTagInfo(root->tagInfo()); @@ -6731,7 +6592,7 @@ static void findMember(Entry *root, const MemberDef *rmd; while ((rmd=rmni.current()) && !found) // see if we got another member with matching arguments { - const ArgumentList *rmdAl = rmd->argumentList(); + const ArgumentList &rmdAl = rmd->argumentList(); // check for matching argument lists if ( matchArguments2(rmd->getOuterScope(),rmd->getFileDef(),rmdAl, @@ -6763,7 +6624,7 @@ static void findMember(Entry *root, // md->setMemberGroup(memberGroupDict[root->mGrpId]); //} md->setMemberClass(cd); - md->setMemberSpecifiers(root->spec); + md->setMemberSpecifiers(spec); md->setDefinition(funcDecl); md->enableCallGraph(root->callGraph); md->enableCallerGraph(root->callerGraph); @@ -6798,7 +6659,7 @@ static void findMember(Entry *root, } if (root->relatesType == Duplicate) { - if (!findGlobalMember(root,namespaceName,funcType,funcName,funcTempList,funcArgs,funcDecl)) + if (!findGlobalMember(root,namespaceName,funcType,funcName,funcTempList,funcArgs,funcDecl,spec)) { QCString fullFuncDecl=funcDecl.copy(); if (isFunc) fullFuncDecl+=argListToString(root->argList,TRUE); @@ -6832,8 +6693,8 @@ localObjCMethod: root->fileName,root->startLine,root->startColumn, funcType,funcName,funcArgs,exceptions, root->protection,root->virt,root->stat,Member, - MemberType_Function,0,root->argList,root->metaData); - md->setTagInfo(root->tagInfo); + MemberType_Function,ArgumentList(),root->argList,root->metaData); + md->setTagInfo(root->tagInfo()); md->setLanguage(root->lang); md->setId(root->id); md->makeImplementationDetail(); @@ -6852,7 +6713,7 @@ localObjCMethod: md->setBodySegment(root->bodyLine,root->endBodyLine); FileDef *fd=root->fileDef(); md->setBodyDef(fd); - md->setMemberSpecifiers(root->spec); + md->setMemberSpecifiers(spec); md->setMemberGroupId(root->mGrpId); cd->insertMember(md); cd->insertUsedFile(fd); @@ -6875,7 +6736,7 @@ localObjCMethod: } else // unrelated not overloaded member found { - bool globMem = findGlobalMember(root,namespaceName,funcType,funcName,funcTempList,funcArgs,funcDecl); + bool globMem = findGlobalMember(root,namespaceName,funcType,funcName,funcTempList,funcArgs,funcDecl,spec); if (className.isEmpty() && !globMem) { warn(root->fileName,root->startLine, @@ -6904,7 +6765,7 @@ localObjCMethod: // find the members corresponding to the different documentation blocks // that are extracted from the sources. -static void filterMemberDocumentation(Entry *root) +static void filterMemberDocumentation(const Entry *root,const QCString relates) { int i=-1,l; Debug::print(Debug::FindMembers,0, @@ -6914,26 +6775,20 @@ static void filterMemberDocumentation(Entry *root) //printf("root->parent()->name=%s\n",root->parent()->name.data()); bool isFunc=TRUE; - if (root->relatesType == Duplicate && !root->relates.isEmpty()) - { - QCString tmp = root->relates; - root->relates.resize(0); - filterMemberDocumentation(root); - root->relates = tmp; - } - + QCString type = root->type; + QCString args = root->args; if ( // detect func variable/typedef to func ptr - (i=findFunctionPtr(root->type,root->lang,&l))!=-1 + (i=findFunctionPtr(type,root->lang,&l))!=-1 ) { //printf("Fixing function pointer!\n"); // fix type and argument - root->args.prepend(root->type.right(root->type.length()-i-l)); - root->type=root->type.left(i+l); - //printf("Results type=%s,name=%s,args=%s\n",root->type.data(),root->name.data(),root->args.data()); + args.prepend(type.right(type.length()-i-l)); + type=type.left(i+l); + //printf("Results type=%s,name=%s,args=%s\n",type.data(),root->name.data(),args.data()); isFunc=FALSE; } - else if ((root->type.left(8)=="typedef " && root->args.find('(')!=-1)) + else if ((type.left(8)=="typedef " && args.find('(')!=-1)) // detect function types marked as functions { isFunc=FALSE; @@ -6943,80 +6798,117 @@ static void filterMemberDocumentation(Entry *root) if (root->section==Entry::MEMBERDOC_SEC) { //printf("Documentation for inline member '%s' found args='%s'\n", - // root->name.data(),root->args.data()); - //if (root->relates.length()) printf(" Relates %s\n",root->relates.data()); - if (root->type.isEmpty()) - { - findMember(root,root->name+root->args+root->exception,FALSE,isFunc); + // root->name.data(),args.data()); + //if (relates.length()) printf(" Relates %s\n",relates.data()); + if (type.isEmpty()) + { + findMember(root, + relates, + type, + args, + root->name + args + root->exception, + FALSE, + isFunc); } else { - findMember(root,root->type+" "+root->name+root->args+root->exception,FALSE,isFunc); + findMember(root, + relates, + type, + args, + type + " " + root->name + args + root->exception, + FALSE, + isFunc); } } else if (root->section==Entry::OVERLOADDOC_SEC) { //printf("Overloaded member %s found\n",root->name.data()); - findMember(root,root->name,TRUE,isFunc); + findMember(root, + relates, + type, + args, + root->name, + TRUE, + isFunc); } else if ((root->section==Entry::FUNCTION_SEC // function || (root->section==Entry::VARIABLE_SEC && // variable - !root->type.isEmpty() && // with a type - g_compoundKeywordDict.find(root->type)==0 // that is not a keyword + !type.isEmpty() && // with a type + g_compoundKeywordDict.find(type)==0 // that is not a keyword // (to skip forward declaration of class etc.) ) ) ) { //printf("Documentation for member '%s' found args='%s' excp='%s'\n", - // root->name.data(),root->args.data(),root->exception.data()); - //if (root->relates.length()) printf(" Relates %s\n",root->relates.data()); - //printf("Inside=%s\n Relates=%s\n",root->inside.data(),root->relates.data()); - if (root->type=="friend class" || root->type=="friend struct" || - root->type=="friend union") + // root->name.data(),args.data(),root->exception.data()); + //if (relates.length()) printf(" Relates %s\n",relates.data()); + //printf("Inside=%s\n Relates=%s\n",root->inside.data(),relates.data()); + if (type=="friend class" || type=="friend struct" || + type=="friend union") { findMember(root, - root->type+" "+ - root->name, + relates, + type, + args, + type+" "+root->name, FALSE,FALSE); } - else if (!root->type.isEmpty()) + else if (!type.isEmpty()) { findMember(root, - root->type+" "+ - root->inside+ - root->name+ - root->args+ - root->exception, + relates, + type, + args, + type+" "+ root->inside + root->name + args + root->exception, FALSE,isFunc); } else { findMember(root, - root->inside+ - root->name+ - root->args+ - root->exception, + relates, + type, + args, + root->inside + root->name + args + root->exception, FALSE,isFunc); } } - else if (root->section==Entry::DEFINE_SEC && !root->relates.isEmpty()) + else if (root->section==Entry::DEFINE_SEC && !relates.isEmpty()) { - findMember(root,root->name+root->args,FALSE,!root->args.isEmpty()); + findMember(root, + relates, + type, + args, + root->name + args, + FALSE, + !args.isEmpty()); } else if (root->section==Entry::VARIABLEDOC_SEC) { //printf("Documentation for variable %s found\n",root->name.data()); - //if (!root->relates.isEmpty()) printf(" Relates %s\n",root->relates.data()); - findMember(root,root->name,FALSE,FALSE); + //if (!relates.isEmpty()) printf(" Relates %s\n",relates.data()); + findMember(root, + relates, + type, + args, + root->name, + FALSE, + FALSE); } else if (root->section==Entry::EXPORTED_INTERFACE_SEC || root->section==Entry::INCLUDED_SERVICE_SEC) { - findMember(root,root->type + " " + root->name,FALSE,FALSE); + findMember(root, + relates, + type, + args, + type + " " + root->name, + FALSE, + FALSE); } else { @@ -7025,7 +6917,7 @@ static void filterMemberDocumentation(Entry *root) } } -static void findMemberDocumentation(Entry *root) +static void findMemberDocumentation(const Entry *root) { if (root->section==Entry::MEMBERDOC_SEC || root->section==Entry::OVERLOADDOC_SEC || @@ -7037,42 +6929,41 @@ static void findMemberDocumentation(Entry *root) root->section==Entry::EXPORTED_INTERFACE_SEC ) { - filterMemberDocumentation(root); + if (root->relatesType == Duplicate && !root->relates.isEmpty()) + { + filterMemberDocumentation(root,""); + } + filterMemberDocumentation(root,root->relates); } - if (root->children()) + for (const auto &e : root->children()) { - EntryListIterator eli(*root->children()); - Entry *e; - for (;(e=eli.current());++eli) + if (e->section!=Entry::ENUM_SEC) { - if (e->section!=Entry::ENUM_SEC) findMemberDocumentation(e); + findMemberDocumentation(e.get()); } } } //---------------------------------------------------------------------- -static void findObjCMethodDefinitions(Entry *root) +static void findObjCMethodDefinitions(const Entry *root) { - if (root->children()) + for (const auto &objCImpl : root->children()) { - EntryListIterator eli(*root->children()); - Entry *objCImpl; - for (;(objCImpl=eli.current());++eli) + if (objCImpl->section==Entry::OBJCIMPL_SEC) { - if (objCImpl->section==Entry::OBJCIMPL_SEC && objCImpl->children()) + for (const auto &objCMethod : objCImpl->children()) { - EntryListIterator seli(*objCImpl->children()); - Entry *objCMethod; - for (;(objCMethod=seli.current());++seli) + if (objCMethod->section==Entry::FUNCTION_SEC) { - if (objCMethod->section==Entry::FUNCTION_SEC) - { - //Printf(" Found ObjC method definition %s\n",objCMethod->name.data()); - findMember(objCMethod, objCMethod->type+" "+objCImpl->name+"::"+ - objCMethod->name+" "+objCMethod->args, FALSE,TRUE); - objCMethod->section=Entry::EMPTY_SEC; - } + //Printf(" Found ObjC method definition %s\n",objCMethod->name.data()); + findMember(objCMethod.get(), + objCMethod->relates, + objCMethod->type, + objCMethod->args, + objCMethod->type+" "+objCImpl->name+"::"+objCMethod->name+" "+objCMethod->args, + FALSE,TRUE); + objCMethod->section=Entry::EMPTY_SEC; } } } @@ -7082,7 +6973,7 @@ static void findObjCMethodDefinitions(Entry *root) //---------------------------------------------------------------------- // find and add the enumeration to their classes, namespaces or files -static void findEnums(Entry *root) +static void findEnums(const Entry *root) { if (root->section==Entry::ENUM_SEC) { @@ -7157,8 +7048,8 @@ static void findEnums(Entry *root) root->protection,Normal,FALSE, isMemberOf ? Foreign : isRelated ? Related : Member, MemberType_Enumeration, - 0,0,root->metaData); - md->setTagInfo(root->tagInfo); + ArgumentList(),ArgumentList(),root->metaData); + md->setTagInfo(root->tagInfo()); md->setLanguage(root->lang); md->setId(root->id); if (!isGlobal) md->setMemberClass(cd); else md->setFileDef(fd); @@ -7255,13 +7146,13 @@ static void findEnums(Entry *root) } else { - RECURSE_ENTRYTREE(findEnums,root); + for (const auto &e : root->children()) findEnums(e.get()); } } //---------------------------------------------------------------------- -static void addEnumValuesToEnums(Entry *root) +static void addEnumValuesToEnums(const Entry *root) { if (root->section==Entry::ENUM_SEC) // non anonymous enumeration @@ -7337,12 +7228,10 @@ static void addEnumValuesToEnums(Entry *root) MemberDef *md; for (mni.toFirst(); (md=mni.current()) ; ++mni) // for each enum in this list { - if (!md->isAlias() && md->isEnumerate() && root->children()) + if (!md->isAlias() && md->isEnumerate() && !root->children().empty()) { //printf(" enum with %d children\n",root->children()->count()); - EntryListIterator eli(*root->children()); // for each enum value - Entry *e; - for (;(e=eli.current());++eli) + for (const auto &e : root->children()) { SrcLangExt sle; if ( @@ -7358,7 +7247,7 @@ static void addEnumValuesToEnums(Entry *root) //printf("md->qualifiedName()=%s e->name=%s tagInfo=%p name=%s\n", // md->qualifiedName().data(),e->name.data(),e->tagInfo,e->name.data()); QCString qualifiedName = substitute(root->name,"::","."); - if (!scope.isEmpty() && root->tagInfo) + if (!scope.isEmpty() && root->tagInfo()) { qualifiedName=substitute(scope,"::",".")+"."+qualifiedName; } @@ -7367,20 +7256,20 @@ static void addEnumValuesToEnums(Entry *root) ) { QCString fileName = e->fileName; - if (fileName.isEmpty() && e->tagInfo) + if (fileName.isEmpty() && e->tagInfo()) { - fileName = e->tagInfo->tagName; + fileName = e->tagInfo()->tagName; } MemberDef *fmd=createMemberDef( fileName,e->startLine,e->startColumn, e->type,e->name,e->args,0, e->protection, Normal,e->stat,Member, - MemberType_EnumValue,0,0,e->metaData); + MemberType_EnumValue,ArgumentList(),ArgumentList(),e->metaData); if (md->getClassDef()) fmd->setMemberClass(md->getClassDef()); else if (md->getNamespaceDef()) fmd->setNamespace(md->getNamespaceDef()); else if (md->getFileDef()) fmd->setFileDef(md->getFileDef()); fmd->setOuterScope(md->getOuterScope()); - fmd->setTagInfo(e->tagInfo); + fmd->setTagInfo(e->tagInfo()); fmd->setLanguage(e->lang); fmd->setId(e->id); fmd->setDocumentation(e->doc,e->docFile,e->docLine); @@ -7474,7 +7363,7 @@ static void addEnumValuesToEnums(Entry *root) } else { - RECURSE_ENTRYTREE(addEnumValuesToEnums,root); + for (const auto &e : root->children()) addEnumValuesToEnums(e.get()); } } @@ -7482,7 +7371,7 @@ static void addEnumValuesToEnums(Entry *root) //---------------------------------------------------------------------- // find the documentation blocks for the enumerations -static void findEnumDocumentation(Entry *root) +static void findEnumDocumentation(const Entry *root) { if (root->section==Entry::ENUMDOC_SEC && !root->name.isEmpty() @@ -7562,7 +7451,7 @@ static void findEnumDocumentation(Entry *root) md->setRefItems(root->sli); const GroupDef *gd=md->getGroupDef(); - if (gd==0 &&root->groups->getFirst()!=0) // member not grouped but out-of-line documentation is + if (gd==0 && !root->groups.empty()) // member not grouped but out-of-line documentation is { addMemberToGroups(root,md); } @@ -7596,7 +7485,7 @@ static void findEnumDocumentation(Entry *root) md->setMemberGroupId(root->mGrpId); const GroupDef *gd=md->getGroupDef(); - if (gd==0 && root->groups->getFirst()!=0) // member not grouped but out-of-line documentation is + if (gd==0 && !root->groups.empty()) // member not grouped but out-of-line documentation is { addMemberToGroups(root,md); } @@ -7615,7 +7504,7 @@ static void findEnumDocumentation(Entry *root) } } } - RECURSE_ENTRYTREE(findEnumDocumentation,root); + for (const auto &e : root->children()) findEnumDocumentation(e.get()); } // search for each enum (member or function) in mnl if it has documented @@ -7773,8 +7662,8 @@ static void computeMemberRelations() mcd->isBaseClass(bmcd,TRUE)) { //printf(" derived scope\n"); - ArgumentList *bmdAl = bmd->argumentList(); - ArgumentList *mdAl = md->argumentList(); + const ArgumentList &bmdAl = bmd->argumentList(); + const ArgumentList &mdAl = md->argumentList(); //printf(" Base argList='%s'\n Super argList='%s'\n", // argListToString(bmdAl.pointer()).data(), // argListToString(mdAl.pointer()).data() @@ -8605,12 +8494,13 @@ static void findDefineDocumentation(Entry *root) //printf("found define '%s' '%s' brief='%s' doc='%s'\n", // root->name.data(),root->args.data(),root->brief.data(),root->doc.data()); - if (root->tagInfo && !root->name.isEmpty()) // define read from a tag file + if (root->tagInfo() && !root->name.isEmpty()) // define read from a tag file { - MemberDef *md=createMemberDef(root->tagInfo->tagName,1,1, + MemberDef *md=createMemberDef(root->tagInfo()->tagName,1,1, "#define",root->name,root->args,0, - Public,Normal,FALSE,Member,MemberType_Define,0,0,""); - md->setTagInfo(root->tagInfo); + Public,Normal,FALSE,Member,MemberType_Define, + ArgumentList(),ArgumentList(),""); + md->setTagInfo(root->tagInfo()); md->setLanguage(root->lang); //printf("Searching for '%s' fd=%p\n",filePathName.data(),fd); md->setFileDef(root->parent()->fileDef()); @@ -8730,12 +8620,12 @@ static void findDefineDocumentation(Entry *root) } } } - RECURSE_ENTRYTREE(findDefineDocumentation,root); + for (const auto &e : root->children()) findDefineDocumentation(e.get()); } //---------------------------------------------------------------------------- -static void findDirDocumentation(Entry *root) +static void findDirDocumentation(const Entry *root) { if (root->section == Entry::DIRDOC_SEC) { @@ -8791,7 +8681,7 @@ static void findDirDocumentation(Entry *root) "directory found for command \\dir %s\n",normalizedName.data()); } } - RECURSE_ENTRYTREE(findDirDocumentation,root); + for (const auto &e : root->children()) findDirDocumentation(e.get()); } @@ -8821,7 +8711,7 @@ static void buildPageList(Entry *root) 0,0 ); } - RECURSE_ENTRYTREE(buildPageList,root); + for (const auto &e : root->children()) buildPageList(e.get()); } // search for the main page defined in this project @@ -8829,7 +8719,7 @@ static void findMainPage(Entry *root) { if (root->section == Entry::MAINPAGEDOC_SEC) { - if (Doxygen::mainPage==0 && root->tagInfo==0) + if (Doxygen::mainPage==0 && root->tagInfo()==0) { //printf("Found main page! \n======\n%s\n=======\n",root->doc.data()); QCString title=root->args.stripWhiteSpace(); @@ -8868,14 +8758,14 @@ static void findMainPage(Entry *root) Doxygen::mainPage->addSectionsToDefinition(root->anchors); } } - else if (root->tagInfo==0) + else if (root->tagInfo()==0) { warn(root->fileName,root->startLine, "found more than one \\mainpage comment block! (first occurrence: %s, line %d), Skipping current block!", Doxygen::mainPage->docFile().data(),Doxygen::mainPage->docLine()); } } - RECURSE_ENTRYTREE(findMainPage,root); + for (const auto &e : root->children()) findMainPage(e.get()); } // search for the main page imported via tag files and add only the section labels @@ -8883,12 +8773,12 @@ static void findMainPageTagFiles(Entry *root) { if (root->section == Entry::MAINPAGEDOC_SEC) { - if (Doxygen::mainPage && root->tagInfo) + if (Doxygen::mainPage && root->tagInfo()) { Doxygen::mainPage->addSectionsToDefinition(root->anchors); } } - RECURSE_ENTRYTREE(findMainPageTagFiles,root); + for (const auto &e : root->children()) findMainPageTagFiles(e.get()); } static void computePageRelations(Entry *root) @@ -8904,11 +8794,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 " @@ -8925,7 +8813,7 @@ static void computePageRelations(Entry *root) } } } - RECURSE_ENTRYTREE(computePageRelations,root); + for (const auto &e : root->children()) computePageRelations(e.get()); } static void checkPageRelations() @@ -9071,7 +8959,7 @@ static void buildExampleList(Entry *root) //addExampleToGroups(root,pd); } } - RECURSE_ENTRYTREE(buildExampleList,root); + for (const auto &e : root->children()) buildExampleList(e.get()); } //---------------------------------------------------------------------------- @@ -9085,10 +8973,9 @@ void printNavTree(Entry *root,int indent) indentStr.isEmpty()?"":indentStr.data(), root->name.isEmpty()?"<empty>":root->name.data(), root->section); - if (root->children()) + for (const auto &e : root->children()) { - EntryListIterator eli(*root->children()); - for (;eli.current();++eli) printNavTree(eli.current(),indent+2); + printNavTree(e.get(),indent+2); } } @@ -9310,7 +9197,7 @@ static void compareDoxyfile() //---------------------------------------------------------------------------- -static void readTagFile(Entry *root,const char *tl) +static void readTagFile(const std::unique_ptr<Entry> &root,const char *tl) { QCString tagLine = tl; QCString fileName; @@ -9479,7 +9366,7 @@ static ParserInterface *getParserForFile(const char *fn) } static void parseFile(ParserInterface *parser, - Entry *root,FileDef *fd,const char *fn, + const std::unique_ptr<Entry> &root,FileDef *fd,const char *fn, bool sameTu,QStrList &filesInSameTu) { #if USE_LIBCLANG @@ -9532,15 +9419,15 @@ static void parseFile(ParserInterface *parser, fd->getAllIncludeFilesRecursively(filesInSameTu); } - Entry *fileRoot = new Entry; + std::unique_ptr<Entry> fileRoot = std::make_unique<Entry>(); // use language parse to parse the file parser->parseInput(fileName,convBuf.data(),fileRoot,sameTu,filesInSameTu); fileRoot->setFileDef(fd); - root->addSubEntry(fileRoot); + root->moveToSubEntryAndKeep(fileRoot); } //! parse the list of input files -static void parseFiles(Entry *root) +static void parseFiles(const std::unique_ptr<Entry> &root) { #if USE_LIBCLANG static bool clangAssistedParsing = Config_getBool(CLANG_ASSISTED_PARSING); @@ -10135,29 +10022,31 @@ static void usage(const char *name,const char *versionString) msg("You can use doxygen in a number of ways:\n\n"); msg("1) Use doxygen to generate a template configuration file:\n"); msg(" %s [-s] -g [configName]\n\n",name); - msg(" If - is used for configName doxygen will write to standard output.\n\n"); msg("2) Use doxygen to update an old configuration file:\n"); msg(" %s [-s] -u [configName]\n\n",name); msg("3) Use doxygen to generate documentation using an existing "); msg("configuration file:\n"); msg(" %s [configName]\n\n",name); - msg(" If - is used for configName doxygen will read from standard input.\n\n"); msg("4) Use doxygen to generate a template file controlling the layout of the\n"); msg(" generated documentation:\n"); - msg(" %s -l [layoutFileName.xml]\n\n",name); + msg(" %s -l [layoutFileName]\n\n",name); + msg(" In case layoutFileName is omitted layoutFileName.xml will be used as filename.\n"); + msg(" If - is used for layoutFileName doxygen will write to standard output.\n\n"); msg("5) Use doxygen to generate a template style sheet file for RTF, HTML or Latex.\n"); msg(" RTF: %s -w rtf styleSheetFile\n",name); msg(" HTML: %s -w html headerFile footerFile styleSheetFile [configFile]\n",name); msg(" LaTeX: %s -w latex headerFile footerFile styleSheetFile [configFile]\n\n",name); msg("6) Use doxygen to generate a rtf extensions file\n"); msg(" RTF: %s -e rtf extensionsFile\n\n",name); + msg(" If - is used for extensionsFile doxygen will write to standard output.\n\n"); msg("7) Use doxygen to compare the used configuration file with the template configuration file\n"); msg(" %s -x [configFile]\n\n",name); msg("8) Use doxygen to show a list of built-in emojis.\n"); msg(" %s -f emoji outputFileName\n\n",name); msg(" If - is used for outputFileName doxygen will write to standard output.\n\n"); msg("If -s is specified the comments of the configuration items in the config file will be omitted.\n"); - msg("If configName is omitted 'Doxyfile' will be used as a default.\n\n"); + msg("If configName is omitted 'Doxyfile' will be used as a default.\n"); + msg("If - is used for configFile doxygen will write / read the configuration to /from standard output / input.\n\n"); msg("-v print version string\n"); } @@ -10384,10 +10273,15 @@ void readConfiguration(int argc, char **argv) genConfig=TRUE; break; case 'l': - layoutName=getArg(argc,argv,optind); - if (!layoutName) - { layoutName="DoxygenLayout.xml"; } - LayoutDocManager::instance().writeDefault(layoutName); + if (optind+1>=argc) + { + layoutName="DoxygenLayout.xml"; + } + else + { + layoutName=argv[optind+1]; + } + writeDefaultLayoutFile(layoutName); cleanUpDoxygen(); exit(0); break; @@ -11346,7 +11240,7 @@ void parseInput() * Handle Tag Files * **************************************************************************/ - Entry *root=new Entry; + std::unique_ptr<Entry> root = std::make_unique<Entry>(); msg("Reading and parsing tag files\n"); QStrList &tagFileList = Config_getList(TAGFILES); @@ -11381,31 +11275,31 @@ void parseInput() **************************************************************************/ g_s.begin("Building group list...\n"); - buildGroupList(root); - organizeSubGroups(root); + buildGroupList(root.get()); + organizeSubGroups(root.get()); g_s.end(); g_s.begin("Building directory list...\n"); buildDirectories(); - findDirDocumentation(root); + findDirDocumentation(root.get()); g_s.end(); g_s.begin("Building namespace list...\n"); - buildNamespaceList(root); - findUsingDirectives(root); + buildNamespaceList(root.get()); + findUsingDirectives(root.get()); g_s.end(); g_s.begin("Building file list...\n"); - buildFileList(root); + buildFileList(root.get()); g_s.end(); //generateFileTree(); g_s.begin("Building class list...\n"); - buildClassList(root); + buildClassList(root.get()); g_s.end(); // build list of using declarations here (global list) - buildListOfUsingDecls(root); + buildListOfUsingDecls(root.get()); g_s.end(); g_s.begin("Computing nesting relations for classes...\n"); @@ -11422,14 +11316,14 @@ void parseInput() g_usingDeclarations.clear(); g_s.begin("Associating documentation with classes...\n"); - buildClassDocList(root); + buildClassDocList(root.get()); g_s.begin("Building example list...\n"); - buildExampleList(root); + buildExampleList(root.get()); g_s.end(); g_s.begin("Searching for enumerations...\n"); - findEnums(root); + findEnums(root.get()); g_s.end(); // Since buildVarList calls isVarWithConstructor @@ -11437,24 +11331,24 @@ void parseInput() // typedefs first so the relations between classes via typedefs // are properly resolved. See bug 536385 for an example. g_s.begin("Searching for documented typedefs...\n"); - buildTypedefList(root); + buildTypedefList(root.get()); g_s.end(); if (Config_getBool(OPTIMIZE_OUTPUT_SLICE)) { g_s.begin("Searching for documented sequences...\n"); - buildSequenceList(root); + buildSequenceList(root.get()); g_s.end(); g_s.begin("Searching for documented dictionaries...\n"); - buildDictionaryList(root); + buildDictionaryList(root.get()); g_s.end(); } g_s.begin("Searching for members imported via using declarations...\n"); // this should be after buildTypedefList in order to properly import // used typedefs - findUsingDeclarations(root); + findUsingDeclarations(root.get()); g_s.end(); g_s.begin("Searching for included using directives...\n"); @@ -11462,14 +11356,14 @@ void parseInput() g_s.end(); g_s.begin("Searching for documented variables...\n"); - buildVarList(root); + buildVarList(root.get()); g_s.end(); g_s.begin("Building interface member list...\n"); - buildInterfaceAndServiceList(root); // UNO IDL + buildInterfaceAndServiceList(root.get()); // UNO IDL g_s.begin("Building member list...\n"); // using class info only ! - buildFunctionList(root); + buildFunctionList(root.get()); g_s.end(); g_s.begin("Searching for friends...\n"); @@ -11477,11 +11371,11 @@ void parseInput() g_s.end(); g_s.begin("Searching for documented defines...\n"); - findDefineDocumentation(root); + findDefineDocumentation(root.get()); g_s.end(); g_s.begin("Computing class inheritance relations...\n"); - findClassEntries(root); + findClassEntries(root.get()); findInheritedTemplateInstances(); g_s.end(); @@ -11512,14 +11406,14 @@ void parseInput() g_s.end(); g_s.begin("Add enum values to enums...\n"); - addEnumValuesToEnums(root); - findEnumDocumentation(root); + addEnumValuesToEnums(root.get()); + findEnumDocumentation(root.get()); g_s.end(); g_s.begin("Searching for member function documentation...\n"); - findObjCMethodDefinitions(root); - findMemberDocumentation(root); // may introduce new members ! - findUsingDeclImports(root); // may introduce new members ! + findObjCMethodDefinitions(root.get()); + findMemberDocumentation(root.get()); // may introduce new members ! + findUsingDeclImports(root.get()); // may introduce new members ! transferRelatedFunctionDocumentation(); transferFunctionDocumentation(); @@ -11532,21 +11426,21 @@ void parseInput() g_s.end(); g_s.begin("Building page list...\n"); - buildPageList(root); + buildPageList(root.get()); g_s.end(); g_s.begin("Search for main page...\n"); - findMainPage(root); - findMainPageTagFiles(root); + findMainPage(root.get()); + findMainPageTagFiles(root.get()); g_s.end(); g_s.begin("Computing page relations...\n"); - computePageRelations(root); + computePageRelations(root.get()); checkPageRelations(); g_s.end(); g_s.begin("Determining the scope of groups...\n"); - findGroupScope(root); + findGroupScope(root.get()); g_s.end(); g_s.begin("Sorting lists...\n"); diff --git a/src/entry.cpp b/src/entry.cpp index e2a21c6..066c4a0 100644 --- a/src/entry.cpp +++ b/src/entry.cpp @@ -15,6 +15,7 @@ * */ +#include <algorithm> #include <stdlib.h> #include <qfile.h> #include "entry.h" @@ -37,21 +38,9 @@ Entry::Entry() num++; m_parent=0; section = EMPTY_SEC; - m_sublist = new QList<Entry>; - m_sublist->setAutoDelete(TRUE); - 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! - argList = new ArgumentList; - argList->setAutoDelete(TRUE); //printf("Entry::Entry() tArgList=0\n"); - tArgLists = 0; - typeConstr = 0; mGrpId = -1; - tagInfo = 0; - sli = 0; + hasTagInfo = FALSE; relatesType = Simple; hidden = FALSE; groupDocType = GROUPDOC_NORMAL; @@ -65,7 +54,8 @@ Entry::Entry(const Entry &e) section = e.section; type = e.type; name = e.name; - tagInfo = e.tagInfo; + hasTagInfo = e.hasTagInfo; + tagInfoData = e.tagInfoData; protection = e.protection; mtype = e.mtype; spec = e.spec; @@ -82,8 +72,8 @@ Entry::Entry(const Entry &e) virt = e.virt; args = e.args; bitfields = e.bitfields; - argList = e.argList->deepCopy(); - tArgLists = 0; + argList = e.argList; + tArgLists = e.tArgLists; program = e.program; initializer = e.initializer; includeFile = e.includeFile; @@ -103,88 +93,31 @@ Entry::Entry(const Entry &e) write = e.write; inside = e.inside; exception = e.exception; - typeConstr = 0; + typeConstr = e.typeConstr; 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>; + anchors = e.anchors; fileName = e.fileName; startLine = e.startLine; startColumn = e.startColumn; - if (e.sli) - { - sli = new QList<ListItemInfo>; - sli->setAutoDelete(TRUE); - QListIterator<ListItemInfo> slii(*e.sli); - ListItemInfo *ili; - for (slii.toFirst();(ili=slii.current());++slii) - { - sli->append(new ListItemInfo(*ili)); - } - } - else - { - sli=0; - } + sli = e.sli; lang = e.lang; hidden = e.hidden; artificial = e.artificial; groupDocType = e.groupDocType; id = e.id; + extends = e.extends; + groups = e.groups; + m_fileDef = e.m_fileDef; m_parent = e.m_parent; - m_sublist = new QList<Entry>; - m_sublist->setAutoDelete(TRUE); - - // deep copy of the child entry list - QListIterator<Entry> eli(*e.m_sublist); - Entry *cur; - for (;(cur=eli.current());++eli) - { - m_sublist->append(new Entry(*cur)); - } - - // deep copy base class list - QListIterator<BaseInfo> bli(*e.extends); - BaseInfo *bi; - for (;(bi=bli.current());++bli) + // deep copy child entries + m_sublist.reserve(e.m_sublist.size()); + for (const auto &cur : e.m_sublist) { - extends->append(new BaseInfo(*bi)); + m_sublist.push_back(std::make_unique<Entry>(*cur)); } - - // deep copy group list - QListIterator<Grouping> gli(*e.groups); - Grouping *g; - for (;(g=gli.current());++gli) - { - groups->append(new Grouping(*g)); - } - - QListIterator<SectionInfo> sli2(*e.anchors); - SectionInfo *s; - for (;(s=sli2.current());++sli2) - { - anchors->append(s); // shallow copy, object are owned by Doxygen::sectionDict - } - - // deep copy type constraint list - if (e.typeConstr) - { - typeConstr = e.typeConstr->deepCopy(); - } - - // deep copy template argument lists - if (e.tArgLists) - { - tArgLists = copyArgumentLists(e.tArgLists); - } - - m_fileDef = e.m_fileDef; - } Entry::~Entry() @@ -192,31 +125,76 @@ Entry::~Entry() //printf("Entry::~Entry(%p) num=%d\n",this,num); //printf("Deleting entry %d name %s type %x children %d\n", // num,name.data(),section,sublist->count()); - - delete m_sublist; // each element is now own by a EntryNav so we do no longer own - // our children. - delete extends; - delete groups; - delete anchors; - delete argList; - delete tArgLists; - delete tagInfo; - delete typeConstr; - delete sli; + num--; } -void Entry::addSubEntry(Entry *current) +void Entry::moveToSubEntryAndRefresh(Entry *¤t) { - //printf("Entry %d with name %s type 0x%x added to %s type 0x%x\n", - // current->num,current->name.data(),current->section, - // name.data(),section); - //printf("Entry::addSubEntry(%s:%p) to %s\n",current->name.data(), - // current,name.data()); current->m_parent=this; - m_sublist->append(current); + m_sublist.emplace_back(current); + current = new Entry; } +void Entry::moveToSubEntryAndRefresh(std::unique_ptr<Entry> ¤t) +{ + current->m_parent=this; + m_sublist.push_back(std::move(current)); + current = std::make_unique<Entry>(); +} + +void Entry::moveToSubEntryAndKeep(Entry *current) +{ + current->m_parent=this; + m_sublist.emplace_back(current); +} + +void Entry::moveToSubEntryAndKeep(std::unique_ptr<Entry> ¤t) +{ + current->m_parent=this; + m_sublist.push_back(std::move(current)); +} + +void Entry::copyToSubEntry(Entry *current) +{ + Entry *copy = new Entry(*current); + copy->m_parent=this; + m_sublist.emplace_back(copy); +} + +void Entry::copyToSubEntry(const std::unique_ptr<Entry> ¤t) +{ + std::unique_ptr<Entry> copy = std::make_unique<Entry>(*current); + copy->m_parent=this; + m_sublist.push_back(std::move(copy)); +} + +void Entry::moveFromSubEntry(const Entry *child,std::unique_ptr<Entry> &moveTo) +{ + auto it = std::find_if(m_sublist.begin(),m_sublist.end(), + [child](const std::unique_ptr<Entry>&elem) { return elem.get()==child; }); + if (it!=m_sublist.end()) + { + moveTo = std::move(*it); + m_sublist.erase(it); + } + else + { + moveTo.reset(); + } +} + +void Entry::removeSubEntry(const Entry *e) +{ + auto it = std::find_if(m_sublist.begin(),m_sublist.end(), + [e](const std::unique_ptr<Entry>&elem) { return elem.get()==e; }); + if (it!=m_sublist.end()) + { + m_sublist.erase(it); + } +} + + void Entry::reset() { static bool entryCallGraph = Config_getBool(CALL_GRAPH); @@ -271,56 +249,34 @@ void Entry::reset() groupDocType = GROUPDOC_NORMAL; id.resize(0); metaData.resize(0); - m_sublist->clear(); - extends->clear(); - groups->clear(); - anchors->clear(); - argList->clear(); - if (tagInfo) { delete tagInfo; tagInfo=0; } - if (tArgLists) { delete tArgLists; tArgLists=0; } - if (sli) { delete sli; sli=0; } - if (typeConstr) { delete typeConstr; typeConstr=0; } - //if (mtArgList) { delete mtArgList; mtArgList=0; } + m_sublist.clear(); + extends.clear(); + groups.clear(); + anchors.clear(); + argList.clear(); + tArgLists.clear(); + argList.reset(); + typeConstr.reset(); + sli.clear(); m_fileDef = 0; } - -int Entry::getSize() -{ - return sizeof(Entry); -} - void Entry::setFileDef(FileDef *fd) { m_fileDef = fd; - if (m_sublist) + for (const auto &childNode : m_sublist) { - QListIterator<Entry> eli(*m_sublist); - Entry *childNode; - for (eli.toFirst();(childNode=eli.current());++eli) - { childNode->setFileDef(fd); - } } } void Entry::addSpecialListItem(const char *listName,int itemId) { - if (sli==0) - { - sli = new QList<ListItemInfo>; - sli->setAutoDelete(TRUE); - } - ListItemInfo *ili=new ListItemInfo; - ili->type = listName; - ili->itemId = itemId; - sli->append(ili); + ListItemInfo ili; + ili.type = listName; + ili.itemId = itemId; + sli.push_back(ili); } -Entry *Entry::removeSubEntry(Entry *e) -{ - int i = m_sublist->find(e); - return i!=-1 ? m_sublist->take(i) : 0; -} //------------------------------------------------------------------ diff --git a/src/entry.h b/src/entry.h index 6dfa0c6..9d4ae9d 100644 --- a/src/entry.h +++ b/src/entry.h @@ -18,17 +18,17 @@ #ifndef ENTRY_H #define ENTRY_H -#include "types.h" - -#include <qlist.h> #include <qgstring.h> +#include <vector> +#include <memory> + +#include "types.h" +#include "arguments.h" + struct SectionInfo; class QFile; class FileDef; -class FileStorage; -class StorageIntf; -class ArgumentList; struct ListItemInfo; /** This class stores information about an inheritance relation @@ -194,47 +194,56 @@ class Entry Entry(const Entry &); ~Entry(); - /*! Returns the static size of the Entry (so excluding any dynamic memory) */ - int getSize(); - void addSpecialListItem(const char *listName,int index); - // while parsing a file these function can be used to navigate/build the tree - void setParent(Entry *parent) { m_parent = parent; } - /*! Returns the parent for this Entry or 0 if this entry has no parent. */ Entry *parent() const { return m_parent; } /*! Returns the list of children for this Entry * @see addSubEntry() and removeSubEntry() */ - const QList<Entry> *children() const { return m_sublist; } + const std::vector< std::unique_ptr<Entry> > &children() const { return m_sublist; } - /*! Adds entry \a e as a child to this entry */ - void addSubEntry (Entry* e) ; + /*! @name add entry as a child and pass ownership. + * @note This makes the entry passed invalid! (TODO: tclscanner.l still has use after move!) + * @{ + */ + void moveToSubEntryAndKeep(Entry* e); + void moveToSubEntryAndKeep(std::unique_ptr<Entry> &e); + /*! @} */ + + /*! @name add entry as a child, pass ownership and reinitialize entry */ + void moveToSubEntryAndRefresh(Entry* &e); + void moveToSubEntryAndRefresh(std::unique_ptr<Entry> &e); + + /*! take \a child of of to list of children and move it into \a moveTo */ + void moveFromSubEntry(const Entry *child,std::unique_ptr<Entry> &moveTo); + + /*! make a copy of \a e and add it as a child to this entry */ + void copyToSubEntry (Entry* e); + void copyToSubEntry (const std::unique_ptr<Entry> &e); /*! Removes entry \a e from the list of children. - * Returns a pointer to the entry or 0 if the entry was not a child. - * Note the entry will not be deleted. + * The entry will be deleted if found. */ - Entry *removeSubEntry(Entry *e); + void removeSubEntry(const Entry *e); /*! Restore the state of this Entry to the default value it has * at construction time. */ void reset(); - void changeSection(int sec) { section = sec; } + void markAsProcessed() const { ((Entry*)(this))->section = Entry::EMPTY_SEC; } void setFileDef(FileDef *fd); FileDef *fileDef() const { return m_fileDef; } - public: - // identification int section; //!< entry type (see Sections); QCString type; //!< member type QCString name; //!< member name - TagInfo *tagInfo; //!< tag file info + bool hasTagInfo; //!< is tag info valid + TagInfo tagInfoData; //!< tag file info data + const TagInfo *tagInfo() const { return hasTagInfo ? &tagInfoData : 0; } // content Protection protection; //!< class protection @@ -252,8 +261,8 @@ class Entry Specifier virt; //!< virtualness of the entry QCString args; //!< member argument string QCString bitfields; //!< member's bit fields - ArgumentList *argList; //!< member arguments as a list - QList<ArgumentList> *tArgLists; //!< template argument declarations + ArgumentList argList; //!< member arguments as a list + std::vector<ArgumentList> tArgLists; //!< template argument declarations QGString program; //!< the program text QGString initializer; //!< initial value (for variables) QCString includeFile; //!< include file (2 arg of \\class, must be unique) @@ -273,17 +282,17 @@ class Entry QCString write; //!< property write accessor QCString inside; //!< name of the class in which documents are found QCString exception; //!< throw specification - ArgumentList *typeConstr; //!< where clause (C#) for type constraints + ArgumentList typeConstr; //!< where clause (C#) for type constraints 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 - QList<Grouping> *groups; //!< list of groups this entry belongs to - QList<SectionInfo> *anchors; //!< list of anchors defined in this entry + std::vector<BaseInfo> extends; //!< list of base classes + std::vector<Grouping> groups; //!< list of groups this entry belongs to + std::vector<const SectionInfo*> anchors; //!< list of anchors defined in this entry QCString fileName; //!< file this entry was extracted from int startLine; //!< start line of entry in the source int startColumn; //!< start column of entry in the source - QList<ListItemInfo> *sli; //!< special lists (test/todo/bug/deprecated/..) this entry is in + std::vector<ListItemInfo> sli; //!< special lists (test/todo/bug/deprecated/..) this entry is in SrcLangExt lang; //!< programming language in which this entry was found bool hidden; //!< does this represent an entity that is hidden from the output bool artificial; //!< Artificially introduced item @@ -323,12 +332,9 @@ class Entry private: Entry *m_parent; //!< parent node in the tree - QList<Entry> *m_sublist; //!< entries that are children of this one + std::vector< std::unique_ptr<Entry> > m_sublist; Entry &operator=(const Entry &); FileDef *m_fileDef; }; -typedef QList<Entry> EntryList; -typedef QListIterator<Entry> EntryListIterator; - #endif diff --git a/src/filedef.cpp b/src/filedef.cpp index e4f6c86..f358dba 100644 --- a/src/filedef.cpp +++ b/src/filedef.cpp @@ -1680,7 +1680,7 @@ bool FileDefImpl::generateSourceFile() const void FileDefImpl::addListReferences() { { - QList<ListItemInfo> *xrefItems = xrefListItems(); + const std::vector<ListItemInfo> &xrefItems = xrefListItems(); addRefItem(xrefItems, getOutputFileBase(), theTranslator->trFile(TRUE,TRUE), diff --git a/src/fileparser.h b/src/fileparser.h index 4b311e6..7c3f40c 100644 --- a/src/fileparser.h +++ b/src/fileparser.h @@ -25,7 +25,7 @@ class FileParser : public ParserInterface virtual ~FileParser() {} void startTranslationUnit(const char *) {} void finishTranslationUnit() {} - void parseInput(const char *, const char *,Entry *, bool, QStrList &) {} + void parseInput(const char *, const char *,const std::unique_ptr<Entry> &, bool, QStrList &) {} bool needsPreprocessing(const QCString &) { return FALSE; } void parseCode(CodeOutputInterface &codeOutIntf, const char *scopeName, diff --git a/src/fortrancode.l b/src/fortrancode.l index d372299..303bbfb 100644 --- a/src/fortrancode.l +++ b/src/fortrancode.l @@ -521,7 +521,7 @@ static bool getGenericProcedureLink(const ClassDef *cd, return FALSE; } -static bool getLink(UseSDict *usedict, // dictonary with used modules +static bool getLink(UseSDict *usedict, // dictionary with used modules const char *memberText, // exact member text CodeOutputInterface &ol, const char *text) diff --git a/src/fortranscanner.h b/src/fortranscanner.h index 15a9bf0..7490cde 100644 --- a/src/fortranscanner.h +++ b/src/fortranscanner.h @@ -33,7 +33,7 @@ class FortranLanguageScanner : public ParserInterface void finishTranslationUnit() {} void parseInput(const char *fileName, const char *fileBuf, - Entry *root, + const std::unique_ptr<Entry> &root, bool sameTranslationUnit, QStrList &filesInSameTranslationUnit); bool needsPreprocessing(const QCString &extension); diff --git a/src/fortranscanner.l b/src/fortranscanner.l index d75134a..161deae 100644 --- a/src/fortranscanner.l +++ b/src/fortranscanner.l @@ -165,11 +165,11 @@ static int yyColNr = 0 ; static Entry* current_root = 0 ; static Entry* global_root = 0 ; static Entry* file_root = 0 ; -static Entry* current = 0 ; static Entry* last_entry = 0 ; static Entry* last_enum = 0 ; +static std::unique_ptr<Entry> current; static ScanVar v_type = V_IGNORE; // type of parsed variable -static QList<Entry> moduleProcedures; // list of all interfaces which contain unresolved +static std::vector<Entry*> moduleProcedures; // list of all interfaces which contain unresolved // module procedures static QCString docBlock; static bool docBlockInBody = FALSE; @@ -181,7 +181,7 @@ static Specifier virt; static QCString debugStr; static QCString result; // function result -static Argument *parameter; // element of parameter list +static Argument *parameter; // element of parameter list static QCString argType; // fortran type of an argument of a parameter list static QCString argName; // last identifier name in variable list static QCString initializer; // initial value of a variable @@ -202,7 +202,7 @@ static SymbolModifiers currentModifiers; //! Holds program scope->symbol name->symbol modifiers. static QMap<Entry*,QMap<QCString,SymbolModifiers> > modifiers; -static Entry *global_scope = NULL; +static Entry *global_scope = 0; static int anonCount = 0 ; //----------------------------------------------------------------------------- @@ -211,7 +211,7 @@ static void startCommentBlock(bool); static void handleCommentBlock(const QCString &doc,bool brief); static void subrHandleCommentBlock(const QCString &doc,bool brief); static void subrHandleCommentBlockResult(const QCString &doc,bool brief); -static void addCurrentEntry(int case_insens); +static void addCurrentEntry(bool case_insens); static void addModule(const char *name, bool isModule=FALSE); static void addSubprogram(const char *text); static void addInterface(QCString name, InterfaceType type); @@ -221,7 +221,7 @@ static void scanner_abort(); static void startScope(Entry *scope); static bool endScope(Entry *scope, bool isGlobalRoot=FALSE); //static bool isTypeName(QCString name); -static void resolveModuleProcedures(QList<Entry> &moduleProcedures, Entry *current_root); +static void resolveModuleProcedures(Entry *current_root); static int getAmpersandAtTheStart(const char *buf, int length); static int getAmpOrExclAtTheEnd(const char *buf, int length, char ch); static void truncatePrepass(int index); @@ -241,6 +241,7 @@ static const char *stateToString(int state); #undef YY_INPUT #define YY_INPUT(buf,result,max_size) result=yyread(buf,max_size); #define YY_USER_ACTION yyColNr+=(int)yyleng; +#define INVALID_ENTRY ((Entry*)0x8) //----------------------------------------------------------------------------- %} @@ -444,8 +445,7 @@ SCOPENAME ({ID}{BS}"::"{BS})* current->name=yytext; current->fileName = yyFileName; current->section=Entry::USINGDIR_SEC; - current_root->addSubEntry(current); - current = new Entry; + current_root->moveToSubEntryAndRefresh(current); current->lang = SrcLangExt_Fortran; yy_pop_state(); } @@ -459,8 +459,7 @@ SCOPENAME ({ID}{BS}"::"{BS})* current->name= useModuleName+"::"+yytext; current->fileName = yyFileName; current->section=Entry::USINGDECL_SEC; - current_root->addSubEntry(current); - current = new Entry ; + current_root->moveToSubEntryAndRefresh(current); current->lang = SrcLangExt_Fortran; } <Use,UseOnly>"\n" { @@ -516,8 +515,8 @@ SCOPENAME ({ID}{BS}"::"{BS})* current->section = Entry::FUNCTION_SEC ; current->name = yytext; - moduleProcedures.append(current); - addCurrentEntry(1); + moduleProcedures.push_back(current.get()); + addCurrentEntry(true); } <ModuleProcedure>"\n" { yyColNr -= 1; unput(*yytext); @@ -558,13 +557,13 @@ SCOPENAME ({ID}{BS}"::"{BS})* yy_pop_state(); } <Start,ModuleBody,ModuleBodyContains>"end"({BS}(module|program)({BS_}{ID})?)?{BS}/(\n|!|;) { // end module - resolveModuleProcedures(moduleProcedures, current_root); + resolveModuleProcedures(current_root); if (!endScope(current_root)) yyterminate(); defaultProtection = Public; if (global_scope) { - if (global_scope != (Entry *) -1) + if (global_scope != INVALID_ENTRY) yy_push_state(Start); else yy_pop_state(); // cannot pop artrificial entry @@ -572,7 +571,7 @@ SCOPENAME ({ID}{BS}"::"{BS})* else { yy_push_state(Start); - global_scope = (Entry *)-1; // signal that the global_scope has already been used. + global_scope = INVALID_ENTRY; // signal that the global_scope has already been used. } } <Module>{ID} { @@ -618,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; @@ -647,7 +646,7 @@ private { current->name = current_root->name + "::" + current->name; } - addCurrentEntry(1); + addCurrentEntry(true); startScope(last_entry); BEGIN(TypedefBody); } @@ -679,7 +678,7 @@ private { current->fileName = yyFileName; current->bodyLine = yyLineNr; current->startLine = yyLineNr; - addCurrentEntry(1); + addCurrentEntry(true); } {BS}"=>"[^(\n|\!)]* { /* Specific bindings come after the ID. */ QCString args = yytext; @@ -866,17 +865,15 @@ private { current->startLine = yyLineNr; if (argType == "@") { - current_root->addSubEntry(current); - current = new Entry(*current); + current_root->copyToSubEntry(current); // add to the scope surrounding the enum (copy!) - current_root->parent()->addSubEntry(current); - last_enum = current; - current = new Entry ; + last_enum = current.get(); + current_root->parent()->moveToSubEntryAndRefresh(current); initEntry(); } else { - addCurrentEntry(1); + addCurrentEntry(true); } } else if (!argType.isEmpty()) @@ -889,7 +886,7 @@ private { if (!docBlock.isNull()) { subrHandleCommentBlock(docBlock,TRUE); - } + } } // save, it may be function return type if (parameter) @@ -1068,7 +1065,7 @@ private { current->name = current_root->name + "::" + current->name; } - addCurrentEntry(1); + addCurrentEntry(true); startScope(last_entry); BEGIN( Enum ) ; } @@ -1138,15 +1135,17 @@ private { <Parameterlist>")" { current->args += ")"; current->args = removeRedundantWhiteSpace(current->args); - addCurrentEntry(1); + addCurrentEntry(true); startScope(last_entry); BEGIN(SubprogBody); } <Parameterlist>{COMMA}|{BS} { current->args += yytext; CommentInPrepass *c = locatePrepassComment(yyColNr-(int)yyleng, yyColNr); - if (c!=NULL) { - if(current->argList->count()>0) { - current->argList->at(current->argList->count()-1)->docs = c->str; + if (c!=NULL) + { + if (!current->argList.empty()) + { + current->argList.back().docs = c->str; } } } @@ -1155,16 +1154,14 @@ private { QCString param = yytext; // std::cout << "3=========> got parameter " << param << std::endl; current->args += param; - Argument *arg = new Argument; - arg->name = param; - arg->type = ""; - current->argList->append(arg); + Argument arg; + arg.name = param; + current->argList.push_back(arg); } <Parameterlist>{NOARGS} { newLine(); //printf("3=========> without parameterlist \n"); - //current->argList = ; - addCurrentEntry(1); + addCurrentEntry(true); startScope(last_entry); BEGIN(SubprogBody); } @@ -1217,11 +1214,20 @@ private { unput(*yytext); if (v_type == V_VARIABLE) { - Entry *tmp_entry = current; - current = last_entry; // temporarily switch to the previous entry - if (last_enum) current = last_enum; + std::unique_ptr<Entry> tmp_entry; + current.swap(tmp_entry); + // temporarily switch to the previous entry + if (last_enum) + { + current.reset(last_enum); + } + else + { + current.reset(last_entry); + } handleCommentBlock(docBlock,TRUE); - current=tmp_entry; + // switch back + tmp_entry.swap(current); } else if (v_type == V_PARAMETER) { @@ -1274,9 +1280,9 @@ private { <PrototypeArgs>{ "("|")"|","|{BS_} { current->args += yytext; } {ID} { current->args += yytext; - Argument *a = new Argument; - a->name = QCString(yytext).lower(); - current->argList->append(a); + Argument a; + a.name = QCString(yytext).lower(); + current->argList.push_back(a); } } @@ -1773,34 +1779,29 @@ static void popBuffer() { } /** used to copy entry to an interface module procedure */ -static void copyEntry(Entry *dest, Entry *src) +static void copyEntry(Entry *dest, const std::unique_ptr<Entry> &src) { - dest->type = src->type; - dest->fileName = src->fileName; - dest->startLine = src->startLine; - dest->bodyLine = src->bodyLine; + dest->type = src->type; + dest->fileName = src->fileName; + dest->startLine = src->startLine; + dest->bodyLine = src->bodyLine; dest->endBodyLine = src->endBodyLine; - dest->args = src->args; - dest->argList = new ArgumentList(*src->argList); - dest->doc = src->doc; - dest->brief = src->brief; + dest->args = src->args; + dest->argList = src->argList; + dest->doc = src->doc; + dest->brief = src->brief; } /** fill empty interface module procedures with info from corresponding module subprogs @TODO: handle procedures in used modules */ -void resolveModuleProcedures(QList<Entry> &moduleProcedures, Entry *current_root) +void resolveModuleProcedures(Entry *current_root) { - if (moduleProcedures.isEmpty()) return; - - EntryListIterator eli1(moduleProcedures); - // for all module procedures - for (Entry *ce1; (ce1=eli1.current()); ++eli1) + for (const auto &ce1 : moduleProcedures) { // check all entries in this module - EntryListIterator eli2(*current_root->children()); - for (Entry *ce2; (ce2=eli2.current()); ++eli2) + for (const auto &ce2 : current_root->children()) { if (ce1->name == ce2->name) { @@ -1840,7 +1841,7 @@ static QCString extractFromParens(const QCString name) return extracted; } -/*! remove non usefull spaces from bind statement */ +/*! remove unuseful spaces from bind statement */ static QCString extractBind(const QCString name) { QCString parensPart = extractFromParens(name); @@ -2009,39 +2010,18 @@ SymbolModifiers& SymbolModifiers::operator|=(QCString mdfStringArg) static Argument *findArgument(Entry* subprog, QCString name, bool byTypeName = FALSE) { QCString cname(name.lower()); - for (unsigned int i=0; i<subprog->argList->count(); i++) + for (Argument &arg : subprog->argList) { - Argument *arg = subprog->argList->at(i); - if ((!byTypeName && arg->name.lower() == cname) || - (byTypeName && arg->type.lower() == cname) + if ((!byTypeName && arg.name.lower() == cname) || + (byTypeName && arg.type.lower() == cname) ) { - return arg; + return &arg; } } return 0; } -/*! Find function with given name in \a entry. */ -#if 0 -static Entry *findFunction(Entry* entry, QCString name) -{ - QCString cname(name.lower()); - - EntryListIterator eli(*entry->children()); - Entry *ce; - for (;(ce=eli.current());++eli) - { - if (ce->section != Entry::FUNCTION_SEC) - continue; - - if (ce->name.lower() == cname) - return ce; - } - - return 0; -} -#endif /*! Apply modifiers stored in \a mdfs to the \a typeName string. */ static QCString applyModifiers(QCString typeName, SymbolModifiers& mdfs) @@ -2199,10 +2179,10 @@ static bool endScope(Entry *scope, bool isGlobalRoot) { if (global_scope == scope) { - global_scope = NULL; + global_scope = 0; return TRUE; } - if (global_scope == (Entry *) -1) + if (global_scope == INVALID_ENTRY) { return TRUE; } @@ -2230,7 +2210,9 @@ static bool endScope(Entry *scope, bool isGlobalRoot) Argument *arg = findArgument(scope, it.key()); if (arg) + { applyModifiers(arg, it.data()); + } } // find return type for function @@ -2250,11 +2232,9 @@ static bool endScope(Entry *scope, bool isGlobalRoot) // iterate functions of interface and // try to find types for dummy(ie. argument) procedures. //cout<<"Search in "<<scope->name<<endl; - EntryListIterator eli(*scope->children()); - Entry *ce; int count = 0; int found = FALSE; - for (;(ce=eli.current());++eli) + for (const auto &ce : scope->children()) { count++; if (ce->section != Entry::FUNCTION_SEC) @@ -2273,7 +2253,7 @@ static bool endScope(Entry *scope, bool isGlobalRoot) { // clear all modifiers of the scope modifiers.remove(scope); - delete scope->parent()->removeSubEntry(scope); + scope->parent()->removeSubEntry(scope); scope = 0; return TRUE; } @@ -2282,16 +2262,14 @@ static bool endScope(Entry *scope, bool isGlobalRoot) if (scope->section!=Entry::FUNCTION_SEC) { // not function section // iterate variables: get and apply modifiers - EntryListIterator eli(*scope->children()); - Entry *ce; - for (;(ce=eli.current());++eli) + for (const auto &ce : scope->children()) { if (ce->section != Entry::VARIABLE_SEC && ce->section != Entry::FUNCTION_SEC) continue; //cout<<ce->name<<", "<<mdfsMap.contains(ce->name.lower())<<mdfsMap.count()<<endl; if (mdfsMap.contains(ce->name.lower())) - applyModifiers(ce, mdfsMap[ce->name.lower()]); + applyModifiers(ce.get(), mdfsMap[ce->name.lower()]); } } @@ -2345,19 +2323,18 @@ static void initEntry() current->virt = virt; current->stat = gstat; current->lang = SrcLangExt_Fortran; - Doxygen::docGroup.initGroupInfo(current); + Doxygen::docGroup.initGroupInfo(current.get()); } /** adds current entry to current_root and creates new current */ -static void addCurrentEntry(int case_insens) +static void addCurrentEntry(bool case_insens) { if (case_insens) current->name = current->name.lower(); //printf("===Adding entry %s to %s\n", current->name.data(), current_root->name.data()); - current_root->addSubEntry(current); - last_entry = current; - current = new Entry ; + last_entry = current.get(); + current_root->moveToSubEntryAndRefresh(current); initEntry(); } @@ -2375,7 +2352,7 @@ static void addModule(const char *name, bool isModule) if (name!=NULL) { current->name = name; - } + } else { QCString fname = yyFileName; @@ -2389,7 +2366,7 @@ static void addModule(const char *name, bool isModule) current->bodyLine = yyLineNr; // used for source reference current->startLine = yyLineNr; current->protection = Public ; - addCurrentEntry(1); + addCurrentEntry(true); startScope(last_entry); } @@ -2397,7 +2374,7 @@ static void addModule(const char *name, bool isModule) static void addSubprogram(const char *text) { DBG_CTX((stderr,"1=========> got subprog, type: %s\n",text)); - subrCurrent.prepend(current); + subrCurrent.prepend(current.get()); current->section = Entry::FUNCTION_SEC ; QCString subtype = text; subtype=subtype.lower().stripWhiteSpace(); functionLine = (subtype.find("function") != -1); @@ -2407,7 +2384,7 @@ static void addSubprogram(const char *text) current->bodyLine = yyLineNr; // used for source reference start of body of routine current->startLine = yyLineNr; // used for source reference start of definition current->args.resize(0); - current->argList->clear(); + current->argList.clear(); docBlock.resize(0); } @@ -2454,7 +2431,7 @@ static void addInterface(QCString name, InterfaceType type) current->fileName = yyFileName; current->bodyLine = yyLineNr; current->startLine = yyLineNr; - addCurrentEntry(1); + addCurrentEntry(true); } @@ -2462,18 +2439,15 @@ static void addInterface(QCString name, InterfaceType type) /*! Get the argument \a name. */ -static Argument* getParameter(const QCString &name) +static Argument *getParameter(const QCString &name) { // std::cout<<"addFortranParameter(): "<<name<<" DOCS:"<<(docs.isNull()?QCString("null"):docs)<<std::endl; Argument *ret = 0; - if (current_root->argList==0) return 0; - ArgumentListIterator ali(*current_root->argList); - Argument *a; - for (ali.toFirst();(a=ali.current());++ali) + for (Argument &a:current_root->argList) { - if (a->name.lower()==name.lower()) + if (a.name.lower()==name.lower()) { - ret=a; + ret=&a; //printf("parameter found: %s\n",(const char*)name); break; } @@ -2513,7 +2487,7 @@ static void handleCommentBlock(const QCString &doc,bool brief) QCString processedDoc = preprocessCommentBlock(doc,yyFileName,lineNr); while (parseCommentBlock( g_thisParser, - docBlockInBody ? subrCurrent.getFirst() : current, + docBlockInBody ? subrCurrent.getFirst() : current.get(), processedDoc, // text yyFileName, // file lineNr, @@ -2526,11 +2500,11 @@ static void handleCommentBlock(const QCString &doc,bool brief) )) { DBG_CTX((stderr,"parseCommentBlock position=%d [%s] needsEntry=%d\n",position,doc.data()+position,needsEntry)); - if (needsEntry) addCurrentEntry(0); + if (needsEntry) addCurrentEntry(false); } DBG_CTX((stderr,"parseCommentBlock position=%d [%s] needsEntry=%d\n",position,doc.data()+position,needsEntry)); - if (needsEntry) addCurrentEntry(0); + if (needsEntry) addCurrentEntry(false); docBlockInBody = FALSE; } @@ -2541,8 +2515,9 @@ static void subrHandleCommentBlock(const QCString &doc,bool brief) QCString loc_doc; loc_doc = doc.stripWhiteSpace(); - Entry *tmp_entry = current; - current = subrCurrent.getFirst(); // temporarily switch to the entry of the subroutine / function + std::unique_ptr<Entry> tmp_entry; + current.swap(tmp_entry); + current.reset(subrCurrent.getFirst()); // temporarily switch to the entry of the subroutine / function // Still in the specification section so no inbodyDocs yet, but parameter documentation current->inbodyDocs = ""; @@ -2566,14 +2541,11 @@ static void subrHandleCommentBlock(const QCString &doc,bool brief) loc_doc = loc_doc.right(loc_doc.length()-strlen(directionParam[SymbolModifiers::IN])); loc_doc.stripWhiteSpace(); // in case of empty documentation or (now) just name, consider it as no documemntation - if (loc_doc.isEmpty() || (loc_doc.lower() == argName.lower())) + if (!loc_doc.isEmpty() && (loc_doc.lower() != argName.lower())) { - // reset current back to the part inside the routine - current=tmp_entry; - return; - } - handleCommentBlock(QCString("\n\n@param ") + directionParam[SymbolModifiers::IN] + " " + + handleCommentBlock(QCString("\n\n@param ") + directionParam[SymbolModifiers::IN] + " " + argName + " " + loc_doc,brief); + } } else { @@ -2594,7 +2566,7 @@ static void subrHandleCommentBlock(const QCString &doc,bool brief) loc_doc.stripWhiteSpace(); if (loc_doc.isEmpty() || (loc_doc.lower() == argName.lower())) { - current=tmp_entry; + tmp_entry.swap(current); return; } handleCommentBlock(QCString("\n\n@param ") + directionParam[SymbolModifiers::OUT] + " " + @@ -2616,13 +2588,11 @@ static void subrHandleCommentBlock(const QCString &doc,bool brief) { loc_doc = loc_doc.right(loc_doc.length()-strlen(directionParam[SymbolModifiers::INOUT])); loc_doc.stripWhiteSpace(); - if (loc_doc.isEmpty() || (loc_doc.lower() == argName.lower())) + if (!loc_doc.isEmpty() && (loc_doc.lower() != argName.lower())) { - current=tmp_entry; - return; + handleCommentBlock(QCString("\n\n@param ") + directionParam[SymbolModifiers::INOUT] + " " + + argName + " " + loc_doc,brief); } - handleCommentBlock(QCString("\n\n@param ") + directionParam[SymbolModifiers::INOUT] + " " + - argName + " " + loc_doc,brief); } else { @@ -2633,19 +2603,14 @@ static void subrHandleCommentBlock(const QCString &doc,bool brief) } } // analogous to the [in] case; here no direction specified - else + else if (!loc_doc.isEmpty() && (loc_doc.lower() != argName.lower())) { - if (loc_doc.isEmpty() || (loc_doc.lower() == argName.lower())) - { - current=tmp_entry; - return; - } handleCommentBlock(QCString("\n\n@param ") + directionParam[dir1] + " " + argName + " " + loc_doc,brief); } // reset current back to the part inside the routine - current=tmp_entry; + tmp_entry.swap(current); } //---------------------------------------------------------------------------- /// Handle result description as defined after the declaration of the parameter @@ -2654,8 +2619,9 @@ static void subrHandleCommentBlockResult(const QCString &doc,bool brief) QCString loc_doc; loc_doc = doc.stripWhiteSpace(); - Entry *tmp_entry = current; - current = subrCurrent.getFirst(); // temporarily switch to the entry of the subroutine / function + std::unique_ptr<Entry> tmp_entry; + current.swap(tmp_entry); + current.reset(subrCurrent.getFirst()); // temporarily switch to the entry of the subroutine / function // Still in the specification section so no inbodyDocs yet, but parameter documentation current->inbodyDocs = ""; @@ -2668,15 +2634,13 @@ static void subrHandleCommentBlockResult(const QCString &doc,bool brief) ) (void)loc_doc; // Do nothing work has been done by stripPrefix; (void)loc_doc: to overcome 'empty controlled statement' warning loc_doc.stripWhiteSpace(); - if (loc_doc.isEmpty() || (loc_doc.lower() == argName.lower())) + if (!loc_doc.isEmpty() && (loc_doc.lower() != argName.lower())) { - current=tmp_entry; - return; + handleCommentBlock(QCString("\n\n@returns ") + loc_doc,brief); } - handleCommentBlock(QCString("\n\n@returns ") + loc_doc,brief); // reset current back to the part inside the routine - current=tmp_entry; + tmp_entry.swap(current); } //---------------------------------------------------------------------------- @@ -2687,18 +2651,17 @@ static void debugCompounds(Entry *rt) // print Entry structure (for debugging) { level++; printf("%d) debugCompounds(%s) line %d\n",level, rt->name.data(), rt->bodyLine); - EntryListIterator eli(*rt->children()); - Entry *ce; - for (;(ce=eli.current());++eli) + for (const auto &ce : rt->children()) { - debugCompounds(ce); - } + debugCompounds(ce.get()); + } level--; } #endif -static void parseMain(const char *fileName,const char *fileBuf,Entry *rt, FortranFormat format) +static void parseMain(const char *fileName,const char *fileBuf, + const std::unique_ptr<Entry> &rt, FortranFormat format) { char *tmpBuf = NULL; initParser(); @@ -2713,8 +2676,8 @@ static void parseMain(const char *fileName,const char *fileBuf,Entry *rt, Fortra mtype = Method; gstat = FALSE; virt = Normal; - current_root = rt; - global_root = rt; + current_root = rt.get(); + global_root = rt.get(); inputFile.setName(fileName); if (inputFile.open(IO_ReadOnly)) { @@ -2750,18 +2713,18 @@ static void parseMain(const char *fileName,const char *fileBuf,Entry *rt, Fortra yyFileName = fileName; msg("Parsing file %s...\n",yyFileName.data()); - global_scope = rt; - startScope(rt); // implies current_root = rt + global_scope = rt.get(); + startScope(rt.get()); // implies current_root = rt initParser(); Doxygen::docGroup.enterFile(yyFileName,yyLineNr); - current = new Entry; + // add entry for the file + current = std::make_unique<Entry>(); current->lang = SrcLangExt_Fortran; current->name = yyFileName; current->section = Entry::SOURCE_SEC; - current_root->addSubEntry(current); - file_root = current; - current = new Entry; + file_root = current.get(); + current_root->moveToSubEntryAndRefresh(current); current->lang = SrcLangExt_Fortran; fortranscannerYYrestart( fortranscannerYYin ); @@ -2772,12 +2735,12 @@ static void parseMain(const char *fileName,const char *fileBuf,Entry *rt, Fortra fortranscannerYYlex(); Doxygen::docGroup.leaveFile(yyFileName,yyLineNr); - if (global_scope && global_scope != (Entry *) -1) endScope(current_root, TRUE); // TRUE - global root + if (global_scope && global_scope != INVALID_ENTRY) endScope(current_root, TRUE); // TRUE - global root //debugCompounds(rt); //debug rt->program.resize(0); - delete current; current=0; + //delete current; current=0; moduleProcedures.clear(); if (tmpBuf) { free((char*)tmpBuf); @@ -2796,7 +2759,7 @@ static void parseMain(const char *fileName,const char *fileBuf,Entry *rt, Fortra void FortranLanguageScanner::parseInput(const char *fileName, const char *fileBuf, - Entry *root, + const std::unique_ptr<Entry> &root, bool /*sameTranslationUnit*/, QStrList & /*filesInSameTranslationUnit*/) { @@ -2856,13 +2819,11 @@ static void scanner_abort() fprintf(stderr,"Error in file %s line: %d, state: %d(%s)\n",yyFileName.data(),yyLineNr,YY_START,stateToString(YY_START)); fprintf(stderr,"********************************************************************\n"); - EntryListIterator eli(*global_root->children()); - Entry *ce; bool start=FALSE; - for (;(ce=eli.current());++eli) + for (const auto &ce : global_root->children()) { - if (ce == file_root) start=TRUE; + if (ce.get() == file_root) start=TRUE; if (start) ce->reset(); } diff --git a/src/groupdef.cpp b/src/groupdef.cpp index e1fab11..0d6d43f 100644 --- a/src/groupdef.cpp +++ b/src/groupdef.cpp @@ -396,15 +396,13 @@ bool GroupDefImpl::insertMember(MemberDef *md,bool docOnly) (srcMd->getOuterScope()->definitionType()==Definition::TypeFile && md->getOuterScope()->definitionType()==Definition::TypeFile); - const ArgumentList *srcMdAl = srcMd->argumentList(); - const ArgumentList *mdAl = md->argumentList(); - const ArgumentList *tSrcMdAl = srcMd->templateArguments(); - const ArgumentList *tMdAl = md->templateArguments(); - + const ArgumentList &srcMdAl = srcMd->argumentList(); + const ArgumentList &mdAl = md->argumentList(); + const ArgumentList &tSrcMdAl = srcMd->templateArguments(); + const ArgumentList &tMdAl = md->templateArguments(); + if (srcMd->isFunction() && md->isFunction() && // both are a function - ((tSrcMdAl==0 && tMdAl==0) || - (tSrcMdAl!=0 && tMdAl!=0 && tSrcMdAl->count()==tMdAl->count()) - ) && // same number of template arguments + (tSrcMdAl.size()==tMdAl.size()) && // same number of template arguments matchArguments2(srcMd->getOuterScope(),srcMd->getFileDef(),srcMdAl, md->getOuterScope(),md->getFileDef(),mdAl, TRUE @@ -1460,14 +1458,12 @@ void GroupDefImpl::writeQuickMemberLinks(OutputList &ol,const MemberDef *current //---- helper functions ------------------------------------------------------ -void addClassToGroups(Entry *root,ClassDef *cd) +void addClassToGroups(const Entry *root,ClassDef *cd) { - QListIterator<Grouping> gli(*root->groups); - Grouping *g; - for (;(g=gli.current());++gli) + for (const Grouping &g : root->groups) { GroupDef *gd=0; - if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname))) + if (!g.groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g.groupname))) { if (gd->addClass(cd)) { @@ -1478,16 +1474,14 @@ void addClassToGroups(Entry *root,ClassDef *cd) } } -void addNamespaceToGroups(Entry *root,NamespaceDef *nd) +void addNamespaceToGroups(const Entry *root,NamespaceDef *nd) { - //printf("root->groups->count()=%d\n",root->groups->count()); - QListIterator<Grouping> gli(*root->groups); - Grouping *g; - for (;(g=gli.current());++gli) + //printf("root->groups.size()=%d\n",root->groups.size()); + for (const Grouping &g : root->groups) { GroupDef *gd=0; //printf("group '%s'\n",s->data()); - if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname))) + if (!g.groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g.groupname))) { if (gd->addNamespace(nd)) nd->makePartOfGroup(gd); //printf("Namespace %s: in group %s\n",nd->name().data(),s->data()); @@ -1495,16 +1489,14 @@ void addNamespaceToGroups(Entry *root,NamespaceDef *nd) } } -void addDirToGroups(Entry *root,DirDef *dd) +void addDirToGroups(const Entry *root,DirDef *dd) { - //printf("*** root->groups->count()=%d\n",root->groups->count()); - QListIterator<Grouping> gli(*root->groups); - Grouping *g; - for (;(g=gli.current());++gli) + //printf("*** root->groups.size()=%d\n",root->groups.size()); + for (const Grouping &g : root->groups) { GroupDef *gd=0; //printf("group '%s'\n",g->groupname.data()); - if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname))) + if (!g.groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g.groupname))) { gd->addDir(dd); dd->makePartOfGroup(gd); @@ -1513,16 +1505,13 @@ void addDirToGroups(Entry *root,DirDef *dd) } } -void addGroupToGroups(Entry *root,GroupDef *subGroup) +void addGroupToGroups(const Entry *root,GroupDef *subGroup) { - //printf("addGroupToGroups for %s groups=%d\n",root->name.data(), - // root->groups?root->groups->count():-1); - QListIterator<Grouping> gli(*root->groups); - Grouping *g; - for (;(g=gli.current());++gli) + //printf("addGroupToGroups for %s groups=%d\n",root->name.data(),root->groups.size()); + for (const Grouping &g : root->groups) { GroupDef *gd=0; - if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname))) + if (!g.groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g.groupname))) { if (gd==subGroup) { @@ -1544,24 +1533,22 @@ void addGroupToGroups(Entry *root,GroupDef *subGroup) } /*! Add a member to the group with the highest priority */ -void addMemberToGroups(Entry *root,MemberDef *md) +void addMemberToGroups(const Entry *root,MemberDef *md) { //printf("addMemberToGroups: Root %p = %s, md %p=%s groups=%d\n", // root, root->name.data(), md, md->name().data(), root->groups->count() ); - QListIterator<Grouping> gli(*root->groups); - Grouping *g; // Search entry's group list for group with highest pri. Grouping::GroupPri_t pri = Grouping::GROUPING_LOWEST; GroupDef *fgd=0; - for (;(g=gli.current());++gli) + for (const Grouping &g : root->groups) { GroupDef *gd=0; - if (!g->groupname.isEmpty() && - (gd=Doxygen::groupSDict->find(g->groupname)) && - g->pri >= pri) + if (!g.groupname.isEmpty() && + (gd=Doxygen::groupSDict->find(g.groupname)) && + g.pri >= pri) { - if (fgd && gd!=fgd && g->pri==pri) + if (fgd && gd!=fgd && g.pri==pri) { warn(root->fileName.data(), root->startLine, "Member %s found in multiple %s groups! " @@ -1572,7 +1559,7 @@ void addMemberToGroups(Entry *root,MemberDef *md) } fgd = gd; - pri = g->pri; + pri = g.pri; } } //printf("fgd=%p\n",fgd); @@ -1650,14 +1637,12 @@ void addMemberToGroups(Entry *root,MemberDef *md) } -void addExampleToGroups(Entry *root,PageDef *eg) +void addExampleToGroups(const Entry *root,PageDef *eg) { - QListIterator<Grouping> gli(*root->groups); - Grouping *g; - for (;(g=gli.current());++gli) + for (const Grouping &g : root->groups) { GroupDef *gd=0; - if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname))) + if (!g.groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g.groupname))) { gd->addExample(eg); eg->makePartOfGroup(gd); @@ -1674,7 +1659,7 @@ QCString GroupDefImpl::getOutputFileBase() const void GroupDefImpl::addListReferences() { { - QList<ListItemInfo> *xrefItems = xrefListItems(); + const std::vector<ListItemInfo> &xrefItems = xrefListItems(); addRefItem(xrefItems, getOutputFileBase(), theTranslator->trGroup(TRUE,TRUE), diff --git a/src/groupdef.h b/src/groupdef.h index 92d524f..8a84a98 100644 --- a/src/groupdef.h +++ b/src/groupdef.h @@ -18,6 +18,8 @@ #ifndef GROUPDEF_H #define GROUPDEF_H +#include <memory> + #include "sortdict.h" #include "definition.h" @@ -138,13 +140,13 @@ class GroupListIterator : public QListIterator<GroupDef> virtual ~GroupListIterator() {} }; -void addClassToGroups(Entry *root,ClassDef *cd); -void addNamespaceToGroups(Entry *root,NamespaceDef *nd); -void addGroupToGroups(Entry *root,GroupDef *subGroup); -void addMemberToGroups(Entry *root,MemberDef *md); -void addPageToGroups(Entry *root,PageDef *pd); -void addExampleToGroups(Entry *root,PageDef *eg); -void addDirToGroups(Entry *root,DirDef *dd); +void addClassToGroups (const Entry *root,ClassDef *cd); +void addNamespaceToGroups(const Entry *root,NamespaceDef *nd); +void addGroupToGroups (const Entry *root,GroupDef *subGroup); +void addMemberToGroups (const Entry *root,MemberDef *md); +void addPageToGroups (const Entry *root,PageDef *pd); +void addExampleToGroups (const Entry *root,PageDef *eg); +void addDirToGroups (const Entry *root,DirDef *dd); #endif diff --git a/src/layout.cpp b/src/layout.cpp index c560147..946b612 100644 --- a/src/layout.cpp +++ b/src/layout.cpp @@ -265,6 +265,9 @@ class LayoutParser : public QXmlDefaultHandler m_part = -1; // invalid m_rootNav = 0; + //bool fortranOpt = Config_getBool(OPTIMIZE_FOR_FORTRAN); + //bool vhdlOpt = Config_getBool(OPTIMIZE_OUTPUT_VHDL); + //bool javaOpt = Config_getBool(OPTIMIZE_OUTPUT_JAVA); bool sliceOpt = Config_getBool(OPTIMIZE_OUTPUT_SLICE); // start & end handlers @@ -1546,7 +1549,9 @@ void LayoutDocManager::parse(const char *fileName) reader.parse( source ); } -void LayoutDocManager::writeDefault(const char *fileName) const +//--------------------------------------------------------------------------------- + +void writeDefaultLayoutFile(const char *fileName) { QFile f(fileName); bool ok = openOutputFile(fileName,f); @@ -1556,6 +1561,7 @@ void LayoutDocManager::writeDefault(const char *fileName) const return; } QTextStream t(&f); + t.setEncoding(QTextStream::UnicodeUTF8); t << substitute(layout_default,"$doxygenversion",getVersion()); } diff --git a/src/layout.h b/src/layout.h index 3260a28..b1facf5 100644 --- a/src/layout.h +++ b/src/layout.h @@ -162,7 +162,8 @@ struct LayoutNavEntry QCString title() const { return m_title; } QCString intro() const { return m_intro; } QCString url() const; - bool visible() const { return m_visible; } + bool visible() { return m_visible; } + void clear() { m_children.clear(); } void addChild(LayoutNavEntry *e) { m_children.append(e); } void prependChild(LayoutNavEntry *e) { m_children.prepend(e); } const QList<LayoutNavEntry> &children() const { return m_children; } @@ -171,7 +172,6 @@ struct LayoutNavEntry private: LayoutNavEntry() : m_parent(0), m_kind(None), m_visible(FALSE) {} LayoutNavEntry *m_parent; - void clear() { m_children.clear(); } Kind m_kind; bool m_visible; QCString m_baseFile; @@ -179,7 +179,6 @@ struct LayoutNavEntry QCString m_intro; QList<LayoutNavEntry> m_children; friend class LayoutDocManager; - friend class LayoutParser; }; /** @brief Singleton providing access to the (user configurable) layout of the documentation */ @@ -204,7 +203,6 @@ class LayoutDocManager /** Parses a user provided layout */ void parse(const char *fileName); void init(); - void writeDefault(const char *fileName) const; private: void addEntry(LayoutPart p,LayoutDocEntry*e); void clear(LayoutPart p); @@ -214,6 +212,7 @@ class LayoutDocManager friend class LayoutParser; }; +void writeDefaultLayoutFile(const char *fileName); #endif diff --git a/src/markdown.cpp b/src/markdown.cpp index ce28540..d1a6a63 100644 --- a/src/markdown.cpp +++ b/src/markdown.cpp @@ -2578,11 +2578,11 @@ QCString markdownFileNameToId(const QCString &fileName) void MarkdownFileParser::parseInput(const char *fileName, const char *fileBuf, - Entry *root, + const std::unique_ptr<Entry> &root, bool /*sameTranslationUnit*/, QStrList & /*filesInSameTranslationUnit*/) { - Entry *current = new Entry; + std::unique_ptr<Entry> current = std::make_unique<Entry>(); current->lang = SrcLangExt_Markdown; current->fileName = fileName; current->docFile = fileName; @@ -2630,7 +2630,7 @@ void MarkdownFileParser::parseInput(const char *fileName, QCString processedDocs = preprocessCommentBlock(docs,fileName,lineNr); while (parseCommentBlock( this, - current, + current.get(), processedDocs, fileName, lineNr, @@ -2644,8 +2644,7 @@ void MarkdownFileParser::parseInput(const char *fileName, if (needsEntry) { QCString docFile = current->docFile; - root->addSubEntry(current); - current = new Entry; + root->moveToSubEntryAndRefresh(current); current->lang = SrcLangExt_Markdown; current->docFile = docFile; current->docLine = lineNr; @@ -2653,7 +2652,7 @@ void MarkdownFileParser::parseInput(const char *fileName, } if (needsEntry) { - root->addSubEntry(current); + root->moveToSubEntryAndKeep(current); } // restore setting diff --git a/src/markdown.h b/src/markdown.h index 1a3895e..f101e5a 100644 --- a/src/markdown.h +++ b/src/markdown.h @@ -33,7 +33,7 @@ class MarkdownFileParser : public ParserInterface void finishTranslationUnit() {} void parseInput(const char *fileName, const char *fileBuf, - Entry *root, + const std::unique_ptr<Entry> &root, bool sameTranslationUnit, QStrList &filesInSameTranslationUnit); bool needsPreprocessing(const QCString &) { return FALSE; } diff --git a/src/memberdef.cpp b/src/memberdef.cpp index 4f44baa..f19a805 100644 --- a/src/memberdef.cpp +++ b/src/memberdef.cpp @@ -54,8 +54,8 @@ class MemberDefImpl : public DefinitionImpl, public MemberDef MemberDefImpl(const char *defFileName,int defLine,int defColumn, const char *type,const char *name,const char *args, const char *excp,Protection prot,Specifier virt,bool stat, - Relationship related,MemberType t,const ArgumentList *tal, - const ArgumentList *al,const char *metaData); + Relationship related,MemberType t,const ArgumentList &tal, + const ArgumentList &al,const char *metaData); virtual ~MemberDefImpl(); virtual DefType definitionType() const { return TypeMember; } @@ -202,11 +202,11 @@ class MemberDefImpl : public DefinitionImpl, public MemberDef virtual bool hasExamples() const; virtual ExampleSDict *getExamples() const; virtual bool isPrototype() const; - virtual const ArgumentList *argumentList() const; - virtual ArgumentList *argumentList(); - virtual const ArgumentList *declArgumentList() const; - virtual const ArgumentList *templateArguments() const; - virtual const QList<ArgumentList> *definitionTemplateParameterLists() const; + virtual const ArgumentList &argumentList() const; + virtual ArgumentList &argumentList(); + virtual const ArgumentList &declArgumentList() const; + virtual const ArgumentList &templateArguments() const; + virtual const std::vector<ArgumentList> &definitionTemplateParameterLists() const; virtual int getMemberGroupId() const; virtual MemberGroup *getMemberGroup() const; virtual bool fromAnonymousScope() const; @@ -233,7 +233,7 @@ class MemberDefImpl : public DefinitionImpl, public MemberDef virtual QCString displayName(bool=TRUE) const; virtual QCString getDeclType() const; virtual void getLabels(QStrList &sl,const Definition *container) const; - virtual const ArgumentList *typeConstraints() const; + virtual const ArgumentList &typeConstraints() const; virtual QCString documentation() const; virtual QCString briefDescription(bool abbr=FALSE) const; virtual QCString fieldType() const; @@ -262,7 +262,7 @@ class MemberDefImpl : public DefinitionImpl, public MemberDef virtual void makeRelated(); virtual void makeForeign(); virtual void setInheritsDocsFrom(MemberDef *md); - virtual void setTagInfo(TagInfo *i); + virtual void setTagInfo(const TagInfo *i); virtual void setArgsString(const char *as); virtual void setReimplements(MemberDef *md); virtual void insertReimplementedBy(MemberDef *md); @@ -276,10 +276,10 @@ class MemberDefImpl : public DefinitionImpl, public MemberDef virtual void setPrototype(bool p,const QCString &df,int line, int column); virtual void setExplicitExternal(bool b,const QCString &df,int line,int column); virtual void setDeclFile(const QCString &df,int line,int column); - virtual void setArgumentList(ArgumentList *al); - virtual void setDeclArgumentList(ArgumentList *al); - virtual void setDefinitionTemplateParameterLists(QList<ArgumentList> *lists); - virtual void setTypeConstraints(ArgumentList *al); + virtual void setArgumentList(const ArgumentList &al); + virtual void setDeclArgumentList(const ArgumentList &al); + virtual void setDefinitionTemplateParameterLists(const std::vector<ArgumentList> &lists); + virtual void setTypeConstraints(const ArgumentList &al); virtual void setType(const char *t); virtual void setAccessorType(ClassDef *cd,const char *t); virtual void setNamespace(NamespaceDef *nd); @@ -324,8 +324,8 @@ class MemberDefImpl : public DefinitionImpl, public MemberDef virtual void warnIfUndocumented() const; virtual void warnIfUndocumentedParams() const; virtual void detectUndocumentedParams(bool hasParamCommand,bool hasReturnCommand) const; - virtual MemberDef *createTemplateInstanceMember(ArgumentList *formalArgs, - ArgumentList *actualArgs) const; + virtual MemberDef *createTemplateInstanceMember(const ArgumentList &formalArgs, + const ArgumentList &actualArgs) const; virtual void findSectionsInDocumentation(); virtual void writeLink(OutputList &ol, const ClassDef *cd,const NamespaceDef *nd,const FileDef *fd,const GroupDef *gd, @@ -367,8 +367,8 @@ class MemberDefImpl : public DefinitionImpl, public MemberDef MemberDef *createMemberDef(const char *defFileName,int defLine,int defColumn, const char *type,const char *name,const char *args, const char *excp,Protection prot,Specifier virt,bool stat, - Relationship related,MemberType t,const ArgumentList *tal, - const ArgumentList *al,const char *metaData) + Relationship related,MemberType t,const ArgumentList &tal, + const ArgumentList &al,const char *metaData) { return new MemberDefImpl(defFileName,defLine,defColumn,type,name,args,excp,prot,virt, stat,related,t,tal,al,metaData); @@ -661,13 +661,13 @@ class MemberDefAliasImpl : public DefinitionAliasImpl, public MemberDef { return getMdAlias()->getExamples(); } virtual bool isPrototype() const { return getMdAlias()->isPrototype(); } - virtual const ArgumentList *argumentList() const + virtual const ArgumentList &argumentList() const { return getMdAlias()->argumentList(); } - virtual const ArgumentList *declArgumentList() const + virtual const ArgumentList &declArgumentList() const { return getMdAlias()->declArgumentList(); } - virtual const ArgumentList *templateArguments() const + virtual const ArgumentList &templateArguments() const { return getMdAlias()->templateArguments(); } - virtual const QList<ArgumentList> *definitionTemplateParameterLists() const + virtual const std::vector<ArgumentList> &definitionTemplateParameterLists() const { return getMdAlias()->definitionTemplateParameterLists(); } virtual int getMemberGroupId() const { return getMdAlias()->getMemberGroupId(); } @@ -721,7 +721,7 @@ class MemberDefAliasImpl : public DefinitionAliasImpl, public MemberDef { return getMdAlias()->getDeclType(); } virtual void getLabels(QStrList &sl,const Definition *container) const { return getMdAlias()->getLabels(sl,container); } - virtual const ArgumentList *typeConstraints() const + virtual const ArgumentList &typeConstraints() const { return getMdAlias()->typeConstraints(); } virtual QCString documentation() const { return getMdAlias()->documentation(); } @@ -747,8 +747,10 @@ class MemberDefAliasImpl : public DefinitionAliasImpl, public MemberDef { err("non-const getNamespaceDef() called on aliased member. Please report as a bug.\n"); return 0; } virtual GroupDef *getGroupDef() { err("non-const getGroupDef() called on aliased member. Please report as a bug.\n"); return 0; } - virtual ArgumentList *argumentList() - { err("non-const argumentList() called on aliased member. Please report as bug.\n"); return 0; } + virtual ArgumentList &argumentList() + { err("non-const argumentList() called on aliased member. Please report as bug.\n"); + static ArgumentList dummy; return dummy; + } virtual void setEnumBaseType(const QCString &type) {} virtual void setMemberType(MemberType t) {} @@ -772,7 +774,7 @@ class MemberDefAliasImpl : public DefinitionAliasImpl, public MemberDef virtual void makeRelated() {} virtual void makeForeign() {} virtual void setInheritsDocsFrom(MemberDef *md) {} - virtual void setTagInfo(TagInfo *i) {} + virtual void setTagInfo(const TagInfo *i) {} virtual void setArgsString(const char *as) {} virtual void setReimplements(MemberDef *md) {} virtual void insertReimplementedBy(MemberDef *md) {} @@ -786,10 +788,10 @@ class MemberDefAliasImpl : public DefinitionAliasImpl, public MemberDef virtual void setPrototype(bool p,const QCString &df,int line, int column) {} virtual void setExplicitExternal(bool b,const QCString &df,int line,int column) {} virtual void setDeclFile(const QCString &df,int line,int column) {} - virtual void setArgumentList(ArgumentList *al) {} - virtual void setDeclArgumentList(ArgumentList *al) {} - virtual void setDefinitionTemplateParameterLists(QList<ArgumentList> *lists) {} - virtual void setTypeConstraints(ArgumentList *al) {} + virtual void setArgumentList(const ArgumentList &al) {} + virtual void setDeclArgumentList(const ArgumentList &al) {} + virtual void setDefinitionTemplateParameterLists(const std::vector<ArgumentList> &lists) {} + virtual void setTypeConstraints(const ArgumentList &al) {} virtual void setType(const char *t) {} virtual void setAccessorType(ClassDef *cd,const char *t) {} virtual void setNamespace(NamespaceDef *nd) {} @@ -821,8 +823,8 @@ class MemberDefAliasImpl : public DefinitionAliasImpl, public MemberDef virtual void setHidden(bool b) {} virtual void addToSearchIndex() const {} virtual void findSectionsInDocumentation() {} - virtual MemberDef *createTemplateInstanceMember(ArgumentList *formalArgs, - ArgumentList *actualArgs) const + virtual MemberDef *createTemplateInstanceMember(const ArgumentList &formalArgs, + const ArgumentList &actualArgs) const { return getMdAlias()->createTemplateInstanceMember(formalArgs,actualArgs); } virtual void incrementFlowKeyWordCount() {} @@ -934,10 +936,10 @@ static QCString addTemplateNames(const QCString &s,const QCString &n,const QCStr static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const MemberDef *md) { - const ArgumentList *defArgList=(md->isDocsForDefinition()) ? + const ArgumentList &defArgList=(md->isDocsForDefinition()) ? md->argumentList() : md->declArgumentList(); //printf("writeDefArgumentList '%s' isDocsForDefinition()=%d\n",md->name().data(),md->isDocsForDefinition()); - if (defArgList==0 || md->isProperty()) + if (!defArgList.hasParameters() || md->isProperty()) { return FALSE; // member has no function like argument list } @@ -945,23 +947,21 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me // simple argument list for tcl if (md->getLanguage()==SrcLangExt_Tcl) { - if (defArgList->count()==0) return FALSE; - ArgumentListIterator ali(*defArgList); - Argument *a; + if (defArgList.empty()) return FALSE; ol.endMemberDocName(); ol.startParameterList(FALSE); ol.startParameterType(TRUE,0); ol.endParameterType(); ol.startParameterName(FALSE); - for (;(a=ali.current());++ali) + for (const Argument &a : defArgList) { - if (a->defval.isEmpty()) + if (a.defval.isEmpty()) { - ol.docify(a->name+" "); + ol.docify(a.name+" "); } else { - ol.docify("?"+a->name+"? "); + ol.docify("?"+a.name+"? "); } } ol.endParameterName(TRUE,FALSE,FALSE); @@ -1008,9 +1008,10 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me cName=cName.mid(il,ir-il+1); //printf("1. cName=%s\n",cName.data()); } - else if (scope->definitionType()==Definition::TypeClass && (dynamic_cast<const ClassDef*>(scope))->templateArguments()) + else if (scope->definitionType()==Definition::TypeClass) { - cName=tempArgListToString((dynamic_cast<const ClassDef*>(scope))->templateArguments(),scope->getLanguage()); + cName=tempArgListToString((dynamic_cast<const ClassDef*>(scope))->templateArguments(), + scope->getLanguage()); //printf("2. cName=%s\n",cName.data()); } else // no template specifier @@ -1023,10 +1024,10 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me bool first=TRUE; bool paramTypeStarted=FALSE; bool isDefine = md->isDefine(); - ArgumentListIterator ali(*defArgList); - Argument *a=ali.current(); - while (a) + auto alIt = defArgList.begin(); + while (alIt!=defArgList.end()) { + Argument a = *alIt; if (isDefine || first) { ol.startParameterType(first,0); @@ -1038,30 +1039,30 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me } } QRegExp re(")("),res("(.*\\*"); - int vp=a->type.find(re); - int wp=a->type.find(res); + int vp=a.type.find(re); + int wp=a.type.find(res); // use the following to put the function pointer type before the name bool hasFuncPtrType=FALSE; - if (!a->attrib.isEmpty() && !md->isObjCMethod()) // argument has an IDL attribute + if (!a.attrib.isEmpty() && !md->isObjCMethod()) // argument has an IDL attribute { - ol.docify(a->attrib+" "); + ol.docify(a.attrib+" "); } if (hasFuncPtrType) // argument type is a function pointer { - //printf("a->type='%s' a->name='%s'\n",a->type.data(),a->name.data()); - QCString n=a->type.left(vp); - if (hasFuncPtrType) n=a->type.left(wp); + //printf("a.type='%s' a.name='%s'\n",a.type.data(),a.name.data()); + QCString n=a.type.left(vp); + if (hasFuncPtrType) n=a.type.left(wp); if (md->isObjCMethod()) { n.prepend("("); n.append(")"); } if (!cName.isEmpty()) n=addTemplateNames(n,scope->name(),cName); linkifyText(TextGeneratorOLImpl(ol),scope,md->getBodyDef(),md,n); } else // non-function pointer type { - QCString n=a->type; + QCString n=a.type; if (md->isObjCMethod()) { n.prepend("("); n.append(")"); } - if (a->type!="...") + if (a.type!="...") { if (!cName.isEmpty()) n=addTemplateNames(n,scope->name(),cName); linkifyText(TextGeneratorOLImpl(ol),scope,md->getBodyDef(),md,n); @@ -1074,13 +1075,13 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me ol.endParameterType(); paramTypeStarted=FALSE; } - ol.startParameterName(defArgList->count()<2); + ol.startParameterName(defArgList.size()<2); } if (hasFuncPtrType) { - ol.docify(a->type.mid(wp,vp-wp)); + ol.docify(a.type.mid(wp,vp-wp)); } - if (!a->name.isEmpty() || a->type=="...") // argument has a name + if (!a.name.isEmpty() || a.type=="...") // argument has a name { //if (!hasFuncPtrType) //{ @@ -1096,7 +1097,7 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me ol.enable(OutputGenerator::Man); if (latexOn) ol.enable(OutputGenerator::Latex); if (docbookOn) ol.enable(OutputGenerator::Docbook); - if (a->name.isEmpty()) ol.docify(a->type); else ol.docify(a->name); + if (a.name.isEmpty()) ol.docify(a.type); else ol.docify(a.name); ol.disable(OutputGenerator::Man); ol.disable(OutputGenerator::Latex); ol.disable(OutputGenerator::Docbook); @@ -1105,19 +1106,19 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me if (latexOn) ol.enable(OutputGenerator::Latex); if (docbookOn) ol.enable(OutputGenerator::Docbook); } - if (!a->array.isEmpty()) + if (!a.array.isEmpty()) { - ol.docify(a->array); + ol.docify(a.array); } if (hasFuncPtrType) // write the part of the argument type // that comes after the name { linkifyText(TextGeneratorOLImpl(ol),scope,md->getBodyDef(), - md,a->type.right(a->type.length()-vp)); + md,a.type.right(a.type.length()-vp)); } - if (!a->defval.isEmpty()) // write the default value + if (!a.defval.isEmpty()) // write the default value { - QCString n=a->defval; + QCString n=a.defval; if (!cName.isEmpty()) n=addTemplateNames(n,scope->name(),cName); ol.docify(" = "); @@ -1126,19 +1127,19 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me ol.endTypewriter(); } - ++ali; - a=ali.current(); - if (a) + ++alIt; + if (alIt!=defArgList.end()) { + a = *alIt; if (!md->isObjCMethod()) ol.docify(", "); // there are more arguments if (!isDefine) { QCString key; - if (md->isObjCMethod() && a->attrib.length()>=2) + if (md->isObjCMethod() && a.attrib.length()>=2) { - //printf("Found parameter keyword %s\n",a->attrib.data()); + //printf("Found parameter keyword %s\n",a.attrib.data()); // strip [ and ] - key=a->attrib.mid(1,a->attrib.length()-2); + key=a.attrib.mid(1,a.attrib.length()-2); if (key!=",") key+=":"; // for normal keywords add colon } ol.endParameterName(FALSE,FALSE,!md->isObjCMethod()); @@ -1165,36 +1166,36 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me if (htmlOn) ol.enable(OutputGenerator::Html); if (latexOn) ol.enable(OutputGenerator::Latex); if (docbookOn) ol.enable(OutputGenerator::Docbook); - if (first) ol.startParameterName(defArgList->count()<2); - ol.endParameterName(TRUE,defArgList->count()<2,!md->isObjCMethod()); + if (first) ol.startParameterName(defArgList.size()<2); + ol.endParameterName(TRUE,defArgList.size()<2,!md->isObjCMethod()); ol.popGeneratorState(); if (md->extraTypeChars()) { ol.docify(md->extraTypeChars()); } - if (defArgList->constSpecifier) + if (defArgList.constSpecifier) { ol.docify(" const"); } - if (defArgList->volatileSpecifier) + if (defArgList.volatileSpecifier) { ol.docify(" volatile"); } - if (defArgList->refQualifier==RefQualifierLValue) + if (defArgList.refQualifier==RefQualifierLValue) { ol.docify(" &"); } - else if (defArgList->refQualifier==RefQualifierRValue) + else if (defArgList.refQualifier==RefQualifierRValue) { ol.docify(" &&"); } - if (!defArgList->trailingReturnType.isEmpty()) + if (!defArgList.trailingReturnType.isEmpty()) { linkifyText(TextGeneratorOLImpl(ol), // out scope, // scope md->getBodyDef(), // fileScope md, // self - defArgList->trailingReturnType, // text + defArgList.trailingReturnType, // text FALSE // autoBreak ); @@ -1264,24 +1265,22 @@ static void writeExceptionList(OutputList &ol, const ClassDef *cd, const MemberD } } -static void writeTemplatePrefix(OutputList &ol,const ArgumentList *al) +static void writeTemplatePrefix(OutputList &ol,const ArgumentList &al) { ol.docify("template<"); - ArgumentListIterator ali(*al); - Argument *a = ali.current(); - while (a) + for (auto it = al.begin(); it!=al.end();) { - ol.docify(a->type); + Argument a = *it; + ol.docify(a.type); ol.docify(" "); - ol.docify(a->name); - if (a->defval.length()!=0) + ol.docify(a.name); + if (a.defval.length()!=0) { ol.docify(" = "); - ol.docify(a->defval); + ol.docify(a.defval); } - ++ali; - a=ali.current(); - if (a) ol.docify(", "); + ++it; + if (it!=al.end()) ol.docify(", "); } ol.docify("> "); } @@ -1297,8 +1296,8 @@ class MemberDefImpl::IMPL ~IMPL(); void init(Definition *def,const char *t,const char *a,const char *e, Protection p,Specifier v,bool s,Relationship r, - MemberType mt,const ArgumentList *tal, - const ArgumentList *al,const char *meta + MemberType mt,const ArgumentList &tal, + const ArgumentList &al,const char *meta ); ClassDef *classDef; // member of or related to @@ -1344,13 +1343,13 @@ class MemberDefImpl::IMPL int userInitLines; // result of explicit \hideinitializer or \showinitializer MemberDef *annMemb; - ArgumentList *defArgList; // argument list of this member definition - ArgumentList *declArgList; // argument list of this member declaration + ArgumentList defArgList; // argument list of this member definition + ArgumentList declArgList; // argument list of this member declaration - ArgumentList *tArgList; // template argument list of function template - ArgumentList *typeConstraints; // type constraints for template parameters + ArgumentList tArgList; // template argument list of function template + ArgumentList typeConstraints; // type constraints for template parameters MemberDef *templateMaster; - QList<ArgumentList> *defTmpArgLists; // lists of template argument lists + std::vector<ArgumentList> defTmpArgLists; // lists of template argument lists // (for template functions in nested template classes) QCString metaData; // Slice metadata. @@ -1422,11 +1421,6 @@ MemberDefImpl::IMPL::IMPL() : enumFields(0), redefinedBy(0), exampleSDict(0), - defArgList(0), - declArgList(0), - tArgList(0), - typeConstraints(0), - defTmpArgLists(0), classSectionSDict(0), category(0), categoryRelation(0), @@ -1441,19 +1435,14 @@ MemberDefImpl::IMPL::~IMPL() delete redefinedBy; delete exampleSDict; delete enumFields; - delete defArgList; - delete tArgList; - delete typeConstraints; - delete defTmpArgLists; delete classSectionSDict; - delete declArgList; } void MemberDefImpl::IMPL::init(Definition *def, const char *t,const char *a,const char *e, Protection p,Specifier v,bool s,Relationship r, - MemberType mt,const ArgumentList *tal, - const ArgumentList *al,const char *meta + MemberType mt,const ArgumentList &tal, + const ArgumentList &al,const char *meta ) { classDef=0; @@ -1471,7 +1460,6 @@ void MemberDefImpl::IMPL::init(Definition *def, enumFields=0; enumScope=0; livesInsideEnum=FALSE; - defTmpArgLists=0; hasCallGraph = FALSE; hasCallerGraph = FALSE; hasReferencedByRelation = FALSE; @@ -1508,36 +1496,17 @@ void MemberDefImpl::IMPL::init(Definition *def, userInitLines=-1; docEnumValues=FALSE; // copy function template arguments (if any) - if (tal) - { - tArgList = tal->deepCopy(); - } - else - { - tArgList=0; - } + tArgList = tal; //printf("new member al=%p\n",al); // copy function definition arguments (if any) - if (al) - { - defArgList = al->deepCopy(); - } - else - { - defArgList=0; - } + defArgList = al; // convert function declaration arguments (if any) if (!args.isEmpty()) { - declArgList = new ArgumentList; stringToArgumentList(args,declArgList,&extraTypeChars); //printf("setDeclArgList %s to %s const=%d\n",args.data(), // argListToString(declArgList).data(),declArgList->constSpecifier); } - else - { - declArgList = 0; - } metaData = meta; templateMaster = 0; classSectionSDict = 0; @@ -1584,7 +1553,7 @@ void MemberDefImpl::IMPL::init(Definition *def, MemberDefImpl::MemberDefImpl(const char *df,int dl,int dc, const char *t,const char *na,const char *a,const char *e, Protection p,Specifier v,bool s,Relationship r,MemberType mt, - const ArgumentList *tal,const ArgumentList *al,const char *meta + const ArgumentList &tal,const ArgumentList &al,const char *meta ) : DefinitionImpl(df,dl,dc,removeRedundantWhiteSpace(na)) { //printf("MemberDefImpl::MemberDef(%s)\n",na); @@ -1613,12 +1582,7 @@ MemberDef *MemberDefImpl::deepCopy() const result->m_impl->redefinedBy= 0; result->m_impl->exampleSDict=0; result->m_impl->enumFields=0; - result->m_impl->defArgList=0; - result->m_impl->tArgList=0; - result->m_impl->typeConstraints=0; - result->m_impl->defTmpArgLists=0; result->m_impl->classSectionSDict=0; - result->m_impl->declArgList=0; // replace pointers owned by the object by deep copies if (m_impl->redefinedBy) { @@ -1647,18 +1611,9 @@ MemberDef *MemberDefImpl::deepCopy() const result->insertEnumField(md); } } - if (m_impl->defArgList) - { - result->m_impl->defArgList = m_impl->defArgList->deepCopy(); - } - if (m_impl->tArgList) - { - result->m_impl->tArgList = m_impl->tArgList->deepCopy(); - } - if (m_impl->typeConstraints) - { - result->m_impl->typeConstraints = m_impl->typeConstraints->deepCopy(); - } + result->m_impl->defArgList = m_impl->defArgList; + result->m_impl->tArgList = m_impl->tArgList; + result->m_impl->typeConstraints = m_impl->typeConstraints; result->setDefinitionTemplateParameterLists(m_impl->defTmpArgLists); if (m_impl->classSectionSDict) { @@ -1670,10 +1625,7 @@ MemberDef *MemberDefImpl::deepCopy() const result->m_impl->classSectionSDict->append(it.currentKey(),ml); } } - if (m_impl->declArgList) - { - result->m_impl->declArgList = m_impl->declArgList->deepCopy(); - } + result->m_impl->declArgList = m_impl->declArgList; return result; } @@ -2033,13 +1985,9 @@ bool MemberDefImpl::isLinkable() const } -void MemberDefImpl::setDefinitionTemplateParameterLists(QList<ArgumentList> *lists) +void MemberDefImpl::setDefinitionTemplateParameterLists(const std::vector<ArgumentList> &lists) { - if (lists) - { - if (m_impl->defTmpArgLists) delete m_impl->defTmpArgLists; - m_impl->defTmpArgLists = copyArgumentLists(lists); - } + m_impl->defTmpArgLists = lists; } void MemberDefImpl::writeLink(OutputList &ol, @@ -2225,9 +2173,8 @@ bool MemberDefImpl::isBriefSectionVisible() const // hide default constructors or destructors (no args) without // documentation bool visibleIfNotDefaultCDTor = !(cOrDTor && - m_impl->defArgList && - (m_impl->defArgList->isEmpty() || - m_impl->defArgList->getFirst()->type == "void" + (m_impl->defArgList.empty() || + m_impl->defArgList.front().type == "void" ) && !hasDocs ); @@ -2313,7 +2260,7 @@ void MemberDefImpl::writeDeclaration(OutputList &ol, bool isAnonymous = annoClassDef || m_impl->annMemb || m_impl->annEnumType; ///printf("startMemberItem for %s\n",name().data()); ol.startMemberItem(anchor(), - isAnonymous ? 1 : m_impl->tArgList ? 3 : 0, + isAnonymous ? 1 : !m_impl->tArgList.empty() ? 3 : 0, inheritId ); @@ -2352,7 +2299,7 @@ void MemberDefImpl::writeDeclaration(OutputList &ol, } // *** write template lists - if (m_impl->tArgList && getLanguage()==SrcLangExt_Cpp) + if (m_impl->tArgList.hasParameters() && getLanguage()==SrcLangExt_Cpp) { if (!isAnonymous) ol.startMemberTemplateParams(); writeTemplatePrefix(ol,m_impl->tArgList); @@ -2474,7 +2421,7 @@ void MemberDefImpl::writeDeclaration(OutputList &ol, } else { - ol.insertMemberAlign(m_impl->tArgList!=0); + ol.insertMemberAlign(m_impl->tArgList.hasParameters()); } // *** write name @@ -2754,7 +2701,7 @@ bool MemberDefImpl::isDetailedSectionLinkable() const //(initLines>0 && initLines<maxInitLines) || (hasMultiLineInitializer() && !hideUndocMembers) || // has one or more documented arguments - (m_impl->defArgList!=0 && m_impl->defArgList->hasDocumentation()) || + (m_impl->defArgList.hasDocumentation()) || // is an attribute or property - need to display that tag (m_impl->memSpec & (Entry::Attribute|Entry::Property)) || // has user comments @@ -3169,7 +3116,7 @@ void MemberDefImpl::_writeExamples(OutputList &ol) const void MemberDefImpl::_writeTypeConstraints(OutputList &ol) const { - if (m_impl->typeConstraints) + if (m_impl->typeConstraints.hasParameters()) { writeTypeConstraints(ol,this,m_impl->typeConstraints); } @@ -3460,7 +3407,7 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, ldef=ldef.mid(2); } } - else if (isFunction()) + else if (isFunction() && !isObjCMethod()) { title += "()"; } @@ -3546,14 +3493,12 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, { bool first=TRUE; SrcLangExt lang = getLanguage(); - if (m_impl->defTmpArgLists && lang==SrcLangExt_Cpp) + if (!m_impl->defTmpArgLists.empty() && lang==SrcLangExt_Cpp) // definition has explicit template parameter declarations { - QListIterator<ArgumentList> ali(*m_impl->defTmpArgLists); - ArgumentList *tal; - for (ali.toFirst();(tal=ali.current());++ali) + for (const ArgumentList &tal : m_impl->defTmpArgLists) { - if (tal->count()>0) + if (!tal.empty()) { if (!first) ol.docify(" "); ol.startMemberDocPrefixItem(); @@ -3567,14 +3512,9 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, { if (cd && lang==SrcLangExt_Cpp && !isTemplateSpecialization()) { - QList<ArgumentList> tempParamLists; - cd->getTemplateParameterLists(tempParamLists); - //printf("#tempParamLists=%d\n",tempParamLists.count()); - QListIterator<ArgumentList> ali(tempParamLists); - ArgumentList *tal; - for (ali.toFirst();(tal=ali.current());++ali) + for (const ArgumentList &tal : cd->getTemplateParameterLists()) { - if (tal->count()>0) + if (!tal.empty()) { if (!first) ol.docify(" "); ol.startMemberDocPrefixItem(); @@ -3583,7 +3523,7 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, } } } - if (m_impl->tArgList && lang==SrcLangExt_Cpp) // function template prefix + if (m_impl->tArgList.hasParameters() && lang==SrcLangExt_Cpp) // function template prefix { ol.startMemberDocPrefixItem(); writeTemplatePrefix(ol,m_impl->tArgList); @@ -3775,7 +3715,7 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, QCString brief = briefDescription(); QCString detailed = documentation(); - ArgumentList *docArgList = m_impl->defArgList; + ArgumentList &docArgList = m_impl->defArgList; if (m_impl->templateMaster) { brief = m_impl->templateMaster->briefDescription(); @@ -3832,18 +3772,16 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, //printf("***** defArgList=%p name=%s docs=%s hasDocs=%d\n", // defArgList, // defArgList?defArgList->hasDocumentation():-1); - if (docArgList!=0 && docArgList->hasDocumentation()) + if (docArgList.hasDocumentation()) { QCString paramDocs; - ArgumentListIterator ali(*docArgList); - Argument *a; - // convert the parameter documentation into a list of @param commands - for (ali.toFirst();(a=ali.current());++ali) + for (const Argument &a : docArgList) { - if (a->hasDocumentation()) + if (a.hasDocumentation()) { - QCString direction = extractDirection(a->docs); - paramDocs+="@param"+direction+" "+a->name+" "+a->docs; + QCString docsWithoutDir = a.docs; + QCString direction = extractDirection(docsWithoutDir); + paramDocs+="@param"+direction+" "+a.name+" "+a.docs; } } // feed the result to the documentation parser @@ -4146,41 +4084,37 @@ void MemberDefImpl::detectUndocumentedParams(bool hasParamCommand,bool hasReturn } else if (!m_impl->hasDocumentedParams) { - const ArgumentList *al = argumentList(); - const ArgumentList *declAl = declArgumentList(); + const ArgumentList &al = argumentList(); + const ArgumentList &declAl = declArgumentList(); bool allDoc=TRUE; // no parameter => all parameters are documented if ( // member has parameters - al!=0 && // but the member has a parameter list - al->count()>0 // with at least one parameter (that is not void) + al.hasParameters() // with at least one parameter (that is not void) ) { - ArgumentListIterator ali(*al); - Argument *a; - // see if all parameters have documentation - for (ali.toFirst();(a=ali.current()) && allDoc;++ali) + for (auto it = al.begin(); it!=al.end() && allDoc; ++it) { - if (!a->name.isEmpty() && a->type!="void" && - !(isPython && (a->name=="self" || a->name=="cls")) + Argument a = *it; + if (!a.name.isEmpty() && a.type!="void" && + !(isPython && (a.name=="self" || a.name=="cls")) ) { - allDoc = !a->docs.isEmpty(); + allDoc = !a.docs.isEmpty(); } //printf("a->type=%s a->name=%s doc=%s\n", // a->type.data(),a->name.data(),a->docs.data()); } - if (!allDoc && declAl!=0) // try declaration arguments as well + if (!allDoc && declAl.empty()) // try declaration arguments as well { allDoc=TRUE; - ArgumentListIterator ali(*declAl); - Argument *a; - for (ali.toFirst();(a=ali.current()) && allDoc;++ali) + for (auto it = al.begin(); it!=al.end() && allDoc; ++it) { - if (!a->name.isEmpty() && a->type!="void" && - !(isPython && (a->name=="self" || a->name=="cls")) + Argument a = *it; + if (!a.name.isEmpty() && a.type!="void" && + !(isPython && (a.name=="self" || a.name=="cls")) ) { - allDoc = !a->docs.isEmpty(); + allDoc = !a.docs.isEmpty(); } //printf("a->name=%s doc=%s\n",a->name.data(),a->docs.data()); } @@ -4269,14 +4203,14 @@ bool MemberDefImpl::isDocumentedFriendClass() const bool MemberDefImpl::isDeleted() const { - return m_impl->defArgList && m_impl->defArgList->isDeleted; + return m_impl->defArgList.isDeleted; } bool MemberDefImpl::hasDocumentation() const { return DefinitionImpl::hasDocumentation() || (m_impl->mtype==MemberType_Enumeration && m_impl->docEnumValues) || // has enum values - (m_impl->defArgList!=0 && m_impl->defArgList->hasDocumentation()); // has doc arguments + (m_impl->defArgList.hasDocumentation()); // has doc arguments } #if 0 @@ -4344,10 +4278,10 @@ void MemberDefImpl::setAnchor() // include number of template arguments as well, // to distinguish between two template // specializations that only differ in the template parameters. - if (m_impl->tArgList) + if (m_impl->tArgList.hasParameters()) { char buf[20]; - qsnprintf(buf,20,"%d:",m_impl->tArgList->count()); + qsnprintf(buf,20,"%d:",(int)m_impl->tArgList.size()); buf[19]='\0'; memAnchor.prepend(buf); } @@ -4356,7 +4290,6 @@ void MemberDefImpl::setAnchor() uchar md5_sig[16]; QCString sigStr(33); MD5Buffer((const unsigned char *)memAnchor.data(),memAnchor.length(),md5_sig); - //printf("memAnchor=%s\n",memAnchor.data()); MD5SigToString(md5_sig,sigStr.rawData(),33); m_impl->anc = "a"+sigStr; } @@ -4405,23 +4338,21 @@ void MemberDefImpl::setNamespace(NamespaceDef *nd) } MemberDef *MemberDefImpl::createTemplateInstanceMember( - ArgumentList *formalArgs,ArgumentList *actualArgs) const + const ArgumentList &formalArgs,const ArgumentList &actualArgs) const { //printf(" Member %s %s %s\n",typeString(),name().data(),argsString()); - ArgumentList *actualArgList = 0; - if (m_impl->defArgList) + ArgumentList actualArgList; + if (!m_impl->defArgList.empty()) { - actualArgList = m_impl->defArgList->deepCopy(); + actualArgList = m_impl->defArgList; // replace formal arguments with actuals - ArgumentListIterator ali(*actualArgList); - Argument *arg; - for (;(arg=ali.current());++ali) + for (Argument &arg : actualArgList) { - arg->type = substituteTemplateArgumentsInString(arg->type,formalArgs,actualArgs); + arg.type = substituteTemplateArgumentsInString(arg.type,formalArgs,actualArgs); } - actualArgList->trailingReturnType = - substituteTemplateArgumentsInString(actualArgList->trailingReturnType,formalArgs,actualArgs); + actualArgList.trailingReturnType = + substituteTemplateArgumentsInString(actualArgList.trailingReturnType,formalArgs,actualArgs); } QCString methodName=name(); @@ -4436,7 +4367,8 @@ MemberDef *MemberDefImpl::createTemplateInstanceMember( methodName, substituteTemplateArgumentsInString(m_impl->args,formalArgs,actualArgs), m_impl->exception, m_impl->prot, - m_impl->virt, m_impl->stat, m_impl->related, m_impl->mtype, 0, 0, "" + m_impl->virt, m_impl->stat, m_impl->related, m_impl->mtype, + ArgumentList(), ArgumentList(), "" ); imd->setArgumentList(actualArgList); imd->setDefinition(substituteTemplateArgumentsInString(m_impl->def,formalArgs,actualArgs)); @@ -4528,14 +4460,11 @@ void MemberDefImpl::addListReference(Definition *) memArgs = argsString(); } } - QList<ListItemInfo> *xrefItems = xrefListItems(); - if (xrefItems) - { - addRefItem(xrefItems, + const std::vector<ListItemInfo> &xrefItems = xrefListItems(); + addRefItem(xrefItems, qualifiedName()+argsString(), // argsString is needed for overloaded functions (see bug 609624) memLabel, getOutputFileBase()+"#"+anchor(),memName,memArgs,pd); - } } const MemberList *MemberDefImpl::getSectionList() const @@ -4879,30 +4808,19 @@ void MemberDefImpl::writeEnumDeclaration(OutputList &typeDecl, } } -void MemberDefImpl::setArgumentList(ArgumentList *al) +void MemberDefImpl::setArgumentList(const ArgumentList &al) { - if (m_impl->defArgList) delete m_impl->defArgList; m_impl->defArgList = al; } -void MemberDefImpl::setDeclArgumentList(ArgumentList *al) +void MemberDefImpl::setDeclArgumentList(const ArgumentList &al) { - if (m_impl->declArgList) delete m_impl->declArgList; m_impl->declArgList = al; } -void MemberDefImpl::setTypeConstraints(ArgumentList *al) +void MemberDefImpl::setTypeConstraints(const ArgumentList &al) { - if (al==0) return; - if (m_impl->typeConstraints) delete m_impl->typeConstraints; - m_impl->typeConstraints = new ArgumentList; - m_impl->typeConstraints->setAutoDelete(TRUE); - ArgumentListIterator ali(*al); - Argument *a; - for (;(a=ali.current());++ali) - { - m_impl->typeConstraints->append(new Argument(*a)); - } + m_impl->typeConstraints = al; } void MemberDefImpl::setType(const char *t) @@ -5007,7 +4925,7 @@ QCString MemberDefImpl::qualifiedName() const } } -void MemberDefImpl::setTagInfo(TagInfo *ti) +void MemberDefImpl::setTagInfo(const TagInfo *ti) { if (ti) { @@ -5557,27 +5475,27 @@ bool MemberDefImpl::isPrototype() const return m_impl->proto; } -const ArgumentList *MemberDefImpl::argumentList() const +const ArgumentList &MemberDefImpl::argumentList() const { return m_impl->defArgList; } -ArgumentList *MemberDefImpl::argumentList() +ArgumentList &MemberDefImpl::argumentList() { return m_impl->defArgList; } -const ArgumentList *MemberDefImpl::declArgumentList() const +const ArgumentList &MemberDefImpl::declArgumentList() const { return m_impl->declArgList; } -const ArgumentList *MemberDefImpl::templateArguments() const +const ArgumentList &MemberDefImpl::templateArguments() const { return m_impl->tArgList; } -const QList<ArgumentList> *MemberDefImpl::definitionTemplateParameterLists() const +const std::vector<ArgumentList> &MemberDefImpl::definitionTemplateParameterLists() const { return m_impl->defTmpArgLists; } @@ -5931,47 +5849,44 @@ void MemberDefImpl::cacheTypedefVal(const ClassDef*val, const QCString & templSp void MemberDefImpl::copyArgumentNames(MemberDef *bmd) { { - const ArgumentList *arguments = bmd->argumentList(); - if (m_impl->defArgList && arguments) + const ArgumentList &srcAl = bmd->argumentList(); + ArgumentList &dstAl = m_impl->defArgList; + auto srcIt = srcAl.begin(); + auto dstIt = dstAl.begin(); + while ( srcIt!=srcAl.end() && dstIt!=dstAl.end()) { - ArgumentListIterator aliDst(*m_impl->defArgList); - ArgumentListIterator aliSrc(*arguments); - Argument *argDst; - const Argument *argSrc; - for (;(argDst=aliDst.current()) && (argSrc=aliSrc.current());++aliDst,++aliSrc) - { - argDst->name = argSrc->name; - argDst->docs = argSrc->docs; - } + Argument &argDst = *dstIt; + const Argument &argSrc = *srcIt; + argDst.name = argSrc.name; + argDst.docs = argSrc.docs; + ++srcIt; + ++dstIt; } } + { - const ArgumentList *arguments = bmd->declArgumentList(); - if (m_impl->declArgList && arguments) + const ArgumentList &srcAl = bmd->declArgumentList(); + ArgumentList &dstAl = m_impl->declArgList; + auto srcIt = srcAl.begin(); + auto dstIt = dstAl.begin(); + + while ( srcIt!=srcAl.end() && dstIt!=dstAl.end()) { - ArgumentListIterator aliDst(*m_impl->declArgList); - ArgumentListIterator aliSrc(*arguments); - Argument *argDst; - const Argument *argSrc; - for (;(argDst=aliDst.current()) && (argSrc=aliSrc.current());++aliDst,++aliSrc) - { - argDst->name = argSrc->name; - argDst->docs = argSrc->docs; - } + Argument &argDst = *dstIt; + const Argument &argSrc = *srcIt; + argDst.name = argSrc.name; + argDst.docs = argSrc.docs; + ++srcIt; + ++dstIt; } } } -static void invalidateCachedTypesInArgumentList(ArgumentList *al) +static void invalidateCachedTypesInArgumentList(ArgumentList &al) { - if (al) + for (Argument &a : al) { - ArgumentListIterator ali(*al); - Argument *a; - for (ali.toFirst();(a=ali.current());++ali) - { - a->canType.resize(0); - } + a.canType.resize(0); } } @@ -6025,49 +5940,41 @@ void MemberDefImpl::addToSearchIndex() const //---------------- -static void transferArgumentDocumentation(ArgumentList *decAl,ArgumentList *defAl) +static void transferArgumentDocumentation(ArgumentList &decAl,ArgumentList &defAl) { - if (decAl && defAl) + for (auto decIt = decAl.begin(), defIt = defAl.begin(); + decIt!= decAl.end() && defIt!= defAl.end(); + ++decIt, ++defIt) { - ArgumentListIterator decAli(*decAl); - ArgumentListIterator defAli(*defAl); - Argument *decA,*defA; - for (decAli.toFirst(),defAli.toFirst(); - (decA=decAli.current()) && (defA=defAli.current()); - ++decAli,++defAli) + Argument decA = *decIt; + Argument defA = *defIt; + if (decA.docs.isEmpty() && !defA.docs.isEmpty()) { - //printf("Argument decA->name=%s (doc=%s) defA->name=%s (doc=%s)\n", - // decA->name.data(),decA->docs.data(), - // defA->name.data(),defA->docs.data() - // ); - if (decA->docs.isEmpty() && !defA->docs.isEmpty()) - { - decA->docs = defA->docs.copy(); - } - else if (defA->docs.isEmpty() && !decA->docs.isEmpty()) - { - defA->docs = decA->docs.copy(); - } + decA.docs = defA.docs; + } + else if (defA.docs.isEmpty() && !decA.docs.isEmpty()) + { + defA.docs = decA.docs; } } } void combineDeclarationAndDefinition(MemberDef *mdec,MemberDef *mdef) { - //printf("mdec=%s isPrototype()=%d\n",mdec->name().data(),mdec->isPrototype()); + printf("mdec=%s isPrototype()=%d\n",mdec->name().data(),mdec->isPrototype()); if ( (mdef->isFunction() && !mdef->isStatic() && !mdef->isPrototype()) || (mdef->isVariable() && !mdef->isExternal() && !mdef->isStatic()) ) { - //printf("mdef=(%p,%s) mdec=(%p,%s)\n", - // mdef, mdef ? mdef->name().data() : "", - // mdec, mdec ? mdec->name().data() : ""); + printf("mdef=(%p,%s) mdec=(%p,%s)\n", + mdef, mdef ? mdef->name().data() : "", + mdec, mdec ? mdec->name().data() : ""); const MemberDef *cmdec = const_cast<const MemberDef*>(mdec); const MemberDef *cmdef = const_cast<const MemberDef*>(mdef); - ArgumentList *mdefAl = mdef->argumentList(); - ArgumentList *mdecAl = mdec->argumentList(); + ArgumentList &mdefAl = mdef->argumentList(); + ArgumentList &mdecAl = mdec->argumentList(); if (matchArguments2(cmdef->getOuterScope(),cmdef->getFileDef(),mdefAl, cmdec->getOuterScope(),cmdec->getFileDef(),mdecAl, TRUE @@ -6097,9 +6004,9 @@ void combineDeclarationAndDefinition(MemberDef *mdec,MemberDef *mdef) //printf("transferring docs mdef->mdec (%s->%s)\n",mdef->argsString(),mdec->argsString()); mdec->setDocumentation(mdef->documentation(),mdef->docFile(),mdef->docLine()); mdec->setDocsForDefinition(mdef->isDocsForDefinition()); - if (mdefAl!=0) + if (mdefAl.hasParameters()) { - ArgumentList *mdefAlComb = new ArgumentList; + ArgumentList mdefAlComb; stringToArgumentList(mdef->argsString(),mdefAlComb); transferArgumentDocumentation(mdefAl,mdefAlComb); mdec->setArgumentList(mdefAlComb); @@ -6110,9 +6017,9 @@ void combineDeclarationAndDefinition(MemberDef *mdec,MemberDef *mdef) //printf("transferring docs mdec->mdef (%s->%s)\n",mdec->argsString(),mdef->argsString()); mdef->setDocumentation(mdec->documentation(),mdec->docFile(),mdec->docLine()); mdef->setDocsForDefinition(mdec->isDocsForDefinition()); - if (mdecAl!=0) + if (mdecAl.hasParameters()) { - ArgumentList *mdecAlComb = new ArgumentList; + ArgumentList mdecAlComb; stringToArgumentList(mdec->argsString(),mdecAlComb); transferArgumentDocumentation(mdecAl,mdecAlComb); mdef->setDeclArgumentList(mdecAlComb); @@ -6210,7 +6117,7 @@ QCString MemberDefImpl::documentation() const } } -const ArgumentList *MemberDefImpl::typeConstraints() const +const ArgumentList &MemberDefImpl::typeConstraints() const { return m_impl->typeConstraints; } diff --git a/src/memberdef.h b/src/memberdef.h index b200833..a9103e1 100644 --- a/src/memberdef.h +++ b/src/memberdef.h @@ -18,6 +18,8 @@ #ifndef MEMBERDEF_H #define MEMBERDEF_H +#include <vector> + #include <qlist.h> #include <sys/types.h> @@ -221,11 +223,11 @@ class MemberDef : virtual public Definition virtual bool isPrototype() const = 0; // argument related members - virtual const ArgumentList *argumentList() const = 0; - virtual ArgumentList *argumentList() = 0; - virtual const ArgumentList *declArgumentList() const = 0; - virtual const ArgumentList *templateArguments() const = 0; - virtual const QList<ArgumentList> *definitionTemplateParameterLists() const = 0; + virtual const ArgumentList &argumentList() const = 0; + virtual ArgumentList &argumentList() = 0; + virtual const ArgumentList &declArgumentList() const = 0; + virtual const ArgumentList &templateArguments() const = 0; + virtual const std::vector<ArgumentList> &definitionTemplateParameterLists() const = 0; // member group related members virtual int getMemberGroupId() const = 0; @@ -239,7 +241,7 @@ class MemberDef : virtual public Definition virtual bool hasCallGraph() const = 0; virtual bool hasCallerGraph() const = 0; virtual bool visibleMemberGroup(bool hideNoHeader) const = 0; - // refrenced related members + // referenced related members virtual bool hasReferencesRelation() const = 0; virtual bool hasReferencedByRelation() const = 0; @@ -265,7 +267,7 @@ class MemberDef : virtual public Definition virtual QCString getDeclType() const = 0; virtual void getLabels(QStrList &sl,const Definition *container) const = 0; - virtual const ArgumentList *typeConstraints() const = 0; + virtual const ArgumentList &typeConstraints() const = 0; // overrules virtual QCString documentation() const = 0; @@ -305,7 +307,7 @@ class MemberDef : virtual public Definition virtual void makeRelated() = 0; virtual void makeForeign() = 0; virtual void setInheritsDocsFrom(MemberDef *md) = 0; - virtual void setTagInfo(TagInfo *i) = 0; + virtual void setTagInfo(const TagInfo *i) = 0; virtual void setArgsString(const char *as) = 0; virtual void incrementFlowKeyWordCount() = 0; @@ -331,10 +333,10 @@ class MemberDef : virtual public Definition virtual void setDeclFile(const QCString &df,int line,int column) = 0; // argument related members - virtual void setArgumentList(ArgumentList *al) = 0; - virtual void setDeclArgumentList(ArgumentList *al) = 0; - virtual void setDefinitionTemplateParameterLists(QList<ArgumentList> *lists) = 0; - virtual void setTypeConstraints(ArgumentList *al) = 0; + virtual void setArgumentList(const ArgumentList &al) = 0; + virtual void setDeclArgumentList(const ArgumentList &al) = 0; + virtual void setDefinitionTemplateParameterLists(const std::vector<ArgumentList> &lists) = 0; + virtual void setTypeConstraints(const ArgumentList &al) = 0; virtual void setType(const char *t) = 0; virtual void setAccessorType(ClassDef *cd,const char *t) = 0; @@ -384,8 +386,8 @@ class MemberDef : virtual public Definition // --- actions ---- //----------------------------------------------------------------------------------- - virtual MemberDef *createTemplateInstanceMember(ArgumentList *formalArgs, - ArgumentList *actualArgs) const = 0; + virtual MemberDef *createTemplateInstanceMember(const ArgumentList &formalArgs, + const ArgumentList &actualArgs) const = 0; virtual void findSectionsInDocumentation() = 0; virtual void addToSearchIndex() const = 0; @@ -421,8 +423,8 @@ class MemberDef : virtual public Definition MemberDef *createMemberDef(const char *defFileName,int defLine,int defColumn, const char *type,const char *name,const char *args, const char *excp,Protection prot,Specifier virt,bool stat, - Relationship related,MemberType t,const ArgumentList *tal, - const ArgumentList *al,const char *metaData); + Relationship related,MemberType t,const ArgumentList &tal, + const ArgumentList &al,const char *metaData); MemberDef *createMemberDefAlias(const Definition *newScope,const MemberDef *aliasMd); diff --git a/src/membergroup.cpp b/src/membergroup.cpp index c127302..da52d64 100644 --- a/src/membergroup.cpp +++ b/src/membergroup.cpp @@ -56,7 +56,6 @@ MemberGroup::MemberGroup(int id,const char *hdr,const char *d,const char *docFil m_numDocMembers = -1; m_docFile = docFile; m_docLine = docLine; - m_xrefListItems = 0; //printf("Member group docs='%s'\n",doc.data()); } @@ -340,7 +339,7 @@ QCString MemberGroup::anchor() const void MemberGroup::addListReferences(Definition *def) { memberList->addListReferences(def); - if (m_xrefListItems && def) + if (def) { QCString name = def->getOutputFileBase()+"#"+anchor(); addRefItem(m_xrefListItems, @@ -357,23 +356,9 @@ void MemberGroup::findSectionsInDocumentation(const Definition *d) memberList->findSectionsInDocumentation(d); } -void MemberGroup::setRefItems(const QList<ListItemInfo> *sli) +void MemberGroup::setRefItems(const std::vector<ListItemInfo> &sli) { - if (sli) - { - // deep copy the list - if (m_xrefListItems==0) - { - m_xrefListItems=new QList<ListItemInfo>; - m_xrefListItems->setAutoDelete(TRUE); - } - QListIterator<ListItemInfo> slii(*sli); - ListItemInfo *lii; - for (slii.toFirst();(lii=slii.current());++slii) - { - m_xrefListItems->append(new ListItemInfo(*lii)); - } - } + m_xrefListItems = sli; } void MemberGroup::writeTagFile(FTextStream &tagFile) @@ -383,18 +368,7 @@ void MemberGroup::writeTagFile(FTextStream &tagFile) //-------------------------------------------------------------------------- -void MemberGroupInfo::setRefItems(const QList<ListItemInfo> *sli) +void MemberGroupInfo::setRefItems(const std::vector<ListItemInfo> &sli) { - if (!sli) return; - if (m_sli==0) - { - m_sli = new QList<ListItemInfo>; - m_sli->setAutoDelete(TRUE); - } - QListIterator<ListItemInfo> slii(*sli); - ListItemInfo *ili; - for (slii.toFirst();(ili=slii.current());++slii) - { - m_sli->append(new ListItemInfo(*ili)); - } + m_sli = sli; } diff --git a/src/membergroup.h b/src/membergroup.h index c332b56..0fda3d7 100644 --- a/src/membergroup.h +++ b/src/membergroup.h @@ -18,6 +18,8 @@ #ifndef MEMBERGROUP_H #define MEMBERGROUP_H +#include <vector> + #include <qlist.h> #include "sortdict.h" #include "types.h" @@ -32,7 +34,6 @@ class FileDef; class GroupDef; class OutputList; class Definition; -class StorageIntf; class FTextStream; struct ListItemInfo; @@ -80,7 +81,7 @@ class MemberGroup int countInheritableMembers(const ClassDef *inheritedFrom) const; void setInGroup(bool b); void addListReferences(Definition *d); - void setRefItems(const QList<ListItemInfo> *sli); + void setRefItems(const std::vector<ListItemInfo> &sli); MemberList *members() const { return memberList; } QCString anchor() const; @@ -100,7 +101,7 @@ class MemberGroup const Definition *m_parent; QCString m_docFile; int m_docLine; - QList<ListItemInfo> *m_xrefListItems; + std::vector<ListItemInfo> m_xrefListItems; }; /** A list of MemberGroup objects. */ @@ -132,15 +133,13 @@ class MemberGroupSDict : public SIntDict<MemberGroup> /** Data collected for a member group */ struct MemberGroupInfo { - MemberGroupInfo() : docLine(-1), m_sli(0) {} - ~MemberGroupInfo() { delete m_sli; m_sli=0; } - void setRefItems(const QList<ListItemInfo> *sli); + void setRefItems(const std::vector<ListItemInfo> &sli); QCString header; QCString doc; QCString docFile; - int docLine; + int docLine = -1; QCString compoundName; - QList<ListItemInfo> *m_sli; + std::vector<ListItemInfo> m_sli; }; #endif diff --git a/src/memberlist.h b/src/memberlist.h index 0697df4..422c162 100644 --- a/src/memberlist.h +++ b/src/memberlist.h @@ -26,7 +26,6 @@ class GroupDef; class MemberGroup; class MemberGroupList; -class StorageIntf; /** A list of MemberDef objects. */ class MemberList : private QList<MemberDef> diff --git a/src/namespacedef.cpp b/src/namespacedef.cpp index 9a98e0d..fa258a0 100644 --- a/src/namespacedef.cpp +++ b/src/namespacedef.cpp @@ -1269,7 +1269,7 @@ void NamespaceDefImpl::addListReferences() { //bool fortranOpt = Config_getBool(OPTIMIZE_FOR_FORTRAN); { - QList<ListItemInfo> *xrefItems = xrefListItems(); + const std::vector<ListItemInfo> &xrefItems = xrefListItems(); addRefItem(xrefItems, qualifiedName(), getLanguage()==SrcLangExt_Fortran ? diff --git a/src/parserintf.h b/src/parserintf.h index f03aac7..a269bfb 100644 --- a/src/parserintf.h +++ b/src/parserintf.h @@ -21,6 +21,8 @@ #include <qdict.h> #include <qstrlist.h> +#include <memory> + #include "types.h" class Entry; @@ -67,7 +69,7 @@ class ParserInterface */ virtual void parseInput(const char *fileName, const char *fileBuf, - Entry *root, + const std::unique_ptr<Entry> &root, bool sameTranslationUnit, QStrList &filesInSameTranslationUnit) = 0; diff --git a/src/perlmodgen.cpp b/src/perlmodgen.cpp index a288e0e..c8f9273 100644 --- a/src/perlmodgen.cpp +++ b/src/perlmodgen.cpp @@ -1422,23 +1422,20 @@ void PerlModDocVisitor::visitPost(DocParBlock *) } -static void addTemplateArgumentList(ArgumentList *al,PerlModOutput &output,const char *) +static void addTemplateArgumentList(const ArgumentList &al,PerlModOutput &output,const char *) { - if (!al) - return; + if (!al.hasParameters()) return; output.openList("template_parameters"); - ArgumentListIterator ali(*al); - Argument *a; - for (ali.toFirst();(a=ali.current());++ali) + for (const Argument &a : al) { output.openHash(); - if (!a->type.isEmpty()) - output.addFieldQuotedString("type", a->type); - if (!a->name.isEmpty()) - output.addFieldQuotedString("declaration_name", a->name) - .addFieldQuotedString("definition_name", a->name); - if (!a->defval.isEmpty()) - output.addFieldQuotedString("default", a->defval); + if (!a.type.isEmpty()) + output.addFieldQuotedString("type", a.type); + if (!a.name.isEmpty()) + output.addFieldQuotedString("declaration_name", a.name) + .addFieldQuotedString("definition_name", a.name); + if (!a.defval.isEmpty()) + output.addFieldQuotedString("default", a.defval); output.closeHash(); } output.closeList(); @@ -1609,45 +1606,46 @@ void PerlModGenerator::generatePerlModForMember(const MemberDef *md,const Defini md->memberType()!=MemberType_Enumeration) m_output.addFieldQuotedString("type", md->typeString()); - const ArgumentList *al = md->argumentList(); + const ArgumentList &al = md->argumentList(); if (isFunc) //function { - m_output.addFieldBoolean("const", al!=0 && al->constSpecifier) - .addFieldBoolean("volatile", al!=0 && al->volatileSpecifier); + m_output.addFieldBoolean("const", al.constSpecifier) + .addFieldBoolean("volatile", al.volatileSpecifier); m_output.openList("parameters"); - const ArgumentList *declAl = md->declArgumentList(); - const ArgumentList *defAl = md->argumentList(); - if (declAl && defAl && declAl->count()>0) + const ArgumentList &declAl = md->declArgumentList(); + if (!declAl.empty()) { - ArgumentListIterator declAli(*declAl); - ArgumentListIterator defAli(*defAl); - const Argument *a; - for (declAli.toFirst();(a=declAli.current());++declAli) + auto defIt = al.begin(); + for (const Argument &a : declAl) { - const Argument *defArg = defAli.current(); + const Argument *defArg = 0; + if (defIt!=al.end()) + { + defArg = &(*defIt); + ++defIt; + } m_output.openHash(); - if (!a->name.isEmpty()) - m_output.addFieldQuotedString("declaration_name", a->name); + if (!a.name.isEmpty()) + m_output.addFieldQuotedString("declaration_name", a.name); - if (defArg && !defArg->name.isEmpty() && defArg->name!=a->name) + if (defArg && !defArg->name.isEmpty() && defArg->name!=a.name) m_output.addFieldQuotedString("definition_name", defArg->name); - if (!a->type.isEmpty()) - m_output.addFieldQuotedString("type", a->type); + if (!a.type.isEmpty()) + m_output.addFieldQuotedString("type", a.type); - if (!a->array.isEmpty()) - m_output.addFieldQuotedString("array", a->array); + if (!a.array.isEmpty()) + m_output.addFieldQuotedString("array", a.array); - if (!a->defval.isEmpty()) - m_output.addFieldQuotedString("default_value", a->defval); + if (!a.defval.isEmpty()) + m_output.addFieldQuotedString("default_value", a.defval); - if (!a->attrib.isEmpty()) - m_output.addFieldQuotedString("attributes", a->attrib); + if (!a.attrib.isEmpty()) + m_output.addFieldQuotedString("attributes", a.attrib); m_output.closeHash(); - if (defArg) ++defAli; } } m_output.closeList(); @@ -1656,12 +1654,10 @@ void PerlModGenerator::generatePerlModForMember(const MemberDef *md,const Defini md->argsString()!=0) // define { m_output.openList("parameters"); - ArgumentListIterator ali(*al); - const Argument *a; - for (ali.toFirst();(a=ali.current());++ali) + for (const Argument &a : al) { m_output.openHash() - .addFieldQuotedString("name", a->type) + .addFieldQuotedString("name", a.type) .closeHash(); } m_output.closeList(); diff --git a/src/portable.cpp b/src/portable.cpp index 3d64638..c6e829d 100644 --- a/src/portable.cpp +++ b/src/portable.cpp @@ -457,7 +457,7 @@ bool portable_isAbsolutePath(const char *fileName) /** * Correct a possible wrong PATH variable * - * This routine was inspired by the cause for bug 766059 was that in the Windows path there were forward slahes. + * This routine was inspired by the cause for bug 766059 was that in the Windows path there were forward slashes. */ void portable_correct_path(void) { @@ -1444,10 +1444,10 @@ void addDefine() MemberDef *md=createMemberDef( g_yyFileName,g_yyLineNr-g_yyMLines,g_yyColNr, "#define",g_defName,g_defArgsStr,0, - Public,Normal,FALSE,Member,MemberType_Define,0,0,""); + Public,Normal,FALSE,Member,MemberType_Define,ArgumentList(),ArgumentList(),""); if (!g_defArgsStr.isEmpty()) { - ArgumentList *argList = new ArgumentList; + ArgumentList argList; //printf("addDefine() g_defName='%s' g_defArgsStr='%s'\n",g_defName.data(),g_defArgsStr.data()); stringToArgumentList(g_defArgsStr,argList); md->setArgumentList(argList); diff --git a/src/pycode.l b/src/pycode.l index a76129d..8cae0e2 100644 --- a/src/pycode.l +++ b/src/pycode.l @@ -1316,7 +1316,7 @@ TARGET ({IDENTIFIER}|"("{TARGET_LIST}")"|"["{TARGET_LIST}"]"|{ATTRIBUT \\{B}\n { // line continuation codifyLines(yytext); } - \\. { // espaced char + \\. { // escaped char codify(yytext); } {STRINGPREFIX}?{TRIDOUBLEQUOTE} { // triple double quotes @@ -1339,7 +1339,7 @@ TARGET ({IDENTIFIER}|"("{TARGET_LIST}")"|"["{TARGET_LIST}"]"|{ATTRIBUT \\{B}\n { // line continuation codifyLines(yytext); } - \\. { // espaced char + \\. { // escaped char codify(yytext); } {STRINGPREFIX}?{TRISINGLEQUOTE} { // triple single quotes diff --git a/src/pyscanner.h b/src/pyscanner.h index 01235ee..13b10b9 100644 --- a/src/pyscanner.h +++ b/src/pyscanner.h @@ -39,7 +39,7 @@ class PythonLanguageScanner : public ParserInterface void finishTranslationUnit() {} void parseInput(const char * fileName, const char *fileBuf, - Entry *root, + const std::unique_ptr<Entry> &root, bool sameTranslationUnit, QStrList &filesInSameTranslationUnit); bool needsPreprocessing(const QCString &extension); diff --git a/src/pyscanner.l b/src/pyscanner.l index 2320bca..829980c 100644 --- a/src/pyscanner.l +++ b/src/pyscanner.l @@ -73,7 +73,7 @@ static QFile inputFile; static Protection protection; static Entry* current_root = 0 ; -static Entry* current = 0 ; +static std::unique_ptr<Entry> current; static Entry* previous = 0 ; static Entry* bodyEntry = 0 ; static int yyLineNr = 1 ; @@ -145,16 +145,14 @@ static void initEntry() current->virt = virt; current->stat = gstat; current->lang = SrcLangExt_Python; - current->setParent(current_root); - Doxygen::docGroup.initGroupInfo(current); + Doxygen::docGroup.initGroupInfo(current.get()); gstat = FALSE; } static void newEntry() { - previous = current; - current_root->addSubEntry(current); - current = new Entry ; + previous = current.get(); + current_root->moveToSubEntryAndRefresh(current); initEntry(); } @@ -240,8 +238,7 @@ static void addFrom(bool all) current->fileName = yyFileName; //printf("Adding using declaration: found:%s:%d name=%s\n",yyFileName.data(),yyLineNr,current->name.data()); current->section=all ? Entry::USINGDIR_SEC : Entry::USINGDECL_SEC; - current_root->addSubEntry(current); - current = new Entry ; + current_root->moveToSubEntryAndRefresh(current); initEntry(); } //----------------------------------------------------------------------------- @@ -261,43 +258,6 @@ static void incLineNr() yyLineNr++; } -#if 0 -// Appends the current-name to current-type; -// Destroys current-name. -// Destroys current->args and current->argList -static void addType( Entry* current ) -{ - uint tl=current->type.length(); - if ( tl>0 && !current->name.isEmpty() && current->type.at(tl-1)!='.') - { - current->type += ' ' ; - } - current->type += current->name ; - current->name.resize(0) ; - tl=current->type.length(); - if ( tl>0 && !current->args.isEmpty() && current->type.at(tl-1)!='.') - { - current->type += ' ' ; - } - current->type += current->args ; - current->args.resize(0) ; - current->argList->clear(); -} - -static QCString stripQuotes(const char *s) -{ - QCString name; - if (s==0 || *s==0) return name; - name=s; - if (name.at(0)=='"' && name.at(name.length()-1)=='"') - { - name=name.mid(1,name.length()-2); - } - return name; -} -#endif -//----------------------------------------------------------------- - //----------------------------------------------------------------- static void startCommentBlock(bool brief) { @@ -313,15 +273,6 @@ static void startCommentBlock(bool brief) } } -/* -static void appendDocBlock() { - previous = current; - current_root->addSubEntry(current); - current = new Entry; - initEntry(); -} -*/ - static void handleCommentBlock(const QCString &doc,bool brief) { //printf("handleCommentBlock(doc=[%s] brief=%d docBlockInBody=%d docBlockJavaStyle=%d\n", @@ -341,7 +292,7 @@ static void handleCommentBlock(const QCString &doc,bool brief) QCString processedDoc = preprocessCommentBlock(doc,yyFileName,lineNr); while (parseCommentBlock( g_thisParser, - (docBlockInBody && previous) ? previous : current, + (docBlockInBody && previous) ? previous : current.get(), processedDoc, // text yyFileName, // file lineNr, @@ -427,7 +378,7 @@ static void searchFoundDef() current->type.resize(0); current->name.resize(0); current->args.resize(0); - current->argList->clear(); + current->argList.clear(); g_packageCommentAllowed = FALSE; gstat=FALSE; //printf("searchFoundDef at=%d\n",yyLineNr); @@ -436,7 +387,7 @@ static void searchFoundDef() static void searchFoundClass() { current->section = Entry::CLASS_SEC; - current->argList->clear(); + current->argList.clear(); current->type += "class" ; current->fileName = yyFileName; current->startLine = yyLineNr; @@ -765,8 +716,7 @@ STARTDOCSYMS "##" current->fileName = yyFileName; //printf("Adding using declaration: found:%s:%d name=%s\n",yyFileName.data(),yyLineNr,current->name.data()); current->section=Entry::USINGDECL_SEC; - current_root->addSubEntry(current); - current = new Entry ; + current_root->moveToSubEntryAndRefresh(current); initEntry(); BEGIN(Search); } @@ -963,7 +913,7 @@ STARTDOCSYMS "##" } {B}":"{B} { // function without arguments g_specialBlock = TRUE; // expecting a docstring - bodyEntry = current; + bodyEntry = current.get(); BEGIN(FunctionBody); } @@ -978,6 +928,10 @@ STARTDOCSYMS "##" BEGIN(FunctionParams); } ")" { // end of parameter list + if (current->argList.empty()) + { + current->argList.noParameters=TRUE; + } current->args = argListToString(current->argList); g_funcParamsEnd = TRUE; } @@ -992,10 +946,10 @@ STARTDOCSYMS "##" } {IDENTIFIER} { // Name of parameter lineCount(); - Argument *a = new Argument; - current->argList->append(a); - current->argList->getLast()->name = QCString(yytext).stripWhiteSpace(); - current->argList->getLast()->type = g_argType; + Argument a; + a.name = QCString(yytext).stripWhiteSpace(); + a.type = g_argType; + current->argList.push_back(a); g_argType = ""; } "=" { // default value @@ -1082,8 +1036,8 @@ STARTDOCSYMS "##" "," { if (g_braceCount == 0) { - if (current->argList->getLast()) - current->argList->getLast()->type += g_defVal.data(); + if (!current->argList.empty()) + current->argList.back().type += g_defVal; if (*yytext != ',') unput(*yytext); BEGIN(FunctionParams); @@ -1132,8 +1086,8 @@ STARTDOCSYMS "##" "," { if (g_braceCount == 0) { - if (current->argList->getLast()) - current->argList->getLast()->defval=QCString(g_defVal.data()).stripWhiteSpace(); + if (!current->argList.empty()) + current->argList.back().defval=QCString(g_defVal).stripWhiteSpace(); if (*yytext == ')') unput(*yytext); BEGIN(FunctionParams); @@ -1291,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 } @@ -1346,7 +1300,7 @@ STARTDOCSYMS "##" current->program+=yytext; //current->startLine = yyLineNr; g_curIndent=computeIndent(yytext); - bodyEntry = current; + bodyEntry = current.get(); DBG_CTX((stderr,"setting indent %d\n",g_curIndent)); //printf("current->program=[%s]\n",current->program.data()); //g_hideClassDocs = TRUE; @@ -1452,9 +1406,10 @@ STARTDOCSYMS "##" // do something based on the type of the IDENTIFIER if (current->type.isEmpty()) { - QListIterator<Entry> eli(*(current_root->children())); - Entry *child; - for (eli.toFirst();(child=eli.current());++eli) + //QListIterator<Entry> eli(*(current_root->children())); + //Entry *child; + //for (eli.toFirst();(child=eli.current());++eli) + for (const auto &child : current_root->children()) { if (child->name == QCString(yytext)) { @@ -1619,7 +1574,7 @@ STARTDOCSYMS "##" incLineNr(); docBlock += yytext; } - \\. { // espaced char + \\. { // escaped char docBlock += yytext; } . { @@ -1654,7 +1609,7 @@ STARTDOCSYMS "##" addToString(yytext); incLineNr(); } - \\. { // espaced char + \\. { // escaped char addToString(yytext); } "\"\"\"" { // triple double quotes @@ -1677,7 +1632,7 @@ STARTDOCSYMS "##" addToString(yytext); incLineNr(); } - \\. { // espaced char + \\. { // escaped char addToString(yytext); } "'''" { // triple single quotes @@ -1754,10 +1709,9 @@ STARTDOCSYMS "##" static void parseCompounds(Entry *rt) { //printf("parseCompounds(%s)\n",rt->name.data()); - EntryListIterator eli(*rt->children()); - Entry *ce; - for (;(ce=eli.current());++eli) + for (int i=0; i<rt->children().size(); ++i) { + Entry *ce = rt->children()[i].get(); if (!ce->program.isEmpty()) { //printf("-- %s ---------\n%s\n---------------\n", @@ -1768,7 +1722,7 @@ static void parseCompounds(Entry *rt) pyscannerYYrestart( pyscannerYYin ) ; if (ce->section&Entry::COMPOUND_MASK) { - current_root = ce ; + current_root = ce; BEGIN( Search ); } else if (ce->parent()) @@ -1780,18 +1734,17 @@ static void parseCompounds(Entry *rt) } yyFileName = ce->fileName; yyLineNr = ce->bodyLine ; - if (current) delete current; - current = new Entry; + current = std::make_unique<Entry>(); initEntry(); - Doxygen::docGroup.enterCompound(yyFileName,yyLineNr,ce->name); - + QCString name = ce->name; + Doxygen::docGroup.enterCompound(yyFileName,yyLineNr,name); + pyscannerYYlex() ; g_lexInit=TRUE; - delete current; current=0; ce->program.resize(0); - Doxygen::docGroup.leaveCompound(yyFileName,yyLineNr,ce->name); + Doxygen::docGroup.leaveCompound(yyFileName,yyLineNr,name); } parseCompounds(ce); @@ -1801,7 +1754,7 @@ static void parseCompounds(Entry *rt) //---------------------------------------------------------------------------- -static void parseMain(const char *fileName,const char *fileBuf,Entry *rt) +static void parseMain(const char *fileName,const char *fileBuf,const std::unique_ptr<Entry> &rt) { initParser(); @@ -1812,7 +1765,7 @@ static void parseMain(const char *fileName,const char *fileBuf,Entry *rt) mtype = Method; gstat = FALSE; virt = Normal; - current_root = rt; + current_root = rt.get(); g_specialBlock = FALSE; @@ -1836,7 +1789,7 @@ static void parseMain(const char *fileName,const char *fileBuf,Entry *rt) g_moduleScope+=baseName; } - current = new Entry; + current = std::make_unique<Entry>(); initEntry(); current->name = g_moduleScope; current->section = Entry::NAMESPACE_SEC; @@ -1845,11 +1798,11 @@ static void parseMain(const char *fileName,const char *fileBuf,Entry *rt) current->startLine = yyLineNr; current->bodyLine = yyLineNr; - rt->addSubEntry(current); + current_root = current.get(); + + rt->moveToSubEntryAndRefresh(current); - current_root = current ; initParser(); - current = new Entry; Doxygen::docGroup.enterFile(yyFileName,yyLineNr); @@ -1863,7 +1816,6 @@ static void parseMain(const char *fileName,const char *fileBuf,Entry *rt) Doxygen::docGroup.leaveFile(yyFileName,yyLineNr); current_root->program.resize(0); - delete current; current=0; parseCompounds(current_root); @@ -1936,7 +1888,7 @@ void pyscanFreeScanner() void PythonLanguageScanner::parseInput(const char *fileName, const char *fileBuf, - Entry *root, + const std::unique_ptr<Entry> &root, bool /*sameTranslationUnit*/, QStrList & /*filesInSameTranslationUnit*/) { diff --git a/src/reflist.cpp b/src/reflist.cpp index e874653..016ef49 100644 --- a/src/reflist.cpp +++ b/src/reflist.cpp @@ -206,6 +206,6 @@ void RefList::generatePage() } doc += "</dl>\n"; //printf("generatePage('%s')\n",doc.data()); - addRelatedPage(m_listName,m_pageTitle,doc,0,m_fileName,1,0,0,0,TRUE); + addRelatedPage(m_listName,m_pageTitle,doc,m_fileName,1,std::vector<ListItemInfo>(),0,0,TRUE); } diff --git a/src/scanner.h b/src/scanner.h index c0d3dff..7103cb0 100644 --- a/src/scanner.h +++ b/src/scanner.h @@ -34,7 +34,7 @@ class CLanguageScanner : public ParserInterface void finishTranslationUnit(); void parseInput(const char *fileName, const char *fileBuf, - Entry *root, + const std::unique_ptr<Entry> &root, bool sameTranslationUnit, QStrList &filesInSameTranslationUnit); bool needsPreprocessing(const QCString &extension); diff --git a/src/scanner.l b/src/scanner.l index 07d5c71..957c1e4 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -22,6 +22,11 @@ /* * includes */ + +#include <algorithm> +#include <vector> +#include <utility> + #include <stdio.h> #include <stdlib.h> #include <assert.h> @@ -86,11 +91,11 @@ static int roundCount = 0 ; static int curlyCount = 0 ; static int squareCount = 0 ; static int padCount = 0 ; +static std::unique_ptr<Entry> current; static Entry* current_root = 0 ; static Entry* global_root = 0 ; -static Entry* current = 0 ; static Entry* previous = 0 ; -static Entry* tempEntry = 0 ; +static std::unique_ptr<Entry> tempEntry; static Entry* firstTypedefEntry = 0 ; static Entry* memspecEntry = 0 ; static int yyLineNr = 1 ; @@ -194,6 +199,8 @@ static int g_column; static int g_fencedSize=0; static bool g_nestedComment=0; +static std::vector< std::pair<Entry*,std::unique_ptr<Entry> > > g_outerScopeEntries; + static const char *stateToString(int state); //----------------------------------------------------------------------------- @@ -205,6 +212,7 @@ static const char *stateToString(int state); static void initParser() { + g_outerScopeEntries.clear(); sectionLabel.resize(0); sectionTitle.resize(0); baseName.resize(0); @@ -228,7 +236,6 @@ static void initParser() sliceOpt=Config_getBool(OPTIMIZE_OUTPUT_SLICE); previous = 0; firstTypedefEntry = 0; - tempEntry = 0; memspecEntry =0; } @@ -244,54 +251,13 @@ static void initEntry() current->stat = gstat; current->lang = language; //printf("*** initEntry() language=%d\n",language); - //if (!autoGroupStack.isEmpty()) - //{ - // //printf("Appending group %s\n",autoGroupStack.top()->groupname.data()); - // current->groups->append(new Grouping(*autoGroupStack.top())); - //} - Doxygen::docGroup.initGroupInfo(current); + Doxygen::docGroup.initGroupInfo(current.get()); isTypedef=FALSE; } //----------------------------------------------------------------------------- -///// remove any automatic grouping and add new one (if given) -//static void setCurrentGroup( QCString *newgroup, Grouping::GroupPri_t pri ) -//{ -// /* remove auto group name from current entry and discard it */ -// Grouping *g = current->groups->first(); -// int i=0; -// while (g) -// { -// if (g->pri <= Grouping::GROUPING_AUTO_DEF) -// { -// current->groups->remove(i); -// i--; -// } -// g=current->groups->next(); -// i++; -// } -// -// /* use new group name instead? */ -// if ( newgroup ) -// { -// current->groups->append(new Grouping(*newgroup, pri)); -// } -//} -// -//static int newMemberGroupId() -//{ -// static int curGroupId=0; -// return curGroupId++; -//} -// -// forward declarations -//static void startGroupInDoc(); -//static void endGroup(); - -//----------------------------------------------------------------------------- - static void lineCount() { static int tabSize = Config_getInt(TAB_SIZE); @@ -329,7 +295,7 @@ static inline int computeIndent(const char *s,int startIndent) return col; } -static void addType( Entry* current ) +static void addType() { uint tl=current->type.length(); if( tl>0 && !current->name.isEmpty() && current->type.at(tl-1)!='.') @@ -345,7 +311,7 @@ static void addType( Entry* current ) } current->type += current->args ; current->args.resize(0) ; - current->argList->clear(); + current->argList.clear(); } @@ -365,7 +331,7 @@ static QCString stripQuotes(const char *s) static void startCommentBlock(bool); static void handleCommentBlock(const QCString &doc,bool brief); -static void handleParametersCommentBlocks(ArgumentList *al); +static void handleParametersCommentBlocks(ArgumentList &al); //----------------------------------------------------------------- @@ -411,28 +377,10 @@ static void prependScope() { //printf("--- prependScope %s to %s\n",current_root->name.data(),current->name.data()); current->name.prepend(current_root->name+"::"); - if (current_root->tArgLists) + //printf("prependScope #=%d #current=%d\n",current_root->tArgLists->count(),current->tArgLists->count()); + for (const ArgumentList &srcAl : current_root->tArgLists) { - if (current->tArgLists==0) - { - current->tArgLists = new QList<ArgumentList>; - current->tArgLists->setAutoDelete(TRUE); - } - //printf("prependScope #=%d #current=%d\n",current_root->tArgLists->count(),current->tArgLists->count()); - QListIterator<ArgumentList> talsi(*current_root->tArgLists); - ArgumentList *srcAl=0; - for (talsi.toLast();(srcAl=talsi.current());--talsi) - { - ArgumentList *dstAl = new ArgumentList; - QListIterator<Argument> tali(*srcAl); - Argument *a; - for (;(a=tali.current());++tali) - { - dstAl->append(new Argument(*a)); - //printf("appending argument %s %s\n",a->type.data(),a->name.data()); - } - current->tArgLists->insert(0,dstAl); - } + current->tArgLists.insert(current->tArgLists.begin(),srcAl); } } } @@ -443,14 +391,12 @@ static void prependScope() static bool checkForKnRstyleC() { if (((QCString)yyFileName).right(2).lower()!=".c") return FALSE; // must be a C file - if (!current->argList) return FALSE; // must have arguments - ArgumentListIterator ali(*current->argList); - Argument *a; - for (ali.toFirst();(a=ali.current());++ali) + if (current->argList.empty()) return FALSE; // must have arguments + for (const Argument &a : current->argList) { // in K&R style argument do not have a type, but doxygen expects a type // so it will think the argument has no name - if (a->type.isEmpty() || !a->name.isEmpty()) return FALSE; + if (a.type.isEmpty() || !a.name.isEmpty()) return FALSE; } return TRUE; } @@ -538,30 +484,27 @@ static void splitKnRArg(QCString &oldStyleArgPtr,QCString &oldStyleArgName) static void addKnRArgInfo(const QCString &type,const QCString &name, const QCString &brief,const QCString &docs) { - if (current->argList==0) return; - ArgumentListIterator ali(*current->argList); - Argument *a; - for (ali.toFirst();(a=ali.current());++ali) + for (Argument &a : current->argList) { - if (a->type==name) + if (a.type==name) { - a->type=type.stripWhiteSpace(); - if (a->type.left(9)=="register ") // strip keyword + a.type=type.stripWhiteSpace(); + if (a.type.left(9)=="register ") // strip keyword { - a->type=a->type.mid(9); + a.type=a.type.mid(9); } - a->name=name.stripWhiteSpace(); + a.name=name.stripWhiteSpace(); if (!brief.isEmpty() && !docs.isEmpty()) { - a->docs=brief+"\n\n"+docs; + a.docs=brief+"\n\n"+docs; } else if (!brief.isEmpty()) { - a->docs=brief; + a.docs=brief; } else { - a->docs=docs; + a.docs=docs; } } } @@ -570,17 +513,14 @@ static void addKnRArgInfo(const QCString &type,const QCString &name, //----------------------------------------------------------------------------- -void fixArgumentListForJavaScript(ArgumentList *al) +void fixArgumentListForJavaScript(ArgumentList &al) { - if (al==0) return; - ArgumentListIterator ali(*al); - Argument *a; - for (ali.toFirst();(a=ali.current());++ali) + for (Argument &a : al) { - if (!a->type.isEmpty() && a->name.isEmpty()) + if (!a.type.isEmpty() && a.name.isEmpty()) { // a->type is actually the (typeless) parameter name, so move it - a->name=a->type; - a->type.resize(0); + a.name=a.type; + a.type.resize(0); } } } @@ -744,6 +684,8 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) %x GCopyCurly %x SkipUnionSwitch %x Specialization +%x SpecializationSingleQuote +%x SpecializationDoubleQuote %x FuncPtrInit %x FuncFunc %x FuncFuncEnd @@ -895,7 +837,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->type.resize(0); current->name.resize(0); current->args.resize(0); - current->argList->clear(); + current->argList.clear(); lineCount() ; } @@ -904,7 +846,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->type.resize(0); current->name.resize(0); current->args.resize(0); - current->argList->clear(); + current->argList.clear(); lineCount() ; } @@ -914,7 +856,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->type.resize(0); current->name.resize(0); current->args.resize(0); - current->argList->clear(); + current->argList.clear(); lineCount() ; } @@ -924,7 +866,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->type.resize(0); current->name.resize(0); current->args.resize(0); - current->argList->clear(); + current->argList.clear(); lineCount(); } @@ -934,7 +876,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->type.resize(0); current->name.resize(0); current->args.resize(0); - current->argList->clear(); + current->argList.clear(); lineCount(); } @@ -944,7 +886,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->type.resize(0); current->name.resize(0); current->args.resize(0); - current->argList->clear(); + current->argList.clear(); lineCount(); } <FindMembers>{B}*("public"|"methods"|"__published"){BN}*":"{BN}* { @@ -953,7 +895,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->type.resize(0); current->name.resize(0); current->args.resize(0); - current->argList->clear(); + current->argList.clear(); lineCount() ; } <FindMembers>{B}*"internal"{BN}*":"{BN}* { // for now treat C++/CLI's internal as package... @@ -964,7 +906,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->type.resize(0); current->name.resize(0); current->args.resize(0); - current->argList->clear(); + current->argList.clear(); lineCount() ; } else @@ -978,7 +920,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->type.resize(0); current->name.resize(0); current->args.resize(0); - current->argList->clear(); + current->argList.clear(); lineCount() ; } <FindMembers>{B}*"private"{BN}*":"{BN}* { @@ -987,7 +929,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->type.resize(0); current->name.resize(0); current->args.resize(0); - current->argList->clear(); + current->argList.clear(); lineCount() ; } <FindMembers>{B}*"event"{BN}+ { @@ -1027,7 +969,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } } <CliPropertyType>{ID} { - addType( current ); + addType(); current->name = yytext; } <CliPropertyType>"[" { // C++/CLI indexed property @@ -1049,7 +991,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) <CliPropertyType>{B}* { } <CliPropertyType>. { - addType( current ); + addType(); current->type += yytext; } <CliPropertyIndex>"]" { @@ -1078,7 +1020,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->type.resize(0); current->name.resize(0); current->args.resize(0); - current->argList->clear(); + current->argList.clear(); lineCount() ; } <FindMembers>{B}*"@protected"{BN}+ { @@ -1087,7 +1029,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->type.resize(0); current->name.resize(0); current->args.resize(0); - current->argList->clear(); + current->argList.clear(); lineCount() ; } <FindMembers>{B}*"@public"{BN}+ { @@ -1096,7 +1038,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->type.resize(0); current->name.resize(0); current->args.resize(0); - current->argList->clear(); + current->argList.clear(); lineCount() ; } <FindMembers>[\-+]{BN}* { @@ -1121,7 +1063,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->type.resize(0); current->name.resize(0); current->args.resize(0); - current->argList->clear(); + current->argList.clear(); BEGIN( ObjCMethod ); } } @@ -1141,8 +1083,8 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } <ObjCMethod>":"{B}* { // start of parameter list current->name += ':'; - Argument *a = new Argument; - current->argList->append(a); + Argument a; + current->argList.push_back(a); BEGIN( ObjCParams ); } <ObjCReturnType>[^)]* { // TODO: check if nested braches are possible. @@ -1162,26 +1104,26 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) { current->name += keyw+":"; } - if (current->argList->getLast()->type.isEmpty()) + if (current->argList.back().type.isEmpty()) { - current->argList->getLast()->type="id"; + current->argList.back().type="id"; } - Argument *a = new Argument; - a->attrib=(QCString)"["+keyw+"]"; - current->argList->append(a); + Argument a; + a.attrib=(QCString)"["+keyw+"]"; + current->argList.push_back(a); } <ObjCParams>{ID}{BN}* { // name of parameter lineCount(); - current->argList->getLast()->name=QCString(yytext).stripWhiteSpace(); + current->argList.back().name=QCString(yytext).stripWhiteSpace(); } <ObjCParams>","{BN}*"..." { // name of parameter lineCount(); // do we want the comma as part of the name? //current->name += ","; - Argument *a = new Argument; - a->attrib="[,]"; - a->type="..."; - current->argList->append(a); + Argument a; + a.attrib="[,]"; + a.type="..."; + current->argList.push_back(a); } /* <ObjCParams>":" { @@ -1190,12 +1132,12 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) */ <ObjCParams>"(" { roundCount=0; - current->argList->getLast()->type.resize(0); + current->argList.back().type.resize(0); BEGIN( ObjCParamType ); } <ObjCParamType>"(" { roundCount++; - current->argList->getLast()->type+=yytext; + current->argList.back().type+=yytext; } <ObjCParamType>")"/{B}* { if (roundCount<=0) @@ -1204,18 +1146,22 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } else { - current->argList->getLast()->type+=yytext; + current->argList.back().type+=yytext; roundCount--; } } <ObjCParamType>[^()]* { - current->argList->getLast()->type+=QCString(yytext).stripWhiteSpace(); + current->argList.back().type+=QCString(yytext).stripWhiteSpace(); } <ObjCMethod,ObjCParams>";" { // end of method declaration - if (current->argList->getLast() && current->argList->getLast()->type.isEmpty()) + if (!current->argList.empty() && current->argList.back().type.isEmpty()) { - current->argList->getLast()->type="id"; + current->argList.back().type="id"; } + if (current->argList.empty()) // method without parameters + { + current->argList.noParameters = TRUE; + } current->args = argListToString(current->argList); //printf("argList=%s\n",current->args.data()); unput(';'); @@ -1226,10 +1172,14 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) //printf("Type=%s Name=%s args=%s\n", // current->type.data(),current->name.data(),argListToString(current->argList).data() // ); - if (current->argList->getLast() && current->argList->getLast()->type.isEmpty()) + if (!current->argList.empty() && current->argList.back().type.isEmpty()) { - current->argList->getLast()->type="id"; + current->argList.back().type="id"; } + if (current->argList.empty()) // method without parameters + { + current->argList.noParameters = TRUE; + } current->args = argListToString(current->argList); unput('{'); BEGIN( Function ); @@ -1371,9 +1321,9 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) lineCount(); } <PackageName>";" { - current_root->addSubEntry(current); - current_root = current ; - current = new Entry ; + Entry *tmp = current.get(); + current_root->moveToSubEntryAndRefresh(current); + current_root = tmp; initEntry(); BEGIN(FindMembers); } @@ -1509,7 +1459,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } else { - addType( current ) ; + addType(); current->name = QCString(yytext).stripWhiteSpace(); } } @@ -1528,7 +1478,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } else { - addType( current ) ; + addType(); current->name = QCString(yytext).stripWhiteSpace(); } } @@ -1547,7 +1497,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } else { - addType( current ) ; + addType(); current->name = QCString(yytext).stripWhiteSpace(); } } @@ -1560,7 +1510,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->spec = Entry::Service | // preserve UNO IDL [optional] or published (current->spec & (Entry::Optional|Entry::Published)); - addType( current ) ; + addType(); current->type += " service " ; current->fileName = yyFileName; current->startLine = yyLineNr; @@ -1569,7 +1519,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } else // TODO is addType right? just copy/pasted { - addType( current ) ; + addType(); current->name = QCString(yytext).stripWhiteSpace(); } } @@ -1581,7 +1531,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->section = Entry::CLASS_SEC; current->spec = Entry::Singleton | (current->spec & Entry::Published); // preserve - addType( current ) ; + addType(); current->type += " singleton " ; current->fileName = yyFileName; current->startLine = yyLineNr; @@ -1590,7 +1540,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } else // TODO is addType right? just copy/pasted { - addType( current ) ; + addType(); current->name = QCString(yytext).stripWhiteSpace(); } } @@ -1603,7 +1553,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->spec = Entry::Interface | // preserve UNO IDL [optional], published, Slice local (current->spec & (Entry::Optional|Entry::Published|Entry::Local)); - addType( current ) ; + addType(); current->type += " interface" ; current->fileName = yyFileName; current->startLine = yyLineNr; @@ -1613,7 +1563,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } else { - addType( current ) ; + addType(); current->name = QCString(yytext).stripWhiteSpace(); } } @@ -1624,7 +1574,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) language = current->lang = SrcLangExt_ObjC; insideObjC = TRUE; current->protection = protection = Public ; - addType( current ) ; + addType(); current->type += " implementation" ; current->fileName = yyFileName; current->startLine = yyLineNr; @@ -1642,7 +1592,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) insideObjC = TRUE; } current->protection = protection = Public ; - addType( current ) ; + addType(); current->type += " interface" ; current->fileName = yyFileName; current->startLine = yyLineNr; @@ -1658,7 +1608,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) language = current->lang = SrcLangExt_ObjC; insideObjC = TRUE; current->protection = protection = Public ; - addType( current ) ; + addType(); current->type += " protocol" ; current->fileName = yyFileName; current->startLine = yyLineNr; @@ -1673,7 +1623,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->spec = Entry::Exception | (current->spec & Entry::Published) | (current->spec & Entry::Local); - addType( current ) ; + addType(); current->type += " exception" ; current->fileName = yyFileName; current->startLine = yyLineNr; @@ -1690,7 +1640,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) bool isConst=decl.find("const")!=-1; bool isVolatile=decl.find("volatile")!=-1; current->section = Entry::CLASS_SEC; - addType( current ) ; + addType(); uint64 spec = current->spec; if (insidePHP && current->spec&Entry::Abstract) { @@ -1728,7 +1678,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) isTypedef=FALSE; current->section = Entry::CLASS_SEC; current->spec = Entry::Value; - addType( current ) ; + addType(); current->type += " value class" ; current->fileName = yyFileName; current->startLine = yyLineNr; @@ -1743,7 +1693,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) isTypedef=FALSE; current->section = Entry::CLASS_SEC; current->spec = Entry::Ref; - addType( current ) ; + addType(); current->type += " ref class" ; current->fileName = yyFileName; current->startLine = yyLineNr; @@ -1758,7 +1708,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) isTypedef=FALSE; current->section = Entry::CLASS_SEC; current->spec = Entry::Interface; - addType( current ) ; + addType(); current->type += " interface class" ; current->fileName = yyFileName; current->startLine = yyLineNr; @@ -1773,7 +1723,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) { isTypedef=FALSE; current->section = Entry::CLASS_SEC; - addType( current ) ; + addType(); current->type += " coclass" ; current->fileName = yyFileName; current->startLine = yyLineNr; @@ -1784,7 +1734,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } else { - addType(current); + addType(); current->name = yytext; current->name = current->name.stripWhiteSpace(); lineCount(); @@ -1805,7 +1755,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) (current->spec & Entry::Local); // bug 582676: can be a struct nested in an interface so keep insideObjC state //current->objc = insideObjC = FALSE; - addType( current ) ; + addType(); if (isConst) { current->type += " const"; @@ -1828,7 +1778,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) isTypedef=FALSE; current->section = Entry::CLASS_SEC; current->spec = Entry::Struct | Entry::Value; - addType( current ) ; + addType(); current->type += " value struct" ; current->fileName = yyFileName; current->startLine = yyLineNr; @@ -1843,7 +1793,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) isTypedef=FALSE; current->section = Entry::CLASS_SEC; current->spec = Entry::Struct | Entry::Ref; - addType( current ) ; + addType(); current->type += " ref struct" ; current->fileName = yyFileName; current->startLine = yyLineNr; @@ -1858,7 +1808,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) isTypedef=FALSE; current->section = Entry::CLASS_SEC; current->spec = Entry::Struct | Entry::Interface; - addType( current ) ; + addType(); current->type += " interface struct"; current->fileName = yyFileName; current->startLine = yyLineNr; @@ -1878,7 +1828,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->spec = Entry::Union; // bug 582676: can be a struct nested in an interface so keep insideObjC state //current->objc = insideObjC = FALSE; - addType( current ) ; + addType(); if (isConst) { current->type += " const"; @@ -1910,7 +1860,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) { current->section = Entry::ENUM_SEC ; } - addType( current ) ; + addType(); current->type += " enum"; if (isStrongEnum) { @@ -1951,15 +1901,10 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } <FindMembers>("template"|"generic")({BN}*)"<"/[>]? { // generic is a C++/CLI extension lineCount(); - if (current->tArgLists==0) - { - current->tArgLists = new QList<ArgumentList>; - current->tArgLists->setAutoDelete(TRUE); - } - ArgumentList *al = new ArgumentList; + ArgumentList al; //current->spec |= (yytext[0]=='g') ? Entry::Generic : Entry::Template; - current->tArgLists->append(al); - currentArgumentList = al; + current->tArgLists.push_back(al); + currentArgumentList = ¤t->tArgLists.back(); templateStr="<"; fullArgString = templateStr; copyArgString = &templateStr; @@ -2001,14 +1946,12 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->name=removeRedundantWhiteSpace(substitute(yytext,"\\","::")); //printf("PHP: adding use relation: %s\n",current->name.data()); current->fileName = yyFileName; - // add a using declaraton + // add a using declaration current->section=Entry::USINGDECL_SEC; - current_root->addSubEntry(current); - current = new Entry(*current); + current_root->copyToSubEntry(current); // also add it as a using directive current->section=Entry::USINGDIR_SEC; - current_root->addSubEntry(current); - current = new Entry ; + current_root->moveToSubEntryAndRefresh(current); initEntry(); aliasName.resize(0); } @@ -2043,8 +1986,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->name=removeRedundantWhiteSpace(substitute(scope.left(scope.length()-1),".","::")); current->fileName = yyFileName; current->section=Entry::USINGDIR_SEC; - current_root->addSubEntry(current); - current = new Entry; + current_root->moveToSubEntryAndRefresh(current); initEntry(); BEGIN(Using); } @@ -2062,9 +2004,8 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) //printf("import name = %s -> %s\n",yytext,current->name.data()); current->section=Entry::USINGDECL_SEC; } - current_root->addSubEntry(current); - previous = current; - current = new Entry ; + previous = current.get(); + current_root->moveToSubEntryAndRefresh(current); initEntry(); BEGIN(Using); } @@ -2081,9 +2022,9 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->fileName = yyFileName; current->section=Entry::USINGDECL_SEC; current->startLine = yyLineNr; - current_root->addSubEntry(current); - previous = current; - current = new Entry ; + previous = current.get(); + current_root->moveToSubEntryAndRefresh(current); + initEntry(); if (insideCS) /* Hack: in C# a using declaration and directive have the same syntax, so we also add it as a using directive here @@ -2094,10 +2035,9 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->startLine = yyLineNr; current->startColumn = yyColNr; current->section=Entry::USINGDIR_SEC; - current_root->addSubEntry(current); - current = new Entry ; + current_root->moveToSubEntryAndRefresh(current); + initEntry(); } - initEntry(); BEGIN(Using); } <Using>"=" { // C++11 style template alias? @@ -2156,22 +2096,21 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) <UsingDirective>{SCOPENAME} { current->name=removeRedundantWhiteSpace(yytext); current->fileName = yyFileName; current->section=Entry::USINGDIR_SEC; - current_root->addSubEntry(current); - current = new Entry ; + current_root->moveToSubEntryAndRefresh(current); initEntry(); BEGIN(Using); } <Using>";" { BEGIN(FindMembers); } <FindMembers>{SCOPENAME}{BN}*"<>" { // guided template decl QCString n=yytext; - addType( current ); + addType(); current->name=n.left(n.length()-2); } <FindMembers>{SCOPENAME}{BN}*/"<" { // Note: this could be a return type! roundCount=0; sharpCount=0; lineCount(); - addType( current ); + addType(); current->name=yytext; current->name=current->name.stripWhiteSpace(); //current->scopeSpec.resize(0); @@ -2437,7 +2376,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) else if (insideCS && qstrcmp(yytext,"this")==0) { // C# indexer - addType( current ) ; + addType(); current->name="this"; BEGIN(CSIndexer); } @@ -2469,7 +2408,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) { if (YY_START==FindMembers) { - addType( current ) ; + addType(); } bool javaLike = insideJava || insideCS || insideD || insidePHP || insideJS; if (javaLike && qstrcmp(yytext,"public")==0) @@ -2704,8 +2643,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->args = current->args.simplifyWhiteSpace(); current->name = current->name.stripWhiteSpace(); current->section = Entry::DEFINE_SEC; - current_root->addSubEntry(current); - current = new Entry ; + current_root->moveToSubEntryAndRefresh(current); initEntry(); BEGIN(lastDefineContext); } @@ -2722,8 +2660,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->initializer = init; current->name = current->name.stripWhiteSpace(); current->section = Entry::VARIABLE_SEC; - current_root->addSubEntry(current); - current = new Entry ; + current_root->moveToSubEntryAndRefresh(current); initEntry(); BEGIN(FindMembers); } @@ -2758,7 +2695,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) <FindMembers>[\^%] { // ^ and % are C++/CLI extensions if (insideCli) { - addType( current ); + addType(); current->name = yytext ; } else @@ -2768,9 +2705,9 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } <FindMembers>[*&]+ { current->name += yytext ; - addType( current ); + addType(); } -<FindMembers,MemberSpec,Function,NextSemi,EnumBaseType,BitFields,ReadInitializer,OldStyleArgs>";"{BN}*("/**"|"//!"|"/*!"|"///")"<" { +<FindMembers,MemberSpec,Function,NextSemi,EnumBaseType,BitFields,ReadInitializer,OldStyleArgs,DefinePHPEnd>";"{BN}*("/**"|"//!"|"/*!"|"///")"<" { if (current->bodyLine==-1) { current->bodyLine=yyLineNr; @@ -2870,7 +2807,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) else { // link open command to the current entry - Doxygen::docGroup.open(current,yyFileName,yyLineNr); + Doxygen::docGroup.open(current.get(),yyFileName,yyLineNr); } //current = tmp; initEntry(); @@ -2914,7 +2851,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } <FindMembers,FindFields,ReadInitializer>"//"([!/]){B}*{CMD}"}".*|"/*"([!*]){B}*{CMD}"}"[^*]*"*/" { bool insideEnum = YY_START==FindFields || (YY_START==ReadInitializer && lastInitializerContext==FindFields); // see bug746226 - Doxygen::docGroup.close(current,yyFileName,yyLineNr,insideEnum); + Doxygen::docGroup.close(current.get(),yyFileName,yyLineNr,insideEnum); } <FindMembers>"=" { // in PHP code this could also be due to "<?=" current->bodyLine = yyLineNr; @@ -2965,8 +2902,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->args = current->args.simplifyWhiteSpace(); current->name = current->name.stripWhiteSpace(); current->section = Entry::VARIABLE_SEC; - current_root->addSubEntry(current); - current = new Entry; + current_root->moveToSubEntryAndRefresh(current); initEntry(); BEGIN(FindMembers); } @@ -3468,7 +3404,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) { if (current->type.isEmpty()) // anonymous padding field, e.g. "int :7;" { - addType(current); + addType(); current->name.sprintf("__pad%d__",padCount++); } BEGIN(BitFields); @@ -3499,7 +3435,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) { current->type.prepend("typedef "); } - bool needNewCurrent=FALSE; + bool stat = current->stat; if (!current->name.isEmpty() && current->section!=Entry::ENUM_SEC) { current->type=current->type.simplifyWhiteSpace(); @@ -3513,17 +3449,11 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->fileName = yyFileName; current->startLine = yyBegLineNr; current->startColumn = yyBegColNr; - current_root->addSubEntry( current ) ; - needNewCurrent=TRUE; + current_root->moveToSubEntryAndRefresh( current ) ; + initEntry(); } if ( *yytext == ',') { - bool stat = current->stat; - if (needNewCurrent) - { - current = new Entry(*current); - initEntry(); - } current->stat = stat; // the static attribute holds for all variables current->name.resize(0); current->args.resize(0); @@ -3539,14 +3469,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) { mtype = Method; virt = Normal; - if (needNewCurrent) - { - current = new Entry ; - } - else if (current->groups) - { - current->groups->clear(); - } + current->groups.clear(); initEntry(); } } @@ -3764,8 +3687,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->args += ")"; current->name = current->name.stripWhiteSpace(); current->section = Entry::VARIABLE_SEC; - current_root->addSubEntry(current); - current = new Entry; + current_root->moveToSubEntryAndRefresh(current); initEntry(); BEGIN( FindMembers ); } @@ -3794,7 +3716,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) BEGIN( SkipString ); } <SkipSquare>[^\n\[\]\"]+ -<FindMembers>"<" { addType( current ) ; +<FindMembers>"<" { addType(); current->type += yytext ; BEGIN( Sharp ) ; } @@ -3847,8 +3769,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->args = current->args.simplifyWhiteSpace(); current->name = current->name.stripWhiteSpace(); current->section = Entry::VARIABLE_SEC; - current_root->addSubEntry(current); - current = new Entry ; + current_root->moveToSubEntryAndRefresh(current); initEntry(); } @@ -3880,17 +3801,17 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->name = current->name.stripWhiteSpace(); current->section = Entry::VARIABLE_SEC; // add to the scope of the enum - current_root->addSubEntry(current); if (!insideCS && !insideJava && !(current_root->spec&Entry::Strong)) // for C# and Java 1.5+ enum values always have to be explicitly qualified, // same for C++11 style enums (enum class Name {}) { - current = new Entry(*current); // add to the scope surrounding the enum (copy!) - current_root->parent()->addSubEntry(current); + // we cannot during it directly as that would invalidate the iterator in parseCompounds. + //printf("*** adding outer scope entry for %s\n",current->name.data()); + g_outerScopeEntries.emplace_back(current_root->parent(), std::make_unique<Entry>(*current)); } - current = new Entry ; + current_root->moveToSubEntryAndRefresh(current); initEntry(); } else // probably a redundant , @@ -3985,13 +3906,13 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) else { current->endBodyLine = yyLineNr; - Entry * original_root = current_root; // save root this namespace is in + Entry * original_root = current_root; // save root this namespace is in if (current->section == Entry::NAMESPACE_SEC && current->type == "namespace") { int split_point; while ((split_point = current->name.find("::")) != -1) { - Entry *new_current = new Entry(*current); + std::unique_ptr<Entry> new_current = std::make_unique<Entry>(*current); current->program = ""; new_current->doc = ""; new_current->docLine = 0; @@ -4003,9 +3924,10 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->name = current->name.left(split_point); if (!current_root->name.isEmpty()) current->name.prepend(current_root->name+"::"); - current_root->addSubEntry(current); - current_root = current; - current = new_current; + Entry *tmp = current.get(); + current_root->moveToSubEntryAndKeep(current); + current_root = tmp; + current.swap(new_current); } } QCString &cn = current->name; @@ -4040,17 +3962,16 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } else { - current_root->addSubEntry( current ) ; - memspecEntry = current; - current = new Entry(*current); - if (current->section==Entry::NAMESPACE_SEC || + memspecEntry = current.get(); + current_root->copyToSubEntry( current ) ; + if (current->section==Entry::NAMESPACE_SEC || (current->spec==Entry::Interface) || insideJava || insidePHP || insideCS || insideD || insideJS || insideSlice ) { // namespaces and interfaces and java classes ends with a closing bracket without semicolon - current->reset(); - current_root = original_root; // restore scope from before namespace descent + current->reset(); + current_root = original_root; // restore scope from before namespace descent initEntry(); memspecEntry = 0; BEGIN( FindMembers ) ; @@ -4105,12 +4026,11 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->args = current->args.simplifyWhiteSpace(); current->type = current->type.simplifyWhiteSpace(); //printf("Adding compound %s %s %s\n",current->type.data(),current->name.data(),current->args.data()); - current_root->addSubEntry( current ) ; if (!firstTypedefEntry) { - firstTypedefEntry = current; + firstTypedefEntry = current.get(); } - current = new Entry; + current_root->moveToSubEntryAndRefresh( current ) ; initEntry(); isTypedef=TRUE; // to undo reset by initEntry() BEGIN(MemberSpecSkip); @@ -4124,9 +4044,8 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) // add compound definition to the tree current->args = current->args.simplifyWhiteSpace(); current->type = current->type.simplifyWhiteSpace(); - current_root->addSubEntry( current ) ; - memspecEntry = current; - current = new Entry(*current); + memspecEntry = current.get(); + current_root->moveToSubEntryAndRefresh( current ) ; initEntry(); unput(';'); BEGIN( MemberSpec ) ; @@ -4166,7 +4085,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } } <MemberSpec>"(" { // function with struct return type - addType(current); + addType(); current->name = msName; current->spec = 0; unput('('); @@ -4179,7 +4098,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) // anonymous compound. If so we insert a // special 'anonymous' variable. //Entry *p=current_root; - Entry *p=current; + const Entry *p=current.get(); while (p) { // only look for class scopes, not namespace scopes @@ -4197,7 +4116,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } } //p=p->parent; - if (p==current) p=current_root; else p=p->parent(); + if (p==current.get()) p=current_root; else p=p->parent(); } } //printf("msName=%s current->name=%s\n",msName.data(),current->name.data()); @@ -4218,7 +4137,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } else // case 2: create a typedef field { - Entry *varEntry=new Entry; + std::unique_ptr<Entry> varEntry=std::make_unique<Entry>(); varEntry->lang = language; varEntry->protection = current->protection ; varEntry->mtype = current->mtype; @@ -4252,28 +4171,13 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) varEntry->brief = current->brief.copy(); varEntry->mGrpId = current->mGrpId; varEntry->initializer = current->initializer; - - // deep copy group list - QListIterator<Grouping> gli(*current->groups); - Grouping *g; - for (;(g=gli.current());++gli) - { - varEntry->groups->append(new Grouping(*g)); - } - if (current->sli) // copy special list items - { - QListIterator<ListItemInfo> li(*current->sli); - ListItemInfo *lii; - for (li.toFirst();(lii=li.current());++li) - { - varEntry->addSpecialListItem(lii->type,lii->itemId); - } - } + varEntry->groups = current->groups; + varEntry->sli = current->sli; //printf("Add: type='%s',name='%s',args='%s' brief=%s doc=%s\n", // varEntry->type.data(),varEntry->name.data(), // varEntry->args.data(),varEntry->brief.data(),varEntry->doc.data()); - current_root->addSubEntry(varEntry); + current_root->moveToSubEntryAndKeep(varEntry); } } if (*yytext==';') // end of a struct/class ... @@ -4327,8 +4231,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) lineCount() ; } <ReadBodyIntf>"@end"/[^a-z_A-Z0-9] { // end of Objective C block - current_root->addSubEntry( current ) ; - current=new Entry; + current_root->moveToSubEntryAndRefresh( current ) ; initEntry(); language = current->lang = SrcLangExt_Cpp; // see bug746361 insideObjC=FALSE; @@ -4346,7 +4249,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) { current->bodyLine = yyLineNr; lineCount(); - addType(current); + addType(); funcPtrType=yytext; roundCount=0; //current->type += yytext; @@ -4491,7 +4394,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } <GetCallType>{BN}*{ID}{BN}*"*" { lineCount(); - addType(current); + addType(); funcPtrType="("; funcPtrType+=yytext; roundCount=0; @@ -4506,7 +4409,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) fullArgString=current->args.copy(); copyArgString=¤t->args; BEGIN( ReadFuncArgType ) ; - //printf(">>> Read function arguments current->argList->count()=%d\n",current->argList->count()); + //printf(">>> Read function arguments current->argList.size()=%d\n",current->argList.size()); } } /* @@ -4719,8 +4622,8 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) <ReadTempArgs>">" { *copyArgString+=*yytext; fullArgString+=*yytext; - //printf("end template list %s\n",copyArgString->data()); - stringToArgumentList(fullArgString,currentArgumentList); + //printf("end template list '%s'\n",copyArgString->data()); + stringToArgumentList(fullArgString,*currentArgumentList); BEGIN( currentArgumentContext ); } <CopyArgRound>"(" { @@ -4872,12 +4775,12 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) <FuncQual>{BN}*"const"{BN}* { // const member function lineCount() ; current->args += " const "; - current->argList->constSpecifier=TRUE; + current->argList.constSpecifier=TRUE; } <FuncQual>{BN}*"volatile"{BN}* { // volatile member function lineCount() ; current->args += " volatile "; - current->argList->volatileSpecifier=TRUE; + current->argList.volatileSpecifier=TRUE; } <FuncQual>{BN}*"noexcept"{BN}* { // noexcept qualifier lineCount() ; @@ -4895,25 +4798,25 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } <FuncQual>{BN}*"&" { current->args += " &"; - current->argList->refQualifier=RefQualifierLValue; + current->argList.refQualifier=RefQualifierLValue; } <FuncQual>{BN}*"&&" { current->args += " &&"; - current->argList->refQualifier=RefQualifierRValue; + current->argList.refQualifier=RefQualifierRValue; } <FuncQual,TrailingReturn>{BN}*"="{BN}*"0"{BN}* { // pure virtual member function lineCount() ; current->args += " = 0"; current->virt = Pure; - current->argList->pureSpecifier=TRUE; + current->argList.pureSpecifier=TRUE; BEGIN(FuncQual); } <FuncQual,TrailingReturn>{BN}*"="{BN}*"delete"{BN}* { // C++11 explicitly delete member lineCount(); current->args += " = delete"; current->spec |= Entry::Delete; - current->argList->isDeleted=TRUE; + current->argList.isDeleted=TRUE; BEGIN(FuncQual); } <FuncQual,TrailingReturn>{BN}*"="{BN}*"default"{BN}* { // C++11 explicitly defaulted constructor/assignment operator @@ -4924,7 +4827,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } <FuncQual>{BN}*"->"{BN}* { lineCount(); - current->argList->trailingReturnType = " -> "; + current->argList.trailingReturnType = " -> "; current->args += " -> "; BEGIN(TrailingReturn); } @@ -4933,12 +4836,12 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) BEGIN(FuncQual); } <TrailingReturn>. { - current->argList->trailingReturnType+=yytext; + current->argList.trailingReturnType+=yytext; current->args+=yytext; } <TrailingReturn>\n { lineCount(); - current->argList->trailingReturnType+=yytext; + current->argList.trailingReturnType+=yytext; current->args+=' '; } <FuncRound,FuncFunc>{BN}*","{BN}* { @@ -5024,9 +4927,8 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) if (insideCS && qstrcmp(yytext,"where")==0) { // type constraint for a method - delete current->typeConstr; - current->typeConstr = new ArgumentList; - current->typeConstr->append(new Argument); + current->typeConstr.clear(); + current->typeConstr.push_back(Argument()); lastCSConstraint = YY_START; BEGIN( CSConstraintName ); } @@ -5063,6 +4965,10 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } <OldStyleArgs>{ID} { current->args += yytext; } <OldStyleArgs>"{" { + if (current->argList.empty()) + { + current->argList.noParameters=TRUE; + } current->args = argListToString(current->argList); unput('{'); BEGIN(FuncQual); @@ -5223,9 +5129,8 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) { findAndRemoveWord(current->type,"function"); } - previous = current; - current_root->addSubEntry(current); - current = new Entry ; + previous = current.get(); + current_root->moveToSubEntryAndRefresh(current); initEntry(); // Objective C 2.0: Required/Optional section if (previous->spec & (Entry::Optional | Entry::Required)) @@ -5298,16 +5203,10 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } else { - if (current->sli && previous) // copy special list items + if (!current->sli.empty() && previous) // copy special list items { - QListIterator<ListItemInfo> li(*current->sli); - ListItemInfo *lii; - for (li.toFirst();(lii=li.current());++li) - { - previous->addSpecialListItem(lii->type,lii->itemId); - } - delete current->sli; - current->sli = 0; + previous->sli = current->sli; + current->sli.clear(); } if (previous) previous->endBodyLine=yyLineNr; BEGIN( lastCurlyContext ) ; @@ -5323,9 +5222,9 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) else { current->endBodyLine=yyLineNr; - - tempEntry = current; // temporarily switch to the previous entry - current = previous; + // take previous out of current_root and move it into current + current.swap(tempEntry); // remember current + current_root->moveFromSubEntry(previous,current); previous = 0; docBlockContext = SkipCurlyEndDoc; @@ -5368,8 +5267,8 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) //addToBody("}"); if (tempEntry) // we can only switch back to current if no new item was created { - current = tempEntry; - tempEntry = 0; + tempEntry.swap(current); + tempEntry.reset(); } BEGIN( lastCurlyContext ); } @@ -5495,7 +5394,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->type.resize(0) ; current->name.resize(0) ; current->args.resize(0) ; - current->argList->clear(); + current->argList.clear(); BEGIN( FindMembers ) ; } <Bases>";" { @@ -5512,12 +5411,12 @@ 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->addSubEntry( current ) ; - current = new Entry; + current_root->moveToSubEntryAndRefresh( current ) ; + initEntry(); } else { @@ -5525,7 +5424,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->type.resize(0) ; current->name.resize(0) ; current->args.resize(0) ; - current->argList->clear(); + current->argList.clear(); } BEGIN( FindMembers ) ; } @@ -5554,16 +5453,11 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } } <CSGeneric>"<" { - if (current->tArgLists==0) - { - current->tArgLists = new QList<ArgumentList>; - current->tArgLists->setAutoDelete(TRUE); - } - ArgumentList *al = new ArgumentList; + ArgumentList al; // check bug 612858 before enabling the next line //current->spec |= Entry::Template; - current->tArgLists->append(al); - currentArgumentList = al; + current->tArgLists.push_back(al); + currentArgumentList = ¤t->tArgLists.back(); templateStr="<"; current->name += "<"; fullArgString = templateStr; @@ -5601,7 +5495,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) current->name += yytext; } <CompoundName>{SCOPENAME}{BN}*";" { // forward declaration - if (current->tArgLists && current->tArgLists->count()>0) + if (!current->tArgLists.empty()) { // found a forward template declaration, this has // a purpose of its own @@ -5615,8 +5509,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) prependScope(); } current->spec|=Entry::ForwardDecl; - current_root->addSubEntry(current); - current = new Entry; + current_root->moveToSubEntryAndRefresh(current); } else if (insideIDL && (((current_root->spec & (Entry::Interface | @@ -5637,8 +5530,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) : Entry::INCLUDED_SERVICE_SEC; // current->section = Entry::MEMBERDOC_SEC; current->spec &= ~(Entry::Interface|Entry::Service); // FIXME: horrible: Interface == Gettable, so need to clear it - actually we're mixing values from different enums in this case... granted only Optional and Interface are actually valid in this context but urgh... - current_root->addSubEntry(current); - current = new Entry; + current_root->moveToSubEntryAndRefresh(current); } unput(';'); @@ -5722,7 +5614,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } else { - addType(current); + addType(); current->name = yytext; current->name = current->name.stripWhiteSpace(); lineCount(); @@ -5777,9 +5669,8 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } else if (insideCS && qstrcmp(yytext,"where")==0) // C# type constraint { - delete current->typeConstr; - current->typeConstr = new ArgumentList; - current->typeConstr->append(new Argument); + current->typeConstr.clear(); + current->typeConstr.push_back(Argument()); lastCSConstraint = YY_START; BEGIN( CSConstraintName ); } @@ -5839,7 +5730,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) BEGIN( CopyArgComment ); } <CSConstraintType,CSConstraintName>"#" { // artificially inserted token to signal end of comment block - current->typeConstr->getLast()->docs = fullArgString; + current->typeConstr.back().docs = fullArgString; } <CSConstraintType>"{" { // end of type constraint reached // parse documentation of the constraints @@ -5857,24 +5748,24 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } <CSConstraintName>{ID} { // parameter name - current->typeConstr->getLast()->name=yytext; + current->typeConstr.back().name=yytext; } <CSConstraintType>"where" { // another constraint for a different param - current->typeConstr->append(new Argument); + current->typeConstr.push_back(Argument()); BEGIN( CSConstraintName ); } <CSConstraintType>({ID}".")*{ID}("<"{ID}">")?("()")? { - if (current->typeConstr->getLast()->type.isEmpty()) + if (current->typeConstr.back().type.isEmpty()) // first type constraint for this parameter { - current->typeConstr->getLast()->type=yytext; + current->typeConstr.back().type=yytext; } else // new type constraint for same parameter { - QCString name = current->typeConstr->getLast()->name; - current->typeConstr->append(new Argument); - current->typeConstr->getLast()->name=name; - current->typeConstr->getLast()->type=yytext; + QCString name = current->typeConstr.back().name; + current->typeConstr.push_back(Argument()); + current->typeConstr.back().name=name; + current->typeConstr.back().type=yytext; } } <CSConstraintName,CSConstraintType>\n { @@ -6056,9 +5947,8 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) if (insideCS && baseScope.stripWhiteSpace()=="where") { // type constraint for a class - delete current->typeConstr; - current->typeConstr = new ArgumentList; - current->typeConstr->append(new Argument); + current->typeConstr.clear(); + current->typeConstr.push_back(Argument()); lastCSConstraint = YY_START; BEGIN( CSConstraintName ); } @@ -6165,6 +6055,19 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) <Specialization>"typename"{BN}+ { lineCount(); } <Specialization>"(" { *specName += *yytext; roundCount++; } <Specialization>")" { *specName += *yytext; roundCount--; } + +<Specialization>"\\\\" { *specName += *yytext;} +<Specialization>"\\'" { *specName += *yytext;} +<Specialization>"\\\"" { *specName += *yytext;} +<Specialization>"'" { *specName += *yytext;BEGIN(SpecializationSingleQuote);} +<Specialization>"\"" { *specName += *yytext;BEGIN(SpecializationDoubleQuote);} +<SpecializationSingleQuote,SpecializationDoubleQuote>"\\\\" { *specName += *yytext;} +<SpecializationSingleQuote>"\\'" { *specName += *yytext;} +<SpecializationSingleQuote>"'" { *specName += *yytext; BEGIN(Specialization);} +<SpecializationDoubleQuote>"\\\"" { *specName += *yytext;} +<SpecializationDoubleQuote>"\"" { *specName += *yytext; BEGIN(Specialization);} +<SpecializationSingleQuote,SpecializationDoubleQuote>. { *specName += *yytext;} + <Specialization>. { *specName += *yytext; } @@ -6188,8 +6091,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)) || @@ -6230,8 +6133,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) @@ -6466,7 +6369,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) //current->type.resize(0); //current->name.resize(0); //current->args.resize(0); - //current->argList->clear(); + //current->argList.clear(); //curlyCount=0; //BEGIN( SkipCurlyBlock ); @@ -6546,8 +6449,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) <SliceSequenceName>";" { current->section = Entry::VARIABLE_SEC; - current_root->addSubEntry(current); - current = new Entry; + current_root->moveToSubEntryAndRefresh(current); initEntry(); BEGIN(FindMembers); } @@ -6577,8 +6479,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) <SliceDictionaryName>";" { current->section = Entry::VARIABLE_SEC; - current_root->addSubEntry(current); - current = new Entry; + current_root->moveToSubEntryAndRefresh(current); initEntry(); BEGIN(FindMembers); } @@ -6871,16 +6772,16 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } <PrototypeQual>{B}*"const"{B}* { current->args += " const "; - current->argList->constSpecifier=TRUE; + current->argList.constSpecifier=TRUE; } <PrototypeQual>{B}*"volatile"{B}* { current->args += " volatile "; - current->argList->volatileSpecifier=TRUE; + current->argList.volatileSpecifier=TRUE; } <PrototypeQual>{B}*"="{B}*"0"{B}* { current->args += " = 0"; current->virt = Pure; - current->argList->pureSpecifier=TRUE; + current->argList.pureSpecifier=TRUE; } <PrototypeQual>"throw"{B}*"(" { current->exception = "throw("; @@ -7009,11 +6910,15 @@ static void newEntry() // already added to current_root, so we should not add it again // (see bug723314) { - current_root->addSubEntry(current); + previous = current.get(); + current_root->moveToSubEntryAndRefresh(current); + } + else + { + previous = current.get(); + tempEntry.swap(current); + tempEntry.reset(); } - tempEntry = 0; - previous = current; - current = new Entry ; initEntry(); } @@ -7025,7 +6930,7 @@ static void handleCommentBlock(const QCString &doc,bool brief) int lineNr = brief ? current->briefLine : current->docLine; // line of block start // fill in inbodyFile && inbodyLine the first time, see bug 633891 - Entry *docEntry = docBlockInBody && previous ? previous : current; + Entry *docEntry = docBlockInBody && previous ? previous : current.get(); if (docBlockInBody && docEntry && docEntry->inbodyLine==-1) { docEntry->inbodyFile = yyFileName; @@ -7037,7 +6942,7 @@ static void handleCommentBlock(const QCString &doc,bool brief) QCString processedDoc = preprocessCommentBlock(stripIndentation(doc),yyFileName,lineNr); while (parseCommentBlock( g_thisParser, - docBlockInBody && previous ? previous : current, + docBlockInBody && previous ? previous : current.get(), processedDoc, // text yyFileName, // file lineNr, // line of block start @@ -7071,17 +6976,15 @@ static void handleCommentBlock(const QCString &doc,bool brief) } } -static void handleParametersCommentBlocks(ArgumentList *al) +static void handleParametersCommentBlocks(ArgumentList &al) { //printf(">>>>>>> handleParametersCommentBlocks()\n"); - ArgumentListIterator ali(*al); - Argument *a; - for (ali.toFirst();(a=ali.current());++ali) + for (Argument &a : al) { //printf(" Param %s docs=%s\n",a->name.data(),a->docs.data()); - if (!a->docs.isEmpty()) + if (!a.docs.isEmpty()) { - if (!a->name && a->type == "...") a->name= "..."; + if (!a.name && a.type == "...") a.name= "..."; int position=0; bool needsEntry; @@ -7097,8 +7000,8 @@ static void handleParametersCommentBlocks(ArgumentList *al) //printf("handleParametersCommentBlock [%s]\n",doc.data()); while (parseCommentBlock( g_thisParser, - current, - a->docs, // text + current.get(), + a.docs, // text yyFileName, // file current->docLine, // line of block start FALSE, @@ -7117,7 +7020,7 @@ static void handleParametersCommentBlocks(ArgumentList *al) { newEntry(); } - a->docs = current->doc; + a.docs = current->doc; // restore context current->doc = orgDoc; @@ -7131,12 +7034,10 @@ static void handleParametersCommentBlocks(ArgumentList *al) //---------------------------------------------------------------------------- -static void parseCompounds(Entry *rt) +static void parseCompounds(const std::unique_ptr<Entry> &rt) { //printf("parseCompounds(%s)\n",rt->name.data()); - EntryListIterator eli(*rt->children()); - Entry *ce; - for (;(ce=eli.current());++eli) + for (const auto &ce : rt->children()) { if (!ce->program.isEmpty()) { @@ -7153,29 +7054,22 @@ static void parseCompounds(Entry *rt) BEGIN( FindFields ) ; else BEGIN( FindMembers ) ; - current_root = ce ; + current_root = ce.get() ; yyFileName = ce->fileName; //setContext(); yyLineNr = ce->startLine ; yyColNr = ce->startColumn ; insideObjC = ce->lang==SrcLangExt_ObjC; //printf("---> Inner block starts at line %d objC=%d\n",yyLineNr,insideObjC); - //current->reset(); - if (current) delete current; - current = new Entry; + current = std::make_unique<Entry>(); gstat = FALSE; initEntry(); // deep copy group list from parent (see bug 727732) static bool autoGroupNested = Config_getBool(GROUP_NESTED_COMPOUNDS); - if (autoGroupNested && rt->groups && ce->section!=Entry::ENUM_SEC && !(ce->spec&Entry::Enum)) + if (autoGroupNested && ce->section!=Entry::ENUM_SEC && !(ce->spec&Entry::Enum)) { - QListIterator<Grouping> gli(*rt->groups); - Grouping *g; - for (;(g=gli.current());++gli) - { - ce->groups->append(new Grouping(*g)); - } + ce->groups = rt->groups; } int ni=ce->name.findRev("::"); if (ni==-1) ni=0; else ni+=2; @@ -7229,15 +7123,15 @@ static void parseCompounds(Entry *rt) //memberGroupId = DOX_NOGROUP; //memberGroupRelates.resize(0); //memberGroupInside.resize(0); - Doxygen::docGroup.enterCompound(yyFileName,yyLineNr,ce->name); + QCString name = ce->name; + Doxygen::docGroup.enterCompound(yyFileName,yyLineNr,name); scannerYYlex() ; g_lexInit=TRUE; //forceEndGroup(); - Doxygen::docGroup.leaveCompound(yyFileName,yyLineNr,ce->name); + Doxygen::docGroup.leaveCompound(yyFileName,yyLineNr,name); - delete current; current=0; ce->program.resize(0); @@ -7254,7 +7148,7 @@ static void parseCompounds(Entry *rt) static void parseMain(const char *fileName, const char *fileBuf, - Entry *rt, + const std::unique_ptr<Entry> &rt, bool sameTranslationUnit, QStrList & filesInSameTranslationUnit) { @@ -7270,8 +7164,8 @@ static void parseMain(const char *fileName, mtype = Method; gstat = FALSE; virt = Normal; - current_root = rt; - global_root = rt; + current_root = rt.get(); + global_root = rt.get(); inputFile.setName(fileName); if (inputFile.open(IO_ReadOnly)) { @@ -7293,18 +7187,17 @@ static void parseMain(const char *fileName, rt->lang = language; msg("Parsing file %s...\n",yyFileName.data()); - current_root = rt ; + current_root = rt.get() ; initParser(); Doxygen::docGroup.enterFile(yyFileName,yyLineNr); - current = new Entry; + current = std::make_unique<Entry>(); //printf("current=%p current_root=%p\n",current,current_root); int sec=guessSection(yyFileName); if (sec) { current->name = yyFileName; current->section = sec; - current_root->addSubEntry(current); - current = new Entry; + current_root->moveToSubEntryAndRefresh(current); } current->reset(); initEntry(); @@ -7329,18 +7222,7 @@ static void parseMain(const char *fileName, //forceEndGroup(); Doxygen::docGroup.leaveFile(yyFileName,yyLineNr); - //if (depthIf>0) - //{ - // warn(yyFileName,yyLineNr,"Documentation block ended in the middle of a conditional section!"); - //} - rt->program.resize(0); - if (rt->children()->contains(current)==0) - // it could be that current is already added as a child to rt, so we - // only delete it if this is not the case. See bug 635317. - { - delete current; current=0; - } parseCompounds(rt); @@ -7348,6 +7230,14 @@ static void parseMain(const char *fileName, anonNSCount++; + // add additional entries that were created during processing + for (auto &kv: g_outerScopeEntries) + { + //printf(">>> adding '%s' to scope '%s'\n",kv.second->name.data(),kv.first->name.data()); + kv.first->moveToSubEntryAndKeep(kv.second); + } + g_outerScopeEntries.clear(); + } } @@ -7396,6 +7286,7 @@ static void parsePrototype(const QCString &text) inputString = orgInputString; inputPosition = orgInputPosition; + //printf("**** parsePrototype end\n"); } @@ -7438,7 +7329,7 @@ void CLanguageScanner::finishTranslationUnit() void CLanguageScanner::parseInput(const char *fileName, const char *fileBuf, - Entry *root, + const std::unique_ptr<Entry> &root, bool sameTranslationUnit, QStrList & filesInSameTranslationUnit) { diff --git a/src/section.h b/src/section.h index b6268a9..9e6c695 100644 --- a/src/section.h +++ b/src/section.h @@ -26,33 +26,18 @@ class Definition; /** Class representing a section in a page */ struct SectionInfo { - enum SectionType { Page = 0, - Section = 1, - Subsection = 2, - Subsubsection = 3, - Paragraph = 4, + enum SectionType { Page = 0, + Section = 1, + Subsection = 2, + Subsubsection = 3, + Paragraph = 4, Anchor = 5, Table = 6 }; SectionInfo(const char *f,const int lin,const char *l,const char *t, SectionType st,int lev,const char *r=0) : label(l), title(t), type(st), ref(r), definition(0), - fileName(f), lineNr(lin), generated(FALSE), level(lev) - { - } - SectionInfo(const SectionInfo &s) - { - label=s.label.copy(); - title=s.title.copy(); - type =s.type; - ref=s.ref.copy(); - definition=s.definition; - fileName=s.fileName.copy(); - lineNr=s.lineNr; - generated=s.generated; - level=s.level; - } - ~SectionInfo() {} + fileName(f), lineNr(lin), generated(FALSE), level(lev) {} QCString label; QCString title; SectionType type; diff --git a/src/sortdict.h b/src/sortdict.h index 52eccd3..0e0b5c1 100644 --- a/src/sortdict.h +++ b/src/sortdict.h @@ -128,7 +128,7 @@ class SDict /*! Appends an element to the dictionary. The element is owned by the * dictionary. - * \param key The unique key to use to quicky find the item later on. + * \param key The unique key to use to quickly find the item later on. * \param d The compound to add. * \sa find() */ @@ -146,7 +146,7 @@ class SDict /*! Prepends an element to the dictionary. The element is owned by the * dictionary. - * \param key The unique key to use to quicky find the item later on. + * \param key The unique key to use to quickly find the item later on. * \param d The compound to add. * \sa find() */ @@ -190,7 +190,7 @@ class SDict m_list->sort(); } /*! Inserts a compound into the dictionary in a sorted way. - * \param key The unique key to use to quicky find the item later on. + * \param key The unique key to use to quickly find the item later on. * \param d The compound to add. * \sa find() */ @@ -470,7 +470,7 @@ class SIntDict /*! Appends a compound to the dictionary. The element is owned by the * dictionary. - * \param key The unique key to use to quicky find the item later on. + * \param key The unique key to use to quickly find the item later on. * \param d The compound to add. * \sa find() */ @@ -488,7 +488,7 @@ class SIntDict /*! Prepend a compound to the dictionary. The element is owned by the * dictionary. - * \param key The unique key to use to quicky find the item later on. + * \param key The unique key to use to quickly find the item later on. * \param d The compound to add. * \sa find() */ @@ -521,7 +521,7 @@ class SIntDict } /*! Inserts a compound into the dictionary in a sorted way. - * \param key The unique key to use to quicky find the item later on. + * \param key The unique key to use to quickly find the item later on. * \param d The compound to add. * \sa find() */ diff --git a/src/sqlite3gen.cpp b/src/sqlite3gen.cpp index 49818b2..dc0cc85 100644 --- a/src/sqlite3gen.cpp +++ b/src/sqlite3gen.cpp @@ -1015,26 +1015,34 @@ static void insertMemberReference(const MemberDef *src, const MemberDef *dst, co static void insertMemberFunctionParams(int memberdef_id, const MemberDef *md, const Definition *def) { - const ArgumentList *declAl = md->declArgumentList(); - const ArgumentList *defAl = md->argumentList(); - if (declAl!=0 && defAl!=0 && declAl->count()>0) - { - ArgumentListIterator declAli(*declAl); - ArgumentListIterator defAli(*defAl); - const Argument *a; - for (declAli.toFirst();(a=declAli.current());++declAli) + const ArgumentList &declAl = md->declArgumentList(); + const ArgumentList &defAl = md->argumentList(); + if (declAl.size()>0) + { +// ArgumentListIterator declAli(*declAl); +// ArgumentListIterator defAli(*defAl); +// const Argument *a; +// for (declAli.toFirst();(a=declAli.current());++declAli) + auto defIt = defAl.begin(); + for (const Argument &a : declAl) { - const Argument *defArg = defAli.current(); + //const Argument *defArg = defAli.current(); + const Argument *defArg = 0; + if (defIt!=defAl.end()) + { + defArg = &(*defIt); + ++defIt; + } - if (!a->attrib.isEmpty()) + if (!a.attrib.isEmpty()) { - bindTextParameter(param_select,":attributes",a->attrib); - bindTextParameter(param_insert,":attributes",a->attrib); + bindTextParameter(param_select,":attributes",a.attrib); + bindTextParameter(param_insert,":attributes",a.attrib); } - if (!a->type.isEmpty()) + if (!a.type.isEmpty()) { StringList l; - linkifyText(TextGeneratorSqlite3Impl(l),def,md->getBodyDef(),md,a->type); + linkifyText(TextGeneratorSqlite3Impl(l),def,md->getBodyDef(),md,a.type); StringListIterator li(l); QCString *s; @@ -1046,32 +1054,31 @@ static void insertMemberFunctionParams(int memberdef_id, const MemberDef *md, co insertMemberReference(src_refid,dst_refid, "argument"); ++li; } - bindTextParameter(param_select,":type",a->type); - bindTextParameter(param_insert,":type",a->type); + bindTextParameter(param_select,":type",a.type); + bindTextParameter(param_insert,":type",a.type); } - if (!a->name.isEmpty()) + if (!a.name.isEmpty()) { - bindTextParameter(param_select,":declname",a->name); - bindTextParameter(param_insert,":declname",a->name); + bindTextParameter(param_select,":declname",a.name); + bindTextParameter(param_insert,":declname",a.name); } - if (defArg && !defArg->name.isEmpty() && defArg->name!=a->name) + if (defArg && !defArg->name.isEmpty() && defArg->name!=a.name) { bindTextParameter(param_select,":defname",defArg->name); bindTextParameter(param_insert,":defname",defArg->name); } - if (!a->array.isEmpty()) + if (!a.array.isEmpty()) { - bindTextParameter(param_select,":array",a->array); - bindTextParameter(param_insert,":array",a->array); + bindTextParameter(param_select,":array",a.array); + bindTextParameter(param_insert,":array",a.array); } - if (!a->defval.isEmpty()) + if (!a.defval.isEmpty()) { StringList l; - linkifyText(TextGeneratorSqlite3Impl(l),def,md->getBodyDef(),md,a->defval); - bindTextParameter(param_select,":defval",a->defval); - bindTextParameter(param_insert,":defval",a->defval); + linkifyText(TextGeneratorSqlite3Impl(l),def,md->getBodyDef(),md,a.defval); + bindTextParameter(param_select,":defval",a.defval); + bindTextParameter(param_insert,":defval",a.defval); } - if (defArg) ++defAli; int param_id=step(param_select,TRUE,TRUE); if (param_id==0) { @@ -1091,18 +1098,16 @@ static void insertMemberFunctionParams(int memberdef_id, const MemberDef *md, co static void insertMemberDefineParams(int memberdef_id,const MemberDef *md, const Definition *def) { - if (md->argumentList()->count()==0) // special case for "foo()" to - // disguish it from "foo". + if (md->argumentList().empty()) // special case for "foo()" to + // disguish it from "foo". { DBG_CTX(("no params\n")); } else { - ArgumentListIterator ali(*md->argumentList()); - Argument *a; - for (ali.toFirst();(a=ali.current());++ali) + for (const Argument &a : md->argumentList()) { - bindTextParameter(param_insert,":defname",a->type); + bindTextParameter(param_insert,":defname",a.type); int param_id=step(param_insert,TRUE); if (param_id==-1) { continue; @@ -1373,48 +1378,39 @@ static void writeInnerNamespaces(const NamespaceSDict *nl, struct Refid outer_re } -static void writeTemplateArgumentList(const ArgumentList * al, +static void writeTemplateArgumentList(const ArgumentList &al, const Definition * scope, const FileDef * fileScope) { - if (al) + for (const Argument &a : al) { - ArgumentListIterator ali(*al); - Argument *a; - for (ali.toFirst();(a=ali.current());++ali) + if (!a.type.isEmpty()) { - if (!a->type.isEmpty()) - { - #warning linkifyText(TextGeneratorXMLImpl(t),scope,fileScope,0,a->type); - bindTextParameter(param_select,":type",a->type); - bindTextParameter(param_insert,":type",a->type); - } - if (!a->name.isEmpty()) - { - bindTextParameter(param_select,":declname",a->name); - bindTextParameter(param_insert,":declname",a->name); - bindTextParameter(param_select,":defname",a->name); - bindTextParameter(param_insert,":defname",a->name); - } - if (!a->defval.isEmpty()) - { - #warning linkifyText(TextGeneratorXMLImpl(t),scope,fileScope,0,a->defval); - bindTextParameter(param_select,":defval",a->defval); - bindTextParameter(param_insert,":defval",a->defval); - } - if (!step(param_select,TRUE,TRUE)) - step(param_insert); +//#warning linkifyText(TextGeneratorXMLImpl(t),scope,fileScope,0,a.type); + bindTextParameter(param_select,":type",a.type); + bindTextParameter(param_insert,":type",a.type); } + if (!a.name.isEmpty()) + { + bindTextParameter(param_select,":declname",a.name); + bindTextParameter(param_insert,":declname",a.name); + bindTextParameter(param_select,":defname",a.name); + bindTextParameter(param_insert,":defname",a.name); + } + if (!a.defval.isEmpty()) + { +//#warning linkifyText(TextGeneratorXMLImpl(t),scope,fileScope,0,a.defval); + bindTextParameter(param_select,":defval",a.defval); + bindTextParameter(param_insert,":defval",a.defval); + } + if (!step(param_select,TRUE,TRUE)) + step(param_insert); } } static void writeMemberTemplateLists(const MemberDef *md) { - const ArgumentList *templMd = md->templateArguments(); - if (templMd) // function template prefix - { - writeTemplateArgumentList(templMd,md->getClassDef(),md->getFileDef()); - } + writeTemplateArgumentList(md->templateArguments(),md->getClassDef(),md->getFileDef()); } static void writeTemplateList(const ClassDef *cd) { @@ -1675,12 +1671,9 @@ static void generateSqlite3ForMember(const MemberDef *md, struct Refid scope_ref if (isFunc) { - const ArgumentList *al = md->argumentList(); - if (al!=0) - { - bindIntParameter(memberdef_insert,":const",al->constSpecifier); - bindIntParameter(memberdef_insert,":volatile",al->volatileSpecifier); - } + const ArgumentList &al = md->argumentList(); + bindIntParameter(memberdef_insert,":const",al.constSpecifier); + bindIntParameter(memberdef_insert,":volatile",al.volatileSpecifier); bindIntParameter(memberdef_insert,":explicit",md->isExplicit()); bindIntParameter(memberdef_insert,":inline",md->isInline()); bindIntParameter(memberdef_insert,":final",md->isFinal()); diff --git a/src/sqlscanner.h b/src/sqlscanner.h index 3ca6fe3..b981b5b 100644 --- a/src/sqlscanner.h +++ b/src/sqlscanner.h @@ -28,7 +28,7 @@ public: virtual ~SQLScanner() {} void startTranslationUnit(const char *) {} void finishTranslationUnit() {} - void parseInput(const char *, const char *, Entry *, bool , QStrList &) {} + void parseInput(const char *, const char *, const std::unique_ptr<Entry> &, bool , QStrList &) {} bool needsPreprocessing(const QCString &) { return FALSE; } void parseCode(CodeOutputInterface &codeOutIntf, diff --git a/src/tagreader.cpp b/src/tagreader.cpp index 56dbe7d..65336e3 100644 --- a/src/tagreader.cpp +++ b/src/tagreader.cpp @@ -21,6 +21,8 @@ #include <assert.h> #include <stdio.h> #include <stdarg.h> +#include <algorithm> + #include <qxml.h> #include <qstack.h> @@ -98,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; @@ -621,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 { @@ -638,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 { @@ -912,12 +909,12 @@ class TagFileParser : public QXmlDefaultHandler } void dump(); - void buildLists(Entry *root); + void buildLists(const std::unique_ptr<Entry> &root); void addIncludes(); private: - void buildMemberList(Entry *ce,QList<TagMemberInfo> &members); - void addDocAnchors(Entry *e,const TagAnchorInfoList &l); + void buildMemberList(const std::unique_ptr<Entry> &ce,QList<TagMemberInfo> &members); + void addDocAnchors(const std::unique_ptr<Entry> &e,const TagAnchorInfoList &l); QList<TagClassInfo> m_tagFileClasses; QList<TagFileInfo> m_tagFileFiles; QList<TagNamespaceInfo> m_tagFileNamespaces; @@ -988,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); @@ -1147,7 +1139,7 @@ void TagFileParser::dump() } } -void TagFileParser::addDocAnchors(Entry *e,const TagAnchorInfoList &l) +void TagFileParser::addDocAnchors(const std::unique_ptr<Entry> &e,const TagAnchorInfoList &l) { QListIterator<TagAnchorInfo> tli(l); TagAnchorInfo *ta; @@ -1160,7 +1152,7 @@ void TagFileParser::addDocAnchors(Entry *e,const TagAnchorInfoList &l) SectionInfo *si=new SectionInfo(ta->fileName,-1,ta->label,ta->title, SectionInfo::Anchor,0,m_tagName); Doxygen::sectionDict->append(ta->label,si); - e->anchors->append(si); + e->anchors.push_back(si); } else { @@ -1169,20 +1161,18 @@ void TagFileParser::addDocAnchors(Entry *e,const TagAnchorInfoList &l) } } -void TagFileParser::buildMemberList(Entry *ce,QList<TagMemberInfo> &members) +void TagFileParser::buildMemberList(const std::unique_ptr<Entry> &ce,QList<TagMemberInfo> &members) { QListIterator<TagMemberInfo> mii(members); TagMemberInfo *tmi; for (;(tmi=mii.current());++mii) { - Entry *me = new Entry; + std::unique_ptr<Entry> me = std::make_unique<Entry>(); me->type = tmi->type; me->name = tmi->name; me->args = tmi->arglist; if (!me->args.isEmpty()) { - delete me->argList; - me->argList = new ArgumentList; stringToArgumentList(me->args,me->argList); } if (tmi->enumValues.count()>0) @@ -1192,17 +1182,16 @@ void TagFileParser::buildMemberList(Entry *ce,QList<TagMemberInfo> &members) TagEnumValueInfo *evi; for (evii.toFirst();(evi=evii.current());++evii) { - Entry *ev = new Entry; + std::unique_ptr<Entry> ev = std::make_unique<Entry>(); ev->type = "@"; ev->name = evi->name; ev->id = evi->clangid; ev->section = Entry::VARIABLE_SEC; - TagInfo *ti = new TagInfo; - ti->tagName = m_tagName; - ti->anchor = evi->anchor; - ti->fileName = evi->file; - ev->tagInfo = ti; - me->addSubEntry(ev); + ev->tagInfoData.tagName = m_tagName; + ev->tagInfoData.anchor = evi->anchor; + ev->tagInfoData.fileName = evi->file; + ev->hasTagInfo = TRUE; + me->moveToSubEntryAndKeep(ev); } } me->protection = tmi->prot; @@ -1212,14 +1201,13 @@ void TagFileParser::buildMemberList(Entry *ce,QList<TagMemberInfo> &members) me->id = tmi->clangId; if (ce->section == Entry::GROUPDOC_SEC) { - me->groups->append(new Grouping(ce->name,Grouping::GROUPING_INGROUP)); + me->groups.push_back(Grouping(ce->name,Grouping::GROUPING_INGROUP)); } addDocAnchors(me,tmi->docAnchors); - TagInfo *ti = new TagInfo; - ti->tagName = m_tagName; - ti->anchor = tmi->anchor; - ti->fileName = tmi->anchorFile; - me->tagInfo = ti; + me->tagInfoData.tagName = m_tagName; + me->tagInfoData.anchor = tmi->anchor; + me->tagInfoData.fileName = tmi->anchorFile; + me->hasTagInfo = TRUE; if (tmi->kind=="define") { me->type="#define"; @@ -1287,7 +1275,7 @@ void TagFileParser::buildMemberList(Entry *ce,QList<TagMemberInfo> &members) me->section = Entry::FUNCTION_SEC; me->mtype = Slot; } - ce->addSubEntry(me); + ce->moveToSubEntryAndKeep(me); } } @@ -1308,14 +1296,14 @@ static QCString stripPath(const QCString &s) * This tree contains the information extracted from the input in a * "unrelated" form. */ -void TagFileParser::buildLists(Entry *root) +void TagFileParser::buildLists(const std::unique_ptr<Entry> &root) { // build class list QListIterator<TagClassInfo> cit(m_tagFileClasses); TagClassInfo *tci; for (cit.toFirst();(tci=cit.current());++cit) { - Entry *ce = new Entry; + std::unique_ptr<Entry> ce = std::make_unique<Entry>(); ce->section = Entry::CLASS_SEC; switch (tci->kind) { @@ -1339,42 +1327,32 @@ void TagFileParser::buildLists(Entry *root) ce->name+="-p"; } addDocAnchors(ce,tci->docAnchors); - TagInfo *ti = new TagInfo; - ti->tagName = m_tagName; - ti->anchor = tci->anchor; - ti->fileName = tci->filename; + ce->tagInfoData.tagName = m_tagName; + ce->tagInfoData.anchor = tci->anchor; + ce->tagInfoData.fileName = tci->filename; + ce->hasTagInfo = TRUE; ce->id = tci->clangId; - ce->tagInfo = ti; 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) { - if (ce->tArgLists==0) - { - ce->tArgLists = new QList<ArgumentList>; - ce->tArgLists->setAutoDelete(TRUE); - } - ArgumentList *al = new ArgumentList; - ce->tArgLists->append(al); - + ArgumentList al; QListIterator<QCString> sli(*tci->templateArguments); QCString *argName; for (;(argName=sli.current());++sli) { - Argument *a = new Argument; - a->type = "class"; - a->name = *argName; - al->append(a); + Argument a; + a.type = "class"; + a.name = *argName; + al.push_back(a); } + ce->tArgLists.push_back(al); } buildMemberList(ce,tci->members); - root->addSubEntry(ce); + root->moveToSubEntryAndKeep(ce); } // build file list @@ -1382,15 +1360,14 @@ void TagFileParser::buildLists(Entry *root) TagFileInfo *tfi; for (fit.toFirst();(tfi=fit.current());++fit) { - Entry *fe = new Entry; + std::unique_ptr<Entry> fe = std::make_unique<Entry>(); fe->section = guessSection(tfi->name); fe->name = tfi->name; addDocAnchors(fe,tfi->docAnchors); - TagInfo *ti = new TagInfo; - ti->tagName = m_tagName; - ti->fileName = tfi->filename; - fe->tagInfo = ti; - + fe->tagInfoData.tagName = m_tagName; + fe->tagInfoData.fileName = tfi->filename; + fe->hasTagInfo = TRUE; + QCString fullName = m_tagName+":"+tfi->path+stripPath(tfi->name); fe->fileName = fullName; //printf("createFileDef() filename=%s\n",tfi->filename.data()); @@ -1411,7 +1388,7 @@ void TagFileParser::buildLists(Entry *root) Doxygen::inputNameDict->insert(tfi->name,mn); } buildMemberList(fe,tfi->members); - root->addSubEntry(fe); + root->moveToSubEntryAndKeep(fe); } // build namespace list @@ -1419,18 +1396,17 @@ void TagFileParser::buildLists(Entry *root) TagNamespaceInfo *tni; for (nit.toFirst();(tni=nit.current());++nit) { - Entry *ne = new Entry; + std::unique_ptr<Entry> ne = std::make_unique<Entry>(); ne->section = Entry::NAMESPACE_SEC; ne->name = tni->name; addDocAnchors(ne,tni->docAnchors); - TagInfo *ti = new TagInfo; - ti->tagName = m_tagName; - ti->fileName = tni->filename; + ne->tagInfoData.tagName = m_tagName; + ne->tagInfoData.fileName = tni->filename; + ne->hasTagInfo = TRUE; ne->id = tni->clangId; - ne->tagInfo = ti; buildMemberList(ne,tni->members); - root->addSubEntry(ne); + root->moveToSubEntryAndKeep(ne); } // build package list @@ -1438,17 +1414,16 @@ void TagFileParser::buildLists(Entry *root) TagPackageInfo *tpgi; for (pit.toFirst();(tpgi=pit.current());++pit) { - Entry *pe = new Entry; + std::unique_ptr<Entry> pe = std::make_unique<Entry>(); pe->section = Entry::PACKAGE_SEC; pe->name = tpgi->name; addDocAnchors(pe,tpgi->docAnchors); - TagInfo *ti = new TagInfo; - ti->tagName = m_tagName; - ti->fileName = tpgi->filename; - pe->tagInfo = ti; + pe->tagInfoData.tagName = m_tagName; + pe->tagInfoData.fileName = tpgi->filename; + pe->hasTagInfo = TRUE; buildMemberList(pe,tpgi->members); - root->addSubEntry(pe); + root->moveToSubEntryAndKeep(pe); } // build group list @@ -1456,18 +1431,17 @@ void TagFileParser::buildLists(Entry *root) TagGroupInfo *tgi; for (git.toFirst();(tgi=git.current());++git) { - Entry *ge = new Entry; + std::unique_ptr<Entry> ge = std::make_unique<Entry>(); ge->section = Entry::GROUPDOC_SEC; ge->name = tgi->name; ge->type = tgi->title; addDocAnchors(ge,tgi->docAnchors); - TagInfo *ti = new TagInfo; - ti->tagName = m_tagName; - ti->fileName = tgi->filename; - ge->tagInfo = ti; + ge->tagInfoData.tagName = m_tagName; + ge->tagInfoData.fileName = tgi->filename; + ge->hasTagInfo = TRUE; buildMemberList(ge,tgi->members); - root->addSubEntry(ge); + root->moveToSubEntryAndKeep(ge); } // set subgroup relations bug_774118 @@ -1476,13 +1450,16 @@ void TagFileParser::buildLists(Entry *root) QCStringList::Iterator it; for ( it = tgi->subgroupList.begin(); it != tgi->subgroupList.end(); ++it ) { - QListIterator<Entry> eli(*(root->children())); - Entry *childNode; - for (eli.toFirst();(childNode=eli.current());++eli) + //QListIterator<Entry> eli(*(root->children())); + //Entry *childNode; + //for (eli.toFirst();(childNode=eli.current());++eli) + const auto &children = root->children(); + auto i = std::find_if(children.begin(),children.end(), + [&](const std::unique_ptr<Entry> &e) { return e->name = *it; }); + if (i!=children.end()) { - if (childNode->name == (*it)) break; + (*i)->groups.push_back(Grouping(tgi->name,Grouping::GROUPING_INGROUP)); } - childNode->groups->append(new Grouping(tgi->name,Grouping::GROUPING_INGROUP)); } } @@ -1491,16 +1468,15 @@ void TagFileParser::buildLists(Entry *root) TagPageInfo *tpi; for (pgit.toFirst();(tpi=pgit.current());++pgit) { - Entry *pe = new Entry; + std::unique_ptr<Entry> pe = std::make_unique<Entry>(); pe->section = tpi->filename=="index" ? Entry::MAINPAGEDOC_SEC : Entry::PAGEDOC_SEC; pe->name = tpi->name; pe->args = tpi->title; addDocAnchors(pe,tpi->docAnchors); - TagInfo *ti = new TagInfo; - ti->tagName = m_tagName; - ti->fileName = tpi->filename; - pe->tagInfo = ti; - root->addSubEntry(pe); + pe->tagInfoData.tagName = m_tagName; + pe->tagInfoData.fileName = tpi->filename; + pe->hasTagInfo = TRUE; + root->moveToSubEntryAndKeep(pe); } } @@ -1551,7 +1527,7 @@ void TagFileParser::addIncludes() } } -void parseTagFile(Entry *root,const char *fullName) +void parseTagFile(const std::unique_ptr<Entry> &root,const char *fullName) { QFileInfo fi(fullName); if (!fi.exists()) return; diff --git a/src/tagreader.h b/src/tagreader.h index 6ea2d81..4c09a04 100644 --- a/src/tagreader.h +++ b/src/tagreader.h @@ -21,6 +21,8 @@ class Entry; -void parseTagFile(Entry *root,const char *fullPathName); +#include <memory> + +void parseTagFile(const std::unique_ptr<Entry> &root,const char *fullPathName); #endif diff --git a/src/tclscanner.h b/src/tclscanner.h index 0e56bdd..482fb1f 100644 --- a/src/tclscanner.h +++ b/src/tclscanner.h @@ -33,7 +33,7 @@ class TclLanguageScanner : public ParserInterface void finishTranslationUnit() {} void parseInput(const char *fileName, const char *fileBuf, - Entry *root, + const std::unique_ptr<Entry> &root, bool sameTranslationUnit, QStrList &filesInSameTranslationUnit); bool needsPreprocessing(const QCString &extension); diff --git a/src/tclscanner.l b/src/tclscanner.l index e763575..4a262bc 100644 --- a/src/tclscanner.l +++ b/src/tclscanner.l @@ -578,7 +578,7 @@ Entry* tcl_entry_namespace(const QCString ns) myEntry = tcl_entry_new(); myEntry->section = Entry::NAMESPACE_SEC; myEntry->name = ns; - tcl.entry_main->addSubEntry(myEntry); + tcl.entry_main->moveToSubEntryAndKeep(myEntry); tcl.ns.insert(ns,myEntry); } return myEntry; @@ -597,7 +597,7 @@ Entry* tcl_entry_class(const QCString cl) myEntry = tcl_entry_new(); myEntry->section = Entry::CLASS_SEC; myEntry->name = cl; - tcl.entry_main->addSubEntry(myEntry); + tcl.entry_main->moveToSubEntryAndKeep(myEntry); tcl.cl.insert(cl,myEntry); } return myEntry; @@ -1540,7 +1540,7 @@ tcl_inf("-> %s\n",(const char *)tcl.string_comment); processedDoc = preprocessCommentBlock(myDoc,tcl.file_name,myLine0); parseCommentBlock(tcl.this_parser, myEntry, processedDoc, tcl.file_name, myLine0, FALSE, tcl.config_autobrief, FALSE, myProt, myPos0, myNew); - tcl.entry_inside->addSubEntry(myEntry); + tcl.entry_inside->moveToSubEntryAndRefresh(myEntry); } else { // we can add to current entry in this case @@ -1562,7 +1562,7 @@ tcl_inf("-> %s\n",(const char *)tcl.string_comment); processedDoc = preprocessCommentBlock(myDoc,tcl.file_name,myLine0); parseCommentBlock(tcl.this_parser, myEntry, processedDoc, tcl.file_name, myLine0, FALSE, tcl.config_autobrief, FALSE, myProt, myPos0, myNew); - tcl.entry_inside->addSubEntry(myEntry); + tcl.entry_inside->moveToSubEntryAndKeep(myEntry); } else { // we can add to current entry @@ -1585,7 +1585,7 @@ tcl_inf("-> %s\n",(const char *)tcl.string_comment); { if (myNew) { - tcl.entry_inside->addSubEntry(tcl.entry_current); + tcl.entry_inside->moveToSubEntryAndKeep(tcl.entry_current); tcl.entry_current = tcl_entry_new(); } else @@ -1596,7 +1596,7 @@ tcl_inf("-> %s\n",(const char *)tcl.string_comment); } if (myNew) { - tcl.entry_inside->addSubEntry(tcl.entry_current); + tcl.entry_inside->moveToSubEntryAndKeep(tcl.entry_current); tcl.entry_current = tcl_entry_new(); } else @@ -1622,37 +1622,32 @@ tcl_inf("-> %s\n",(const char *)tcl.string_comment); static void tcl_command_ARGLIST(QCString &arglist) { D - Argument *myArg; QCStringList myArgs; QCString myArglist=""; - if (!tcl.entry_current->argList) - { - tcl.entry_current->argList=new ArgumentList; - } tcl_split_list(arglist,myArgs); for (uint i=0;i<myArgs.count();i++) { QCStringList myArgs1; - myArg=new Argument; + Argument myArg; tcl_split_list(*myArgs.at(i),myArgs1); if (myArgs1.count()==2) { - myArg->name= (*myArgs1.at(0)); - myArg->defval= (*myArgs1.at(1)); - if (myArg->defval.isEmpty()) + myArg.name= (*myArgs1.at(0)); + myArg.defval= (*myArgs1.at(1)); + if (myArg.defval.isEmpty()) { - myArg->defval = " "; + myArg.defval = " "; } - myArglist += "?" + QCString(myArg->name) + "? "; + myArglist += "?" + QCString(myArg.name) + "? "; } else { - myArg->name= (*myArgs.at(i)); - myArglist += myArg->name + " "; + myArg.name= (*myArgs.at(i)); + myArglist += myArg.name + " "; } - tcl.entry_current->argList->append(myArg); + tcl.entry_current->argList.push_back(myArg); } arglist = myArglist; tcl.entry_current->args = arglist; @@ -2155,7 +2150,7 @@ D tcl.entry_current->endBodyLine = tcl.line_body1; tcl_protection(tcl.entry_current); tcl_command_ARGLIST(*tcl.list_commandwords.at(4)); - myEntryNs->addSubEntry(tcl.entry_current); + myEntryNs->moveToSubEntryAndKeep(tcl.entry_current); myEntry = tcl.entry_current; tcl.fn.insert(myName,myEntry); myScan = tcl_scan_start(tcl.word_is,*tcl.list_commandwords.at(6), @@ -2197,7 +2192,7 @@ D tcl.entry_current->endBodyLine = tcl.line_body1; tcl_protection(tcl.entry_current); tcl_command_ARGLIST(*tcl.list_commandwords.at(4)); - myEntryCl->addSubEntry(tcl.entry_current); + myEntryCl->moveToSubEntryAndKeep(tcl.entry_current); tcl.fn.insert(myName,tcl.entry_current); myEntry = tcl.entry_current; myScan = tcl_scan_start(tcl.word_is,*tcl.list_commandwords.at(6), @@ -2234,7 +2229,7 @@ D tcl.entry_current->endBodyLine = tcl.line_body1; tcl_protection(tcl.entry_current); tcl_command_ARGLIST(*tcl.list_commandwords.at(2)); - if (myEntryCl) myEntryCl->addSubEntry(tcl.entry_current); + if (myEntryCl) myEntryCl->moveToSubEntryAndKeep(tcl.entry_current); myEntry = tcl.entry_current; tcl.fn.insert(myName,myEntry); myScan = tcl_scan_start(tcl.word_is,*tcl.list_commandwords.at(4), @@ -2268,7 +2263,7 @@ D tcl.entry_current->bodyLine = tcl.line_body0; tcl.entry_current->endBodyLine = tcl.line_body1; tcl_protection(tcl.entry_current); - myEntryCl->addSubEntry(tcl.entry_current); + myEntryCl->moveToSubEntryAndKeep(tcl.entry_current); myEntry = tcl.entry_current; tcl.fn.insert(myName,myEntry); myScan = tcl_scan_start(tcl.word_is,*tcl.list_commandwords.at(2), @@ -2300,7 +2295,7 @@ D tcl.entry_current->startLine = tcl.line_command; tcl.entry_current->bodyLine = tcl.line_body0; tcl.entry_current->endBodyLine = tcl.line_body1; - tcl.entry_main->addSubEntry(tcl.entry_current); + tcl.entry_main->moveToSubEntryAndKeep(tcl.entry_current); tcl.ns.insert(myName,tcl.entry_current); //myEntryNs = tcl.entry_current; myStr = (*tcl.list_commandwords.at(6)); @@ -2338,7 +2333,7 @@ D tcl.entry_current->startLine = tcl.line_command; tcl.entry_current->bodyLine = tcl.line_body0; tcl.entry_current->endBodyLine = tcl.line_body1; - tcl.entry_main->addSubEntry(tcl.entry_current); + tcl.entry_main->moveToSubEntryAndKeep(tcl.entry_current); tcl.cl.insert(myName,tcl.entry_current); myEntryCl = tcl.entry_current; myScan = tcl_scan_start(tcl.word_is,*tcl.list_commandwords.at(4), @@ -2370,7 +2365,7 @@ D tcl.entry_current->startLine = tcl.line_command; tcl.entry_current->bodyLine = tcl.line_body0; tcl.entry_current->endBodyLine = tcl.line_body1; - tcl.entry_main->addSubEntry(tcl.entry_current); + tcl.entry_main->moveToSubEntryAndKeep(tcl.entry_current); //myEntryNs = tcl_entry_namespace(myName); tcl.cl.insert(myName,tcl.entry_current); myEntryCl = tcl.entry_current; @@ -2431,7 +2426,7 @@ D { tcl_command_ARGLIST(*tcl.list_commandwords.at(6)); } - if (myEntryCl) myEntryCl->addSubEntry(tcl.entry_current); + if (myEntryCl) myEntryCl->moveToSubEntryAndKeep(tcl.entry_current); tcl.fn.insert(myMethod,tcl.entry_current); myEntry = tcl.entry_current; myScan = tcl_scan_start('?',*tcl.list_commandwords.at(n-1), @@ -2493,7 +2488,7 @@ D tcl.entry_current->bodyLine = tcl.line_body0; tcl.entry_current->endBodyLine = tcl.line_body1; tcl_protection(tcl.entry_current); - myEntry->addSubEntry(tcl.entry_current); + myEntry->moveToSubEntryAndKeep(tcl.entry_current); tcl.entry_current = tcl_entry_new(); } @@ -2705,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; @@ -2911,10 +2906,10 @@ static void tcl_parse(const QCString ns, const QCString cls) tcl.entry_file->name = tcl.file_name; tcl.entry_file->section = Entry::SOURCE_SEC; tcl.entry_file->protection = Public; - tcl.entry_main->addSubEntry(tcl.entry_file); + tcl.entry_main->moveToSubEntryAndKeep(tcl.entry_file); Entry *myEntry=tcl_entry_new(); myEntry->name=""; - tcl.entry_main->addSubEntry(myEntry); + tcl.entry_main->moveToSubEntryAndKeep(myEntry); tcl.ns.insert("::",myEntry); tcl.entry_current = tcl_entry_new(); @@ -2944,7 +2939,7 @@ static void tcl_parse(const QCString ns, const QCString cls) //! Parse text file and build up entry tree. void TclLanguageScanner::parseInput(const char *fileName, const char *input, - Entry *root, + const std::unique_ptr<Entry> &root, bool /*sameTranslationUnit*/, QStrList & /*filesInSameTranslationUnit*/) { @@ -2965,7 +2960,7 @@ tcl_inf("%s\n",fileName); tcl.code = NULL; tcl.file_name = fileName; tcl.this_parser = this; - tcl.entry_main = root; /* toplevel entry */ + tcl.entry_main = root.get(); /* toplevel entry */ tcl_parse("",""); Doxygen::docGroup.leaveFile(tcl.file_name,yylineno); root->program.resize(0); diff --git a/src/types.h b/src/types.h index 4d305b6..189a93d 100644 --- a/src/types.h +++ b/src/types.h @@ -92,7 +92,6 @@ struct Grouping } Grouping( const char *gn, GroupPri_t p ) : groupname(gn), pri(p) {} - Grouping( const Grouping &g ) : groupname(g.groupname), pri(g.pri) {} QCString groupname; //!< name of the group GroupPri_t pri; //!< priority of this definition diff --git a/src/util.cpp b/src/util.cpp index 85536ca..8e0884f 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -540,7 +540,7 @@ const ClassDef *newResolveTypedef(const FileDef *fileScope, const MemberDef **pMemType, QCString *pTemplSpec, QCString *pResolvedType, - ArgumentList *actTemplParams) + const ArgumentList *actTemplParams) { //printf("newResolveTypedef(md=%p,cachedVal=%p)\n",md,md->getCachedTypedefVal()); bool isCached = md->isTypedefValCached(); // value already cached @@ -563,11 +563,11 @@ const ClassDef *newResolveTypedef(const FileDef *fileScope, const ClassDef *typeClass = md->getClassDef(); QCString type = md->typeString(); // get the "value" of the typedef - if (typeClass && typeClass->isTemplate() && - actTemplParams && actTemplParams->count()>0) + if (typeClass && typeClass->isTemplate() && + actTemplParams && !actTemplParams->empty()) { type = substituteTemplateArgumentsInString(type, - typeClass->templateArguments(),actTemplParams); + typeClass->templateArguments(),*actTemplParams); } QCString typedefValue = type; int tl=type.length(); @@ -1397,7 +1397,7 @@ static const ClassDef *getResolvedClassRec(const Definition *scope, ArgumentList actTemplParams; if (!strippedTemplateParams.isEmpty()) // template part that was stripped { - stringToArgumentList(strippedTemplateParams,&actTemplParams); + stringToArgumentList(strippedTemplateParams,actTemplParams); } int qualifierIndex = computeQualifiedIndex(name); @@ -2260,17 +2260,15 @@ void writeExample(OutputList &ol,ExampleSDict *ed) } -QCString argListToString(const ArgumentList *al,bool useCanonicalType,bool showDefVals) +QCString argListToString(const ArgumentList &al,bool useCanonicalType,bool showDefVals) { QCString result; - if (al==0) return result; - ArgumentListIterator ali(*al); - const Argument *a=ali.current(); + if (!al.hasParameters()) return result; result+="("; - while (a) + for (auto it = al.begin() ; it!=al.end() ;) { - QCString type1 = useCanonicalType && !a->canType.isEmpty() ? - a->canType : a->type; + Argument a = *it; + QCString type1 = useCanonicalType && !a.canType.isEmpty() ? a.canType : a.type; QCString type2; int i=type1.find(")("); // hack to deal with function pointers if (i!=-1) @@ -2278,86 +2276,84 @@ QCString argListToString(const ArgumentList *al,bool useCanonicalType,bool showD type2=type1.mid(i); type1=type1.left(i); } - if (!a->attrib.isEmpty()) + if (!a.attrib.isEmpty()) { - result+=a->attrib+" "; + result+=a.attrib+" "; } - if (!a->name.isEmpty() || !a->array.isEmpty()) + if (!a.name.isEmpty() || !a.array.isEmpty()) { - result+= type1+" "+a->name+type2+a->array; + result+= type1+" "+a.name+type2+a.array; } else { result+= type1+type2; } - if (!a->defval.isEmpty() && showDefVals) + if (!a.defval.isEmpty() && showDefVals) { - result+="="+a->defval; + result+="="+a.defval; } - ++ali; - a = ali.current(); - if (a) result+=", "; + ++it; + if (it!=al.end()) result+=", "; } result+=")"; - if (al->constSpecifier) result+=" const"; - if (al->volatileSpecifier) result+=" volatile"; - if (al->refQualifier==RefQualifierLValue) result+=" &"; - else if (al->refQualifier==RefQualifierRValue) result+=" &&"; - if (!al->trailingReturnType.isEmpty()) result+=" -> "+al->trailingReturnType; - if (al->pureSpecifier) result+=" =0"; + if (al.constSpecifier) result+=" const"; + if (al.volatileSpecifier) result+=" volatile"; + if (al.refQualifier==RefQualifierLValue) result+=" &"; + else if (al.refQualifier==RefQualifierRValue) result+=" &&"; + if (!al.trailingReturnType.isEmpty()) result+=" -> "+al.trailingReturnType; + if (al.pureSpecifier) result+=" =0"; return removeRedundantWhiteSpace(result); } -QCString tempArgListToString(const ArgumentList *al,SrcLangExt lang) +QCString tempArgListToString(const ArgumentList &al,SrcLangExt lang) { QCString result; - if (al==0) return result; + if (al.empty()) return result; result="<"; - ArgumentListIterator ali(*al); - const Argument *a=ali.current(); - while (a) + auto it = al.begin(); + while (it!=al.end()) { - if (!a->name.isEmpty()) // add template argument name + Argument a = *it; + if (!a.name.isEmpty()) // add template argument name { - if (a->type.left(4)=="out") // C# covariance + if (a.type.left(4)=="out") // C# covariance { result+="out "; } - else if (a->type.left(3)=="in") // C# contravariance + else if (a.type.left(3)=="in") // C# contravariance { result+="in "; } if (lang==SrcLangExt_Java || lang==SrcLangExt_CSharp) { - result+=a->type+" "; + result+=a.type+" "; } - result+=a->name; + result+=a.name; } else // extract name from type { - int i=a->type.length()-1; - while (i>=0 && isId(a->type.at(i))) i--; + int i=a.type.length()-1; + while (i>=0 && isId(a.type.at(i))) i--; if (i>0) { - result+=a->type.right(a->type.length()-i-1); - if (a->type.find("...")!=-1) + result+=a.type.right(a.type.length()-i-1); + if (a.type.find("...")!=-1) { result+="..."; } } else // nothing found -> take whole name { - result+=a->type; + result+=a.type; } } - if (!a->typeConstraint.isEmpty() && lang==SrcLangExt_Java) + if (!a.typeConstraint.isEmpty() && lang==SrcLangExt_Java) { result+=" extends "; // TODO: now Java specific, C# has where... - result+=a->typeConstraint; + result+=a.typeConstraint; } - ++ali; - a=ali.current(); - if (a) result+=", "; + ++it; + if (it!=al.end()) result+=", "; } result+=">"; return removeRedundantWhiteSpace(result); @@ -2590,7 +2586,7 @@ QCString fileToString(const char *name,bool filter,bool isSourceCode) return ""; } -QCString dateToString(bool includeTime) +static QDateTime getCurrentDateTime() { QDateTime current = QDateTime::currentDateTime(); QCString sourceDateEpoch = portable_getenv("SOURCE_DATE_EPOCH"); @@ -2622,6 +2618,12 @@ QCString dateToString(bool includeTime) current.setTimeUtc_t((ulong)epoch); // TODO: add support for 64bit epoch value } } + return current; +} + +QCString dateToString(bool includeTime) +{ + const QDateTime current = getCurrentDateTime(); return theTranslator->trDateTime(current.date().year(), current.date().month(), current.date().day(), @@ -2634,9 +2636,9 @@ QCString dateToString(bool includeTime) QCString yearToString() { - const QDate &d=QDate::currentDate(); + const QDateTime current = getCurrentDateTime(); QCString result; - result.sprintf("%d", d.year()); + result.sprintf("%d", current.date().year()); return result; } @@ -2705,19 +2707,6 @@ exit: return prot; } -//static void printArgList(ArgumentList *al) -//{ -// if (al==0) return; -// ArgumentListIterator ali(*al); -// Argument *a; -// printf("("); -// for (;(a=ali.current());++ali) -// { -// printf("t='%s' n='%s' v='%s' ",a->type.data(),!a->name.isEmpty()>0?a->name.data():"",!a->defval.isEmpty()>0?a->defval.data():""); -// } -// printf(")"); -//} - #ifndef NEWMATCH // strip any template specifiers that follow className in string s static QCString trimTemplateSpecifiers( @@ -3311,138 +3300,6 @@ static bool matchArgument(const Argument *srcA,const Argument *dstA, return TRUE; } - -/*! - * Matches the arguments list srcAl with the argument list dstAl - * Returns TRUE if the argument lists are equal. Two argument list are - * considered equal if the number of arguments is equal and the types of all - * arguments are equal. Furthermore the const and volatile specifiers - * stored in the list should be equal. - */ -bool matchArguments(ArgumentList *srcAl,ArgumentList *dstAl, - const char *cl,const char *ns,bool checkCV, - NamespaceSDict *usingNamespaces, - SDict<Definition> *usingClasses) -{ - QCString className=cl; - QCString namespaceName=ns; - - // strip template specialization from class name if present - //int til=className.find('<'),tir=className.find('>'); - //if (til!=-1 && tir!=-1 && tir>til) - //{ - // className=className.left(til)+className.right(className.length()-tir-1); - //} - - //printf("matchArguments(%s,%s) className=%s namespaceName=%s checkCV=%d usingNamespaces=%d usingClasses=%d\n", - // srcAl ? argListToString(srcAl).data() : "", - // dstAl ? argListToString(dstAl).data() : "", - // cl,ns,checkCV, - // usingNamespaces?usingNamespaces->count():0, - // usingClasses?usingClasses->count():0 - // ); - - if (srcAl==0 || dstAl==0) - { - bool match = srcAl==dstAl; // at least one of the members is not a function - if (match) - { - MATCH - return TRUE; - } - else - { - NOMATCH - return FALSE; - } - } - - // handle special case with void argument - if ( srcAl->count()==0 && dstAl->count()==1 && - dstAl->getFirst()->type=="void" ) - { // special case for finding match between func() and func(void) - Argument *a=new Argument; - a->type = "void"; - srcAl->append(a); - MATCH - return TRUE; - } - if ( dstAl->count()==0 && srcAl->count()==1 && - srcAl->getFirst()->type=="void" ) - { // special case for finding match between func(void) and func() - Argument *a=new Argument; - a->type = "void"; - dstAl->append(a); - MATCH - return TRUE; - } - - if (srcAl->count() != dstAl->count()) - { - NOMATCH - return FALSE; // different number of arguments -> no match - } - - if (checkCV) - { - if (srcAl->constSpecifier != dstAl->constSpecifier) - { - NOMATCH - return FALSE; // one member is const, the other not -> no match - } - if (srcAl->volatileSpecifier != dstAl->volatileSpecifier) - { - NOMATCH - return FALSE; // one member is volatile, the other not -> no match - } - } - - if (srcAl->refQualifier != dstAl->refQualifier) - { - NOMATCH - return FALSE; // one member is has a different ref-qualifier than the other - } - - // so far the argument list could match, so we need to compare the types of - // all arguments. - ArgumentListIterator srcAli(*srcAl),dstAli(*dstAl); - Argument *srcA,*dstA; - for (;(srcA=srcAli.current()) && (dstA=dstAli.current());++srcAli,++dstAli) - { - if (!matchArgument(srcA,dstA,className,namespaceName, - usingNamespaces,usingClasses)) - { - NOMATCH - return FALSE; - } - } - MATCH - return TRUE; // all arguments match -} - -#endif - -#if 0 -static QCString resolveSymbolName(FileDef *fs,Definition *symbol,QCString &templSpec) -{ - ASSERT(symbol!=0); - if (symbol->definitionType()==Definition::TypeMember && - ((MemberDef*)symbol)->isTypedef()) // if symbol is a typedef then try - // to resolve it - { - MemberDef *md = 0; - ClassDef *cd = newResolveTypedef(fs,(MemberDef*)symbol,&md,&templSpec); - if (cd) - { - return cd->qualifiedName()+templSpec; - } - else if (md) - { - return md->qualifiedName(); - } - } - return symbol->qualifiedName(); -} #endif static QCString stripDeclKeywords(const QCString &s) @@ -3688,10 +3545,10 @@ static QCString extractCanonicalType(const Definition *d,const FileDef *fs,QCStr return removeRedundantWhiteSpace(canType); } -static QCString extractCanonicalArgType(const Definition *d,const FileDef *fs,const Argument *arg) +static QCString extractCanonicalArgType(const Definition *d,const FileDef *fs,const Argument &arg) { - QCString type = arg->type.stripWhiteSpace(); - QCString name = arg->name; + QCString type = arg.type.stripWhiteSpace(); + QCString name = arg.name; //printf("----- extractCanonicalArgType(type=%s,name=%s)\n",type.data(),name.data()); if ((type=="const" || type=="volatile") && !name.isEmpty()) { // name is part of type => correct @@ -3703,17 +3560,17 @@ static QCString extractCanonicalArgType(const Definition *d,const FileDef *fs,co if (!type.isEmpty()) type+=" "; type+=name; } - if (!arg->array.isEmpty()) + if (!arg.array.isEmpty()) { - type+=arg->array; + type+=arg.array; } return extractCanonicalType(d,fs,type); } static bool matchArgument2( - const Definition *srcScope,const FileDef *srcFileScope,Argument *srcA, - const Definition *dstScope,const FileDef *dstFileScope,Argument *dstA + const Definition *srcScope,const FileDef *srcFileScope,Argument &srcA, + const Definition *dstScope,const FileDef *dstFileScope,Argument &dstA ) { //printf(">> match argument: %s::'%s|%s' (%s) <-> %s::'%s|%s' (%s)\n", @@ -3727,37 +3584,37 @@ static bool matchArgument2( // NOMATCH // return FALSE; //} - QCString sSrcName = " "+srcA->name; - QCString sDstName = " "+dstA->name; - QCString srcType = srcA->type; - QCString dstType = dstA->type; + QCString sSrcName = " "+srcA.name; + QCString sDstName = " "+dstA.name; + QCString srcType = srcA.type; + QCString dstType = dstA.type; stripIrrelevantConstVolatile(srcType); stripIrrelevantConstVolatile(dstType); //printf("'%s'<->'%s'\n",sSrcName.data(),dstType.right(sSrcName.length()).data()); //printf("'%s'<->'%s'\n",sDstName.data(),srcType.right(sDstName.length()).data()); if (sSrcName==dstType.right(sSrcName.length())) { // case "unsigned int" <-> "unsigned int i" - srcA->type+=sSrcName; - srcA->name=""; - srcA->canType=""; // invalidate cached type value + srcA.type+=sSrcName; + srcA.name=""; + srcA.canType=""; // invalidate cached type value } else if (sDstName==srcType.right(sDstName.length())) { // case "unsigned int i" <-> "unsigned int" - dstA->type+=sDstName; - dstA->name=""; - dstA->canType=""; // invalidate cached type value + dstA.type+=sDstName; + dstA.name=""; + dstA.canType=""; // invalidate cached type value } - if (srcA->canType.isEmpty()) + if (srcA.canType.isEmpty()) { - srcA->canType = extractCanonicalArgType(srcScope,srcFileScope,srcA); + srcA.canType = extractCanonicalArgType(srcScope,srcFileScope,srcA); } - if (dstA->canType.isEmpty()) + if (dstA.canType.isEmpty()) { - dstA->canType = extractCanonicalArgType(dstScope,dstFileScope,dstA); + dstA.canType = extractCanonicalArgType(dstScope,dstFileScope,dstA); } - if (srcA->canType==dstA->canType) + if (srcA.canType==dstA.canType) { MATCH return TRUE; @@ -3773,49 +3630,34 @@ static bool matchArgument2( // new algorithm for argument matching -bool matchArguments2(const Definition *srcScope,const FileDef *srcFileScope,const ArgumentList *srcAl, - const Definition *dstScope,const FileDef *dstFileScope,const ArgumentList *dstAl, +bool matchArguments2(const Definition *srcScope,const FileDef *srcFileScope,const ArgumentList &inSrcAl, + const Definition *dstScope,const FileDef *dstFileScope,const ArgumentList &inDstAl, bool checkCV) { - //printf("*** matchArguments2\n"); ASSERT(srcScope!=0 && dstScope!=0); - if (srcAl==0 || dstAl==0) - { - bool match = srcAl==dstAl; // at least one of the members is not a function - if (match) - { - MATCH - return TRUE; - } - else - { - NOMATCH - return FALSE; - } - } + ArgumentList srcAl = inSrcAl; + ArgumentList dstAl = inDstAl; // handle special case with void argument - if ( srcAl->count()==0 && dstAl->count()==1 && - dstAl->getFirst()->type=="void" ) + if ( srcAl.empty() && dstAl.size()==1 && dstAl.front().type=="void" ) { // special case for finding match between func() and func(void) - Argument *a=new Argument; - a->type = "void"; - const_cast<ArgumentList*>(srcAl)->append(a); + Argument a; + a.type = "void"; + srcAl.push_back(a); MATCH return TRUE; } - if ( dstAl->count()==0 && srcAl->count()==1 && - srcAl->getFirst()->type=="void" ) + if ( dstAl.empty() && srcAl.size()==1 && srcAl.front().type=="void" ) { // special case for finding match between func(void) and func() - Argument *a=new Argument; - a->type = "void"; - const_cast<ArgumentList*>(dstAl)->append(a); + Argument a; + a.type = "void"; + dstAl.push_back(a); MATCH return TRUE; } - if (srcAl->count() != dstAl->count()) + if (srcAl.size() != dstAl.size()) { NOMATCH return FALSE; // different number of arguments -> no match @@ -3823,19 +3665,19 @@ bool matchArguments2(const Definition *srcScope,const FileDef *srcFileScope,cons if (checkCV) { - if (srcAl->constSpecifier != dstAl->constSpecifier) + if (srcAl.constSpecifier != dstAl.constSpecifier) { NOMATCH return FALSE; // one member is const, the other not -> no match } - if (srcAl->volatileSpecifier != dstAl->volatileSpecifier) + if (srcAl.volatileSpecifier != dstAl.volatileSpecifier) { NOMATCH return FALSE; // one member is volatile, the other not -> no match } } - if (srcAl->refQualifier != dstAl->refQualifier) + if (srcAl.refQualifier != dstAl.refQualifier) { NOMATCH return FALSE; // one member is has a different ref-qualifier than the other @@ -3843,10 +3685,12 @@ bool matchArguments2(const Definition *srcScope,const FileDef *srcFileScope,cons // so far the argument list could match, so we need to compare the types of // all arguments. - ArgumentListIterator srcAli(*srcAl),dstAli(*dstAl); - Argument *srcA,*dstA; - for (;(srcA=srcAli.current()) && (dstA=dstAli.current());++srcAli,++dstAli) - { + auto srcIt = srcAl.begin(); + auto dstIt = dstAl.begin(); + for (;srcIt!=srcAl.end() && dstIt!=dstAl.end();++srcIt,++dstIt) + { + Argument &srcA = *srcIt; + Argument &dstA = *dstIt; if (!matchArgument2(srcScope,srcFileScope,srcA, dstScope,dstFileScope,dstA) ) @@ -3863,134 +3707,139 @@ bool matchArguments2(const Definition *srcScope,const FileDef *srcFileScope,cons // merges the initializer of two argument lists // pre: the types of the arguments in the list should match. -void mergeArguments(ArgumentList *srcAl,ArgumentList *dstAl,bool forceNameOverwrite) +void mergeArguments(ArgumentList &srcAl,ArgumentList &dstAl,bool forceNameOverwrite) { //printf("mergeArguments '%s', '%s'\n", // argListToString(srcAl).data(),argListToString(dstAl).data()); - if (srcAl==0 || dstAl==0 || srcAl->count()!=dstAl->count()) + if (srcAl.size()!=dstAl.size()) { return; // invalid argument lists -> do not merge } - ArgumentListIterator srcAli(*srcAl),dstAli(*dstAl); - Argument *srcA,*dstA; - for (;(srcA=srcAli.current()) && (dstA=dstAli.current());++srcAli,++dstAli) + auto srcIt=srcAl.begin(); + auto dstIt=dstAl.begin(); + while (srcIt!=srcAl.end() && dstIt!=dstAl.end()) { - if (srcA->defval.isEmpty() && !dstA->defval.isEmpty()) + Argument &srcA = *srcIt; + Argument &dstA = *dstIt; + + if (srcA.defval.isEmpty() && !dstA.defval.isEmpty()) { - //printf("Defval changing '%s'->'%s'\n",srcA->defval.data(),dstA->defval.data()); - srcA->defval=dstA->defval.copy(); + //printf("Defval changing '%s'->'%s'\n",srcA.defval.data(),dstA.defval.data()); + srcA.defval=dstA.defval; } - else if (!srcA->defval.isEmpty() && dstA->defval.isEmpty()) + else if (!srcA.defval.isEmpty() && dstA.defval.isEmpty()) { - //printf("Defval changing '%s'->'%s'\n",dstA->defval.data(),srcA->defval.data()); - dstA->defval=srcA->defval.copy(); + //printf("Defval changing '%s'->'%s'\n",dstA.defval.data(),srcA.defval.data()); + dstA.defval=srcA.defval; } // fix wrongly detected const or volatile specifiers before merging. // example: "const A *const" is detected as type="const A *" name="const" - if (srcA->name=="const" || srcA->name=="volatile") + if (srcA.name=="const" || srcA.name=="volatile") { - srcA->type+=" "+srcA->name; - srcA->name.resize(0); + srcA.type+=" "+srcA.name; + srcA.name.resize(0); } - if (dstA->name=="const" || dstA->name=="volatile") + if (dstA.name=="const" || dstA.name=="volatile") { - dstA->type+=" "+dstA->name; - dstA->name.resize(0); + dstA.type+=" "+dstA.name; + dstA.name.resize(0); } - if (srcA->type==dstA->type) + if (srcA.type==dstA.type) { - //printf("1. merging %s:%s <-> %s:%s\n",srcA->type.data(),srcA->name.data(),dstA->type.data(),dstA->name.data()); - if (srcA->name.isEmpty() && !dstA->name.isEmpty()) + //printf("1. merging %s:%s <-> %s:%s\n",srcA.type.data(),srcA.name.data(),dstA.type.data(),dstA.name.data()); + if (srcA.name.isEmpty() && !dstA.name.isEmpty()) { - //printf("type: '%s':='%s'\n",srcA->type.data(),dstA->type.data()); - //printf("name: '%s':='%s'\n",srcA->name.data(),dstA->name.data()); - srcA->type = dstA->type.copy(); - srcA->name = dstA->name.copy(); + //printf("type: '%s':='%s'\n",srcA.type.data(),dstA.type.data()); + //printf("name: '%s':='%s'\n",srcA.name.data(),dstA.name.data()); + srcA.type = dstA.type; + srcA.name = dstA.name; } - else if (!srcA->name.isEmpty() && dstA->name.isEmpty()) + else if (!srcA.name.isEmpty() && dstA.name.isEmpty()) { - //printf("type: '%s':='%s'\n",dstA->type.data(),srcA->type.data()); - //printf("name: '%s':='%s'\n",dstA->name.data(),srcA->name.data()); - dstA->type = srcA->type.copy(); - dstA->name = dstA->name.copy(); + //printf("type: '%s':='%s'\n",dstA.type.data(),srcA.type.data()); + //printf("name: '%s':='%s'\n",dstA.name.data(),srcA.name.data()); + dstA.type = srcA.type; + dstA.name = dstA.name; } - else if (!srcA->name.isEmpty() && !dstA->name.isEmpty()) + else if (!srcA.name.isEmpty() && !dstA.name.isEmpty()) { - //printf("srcA->name=%s dstA->name=%s\n",srcA->name.data(),dstA->name.data()); + //printf("srcA.name=%s dstA.name=%s\n",srcA.name.data(),dstA.name.data()); if (forceNameOverwrite) { - srcA->name = dstA->name; + srcA.name = dstA.name; } else { - if (srcA->docs.isEmpty() && !dstA->docs.isEmpty()) + if (srcA.docs.isEmpty() && !dstA.docs.isEmpty()) { - srcA->name = dstA->name; + srcA.name = dstA.name; } - else if (!srcA->docs.isEmpty() && dstA->docs.isEmpty()) + else if (!srcA.docs.isEmpty() && dstA.docs.isEmpty()) { - dstA->name = srcA->name; + dstA.name = srcA.name; } } } } else { - //printf("2. merging '%s':'%s' <-> '%s':'%s'\n",srcA->type.data(),srcA->name.data(),dstA->type.data(),dstA->name.data()); - srcA->type=srcA->type.stripWhiteSpace(); - dstA->type=dstA->type.stripWhiteSpace(); - if (srcA->type+" "+srcA->name==dstA->type) // "unsigned long:int" <-> "unsigned long int:bla" + //printf("2. merging '%s':'%s' <-> '%s':'%s'\n",srcA.type.data(),srcA.name.data(),dstA.type.data(),dstA.name.data()); + srcA.type=srcA.type.stripWhiteSpace(); + dstA.type=dstA.type.stripWhiteSpace(); + if (srcA.type+" "+srcA.name==dstA.type) // "unsigned long:int" <-> "unsigned long int:bla" { - srcA->type+=" "+srcA->name; - srcA->name=dstA->name; + srcA.type+=" "+srcA.name; + srcA.name=dstA.name; } - else if (dstA->type+" "+dstA->name==srcA->type) // "unsigned long int bla" <-> "unsigned long int" + else if (dstA.type+" "+dstA.name==srcA.type) // "unsigned long int bla" <-> "unsigned long int" { - dstA->type+=" "+dstA->name; - dstA->name=srcA->name; + dstA.type+=" "+dstA.name; + dstA.name=srcA.name; } - else if (srcA->name.isEmpty() && !dstA->name.isEmpty()) + else if (srcA.name.isEmpty() && !dstA.name.isEmpty()) { - srcA->name = dstA->name; + srcA.name = dstA.name; } - else if (dstA->name.isEmpty() && !srcA->name.isEmpty()) + else if (dstA.name.isEmpty() && !srcA.name.isEmpty()) { - dstA->name = srcA->name; + dstA.name = srcA.name; } } - int i1=srcA->type.find("::"), - i2=dstA->type.find("::"), - j1=srcA->type.length()-i1-2, - j2=dstA->type.length()-i2-2; - if (i1!=-1 && i2==-1 && srcA->type.right(j1)==dstA->type) + int i1=srcA.type.find("::"), + i2=dstA.type.find("::"), + j1=srcA.type.length()-i1-2, + j2=dstA.type.length()-i2-2; + if (i1!=-1 && i2==-1 && srcA.type.right(j1)==dstA.type) { - //printf("type: '%s':='%s'\n",dstA->type.data(),srcA->type.data()); - //printf("name: '%s':='%s'\n",dstA->name.data(),srcA->name.data()); - dstA->type = srcA->type.left(i1+2)+dstA->type; - dstA->name = dstA->name.copy(); + //printf("type: '%s':='%s'\n",dstA.type.data(),srcA.type.data()); + //printf("name: '%s':='%s'\n",dstA.name.data(),srcA.name.data()); + dstA.type = srcA.type.left(i1+2)+dstA.type; + dstA.name = dstA.name; } - else if (i1==-1 && i2!=-1 && dstA->type.right(j2)==srcA->type) + else if (i1==-1 && i2!=-1 && dstA.type.right(j2)==srcA.type) { - //printf("type: '%s':='%s'\n",srcA->type.data(),dstA->type.data()); - //printf("name: '%s':='%s'\n",dstA->name.data(),srcA->name.data()); - srcA->type = dstA->type.left(i2+2)+srcA->type; - srcA->name = dstA->name.copy(); + //printf("type: '%s':='%s'\n",srcA.type.data(),dstA.type.data()); + //printf("name: '%s':='%s'\n",dstA.name.data(),srcA.name.data()); + srcA.type = dstA.type.left(i2+2)+srcA.type; + srcA.name = dstA.name; } - if (srcA->docs.isEmpty() && !dstA->docs.isEmpty()) + if (srcA.docs.isEmpty() && !dstA.docs.isEmpty()) { - srcA->docs = dstA->docs.copy(); + srcA.docs = dstA.docs; } - else if (dstA->docs.isEmpty() && !srcA->docs.isEmpty()) + else if (dstA.docs.isEmpty() && !srcA.docs.isEmpty()) { - dstA->docs = srcA->docs.copy(); + dstA.docs = srcA.docs; } //printf("Merge argument '%s|%s' '%s|%s'\n", - // srcA->type.data(),srcA->name.data(), - // dstA->type.data(),dstA->name.data()); + // srcA.type.data(),srcA.name.data(), + // dstA.type.data(),dstA.name.data()); + ++srcIt; + ++dstIt; } } @@ -4023,14 +3872,13 @@ static void findMembersWithSpecificName(MemberName *mn, ArgumentList *argList=0; if (args && !md->isDefine() && qstrcmp(args,"()")!=0) { - argList=new ArgumentList; - const ArgumentList *mdAl = md->argumentList(); + const ArgumentList &mdAl = md->argumentList(); + ArgumentList argList; stringToArgumentList(args,argList); match=matchArguments2( md->getOuterScope(),fd,mdAl, Doxygen::globalScope,fd,argList, - checkCV); - delete argList; argList=0; + checkCV); } if (match && (forceTagFile==0 || md->getReference()==forceTagFile)) { @@ -4154,22 +4002,20 @@ bool getDefs(const QCString &scName, MemberNameIterator mmli(*mn); MemberDef *mmd; int mdist=maxInheritanceDepth; - ArgumentList *argList=0; + ArgumentList argList; if (args) { - argList=new ArgumentList; stringToArgumentList(args,argList); } for (mmli.toFirst();(mmd=mmli.current());++mmli) { if (!mmd->isStrongEnumValue()) { - ArgumentList *mmdAl = mmd->argumentList(); - bool match=args==0 || + const ArgumentList &mmdAl = mmd->argumentList(); + bool match=args==0 || matchArguments2(mmd->getOuterScope(),mmd->getFileDef(),mmdAl, - fcd,fcd->getFileDef(),argList, - checkCV - ); + fcd, fcd->getFileDef(),argList, + checkCV); //printf("match=%d\n",match); if (match) { @@ -4187,10 +4033,6 @@ bool getDefs(const QCString &scName, } } } - if (argList) - { - delete argList; argList=0; - } if (mdist==maxInheritanceDepth && args && qstrcmp(args,"()")==0) // no exact match found, but if args="()" an arbitrary member will do { @@ -4277,33 +4119,43 @@ bool getDefs(const QCString &scName, //printf("Global symbol\n"); MemberNameIterator mmli(*mn); MemberDef *mmd, *fuzzy_mmd = 0; - ArgumentList *argList = 0; + ArgumentList argList; bool hasEmptyArgs = args && qstrcmp(args, "()") == 0; if (args) - stringToArgumentList(args, argList = new ArgumentList); + { + stringToArgumentList(args, argList); + } for (mmli.toFirst(); (mmd = mmli.current()); ++mmli) { if (!mmd->isLinkable() || (!mmd->isRelated() && !mmd->isForeign()) || !mmd->getClassDef()) + { continue; + } - if (!args) break; + if (!args) + { + break; + } - ArgumentList *mmdAl = mmd->argumentList(); + ArgumentList &mmdAl = mmd->argumentList(); if (matchArguments2(mmd->getOuterScope(),mmd->getFileDef(),mmdAl, Doxygen::globalScope,mmd->getFileDef(),argList, checkCV ) - ) break; + ) + { + break; + } if (!fuzzy_mmd && hasEmptyArgs) + { fuzzy_mmd = mmd; + } } - if (argList) delete argList, argList = 0; - mmd = mmd ? mmd : fuzzy_mmd; if (mmd && !mmd->isStrongEnumValue()) @@ -4371,16 +4223,15 @@ bool getDefs(const QCString &scName, else if (mmd->getOuterScope()==fnd /* && mmd->isLinkable() */ ) { // namespace is found bool match=TRUE; - ArgumentList *argList=0; + ArgumentList argList; if (args && qstrcmp(args,"()")!=0) { - argList=new ArgumentList; - const ArgumentList *mmdAl = mmd->argumentList(); + const ArgumentList &mmdAl = mmd->argumentList(); stringToArgumentList(args,argList); match=matchArguments2( mmd->getOuterScope(),mmd->getFileDef(),mmdAl, fnd,mmd->getFileDef(),argList, - checkCV); + checkCV); } if (match) { @@ -4388,10 +4239,6 @@ bool getDefs(const QCString &scName, md=mmd; found=TRUE; } - if (args) - { - delete argList; argList=0; - } } } if (!found && args && !qstrcmp(args,"()")) @@ -5820,10 +5667,10 @@ QCString insertTemplateSpecifierInScope(const QCString &scope,const QCString &te int si,pi=0; ClassDef *cd=0; while ( - (si=scope.find("::",pi))!=-1 && !getClass(scope.left(si)+templ) && - ((cd=getClass(scope.left(si)))==0 || cd->templateArguments()==0) - ) - { + (si=scope.find("::",pi))!=-1 && !getClass(scope.left(si)+templ) && + ((cd=getClass(scope.left(si)))==0 || cd->templateArguments().empty()) + ) + { //printf("Tried '%s'\n",(scope.left(si)+templ).data()); pi=si+2; } @@ -6183,6 +6030,26 @@ QCString convertToJSString(const char *s, bool applyTextDir) return convertCharEntitiesToUTF8(growBuf.get()); } +QCString convertToPSString(const char *s) +{ + static GrowBuf growBuf; + growBuf.clear(); + if (s==0) return ""; + const char *p=s; + char c; + while ((c=*p++)) + { + switch (c) + { + case '(': growBuf.addStr("\\("); break; + case ')': growBuf.addStr("\\)"); break; + default: growBuf.addChar(c); break; + } + } + growBuf.addChar(0); + return growBuf.get(); +} + QCString convertToLaTeX(const QCString &s,bool insideTabbing,bool keepSpaces) { QGString result; @@ -6409,7 +6276,7 @@ int extractClassNameFromType(const QCString &type,int &pos,QCString &name,QCStri QCString normalizeNonTemplateArgumentsInString( const QCString &name, const Definition *context, - const ArgumentList * formalArgs) + const ArgumentList &formalArgs) { // skip until < int p=name.find('<'); @@ -6425,16 +6292,12 @@ QCString normalizeNonTemplateArgumentsInString( result += name.mid(p,i-p); QCString n = name.mid(i,l); bool found=FALSE; - if (formalArgs) // check that n is not a formal template argument + for (const Argument formArg : formalArgs) { - ArgumentListIterator formAli(*formalArgs); - const Argument *formArg; - for (formAli.toFirst(); - (formArg=formAli.current()) && !found; - ++formAli - ) + if (formArg.name == n) { - found = formArg->name==n; + found=TRUE; + break; } } if (!found) @@ -6470,12 +6333,12 @@ QCString normalizeNonTemplateArgumentsInString( */ QCString substituteTemplateArgumentsInString( const QCString &name, - ArgumentList *formalArgs, - ArgumentList *actualArgs) + const ArgumentList &formalArgs, + const ArgumentList &actualArgs) { //printf("substituteTemplateArgumentsInString(name=%s formal=%s actualArg=%s)\n", // name.data(),argListToString(formalArgs).data(),argListToString(actualArgs).data()); - if (formalArgs==0) return name; + if (formalArgs.empty()) return name; QCString result; static QRegExp re("[a-z_A-Z\\x80-\\xFF][a-z_A-Z0-9\\x80-\\xFF]*"); int p=0,l,i; @@ -6484,82 +6347,89 @@ QCString substituteTemplateArgumentsInString( { result += name.mid(p,i-p); QCString n = name.mid(i,l); - ArgumentListIterator formAli(*formalArgs); - ArgumentListIterator actAli(*actualArgs); - Argument *formArg; - Argument *actArg; + auto formIt = formalArgs.begin(); + auto actIt = actualArgs.begin(); // if n is a template argument, then we substitute it // for its template instance argument. bool found=FALSE; - for (formAli.toFirst(); - (formArg=formAli.current()) && !found; - ++formAli,++actAli + for (auto formIt = formalArgs.begin(); + formIt!=formalArgs.end() && !found; + ++formIt ) { - actArg = actAli.current(); - if (formArg->type.left(6)=="class " && formArg->name.isEmpty()) + Argument formArg = *formIt; + Argument actArg; + if (actIt!=actualArgs.end()) { - formArg->name = formArg->type.mid(6); - formArg->type = "class"; + actArg = *actIt; } - if (formArg->type.left(9)=="typename " && formArg->name.isEmpty()) + if (formArg.type.left(6)=="class " && formArg.name.isEmpty()) { - formArg->name = formArg->type.mid(9); - formArg->type = "typename"; + formArg.name = formArg.type.mid(6); + formArg.type = "class"; } - if (formArg->type=="class" || formArg->type=="typename" || formArg->type.left(8)=="template") + if (formArg.type.left(9)=="typename " && formArg.name.isEmpty()) + { + formArg.name = formArg.type.mid(9); + formArg.type = "typename"; + } + if (formArg.type=="class" || formArg.type=="typename" || formArg.type.left(8)=="template") { //printf("n=%s formArg->type='%s' formArg->name='%s' formArg->defval='%s'\n", // n.data(),formArg->type.data(),formArg->name.data(),formArg->defval.data()); //printf(">> formArg->name='%s' actArg->type='%s' actArg->name='%s'\n", // formArg->name.data(),actArg ? actArg->type.data() : "",actArg ? actArg->name.data() : "" // ); - if (formArg->name==n && actArg && !actArg->type.isEmpty()) // base class is a template argument + if (formArg.name==n && actIt!=actualArgs.end() && !actArg.type.isEmpty()) // base class is a template argument { // replace formal argument with the actual argument of the instance - if (!leftScopeMatch(actArg->type,n)) + if (!leftScopeMatch(actArg.type,n)) // the scope guard is to prevent recursive lockup for // template<class A> class C : public<A::T>, // where A::T would become A::T::T here, // since n==A and actArg->type==A::T // see bug595833 for an example { - if (actArg->name.isEmpty()) + if (actArg.name.isEmpty()) { - result += actArg->type+" "; + result += actArg.type+" "; found=TRUE; } else // for case where the actual arg is something like "unsigned int" // the "int" part is in actArg->name. { - result += actArg->type+" "+actArg->name+" "; + result += actArg.type+" "+actArg.name+" "; found=TRUE; } } } - else if (formArg->name==n && - actArg==0 && - !formArg->defval.isEmpty() && - formArg->defval!=name /* to prevent recursion */ + else if (formArg.name==n && + actIt==actualArgs.end() && + !formArg.defval.isEmpty() && + formArg.defval!=name /* to prevent recursion */ ) { - result += substituteTemplateArgumentsInString(formArg->defval,formalArgs,actualArgs)+" "; + result += substituteTemplateArgumentsInString(formArg.defval,formalArgs,actualArgs)+" "; found=TRUE; } } - else if (formArg->name==n && - actArg==0 && - !formArg->defval.isEmpty() && - formArg->defval!=name /* to prevent recursion */ + else if (formArg.name==n && + actIt==actualArgs.end() && + !formArg.defval.isEmpty() && + formArg.defval!=name /* to prevent recursion */ ) { - result += substituteTemplateArgumentsInString(formArg->defval,formalArgs,actualArgs)+" "; + result += substituteTemplateArgumentsInString(formArg.defval,formalArgs,actualArgs)+" "; found=TRUE; } + if (actIt!=actualArgs.end()) + { + actIt++; + } } - if (!found) + if (!found) { result += n; } @@ -6571,6 +6441,7 @@ QCString substituteTemplateArgumentsInString( return result.stripWhiteSpace(); } +#if 0 /*! Makes a deep copy of the list of argument lists \a srcLists. * Will allocate memory, that is owned by the caller. */ @@ -6587,6 +6458,7 @@ QList<ArgumentList> *copyArgumentLists(const QList<ArgumentList> *srcLists) } return dstLists; } +#endif /*! Strips template specifiers from scope \a fullName, except those * that make up specialized classes. The switch \a parentOnly @@ -6740,11 +6612,10 @@ found: PageDef *addRelatedPage(const char *name,const QCString &ptitle, const QCString &doc, - const QList<SectionInfo> * /*anchors*/, const char *fileName,int startLine, - const QList<ListItemInfo> *sli, + const std::vector<ListItemInfo> &sli, GroupDef *gd, - TagInfo *tagInfo, + const TagInfo *tagInfo, bool xref, SrcLangExt lang ) @@ -6830,30 +6701,28 @@ PageDef *addRelatedPage(const char *name,const QCString &ptitle, //---------------------------------------------------------------------------- -void addRefItem(const QList<ListItemInfo> *sli, +void addRefItem(const std::vector<ListItemInfo> &sli, const char *key, const char *prefix, const char *name,const char *title,const char *args,Definition *scope) { //printf("addRefItem(sli=%p,key=%s,prefix=%s,name=%s,title=%s,args=%s)\n",sli,key,prefix,name,title,args); - if (sli && key && key[0]!='@') // check for @ to skip anonymous stuff (see bug427012) + if (key && key[0]!='@') // check for @ to skip anonymous stuff (see bug427012) { - QListIterator<ListItemInfo> slii(*sli); - ListItemInfo *lii; - for (slii.toFirst();(lii=slii.current());++slii) + for (const ListItemInfo &lii : sli) { - RefList *refList = Doxygen::xrefLists->find(lii->type); + RefList *refList = Doxygen::xrefLists->find(lii.type); if (refList && ( // either not a built-in list or the list is enabled - (lii->type!="todo" || Config_getBool(GENERATE_TODOLIST)) && - (lii->type!="test" || Config_getBool(GENERATE_TESTLIST)) && - (lii->type!="bug" || Config_getBool(GENERATE_BUGLIST)) && - (lii->type!="deprecated" || Config_getBool(GENERATE_DEPRECATEDLIST)) + (lii.type!="todo" || Config_getBool(GENERATE_TODOLIST)) && + (lii.type!="test" || Config_getBool(GENERATE_TESTLIST)) && + (lii.type!="bug" || Config_getBool(GENERATE_BUGLIST)) && + (lii.type!="deprecated" || Config_getBool(GENERATE_DEPRECATEDLIST)) ) ) { - RefItem *item = refList->getRefItem(lii->itemId); + RefItem *item = refList->getRefItem(lii.itemId); ASSERT(item!=0); item->prefix = prefix; @@ -8025,22 +7894,20 @@ QCString expandAlias(const QCString &aliasName,const QCString &aliasValue) return result; } -void writeTypeConstraints(OutputList &ol,const Definition *d,const ArgumentList *al) +void writeTypeConstraints(OutputList &ol,const Definition *d,const ArgumentList &al) { - if (al==0) return; + if (al.empty()) return; ol.startConstraintList(theTranslator->trTypeConstraints()); - ArgumentListIterator ali(*al); - const Argument *a; - for (;(a=ali.current());++ali) + for (const Argument &a : al) { ol.startConstraintParam(); - ol.parseText(a->name); + ol.parseText(a.name); ol.endConstraintParam(); ol.startConstraintType(); - linkifyText(TextGeneratorOLImpl(ol),d,0,0,a->type); + linkifyText(TextGeneratorOLImpl(ol),d,0,0,a.type); ol.endConstraintType(); ol.startConstraintDocs(); - ol.generateDoc(d->docFile(),d->docLine(),d,0,a->docs,TRUE,FALSE); + ol.generateDoc(d->docFile(),d->docLine(),d,0,a.docs,TRUE,FALSE); ol.endConstraintDocs(); } ol.endConstraintList(); @@ -186,12 +186,12 @@ void writePageRef(OutputDocInterface &od,const char *cn,const char *mn); QCString getCanonicalTemplateSpec(const Definition *d,const FileDef *fs,const QCString& spec); -bool matchArguments2(const Definition *srcScope,const FileDef *srcFileScope,const ArgumentList *srcAl, - const Definition *dstScope,const FileDef *dstFileScope,const ArgumentList *dstAl, +bool matchArguments2(const Definition *srcScope,const FileDef *srcFileScope,const ArgumentList &srcAl, + const Definition *dstScope,const FileDef *dstFileScope,const ArgumentList &dstAl, bool checkCV ); -void mergeArguments(ArgumentList *,ArgumentList *,bool forceNameOverwrite=FALSE); +void mergeArguments(ArgumentList &,ArgumentList &,bool forceNameOverwrite=FALSE); QCString substituteClassNames(const QCString &s); @@ -232,9 +232,9 @@ inline bool isId(int c) QCString removeRedundantWhiteSpace(const QCString &s); -QCString argListToString(const ArgumentList *al,bool useCanonicalType=FALSE,bool showDefVals=TRUE); +QCString argListToString(const ArgumentList &al,bool useCanonicalType=FALSE,bool showDefVals=TRUE); -QCString tempArgListToString(const ArgumentList *al,SrcLangExt lang); +QCString tempArgListToString(const ArgumentList &al,SrcLangExt lang); QCString generateMarker(int id); @@ -291,6 +291,8 @@ QCString convertToDocBook(const char *s); QCString convertToJSString(const char *s, bool applyTextDir = true); +QCString convertToPSString(const char *s); + QCString getOverloadDocs(); void addMembersToMemberGroup(/* in,out */ MemberList *ml, @@ -303,14 +305,14 @@ int extractClassNameFromType(const QCString &type,int &pos, QCString normalizeNonTemplateArgumentsInString( const QCString &name, const Definition *context, - const ArgumentList *formalArgs); + const ArgumentList &formalArgs); QCString substituteTemplateArgumentsInString( const QCString &name, - ArgumentList *formalArgs, - ArgumentList *actualArgs); + const ArgumentList &formalArgs, + const ArgumentList &actualArgs); -QList<ArgumentList> *copyArgumentLists(const QList<ArgumentList> *srcLists); +//QList<ArgumentList> *copyArgumentLists(const QList<ArgumentList> *srcLists); QCString stripTemplateSpecifiersFromScope(const QCString &fullName, bool parentOnly=TRUE, @@ -325,18 +327,17 @@ int getScopeFragment(const QCString &s,int p,int *l); int filterCRLF(char *buf,int len); -void addRefItem(const QList<ListItemInfo> *sli,const char *prefix, +void addRefItem(const std::vector<ListItemInfo> &sli,const char *prefix, const char *key, const char *name,const char *title,const char *args,Definition *scope); PageDef *addRelatedPage(const char *name, const QCString &ptitle, const QCString &doc, - const QList<SectionInfo> *anchors, const char *fileName,int startLine, - const QList<ListItemInfo> *sli, + const std::vector<ListItemInfo> &sli = std::vector<ListItemInfo>(), GroupDef *gd=0, - TagInfo *tagInfo=0, + const TagInfo *tagInfo=0, bool xref=FALSE, SrcLangExt lang=SrcLangExt_Unknown ); @@ -405,7 +406,7 @@ const ClassDef *newResolveTypedef(const FileDef *fileScope, const MemberDef **pMemType=0, QCString *pTemplSpec=0, QCString *pResolvedType=0, - ArgumentList *actTemplParams=0); + const ArgumentList *actTemplParams=0); QCString parseCommentAsText(const Definition *scope,const MemberDef *member,const QCString &doc,const QCString &fileName,int lineNr); @@ -422,7 +423,7 @@ int countAliasArguments(const QCString argList); QCString resolveAliasCmd(const QCString aliasCmd); QCString expandAlias(const QCString &aliasName,const QCString &aliasValue); -void writeTypeConstraints(OutputList &ol,const Definition *d,const ArgumentList *al); +void writeTypeConstraints(OutputList &ol,const Definition *d,const ArgumentList &al); QCString convertCharEntitiesToUTF8(const QCString &s); diff --git a/src/vhdlcode.l b/src/vhdlcode.l index 03bf883..9f128ea 100644 --- a/src/vhdlcode.l +++ b/src/vhdlcode.l @@ -434,14 +434,10 @@ static void writeMultiLineCodeLink(CodeOutputInterface &ol, static void setParameterList(const MemberDef *md) { g_classScope = md->getClassDef() ? md->getClassDef()->name().data() : ""; - const ArgumentList *al = md->argumentList(); - if (al==0) return; - ArgumentListIterator ali(*al); - const Argument *a; - for (ali.toFirst();(a=ali.current());++ali) + for (const Argument &a: md->argumentList()) { - g_parmName = a->name.copy(); - g_parmType = a->type.copy(); + g_parmName = a.name.copy(); + g_parmType = a.type.copy(); int i = g_parmType.find('*'); if (i!=-1) g_parmType = g_parmType.left(i); i = g_parmType.find('&'); @@ -683,9 +679,8 @@ static void codifyMapLines(const char *text) static void writeFuncProto() { - QList<Argument> ql; QCString name,ret; - VhdlDocGen::parseFuncProto(g_FuncProto,ql,name,ret,FALSE); + VhdlDocGen::parseFuncProto(g_FuncProto,name,ret,FALSE); if (name.isEmpty()) { @@ -702,7 +697,7 @@ static void writeFuncProto() { temp.stripPrefix("_");// _{package body name} } - MemberDef *mdef=VhdlDocGen::findFunction(ql,name,temp,FALSE); + MemberDef *mdef=VhdlDocGen::findFunction(name,temp); if (mdef) { diff --git a/src/vhdldocgen.cpp b/src/vhdldocgen.cpp index 38a80ef..3585230 100644 --- a/src/vhdldocgen.cpp +++ b/src/vhdldocgen.cpp @@ -71,7 +71,8 @@ static QDict<QCString> g_vhdlKeyDict3(17,FALSE); static void initUCF(Entry* root,const char* type,QCString & qcs,int line,QCString & fileName,QCString & brief); static void writeUCFLink(const MemberDef* mdef,OutputList &ol); static void assignBinding(VhdlConfNode* conf); -static void addInstance(ClassDef* entity, ClassDef* arch, ClassDef *inst,Entry *cur,ClassDef* archBind=NULL); +static void addInstance(ClassDef* entity, ClassDef* arch, ClassDef *inst, + const std::unique_ptr<Entry> &cur); //---------- create svg ------------------------------------------------------------- static void createSVG(); @@ -898,12 +899,9 @@ void VhdlDocGen::findAllPackages( ClassDef *cdef) * is called in vhdlcode.l */ -MemberDef* VhdlDocGen::findFunction(const QList<Argument> &ql, - const QCString& funcname, - const QCString& package, bool /*type*/) +MemberDef* VhdlDocGen::findFunction(const QCString& funcname, const QCString& package) { MemberDef* mdef=0; - //int funcType; ClassDef *cdef=getClass(package.data()); if (cdef==0) return 0; @@ -917,40 +915,11 @@ MemberDef* VhdlDocGen::findFunction(const QList<Argument> &ql, QCString mname=mdef->name(); if ((VhdlDocGen::isProcedure(mdef) || VhdlDocGen::isVhdlFunction(mdef)) && (compareString(funcname,mname)==0)) { - ArgumentList *alp = mdef->argumentList(); - - // ArgumentList* arg2=mdef->getArgumentList(); - if (alp==0) break; - ArgumentListIterator ali(*alp); - ArgumentListIterator ali1(ql); - - if (ali.count() != ali1.count()) break; - - Argument *arg,*arg1; - int equ=0; - - for (;(arg=ali.current()) && (arg1=ali1.current());++ali,++ali1) - { - equ+=abs(compareString(arg->type,arg1->type)); - - QCString s1=arg->type; - QCString s2=arg1->type; - VhdlDocGen::deleteAllChars(s1,' '); - VhdlDocGen::deleteAllChars(s2,' '); - equ+=abs(compareString(s1,s2)); - s1=arg->attrib; - s2=arg1->attrib; - VhdlDocGen::deleteAllChars(s1,' '); - VhdlDocGen::deleteAllChars(s2,' '); - equ+=abs(compareString(s1,s2)); - // printf("\n 1. type [%s] name [%s] attrib [%s]",arg->type,arg->name,arg->attrib); - // printf("\n 2. type [%s] name [%s] attrib [%s]",arg1->type,arg1->name,arg1->attrib); - } // for - if (equ==0) return mdef; + return mdef; }//if }//for }//if - return mdef; + return 0; } //findFunction @@ -1152,15 +1121,12 @@ void VhdlDocGen::prepareComment(QCString& qcs) /*! * parses a function proto * @param text function string - * @param qlist stores the function types * @param name points to the function name * @param ret Stores the return type * @param doc ??? */ -void VhdlDocGen::parseFuncProto(const char* text,QList<Argument>& qlist, - QCString& name,QCString& ret,bool doc) +void VhdlDocGen::parseFuncProto(const char* text,QCString& name,QCString& ret,bool doc) { - (void)qlist; //unused int index,end; QCString s1(text); QCString temp; @@ -1449,44 +1415,43 @@ void VhdlDocGen::formatString(const QCString &s, OutputList& ol,const MemberDef* * writes a procedure prototype to the output */ -void VhdlDocGen::writeProcedureProto(OutputList& ol,const ArgumentList* al,const MemberDef* mdef) +void VhdlDocGen::writeProcedureProto(OutputList& ol,const ArgumentList &al,const MemberDef* mdef) { - ArgumentListIterator ali(*al); - Argument *arg; bool sem=FALSE; - int len=al->count(); + int len=al.size(); ol.docify("( "); if (len > 2) { ol.lineBreak(); } - for (;(arg=ali.current());++ali) + for (const Argument &arg : al) { ol.startBold(); if (sem && len <3) ol.writeChar(','); - QCString nn=arg->name; + QCString nn=arg.name; nn+=": "; - QCString *str=VhdlDocGen::findKeyWord(arg->defval); - arg->defval+=" "; + QCString defval = arg.defval; + QCString *str=VhdlDocGen::findKeyWord(defval); + defval+=" "; if (str) { - startFonts(arg->defval,str->data(),ol); + startFonts(defval,str->data(),ol); } else { - startFonts(arg->defval,"vhdlchar",ol); // write type (variable,constant etc.) + startFonts(defval,"vhdlchar",ol); // write type (variable,constant etc.) } startFonts(nn,"vhdlchar",ol); // write name - if (qstricmp(arg->attrib,arg->type) != 0) + if (qstricmp(arg.attrib,arg.type) != 0) { - startFonts(arg->attrib.lower(),"stringliteral",ol); // write in|out + startFonts(arg.attrib.lower(),"stringliteral",ol); // write in|out } ol.docify(" "); - VhdlDocGen::formatString(arg->type,ol,mdef); + VhdlDocGen::formatString(arg.type,ol,mdef); sem=TRUE; ol.endBold(); if (len > 2) @@ -1505,13 +1470,11 @@ void VhdlDocGen::writeProcedureProto(OutputList& ol,const ArgumentList* al,const * writes a function prototype to the output */ -void VhdlDocGen::writeFunctionProto(OutputList& ol,const ArgumentList* al,const MemberDef* mdef) +void VhdlDocGen::writeFunctionProto(OutputList& ol,const ArgumentList &al,const MemberDef* mdef) { - if (al==0) return; - ArgumentListIterator ali(*al); - Argument *arg; + if (!al.hasParameters()) return; bool sem=FALSE; - int len=al->count(); + int len=al.size(); ol.startBold(); ol.docify(" ( "); ol.endBold(); @@ -1519,10 +1482,10 @@ void VhdlDocGen::writeFunctionProto(OutputList& ol,const ArgumentList* al,const { ol.lineBreak(); } - for (;(arg=ali.current());++ali) + for (const Argument &arg : al) { ol.startBold(); - QCString att=arg->defval; + QCString att=arg.defval; bool bGen=att.stripPrefix("gen!"); if (sem && len < 3) @@ -1544,9 +1507,9 @@ void VhdlDocGen::writeFunctionProto(OutputList& ol,const ArgumentList* al,const startFonts(att,"vhdlchar",ol); } - QCString nn=arg->name; + QCString nn=arg.name; nn+=": "; - QCString ss=arg->type.stripWhiteSpace(); //.lower(); + QCString ss=arg.type.stripWhiteSpace(); //.lower(); QCString w=ss.stripWhiteSpace();//.upper(); startFonts(nn,"vhdlchar",ol); startFonts("in ","stringliteral",ol); @@ -1556,9 +1519,8 @@ void VhdlDocGen::writeFunctionProto(OutputList& ol,const ArgumentList* al,const else startFonts(w,"vhdlchar",ol); - if (arg->attrib) - startFonts(arg->attrib,"vhdlchar",ol); - + if (arg.attrib) + startFonts(arg.attrib,"vhdlchar",ol); sem=TRUE; ol.endBold(); @@ -1586,21 +1548,19 @@ void VhdlDocGen::writeFunctionProto(OutputList& ol,const ArgumentList* al,const * writes a process prototype to the output */ -void VhdlDocGen::writeProcessProto(OutputList& ol,const ArgumentList* al,const MemberDef* mdef) +void VhdlDocGen::writeProcessProto(OutputList& ol,const ArgumentList &al,const MemberDef* mdef) { - if (al==0) return; - ArgumentListIterator ali(*al); - Argument *arg; + if (!al.hasParameters()) return; bool sem=FALSE; ol.startBold(); ol.docify(" ( "); - for (;(arg=ali.current());++ali) + for (const Argument &arg : al) { if (sem) { ol.docify(" , "); } - QCString nn=arg->name; + QCString nn=arg.name; // startFonts(nn,"vhdlchar",ol); VhdlDocGen::writeFormatString(nn,ol,mdef); sem=TRUE; @@ -1617,15 +1577,13 @@ void VhdlDocGen::writeProcessProto(OutputList& ol,const ArgumentList* al,const M bool VhdlDocGen::writeFuncProcDocu( const MemberDef *md, OutputList& ol, - const ArgumentList* al, + const ArgumentList &al, bool /*type*/) { - if (al==0) return FALSE; //bool sem=FALSE; ol.enableAll(); - ArgumentListIterator ali(*al); - int index=ali.count(); + int index=al.size(); if (index==0) { ol.docify(" ( ) "); @@ -1634,13 +1592,12 @@ bool VhdlDocGen::writeFuncProcDocu( ol.endMemberDocName(); ol.startParameterList(TRUE); //ol.startParameterName(FALSE); - Argument *arg; bool first=TRUE; - for (;(arg=ali.current());++ali) + for (const Argument &arg : al) { ol.startParameterType(first,""); // if (first) ol.writeChar('('); - QCString attl=arg->defval; + QCString attl=arg.defval; bool bGen=attl.stripPrefix("gen!"); if (bGen) VhdlDocGen::writeFormatString(QCString("generic "),ol,md); @@ -1648,17 +1605,17 @@ bool VhdlDocGen::writeFuncProcDocu( if (VhdlDocGen::isProcedure(md)) { - startFonts(arg->defval,"keywordtype",ol); + startFonts(arg.defval,"keywordtype",ol); ol.docify(" "); } ol.endParameterType(); ol.startParameterName(TRUE); - VhdlDocGen::writeFormatString(arg->name,ol,md); + VhdlDocGen::writeFormatString(arg.name,ol,md); if (VhdlDocGen::isProcedure(md)) { - startFonts(arg->attrib,"stringliteral",ol); + startFonts(arg.attrib,"stringliteral",ol); } else if (VhdlDocGen::isVhdlFunction(md)) { @@ -1671,8 +1628,8 @@ bool VhdlDocGen::writeFuncProcDocu( ol.enable(OutputGenerator::Man); if (!VhdlDocGen::isProcess(md)) { - // startFonts(arg->type,"vhdlkeyword",ol); - VhdlDocGen::writeFormatString(arg->type,ol,md); + // startFonts(arg.type,"vhdlkeyword",ol); + VhdlDocGen::writeFormatString(arg.type,ol,md); } ol.disable(OutputGenerator::Man); ol.endEmphasis(); @@ -1701,28 +1658,26 @@ bool VhdlDocGen::writeFuncProcDocu( -QCString VhdlDocGen::convertArgumentListToString(const ArgumentList* al,bool func) +QCString VhdlDocGen::convertArgumentListToString(const ArgumentList &al,bool func) { QCString argString; bool sem=FALSE; - ArgumentListIterator ali(*al); - Argument *arg; - for (;(arg=ali.current());++ali) + for (const Argument &arg : al) { if (sem) argString.append(", "); if (func) { - argString+=arg->name; + argString+=arg.name; argString+=":"; - argString+=arg->type; + argString+=arg.type; } else { - argString+=arg->defval+" "; - argString+=arg->name+" :"; - argString+=arg->attrib+" "; - argString+=arg->type; + argString+=arg.defval+" "; + argString+=arg.name+" :"; + argString+=arg.attrib+" "; + argString+=arg.type; } sem=TRUE; } @@ -2002,7 +1957,7 @@ void VhdlDocGen::writeVHDLDeclaration(const MemberDef* mdef,OutputList &ol, QCString ltype(mdef->typeString()); QCString largs(mdef->argsString()); ClassDef *kl=0; - const ArgumentList *alp = mdef->argumentList(); + const ArgumentList &al = mdef->argumentList(); QCString nn; //VhdlDocGen::adjustRecordMember(mdef); if (gd) gd=0; @@ -2020,11 +1975,11 @@ void VhdlDocGen::writeVHDLDeclaration(const MemberDef* mdef,OutputList &ol, ol.docify(" "); writeLink(mdef,ol); - if (alp!=0 && mm==VhdlDocGen::FUNCTION) - VhdlDocGen::writeFunctionProto(ol,alp,mdef); + if (al.hasParameters() && mm==VhdlDocGen::FUNCTION) + VhdlDocGen::writeFunctionProto(ol,al,mdef); - if (alp!=0 && mm==VhdlDocGen::PROCEDURE) - VhdlDocGen::writeProcedureProto(ol,alp,mdef); + if (al.hasParameters() && mm==VhdlDocGen::PROCEDURE) + VhdlDocGen::writeProcedureProto(ol,al,mdef); break; case VhdlDocGen::USE: @@ -2089,7 +2044,7 @@ void VhdlDocGen::writeVHDLDeclaration(const MemberDef* mdef,OutputList &ol, case VhdlDocGen::PROCESS: writeLink(mdef,ol); ol.insertMemberAlign(); - VhdlDocGen::writeProcessProto(ol,alp,mdef); + VhdlDocGen::writeProcessProto(ol,al,mdef); break; case VhdlDocGen::PACKAGE: case VhdlDocGen::ENTITY: @@ -2577,7 +2532,7 @@ static void initUCF(Entry* root,const char* type,QCString & qcs,int line,QCStr qcs.stripPrefix("="); - Entry* current=new Entry; + std::unique_ptr<Entry> current = std::make_unique<Entry>(); current->spec=VhdlDocGen::UCF_CONST; current->section=Entry::VARIABLE_SEC; current->bodyLine=line; @@ -2604,7 +2559,7 @@ static void initUCF(Entry* root,const char* type,QCString & qcs,int line,QCStr brief.resize(0); } - root->addSubEntry(current); + root->moveToSubEntryAndKeep(current); } @@ -2761,9 +2716,6 @@ QCString VhdlDocGen::parseForBinding(QCString & entity,QCString & arch) void assignBinding(VhdlConfNode * conf) { - QList<Entry> instList=getVhdlInstList(); - QListIterator<Entry> eli(instList); - Entry *cur=0; ClassDef *archClass=0,*entClass=0; QCString archName; QCString arcBind,entBind; @@ -2826,7 +2778,7 @@ void assignBinding(VhdlConfNode * conf) all=allOt.lower()=="all" ; others= allOt.lower()=="others"; - for (;(cur=eli.current());++eli) + for (const auto &cur : getVhdlInstList()) { if (cur->exception.lower()==label || conf->isInlineConf) { @@ -2909,11 +2861,7 @@ void VhdlDocGen::computeVhdlComponentRelations() assignBinding(conf); } - QList<Entry> qsl= getVhdlInstList(); - QListIterator<Entry> eli(qsl); - Entry *cur; - - for (eli.toFirst();(cur=eli.current());++eli) + for (const auto &cur : getVhdlInstList()) { if (cur->stat ) // was bind { @@ -2949,7 +2897,7 @@ void VhdlDocGen::computeVhdlComponentRelations() } static void addInstance(ClassDef* classEntity, ClassDef* ar, - ClassDef *cd , Entry *cur,ClassDef* /*archBind*/) + ClassDef *cd , const std::unique_ptr<Entry> &cur) { QCString bName,n1; @@ -2990,8 +2938,8 @@ ferr: n1,uu,uu, 0, Public, Normal, cur->stat,Member, MemberType_Variable, - 0, - 0, + ArgumentList(), + ArgumentList(), ""); if (ar->getOutputFileBase()) @@ -3185,10 +3133,10 @@ void VhdlDocGen::createFlowChart(const MemberDef *mdef) VHDLLanguageScanner *pIntf =(VHDLLanguageScanner*) Doxygen::parserManager->getParser(".vhd"); VhdlDocGen::setFlowMember(mdef); - Entry root; + std::unique_ptr<Entry> root = std::make_unique<Entry>(); QStrList filesInSameTu; pIntf->startTranslationUnit(""); - pIntf->parseInput("",codeFragment.data(),&root,FALSE,filesInSameTu); + pIntf->parseInput("",codeFragment.data(),root,FALSE,filesInSameTu); pIntf->finishTranslationUnit(); } @@ -4061,34 +4009,30 @@ void FlowChart::writeEdge(FTextStream &t,int fl_from,int fl_to,int i,bool bFrom, t << "\n"; } -void FlowChart::alignFuncProc( QCString & q,const ArgumentList* al,bool isFunc) +void FlowChart::alignFuncProc( QCString & q,const ArgumentList &al,bool isFunc) { - if (al==0) return; - - ArgumentListIterator ali(*al); - int index=ali.count(); + int index=al.size(); if (index==0) return; int len=q.length()+VhdlDocGen::getFlowMember()->name().length(); QCString prev,temp; prev.fill(' ',len+1); - Argument *arg; q+="\n"; - for (;(arg=ali.current());++ali) + for (const Argument &arg : al) { - QCString attl=arg->defval+" "; - attl+=arg->name+" "; + QCString attl=arg.defval+" "; + attl+=arg.name+" "; if (!isFunc) { - attl+=arg->attrib+" "; + attl+=arg.attrib+" "; } else { attl+=" in "; } - attl+=arg->type; + attl+=arg.type; if (--index) attl+=",\n"; else attl+="\n"; attl.prepend(prev.data()); diff --git a/src/vhdldocgen.h b/src/vhdldocgen.h index e2c843c..18985ff 100644 --- a/src/vhdldocgen.h +++ b/src/vhdldocgen.h @@ -95,7 +95,6 @@ class VhdlDocGen static bool deleteCharRev(QCString &s,char c); static void deleteAllChars(QCString &s,char c); static void parseFuncProto(const char* text, - QList<Argument>& , QCString& name, QCString& ret, bool doc=false); @@ -113,9 +112,8 @@ class VhdlDocGen const QCString& key, MemberListType type); static ClassDef *getClass(const char *name); - static MemberDef* findFunction(const QList<Argument> &ql, - const QCString& name, - const QCString& package, bool type); + static MemberDef* findFunction(const QCString& name, + const QCString& package); static QCString getClassTitle(const ClassDef*); static void writeInlineClassLink(const ClassDef*, OutputList &ol); @@ -155,11 +153,11 @@ class VhdlDocGen static void formatString(const QCString&,OutputList& ol,const MemberDef*); static void writeFormatString(const QCString&,OutputList& ol,const MemberDef*); - static void writeFunctionProto(OutputList& ol,const ArgumentList *al,const MemberDef*); - static void writeProcessProto(OutputList& ol,const ArgumentList *al,const MemberDef*); - static void writeProcedureProto(OutputList& ol, const ArgumentList *al,const MemberDef*); - static bool writeFuncProcDocu(const MemberDef *mdef, OutputList& ol,const ArgumentList* al,bool type=false); - static void writeRecordProto(const MemberDef *mdef, OutputList& ol,const ArgumentList *al); + static void writeFunctionProto(OutputList& ol,const ArgumentList &al,const MemberDef*); + static void writeProcessProto(OutputList& ol,const ArgumentList &al,const MemberDef*); + static void writeProcedureProto(OutputList& ol, const ArgumentList &al,const MemberDef*); + static bool writeFuncProcDocu(const MemberDef *mdef, OutputList& ol,const ArgumentList &al,bool type=false); + static void writeRecordProto(const MemberDef *mdef, OutputList& ol,const ArgumentList &al); static bool writeVHDLTypeDocumentation(const MemberDef* mdef, const Definition* d, OutputList &ol); @@ -179,7 +177,7 @@ class VhdlDocGen static bool writeClassType(const ClassDef *,OutputList &ol ,QCString & cname); - static QCString convertArgumentListToString(const ArgumentList* al,bool f); + static QCString convertArgumentListToString(const ArgumentList &al,bool f); static QCString getProcessNumber(); static QCString getRecordNumber(); @@ -225,7 +223,7 @@ class VhdlDocGen private: static void findAllArchitectures(QList<QCString>& ql,const ClassDef *cd); - static bool compareArgList(ArgumentList*,ArgumentList*); + static bool compareArgList(const ArgumentList &,const ArgumentList &); static void writeVhdlLink(const ClassDef* cdd ,OutputList& ol,QCString& type,QCString& name,QCString& beh); static void writeStringLink(const MemberDef *mdef,QCString mem,OutputList& ol); static void writeRecUnitDocu( const MemberDef *md, OutputList& ol,QCString largs); @@ -294,7 +292,7 @@ class FlowChart static void moveToPrevLevel(); static int getTimeStamp(); static void writeFlowChart(); - static void alignFuncProc(QCString & q,const ArgumentList* al,bool isFunc); + static void alignFuncProc(QCString & q,const ArgumentList &al,bool isFunc); static QCString convertNameToFileName(); static void printNode(const FlowChart* n); static void printFlowTree(); diff --git a/src/vhdljjparser.cpp b/src/vhdljjparser.cpp index aeed048..39981a0 100644 --- a/src/vhdljjparser.cpp +++ b/src/vhdljjparser.cpp @@ -48,16 +48,16 @@ static Entry* oldEntry; static bool varr=FALSE; static QCString varName; -static QList<Entry> instFiles; -static QList<Entry> libUse; -static QList<Entry> lineEntry; +static std::vector< std::unique_ptr<Entry> > instFiles; +static std::vector< std::unique_ptr<Entry> > libUse; +static std::vector<Entry*> lineEntry; Entry* VhdlParser::currentCompound=0; Entry* VhdlParser::tempEntry=0; Entry* VhdlParser::lastEntity=0 ; Entry* VhdlParser::lastCompound=0 ; -Entry* VhdlParser::current=0; Entry* VhdlParser::current_root = 0; +std::unique_ptr<Entry> VhdlParser::current=0; QCString VhdlParser::compSpec; QCString VhdlParser::currName; QCString VhdlParser::confName; @@ -84,13 +84,13 @@ static QCString strComment; static int iCodeLen; static const char *vhdlFileName = 0; -bool checkMultiComment(QCString& qcs,int line); -QList<Entry>* getEntryAtLine(const Entry* ce,int line); +static bool checkMultiComment(QCString& qcs,int line); +static void insertEntryAtLine(const Entry* ce,int line); //------------------------------------- -QList<VhdlConfNode>& getVhdlConfiguration() { return configL; } -QList<Entry>& getVhdlInstList() { return instFiles; } +const QList<VhdlConfNode>& getVhdlConfiguration() { return configL; } +const std::vector<std::unique_ptr<Entry> > &getVhdlInstList() { return instFiles; } Entry* getVhdlCompound() { @@ -105,8 +105,8 @@ bool isConstraintFile(const QCString &fileName,const QCString &ext) } -void VHDLLanguageScanner::parseInput(const char *fileName,const char *fileBuf,Entry *root, - bool ,QStrList&) +void VHDLLanguageScanner::parseInput(const char *fileName,const char *fileBuf, + const std::unique_ptr<Entry> &root, bool ,QStrList&) { g_thisParser=this; bool inLine=false; @@ -128,34 +128,32 @@ void VHDLLanguageScanner::parseInput(const char *fileName,const char *fileBuf,En if (xilinx_ucf) { - VhdlDocGen::parseUCF(fileBuf,root,yyFileName,FALSE); + VhdlDocGen::parseUCF(fileBuf,root.get(),yyFileName,FALSE); return; } if (altera_qsf) { - VhdlDocGen::parseUCF(fileBuf,root,yyFileName,TRUE); + VhdlDocGen::parseUCF(fileBuf,root.get(),yyFileName,TRUE); return; } - libUse.setAutoDelete(true); yyLineNr=1; - VhdlParser::current_root=root; + VhdlParser::current_root=root.get(); VhdlParser::lastCompound=0; VhdlParser::lastEntity=0; VhdlParser::currentCompound=0; VhdlParser::lastEntity=0; oldEntry = 0; - VhdlParser::current=new Entry(); - VhdlParser::initEntry(VhdlParser::current); + VhdlParser::current=std::make_unique<Entry>(); + VhdlParser::initEntry(VhdlParser::current.get()); Doxygen::docGroup.enterFile(fileName,yyLineNr); vhdlFileName = fileName; lineParse=new int[200]; // Dimitri: dangerous constant: should be bigger than largest token id in VhdlParserConstants.h VhdlParserIF::parseVhdlfile(fileBuf,inLine); - delete VhdlParser::current; - VhdlParser::current=0; + VhdlParser::current.reset(); if (!inLine) - VhdlParser::mapLibPackage(root); + VhdlParser::mapLibPackage(root.get()); delete[] lineParse; yyFileName.resize(0); @@ -198,34 +196,33 @@ void VhdlParser::initEntry(Entry *e) void VhdlParser::newEntry() { + previous = current.get(); if (current->spec==VhdlDocGen::ENTITY || current->spec==VhdlDocGen::PACKAGE || current->spec==VhdlDocGen::ARCHITECTURE || current->spec==VhdlDocGen::PACKAGE_BODY) { - current_root->addSubEntry(current); + current_root->moveToSubEntryAndRefresh(current); } else { if (lastCompound) { - lastCompound->addSubEntry(current); + lastCompound->moveToSubEntryAndRefresh(current); } else { if (lastEntity) { - lastEntity->addSubEntry(current); + lastEntity->moveToSubEntryAndRefresh(current); } else { - current_root->addSubEntry(current); + current_root->moveToSubEntryAndRefresh(current); } } } - previous = current; - current = new Entry ; - initEntry(current); + initEntry(current.get()); } void VhdlParser::handleFlowComment(const char* doc) @@ -259,7 +256,7 @@ void VhdlParser::handleCommentBlock(const char* doc1,bool brief) Protection protection=Public; - if (oldEntry==current) + if (oldEntry==current.get()) { //printf("\n find pending message < %s > at line: %d \n ",doc.data(),iDocLine); str_doc.doc=doc; @@ -269,7 +266,7 @@ void VhdlParser::handleCommentBlock(const char* doc1,bool brief) return; } - oldEntry=current; + oldEntry=current.get(); if (brief) { @@ -293,7 +290,7 @@ void VhdlParser::handleCommentBlock(const char* doc1,bool brief) QCString processedDoc = preprocessCommentBlock(doc,yyFileName,iDocLine); while (parseCommentBlock( g_thisParser, - current, + current.get(), processedDoc, // text yyFileName, // file iDocLine, // line of block start @@ -343,7 +340,7 @@ void VhdlParser::addCompInst(const char *n, const char* instName, const char* co { current->args=lastCompound->name; // architecture name } - current->includeName=comp; // component/enity/configuration + current->includeName=comp; // component/entity/configuration int u=genLabels.find("|",1); if (u>0) { @@ -357,13 +354,11 @@ void VhdlParser::addCompInst(const char *n, const char* instName, const char* co current->args=lastCompound->name; if (true) // !findInstant(current->type)) { - initEntry(current); - instFiles.append(new Entry(*current)); + initEntry(current.get()); + instFiles.emplace_back(std::make_unique<Entry>(*current)); } - Entry *temp=current; // hold current pointer (temp=oldEntry) - current=new Entry; // (oldEntry != current) - delete temp; + current=std::make_unique<Entry>(); } else { @@ -401,7 +396,7 @@ void VhdlParser::addVhdlType(const char *n,int startLine,int section, if (!lastCompound && (section==Entry::VARIABLE_SEC) && (spec == VhdlDocGen::USE || spec == VhdlDocGen::LIBRARY) ) { - libUse.append(new Entry(*current)); + libUse.emplace_back(std::make_unique<Entry>(*current)); current->reset(); } newEntry(); @@ -446,9 +441,9 @@ void VhdlParser::createFunction(const char *imp,uint64 spec,const char *fn) QCStringList q1=QCStringList::split(",",fname); for (uint ii=0;ii<q1.count();ii++) { - Argument *arg=new Argument; - arg->name=q1[ii]; - current->argList->append(arg); + Argument arg; + arg.name=q1[ii]; + current->argList.push_back(arg); } } return; @@ -537,7 +532,7 @@ void VhdlParser::addConfigureNode(const char* a,const char*b, bool,bool isLeaf,b void VhdlParser::addProto(const char *s1,const char *s2,const char *s3, - const char *s4,const char *s5,const char *s6) + const char *s4,const char *s5,const char *s6) { (void)s5; // avoid unused warning QCString name=s2; @@ -545,21 +540,21 @@ void VhdlParser::addProto(const char *s1,const char *s2,const char *s3, for (uint u=0;u<ql.count();u++) { - Argument *arg=new Argument; - arg->name=ql[u]; + Argument arg; + arg.name=ql[u]; if (s3) { - arg->type=s3; + arg.type=s3; } - arg->type+=" "; - arg->type+=s4; + arg.type+=" "; + arg.type+=s4; if (s6) { - arg->type+=s6; + arg.type+=s6; } if (parse_sec==GEN_SEC && param_sec==0) { - arg->defval="gen!"; + arg.defval="gen!"; } if (parse_sec==PARAM_SEC) @@ -567,10 +562,10 @@ void VhdlParser::addProto(const char *s1,const char *s2,const char *s3, // assert(false); } - arg->defval+=s1; - arg->attrib="";//s6; + arg.defval+=s1; + arg.attrib="";//s6; - current->argList->append(arg); + current->argList.push_back(arg); current->args+=s2; current->args+=","; } @@ -584,37 +579,36 @@ void VhdlParser::addProto(const char *s1,const char *s2,const char *s3, * ..... * library * package - * enity zzz + * entity zzz * ..... * and so on.. */ void VhdlParser::mapLibPackage( Entry* root) { - QList<Entry> epp=libUse; - EntryListIterator eli(epp); - Entry *rt; - for (;(rt=eli.current());++eli) + //QList<Entry> epp=libUse; + //EntryListIterator eli(epp); + //Entry *rt; + //for (;(rt=eli.current());++eli) + for (const auto &rt : libUse) { if (addLibUseClause(rt->name)) { - Entry *current; - EntryListIterator eLib(*root->children()); bool bFound=FALSE; - for (eLib.toFirst();(current=eLib.current());++eLib) + for (const auto ¤t : root->children()) { - if (VhdlDocGen::isVhdlClass(current)) + if (VhdlDocGen::isVhdlClass(current.get())) { if (current->startLine > rt->startLine) { bFound=TRUE; - current->addSubEntry(new Entry(*rt)); + current->copyToSubEntry(rt); break; } } }//for if (!bFound) { - root->addSubEntry(new Entry(*rt)); + root->copyToSubEntry(rt); } } //if }// for @@ -718,37 +712,34 @@ void VhdlParser::oneLineComment(QCString qcs) bool checkMultiComment(QCString& qcs,int line) { - QList<Entry> *pTemp=getEntryAtLine(VhdlParser::current_root,line); + insertEntryAtLine(VhdlParser::current_root,line); - if (pTemp->isEmpty()) return false; + if (lineEntry.empty()) return false; VhdlDocGen::prepareComment(qcs); - while (!pTemp->isEmpty()) + while (!lineEntry.empty()) { - Entry *e=(Entry*)pTemp->getFirst(); + Entry *e=lineEntry.back(); e->briefLine=line; e->brief+=qcs; - pTemp->removeFirst(); + lineEntry.pop_back(); } return true; } // returns the vhdl parsed types at line xxx -QList<Entry>* getEntryAtLine(const Entry* ce,int line) +void insertEntryAtLine(const Entry* ce,int line) { - EntryListIterator eli(*ce->children()); - Entry *rt; - for (;(rt=eli.current());++eli) + for (const auto &rt : ce->children()) { if (rt->bodyLine==line) { - lineEntry.insert(0,rt); + lineEntry.push_back(rt.get()); } - getEntryAtLine(rt,line); + insertEntryAtLine(rt.get(),line); } - return &lineEntry; } const char *getVhdlFileName(void) diff --git a/src/vhdljjparser.h b/src/vhdljjparser.h index fffea47..d38a731 100644 --- a/src/vhdljjparser.h +++ b/src/vhdljjparser.h @@ -1,6 +1,9 @@ #ifndef VHDLJJPARSER_H #define VHDLJJPARSER_H +#include <vector> +#include <memory> + #include "parserintf.h" #include <stdio.h> #include <stdlib.h> @@ -27,7 +30,6 @@ void parserVhdlfile(const char* inputBuffer); class Entry; class ClassSDict; -class FileStorage; class ClassDef; class MemberDef; struct VhdlConfNode; @@ -45,7 +47,7 @@ class VHDLLanguageScanner : public ParserInterface void finishTranslationUnit() {} void parseInput(const char * fileName, const char *fileBuf, - Entry *root, + const std::unique_ptr<Entry> &root, bool sameTranslationUnit, QStrList &filesInSameTranslationUnit); @@ -95,7 +97,7 @@ struct VhdlConfNode void vhdlscanFreeScanner(); -QList<VhdlConfNode>& getVhdlConfiguration(); -QList<Entry>& getVhdlInstList(); +const QList<VhdlConfNode>& getVhdlConfiguration(); +const std::vector<std::unique_ptr<Entry> >&getVhdlInstList(); #endif diff --git a/src/xmlgen.cpp b/src/xmlgen.cpp index d05adf0..dfbf630 100644 --- a/src/xmlgen.cpp +++ b/src/xmlgen.cpp @@ -338,43 +338,41 @@ void XMLCodeGenerator::finish() if (m_insideCodeLine) endCodeLine(); } -static void writeTemplateArgumentList(const ArgumentList *al, - FTextStream &t, +static void writeTemplateArgumentList(FTextStream &t, + const ArgumentList &al, const Definition *scope, const FileDef *fileScope, int indent) { QCString indentStr; indentStr.fill(' ',indent); - if (al) + if (al.hasParameters()) { t << indentStr << "<templateparamlist>" << endl; - ArgumentListIterator ali(*al); - const Argument *a; - for (ali.toFirst();(a=ali.current());++ali) + for (const Argument &a : al) { t << indentStr << " <param>" << endl; - if (!a->type.isEmpty()) + if (!a.type.isEmpty()) { t << indentStr << " <type>"; - linkifyText(TextGeneratorXMLImpl(t),scope,fileScope,0,a->type); + linkifyText(TextGeneratorXMLImpl(t),scope,fileScope,0,a.type); t << "</type>" << endl; } - if (!a->name.isEmpty()) + if (!a.name.isEmpty()) { - t << indentStr << " <declname>" << convertToXML(a->name) << "</declname>" << endl; - t << indentStr << " <defname>" << convertToXML(a->name) << "</defname>" << endl; + t << indentStr << " <declname>" << convertToXML(a.name) << "</declname>" << endl; + t << indentStr << " <defname>" << convertToXML(a.name) << "</defname>" << endl; } - if (!a->defval.isEmpty()) + if (!a.defval.isEmpty()) { t << indentStr << " <defval>"; - linkifyText(TextGeneratorXMLImpl(t),scope,fileScope,0,a->defval); + linkifyText(TextGeneratorXMLImpl(t),scope,fileScope,0,a.defval); t << "</defval>" << endl; } - if (!a->typeConstraint.isEmpty()) + if (!a.typeConstraint.isEmpty()) { t << indentStr << " <typeconstraint>"; - linkifyText(TextGeneratorXMLImpl(t),scope,fileScope,0,a->typeConstraint); + linkifyText(TextGeneratorXMLImpl(t),scope,fileScope,0,a.typeConstraint); t << "</typeconstraint>" << endl; } t << indentStr << " </param>" << endl; @@ -385,16 +383,12 @@ static void writeTemplateArgumentList(const ArgumentList *al, static void writeMemberTemplateLists(const MemberDef *md,FTextStream &t) { - const ArgumentList *templMd = md->templateArguments(); - if (templMd) // function template prefix - { - writeTemplateArgumentList(templMd,t,md->getClassDef(),md->getFileDef(),8); - } + writeTemplateArgumentList(t,md->templateArguments(),md->getClassDef(),md->getFileDef(),8); } static void writeTemplateList(const ClassDef *cd,FTextStream &t) { - writeTemplateArgumentList(cd->templateArguments(),t,cd,0,4); + writeTemplateArgumentList(t,cd->templateArguments(),cd,0,4); } static void writeXMLDocBlock(FTextStream &t, @@ -591,9 +585,9 @@ static void generateXMLForMember(const MemberDef *md,FTextStream &ti,FTextStream if (isFunc) { - const ArgumentList *al = md->argumentList(); + const ArgumentList &al = md->argumentList(); t << " const=\""; - if (al!=0 && al->constSpecifier) t << "yes"; else t << "no"; + if (al.constSpecifier) t << "yes"; else t << "no"; t << "\""; t << " explicit=\""; @@ -604,10 +598,10 @@ static void generateXMLForMember(const MemberDef *md,FTextStream &ti,FTextStream if (md->isInline()) t << "yes"; else t << "no"; t << "\""; - if (al!=0 && al->refQualifier!=RefQualifierNone) + if (al.refQualifier!=RefQualifierNone) { t << " refqual=\""; - if (al->refQualifier==RefQualifierLValue) t << "lvalue"; else t << "rvalue"; + if (al.refQualifier==RefQualifierLValue) t << "lvalue"; else t << "rvalue"; t << "\""; } @@ -641,7 +635,7 @@ static void generateXMLForMember(const MemberDef *md,FTextStream &ti,FTextStream t << " noexcept=\"yes\""; } - if (al && al->volatileSpecifier) + if (al.volatileSpecifier) { t << " volatile=\"yes\""; } @@ -840,51 +834,55 @@ static void generateXMLForMember(const MemberDef *md,FTextStream &ti,FTextStream if (isFunc) //function { - const ArgumentList *declAl = md->declArgumentList(); - const ArgumentList *defAl = md->argumentList(); - if (declAl && defAl && declAl->count()>0) + const ArgumentList &declAl = md->declArgumentList(); + const ArgumentList &defAl = md->argumentList(); + if (declAl.hasParameters()) { - ArgumentListIterator declAli(*declAl); - ArgumentListIterator defAli(*defAl); - const Argument *a; - for (declAli.toFirst();(a=declAli.current());++declAli) + auto defIt = defAl.begin(); + for (const Argument &a : declAl) { - Argument *defArg = defAli.current(); + //const Argument *defArg = defAli.current(); + const Argument *defArg = 0; + if (defIt!=defAl.end()) + { + defArg = &(*defIt); + ++defIt; + } t << " <param>" << endl; - if (!a->attrib.isEmpty()) + if (!a.attrib.isEmpty()) { t << " <attributes>"; - writeXMLString(t,a->attrib); + writeXMLString(t,a.attrib); t << "</attributes>" << endl; } - if (!a->type.isEmpty()) + if (!a.type.isEmpty()) { t << " <type>"; - linkifyText(TextGeneratorXMLImpl(t),def,md->getBodyDef(),md,a->type); + linkifyText(TextGeneratorXMLImpl(t),def,md->getBodyDef(),md,a.type); t << "</type>" << endl; } - if (!a->name.isEmpty()) + if (!a.name.isEmpty()) { t << " <declname>"; - writeXMLString(t,a->name); + writeXMLString(t,a.name); t << "</declname>" << endl; } - if (defArg && !defArg->name.isEmpty() && defArg->name!=a->name) + if (defArg && !defArg->name.isEmpty() && defArg->name!=a.name) { t << " <defname>"; writeXMLString(t,defArg->name); t << "</defname>" << endl; } - if (!a->array.isEmpty()) + if (!a.array.isEmpty()) { t << " <array>"; - writeXMLString(t,a->array); + writeXMLString(t,a.array); t << "</array>" << endl; } - if (!a->defval.isEmpty()) + if (!a.defval.isEmpty()) { t << " <defval>"; - linkifyText(TextGeneratorXMLImpl(t),def,md->getBodyDef(),md,a->defval); + linkifyText(TextGeneratorXMLImpl(t),def,md->getBodyDef(),md,a.defval); t << "</defval>" << endl; } if (defArg && defArg->hasDocumentation()) @@ -895,25 +893,22 @@ static void generateXMLForMember(const MemberDef *md,FTextStream &ti,FTextStream t << "</briefdescription>" << endl; } t << " </param>" << endl; - if (defArg) ++defAli; } } } else if (md->memberType()==MemberType_Define && md->argsString()) // define { - if (md->argumentList()->count()==0) // special case for "foo()" to + if (md->argumentList().empty()) // special case for "foo()" to // disguish it from "foo". { t << " <param></param>" << endl; } else { - ArgumentListIterator ali(*md->argumentList()); - const Argument *a; - for (ali.toFirst();(a=ali.current());++ali) + for (const Argument &a : md->argumentList()) { - t << " <param><defname>" << a->type << "</defname></param>" << endl; + t << " <param><defname>" << a.type << "</defname></param>" << endl; } } } diff --git a/src/xmlscanner.h b/src/xmlscanner.h index cb9792c..b54d416 100644 --- a/src/xmlscanner.h +++ b/src/xmlscanner.h @@ -28,7 +28,7 @@ public: virtual ~XMLScanner() {} void startTranslationUnit(const char *) {} void finishTranslationUnit() {} - void parseInput(const char *, const char *, Entry *, bool , QStrList &) {} + void parseInput(const char *, const char *, const std::unique_ptr<Entry> &, bool , QStrList &) {} bool needsPreprocessing(const QCString &) { return FALSE; } void parseCode(CodeOutputInterface &codeOutIntf, |