diff options
Diffstat (limited to 'src/util.cpp')
-rw-r--r-- | src/util.cpp | 171 |
1 files changed, 85 insertions, 86 deletions
diff --git a/src/util.cpp b/src/util.cpp index f92df68..e6fece3 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -346,8 +346,8 @@ int guessSection(const char *name) return 0; } -QCString resolveTypeDef(Definition *context,const QCString &qualifiedName, - Definition **typedefContext) +QCString resolveTypeDef(const Definition *context,const QCString &qualifiedName, + const Definition **typedefContext) { //printf("<<resolveTypeDef(%s,%s)\n", // context ? context->name().data() : "<none>",qualifiedName.data()); @@ -358,7 +358,7 @@ QCString resolveTypeDef(Definition *context,const QCString &qualifiedName, return result; } - Definition *mContext=context; + const Definition *mContext=context; if (typedefContext) *typedefContext=context; // see if the qualified name has a scope part @@ -378,7 +378,7 @@ QCString resolveTypeDef(Definition *context,const QCString &qualifiedName, while (mContext && md==0) { // step 1: get the right scope - Definition *resScope=mContext; + const Definition *resScope=mContext; if (scopeIndex!=-1) { // split-off scope part @@ -559,7 +559,7 @@ ClassDef *newResolveTypedef(const FileDef *fileScope,MemberDef *md, g_resolvedTypedefs.insert(qname,md); // put on the trace list - ClassDef *typeClass = md->getClassDef(); + const ClassDef *typeClass = md->getClassDef(); QCString type = md->typeString(); // get the "value" of the typedef if (typeClass && typeClass->isTemplate() && actTemplParams && actTemplParams->count()>0) @@ -730,7 +730,7 @@ static QCString substTypedef(const Definition *scope,const FileDef *fileScope,co return result; } -static Definition *endOfPathIsUsedClass(SDict<Definition> *cl,const QCString &localName) +static const Definition *endOfPathIsUsedClass(const SDict<Definition> *cl,const QCString &localName) { if (cl) { @@ -1011,13 +1011,13 @@ int isAccessibleFrom(const Definition *scope,const FileDef *fileScope,const Defi { const NamespaceDef *nscope = dynamic_cast<const NamespaceDef*>(scope); //printf(" %s is namespace with %d used classes\n",nscope->name().data(),nscope->getUsedClasses()); - SDict<Definition> *cl = nscope->getUsedClasses(); + const SDict<Definition> *cl = nscope->getUsedClasses(); if (accessibleViaUsingClass(cl,fileScope,item)) { //printf("> found via used class\n"); goto done; } - NamespaceSDict *nl = nscope->getUsedNamespaces(); + const NamespaceSDict *nl = nscope->getUsedNamespaces(); if (accessibleViaUsingNamespace(nl,fileScope,item)) { //printf("> found via used namespace\n"); @@ -1115,11 +1115,11 @@ int isAccessibleFromWithExpScope(const Definition *scope,const FileDef *fileScop // in A via a using directive. //printf("newScope is a namespace: %s!\n",newScope->name().data()); const NamespaceDef *nscope = dynamic_cast<const NamespaceDef*>(newScope); - SDict<Definition> *cl = nscope->getUsedClasses(); + const SDict<Definition> *cl = nscope->getUsedClasses(); if (cl) { SDict<Definition>::Iterator cli(*cl); - Definition *cd; + const Definition *cd; for (cli.toFirst();(cd=cli.current());++cli) { //printf("Trying for class %s\n",cd->name().data()); @@ -1130,11 +1130,11 @@ int isAccessibleFromWithExpScope(const Definition *scope,const FileDef *fileScop } } } - NamespaceSDict *nl = nscope->getUsedNamespaces(); + const NamespaceSDict *nl = nscope->getUsedNamespaces(); if (nl) { NamespaceSDict::Iterator nli(*nl); - NamespaceDef *nd; + const NamespaceDef *nd; for (nli.toFirst();(nd=nli.current());++nli) { if (g_visitedNamespaces.find(nd->name())==0) @@ -1166,7 +1166,7 @@ int isAccessibleFromWithExpScope(const Definition *scope,const FileDef *fileScop if (scope->definitionType()==Definition::TypeNamespace) { const NamespaceDef *nscope = dynamic_cast<const NamespaceDef*>(scope); - NamespaceSDict *nl = nscope->getUsedNamespaces(); + const NamespaceSDict *nl = nscope->getUsedNamespaces(); if (accessibleViaUsingNamespace(nl,fileScope,item,explicitScopePart)) { //printf("> found in used namespace\n"); @@ -1177,7 +1177,7 @@ int isAccessibleFromWithExpScope(const Definition *scope,const FileDef *fileScop { if (fileScope) { - NamespaceSDict *nl = fileScope->getUsedNamespaces(); + const NamespaceSDict *nl = fileScope->getUsedNamespaces(); if (accessibleViaUsingNamespace(nl,fileScope,item,explicitScopePart)) { //printf("> found in used namespace\n"); @@ -2077,11 +2077,11 @@ void linkifyText(const TextGeneratorIntf &out, const Definition *scope, bool found=FALSE; if (!insideString) { - ClassDef *cd=0; - FileDef *fd=0; MemberDef *md=0; - NamespaceDef *nd=0; - GroupDef *gd=0; + const ClassDef *cd=0; + const FileDef *fd=0; + const NamespaceDef *nd=0; + const GroupDef *gd=0; //printf("** Match word '%s'\n",matchWord.data()); MemberDef *typeDef=0; @@ -2249,12 +2249,12 @@ void writeExample(OutputList &ol,ExampleSDict *ed) } -QCString argListToString(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); - Argument *a=ali.current(); + const Argument *a=ali.current(); result+="("; while (a) { @@ -2297,13 +2297,13 @@ QCString argListToString(ArgumentList *al,bool useCanonicalType,bool showDefVals return removeRedundantWhiteSpace(result); } -QCString tempArgListToString(ArgumentList *al,SrcLangExt lang) +QCString tempArgListToString(const ArgumentList *al,SrcLangExt lang) { QCString result; if (al==0) return result; result="<"; ArgumentListIterator ali(*al); - Argument *a=ali.current(); + const Argument *a=ali.current(); while (a) { if (!a->name.isEmpty()) // add template argument name @@ -2662,7 +2662,7 @@ int minClassDistance(const ClassDef *cd,const ClassDef *bcd,int level) return m; } -Protection classInheritedProtectionLevel(ClassDef *cd,ClassDef *bcd,Protection prot,int level) +Protection classInheritedProtectionLevel(const ClassDef *cd,const ClassDef *bcd,Protection prot,int level) { if (bcd->categoryOf()) // use class that is being extended in case of // an Objective-C category @@ -2681,7 +2681,7 @@ Protection classInheritedProtectionLevel(ClassDef *cd,ClassDef *bcd,Protection p else if (cd->baseClasses()) { BaseClassListIterator bcli(*cd->baseClasses()); - BaseClassDef *bcdi; + const BaseClassDef *bcdi; for (;(bcdi=bcli.current()) && prot!=Private;++bcli) { Protection baseProt = classInheritedProtectionLevel(bcdi->classDef,bcd,bcdi->prot,level+1); @@ -3448,9 +3448,9 @@ static QCString stripDeclKeywords(const QCString &s) } // forward decl for circular dependencies -static QCString extractCanonicalType(Definition *d,FileDef *fs,QCString type); +static QCString extractCanonicalType(const Definition *d,const FileDef *fs,QCString type); -QCString getCanonicalTemplateSpec(Definition *d,FileDef *fs,const QCString& spec) +QCString getCanonicalTemplateSpec(const Definition *d,const FileDef *fs,const QCString& spec) { QCString templSpec = spec.stripWhiteSpace(); @@ -3471,7 +3471,7 @@ QCString getCanonicalTemplateSpec(Definition *d,FileDef *fs,const QCString& spec static QCString getCanonicalTypeForIdentifier( - Definition *d,FileDef *fs,const QCString &word, + const Definition *d,const FileDef *fs,const QCString &word, QCString *tSpec,int count=0) { if (count>10) return word; // oops recursion @@ -3607,7 +3607,7 @@ static QCString getCanonicalTypeForIdentifier( return result; } -static QCString extractCanonicalType(Definition *d,FileDef *fs,QCString type) +static QCString extractCanonicalType(const Definition *d,const FileDef *fs,QCString type) { type = type.stripWhiteSpace(); @@ -3677,7 +3677,7 @@ static QCString extractCanonicalType(Definition *d,FileDef *fs,QCString type) return removeRedundantWhiteSpace(canType); } -static QCString extractCanonicalArgType(Definition *d,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; @@ -3701,8 +3701,8 @@ static QCString extractCanonicalArgType(Definition *d,FileDef *fs,const Argument } static bool matchArgument2( - Definition *srcScope,FileDef *srcFileScope,Argument *srcA, - Definition *dstScope,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", @@ -3762,10 +3762,9 @@ static bool matchArgument2( // new algorithm for argument matching -bool matchArguments2(Definition *srcScope,FileDef *srcFileScope,ArgumentList *srcAl, - Definition *dstScope,FileDef *dstFileScope,ArgumentList *dstAl, - bool checkCV - ) +bool matchArguments2(const Definition *srcScope,const FileDef *srcFileScope,ArgumentList *srcAl, + const Definition *dstScope,const FileDef *dstFileScope,ArgumentList *dstAl, + bool checkCV) { //printf("*** matchArguments2\n"); ASSERT(srcScope!=0 && dstScope!=0); @@ -3987,7 +3986,7 @@ void mergeArguments(ArgumentList *srcAl,ArgumentList *dstAl,bool forceNameOverwr static void findMembersWithSpecificName(MemberName *mn, const char *args, bool checkStatics, - FileDef *currentFile, + const FileDef *currentFile, bool checkCV, const char *forceTagFile, QList<MemberDef> &members) @@ -3995,11 +3994,11 @@ static void findMembersWithSpecificName(MemberName *mn, //printf(" Function with global scope name `%s' args=`%s'\n", // mn->memberName(),args); MemberNameIterator mli(*mn); - MemberDef *md; + const MemberDef *md = 0; for (mli.toFirst();(md=mli.current());++mli) { - FileDef *fd=md->getFileDef(); - GroupDef *gd=md->getGroupDef(); + const FileDef *fd=md->getFileDef(); + const GroupDef *gd=md->getGroupDef(); //printf(" md->name()=`%s' md->args=`%s' fd=%p gd=%p current=%p ref=%s\n", // md->name().data(),args,fd,gd,currentFile,md->getReference().data()); if ( @@ -4057,12 +4056,12 @@ bool getDefs(const QCString &scName, const QCString &mbName, const char *args, MemberDef *&md, - ClassDef *&cd, - FileDef *&fd, - NamespaceDef *&nd, - GroupDef *&gd, + const ClassDef *&cd, + const FileDef *&fd, + const NamespaceDef *&nd, + const GroupDef *&gd, bool forceEmptyScope, - FileDef *currentFile, + const FileDef *currentFile, bool checkCV, const char *forceTagFile ) @@ -4225,7 +4224,7 @@ bool getDefs(const QCString &scName, if (tmd && tmd->isEnumerate() && tmd->isStrong()) // scoped enum { //printf("Found scoped enum!\n"); - MemberList *tml = tmd->enumFieldList(); + const MemberList *tml = tmd->enumFieldList(); if (tml) { MemberListIterator tmi(*tml); @@ -4339,7 +4338,7 @@ bool getDefs(const QCString &scName, { //printf("mmd->getNamespaceDef()=%p fnd=%p\n", // mmd->getNamespaceDef(),fnd); - MemberDef *emd = mmd->getEnumScope(); + const MemberDef *emd = mmd->getEnumScope(); if (emd && emd->isStrong()) { //printf("yes match %s<->%s!\n",mScope.data(),emd->localName().data()); @@ -4358,7 +4357,7 @@ bool getDefs(const QCString &scName, return FALSE; } } - else if (mmd->getNamespaceDef()==fnd /* && mmd->isLinkable() */ ) + else if (mmd->getOuterScope()==fnd /* && mmd->isLinkable() */ ) { // namespace is found bool match=TRUE; ArgumentList *argList=0; @@ -4408,7 +4407,7 @@ bool getDefs(const QCString &scName, } else { - gd=md->getGroupDef(); + gd=md->resolveAlias()->getGroupDef(); if (gd && gd->isLinkable()) nd=0; else gd=0; return TRUE; } @@ -4421,7 +4420,7 @@ bool getDefs(const QCString &scName, MemberDef *mmd; for (mmli.toFirst();(mmd=mmli.current());++mmli) { - MemberDef *tmd = mmd->getEnumScope(); + const MemberDef *tmd = mmd->getEnumScope(); //printf("try member %s tmd=%s\n",mmd->name().data(),tmd?tmd->name().data():"<none>"); int ni=namespaceName.findRev("::"); //printf("namespaceName=%s ni=%d\n",namespaceName.data(),ni); @@ -4475,7 +4474,7 @@ bool getDefs(const QCString &scName, //printf("member is linkable md->name()=`%s'\n",md->name().data()); fd=md->getFileDef(); gd=md->getGroupDef(); - MemberDef *tmd = md->getEnumScope(); + const MemberDef *tmd = md->getEnumScope(); if ( (gd && gd->isLinkable()) || (fd && fd->isLinkable()) || (tmd && tmd->isStrong()) @@ -4602,10 +4601,10 @@ static bool isLowerCase(QCString &s) bool resolveRef(/* in */ const char *scName, /* in */ const char *name, /* in */ bool inSeeBlock, - /* out */ Definition **resContext, - /* out */ MemberDef **resMember, + /* out */ const Definition **resContext, + /* out */ const MemberDef **resMember, bool lookForSpecialization, - FileDef *currentFile, + const FileDef *currentFile, bool checkScope ) { @@ -4705,10 +4704,10 @@ bool resolveRef(/* in */ const char *scName, QCString scopeStr=scName; MemberDef *md = 0; - ClassDef *cd = 0; - FileDef *fd = 0; - NamespaceDef *nd = 0; - GroupDef *gd = 0; + const ClassDef *cd = 0; + const FileDef *fd = 0; + const NamespaceDef *nd = 0; + const GroupDef *gd = 0; // check if nameStr is a member or global. //printf("getDefs(scope=%s,name=%s,args=%s checkScope=%d)\n", @@ -4876,7 +4875,7 @@ bool generateRef(OutputDocInterface &od,const char *scName, bool resolveLink(/* in */ const char *scName, /* in */ const char *lr, /* in */ bool /*inSeeBlock*/, - /* out */ Definition **resContext, + /* out */ const Definition **resContext, /* out */ QCString &resAnchor ) { @@ -4885,12 +4884,12 @@ bool resolveLink(/* in */ const char *scName, QCString linkRef=lr; QCString linkRefWithoutTemplates = stripTemplateSpecifiersFromScope(linkRef,FALSE); //printf("ResolveLink linkRef=%s\n",lr); - FileDef *fd; - GroupDef *gd; - PageDef *pd; - ClassDef *cd; - DirDef *dir; - NamespaceDef *nd; + const FileDef *fd; + const GroupDef *gd; + const PageDef *pd; + const ClassDef *cd; + const DirDef *dir; + const NamespaceDef *nd; SectionInfo *si=0; bool ambig; if (linkRef.isEmpty()) // no reference name! @@ -4899,7 +4898,7 @@ bool resolveLink(/* in */ const char *scName, } else if ((pd=Doxygen::pageSDict->find(linkRef))) // link to a page { - GroupDef *gd = pd->getGroupDef(); + const GroupDef *gd = pd->getGroupDef(); if (gd) { if (!pd->name().isEmpty()) si=Doxygen::sectionDict->find(pd->name()); @@ -4971,7 +4970,7 @@ bool resolveLink(/* in */ const char *scName, } else // probably a member reference { - MemberDef *md; + const MemberDef *md = 0; bool res = resolveRef(scName,lr,TRUE,resContext,&md); if (md) resAnchor=md->anchor(); return res; @@ -4990,7 +4989,7 @@ bool generateLink(OutputDocInterface &od,const char *clName, const char *lr,bool inSeeBlock,const char *lt) { //printf("generateLink(clName=%s,lr=%s,lr=%s)\n",clName,lr,lt); - Definition *compound; + const Definition *compound = 0; //PageDef *pageDef=0; QCString anchor,linkText=linkToText(SrcLangExt_Unknown,lt,FALSE); //printf("generateLink linkText=%s\n",linkText.data()); @@ -5002,7 +5001,7 @@ bool generateLink(OutputDocInterface &od,const char *clName, compound->definitionType()==Definition::TypeGroup /* is group */ ) { - linkText=(dynamic_cast<GroupDef *>(compound))->groupTitle(); // use group's title as link + linkText=(dynamic_cast<const GroupDef *>(compound))->groupTitle(); // use group's title as link } else if (compound->definitionType()==Definition::TypeFile) { @@ -5379,7 +5378,7 @@ static void initBaseClassHierarchy(BaseClassList *bcl) } //---------------------------------------------------------------------------- -bool classHasVisibleChildren(ClassDef *cd) +bool classHasVisibleChildren(const ClassDef *cd) { BaseClassList *bcl; @@ -5421,14 +5420,14 @@ void initClassHierarchy(ClassSDict *cl) //---------------------------------------------------------------------------- -bool hasVisibleRoot(BaseClassList *bcl) +bool hasVisibleRoot(const BaseClassList *bcl) { if (bcl) { BaseClassListIterator bcli(*bcl); for ( ; bcli.current(); ++bcli) { - ClassDef *cd=bcli.current()->classDef; + const ClassDef *cd=bcli.current()->classDef; if (cd->isVisibleInHierarchy()) return TRUE; hasVisibleRoot(cd->baseClasses()); } @@ -6154,7 +6153,7 @@ QCString getOverloadDocs() void addMembersToMemberGroup(MemberList *ml, MemberGroupSDict **ppMemberGroupSDict, - Definition *context) + const Definition *context) { ASSERT(context!=0); //printf("addMemberToMemberGroup()\n"); @@ -6166,7 +6165,7 @@ void addMembersToMemberGroup(MemberList *ml, { if (md->isEnumerate()) // insert enum value of this enum into groups { - MemberList *fmdl=md->enumFieldList(); + const MemberList *fmdl=md->enumFieldList(); if (fmdl!=0) { MemberListIterator fmli(*fmdl); @@ -6324,7 +6323,7 @@ int extractClassNameFromType(const QCString &type,int &pos,QCString &name,QCStri QCString normalizeNonTemplateArgumentsInString( const QCString &name, - Definition *context, + const Definition *context, const ArgumentList * formalArgs) { // skip until < @@ -6656,7 +6655,7 @@ found: PageDef *addRelatedPage(const char *name,const QCString &ptitle, const QCString &doc, - QList<SectionInfo> * /*anchors*/, + const QList<SectionInfo> * /*anchors*/, const char *fileName,int startLine, const QList<ListItemInfo> *sli, GroupDef *gd, @@ -6782,7 +6781,7 @@ void addRefItem(const QList<ListItemInfo> *sli, } } -bool recursivelyAddGroupListToTitle(OutputList &ol,Definition *d,bool root) +bool recursivelyAddGroupListToTitle(OutputList &ol,const Definition *d,bool root) { GroupList *groups = d->partOfGroups(); if (groups) // write list of group to which this definition belongs @@ -6815,7 +6814,7 @@ bool recursivelyAddGroupListToTitle(OutputList &ol,Definition *d,bool root) return false; } -void addGroupListToTitle(OutputList &ol,Definition *d) +void addGroupListToTitle(OutputList &ol,const Definition *d) { recursivelyAddGroupListToTitle(ol,d,TRUE); } @@ -7432,7 +7431,7 @@ SrcLangExt getLanguageFromFileName(const QCString& fileName) //-------------------------------------------------------------------------- -MemberDef *getMemberFromSymbol(Definition *scope,FileDef *fileScope, +MemberDef *getMemberFromSymbol(const Definition *scope,const FileDef *fileScope, const char *n) { if (scope==0 || @@ -7504,7 +7503,7 @@ MemberDef *getMemberFromSymbol(Definition *scope,FileDef *fileScope, } /*! Returns true iff the given name string appears to be a typedef in scope. */ -bool checkIfTypedef(Definition *scope,FileDef *fileScope,const char *n) +bool checkIfTypedef(const Definition *scope,const FileDef *fileScope,const char *n) { MemberDef *bestMatch = getMemberFromSymbol(scope,fileScope,n); @@ -7931,7 +7930,7 @@ QCString expandAlias(const QCString &aliasName,const QCString &aliasValue) return result; } -void writeTypeConstraints(OutputList &ol,Definition *d,ArgumentList *al) +void writeTypeConstraints(OutputList &ol,const Definition *d,ArgumentList *al) { if (al==0) return; ol.startConstraintList(theTranslator->trTypeConstraints()); @@ -8549,7 +8548,7 @@ QCString stripIndentation(const QCString &s) } -bool fileVisibleInIndex(FileDef *fd,bool &genSourceFile) +bool fileVisibleInIndex(const FileDef *fd,bool &genSourceFile) { static bool allExternals = Config_getBool(ALLEXTERNALS); bool isDocFile = fd->isDocumentationFile(); @@ -8668,12 +8667,12 @@ uint getUtf8CodeToUpper( const QCString& s, int idx ) //-------------------------------------------------------------------------------------- -bool namespaceHasVisibleChild(NamespaceDef *nd,bool includeClasses,bool filterClasses,ClassDef::CompoundType ct) +bool namespaceHasVisibleChild(const NamespaceDef *nd,bool includeClasses,bool filterClasses,ClassDef::CompoundType ct) { if (nd->getNamespaceSDict()) { NamespaceSDict::Iterator cnli(*nd->getNamespaceSDict()); - NamespaceDef *cnd; + const NamespaceDef *cnd; for (cnli.toFirst();(cnd=cnli.current());++cnli) { if (cnd->isLinkableInProject() && cnd->localName().find('@')==-1) @@ -8688,7 +8687,7 @@ bool namespaceHasVisibleChild(NamespaceDef *nd,bool includeClasses,bool filterCl } if (includeClasses) { - ClassSDict *d = nd->getClassSDict(); + const ClassSDict *d = nd->getClassSDict(); if (filterClasses) { if (ct == ClassDef::Interface) @@ -8708,7 +8707,7 @@ bool namespaceHasVisibleChild(NamespaceDef *nd,bool includeClasses,bool filterCl if (d) { ClassSDict::Iterator cli(*d); - ClassDef *cd; + const ClassDef *cd; for (;(cd=cli.current());++cli) { if (cd->isLinkableInProject() && cd->templateMaster()==0) @@ -8723,7 +8722,7 @@ bool namespaceHasVisibleChild(NamespaceDef *nd,bool includeClasses,bool filterCl //---------------------------------------------------------------------------- -bool classVisibleInIndex(ClassDef *cd) +bool classVisibleInIndex(const ClassDef *cd) { static bool allExternals = Config_getBool(ALLEXTERNALS); return (allExternals && cd->isLinkable()) || cd->isLinkableInProject(); |