diff options
Diffstat (limited to 'src/vhdldocgen.cpp')
-rw-r--r-- | src/vhdldocgen.cpp | 196 |
1 files changed, 70 insertions, 126 deletions
diff --git a/src/vhdldocgen.cpp b/src/vhdldocgen.cpp index 38a80ef..3585230 100644 --- a/src/vhdldocgen.cpp +++ b/src/vhdldocgen.cpp @@ -71,7 +71,8 @@ static QDict<QCString> g_vhdlKeyDict3(17,FALSE); static void initUCF(Entry* root,const char* type,QCString & qcs,int line,QCString & fileName,QCString & brief); static void writeUCFLink(const MemberDef* mdef,OutputList &ol); static void assignBinding(VhdlConfNode* conf); -static void addInstance(ClassDef* entity, ClassDef* arch, ClassDef *inst,Entry *cur,ClassDef* archBind=NULL); +static void addInstance(ClassDef* entity, ClassDef* arch, ClassDef *inst, + const std::unique_ptr<Entry> &cur); //---------- create svg ------------------------------------------------------------- static void createSVG(); @@ -898,12 +899,9 @@ void VhdlDocGen::findAllPackages( ClassDef *cdef) * is called in vhdlcode.l */ -MemberDef* VhdlDocGen::findFunction(const QList<Argument> &ql, - const QCString& funcname, - const QCString& package, bool /*type*/) +MemberDef* VhdlDocGen::findFunction(const QCString& funcname, const QCString& package) { MemberDef* mdef=0; - //int funcType; ClassDef *cdef=getClass(package.data()); if (cdef==0) return 0; @@ -917,40 +915,11 @@ MemberDef* VhdlDocGen::findFunction(const QList<Argument> &ql, QCString mname=mdef->name(); if ((VhdlDocGen::isProcedure(mdef) || VhdlDocGen::isVhdlFunction(mdef)) && (compareString(funcname,mname)==0)) { - ArgumentList *alp = mdef->argumentList(); - - // ArgumentList* arg2=mdef->getArgumentList(); - if (alp==0) break; - ArgumentListIterator ali(*alp); - ArgumentListIterator ali1(ql); - - if (ali.count() != ali1.count()) break; - - Argument *arg,*arg1; - int equ=0; - - for (;(arg=ali.current()) && (arg1=ali1.current());++ali,++ali1) - { - equ+=abs(compareString(arg->type,arg1->type)); - - QCString s1=arg->type; - QCString s2=arg1->type; - VhdlDocGen::deleteAllChars(s1,' '); - VhdlDocGen::deleteAllChars(s2,' '); - equ+=abs(compareString(s1,s2)); - s1=arg->attrib; - s2=arg1->attrib; - VhdlDocGen::deleteAllChars(s1,' '); - VhdlDocGen::deleteAllChars(s2,' '); - equ+=abs(compareString(s1,s2)); - // printf("\n 1. type [%s] name [%s] attrib [%s]",arg->type,arg->name,arg->attrib); - // printf("\n 2. type [%s] name [%s] attrib [%s]",arg1->type,arg1->name,arg1->attrib); - } // for - if (equ==0) return mdef; + return mdef; }//if }//for }//if - return mdef; + return 0; } //findFunction @@ -1152,15 +1121,12 @@ void VhdlDocGen::prepareComment(QCString& qcs) /*! * parses a function proto * @param text function string - * @param qlist stores the function types * @param name points to the function name * @param ret Stores the return type * @param doc ??? */ -void VhdlDocGen::parseFuncProto(const char* text,QList<Argument>& qlist, - QCString& name,QCString& ret,bool doc) +void VhdlDocGen::parseFuncProto(const char* text,QCString& name,QCString& ret,bool doc) { - (void)qlist; //unused int index,end; QCString s1(text); QCString temp; @@ -1449,44 +1415,43 @@ void VhdlDocGen::formatString(const QCString &s, OutputList& ol,const MemberDef* * writes a procedure prototype to the output */ -void VhdlDocGen::writeProcedureProto(OutputList& ol,const ArgumentList* al,const MemberDef* mdef) +void VhdlDocGen::writeProcedureProto(OutputList& ol,const ArgumentList &al,const MemberDef* mdef) { - ArgumentListIterator ali(*al); - Argument *arg; bool sem=FALSE; - int len=al->count(); + int len=al.size(); ol.docify("( "); if (len > 2) { ol.lineBreak(); } - for (;(arg=ali.current());++ali) + for (const Argument &arg : al) { ol.startBold(); if (sem && len <3) ol.writeChar(','); - QCString nn=arg->name; + QCString nn=arg.name; nn+=": "; - QCString *str=VhdlDocGen::findKeyWord(arg->defval); - arg->defval+=" "; + QCString defval = arg.defval; + QCString *str=VhdlDocGen::findKeyWord(defval); + defval+=" "; if (str) { - startFonts(arg->defval,str->data(),ol); + startFonts(defval,str->data(),ol); } else { - startFonts(arg->defval,"vhdlchar",ol); // write type (variable,constant etc.) + startFonts(defval,"vhdlchar",ol); // write type (variable,constant etc.) } startFonts(nn,"vhdlchar",ol); // write name - if (qstricmp(arg->attrib,arg->type) != 0) + if (qstricmp(arg.attrib,arg.type) != 0) { - startFonts(arg->attrib.lower(),"stringliteral",ol); // write in|out + startFonts(arg.attrib.lower(),"stringliteral",ol); // write in|out } ol.docify(" "); - VhdlDocGen::formatString(arg->type,ol,mdef); + VhdlDocGen::formatString(arg.type,ol,mdef); sem=TRUE; ol.endBold(); if (len > 2) @@ -1505,13 +1470,11 @@ void VhdlDocGen::writeProcedureProto(OutputList& ol,const ArgumentList* al,const * writes a function prototype to the output */ -void VhdlDocGen::writeFunctionProto(OutputList& ol,const ArgumentList* al,const MemberDef* mdef) +void VhdlDocGen::writeFunctionProto(OutputList& ol,const ArgumentList &al,const MemberDef* mdef) { - if (al==0) return; - ArgumentListIterator ali(*al); - Argument *arg; + if (!al.hasParameters()) return; bool sem=FALSE; - int len=al->count(); + int len=al.size(); ol.startBold(); ol.docify(" ( "); ol.endBold(); @@ -1519,10 +1482,10 @@ void VhdlDocGen::writeFunctionProto(OutputList& ol,const ArgumentList* al,const { ol.lineBreak(); } - for (;(arg=ali.current());++ali) + for (const Argument &arg : al) { ol.startBold(); - QCString att=arg->defval; + QCString att=arg.defval; bool bGen=att.stripPrefix("gen!"); if (sem && len < 3) @@ -1544,9 +1507,9 @@ void VhdlDocGen::writeFunctionProto(OutputList& ol,const ArgumentList* al,const startFonts(att,"vhdlchar",ol); } - QCString nn=arg->name; + QCString nn=arg.name; nn+=": "; - QCString ss=arg->type.stripWhiteSpace(); //.lower(); + QCString ss=arg.type.stripWhiteSpace(); //.lower(); QCString w=ss.stripWhiteSpace();//.upper(); startFonts(nn,"vhdlchar",ol); startFonts("in ","stringliteral",ol); @@ -1556,9 +1519,8 @@ void VhdlDocGen::writeFunctionProto(OutputList& ol,const ArgumentList* al,const else startFonts(w,"vhdlchar",ol); - if (arg->attrib) - startFonts(arg->attrib,"vhdlchar",ol); - + if (arg.attrib) + startFonts(arg.attrib,"vhdlchar",ol); sem=TRUE; ol.endBold(); @@ -1586,21 +1548,19 @@ void VhdlDocGen::writeFunctionProto(OutputList& ol,const ArgumentList* al,const * writes a process prototype to the output */ -void VhdlDocGen::writeProcessProto(OutputList& ol,const ArgumentList* al,const MemberDef* mdef) +void VhdlDocGen::writeProcessProto(OutputList& ol,const ArgumentList &al,const MemberDef* mdef) { - if (al==0) return; - ArgumentListIterator ali(*al); - Argument *arg; + if (!al.hasParameters()) return; bool sem=FALSE; ol.startBold(); ol.docify(" ( "); - for (;(arg=ali.current());++ali) + for (const Argument &arg : al) { if (sem) { ol.docify(" , "); } - QCString nn=arg->name; + QCString nn=arg.name; // startFonts(nn,"vhdlchar",ol); VhdlDocGen::writeFormatString(nn,ol,mdef); sem=TRUE; @@ -1617,15 +1577,13 @@ void VhdlDocGen::writeProcessProto(OutputList& ol,const ArgumentList* al,const M bool VhdlDocGen::writeFuncProcDocu( const MemberDef *md, OutputList& ol, - const ArgumentList* al, + const ArgumentList &al, bool /*type*/) { - if (al==0) return FALSE; //bool sem=FALSE; ol.enableAll(); - ArgumentListIterator ali(*al); - int index=ali.count(); + int index=al.size(); if (index==0) { ol.docify(" ( ) "); @@ -1634,13 +1592,12 @@ bool VhdlDocGen::writeFuncProcDocu( ol.endMemberDocName(); ol.startParameterList(TRUE); //ol.startParameterName(FALSE); - Argument *arg; bool first=TRUE; - for (;(arg=ali.current());++ali) + for (const Argument &arg : al) { ol.startParameterType(first,""); // if (first) ol.writeChar('('); - QCString attl=arg->defval; + QCString attl=arg.defval; bool bGen=attl.stripPrefix("gen!"); if (bGen) VhdlDocGen::writeFormatString(QCString("generic "),ol,md); @@ -1648,17 +1605,17 @@ bool VhdlDocGen::writeFuncProcDocu( if (VhdlDocGen::isProcedure(md)) { - startFonts(arg->defval,"keywordtype",ol); + startFonts(arg.defval,"keywordtype",ol); ol.docify(" "); } ol.endParameterType(); ol.startParameterName(TRUE); - VhdlDocGen::writeFormatString(arg->name,ol,md); + VhdlDocGen::writeFormatString(arg.name,ol,md); if (VhdlDocGen::isProcedure(md)) { - startFonts(arg->attrib,"stringliteral",ol); + startFonts(arg.attrib,"stringliteral",ol); } else if (VhdlDocGen::isVhdlFunction(md)) { @@ -1671,8 +1628,8 @@ bool VhdlDocGen::writeFuncProcDocu( ol.enable(OutputGenerator::Man); if (!VhdlDocGen::isProcess(md)) { - // startFonts(arg->type,"vhdlkeyword",ol); - VhdlDocGen::writeFormatString(arg->type,ol,md); + // startFonts(arg.type,"vhdlkeyword",ol); + VhdlDocGen::writeFormatString(arg.type,ol,md); } ol.disable(OutputGenerator::Man); ol.endEmphasis(); @@ -1701,28 +1658,26 @@ bool VhdlDocGen::writeFuncProcDocu( -QCString VhdlDocGen::convertArgumentListToString(const ArgumentList* al,bool func) +QCString VhdlDocGen::convertArgumentListToString(const ArgumentList &al,bool func) { QCString argString; bool sem=FALSE; - ArgumentListIterator ali(*al); - Argument *arg; - for (;(arg=ali.current());++ali) + for (const Argument &arg : al) { if (sem) argString.append(", "); if (func) { - argString+=arg->name; + argString+=arg.name; argString+=":"; - argString+=arg->type; + argString+=arg.type; } else { - argString+=arg->defval+" "; - argString+=arg->name+" :"; - argString+=arg->attrib+" "; - argString+=arg->type; + argString+=arg.defval+" "; + argString+=arg.name+" :"; + argString+=arg.attrib+" "; + argString+=arg.type; } sem=TRUE; } @@ -2002,7 +1957,7 @@ void VhdlDocGen::writeVHDLDeclaration(const MemberDef* mdef,OutputList &ol, QCString ltype(mdef->typeString()); QCString largs(mdef->argsString()); ClassDef *kl=0; - const ArgumentList *alp = mdef->argumentList(); + const ArgumentList &al = mdef->argumentList(); QCString nn; //VhdlDocGen::adjustRecordMember(mdef); if (gd) gd=0; @@ -2020,11 +1975,11 @@ void VhdlDocGen::writeVHDLDeclaration(const MemberDef* mdef,OutputList &ol, ol.docify(" "); writeLink(mdef,ol); - if (alp!=0 && mm==VhdlDocGen::FUNCTION) - VhdlDocGen::writeFunctionProto(ol,alp,mdef); + if (al.hasParameters() && mm==VhdlDocGen::FUNCTION) + VhdlDocGen::writeFunctionProto(ol,al,mdef); - if (alp!=0 && mm==VhdlDocGen::PROCEDURE) - VhdlDocGen::writeProcedureProto(ol,alp,mdef); + if (al.hasParameters() && mm==VhdlDocGen::PROCEDURE) + VhdlDocGen::writeProcedureProto(ol,al,mdef); break; case VhdlDocGen::USE: @@ -2089,7 +2044,7 @@ void VhdlDocGen::writeVHDLDeclaration(const MemberDef* mdef,OutputList &ol, case VhdlDocGen::PROCESS: writeLink(mdef,ol); ol.insertMemberAlign(); - VhdlDocGen::writeProcessProto(ol,alp,mdef); + VhdlDocGen::writeProcessProto(ol,al,mdef); break; case VhdlDocGen::PACKAGE: case VhdlDocGen::ENTITY: @@ -2577,7 +2532,7 @@ static void initUCF(Entry* root,const char* type,QCString & qcs,int line,QCStr qcs.stripPrefix("="); - Entry* current=new Entry; + std::unique_ptr<Entry> current = std::make_unique<Entry>(); current->spec=VhdlDocGen::UCF_CONST; current->section=Entry::VARIABLE_SEC; current->bodyLine=line; @@ -2604,7 +2559,7 @@ static void initUCF(Entry* root,const char* type,QCString & qcs,int line,QCStr brief.resize(0); } - root->addSubEntry(current); + root->moveToSubEntryAndKeep(current); } @@ -2761,9 +2716,6 @@ QCString VhdlDocGen::parseForBinding(QCString & entity,QCString & arch) void assignBinding(VhdlConfNode * conf) { - QList<Entry> instList=getVhdlInstList(); - QListIterator<Entry> eli(instList); - Entry *cur=0; ClassDef *archClass=0,*entClass=0; QCString archName; QCString arcBind,entBind; @@ -2826,7 +2778,7 @@ void assignBinding(VhdlConfNode * conf) all=allOt.lower()=="all" ; others= allOt.lower()=="others"; - for (;(cur=eli.current());++eli) + for (const auto &cur : getVhdlInstList()) { if (cur->exception.lower()==label || conf->isInlineConf) { @@ -2909,11 +2861,7 @@ void VhdlDocGen::computeVhdlComponentRelations() assignBinding(conf); } - QList<Entry> qsl= getVhdlInstList(); - QListIterator<Entry> eli(qsl); - Entry *cur; - - for (eli.toFirst();(cur=eli.current());++eli) + for (const auto &cur : getVhdlInstList()) { if (cur->stat ) // was bind { @@ -2949,7 +2897,7 @@ void VhdlDocGen::computeVhdlComponentRelations() } static void addInstance(ClassDef* classEntity, ClassDef* ar, - ClassDef *cd , Entry *cur,ClassDef* /*archBind*/) + ClassDef *cd , const std::unique_ptr<Entry> &cur) { QCString bName,n1; @@ -2990,8 +2938,8 @@ ferr: n1,uu,uu, 0, Public, Normal, cur->stat,Member, MemberType_Variable, - 0, - 0, + ArgumentList(), + ArgumentList(), ""); if (ar->getOutputFileBase()) @@ -3185,10 +3133,10 @@ void VhdlDocGen::createFlowChart(const MemberDef *mdef) VHDLLanguageScanner *pIntf =(VHDLLanguageScanner*) Doxygen::parserManager->getParser(".vhd"); VhdlDocGen::setFlowMember(mdef); - Entry root; + std::unique_ptr<Entry> root = std::make_unique<Entry>(); QStrList filesInSameTu; pIntf->startTranslationUnit(""); - pIntf->parseInput("",codeFragment.data(),&root,FALSE,filesInSameTu); + pIntf->parseInput("",codeFragment.data(),root,FALSE,filesInSameTu); pIntf->finishTranslationUnit(); } @@ -4061,34 +4009,30 @@ void FlowChart::writeEdge(FTextStream &t,int fl_from,int fl_to,int i,bool bFrom, t << "\n"; } -void FlowChart::alignFuncProc( QCString & q,const ArgumentList* al,bool isFunc) +void FlowChart::alignFuncProc( QCString & q,const ArgumentList &al,bool isFunc) { - if (al==0) return; - - ArgumentListIterator ali(*al); - int index=ali.count(); + int index=al.size(); if (index==0) return; int len=q.length()+VhdlDocGen::getFlowMember()->name().length(); QCString prev,temp; prev.fill(' ',len+1); - Argument *arg; q+="\n"; - for (;(arg=ali.current());++ali) + for (const Argument &arg : al) { - QCString attl=arg->defval+" "; - attl+=arg->name+" "; + QCString attl=arg.defval+" "; + attl+=arg.name+" "; if (!isFunc) { - attl+=arg->attrib+" "; + attl+=arg.attrib+" "; } else { attl+=" in "; } - attl+=arg->type; + attl+=arg.type; if (--index) attl+=",\n"; else attl+="\n"; attl.prepend(prev.data()); |