diff options
-rw-r--r-- | addon/doxyparse/README | 14 | ||||
-rw-r--r-- | addon/doxyparse/doxyparse.cpp | 147 | ||||
-rw-r--r-- | src/code.l | 16 | ||||
-rw-r--r-- | src/memberdef.cpp | 11 | ||||
-rw-r--r-- | src/memberdef.h | 5 |
5 files changed, 158 insertions, 35 deletions
diff --git a/addon/doxyparse/README b/addon/doxyparse/README index 288b31e..95cce8c 100644 --- a/addon/doxyparse/README +++ b/addon/doxyparse/README @@ -18,8 +18,20 @@ More info and source code repository: https://github.com/analizo/doxygen sudo make install +## release + +* ensure analizo testsuite passing on newer doxyparse version +* update debian/changelog, commit, push +* create git tag, push to github analizo/doxyparse +* build on amd64 and i386 archs, upload tar.gz to github + * tar -zcf doxyparse_<VERSION>_amd64.tar.gz -C bin/ doxyparse + * tar -zcf doxyparse_<VERSION>_i386.tar.gz -C bin/ doxyparse +* build debian packages for amd64 and i386, update analizo.org repository + * (see analizo.github.io/README.md file for updating repository instructions) + * upload the deb files to github release tag also +* check if a alien-doxyparse release is necessary and do it on cpan + AUTHORS -======= Antonio Terceiro <terceiro@softwarelivre.org> João M. Miranda <joaomm88@gmail.com> diff --git a/addon/doxyparse/doxyparse.cpp b/addon/doxyparse/doxyparse.cpp index 26ecea9..babf3d7 100644 --- a/addon/doxyparse/doxyparse.cpp +++ b/addon/doxyparse/doxyparse.cpp @@ -24,6 +24,7 @@ #else #include <windows.h> #endif +#include "version.h" #include "doxygen.h" #include "outputgen.h" #include "parserintf.h" @@ -40,6 +41,9 @@ #include <sstream> #include <map> #include <qdir.h> +#include <qcstring.h> +#include <qregexp.h> +#include "namespacedef.h" class Doxyparse : public CodeOutputInterface { @@ -81,8 +85,6 @@ class Doxyparse : public CodeOutputInterface }; static bool is_c_code = true; -static std::map<std::string, bool> modules; -static std::string current_module; static void findXRefSymbols(FileDef *fd) { @@ -107,7 +109,7 @@ static void findXRefSymbols(FileDef *fd) static bool ignoreStaticExternalCall(MemberDef *context, MemberDef *md) { if (md->isStatic()) { - if(md->getFileDef()) { + if(md->getFileDef() && context->getFileDef()) { if(md->getFileDef()->getOutputFileBase() == context->getFileDef()->getOutputFileBase()) // TODO ignore prefix of file return false; @@ -123,27 +125,48 @@ static bool ignoreStaticExternalCall(MemberDef *context, MemberDef *md) { } } +// that undo some replacing by src/util.cpp escapeCharsInString(...) +// * https://github.com/doxygen/doxygen/pull/577 +std::string unescapeCharsInString(std::string name) { + QCString module = QCString(name.c_str()); + bool replaced = false; + if (module.find('.') == -1) { + module.replace(QRegExp("_8"), "."); + replaced = true; + } + if (module.find('/') == -1) { + module.replace(QRegExp("_2"), "/"); + replaced = true; + } + if (replaced) { + module.replace(QRegExp("__"), "_"); + } + return module.data(); +} + +static void startYamlDocument() { + printf("---\n"); +} static void printFile(std::string file) { printf("%s:\n", file.c_str()); } static void printModule(std::string module) { - current_module = module; - printf(" %s:\n", module.c_str()); + printf(" \"%s\":\n", unescapeCharsInString(module).c_str()); } static void printClassInformation(std::string information) { printf(" information: %s\n", information.c_str()); } +static void printInherits() { + printf(" inherits:\n"); +} static void printInheritance(std::string base_class) { - printf(" inherits: %s\n", base_class.c_str()); + printf(" - %s\n", base_class.c_str()); } static void printDefines() { - if (! modules[current_module]) { - printf(" defines:\n"); - } - modules[current_module] = true; + printf(" defines:\n"); } static void printDefinition(std::string type, std::string signature, int line) { - printf(" - \"%s\":\n", signature.c_str()); + printf(" - \"%s\":\n", signature.substr(0, 1022).c_str()); printf(" type: %s\n", type.c_str()); printf(" line: %d\n", line); } @@ -160,44 +183,47 @@ static void printUses() { printf(" uses:\n"); } static void printReferenceTo(std::string type, std::string signature, std::string defined_in) { - printf(" - \"%s\":\n", signature.c_str()); + printf(" - \"%s\":\n", signature.substr(0, 1022).c_str()); printf(" type: %s\n", type.c_str()); - printf(" defined_in: %s\n", defined_in.c_str()); + printf(" defined_in: \"%s\"\n", unescapeCharsInString(defined_in).c_str()); +} +static void printNumberOfConditionalPaths(MemberDef* md) { + printf(" conditional_paths: %d\n", md->numberOfFlowKeyWords()); } static int isPartOfCStruct(MemberDef * md) { return is_c_code && md->getClassDef() != NULL; } -std::string removeDoubleQuotes(std::string data) { - // remove surrounding double quotes - if (data.front() == '"' && data.back() == '"') { - data.erase(0, 1); // first double quote - data.erase(data.size() - 1); // last double quote - } - return data; +std::string sanitizeString(std::string data) { + QCString new_data = QCString(data.c_str()); + new_data.replace(QRegExp("\""), ""); + new_data.replace(QRegExp("\\"), ""); // https://github.com/analizo/analizo/issues/138 + return !new_data.isEmpty() ? new_data.data() : ""; } std::string argumentData(Argument *argument) { std::string data = ""; - if (argument->type != NULL) - data = removeDoubleQuotes(argument->type.data()); + if (argument->type != NULL && argument->type.size() > 1) + data = sanitizeString(argument->type.data()); else if (argument->name != NULL) - data = removeDoubleQuotes(argument->name.data()); + data = sanitizeString(argument->name.data()); return data; } std::string functionSignature(MemberDef* md) { - std::string signature = md->name().data(); + std::string signature = sanitizeString(md->name().data()); if(md->isFunction()){ ArgumentList *argList = md->argumentList(); - ArgumentListIterator iterator(*argList); signature += "("; - Argument * argument = iterator.toFirst(); - if(argument != NULL) { - signature += argumentData(argument); - for(++iterator; (argument = iterator.current()); ++iterator){ - signature += std::string(",") + argumentData(argument); + if (argList) { + ArgumentListIterator iterator(*argList); + Argument * argument = iterator.toFirst(); + if(argument != NULL) { + signature += argumentData(argument); + for(++iterator; (argument = iterator.current()); ++iterator) { + signature += std::string(",") + argumentData(argument); + } } } signature += ")"; @@ -221,6 +247,9 @@ static void referenceTo(MemberDef* md) { else if (md->getFileDef()) { defined_in = md->getFileDef()->getOutputFileBase().data(); } + else if (md->getNamespaceDef()) { + defined_in = md->getNamespaceDef()->name().data(); + } } printReferenceTo(type, signature, defined_in); } @@ -228,6 +257,12 @@ static void referenceTo(MemberDef* md) { void cModule(ClassDef* cd) { MemberList* ml = cd->getMemberList(MemberListType_variableMembers); if (ml) { + FileDef *fd = cd->getFileDef(); + MemberList *fd_ml = fd->getMemberList(MemberListType_allMembersList); + if (!fd_ml || fd_ml->count() == 0) { + printModule(fd->getOutputFileBase().data()); + printDefines(); + } MemberListIterator mli(*ml); MemberDef* md; for (mli.toFirst(); (md=mli.current()); ++mli) { @@ -239,18 +274,50 @@ void cModule(ClassDef* cd) { } } +static bool checkOverrideArg(ArgumentList *argList, MemberDef *md) { + ArgumentListIterator iterator(*argList); + Argument * argument = iterator.toFirst(); + + if(!md->isFunction() || argList->count() == 0){ + return false; + } + + if(argument != NULL) { + for(; (argument = iterator.current()); ++iterator){ + if(md->name() == argument->name) { + return true; + } + } + } + + return false; +} + void functionInformation(MemberDef* md) { + std::string temp = ""; int size = md->getEndBodyLine() - md->getStartBodyLine() + 1; printNumberOfLines(size); ArgumentList *argList = md->argumentList(); - printNumberOfArguments(argList->count()); + if (argList) { + ArgumentListIterator iterator(*argList); + Argument * argument = iterator.toFirst(); + if(argument != NULL) { + temp = argumentData(argument); +// TODO: This is a workaround; better not include "void" in argList, in the first place. + if(temp != "void") { + printNumberOfArguments(argList->count()); + } + } + } + + printNumberOfConditionalPaths(md); MemberSDict *defDict = md->getReferencesMembers(); if (defDict) { MemberSDict::Iterator msdi(*defDict); MemberDef *rmd; printUses(); for (msdi.toFirst(); (rmd=msdi.current()); ++msdi) { - if (rmd->definitionType() == Definition::TypeMember && !ignoreStaticExternalCall(md, rmd)) { + if (rmd->definitionType() == Definition::TypeMember && !ignoreStaticExternalCall(md, rmd) && !checkOverrideArg(argList, rmd)) { referenceTo(rmd); } } @@ -276,7 +343,6 @@ void listMembers(MemberList *ml) { if (ml) { MemberListIterator mli(*ml); MemberDef *md; - printDefines(); for (mli.toFirst(); (md=mli.current()); ++mli) { lookupSymbol((Definition*) md); } @@ -299,6 +365,7 @@ static void classInformation(ClassDef* cd) { printModule(cd->name().data()); BaseClassList* baseClasses = cd->baseClasses(); if (baseClasses) { + printInherits(); BaseClassListIterator bci(*baseClasses); BaseClassDef* bcd; for (bci.toFirst(); (bcd = bci.current()); ++bci) { @@ -308,6 +375,7 @@ static void classInformation(ClassDef* cd) { if(cd->isAbstract()) { printClassInformation("abstract class"); } + printDefines(); listAllMembers(cd); } } @@ -356,6 +424,7 @@ static void listSymbols() { MemberList *ml = fd->getMemberList(MemberListType_allMembersList); if (ml && ml->count() > 0) { printModule(fd->getOutputFileBase().data()); + printDefines(); listMembers(ml); } @@ -364,7 +433,10 @@ static void listSymbols() { ClassSDict::Iterator cli(*classes); ClassDef *cd; for (cli.toFirst(); (cd = cli.current()); ++cli) { - classInformation(cd); + if (!cd->isVisited()) { + classInformation(cd); + cd->setVisited(TRUE); + } } } } @@ -377,6 +449,11 @@ int main(int argc,char **argv) { printf("Usage: %s [source_file | source_dir]\n",argv[0]); exit(1); } + if (qstrcmp(&argv[1][2], "version") == 0) { + QCString versionString = getVersion(); + printf("%s\n", versionString); + exit(0); + } // initialize data structures initDoxygen(); @@ -411,6 +488,7 @@ int main(int argc,char **argv) { Config_getBool(EXTRACT_STATIC)=TRUE; Config_getBool(EXTRACT_PRIVATE)=TRUE; Config_getBool(EXTRACT_LOCAL_METHODS)=TRUE; + Config_getBool(EXTRACT_PACKAGE)=TRUE; // Extract source browse information, needed // to make doxygen gather the cross reference info Config_getBool(SOURCE_BROWSER)=TRUE; @@ -464,6 +542,7 @@ int main(int argc,char **argv) { // clean up after us thisDir.rmdir(Config_getString(OUTPUT_DIRECTORY)); + startYamlDocument(); listSymbols(); std::string cleanup_command = "rm -rf "; @@ -2472,6 +2472,10 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" BEGIN(FuncCall); } <Body>{FLOWCONDITION}/{BN}*"(" { + if (g_currentMemberDef && g_currentMemberDef->isFunction()) + { + g_currentMemberDef->addFlowKeyWord(); + } startFontClass("keywordflow"); codifyLines(yytext); endFontClass(); @@ -2489,6 +2493,10 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" } } <Body>{FLOWCONDITION}/([^a-z_A-Z0-9]) { + if (g_currentMemberDef && g_currentMemberDef->isFunction()) + { + g_currentMemberDef->addFlowKeyWord(); + } startFontClass("keywordflow"); codifyLines(yytext); endFontClass(); @@ -2503,6 +2511,10 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" endFontClass(); } <Body>{FLOWCONDITION}/{B}* { + if (g_currentMemberDef && g_currentMemberDef->isFunction()) + { + g_currentMemberDef->addFlowKeyWord(); + } startFontClass("keywordflow"); codifyLines(yytext); endFontClass(); @@ -3038,6 +3050,10 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" endFontClass(); } <MemberCall2,FuncCall>{FLOWCONDITION}/([^a-z_A-Z0-9]) { + if (g_currentMemberDef && g_currentMemberDef->isFunction()) + { + g_currentMemberDef->addFlowKeyWord(); + } addParmType(); g_parmName=yytext; startFontClass("keywordflow"); diff --git a/src/memberdef.cpp b/src/memberdef.cpp index 4693bdb..d0b70bb 100644 --- a/src/memberdef.cpp +++ b/src/memberdef.cpp @@ -1581,6 +1581,7 @@ MemberDefImpl::MemberDefImpl(const char *df,int dl,int dc, //printf("MemberDefImpl::MemberDef(%s)\n",na); m_impl = new MemberDefImpl::IMPL; m_impl->init(this,t,a,e,p,v,s,r,mt,tal,al,meta); + number_of_flowkw = 1; m_isLinkableCached = 0; m_isConstructorCached = 0; m_isDestructorCached = 0; @@ -5970,6 +5971,16 @@ void MemberDefImpl::invalidateCachedArgumentTypes() invalidateCachedTypesInArgumentList(m_impl->declArgList); } +void MemberDef::addFlowKeyWord() +{ + number_of_flowkw++; +} + +int MemberDef::numberOfFlowKeyWords() +{ + return number_of_flowkw; +} + //---------------- QCString MemberDefImpl::displayName(bool) const diff --git a/src/memberdef.h b/src/memberdef.h index af4fb0a..a94005f 100644 --- a/src/memberdef.h +++ b/src/memberdef.h @@ -183,6 +183,7 @@ class MemberDef : virtual public Definition virtual bool isSliceLocal() const = 0; virtual bool isConstExpr() const = 0; + int numberOfFlowKeyWords(); // derived getters virtual bool isFriendToHide() const = 0; virtual bool isNotFriend() const = 0; @@ -280,6 +281,8 @@ class MemberDef : virtual public Definition // ---- setters ----- //----------------------------------------------------------------------------------- + void addFlowKeyWord(); + // set functions virtual void setMemberType(MemberType t) = 0; virtual void setDefinition(const char *d) = 0; @@ -405,6 +408,8 @@ class MemberDef : virtual public Definition const ClassDef *cd,const NamespaceDef *nd,const FileDef *fd,const GroupDef *gd, bool onlyText=FALSE) const = 0; + int number_of_flowkw; + // write helpers virtual void warnIfUndocumented() const = 0; virtual void warnIfUndocumentedParams() const = 0; |