Root/
Source at commit 1322 created 12 years 7 months ago. By meklort, Add doxygen to utils folder | |
---|---|
1 | /******************************************************************************␊ |
2 | *␊ |
3 | * $Id: entry.cpp,v 1.29 2001/03/19 19:27:40 root Exp $␊ |
4 | *␊ |
5 | * Copyright (C) 1997-2011 by Dimitri van Heesch.␊ |
6 | *␊ |
7 | * Permission to use, copy, modify, and distribute this software and its␊ |
8 | * documentation under the terms of the GNU General Public License is hereby ␊ |
9 | * granted. No representations are made about the suitability of this software ␊ |
10 | * for any purpose. It is provided "as is" without express or implied warranty.␊ |
11 | * See the GNU General Public License for more details.␊ |
12 | *␊ |
13 | * Documents produced by Doxygen are derivative works derived from the␊ |
14 | * input used in their production; they are not affected by this license.␊ |
15 | *␊ |
16 | */␊ |
17 | ␊ |
18 | #include <stdlib.h>␊ |
19 | #include <qfile.h>␊ |
20 | #include "entry.h"␊ |
21 | #include "marshal.h"␊ |
22 | #include "util.h"␊ |
23 | #include "section.h"␊ |
24 | #include "doxygen.h"␊ |
25 | ␊ |
26 | //------------------------------------------------------------------␊ |
27 | ␊ |
28 | #define HEADER ('D'<<24)+('O'<<16)+('X'<<8)+'!'␊ |
29 | ␊ |
30 | //------------------------------------------------------------------␊ |
31 | ␊ |
32 | /*! the argument list is documented if one of its␊ |
33 | * arguments is documented ␊ |
34 | */␊ |
35 | bool ArgumentList::hasDocumentation() const␊ |
36 | {␊ |
37 | bool hasDocs=FALSE;␊ |
38 | ArgumentListIterator ali(*this);␊ |
39 | Argument *a;␊ |
40 | for (ali.toFirst();!hasDocs && (a=ali.current());++ali)␊ |
41 | {␊ |
42 | hasDocs = a->hasDocumentation(); ␊ |
43 | }␊ |
44 | return hasDocs;␊ |
45 | }␊ |
46 | ␊ |
47 | //------------------------------------------------------------------␊ |
48 | ␊ |
49 | int Entry::num=0;␊ |
50 | ␊ |
51 | Entry::Entry()␊ |
52 | {␊ |
53 | //printf("Entry::Entry(%p)\n",this);␊ |
54 | num++;␊ |
55 | m_parent=0;␊ |
56 | section = EMPTY_SEC;␊ |
57 | m_sublist = new QList<Entry>;␊ |
58 | m_sublist->setAutoDelete(TRUE);␊ |
59 | extends = new QList<BaseInfo>;␊ |
60 | extends->setAutoDelete(TRUE);␊ |
61 | groups = new QList<Grouping>;␊ |
62 | groups->setAutoDelete(TRUE);␊ |
63 | anchors = new QList<SectionInfo>; // Doxygen::sectionDict takes ownership of the items!␊ |
64 | argList = new ArgumentList;␊ |
65 | argList->setAutoDelete(TRUE);␊ |
66 | //printf("Entry::Entry() tArgList=0\n");␊ |
67 | tArgLists = 0;␊ |
68 | typeConstr = 0;␊ |
69 | mGrpId = -1;␊ |
70 | tagInfo = 0;␊ |
71 | sli = 0;␊ |
72 | relatesType = Simple;␊ |
73 | hidden = FALSE;␊ |
74 | groupDocType = GROUPDOC_NORMAL;␊ |
75 | reset();␊ |
76 | }␊ |
77 | ␊ |
78 | Entry::Entry(const Entry &e)␊ |
79 | {␊ |
80 | //printf("Entry::Entry(%p):copy\n",this);␊ |
81 | num++;␊ |
82 | section = e.section;␊ |
83 | type = e.type;␊ |
84 | name = e.name;␊ |
85 | tagInfo = e.tagInfo;␊ |
86 | protection = e.protection;␊ |
87 | mtype = e.mtype;␊ |
88 | spec = e.spec;␊ |
89 | initLines = e.initLines;␊ |
90 | stat = e.stat;␊ |
91 | explicitExternal = e.explicitExternal;␊ |
92 | proto = e.proto;␊ |
93 | subGrouping = e.subGrouping;␊ |
94 | callGraph = e.callGraph;␊ |
95 | callerGraph = e.callerGraph;␊ |
96 | virt = e.virt;␊ |
97 | args = e.args;␊ |
98 | bitfields = e.bitfields;␊ |
99 | argList = new ArgumentList;␊ |
100 | argList->setAutoDelete(TRUE);␊ |
101 | tArgLists = 0;␊ |
102 | program = e.program;␊ |
103 | initializer = e.initializer;␊ |
104 | includeFile = e.includeFile;␊ |
105 | includeName = e.includeName;␊ |
106 | doc = e.doc;␊ |
107 | docLine = e.docLine;␊ |
108 | docFile = e.docFile;␊ |
109 | brief = e.brief;␊ |
110 | briefLine = e.briefLine;␊ |
111 | briefFile = e.briefFile;␊ |
112 | inbodyDocs = e.inbodyDocs;␊ |
113 | inbodyLine = e.inbodyLine;␊ |
114 | inbodyFile = e.inbodyFile;␊ |
115 | relates = e.relates;␊ |
116 | relatesType = e.relatesType;␊ |
117 | read = e.read;␊ |
118 | write = e.write;␊ |
119 | inside = e.inside;␊ |
120 | exception = e.exception;␊ |
121 | typeConstr = 0;␊ |
122 | bodyLine = e.bodyLine;␊ |
123 | endBodyLine = e.endBodyLine;␊ |
124 | mGrpId = e.mGrpId;␊ |
125 | extends = new QList<BaseInfo>;␊ |
126 | extends->setAutoDelete(TRUE);␊ |
127 | groups = new QList<Grouping>;␊ |
128 | groups->setAutoDelete(TRUE);␊ |
129 | anchors = new QList<SectionInfo>;␊ |
130 | fileName = e.fileName;␊ |
131 | startLine = e.startLine;␊ |
132 | if (e.sli)␊ |
133 | {␊ |
134 | sli = new QList<ListItemInfo>;␊ |
135 | sli->setAutoDelete(TRUE);␊ |
136 | QListIterator<ListItemInfo> slii(*e.sli);␊ |
137 | ListItemInfo *ili;␊ |
138 | for (slii.toFirst();(ili=slii.current());++slii)␊ |
139 | {␊ |
140 | sli->append(new ListItemInfo(*ili));␊ |
141 | }␊ |
142 | }␊ |
143 | else␊ |
144 | {␊ |
145 | sli=0;␊ |
146 | }␊ |
147 | lang = e.lang;␊ |
148 | hidden = e.hidden;␊ |
149 | artificial = e.artificial;␊ |
150 | groupDocType = e.groupDocType;␊ |
151 | ␊ |
152 | m_parent = e.m_parent;␊ |
153 | m_sublist = new QList<Entry>;␊ |
154 | m_sublist->setAutoDelete(TRUE);␊ |
155 | ␊ |
156 | // deep copy of the child entry list␊ |
157 | QListIterator<Entry> eli(*e.m_sublist);␊ |
158 | Entry *cur;␊ |
159 | for (;(cur=eli.current());++eli)␊ |
160 | {␊ |
161 | m_sublist->append(new Entry(*cur));␊ |
162 | }␊ |
163 | ␊ |
164 | // deep copy base class list␊ |
165 | QListIterator<BaseInfo> bli(*e.extends);␊ |
166 | BaseInfo *bi;␊ |
167 | for (;(bi=bli.current());++bli)␊ |
168 | {␊ |
169 | extends->append(new BaseInfo(*bi));␊ |
170 | }␊ |
171 | ␊ |
172 | // deep copy group list␊ |
173 | QListIterator<Grouping> gli(*e.groups);␊ |
174 | Grouping *g;␊ |
175 | for (;(g=gli.current());++gli)␊ |
176 | {␊ |
177 | groups->append(new Grouping(*g));␊ |
178 | }␊ |
179 | ␊ |
180 | QListIterator<SectionInfo> sli2(*e.anchors);␊ |
181 | SectionInfo *s;␊ |
182 | for (;(s=sli2.current());++sli2)␊ |
183 | {␊ |
184 | anchors->append(new SectionInfo(*s));␊ |
185 | }␊ |
186 | ␊ |
187 | // deep copy argument list␊ |
188 | QListIterator<Argument> ali(*e.argList);␊ |
189 | Argument *a;␊ |
190 | for (;(a=ali.current());++ali)␊ |
191 | {␊ |
192 | argList->append(new Argument(*a));␊ |
193 | }␊ |
194 | argList->constSpecifier = e.argList->constSpecifier;␊ |
195 | argList->volatileSpecifier = e.argList->volatileSpecifier;␊ |
196 | argList->pureSpecifier = e.argList->pureSpecifier;␊ |
197 | ␊ |
198 | // deep copy type contraint list␊ |
199 | if (e.typeConstr)␊ |
200 | {␊ |
201 | typeConstr = new ArgumentList;␊ |
202 | typeConstr->setAutoDelete(TRUE);␊ |
203 | QListIterator<Argument> tcli(*e.typeConstr);␊ |
204 | for (;(a=tcli.current());++tcli)␊ |
205 | {␊ |
206 | typeConstr->append(new Argument(*a));␊ |
207 | }␊ |
208 | }␊ |
209 | ␊ |
210 | // deep copy template argument lists␊ |
211 | if (e.tArgLists)␊ |
212 | {␊ |
213 | tArgLists = copyArgumentLists(e.tArgLists);␊ |
214 | }␊ |
215 | ␊ |
216 | }␊ |
217 | ␊ |
218 | Entry::~Entry()␊ |
219 | {␊ |
220 | //printf("Entry::~Entry(%p) num=%d\n",this,num);␊ |
221 | //printf("Deleting entry %d name %s type %x children %d\n",␊ |
222 | // num,name.data(),section,sublist->count());␊ |
223 | ␊ |
224 | delete m_sublist; // each element is now own by a EntryNav so we do no longer own␊ |
225 | // our children.␊ |
226 | delete extends;␊ |
227 | delete groups;␊ |
228 | delete anchors;␊ |
229 | delete argList;␊ |
230 | delete tArgLists;␊ |
231 | delete tagInfo;␊ |
232 | delete typeConstr;␊ |
233 | delete sli;␊ |
234 | num--;␊ |
235 | }␊ |
236 | ␊ |
237 | void Entry::addSubEntry(Entry *current)␊ |
238 | {␊ |
239 | //printf("Entry %d with name %s type 0x%x added to %s type 0x%x\n",␊ |
240 | // current->num,current->name.data(),current->section,␊ |
241 | // name.data(),section);␊ |
242 | //printf("Entry::addSubEntry(%s:%p) to %s\n",current->name.data(),␊ |
243 | // current,name.data());␊ |
244 | current->m_parent=this;␊ |
245 | m_sublist->append(current); ␊ |
246 | }␊ |
247 | ␊ |
248 | void Entry::reset()␊ |
249 | {␊ |
250 | //printf("Entry::reset()\n");␊ |
251 | name.resize(0);␊ |
252 | type.resize(0);␊ |
253 | args.resize(0);␊ |
254 | bitfields.resize(0);␊ |
255 | exception.resize(0);␊ |
256 | program.resize(0);␊ |
257 | includeFile.resize(0);␊ |
258 | includeName.resize(0);␊ |
259 | doc.resize(0);␊ |
260 | docFile.resize(0);␊ |
261 | docLine=-1;␊ |
262 | relates.resize(0);␊ |
263 | relatesType=Simple;␊ |
264 | brief.resize(0);␊ |
265 | briefFile.resize(0);␊ |
266 | briefLine=-1;␊ |
267 | inbodyDocs.resize(0);␊ |
268 | inbodyFile.resize(0);␊ |
269 | inbodyLine=-1;␊ |
270 | inside.resize(0);␊ |
271 | fileName.resize(0);␊ |
272 | initializer.resize(0);␊ |
273 | initLines = -1;␊ |
274 | startLine = 1;␊ |
275 | bodyLine = -1;␊ |
276 | endBodyLine = -1;␊ |
277 | mGrpId = -1;␊ |
278 | callGraph = FALSE;␊ |
279 | callerGraph = FALSE;␊ |
280 | section = EMPTY_SEC;␊ |
281 | mtype = Method;␊ |
282 | virt = Normal;␊ |
283 | stat = FALSE;␊ |
284 | proto = FALSE;␊ |
285 | explicitExternal = FALSE;␊ |
286 | spec = 0;␊ |
287 | lang = SrcLangExt_Unknown;␊ |
288 | hidden = FALSE;␊ |
289 | artificial = FALSE;␊ |
290 | subGrouping = TRUE;␊ |
291 | protection = Public;␊ |
292 | groupDocType = GROUPDOC_NORMAL;␊ |
293 | m_sublist->clear();␊ |
294 | extends->clear();␊ |
295 | groups->clear();␊ |
296 | anchors->clear();␊ |
297 | argList->clear();␊ |
298 | if (tagInfo) { delete tagInfo; tagInfo=0; }␊ |
299 | if (tArgLists) { delete tArgLists; tArgLists=0; }␊ |
300 | if (sli) { delete sli; sli=0; }␊ |
301 | if (typeConstr) { delete typeConstr; typeConstr=0; }␊ |
302 | //if (mtArgList) { delete mtArgList; mtArgList=0; }␊ |
303 | }␊ |
304 | ␊ |
305 | ␊ |
306 | int Entry::getSize()␊ |
307 | {␊ |
308 | return sizeof(Entry);␊ |
309 | }␊ |
310 | ␊ |
311 | void Entry::createSubtreeIndex(EntryNav *nav,FileStorage *storage,FileDef *fd)␊ |
312 | {␊ |
313 | EntryNav *childNav = new EntryNav(nav,this);␊ |
314 | nav->addChild(childNav);␊ |
315 | childNav->setFileDef(fd);␊ |
316 | childNav->saveEntry(this,storage);␊ |
317 | if (m_sublist)␊ |
318 | {␊ |
319 | //printf("saveEntry: %d children\n",node->sublist->count());␊ |
320 | QListIterator<Entry> eli(*m_sublist);␊ |
321 | Entry *childNode;␊ |
322 | for (eli.toFirst();(childNode=eli.current());++eli)␊ |
323 | {␊ |
324 | childNode->createSubtreeIndex(childNav,storage,fd);␊ |
325 | }␊ |
326 | //m_sublist->setAutoDelete(FALSE);␊ |
327 | m_sublist->clear();␊ |
328 | }␊ |
329 | }␊ |
330 | ␊ |
331 | void Entry::createNavigationIndex(EntryNav *rootNav,FileStorage *storage,FileDef *fd)␊ |
332 | {␊ |
333 | //printf("createNavigationIndex(%p) sublist=%p\n",this,m_sublist);␊ |
334 | if (m_sublist)␊ |
335 | {␊ |
336 | //printf("saveEntries: %d children\n",root->sublist->count());␊ |
337 | // store all child entries of root, but keep the navigation info (=index)␊ |
338 | QListIterator<Entry> eli(*m_sublist);␊ |
339 | Entry *e;␊ |
340 | for (eli.toFirst();(e=eli.current());++eli)␊ |
341 | {␊ |
342 | createSubtreeIndex(rootNav,storage,fd);␊ |
343 | }␊ |
344 | // remove all entries from root␊ |
345 | //m_sublist->setAutoDelete(FALSE);␊ |
346 | m_sublist->clear();␊ |
347 | }␊ |
348 | }␊ |
349 | ␊ |
350 | void Entry::addSpecialListItem(const char *listName,int itemId)␊ |
351 | {␊ |
352 | if (sli==0)␊ |
353 | {␊ |
354 | sli = new QList<ListItemInfo>;␊ |
355 | sli->setAutoDelete(TRUE);␊ |
356 | }␊ |
357 | ListItemInfo *ili=new ListItemInfo;␊ |
358 | ili->type = listName;␊ |
359 | ili->itemId = itemId;␊ |
360 | sli->append(ili);␊ |
361 | }␊ |
362 | ␊ |
363 | //------------------------------------------------------------------␊ |
364 | ␊ |
365 | ␊ |
366 | EntryNav::EntryNav(EntryNav *parent, Entry *e)␊ |
367 | : m_parent(parent), m_subList(0), m_section(e->section), m_type(e->type),␊ |
368 | m_name(e->name), m_fileDef(0), m_lang(e->lang), ␊ |
369 | m_info(0), m_offset(-1), m_noLoad(FALSE) ␊ |
370 | {␊ |
371 | if (e->tagInfo)␊ |
372 | {␊ |
373 | m_tagInfo = new TagInfo;␊ |
374 | m_tagInfo->tagName = e->tagInfo->tagName;␊ |
375 | m_tagInfo->fileName = e->tagInfo->fileName;␊ |
376 | m_tagInfo->anchor = e->tagInfo->anchor;␊ |
377 | if (e->tagInfo)␊ |
378 | {␊ |
379 | //printf("tagInfo %p: tagName=%s fileName=%s anchor=%s\n",␊ |
380 | // e->tagInfo,␊ |
381 | // e->tagInfo->tagName.data(),␊ |
382 | // e->tagInfo->fileName.data(),␊ |
383 | // e->tagInfo->anchor.data());␊ |
384 | }␊ |
385 | }␊ |
386 | else␊ |
387 | {␊ |
388 | m_tagInfo = 0;␊ |
389 | }␊ |
390 | }␊ |
391 | ␊ |
392 | EntryNav::~EntryNav()␊ |
393 | {␊ |
394 | delete m_subList;␊ |
395 | delete m_info;␊ |
396 | delete m_tagInfo;␊ |
397 | }␊ |
398 | ␊ |
399 | void EntryNav::addChild(EntryNav *e)␊ |
400 | {␊ |
401 | if (m_subList==0) ␊ |
402 | {␊ |
403 | m_subList = new QList<EntryNav>;␊ |
404 | m_subList->setAutoDelete(TRUE);␊ |
405 | }␊ |
406 | m_subList->append(e);␊ |
407 | }␊ |
408 | ␊ |
409 | bool EntryNav::loadEntry(FileStorage *storage)␊ |
410 | {␊ |
411 | if (m_noLoad)␊ |
412 | {␊ |
413 | return TRUE;␊ |
414 | }␊ |
415 | if (m_offset==-1) ␊ |
416 | {␊ |
417 | //printf("offset not set!\n");␊ |
418 | return FALSE;␊ |
419 | }␊ |
420 | //delete m_info;␊ |
421 | //printf("EntryNav::loadEntry: new entry %p: %s\n",m_info,m_name.data());␊ |
422 | //m_info->tagInfo = m_tagInfo;␊ |
423 | //if (m_parent)␊ |
424 | //{␊ |
425 | // m_info->parent = m_parent->m_info;␊ |
426 | //}␊ |
427 | //m_info->parent = 0;␊ |
428 | //printf("load entry: seek to %llx\n",m_offset);␊ |
429 | if (!storage->seek(m_offset)) ␊ |
430 | {␊ |
431 | //printf("seek failed!\n");␊ |
432 | return FALSE;␊ |
433 | }␊ |
434 | if (m_info) delete m_info;␊ |
435 | m_info = unmarshalEntry(storage);␊ |
436 | m_info->name = m_name;␊ |
437 | m_info->type = m_type;␊ |
438 | m_info->section = m_section;␊ |
439 | return TRUE;␊ |
440 | }␊ |
441 | ␊ |
442 | bool EntryNav::saveEntry(Entry *e,FileStorage *storage)␊ |
443 | {␊ |
444 | m_offset = storage->pos();␊ |
445 | //printf("EntryNav::saveEntry offset=%llx\n",m_offset);␊ |
446 | marshalEntry(storage,e);␊ |
447 | return TRUE;␊ |
448 | }␊ |
449 | ␊ |
450 | void EntryNav::releaseEntry()␊ |
451 | {␊ |
452 | if (!m_noLoad) ␊ |
453 | { ␊ |
454 | //printf("EntryNav::releaseEntry %p\n",m_info);␊ |
455 | delete m_info; ␊ |
456 | m_info=0; ␊ |
457 | }␊ |
458 | }␊ |
459 | ␊ |
460 | void EntryNav::setEntry(Entry *e) ␊ |
461 | { ␊ |
462 | delete m_info;␊ |
463 | m_info = e; ␊ |
464 | //printf("EntryNav::setEntry %p\n",e);␊ |
465 | m_noLoad=TRUE; ␊ |
466 | }␊ |
467 | ␊ |
468 |