/****************************************************************************** * * * * Copyright (C) 1997-2015 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its * documentation under the terms of the GNU General Public License is hereby * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * * Documents produced by Doxygen are derivative works derived from the * input used in their production; they are not affected by this license. * */ #include #include #include "entry.h" #include "util.h" #include "section.h" #include "doxygen.h" #include "arguments.h" #include "config.h" //------------------------------------------------------------------ #define HEADER ('D'<<24)+('O'<<16)+('X'<<8)+'!' //------------------------------------------------------------------ int Entry::num=0; Entry::Entry() { //printf("Entry::Entry(%p)\n",this); num++; m_parent=0; section = EMPTY_SEC; m_sublist = new QList; m_sublist->setAutoDelete(TRUE); extends = new QList; extends->setAutoDelete(TRUE); groups = new QList; groups->setAutoDelete(TRUE); anchors = new QList; // Doxygen::sectionDict takes ownership of the items! argList = new ArgumentList; argList->setAutoDelete(TRUE); //printf("Entry::Entry() tArgList=0\n"); tArgLists = 0; typeConstr = 0; mGrpId = -1; tagInfo = 0; sli = 0; relatesType = Simple; hidden = FALSE; groupDocType = GROUPDOC_NORMAL; reset(); } Entry::Entry(const Entry &e) { //printf("Entry::Entry(%p):copy\n",this); num++; section = e.section; type = e.type; name = e.name; tagInfo = e.tagInfo; protection = e.protection; mtype = e.mtype; spec = e.spec; initLines = e.initLines; stat = e.stat; localToc = e.localToc; explicitExternal = e.explicitExternal; proto = e.proto; subGrouping = e.subGrouping; callGraph = e.callGraph; callerGraph = e.callerGraph; referencedByRelation = e.referencedByRelation; referencesRelation = e.referencesRelation; virt = e.virt; args = e.args; bitfields = e.bitfields; argList = e.argList->deepCopy(); tArgLists = 0; program = e.program; initializer = e.initializer; includeFile = e.includeFile; includeName = e.includeName; doc = e.doc; docLine = e.docLine; docFile = e.docFile; brief = e.brief; briefLine = e.briefLine; briefFile = e.briefFile; inbodyDocs = e.inbodyDocs; inbodyLine = e.inbodyLine; inbodyFile = e.inbodyFile; relates = e.relates; relatesType = e.relatesType; read = e.read; write = e.write; inside = e.inside; exception = e.exception; typeConstr = 0; bodyLine = e.bodyLine; endBodyLine = e.endBodyLine; mGrpId = e.mGrpId; extends = new QList; extends->setAutoDelete(TRUE); groups = new QList; groups->setAutoDelete(TRUE); anchors = new QList; fileName = e.fileName; startLine = e.startLine; startColumn = e.startColumn; if (e.sli) { sli = new QList; sli->setAutoDelete(TRUE); QListIterator slii(*e.sli); ListItemInfo *ili; for (slii.toFirst();(ili=slii.current());++slii) { sli->append(new ListItemInfo(*ili)); } } else { sli=0; } lang = e.lang; hidden = e.hidden; artificial = e.artificial; groupDocType = e.groupDocType; id = e.id; m_parent = e.m_parent; m_sublist = new QList; m_sublist->setAutoDelete(TRUE); // deep copy of the child entry list QListIterator eli(*e.m_sublist); Entry *cur; for (;(cur=eli.current());++eli) { m_sublist->append(new Entry(*cur)); } // deep copy base class list QListIterator bli(*e.extends); BaseInfo *bi; for (;(bi=bli.current());++bli) { extends->append(new BaseInfo(*bi)); } // deep copy group list QListIterator gli(*e.groups); Grouping *g; for (;(g=gli.current());++gli) { groups->append(new Grouping(*g)); } QListIterator sli2(*e.anchors); SectionInfo *s; for (;(s=sli2.current());++sli2) { anchors->append(s); // shallow copy, object are owned by Doxygen::sectionDict } // deep copy type constraint list if (e.typeConstr) { typeConstr = e.typeConstr->deepCopy(); } // deep copy template argument lists if (e.tArgLists) { tArgLists = copyArgumentLists(e.tArgLists); } m_fileDef = e.m_fileDef; } Entry::~Entry() { //printf("Entry::~Entry(%p) num=%d\n",this,num); //printf("Deleting entry %d name %s type %x children %d\n", // num,name.data(),section,sublist->count()); delete m_sublist; // each element is now own by a EntryNav so we do no longer own // our children. delete extends; delete groups; delete anchors; delete argList; delete tArgLists; delete tagInfo; delete typeConstr; delete sli; num--; } void Entry::addSubEntry(Entry *current) { //printf("Entry %d with name %s type 0x%x added to %s type 0x%x\n", // current->num,current->name.data(),current->section, // name.data(),section); //printf("Entry::addSubEntry(%s:%p) to %s\n",current->name.data(), // current,name.data()); current->m_parent=this; m_sublist->append(current); } void Entry::reset() { static bool entryCallGraph = Config_getBool(CALL_GRAPH); static bool entryCallerGraph = Config_getBool(CALLER_GRAPH); static bool entryReferencedByRelation = Config_getBool(REFERENCED_BY_RELATION); static bool entryReferencesRelation = Config_getBool(REFERENCES_RELATION); //printf("Entry::reset()\n"); name.resize(0); type.resize(0); args.resize(0); bitfields.resize(0); exception.resize(0); program.resize(0); includeFile.resize(0); includeName.resize(0); doc.resize(0); docFile.resize(0); docLine=-1; relates.resize(0); relatesType=Simple; brief.resize(0); briefFile.resize(0); briefLine=-1; inbodyDocs.resize(0); inbodyFile.resize(0); inbodyLine=-1; inside.resize(0); fileName.resize(0); initializer.resize(0); initLines = -1; startLine = 1; startColumn = 1; bodyLine = -1; endBodyLine = -1; mGrpId = -1; callGraph = entryCallGraph; callerGraph = entryCallerGraph; referencedByRelation = entryReferencedByRelation; referencesRelation = entryReferencesRelation; section = EMPTY_SEC; mtype = Method; virt = Normal; stat = FALSE; proto = FALSE; explicitExternal = FALSE; spec = 0; lang = SrcLangExt_Unknown; hidden = FALSE; artificial = FALSE; subGrouping = TRUE; protection = Public; groupDocType = GROUPDOC_NORMAL; id.resize(0); metaData.resize(0); m_sublist->clear(); extends->clear(); groups->clear(); anchors->clear(); argList->clear(); if (tagInfo) { delete tagInfo; tagInfo=0; } if (tArgLists) { delete tArgLists; tArgLists=0; } if (sli) { delete sli; sli=0; } if (typeConstr) { delete typeConstr; typeConstr=0; } //if (mtArgList) { delete mtArgList; mtArgList=0; } m_fileDef = 0; } int Entry::getSize() { return sizeof(Entry); } void Entry::setFileDef(FileDef *fd) { m_fileDef = fd; if (m_sublist) { QListIterator eli(*m_sublist); Entry *childNode; for (eli.toFirst();(childNode=eli.current());++eli) { childNode->setFileDef(fd); } } } void Entry::addSpecialListItem(const char *listName,int itemId) { if (sli==0) { sli = new QList; sli->setAutoDelete(TRUE); } ListItemInfo *ili=new ListItemInfo; ili->type = listName; ili->itemId = itemId; sli->append(ili); } Entry *Entry::removeSubEntry(Entry *e) { int i = m_sublist->find(e); return i!=-1 ? m_sublist->take(i) : 0; } //------------------------------------------------------------------