📄 doxygen.cpp
字号:
md->setBodySegment(root->bodyLine,root->endBodyLine); md->setInitializer(root->initializer); md->setMaxInitLines(root->initLines); md->setMemberGroupId(root->mGrpId); addMemberToGroups(root,md); //if (root->mGrpId!=-1) //{ // printf("memberdef %s in memberGroup %d\n",name.data(),root->mGrpId); // md->setMemberGroup(memberGroupDict[root->mGrpId]); // bool ambig; md->setBodyDef(findFileDef(Doxygen::inputNameDict,root->fileName,ambig)); //printf("Adding member=%s\n",md->name().data()); // add the member to the global list if (mn) { mn->append(md); } else // new variable name { mn = new MemberName(name); mn->append(md); //printf("Adding memberName=%s\n",mn->memberName()); //Doxygen::memberNameDict.insert(name,mn); //Doxygen::memberNameList.append(mn); Doxygen::memberNameSDict.append(name,mn); // add the member to the class } cd->insertMember(md); md->setRefItems(root->todoId,root->testId,root->bugId); //TODO: insert FileDef instead of filename strings. cd->insertUsedFile(root->fileName); root->section = Entry::EMPTY_SEC; return md;}//----------------------------------------------------------------------static MemberDef *addVariableToFile( Entry *root, MemberDef::MemberType mtype, const QCString &scope, const QCString &name, bool fromAnnScope, int indentDepth, MemberDef *fromAnnMemb){ Debug::print(Debug::Variables,0, " global variable:\n" " type=`%s' scope=`%s' name=`%s' args=`%s' prot=`%d\n", root->type.data(), scope.data(), name.data(), root->args.data(), root->protection ); bool ambig; FileDef *fd = findFileDef(Doxygen::inputNameDict,root->fileName,ambig); // see if the function is inside a namespace NamespaceDef *nd = 0; if (!scope.isEmpty()) { QCString nscope=removeAnonymousScopes(scope); if (!nscope.isEmpty()) { nd = getResolvedNamespace(nscope); } } QCString def; // determine the definition of the global variable if (nd && !nd->name().isEmpty() && nd->name().at(0)!='@' && !Config_getBool("HIDE_SCOPE_NAMES") ) // variable is inside a namespace, so put the scope before the name { if (!root->type.isEmpty()) { def=root->type+" "+nd->name()+"::"+name+root->args; } else { def=nd->name()+"::"+name+root->args; } } else { if (!root->type.isEmpty()) { if (name.at(0)=='@') // dummy variable representing annonymous union def=root->type; else def=root->type+" "+name+root->args; } else { def=name+root->args; } } if (def.left(7)=="static ") def=def.right(def.length()-7); MemberName *mn=Doxygen::functionNameSDict[name]; if (mn) { QCString nscope=removeAnonymousScopes(scope); NamespaceDef *nd=0; if (!nscope.isEmpty()) { nd = getResolvedNamespace(nscope); } MemberNameIterator mni(*mn); MemberDef *md; for (mni.toFirst();(md=mni.current());++mni) { if ((nd==0 && md->getFileDef() && root->fileName==md->getFileDef()->absFilePath()) || (nd!=0 && md->getNamespaceDef()==nd)) // variable already in the scope { addMemberDocs(root,md,def,0,FALSE); md->setRefItems(root->todoId,root->testId,root->bugId); return md; } if (nd==0 && md->isExplicit()!=root->explicitExternal) { // merge ingroup specifiers if (md->getGroupDef()==0 && root->groups->first()) { GroupDef *gd=Doxygen::groupSDict[root->groups->first()->groupname.data()]; md->setGroupDef(gd, root->groups->first()->pri, root->fileName, root->startLine, root->doc.length() != 0); } else if (md->getGroupDef()!=0 && root->groups->count()==0) { root->groups->append(new Grouping(md->getGroupDef()->name(), md->getGroupPri())); } } } } // new global variable, enum value or typedef MemberDef *md=new MemberDef( root->fileName,root->startLine, root->type,name,root->args,0, Public, Normal,root->stat,FALSE, mtype,0,0); if (root->tagInfo) { md->setAnchor(root->tagInfo->anchor); md->setReference(root->tagInfo->tagName); } //md->setDefFile(root->fileName); //md->setDefLine(root->startLine); md->setDocumentation(root->doc); md->setBriefDescription(root->brief); md->addSectionsToDefinition(root->anchors); md->setFromAnonymousScope(fromAnnScope); md->setFromAnonymousMember(fromAnnMemb); md->setIndentDepth(indentDepth); md->setBodySegment(root->bodyLine,root->endBodyLine); md->setInitializer(root->initializer); md->setMaxInitLines(root->initLines); md->setMemberGroupId(root->mGrpId); md->setBodyDef(fd); md->setDefinition(def); md->setExplicitExternal(root->explicitExternal); addMemberToGroups(root,md); //if (root->mGrpId!=-1) //{ // md->setMemberGroup(memberGroupDict[root->mGrpId]); //} md->setRefItems(root->todoId,root->testId,root->bugId); if (nd && !nd->name().isEmpty() && nd->name().at(0)!='@') { nd->insertMember(md); md->setNamespace(nd); } else { // find file definition if (fd) { fd->insertMember(md); md->setFileDef(fd); } } // add member definition to the list of globals if (mn) { mn->append(md); } else { mn = new MemberName(name); mn->append(md); Doxygen::functionNameSDict.append(name,mn); } root->section = Entry::EMPTY_SEC; return md;}/*! See if the return type string \a type is that of a function pointer * \returns -1 if this is not a function pointer variable or * the index at which the brace of (...*name) was found. */static int findFunctionPtr(const QCString &type,int *pLength=0){ static const QRegExp re("([^)]*"); int i=-1,l; if (!type.isEmpty() && // return type is non-empty (i=re.match(type,0,&l))!=-1 && // contains a (* type.find("operator")==-1 && // not an operator type.find(")(")==-1 // not a function pointer return type ) { if (pLength) *pLength=l; return i; } else { return -1; }}//----------------------------------------------------------------------// Searches the Entry tree for Variable documentation sections.// If found they are stored in their class or in the global list.void buildVarList(Entry *root){ if (!root->name.isEmpty() && (root->type.isEmpty() || compoundKeywordDict.find(root->type)==0) && ( (root->section==Entry::VARIABLE_SEC // it's a variable ) || (root->section==Entry::FUNCTION_SEC && // or maybe a function pointer variable findFunctionPtr(root->type)!=-1 ) ) ) // documented variable { Debug::print(Debug::Variables,0, "VARIABLE_SEC: \n" " type=`%s' name=`%s' args=`%s' bodyLine=`%d' mGrpId=%d\n", root->type.data(), root->name.data(), root->args.data(), root->bodyLine, root->mGrpId ); //printf("root->parent->name=%s\n",root->parent->name.data()); if (root->type.isEmpty() && root->name.find("operator")==-1 && (root->name.find('*')!=-1 || root->name.find('&')!=-1)) { // recover from parse error caused by redundant braces // like in "int *(var[10]);", which is parsed as // type="" name="int *" args="(var[10])" root->type=root->name; static const QRegExp reName("[a-z_A-Z][a-z_A-Z0-9]*"); int l; int i=root->args.isEmpty() ? -1 : reName.match(root->args,0,&l); root->name=root->args.mid(i,l); root->args=root->args.mid(i+l,root->args.find(')',i+l)-i-l); //printf("new: type=`%s' name=`%s' args=`%s'\n", // root->type.data(),root->name.data(),root->args.data()); } else { int i=findFunctionPtr(root->type); if (i!=-1) // function pointer { int ai = root->type.find('[',i); if (ai>i) // function pointer array { root->args.prepend(root->type.right(root->type.length()-ai)); root->type=root->type.left(ai); } else if (root->type.find(')',i)!=-1) // function ptr, not variable like "int (*bla)[10]" { root->type=root->type.left(root->type.length()-1); root->args.prepend(")"); } } } QCString scope,name=root->name.copy(); // find the scope of this variable Entry *p = root->parent; while ((p->section & Entry::SCOPE_MASK)) { QCString scopeName = p->name.copy(); if (!scopeName.isEmpty()) { scope.prepend(scopeName); break; } p=p->parent; } // scope annonymous scope name at the end to determine the scope // where we can put this variable //while ((i=scope.findRev("::"))!=-1 && (int)scope.length()>i+2 && // scope.at(i+2)=='@' // ) //{ // scope=scope.left(i); //} MemberDef::MemberType mtype; QCString type=root->type.stripWhiteSpace(); ClassDef *cd=0; if (root->name.findRev("::")!=-1) { if (root->type=="friend class" || root->type=="friend struct" || root->type=="friend union") { cd=getClass(scope); if (cd) { addVariableToClass(root,cd,MemberDef::Friend,scope, root->name,FALSE,0,0,Public); } } goto nextMember; /* skip this member, because it is a * static variable definition (always?), which will be * found in a class scope as well, but then we know the * correct protection level, so only then it will be * inserted in the correct list! */ } if (type=="@") mtype=MemberDef::EnumValue; else if (type.left(8)=="typedef ") mtype=MemberDef::Typedef; else if (type.left(7)=="friend ") mtype=MemberDef::Friend; else if (root->mtype==Property) mtype=MemberDef::Property; else mtype=MemberDef::Variable; QCString classScope=stripAnonymousNamespaceScope(scope); classScope=stripTemplateSpecifiersFromScope(classScope,FALSE); QCString annScopePrefix=scope.left(scope.length()-classScope.length()); scope=classScope; if (!scope.isEmpty() && !name.isEmpty() && (cd=getClass(scope))) { MemberDef *md=0; // if cd is an annonymous scope we insert the member // into a non-annonymous scope as well. int indentDepth=0; int si=scope.find('@'); if (si!=-1) { //printf("name=`%s' scope=%s\n",name.data(),scope.data()); QCString pScope; ClassDef *pcd=0; pScope = scope.left(QMAX(si-2,0)); indentDepth = scope.right(scope.length()-si).contains("::")+1; if (!pScope.isEmpty()) pScope.prepend(annScopePrefix); else if (annScopePrefix.length()>2) pScope=annScopePrefix.left(annScopePrefix.length()-2); //printf("pScope=`%s'\n",pScope.data()); if (name.at(0)!='@') { if (!pScope.isEmpty() && (pcd=getClass(pScope))) { //Protection p = (Protection)QMAX((int)root->protection,(int)cd->protection()); md=addVariableToClass(root,pcd,mtype,pScope,name,TRUE,indentDepth,0,root->protection); } else // annonymous scope inside namespace or file => put variable in the global scope { //printf("Inserting member in global scope %s!\n",pScope.data()); //md=addVariableToFile(root,mtype,pScope,name,!pScope.isEmpty(),indentDepth,0); md=addVariableToFile(root,mtype,pScope,name,TRUE,indentDepth,0); } } } addVariableToClass(root,cd,mtype,scope,name,FALSE,indentDepth,md,root->protection); } else if (!name.isEmpty()) // global variable { //printf("Inserting member in global scope %s!\n",scope.data()); addVariableToFile(root,mtype,scope,name,FALSE,0,0); } //if (mtype==MemberDef::Typedef) //{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -