diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2019-02-18 19:29:38 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2019-02-28 19:55:47 (GMT) |
commit | 960bae7191faf07f142b1ae5b0038905d33e2b1f (patch) | |
tree | fb5ce28720b56945588c77c3f5ab19c61cc8ef32 /src/util.cpp | |
parent | 79ace06168f1e09fce00515248d83571302a67ae (diff) | |
download | Doxygen-960bae7191faf07f142b1ae5b0038905d33e2b1f.zip Doxygen-960bae7191faf07f142b1ae5b0038905d33e2b1f.tar.gz Doxygen-960bae7191faf07f142b1ae5b0038905d33e2b1f.tar.bz2 |
Refactored Definition and derived classes such that they are abstract interfaces
Diffstat (limited to 'src/util.cpp')
-rw-r--r-- | src/util.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/util.cpp b/src/util.cpp index b99753e..4a2f4fe 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -689,7 +689,7 @@ static QCString substTypedef(const Definition *scope,const FileDef *fileScope,co if (d->definitionType()==Definition::TypeMember) { // that are also typedefs - MemberDef *md = (MemberDef *)d; + MemberDef *md = dynamic_cast<MemberDef *>(d); if (md->isTypedef()) // d is a typedef { // test accessibility of typedef within scope. @@ -708,7 +708,7 @@ static QCString substTypedef(const Definition *scope,const FileDef *fileScope,co { Definition *d = (Definition*)di; // that are also typedefs - MemberDef *md = (MemberDef *)di; + MemberDef *md = dynamic_cast<MemberDef *>(di); if (md->isTypedef()) // d is a typedef { // test accessibility of typedef within scope. @@ -786,12 +786,12 @@ static const Definition *followPath(const Definition *start,const FileDef *fileS if (current->definitionType()==Definition::TypeNamespace) { next = endOfPathIsUsedClass( - ((NamespaceDef *)current)->getUsedClasses(),qualScopePart); + (dynamic_cast<const NamespaceDef *>(current))->getUsedClasses(),qualScopePart); } else if (current->definitionType()==Definition::TypeFile) { next = endOfPathIsUsedClass( - ((FileDef *)current)->getUsedClasses(),qualScopePart); + (dynamic_cast<const FileDef *>(current))->getUsedClasses(),qualScopePart); } current = next; if (current==0) break; @@ -968,13 +968,13 @@ int isAccessibleFrom(const Definition *scope,const FileDef *fileScope,const Defi (item->definitionType()==Definition::TypeMember && // a member itemScope && itemScope->definitionType()==Definition::TypeClass && // of a class scope->definitionType()==Definition::TypeClass && // accessible - ((ClassDef*)scope)->isAccessibleMember((MemberDef *)item) // from scope + (dynamic_cast<const ClassDef*>(scope))->isAccessibleMember(dynamic_cast<const MemberDef *>(item)) // from scope ); bool nestedClassInsideBaseClass = (item->definitionType()==Definition::TypeClass && // a nested class itemScope && itemScope->definitionType()==Definition::TypeClass && // inside a base scope->definitionType()==Definition::TypeClass && // class of scope - ((ClassDef*)scope)->isBaseClass((ClassDef*)itemScope,TRUE) + (dynamic_cast<const ClassDef*>(scope))->isBaseClass(dynamic_cast<ClassDef*>(itemScope),TRUE) ); if (itemScope==scope || memberAccessibleFromScope || nestedClassInsideBaseClass) @@ -1009,7 +1009,7 @@ int isAccessibleFrom(const Definition *scope,const FileDef *fileScope,const Defi // check if scope is a namespace, which is using other classes and namespaces if (scope->definitionType()==Definition::TypeNamespace) { - NamespaceDef *nscope = (NamespaceDef*)scope; + 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(); if (accessibleViaUsingClass(cl,fileScope,item)) @@ -1089,7 +1089,7 @@ int isAccessibleFromWithExpScope(const Definition *scope,const FileDef *fileScop else if (itemScope && newScope && itemScope->definitionType()==Definition::TypeClass && newScope->definitionType()==Definition::TypeClass && - ((ClassDef*)newScope)->isBaseClass((ClassDef*)itemScope,TRUE,0) + (dynamic_cast<const ClassDef*>(newScope))->isBaseClass(dynamic_cast<const ClassDef*>(itemScope),TRUE,0) ) { // inheritance is also ok. Example: looking for B::I, where @@ -1114,7 +1114,7 @@ int isAccessibleFromWithExpScope(const Definition *scope,const FileDef *fileScop // A::B::C but is explicit referenced as A::C, where B is imported // in A via a using directive. //printf("newScope is a namespace: %s!\n",newScope->name().data()); - NamespaceDef *nscope = (NamespaceDef*)newScope; + const NamespaceDef *nscope = dynamic_cast<const NamespaceDef*>(newScope); SDict<Definition> *cl = nscope->getUsedClasses(); if (cl) { @@ -1165,7 +1165,7 @@ int isAccessibleFromWithExpScope(const Definition *scope,const FileDef *fileScop //printf(" failed to resolve: scope=%s\n",scope->name().data()); if (scope->definitionType()==Definition::TypeNamespace) { - NamespaceDef *nscope = (NamespaceDef*)scope; + const NamespaceDef *nscope = dynamic_cast<const NamespaceDef*>(scope); NamespaceSDict *nl = nscope->getUsedNamespaces(); if (accessibleViaUsingNamespace(nl,fileScope,item,explicitScopePart)) { @@ -1227,7 +1227,7 @@ static void getResolvedSymbol(const Definition *scope, // only look at classes and members that are enums or typedefs if (d->definitionType()==Definition::TypeClass || (d->definitionType()==Definition::TypeMember && - (((MemberDef*)d)->isTypedef() || ((MemberDef*)d)->isEnumerate()) + ((dynamic_cast<MemberDef*>(d))->isTypedef() || (dynamic_cast<MemberDef*>(d))->isEnumerate()) ) ) { @@ -1240,7 +1240,7 @@ static void getResolvedSymbol(const Definition *scope, // see if we are dealing with a class or a typedef if (d->definitionType()==Definition::TypeClass) // d is a class { - ClassDef *cd = (ClassDef *)d; + ClassDef *cd = dynamic_cast<ClassDef *>(d); //printf("cd=%s\n",cd->name().data()); if (!cd->isTemplateArgument()) // skip classes that // are only there to @@ -1285,7 +1285,7 @@ static void getResolvedSymbol(const Definition *scope, } else if (d->definitionType()==Definition::TypeMember) { - MemberDef *md = (MemberDef *)d; + MemberDef *md = dynamic_cast<MemberDef *>(d); //printf(" member isTypedef()=%d\n",md->isTypedef()); if (md->isTypedef()) // d is a typedef { @@ -5002,7 +5002,7 @@ bool generateLink(OutputDocInterface &od,const char *clName, compound->definitionType()==Definition::TypeGroup /* is group */ ) { - linkText=((GroupDef *)compound)->groupTitle(); // use group's title as link + linkText=(dynamic_cast<GroupDef *>(compound))->groupTitle(); // use group's title as link } else if (compound->definitionType()==Definition::TypeFile) { @@ -5374,7 +5374,7 @@ static void initBaseClassHierarchy(BaseClassList *bcl) { initBaseClassHierarchy(cd->baseClasses()); } - cd->visited=FALSE; + cd->setVisited(FALSE); } } //---------------------------------------------------------------------------- @@ -5414,7 +5414,7 @@ void initClassHierarchy(ClassSDict *cl) ClassDef *cd; for ( ; (cd=cli.current()); ++cli) { - cd->visited=FALSE; + cd->setVisited(FALSE); initBaseClassHierarchy(cd->baseClasses()); } } @@ -6683,7 +6683,7 @@ PageDef *addRelatedPage(const char *name,const QCString &ptitle, baseName=baseName.left(baseName.length()-Doxygen::htmlFileExtension.length()); QCString title=ptitle.stripWhiteSpace(); - pd=new PageDef(fileName,startLine,baseName,doc,title); + pd=createPageDef(fileName,startLine,baseName,doc,title); pd->setRefItems(sli); pd->setLanguage(lang); @@ -7480,7 +7480,7 @@ MemberDef *getMemberFromSymbol(Definition *scope,FileDef *fileScope, if (distance!=-1 && distance<minDistance) { minDistance = distance; - bestMatch = (MemberDef *)d; + bestMatch = dynamic_cast<MemberDef *>(d); //printf("new best match %s distance=%d\n",bestMatch->qualifiedName().data(),distance); } } @@ -7495,7 +7495,7 @@ MemberDef *getMemberFromSymbol(Definition *scope,FileDef *fileScope, if (distance!=-1 && distance<minDistance) { minDistance = distance; - bestMatch = (MemberDef *)d; + bestMatch = dynamic_cast<MemberDef *>(d); //printf("new best match %s distance=%d\n",bestMatch->qualifiedName().data(),distance); } } |