diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/arguments.cpp | 48 | ||||
-rw-r--r-- | src/arguments.h | 81 | ||||
-rw-r--r-- | src/classdef.cpp | 408 | ||||
-rw-r--r-- | src/classdef.h | 17 | ||||
-rw-r--r-- | src/classlist.cpp | 8 | ||||
-rw-r--r-- | src/code.l | 14 | ||||
-rw-r--r-- | src/context.cpp | 103 | ||||
-rw-r--r-- | src/context.h | 8 | ||||
-rw-r--r-- | src/defargs.h | 2 | ||||
-rw-r--r-- | src/defargs.l | 79 | ||||
-rw-r--r-- | src/defgen.cpp | 97 | ||||
-rw-r--r-- | src/definition.cpp | 2 | ||||
-rw-r--r-- | src/docparser.cpp | 33 | ||||
-rw-r--r-- | src/doxygen.cpp | 582 | ||||
-rw-r--r-- | src/entry.cpp | 33 | ||||
-rw-r--r-- | src/entry.h | 12 | ||||
-rw-r--r-- | src/fortranscanner.l | 51 | ||||
-rw-r--r-- | src/groupdef.cpp | 14 | ||||
-rw-r--r-- | src/memberdef.cpp | 504 | ||||
-rw-r--r-- | src/memberdef.h | 30 | ||||
-rw-r--r-- | src/perlmodgen.cpp | 76 | ||||
-rw-r--r-- | src/pre.l | 4 | ||||
-rw-r--r-- | src/pyscanner.l | 24 | ||||
-rw-r--r-- | src/scanner.l | 257 | ||||
-rw-r--r-- | src/sqlite3gen.cpp | 135 | ||||
-rw-r--r-- | src/tagreader.cpp | 20 | ||||
-rw-r--r-- | src/tclscanner.l | 23 | ||||
-rw-r--r-- | src/util.cpp | 650 | ||||
-rw-r--r-- | src/util.h | 22 | ||||
-rw-r--r-- | src/vhdlcode.l | 15 | ||||
-rw-r--r-- | src/vhdldocgen.cpp | 171 | ||||
-rw-r--r-- | src/vhdldocgen.h | 22 | ||||
-rw-r--r-- | src/vhdljjparser.cpp | 28 | ||||
-rw-r--r-- | src/xmlgen.cpp | 97 |
34 files changed, 1434 insertions, 2236 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..58aaa4f 100644 --- a/src/arguments.h +++ b/src/arguments.h @@ -16,7 +16,7 @@ #ifndef ARGUMENTS_H #define ARGUMENTS_H -#include <qlist.h> +#include <vector> #include <qcstring.h> class StorageIntf; @@ -27,34 +27,6 @@ class StorageIntf; */ 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 +58,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/classdef.cpp b/src/classdef.cpp index 7548c6c..88bec11 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); @@ -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('&'); diff --git a/src/context.cpp b/src/context.cpp index 8b7643a..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())); } @@ -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..b44f2d1 100644 --- a/src/definition.cpp +++ b/src/definition.cpp @@ -420,7 +420,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); } } diff --git a/src/docparser.cpp b/src/docparser.cpp index f655475..48b46a9 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; bool found=FALSE; - 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()) { found = TRUE; } @@ -552,16 +547,16 @@ static void checkUnOrMultipleDocumentedParams() QCString(g_memberDef->qualifiedName()) + QCString(argListToString(al)) + " are 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) { diff --git a/src/doxygen.cpp b/src/doxygen.cpp index e1d7967..decd574 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -294,7 +294,7 @@ void statistics() static void addMemberDocs(const Entry *root,MemberDef *md, const char *funcDecl, - ArgumentList *al,bool over_load,uint64 spec); + const ArgumentList *al,bool over_load,uint64 spec); static void findMember(const Entry *root, const QCString &relates, const QCString &type, @@ -464,21 +464,18 @@ static void addSTLClass(const std::unique_ptr<Entry> &root,const STLInfo *info) // 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); + ArgumentList al; + Argument a; + a.type="typename"; + a.name=info->templType1; + al.push_back(a); if (info->templType2) // another template argument { - a=new Argument; - a->type="typename"; - a->name=info->templType2; - al->append(a); + a.type="typename"; + a.name=info->templType2; + al.push_back(a); } - classEntry->tArgLists = new QList<ArgumentList>; - classEntry->tArgLists->setAutoDelete(TRUE); - classEntry->tArgLists->append(al); + classEntry->tArgLists.push_back(al); } // add member variables if (info->templName1) @@ -1105,17 +1102,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) @@ -1123,15 +1118,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 @@ -1240,13 +1235,12 @@ static void addClassToContext(const 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); } @@ -1280,12 +1274,11 @@ static void addClassToContext(const 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); } @@ -1296,7 +1289,7 @@ static void addClassToContext(const 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); @@ -1561,7 +1554,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()); @@ -2055,7 +2048,7 @@ static void findUsingDeclarations(const 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, @@ -2135,8 +2128,8 @@ static void findUsingDeclImports(const Entry *root) { 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(), @@ -2336,7 +2329,8 @@ static MemberDef *addVariableToClass( fileName,root->startLine,root->startColumn, type,name,args,root->exception, prot,Normal,root->stat,related, - mtype,root->tArgLists ? root->tArgLists->getLast() : 0,0, root->metaData); + 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); @@ -2595,7 +2589,8 @@ static MemberDef *addVariableToFile( fileName,root->startLine,root->startColumn, type,name,args,0, root->protection, Normal,root->stat,Member, - mtype,root->tArgLists ? root->tArgLists->getLast() : 0,0, root->metaData); + 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); @@ -2739,19 +2734,16 @@ static bool isVarWithConstructor(const 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; } @@ -2761,31 +2753,31 @@ static bool isVarWithConstructor(const 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 { @@ -3129,7 +3121,7 @@ static void addInterfaceOrServiceToServiceOrSingleton( 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); + type, ArgumentList(), root->argList, root->metaData); md->setTagInfo(root->tagInfo); md->setMemberClass(cd); md->setDocumentation(root->doc,root->docFile,root->docLine); @@ -3206,7 +3198,7 @@ static void buildInterfaceAndServiceList(const 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, @@ -3317,7 +3309,8 @@ static void addMethodToClass(const Entry *root,ClassDef *cd, stat && root->relatesType != MemberOf, relates.isEmpty() ? Member : root->relatesType == MemberOf ? Foreign : Related, - mtype,root->tArgLists ? root->tArgLists->getLast() : 0,root->argList, root->metaData); + 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); @@ -3347,54 +3340,27 @@ static void addMethodToClass(const Entry *root,ClassDef *cd, // for PHP we use Class::method and Namespace\method scopeSeparator="::"; } +// QCString optArgs = root->argList.empty() ? args : QCString(); if (!relates.isEmpty() || isFriend || Config_getBool(HIDE_SCOPE_NAMES)) { if (!type.isEmpty()) { - if (root->argList) - { - def=type+" "+name; - } - else - { - def=type+" "+name+args; - } + def=type+" "+name; //+optArgs; } else { - if (root->argList) - { - def=name; - } - else - { - def=name+args; - } + def=name; //+optArgs; } } else { if (!type.isEmpty()) { - if (root->argList) - { - def=type+" "+qualScope+scopeSeparator+name; - } - else - { - def=type+" "+qualScope+scopeSeparator+name+args; - } + def=type+" "+qualScope+scopeSeparator+name; //+optArgs; } else { - if (root->argList) - { - def=qualScope+scopeSeparator+name; - } - else - { - def=qualScope+scopeSeparator+name+args; - } + def=qualScope+scopeSeparator+name; //+optArgs; } } if (def.left(7)=="friend ") def=def.right(def.length()-7); @@ -3457,7 +3423,7 @@ static void buildFunctionList(const 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, @@ -3577,16 +3543,16 @@ static void buildFunctionList(const 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; } @@ -3634,11 +3600,12 @@ static void buildFunctionList(const 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) { @@ -3712,13 +3679,14 @@ static void buildFunctionList(const 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->setLanguage(root->lang); @@ -3762,27 +3730,14 @@ static void buildFunctionList(const 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" @@ -3906,8 +3861,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()) { @@ -4023,8 +3978,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, @@ -4144,31 +4099,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; @@ -4219,12 +4169,12 @@ static void findUsedClassesForClass(const Entry *root, 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()); @@ -4250,10 +4200,7 @@ static void findUsedClassesForClass(const 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) @@ -4293,37 +4240,32 @@ static void findUsedClassesForClass(const 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()); } } @@ -4390,14 +4332,14 @@ static void findBaseClassesForClass( 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(); + const ArgumentList &formalArgs = masterCd->templateArguments(); QListIterator<BaseInfo> bii(*root->extends); BaseInfo *bi=0; for (bii.toFirst();(bi=bii.current());++bii) @@ -4411,10 +4353,7 @@ static void findBaseClassesForClass( 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); - } + tbi.name = substituteTemplateArgumentsInString(bi->name,formalArgs,actualArgs); //printf("bi->name=%s tbi.name=%s\n",bi->name.data(),tbi.name.data()); if (mode==DocumentedOnly) @@ -4492,14 +4431,13 @@ static bool findTemplateInstanceRelation(const Entry *root, 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 { @@ -5107,7 +5045,7 @@ 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); @@ -5116,8 +5054,8 @@ static void computeTemplateClassRelations() { // check if the base class is a template argument BaseInfo tbi(bi->name,bi->prot,bi->virt); - ArgumentList *tl = cd->templateArguments(); - if (tl) + const ArgumentList &tl = cd->templateArguments(); + if (!tl.empty()) { QDict<int> *baseClassNames = tcd->getTemplateBaseClassNames(); QDict<int> *templateNames = getTemplateArgumentsInName(tl,bi->name); @@ -5129,18 +5067,20 @@ 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; @@ -5155,7 +5095,6 @@ static void computeTemplateClassRelations() delete actualTemplateNames; } } - delete templArgs; } // class has no base classes } } @@ -5294,13 +5233,13 @@ static void generateXRefPages() static void addMemberDocs(const Entry *root, MemberDef *md, const char *funcDecl, - ArgumentList *al, + const ArgumentList *al, bool over_load, uint64 spec ) { - //printf("addMemberDocs: '%s'::'%s' '%s' funcDecl='%s' mSpec=%d\n", - // root->parent->name.data(),md->name().data(),md->argsString(),funcDecl,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 "); @@ -5324,11 +5263,12 @@ static void addMemberDocs(const 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 { @@ -5340,7 +5280,8 @@ static void addMemberDocs(const 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 @@ -5511,9 +5452,9 @@ static bool findGlobalMember(const 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, @@ -5522,15 +5463,12 @@ static bool findGlobalMember(const 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; } } @@ -5550,11 +5488,11 @@ static bool findGlobalMember(const 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"); @@ -5565,7 +5503,7 @@ static bool findGlobalMember(const 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,root->spec); + addMemberDocs(root,md->resolveAlias(),decl,&root->argList,FALSE,root->spec); found=TRUE; } } @@ -5573,7 +5511,7 @@ static bool findGlobalMember(const 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) @@ -5609,17 +5547,17 @@ static bool findGlobalMember(const 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; } @@ -5629,15 +5567,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 ) { @@ -5651,61 +5589,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; @@ -5717,48 +5653,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() // ); @@ -5786,10 +5713,10 @@ static void findMember(const 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(relates),overloaded,isFunc,root->mGrpId, - root->tArgLists,root->tArgLists ? root->tArgLists->count() : 0, + root->tArgLists.size(), root->spec,root->lang ); @@ -5946,9 +5873,8 @@ static void findMember(const 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 ) ) { @@ -5995,7 +5921,7 @@ static void findMember(const Entry *root, if (funcSpec.isEmpty()) { int argListIndex=0; - tempScopeName=cd->qualifiedNameWithTemplateParameters(root->tArgLists,&argListIndex); + tempScopeName=cd->qualifiedNameWithTemplateParameters(&root->tArgLists,&argListIndex); } else { @@ -6145,39 +6071,33 @@ static void findMember(const 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; } @@ -6194,7 +6114,7 @@ static void findMember(const 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, @@ -6206,7 +6126,7 @@ static void findMember(const 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 @@ -6217,8 +6137,8 @@ static void findMember(const 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"); @@ -6227,9 +6147,9 @@ static void findMember(const 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 @@ -6245,19 +6165,19 @@ static void findMember(const 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 @@ -6267,7 +6187,6 @@ static void findMember(const Entry *root, md->protection(),md->isStatic(),md->virtualness(),spec,relates); return; } - delete argList; } } if (matching) @@ -6303,9 +6222,9 @@ static void findMember(const 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"); addMethodToClass(root,ccd,type,md->name(),args,isFriend, @@ -6356,17 +6275,13 @@ static void findMember(const 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); @@ -6382,8 +6297,8 @@ static void findMember(const 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(); + if (templAl.hasParameters()) { warnMsg+=" 'template "; warnMsg+=tempArgListToString(templAl,root->lang); @@ -6430,7 +6345,7 @@ static void findMember(const 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, @@ -6464,7 +6379,6 @@ static void findMember(const Entry *root, mn->append(md); cd->insertMember(md); md->setRefItems(root->sli); - delete tArgList; } else { @@ -6499,7 +6413,7 @@ static void findMember(const 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( @@ -6590,7 +6504,7 @@ static void findMember(const 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() || @@ -6645,8 +6559,9 @@ static void findMember(const 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) { @@ -6685,7 +6600,7 @@ static void findMember(const 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, @@ -6786,7 +6701,7 @@ 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); + MemberType_Function,ArgumentList(),root->argList,root->metaData); md->setTagInfo(root->tagInfo); md->setLanguage(root->lang); md->setId(root->id); @@ -7141,7 +7056,7 @@ static void findEnums(const Entry *root) root->protection,Normal,FALSE, isMemberOf ? Foreign : isRelated ? Related : Member, MemberType_Enumeration, - 0,0,root->metaData); + ArgumentList(),ArgumentList(),root->metaData); md->setTagInfo(root->tagInfo); md->setLanguage(root->lang); md->setId(root->id); @@ -7357,7 +7272,7 @@ static void addEnumValuesToEnums(const Entry *root) 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()); @@ -7755,8 +7670,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() @@ -8591,7 +8506,8 @@ static void findDefineDocumentation(Entry *root) { MemberDef *md=createMemberDef(root->tagInfo->tagName,1,1, "#define",root->name,root->args,0, - Public,Normal,FALSE,Member,MemberType_Define,0,0,""); + 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); diff --git a/src/entry.cpp b/src/entry.cpp index 8ec7846..e700fab 100644 --- a/src/entry.cpp +++ b/src/entry.cpp @@ -43,11 +43,7 @@ Entry::Entry() 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; @@ -81,8 +77,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; @@ -102,7 +98,7 @@ 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; @@ -167,18 +163,6 @@ Entry::Entry(const Entry &e) 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; } @@ -192,10 +176,7 @@ Entry::~Entry() delete extends; delete groups; delete anchors; - delete argList; - delete tArgLists; delete tagInfo; - delete typeConstr; delete sli; num--; } @@ -324,12 +305,12 @@ void Entry::reset() extends->clear(); groups->clear(); anchors->clear(); - argList->clear(); + argList.clear(); + tArgLists.clear(); + argList.reset(); + typeConstr.reset(); 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_fileDef = 0; } diff --git a/src/entry.h b/src/entry.h index c078936..12bd897 100644 --- a/src/entry.h +++ b/src/entry.h @@ -18,20 +18,20 @@ #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 @@ -268,8 +268,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) @@ -289,7 +289,7 @@ 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 diff --git a/src/fortranscanner.l b/src/fortranscanner.l index d7eefd6..7fa9426 100644 --- a/src/fortranscanner.l +++ b/src/fortranscanner.l @@ -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 @@ -1141,9 +1141,11 @@ private { } <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; } } } @@ -1152,15 +1154,13 @@ 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(true); startScope(last_entry); BEGIN(SubprogBody); @@ -1280,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); } } @@ -1787,8 +1787,7 @@ static void copyEntry(Entry *dest, const std::unique_ptr<Entry> &src) dest->bodyLine = src->bodyLine; dest->endBodyLine = src->endBodyLine; dest->args = src->args; - delete dest->argList; - dest->argList = new ArgumentList(*src->argList); + dest->argList = src->argList; dest->doc = src->doc; dest->brief = src->brief; } @@ -2011,14 +2010,13 @@ 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; @@ -2212,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 @@ -2384,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); } @@ -2439,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; } diff --git a/src/groupdef.cpp b/src/groupdef.cpp index 00e42d7..bcdb3d0 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 diff --git a/src/memberdef.cpp b/src/memberdef.cpp index 4f44baa..28c0abb 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; @@ -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) {} @@ -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)); @@ -4879,30 +4811,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) @@ -5557,27 +5478,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 +5852,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,29 +5943,21 @@ 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; } } } @@ -6066,8 +5976,8 @@ void combineDeclarationAndDefinition(MemberDef *mdec,MemberDef *mdef) 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 +6007,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 +6020,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 +6120,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 97bf819..986ceca 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; @@ -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; @@ -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/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(); @@ -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/pyscanner.l b/src/pyscanner.l index ee72c7c..1a3f052 100644 --- a/src/pyscanner.l +++ b/src/pyscanner.l @@ -378,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); @@ -387,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; @@ -928,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; } @@ -942,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 @@ -1032,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); @@ -1082,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); diff --git a/src/scanner.l b/src/scanner.l index 50ebe5e..61b51cb 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -352,7 +352,7 @@ static void addType() } current->type += current->args ; current->args.resize(0) ; - current->argList->clear(); + current->argList.clear(); } @@ -372,7 +372,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); //----------------------------------------------------------------- @@ -418,28 +418,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); } } } @@ -450,14 +432,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; } @@ -545,30 +525,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; } } } @@ -577,17 +554,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); } } } @@ -904,7 +878,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() ; } @@ -913,7 +887,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() ; } @@ -923,7 +897,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() ; } @@ -933,7 +907,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(); } @@ -943,7 +917,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(); } @@ -953,7 +927,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}* { @@ -962,7 +936,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... @@ -973,7 +947,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 @@ -987,7 +961,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}* { @@ -996,7 +970,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}+ { @@ -1087,7 +1061,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}+ { @@ -1096,7 +1070,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}+ { @@ -1105,7 +1079,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}* { @@ -1130,7 +1104,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 ); } } @@ -1150,8 +1124,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. @@ -1171,26 +1145,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>":" { @@ -1199,12 +1173,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) @@ -1213,18 +1187,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(';'); @@ -1235,10 +1213,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 ); @@ -1960,15 +1942,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; @@ -4491,7 +4468,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()); } } /* @@ -4704,8 +4681,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>"(" { @@ -4857,12 +4834,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() ; @@ -4880,25 +4857,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 @@ -4909,7 +4886,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } <FuncQual>{BN}*"->"{BN}* { lineCount(); - current->argList->trailingReturnType = " -> "; + current->argList.trailingReturnType = " -> "; current->args += " -> "; BEGIN(TrailingReturn); } @@ -4918,12 +4895,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}* { @@ -5009,9 +4986,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 ); } @@ -5048,6 +5024,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); @@ -5479,7 +5459,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>";" { @@ -5509,7 +5489,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 ) ; } @@ -5538,16 +5518,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; @@ -5585,7 +5560,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 @@ -5759,9 +5734,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 ); } @@ -5821,7 +5795,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 @@ -5839,24 +5813,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 { @@ -6038,9 +6012,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 ); } @@ -6461,7 +6434,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 ); @@ -6864,16 +6837,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("; @@ -7068,17 +7041,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; @@ -7095,7 +7066,7 @@ static void handleParametersCommentBlocks(ArgumentList *al) while (parseCommentBlock( g_thisParser, current.get(), - a->docs, // text + a.docs, // text yyFileName, // file current->docLine, // line of block start FALSE, @@ -7114,7 +7085,7 @@ static void handleParametersCommentBlocks(ArgumentList *al) { newEntry(); } - a->docs = current->doc; + a.docs = current->doc; // restore context current->doc = orgDoc; 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/tagreader.cpp b/src/tagreader.cpp index 18f6161..f498c5f 100644 --- a/src/tagreader.cpp +++ b/src/tagreader.cpp @@ -1183,8 +1183,6 @@ void TagFileParser::buildMemberList(const std::unique_ptr<Entry> &ce,QList<TagMe 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) @@ -1356,23 +1354,17 @@ void TagFileParser::buildLists(const std::unique_ptr<Entry> &root) } 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); diff --git a/src/tclscanner.l b/src/tclscanner.l index 3b939ce..d0fb564 100644 --- a/src/tclscanner.l +++ b/src/tclscanner.l @@ -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; diff --git a/src/util.cpp b/src/util.cpp index e1e9fb5..1aba32b 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); @@ -2705,19 +2701,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 +3294,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 +3539,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 +3554,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 +3578,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 +3624,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 +3659,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 +3679,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 +3701,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 +3866,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 +3996,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 +4027,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 +4113,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 +4217,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 +4233,6 @@ bool getDefs(const QCString &scName, md=mmd; found=TRUE; } - if (args) - { - delete argList; argList=0; - } } } if (!found && args && !qstrcmp(args,"()")) @@ -5820,10 +5661,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; } @@ -6429,7 +6270,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('<'); @@ -6445,16 +6286,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) @@ -6490,12 +6327,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; @@ -6504,82 +6341,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; } @@ -6591,6 +6435,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. */ @@ -6607,6 +6452,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 @@ -8045,22 +7891,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); @@ -305,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, @@ -407,7 +407,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); @@ -424,7 +424,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 fca010e..7db56c3 100644 --- a/src/vhdldocgen.cpp +++ b/src/vhdldocgen.cpp @@ -899,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; @@ -918,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 @@ -1158,10 +1126,8 @@ void VhdlDocGen::prepareComment(QCString& qcs) * @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; @@ -1450,44 +1416,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) @@ -1506,13 +1471,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(); @@ -1520,10 +1483,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) @@ -1545,9 +1508,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); @@ -1557,9 +1520,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(); @@ -1587,21 +1549,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; @@ -1618,15 +1578,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(" ( ) "); @@ -1635,13 +1593,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); @@ -1649,17 +1606,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)) { @@ -1672,8 +1629,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(); @@ -1702,28 +1659,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; } @@ -2003,7 +1958,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; @@ -2021,11 +1976,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: @@ -2090,7 +2045,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: @@ -2984,8 +2939,8 @@ ferr: n1,uu,uu, 0, Public, Normal, cur->stat,Member, MemberType_Variable, - 0, - 0, + ArgumentList(), + ArgumentList(), ""); if (ar->getOutputFileBase()) @@ -4055,34 +4010,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 ae10f4d..39981a0 100644 --- a/src/vhdljjparser.cpp +++ b/src/vhdljjparser.cpp @@ -441,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; @@ -532,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; @@ -540,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) @@ -562,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+=","; } 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; } } } |