summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/arch.doc19
-rw-r--r--src/context.cpp1509
-rw-r--r--src/context.h575
-rw-r--r--src/dirdef.cpp6
-rw-r--r--src/dirdef.h1
-rw-r--r--src/filedef.cpp3
-rw-r--r--src/fortranscanner.l2
-rw-r--r--src/ftextstream.cpp1
-rw-r--r--src/memberdef.cpp4
-rw-r--r--src/template.cpp177
-rw-r--r--src/template.h76
11 files changed, 1463 insertions, 910 deletions
diff --git a/doc/arch.doc b/doc/arch.doc
index c464a3e..fc80659 100644
--- a/doc/arch.doc
+++ b/doc/arch.doc
@@ -190,13 +190,13 @@ could extract information from the XML output. Possible tools could be:
Since doxygen uses a lot of \c flex code it is important to understand
how \c flex works (for this one should read the man page)
and to understand what it is doing when \c flex is parsing some input.
-Fortunately, when flex is used with the -d option it outputs what rules
+Fortunately, when flex is used with the `-d` option it outputs what rules
matched. This makes it quite easy to follow what is going on for a
particular input fragment.
To make it easier to toggle debug information for a given flex file I
-wrote the following perl script, which automatically adds or removes -d
-from the correct line in the Makefile:
+wrote the following perl script, which automatically adds or removes `-d`
+from the correct line in the \c Makefile:
\verbatim
#!/usr/bin/perl
@@ -236,6 +236,19 @@ $now = time;
utime $now, $now, $file
\endverbatim
+Another way to get rules matching / debugging information from the flex code is in the following way:
+\verbatim
+touch src/<flex code file>.l
+make LEX="flex -d"
+\endverbatim
+to remove the rules / debug information again:
+\verbatim
+touch src/<flex codefile>.l
+make
+\endverbatim
+
+Note that by running doxygen with `-d lex` you get information about which flex
+codefile is used.
\htmlonly
Return to the <a href="index.html">index</a>.
diff --git a/src/context.cpp b/src/context.cpp
index 3641d1d..0597493 100644
--- a/src/context.cpp
+++ b/src/context.cpp
@@ -67,12 +67,37 @@ template<class T> class ScopedPtr
void reset(T *p=0) { if (p!=m_ptr) { delete m_ptr; m_ptr = p; } }
};
+/** @brief Reference counting smart pointer */
+template<class T> class SharedPtr
+{
+ private:
+ T *m_ptr;
+ SharedPtr(const SharedPtr &);
+ SharedPtr &operator=(const SharedPtr &p);
+ void operator==(const SharedPtr &) const;
+ void operator!=(const SharedPtr &) const;
+
+ public:
+ typedef T Type;
+ explicit SharedPtr(T *p=0) : m_ptr(p) { if (m_ptr) m_ptr->addRef(); }
+ ~SharedPtr() { if (m_ptr) m_ptr->release(); };
+ T &operator*() const { return *m_ptr; }
+ T *operator->() const { return m_ptr; }
+ T *get() const { return m_ptr; }
+ operator bool() const { return m_ptr!=0; }
+ void reset(T *p=0)
+ {
+ if (p) p->addRef();
+ if (m_ptr) m_ptr->release();
+ m_ptr = p;
+ }
+};
+
/** @brief Template List iterator support */
-template<class T>
class GenericConstIterator : public TemplateListIntf::ConstIterator
{
public:
- GenericConstIterator(const QList<T> &list)
+ GenericConstIterator(const QList<TemplateVariant> &list)
: m_it(list) { }
virtual ~GenericConstIterator() {}
void toFirst()
@@ -95,7 +120,7 @@ class GenericConstIterator : public TemplateListIntf::ConstIterator
{
if (m_it.current())
{
- v = m_it.current();
+ v = *m_it.current();
return TRUE;
}
else
@@ -105,17 +130,16 @@ class GenericConstIterator : public TemplateListIntf::ConstIterator
}
}
private:
- QListIterator<T> m_it;
+ QListIterator<TemplateVariant> m_it;
};
//------------------------------------------------------------------------
/** @brief standard template list implementation */
-template<class T>
class GenericNodeListContext : public TemplateListIntf
{
public:
- GenericNodeListContext()
+ GenericNodeListContext() : m_refCount(0)
{
m_children.setAutoDelete(TRUE);
}
@@ -130,31 +154,45 @@ class GenericNodeListContext : public TemplateListIntf
TemplateVariant result;
if (index>=0 && index<count())
{
- result = m_children.at(index);
+ result = *m_children.at(index);
}
return result;
}
TemplateListIntf::ConstIterator *createIterator() const
{
- return new GenericConstIterator<T>(m_children);
+ return new GenericConstIterator(m_children);
}
- void append(T *ctn)
+ void append(const TemplateVariant &ctn)
{
- m_children.append(ctn);
+ m_children.append(new TemplateVariant(ctn));
}
bool isEmpty() const
{
return m_children.isEmpty();
}
+ int addRef()
+ {
+ return ++m_refCount;
+ }
+ int release()
+ {
+ int count = --m_refCount;
+ if (count<=0)
+ {
+ delete this;
+ }
+ return count;
+ }
private:
- mutable QList<T> m_children;
+ mutable QList<TemplateVariant> m_children;
+ int m_refCount;
};
//------------------------------------------------------------------------
/** @brief Helper class to map a property name to a handler member function */
-class PropertyMapper
+class PropertyMapper
{
private:
struct PropertyFuncIntf
@@ -226,29 +264,34 @@ class PropertyMapper
class ConfigContext::Private
{
public:
- Private() { cachedLists.setAutoDelete(TRUE); }
+ Private() { m_cachedLists.setAutoDelete(TRUE); }
+ ~Private() { }
TemplateVariant fetchList(const QCString &name,const QStrList *list)
{
- TemplateList *tlist = cachedLists.find(name);
- if (tlist==0)
+ TemplateVariant *v = m_cachedLists.find(name);
+ if (v==0)
{
- tlist = new TemplateList;
- cachedLists.insert(name,tlist);
+ TemplateList *tlist = TemplateList::alloc();
+ m_cachedLists.insert(name,new TemplateVariant(tlist));
QStrListIterator li(*list);
char *s;
for (li.toFirst();(s=li.current());++li)
{
tlist->append(s);
}
+ return tlist;
+ }
+ else
+ {
+ return *v;
}
- return tlist;
}
private:
- QDict<TemplateList> cachedLists;
+ QDict<TemplateVariant> m_cachedLists;
};
//%% }
-ConfigContext::ConfigContext()
+ConfigContext::ConfigContext() : RefCountedContext("ConfigContext")
{
p = new Private;
}
@@ -312,7 +355,7 @@ class DoxygenContext::Private : public PropertyMapper
};
//%% }
-DoxygenContext::DoxygenContext()
+DoxygenContext::DoxygenContext() : RefCountedContext("DoxygenContext")
{
p = new Private;
}
@@ -721,6 +764,15 @@ class TranslateContext::Private : public PropertyMapper
{
return theTranslator->trDetailLevel();
}
+ TemplateVariant fileListDescription() const
+ {
+ bool extractAll = Config_getBool("EXTRACT_ALL");
+ return theTranslator->trFileListDescription(extractAll);
+ }
+ TemplateVariant directories() const
+ {
+ return theTranslator->trDirectories();
+ }
Private()
{
//%% string generatedBy
@@ -829,8 +881,12 @@ class TranslateContext::Private : public PropertyMapper
addProperty("classDocumentation", this,&Private::classDocumentation);
//%% string compoundMembers
addProperty("compoundMembers", this,&Private::compoundMembers);
- //%% strint detailLevel
+ //%% string detailLevel
addProperty("detailLevel", this,&Private::detailLevel);
+ //%% string fileListDescription
+ addProperty("fileListDescription",this,&Private::fileListDescription);
+ //%% string directories
+ addProperty("directories", this,&Private::directories);
m_javaOpt = Config_getBool("OPTIMIZE_OUTPUT_JAVA");
m_fortranOpt = Config_getBool("OPTIMIZE_FOR_FORTRAN");
@@ -843,7 +899,7 @@ class TranslateContext::Private : public PropertyMapper
};
//%% }
-TranslateContext::TranslateContext()
+TranslateContext::TranslateContext() : RefCountedContext("TranslateContext")
{
p = new Private;
}
@@ -959,29 +1015,33 @@ class DefinitionContext : public PropertyMapper
//%% list[Definition] navigationPath: Breadcrumb navigation path to this item
addProperty("navigationPath",this,&DefinitionContext::navigationPath);
+ m_cache.sourceDef.reset(TemplateList::alloc());
+ m_cache.lineLink.reset(TemplateStruct::alloc());
+ m_cache.fileLink.reset(TemplateStruct::alloc());
+
if (m_def && !m_def->getSourceFileBase().isEmpty())
{
- m_sourceDef.append(&m_lineLink);
- m_sourceDef.append(&m_fileLink);
- m_lineLink.set("text",m_def->getStartBodyLine());
- m_lineLink.set("isLinkable",TRUE);
- m_lineLink.set("fileName",m_def->getSourceFileBase());
- m_lineLink.set("anchor",m_def->getSourceAnchor());
+ m_cache.lineLink->set("text",m_def->getStartBodyLine());
+ m_cache.lineLink->set("isLinkable",TRUE);
+ m_cache.lineLink->set("fileName",m_def->getSourceFileBase());
+ m_cache.lineLink->set("anchor",m_def->getSourceAnchor());
if (m_def->definitionType()==Definition::TypeFile)
{
- m_fileLink.set("text",m_def->name());
+ m_cache.fileLink->set("text",m_def->name());
}
else if (m_def->getBodyDef())
{
- m_fileLink.set("text",m_def->getBodyDef()->name());
+ m_cache.fileLink->set("text",m_def->getBodyDef()->name());
}
else
{
- m_fileLink.set("text",name());
+ m_cache.fileLink->set("text",name());
}
- m_fileLink.set("isLinkable",TRUE);
- m_fileLink.set("fileName",m_def->getSourceFileBase());
- m_fileLink.set("anchor",QCString());
+ m_cache.fileLink->set("isLinkable",TRUE);
+ m_cache.fileLink->set("fileName",m_def->getSourceFileBase());
+ m_cache.fileLink->set("anchor",QCString());
+ m_cache.sourceDef->append(m_cache.lineLink.get());
+ m_cache.sourceDef->append(m_cache.fileLink.get());
}
}
TemplateVariant fileName() const
@@ -1092,9 +1152,9 @@ class DefinitionContext : public PropertyMapper
}
TemplateVariant sourceDef() const
{
- if (m_sourceDef.count()==2)
+ if (m_cache.sourceDef->count()==2)
{
- return &m_sourceDef;
+ return m_cache.sourceDef.get();
}
else
{
@@ -1113,19 +1173,21 @@ class DefinitionContext : public PropertyMapper
{
fillPath(((const FileDef*)def)->getDirDef(),list);
}
- NavPathElemContext *elem = new NavPathElemContext(def);
- list->append(elem);
- m_cache.navPathElems.append(elem);
+ list->append(NavPathElemContext::alloc(def));
}
TemplateVariant navigationPath() const
{
if (!m_cache.navPath)
{
- TemplateList *list = new TemplateList;
+ TemplateList *list = TemplateList::alloc();
if (m_def->getOuterScope() && m_def->getOuterScope()!=Doxygen::globalScope)
{
fillPath(m_def->getOuterScope(),list);
}
+ else if (m_def->definitionType()==Definition::TypeFile && ((const FileDef *)m_def)->getDirDef())
+ {
+ fillPath(((const FileDef *)m_def)->getDirDef(),list);
+ }
m_cache.navPath.reset(list);
}
return m_cache.navPath.get();
@@ -1135,17 +1197,16 @@ class DefinitionContext : public PropertyMapper
Definition *m_def;
struct Cachable
{
- Cachable() { navPathElems.setAutoDelete(TRUE); }
+ Cachable() { }
ScopedPtr<TemplateVariant> details;
ScopedPtr<TemplateVariant> brief;
ScopedPtr<TemplateVariant> inbodyDocs;
- ScopedPtr<TemplateList> navPath;
- QList<NavPathElemContext> navPathElems;
+ SharedPtr<TemplateList> navPath;
+ SharedPtr<TemplateList> sourceDef;
+ SharedPtr<TemplateStruct> fileLink;
+ SharedPtr<TemplateStruct> lineLink;
};
mutable Cachable m_cache;
- TemplateList m_sourceDef;
- TemplateStruct m_fileLink;
- TemplateStruct m_lineLink;
};
//%% }
@@ -1158,7 +1219,6 @@ class IncludeInfoContext::Private : public PropertyMapper
public:
Private(const IncludeInfo *info,SrcLangExt lang) :
m_info(info),
- m_fileContext(info && info->fileDef ? info->fileDef : 0),
m_lang(lang)
{
if (m_info)
@@ -1180,9 +1240,13 @@ class IncludeInfoContext::Private : public PropertyMapper
}
TemplateVariant file() const
{
- if (m_info->fileDef)
+ if (!m_fileContext && m_info && m_info->fileDef)
{
- return &m_fileContext;
+ m_fileContext.reset(FileContext::alloc(m_info->fileDef));
+ }
+ if (m_fileContext)
+ {
+ return m_fileContext.get();
}
else
{
@@ -1195,11 +1259,11 @@ class IncludeInfoContext::Private : public PropertyMapper
}
private:
const IncludeInfo *m_info;
- FileContext m_fileContext;
+ mutable SharedPtr<FileContext> m_fileContext;
SrcLangExt m_lang;
};
-IncludeInfoContext::IncludeInfoContext(const IncludeInfo *info,SrcLangExt lang)
+IncludeInfoContext::IncludeInfoContext(const IncludeInfo *info,SrcLangExt lang) : RefCountedContext("IncludeContext")
{
p = new Private(info,lang);
}
@@ -1218,7 +1282,7 @@ TemplateVariant IncludeInfoContext::get(const char *n) const
//------------------------------------------------------------------------
//%% list IncludeInfoList[Class] : list of nested classes
-class IncludeInfoListContext::Private : public GenericNodeListContext<IncludeInfoContext>
+class IncludeInfoListContext::Private : public GenericNodeListContext
{
public:
Private(const QList<IncludeInfo> &list,SrcLangExt lang)
@@ -1229,13 +1293,13 @@ class IncludeInfoListContext::Private : public GenericNodeListContext<IncludeInf
{
if (!ii->indirect)
{
- append(new IncludeInfoContext(ii,lang));
+ append(IncludeInfoContext::alloc(ii,lang));
}
}
}
};
-IncludeInfoListContext::IncludeInfoListContext(const QList<IncludeInfo> &list,SrcLangExt lang)
+IncludeInfoListContext::IncludeInfoListContext(const QList<IncludeInfo> &list,SrcLangExt lang) : RefCountedContext("IncludeListContext")
{
p = new Private(list,lang);
}
@@ -1269,7 +1333,7 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
{
public:
Private(ClassDef *cd) : DefinitionContext<ClassContext::Private>(cd),
- m_classDef(cd), m_usedFiles(cd)
+ m_classDef(cd)
{
addProperty("title", this,&Private::title);
addProperty("highlight", this,&Private::highlight);
@@ -1357,7 +1421,11 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
}
TemplateVariant usedFiles() const
{
- return TemplateVariant(&m_usedFiles);
+ if (!m_cache.usedFiles)
+ {
+ m_cache.usedFiles.reset(UsedFilesContext::alloc(m_classDef));
+ }
+ return m_cache.usedFiles.get();
}
DotClassGraph *getClassGraph() const
{
@@ -1461,7 +1529,7 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
{
if (!m_cache.includeInfo && m_classDef->includeInfo())
{
- m_cache.includeInfo.reset(new IncludeInfoContext(m_classDef->includeInfo(),m_classDef->getLanguage()));
+ m_cache.includeInfo.reset(IncludeInfoContext::alloc(m_classDef->includeInfo(),m_classDef->getLanguage()));
}
if (m_cache.includeInfo)
{
@@ -1476,7 +1544,7 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
{
if (!m_cache.inheritsList)
{
- m_cache.inheritsList.reset(new InheritanceListContext(m_classDef->baseClasses(),TRUE));
+ m_cache.inheritsList.reset(InheritanceListContext::alloc(m_classDef->baseClasses(),TRUE));
}
return m_cache.inheritsList.get();
}
@@ -1484,11 +1552,11 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
{
if (!m_cache.inheritedByList)
{
- m_cache.inheritedByList.reset(new InheritanceListContext(m_classDef->subClasses(),FALSE));
+ m_cache.inheritedByList.reset(InheritanceListContext::alloc(m_classDef->subClasses(),FALSE));
}
return m_cache.inheritedByList.get();
}
- TemplateVariant getMemberList(ScopedPtr<MemberListInfoContext> &list,
+ TemplateVariant getMemberList(SharedPtr<MemberListInfoContext> &list,
MemberListType type,const char *title,bool detailed=FALSE) const
{
if (!list)
@@ -1496,7 +1564,7 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
MemberList *ml = m_classDef->getMemberList(type);
if (ml)
{
- list.reset(new MemberListInfoContext(m_classDef,relPathAsString(),ml,title,detailed));
+ list.reset(MemberListInfoContext::alloc(m_classDef,relPathAsString(),ml,title,detailed));
}
}
if (list)
@@ -1676,7 +1744,7 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
{
if (!m_cache.classes)
{
- NestedClassListContext *classList = new NestedClassListContext;
+ NestedClassListContext *classList = NestedClassListContext::alloc();
if (m_classDef->getClassSDict())
{
ClassSDict::Iterator sdi(*m_classDef->getClassSDict());
@@ -1709,10 +1777,9 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
ClassDef *cd=(ClassDef *)d;
if (cd->templateArguments())
{
- ArgumentListContext *al = new ArgumentListContext(cd->templateArguments(),cd,relPathAsString());
+ ArgumentListContext *al = ArgumentListContext::alloc(cd->templateArguments(),cd,relPathAsString());
// since a TemplateVariant does take ownership of the object, we add it
// a separate list just to be able to delete it and avoid a memory leak
- m_cache.templateArgList.append(al);
tl->append(al);
}
}
@@ -1725,8 +1792,7 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
Example *ex;
for (it.toFirst();(ex=it.current());++it)
{
- TemplateStruct *s = new TemplateStruct;
- m_cache.exampleList.append(s);
+ TemplateStruct *s = TemplateStruct::alloc();
s->set("text",ex->name);
s->set("isLinkable",TRUE);
s->set("anchor",ex->anchor);
@@ -1739,7 +1805,7 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
{
if (!m_cache.templateDecls)
{
- TemplateList *tl = new TemplateList;
+ TemplateList *tl = TemplateList::alloc();
addTemplateDecls(m_classDef,tl);
m_cache.templateDecls.reset(tl);
}
@@ -1749,11 +1815,11 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
{
if (!m_cache.typeConstraints && m_classDef->typeConstraints())
{
- m_cache.typeConstraints.reset(new ArgumentListContext(m_classDef->typeConstraints(),m_classDef,relPathAsString()));
+ m_cache.typeConstraints.reset(ArgumentListContext::alloc(m_classDef->typeConstraints(),m_classDef,relPathAsString()));
}
else
{
- m_cache.typeConstraints.reset(new ArgumentListContext);
+ m_cache.typeConstraints.reset(ArgumentListContext::alloc());
}
return m_cache.typeConstraints.get();
}
@@ -1761,7 +1827,7 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
{
if (!m_cache.examples)
{
- TemplateList *exampleList = new TemplateList;
+ TemplateList *exampleList = TemplateList::alloc();
addExamples(exampleList);
m_cache.examples.reset(exampleList);
}
@@ -1816,20 +1882,23 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
addMembers(m_classDef,MemberListType_priAttribs);
addMembers(m_classDef,MemberListType_priStaticAttribs);
addMembers(m_classDef,MemberListType_related);
- m_cache.members.reset(new MemberListContext(&m_cache.allMembers));
+ m_cache.members.reset(MemberListContext::alloc(&m_cache.allMembers));
}
return m_cache.members.get();
}
TemplateVariant allMembersList() const
{
- if (!m_cache.allMembersList && m_classDef->memberNameInfoSDict())
+ if (!m_cache.allMembersList)
{
- AllMembersListContext *ml = new AllMembersListContext(m_classDef->memberNameInfoSDict());
- m_cache.allMembersList.reset(ml);
- }
- else
- {
- m_cache.allMembersList.reset(new AllMembersListContext);
+ if (m_classDef->memberNameInfoSDict())
+ {
+ AllMembersListContext *ml = AllMembersListContext::alloc(m_classDef->memberNameInfoSDict());
+ m_cache.allMembersList.reset(ml);
+ }
+ else
+ {
+ m_cache.allMembersList.reset(AllMembersListContext::alloc());
+ }
}
return m_cache.allMembersList.get();
}
@@ -1843,11 +1912,11 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
{
if (m_classDef->getMemberGroupSDict())
{
- m_cache.memberGroups.reset(new MemberGroupListContext(m_classDef,relPathAsString(),m_classDef->getMemberGroupSDict(),m_classDef->subGrouping()));
+ m_cache.memberGroups.reset(MemberGroupListContext::alloc(m_classDef,relPathAsString(),m_classDef->getMemberGroupSDict(),m_classDef->subGrouping()));
}
else
{
- m_cache.memberGroups.reset(new MemberGroupListContext);
+ m_cache.memberGroups.reset(MemberGroupListContext::alloc());
}
}
return m_cache.memberGroups.get();
@@ -1856,7 +1925,7 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
{
if (!m_cache.additionalInheritedMembers)
{
- InheritedMemberInfoListContext *ctx = new InheritedMemberInfoListContext;
+ InheritedMemberInfoListContext *ctx = InheritedMemberInfoListContext::alloc();
ctx->addMemberList(m_classDef,MemberListType_pubTypes,theTranslator->trPublicTypes());
ctx->addMemberList(m_classDef,MemberListType_services,theTranslator->trServices());
ctx->addMemberList(m_classDef,MemberListType_interfaces,theTranslator->trInterfaces());
@@ -1897,77 +1966,72 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
private:
ClassDef *m_classDef;
- UsedFilesContext m_usedFiles;
struct Cachable
{
- Cachable() : inheritanceNodes(-1)
- {
- templateArgList.setAutoDelete(TRUE);
- exampleList.setAutoDelete(TRUE);
- }
- ScopedPtr<IncludeInfoContext> includeInfo;
- ScopedPtr<InheritanceListContext> inheritsList;
- ScopedPtr<InheritanceListContext> inheritedByList;
+ Cachable() : inheritanceNodes(-1) { }
+ SharedPtr<IncludeInfoContext> includeInfo;
+ SharedPtr<InheritanceListContext> inheritsList;
+ SharedPtr<InheritanceListContext> inheritedByList;
ScopedPtr<DotClassGraph> classGraph;
ScopedPtr<DotClassGraph> collaborationGraph;
- ScopedPtr<NestedClassListContext> classes;
- ScopedPtr<MemberListInfoContext> publicTypes;
- ScopedPtr<MemberListInfoContext> publicMethods;
- ScopedPtr<MemberListInfoContext> publicStaticMethods;
- ScopedPtr<MemberListInfoContext> publicAttributes;
- ScopedPtr<MemberListInfoContext> publicStaticAttributes;
- ScopedPtr<MemberListInfoContext> publicSlots;
- ScopedPtr<MemberListInfoContext> protectedTypes;
- ScopedPtr<MemberListInfoContext> protectedMethods;
- ScopedPtr<MemberListInfoContext> protectedStaticMethods;
- ScopedPtr<MemberListInfoContext> protectedAttributes;
- ScopedPtr<MemberListInfoContext> protectedStaticAttributes;
- ScopedPtr<MemberListInfoContext> protectedSlots;
- ScopedPtr<MemberListInfoContext> privateTypes;
- ScopedPtr<MemberListInfoContext> privateMethods;
- ScopedPtr<MemberListInfoContext> privateStaticMethods;
- ScopedPtr<MemberListInfoContext> privateAttributes;
- ScopedPtr<MemberListInfoContext> privateStaticAttributes;
- ScopedPtr<MemberListInfoContext> privateSlots;
- ScopedPtr<MemberListInfoContext> packageTypes;
- ScopedPtr<MemberListInfoContext> packageMethods;
- ScopedPtr<MemberListInfoContext> packageStaticMethods;
- ScopedPtr<MemberListInfoContext> packageAttributes;
- ScopedPtr<MemberListInfoContext> packageStaticAttributes;
- ScopedPtr<MemberListInfoContext> unoIDLServices;
- ScopedPtr<MemberListInfoContext> unoIDLInterfaces;
- ScopedPtr<MemberListInfoContext> signals;
- ScopedPtr<MemberListInfoContext> properties;
- ScopedPtr<MemberListInfoContext> events;
- ScopedPtr<MemberListInfoContext> friends;
- ScopedPtr<MemberListInfoContext> related;
- ScopedPtr<MemberListInfoContext> detailedTypedefs;
- ScopedPtr<MemberListInfoContext> detailedEnums;
- ScopedPtr<MemberListInfoContext> detailedServices;
- ScopedPtr<MemberListInfoContext> detailedInterfaces;
- ScopedPtr<MemberListInfoContext> detailedConstructors;
- ScopedPtr<MemberListInfoContext> detailedMethods;
- ScopedPtr<MemberListInfoContext> detailedRelated;
- ScopedPtr<MemberListInfoContext> detailedVariables;
- ScopedPtr<MemberListInfoContext> detailedProperties;
- ScopedPtr<MemberListInfoContext> detailedEvents;
- ScopedPtr<MemberGroupListContext> memberGroups;
- ScopedPtr<AllMembersListContext> allMembersList;
- ScopedPtr<ArgumentListContext> typeConstraints;
- ScopedPtr<TemplateList> examples;
- ScopedPtr<TemplateList> templateDecls;
- ScopedPtr<InheritedMemberInfoListContext> additionalInheritedMembers;
- ScopedPtr<MemberListContext> members;
- QList<ArgumentListContext> templateArgList;
+ SharedPtr<NestedClassListContext> classes;
+ SharedPtr<MemberListInfoContext> publicTypes;
+ SharedPtr<MemberListInfoContext> publicMethods;
+ SharedPtr<MemberListInfoContext> publicStaticMethods;
+ SharedPtr<MemberListInfoContext> publicAttributes;
+ SharedPtr<MemberListInfoContext> publicStaticAttributes;
+ SharedPtr<MemberListInfoContext> publicSlots;
+ SharedPtr<MemberListInfoContext> protectedTypes;
+ SharedPtr<MemberListInfoContext> protectedMethods;
+ SharedPtr<MemberListInfoContext> protectedStaticMethods;
+ SharedPtr<MemberListInfoContext> protectedAttributes;
+ SharedPtr<MemberListInfoContext> protectedStaticAttributes;
+ SharedPtr<MemberListInfoContext> protectedSlots;
+ SharedPtr<MemberListInfoContext> privateTypes;
+ SharedPtr<MemberListInfoContext> privateMethods;
+ SharedPtr<MemberListInfoContext> privateStaticMethods;
+ SharedPtr<MemberListInfoContext> privateAttributes;
+ SharedPtr<MemberListInfoContext> privateStaticAttributes;
+ SharedPtr<MemberListInfoContext> privateSlots;
+ SharedPtr<MemberListInfoContext> packageTypes;
+ SharedPtr<MemberListInfoContext> packageMethods;
+ SharedPtr<MemberListInfoContext> packageStaticMethods;
+ SharedPtr<MemberListInfoContext> packageAttributes;
+ SharedPtr<MemberListInfoContext> packageStaticAttributes;
+ SharedPtr<MemberListInfoContext> unoIDLServices;
+ SharedPtr<MemberListInfoContext> unoIDLInterfaces;
+ SharedPtr<MemberListInfoContext> signals;
+ SharedPtr<MemberListInfoContext> properties;
+ SharedPtr<MemberListInfoContext> events;
+ SharedPtr<MemberListInfoContext> friends;
+ SharedPtr<MemberListInfoContext> related;
+ SharedPtr<MemberListInfoContext> detailedTypedefs;
+ SharedPtr<MemberListInfoContext> detailedEnums;
+ SharedPtr<MemberListInfoContext> detailedServices;
+ SharedPtr<MemberListInfoContext> detailedInterfaces;
+ SharedPtr<MemberListInfoContext> detailedConstructors;
+ SharedPtr<MemberListInfoContext> detailedMethods;
+ SharedPtr<MemberListInfoContext> detailedRelated;
+ SharedPtr<MemberListInfoContext> detailedVariables;
+ SharedPtr<MemberListInfoContext> detailedProperties;
+ SharedPtr<MemberListInfoContext> detailedEvents;
+ SharedPtr<MemberGroupListContext> memberGroups;
+ SharedPtr<AllMembersListContext> allMembersList;
+ SharedPtr<ArgumentListContext> typeConstraints;
+ SharedPtr<TemplateList> examples;
+ SharedPtr<TemplateList> templateDecls;
+ SharedPtr<InheritedMemberInfoListContext> additionalInheritedMembers;
+ SharedPtr<MemberListContext> members;
+ SharedPtr<UsedFilesContext> usedFiles;
+ SharedPtr<TemplateList> exampleList;
int inheritanceNodes;
- QList<TemplateStruct> exampleList;
MemberList allMembers;
};
mutable Cachable m_cache;
};
//%% }
-ClassContext::ClassContext(ClassDef *cd)
+ClassContext::ClassContext(ClassDef *cd) : RefCountedContext("ClassContext")
{
//printf("ClassContext::ClassContext(%s)\n",cd?cd->name().data():"<none>");
p = new Private(cd);
@@ -2023,7 +2087,7 @@ class NamespaceContext::Private : public DefinitionContext<NamespaceContext::Pri
};
//%% }
-NamespaceContext::NamespaceContext(NamespaceDef *nd)
+NamespaceContext::NamespaceContext(NamespaceDef *nd) : RefCountedContext("NamespaceContext")
{
p = new Private(nd);
}
@@ -2047,6 +2111,7 @@ class FileContext::Private : public DefinitionContext<FileContext::Private>
public:
Private(FileDef *fd) : DefinitionContext<FileContext::Private>(fd) , m_fileDef(fd)
{
+ if (fd==0) abort();
addProperty("title", this,&Private::title);
addProperty("highlight", this,&Private::highlight);
addProperty("subhighlight", this,&Private::subHighlight);
@@ -2075,6 +2140,7 @@ class FileContext::Private : public DefinitionContext<FileContext::Private>
addProperty("detailedFunctions", this,&Private::detailedFunctions);
addProperty("detailedVariables", this,&Private::detailedVariables);
addProperty("inlineClasses", this,&Private::inlineClasses);
+ addProperty("compoundType", this,&Private::compoundType);
}
TemplateVariant title() const
{
@@ -2096,7 +2162,7 @@ class FileContext::Private : public DefinitionContext<FileContext::Private>
{
if (!m_cache.includeInfoList && m_fileDef->includeFileList())
{
- m_cache.includeInfoList.reset(new IncludeInfoListContext(
+ m_cache.includeInfoList.reset(IncludeInfoListContext::alloc(
*m_fileDef->includeFileList(),m_fileDef->getLanguage()));
}
if (m_cache.includeInfoList)
@@ -2201,7 +2267,7 @@ class FileContext::Private : public DefinitionContext<FileContext::Private>
{
if (!m_cache.classes)
{
- NestedClassListContext *classList = new NestedClassListContext;
+ NestedClassListContext *classList = NestedClassListContext::alloc();
if (m_fileDef->getClassSDict())
{
ClassSDict::Iterator sdi(*m_fileDef->getClassSDict());
@@ -2222,7 +2288,7 @@ class FileContext::Private : public DefinitionContext<FileContext::Private>
{
if (!m_cache.namespaces)
{
- NestedNamespaceListContext *namespaceList = new NestedNamespaceListContext;
+ NestedNamespaceListContext *namespaceList = NestedNamespaceListContext::alloc();
if (m_fileDef->getNamespaceSDict())
{
NamespaceSDict::Iterator sdi(*m_fileDef->getNamespaceSDict());
@@ -2243,7 +2309,7 @@ class FileContext::Private : public DefinitionContext<FileContext::Private>
{
if (!m_cache.constantgroups)
{
- NestedNamespaceListContext *namespaceList = new NestedNamespaceListContext;
+ NestedNamespaceListContext *namespaceList = NestedNamespaceListContext::alloc();
if (m_fileDef->getNamespaceSDict())
{
NamespaceSDict::Iterator sdi(*m_fileDef->getNamespaceSDict());
@@ -2260,7 +2326,7 @@ class FileContext::Private : public DefinitionContext<FileContext::Private>
}
return m_cache.constantgroups.get();
}
- TemplateVariant getMemberList(ScopedPtr<MemberListInfoContext> &list,
+ TemplateVariant getMemberList(SharedPtr<MemberListInfoContext> &list,
MemberListType type,const char *title,bool detailed=FALSE) const
{
if (!list)
@@ -2268,7 +2334,7 @@ class FileContext::Private : public DefinitionContext<FileContext::Private>
MemberList *ml = m_fileDef->getMemberList(type);
if (ml)
{
- list.reset(new MemberListInfoContext(m_fileDef,relPathAsString(),ml,title,detailed));
+ list.reset(MemberListInfoContext::alloc(m_fileDef,relPathAsString(),ml,title,detailed));
}
}
if (list)
@@ -2308,11 +2374,11 @@ class FileContext::Private : public DefinitionContext<FileContext::Private>
{
if (m_fileDef->getMemberGroupSDict())
{
- m_cache.memberGroups.reset(new MemberGroupListContext(m_fileDef,relPathAsString(),m_fileDef->getMemberGroupSDict(),m_fileDef->subGrouping()));
+ m_cache.memberGroups.reset(MemberGroupListContext::alloc(m_fileDef,relPathAsString(),m_fileDef->getMemberGroupSDict(),m_fileDef->subGrouping()));
}
else
{
- m_cache.memberGroups.reset(new MemberGroupListContext);
+ m_cache.memberGroups.reset(MemberGroupListContext::alloc());
}
}
return m_cache.memberGroups.get();
@@ -2342,7 +2408,7 @@ class FileContext::Private : public DefinitionContext<FileContext::Private>
{
if (!m_cache.inlineClasses)
{
- NestedClassListContext *classList = new NestedClassListContext;
+ NestedClassListContext *classList = NestedClassListContext::alloc();
if (m_fileDef->getClassSDict())
{
ClassSDict::Iterator sdi(*m_fileDef->getClassSDict());
@@ -2352,7 +2418,7 @@ class FileContext::Private : public DefinitionContext<FileContext::Private>
if (cd->name().find('@')==-1 &&
cd->isLinkableInProject() &&
cd->isEmbeddedInOuterScope() &&
- cd->partOfGroups()==0)
+ cd->partOfGroups()==0)
{
classList->append(cd);
}
@@ -2362,36 +2428,40 @@ class FileContext::Private : public DefinitionContext<FileContext::Private>
}
return m_cache.inlineClasses.get();
}
+ TemplateVariant compoundType() const
+ {
+ return theTranslator->trFile(FALSE,TRUE);
+ }
private:
FileDef *m_fileDef;
struct Cachable
{
- ScopedPtr<IncludeInfoListContext> includeInfoList;
+ SharedPtr<IncludeInfoListContext> includeInfoList;
ScopedPtr<DotInclDepGraph> includeGraph;
ScopedPtr<DotInclDepGraph> includedByGraph;
ScopedPtr<TemplateVariant> sources;
- ScopedPtr<NestedClassListContext> classes;
- ScopedPtr<NestedNamespaceListContext> namespaces;
- ScopedPtr<NestedNamespaceListContext> constantgroups;
- ScopedPtr<MemberListInfoContext> macros;
- ScopedPtr<MemberListInfoContext> typedefs;
- ScopedPtr<MemberListInfoContext> enums;
- ScopedPtr<MemberListInfoContext> functions;
- ScopedPtr<MemberListInfoContext> variables;
- ScopedPtr<MemberGroupListContext> memberGroups;
- ScopedPtr<MemberListInfoContext> detailedMacros;
- ScopedPtr<MemberListInfoContext> detailedTypedefs;
- ScopedPtr<MemberListInfoContext> detailedEnums;
- ScopedPtr<MemberListInfoContext> detailedFunctions;
- ScopedPtr<MemberListInfoContext> detailedVariables;
- ScopedPtr<NestedClassListContext> inlineClasses;
+ SharedPtr<NestedClassListContext> classes;
+ SharedPtr<NestedNamespaceListContext> namespaces;
+ SharedPtr<NestedNamespaceListContext> constantgroups;
+ SharedPtr<MemberListInfoContext> macros;
+ SharedPtr<MemberListInfoContext> typedefs;
+ SharedPtr<MemberListInfoContext> enums;
+ SharedPtr<MemberListInfoContext> functions;
+ SharedPtr<MemberListInfoContext> variables;
+ SharedPtr<MemberGroupListContext> memberGroups;
+ SharedPtr<MemberListInfoContext> detailedMacros;
+ SharedPtr<MemberListInfoContext> detailedTypedefs;
+ SharedPtr<MemberListInfoContext> detailedEnums;
+ SharedPtr<MemberListInfoContext> detailedFunctions;
+ SharedPtr<MemberListInfoContext> detailedVariables;
+ SharedPtr<NestedClassListContext> inlineClasses;
};
mutable Cachable m_cache;
};
//%% }
-FileContext::FileContext(FileDef *fd)
+FileContext::FileContext(FileDef *fd) : RefCountedContext("FileContext")
{
p = new Private(fd);
}
@@ -2415,10 +2485,14 @@ class DirContext::Private : public DefinitionContext<DirContext::Private>
public:
Private(DirDef *dd) : DefinitionContext<DirContext::Private>(dd) , m_dirDef(dd)
{
- addProperty("title",this,&Private::title);
- addProperty("highlight",this,&Private::highlight);
- addProperty("subhighlight",this,&Private::subHighlight);
- addProperty("dirName",this,&Private::dirName);
+ addProperty("title", this,&Private::title);
+ addProperty("highlight", this,&Private::highlight);
+ addProperty("subhighlight", this,&Private::subHighlight);
+ addProperty("dirName", this,&Private::dirName);
+ addProperty("dirs", this,&Private::dirs);
+ addProperty("files", this,&Private::files);
+ addProperty("hasDetails", this,&Private::hasDetails);
+ addProperty("compoundType", this,&Private::compoundType);
}
TemplateVariant title() const
{
@@ -2436,12 +2510,64 @@ class DirContext::Private : public DefinitionContext<DirContext::Private>
{
return TemplateVariant(m_dirDef->shortName());
}
+ TemplateVariant dirs() const
+ {
+ if (!m_cache.dirs)
+ {
+ m_cache.dirs.reset(TemplateList::alloc());
+ const DirList &subDirs = m_dirDef->subDirs();
+ QListIterator<DirDef> it(subDirs);
+ DirDef *dd;
+ for (it.toFirst();(dd=it.current());++it)
+ {
+ DirContext *dc = new DirContext(dd);
+ m_cache.dirs->append(dc);
+ }
+ }
+ return m_cache.dirs.get();
+ }
+ TemplateVariant files() const
+ {
+ // FileList *list = m_dirDef->getFiles();
+ if (!m_cache.files)
+ {
+ m_cache.files.reset(TemplateList::alloc());
+ FileList *files = m_dirDef->getFiles();
+ if (files)
+ {
+ QListIterator<FileDef> it(*files);
+ FileDef *fd;
+ for (it.toFirst();(fd=it.current());++it)
+ {
+ FileContext *fc = FileContext::alloc(fd);
+ m_cache.files->append(fc);
+ }
+ }
+ }
+ return m_cache.files.get();
+ }
+ TemplateVariant hasDetails() const
+ {
+ return m_dirDef->hasDetailedDescription();
+ }
+ TemplateVariant compoundType() const
+ {
+ return theTranslator->trDir(FALSE,TRUE);
+ }
+
private:
DirDef *m_dirDef;
+ struct Cachable
+ {
+ Cachable() {}
+ SharedPtr<TemplateList> dirs;
+ SharedPtr<TemplateList> files;
+ };
+ mutable Cachable m_cache;
};
//%% }
-DirContext::DirContext(DirDef *fd)
+DirContext::DirContext(DirDef *fd) : RefCountedContext("DirContext")
{
p = new Private(fd);
}
@@ -2456,7 +2582,6 @@ TemplateVariant DirContext::get(const char *n) const
return p->get(n);
}
-
//------------------------------------------------------------------------
//%% struct Page(Symbol): page information
@@ -2487,7 +2612,7 @@ class PageContext::Private : public DefinitionContext<PageContext::Private>
};
//%% }
-PageContext::PageContext(PageDef *pd)
+PageContext::PageContext(PageDef *pd) : RefCountedContext("PageContext")
{
p = new Private(pd);
}
@@ -2726,16 +2851,18 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
addProperty("callerGraph", this,&Private::callerGraph);
addProperty("fieldType", this,&Private::fieldType);
+ m_cache.propertyAttrs.reset(TemplateList::alloc());
if (md && md->isProperty())
{
- if (md->isGettable()) m_propertyAttrs.append("get");
- if (md->isSettable()) m_propertyAttrs.append("set");
+ if (md->isGettable()) m_cache.propertyAttrs->append("get");
+ if (md->isSettable()) m_cache.propertyAttrs->append("set");
}
+ m_cache.eventAttrs.reset(TemplateList::alloc());
if (md && md->isEvent())
{
- if (md->isAddable()) m_eventAttrs.append("add");
- if (md->isRemovable()) m_eventAttrs.append("remove");
- if (md->isRaisable()) m_eventAttrs.append("raise");
+ if (md->isAddable()) m_cache.eventAttrs->append("add");
+ if (md->isRemovable()) m_cache.eventAttrs->append("remove");
+ if (md->isRaisable()) m_cache.eventAttrs->append("raise");
}
}
TemplateVariant fieldType() const
@@ -3029,7 +3156,7 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
ClassDef *cd = m_memberDef->getClassDefOfAnonymousType();
if (cd)
{
- m_cache.anonymousType.reset(new ClassContext(cd));
+ m_cache.anonymousType.reset(ClassContext::alloc(cd));
}
}
if (m_cache.anonymousType)
@@ -3048,7 +3175,7 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
MemberDef *md = m_memberDef->fromAnonymousMember();
if (md)
{
- m_cache.anonymousMember.reset(new MemberContext(md));
+ m_cache.anonymousMember.reset(MemberContext::alloc(md));
}
}
if (m_cache.anonymousMember)
@@ -3083,11 +3210,11 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
MemberList *ml = m_memberDef->enumFieldList();
if (ml)
{
- m_cache.enumValues.reset(new MemberListContext(ml));
+ m_cache.enumValues.reset(MemberListContext::alloc(ml));
}
else
{
- m_cache.enumValues.reset(new MemberListContext);
+ m_cache.enumValues.reset(MemberListContext::alloc());
}
}
return m_cache.enumValues.get();
@@ -3096,7 +3223,7 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
{
if (!m_cache.templateArgs && m_memberDef->templateArguments())
{
- m_cache.templateArgs.reset(new ArgumentListContext(m_memberDef->templateArguments(),m_memberDef,relPathAsString()));
+ m_cache.templateArgs.reset(ArgumentListContext::alloc(m_memberDef->templateArguments(),m_memberDef,relPathAsString()));
}
if (m_cache.templateArgs)
{
@@ -3118,17 +3245,17 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
}
TemplateVariant propertyAttrs() const
{
- return &m_propertyAttrs;
+ return m_cache.propertyAttrs.get();
}
TemplateVariant eventAttrs() const
{
- return &m_eventAttrs;
+ return m_cache.eventAttrs.get();
}
TemplateVariant getClass() const
{
if (!m_cache.classDef && m_memberDef->getClassDef())
{
- m_cache.classDef.reset(new ClassContext(m_memberDef->getClassDef()));
+ m_cache.classDef.reset(ClassContext::alloc(m_memberDef->getClassDef()));
}
if (m_cache.classDef)
{
@@ -3156,11 +3283,11 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
ArgumentList *defArgList = getDefArgList();
if (defArgList && !m_memberDef->isProperty())
{
- m_cache.arguments.reset(new ArgumentListContext(defArgList,m_memberDef,relPathAsString()));
+ m_cache.arguments.reset(ArgumentListContext::alloc(defArgList,m_memberDef,relPathAsString()));
}
else
{
- m_cache.arguments.reset(new ArgumentListContext);
+ m_cache.arguments.reset(ArgumentListContext::alloc());
}
}
return m_cache.arguments.get();
@@ -3207,8 +3334,7 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
{
if (tal->count()>0)
{
- ArgumentListContext *al = new ArgumentListContext(tal,m_memberDef,relPathAsString());
- m_cache.templateArgList.append(al);
+ ArgumentListContext *al = ArgumentListContext::alloc(tal,m_memberDef,relPathAsString());
tl->append(al);
}
}
@@ -3226,17 +3352,15 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
{
if (tal->count()>0)
{
- ArgumentListContext *al = new ArgumentListContext(tal,m_memberDef,relPathAsString());
- m_cache.templateArgList.append(al);
+ ArgumentListContext *al = ArgumentListContext::alloc(tal,m_memberDef,relPathAsString());
tl->append(al);
}
}
}
if (m_memberDef->templateArguments()) // function template prefix
{
- ArgumentListContext *al = new ArgumentListContext(
+ ArgumentListContext *al = ArgumentListContext::alloc(
m_memberDef->templateArguments(),m_memberDef,relPathAsString());
- m_cache.templateArgList.append(al);
tl->append(al);
}
}
@@ -3245,7 +3369,7 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
{
if (!m_cache.templateDecls)
{
- TemplateList *tl = new TemplateList;
+ TemplateList *tl = TemplateList::alloc();
addTemplateDecls(tl);
m_cache.templateDecls.reset(tl);
}
@@ -3257,7 +3381,7 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
{
QStrList sl;
m_memberDef->getLabels(sl,m_memberDef->getOuterScope());
- TemplateList *tl = new TemplateList;
+ TemplateList *tl = TemplateList::alloc();
if (sl.count()>0)
{
QStrListIterator it(sl);
@@ -3304,14 +3428,13 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
if (!m_cache.implements)
{
MemberDef *md = m_memberDef->reimplements();
- m_cache.implements.reset(new TemplateList);
+ m_cache.implements.reset(TemplateList::alloc());
if (md)
{
ClassDef *cd = md->getClassDef();
if (cd && (md->virtualness()==Pure || cd->compoundType()==ClassDef::Interface))
{
- MemberContext *mc = new MemberContext(md);
- m_cache.implementsMember.reset(mc);
+ MemberContext *mc = MemberContext::alloc(md);
m_cache.implements->append(mc);
}
}
@@ -3323,14 +3446,13 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
if (!m_cache.reimplements)
{
MemberDef *md = m_memberDef->reimplements();
- m_cache.reimplements.reset(new TemplateList);
+ m_cache.reimplements.reset(TemplateList::alloc());
if (md)
{
ClassDef *cd = md->getClassDef();
if (cd && md->virtualness()!=Pure && cd->compoundType()!=ClassDef::Interface)
{
- MemberContext *mc = new MemberContext(md);
- m_cache.reimplementsMember.reset(mc);
+ MemberContext *mc = MemberContext::alloc(md);
m_cache.reimplements->append(mc);
}
}
@@ -3342,7 +3464,7 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
if (!m_cache.implementedBy)
{
MemberList *ml = m_memberDef->reimplementedBy();
- m_cache.implementedBy.reset(new TemplateList);
+ m_cache.implementedBy.reset(TemplateList::alloc());
if (ml)
{
MemberListIterator mli(*ml);
@@ -3353,7 +3475,6 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
if (cd && (md->virtualness()==Pure || cd->compoundType()==ClassDef::Interface))
{
MemberContext *mc = new MemberContext(md);
- m_cache.implementedByMembers.append(mc);
m_cache.implementedBy->append(mc);
}
}
@@ -3365,7 +3486,7 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
{
if (!m_cache.reimplementedBy)
{
- m_cache.reimplementedBy.reset(new TemplateList);
+ m_cache.reimplementedBy.reset(TemplateList::alloc());
MemberList *ml = m_memberDef->reimplementedBy();
if (ml)
{
@@ -3377,7 +3498,6 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
if (cd && md->virtualness()!=Pure && cd->compoundType()!=ClassDef::Interface)
{
MemberContext *mc = new MemberContext(md);
- m_cache.reimplementedByMembers.append(mc);
m_cache.reimplementedBy->append(mc);
}
}
@@ -3393,8 +3513,7 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
Example *ex;
for (it.toFirst();(ex=it.current());++it)
{
- TemplateStruct *s = new TemplateStruct;
- m_cache.exampleList.append(s);
+ TemplateStruct *s = TemplateStruct::alloc();
s->set("text",ex->name);
s->set("isLinkable",TRUE);
s->set("anchor",ex->anchor);
@@ -3407,7 +3526,7 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
{
if (!m_cache.examples)
{
- TemplateList *exampleList = new TemplateList;
+ TemplateList *exampleList = TemplateList::alloc();
addExamples(exampleList);
m_cache.examples.reset(exampleList);
}
@@ -3417,11 +3536,11 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
{
if (!m_cache.typeConstraints && m_memberDef->typeConstraints())
{
- m_cache.typeConstraints.reset(new ArgumentListContext(m_memberDef->typeConstraints(),m_memberDef,relPathAsString()));
+ m_cache.typeConstraints.reset(ArgumentListContext::alloc(m_memberDef->typeConstraints(),m_memberDef,relPathAsString()));
}
else
{
- m_cache.typeConstraints.reset(new ArgumentListContext);
+ m_cache.typeConstraints.reset(ArgumentListContext::alloc());
}
return m_cache.typeConstraints.get();
}
@@ -3444,7 +3563,7 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
{
if (!m_cache.sourceRefs)
{
- m_cache.sourceRefs.reset(new MemberListContext(m_memberDef->getReferencesMembers(),TRUE));
+ m_cache.sourceRefs.reset(MemberListContext::alloc(m_memberDef->getReferencesMembers(),TRUE));
}
return m_cache.sourceRefs.get();
}
@@ -3452,7 +3571,7 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
{
if (!m_cache.sourceRefBys)
{
- m_cache.sourceRefBys.reset(new MemberListContext(m_memberDef->getReferencedByMembers(),TRUE));
+ m_cache.sourceRefBys.reset(MemberListContext::alloc(m_memberDef->getReferencedByMembers(),TRUE));
}
return m_cache.sourceRefBys.get();
}
@@ -3573,48 +3692,39 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
{
Cachable() : initializerParsed(FALSE), sourceCodeParsed(FALSE)
{
- implementedByMembers.setAutoDelete(TRUE);
- reimplementedByMembers.setAutoDelete(TRUE);
- templateArgList.setAutoDelete(TRUE);
- exampleList.setAutoDelete(TRUE);
- }
- ScopedPtr<ArgumentListContext> templateArgs;
- ScopedPtr<ArgumentListContext> arguments;
- ScopedPtr<MemberListContext> enumValues;
- ScopedPtr<ClassContext> classDef;
- ScopedPtr<ClassContext> anonymousType;
- ScopedPtr<TemplateList> templateDecls;
+ }
+ SharedPtr<ArgumentListContext> templateArgs;
+ SharedPtr<ArgumentListContext> arguments;
+ SharedPtr<MemberListContext> enumValues;
+ SharedPtr<ClassContext> classDef;
+ SharedPtr<ClassContext> anonymousType;
+ SharedPtr<TemplateList> templateDecls;
ScopedPtr<TemplateVariant> paramDocs;
- ScopedPtr<TemplateList> implements;
- ScopedPtr<MemberContext> implementsMember;
- ScopedPtr<TemplateList> reimplements;
- ScopedPtr<MemberContext> reimplementsMember;
- ScopedPtr<TemplateList> implementedBy;
- ScopedPtr<MemberListContext> sourceRefs;
- ScopedPtr<MemberListContext> sourceRefBys;
+ SharedPtr<TemplateList> implements;
+ SharedPtr<TemplateList> reimplements;
+ SharedPtr<TemplateList> implementedBy;
+ SharedPtr<MemberListContext> sourceRefs;
+ SharedPtr<MemberListContext> sourceRefBys;
ScopedPtr<DotCallGraph> callGraph;
ScopedPtr<DotCallGraph> callerGraph;
- ScopedPtr<MemberContext> anonymousMember;
- QList<MemberContext> implementedByMembers;
- ScopedPtr<TemplateList> reimplementedBy;
- QList<MemberContext> reimplementedByMembers;
- QList<ArgumentListContext> templateArgList;
- ScopedPtr<TemplateList> labels;
+ SharedPtr<MemberContext> anonymousMember;
+ SharedPtr<TemplateList> reimplementedBy;
+ SharedPtr<TemplateList> labels;
TemplateVariant initializer;
bool initializerParsed;
TemplateVariant sourceCode;
bool sourceCodeParsed;
- ScopedPtr<TemplateList> examples;
- QList<TemplateStruct> exampleList;
- ScopedPtr<ArgumentListContext> typeConstraints;
+ SharedPtr<TemplateList> examples;
+ SharedPtr<TemplateList> exampleList;
+ SharedPtr<ArgumentListContext> typeConstraints;
+ SharedPtr<TemplateList> propertyAttrs;
+ SharedPtr<TemplateList> eventAttrs;
};
mutable Cachable m_cache;
- TemplateList m_propertyAttrs;
- TemplateList m_eventAttrs;
};
//%% }
-MemberContext::MemberContext(MemberDef *md)
+MemberContext::MemberContext(MemberDef *md) : RefCountedContext("MemberContext")
{
p = new Private(md);
}
@@ -3660,7 +3770,7 @@ class ModuleContext::Private : public DefinitionContext<ModuleContext::Private>
};
//%% }
-ModuleContext::ModuleContext(GroupDef *gd)
+ModuleContext::ModuleContext(GroupDef *gd) : RefCountedContext("ModuleContext")
{
p = new Private(gd);
}
@@ -3678,11 +3788,11 @@ TemplateVariant ModuleContext::get(const char *n) const
//------------------------------------------------------------------------
//%% list NestedClassList[Class] : list of nested classes
-class NestedClassListContext::Private : public GenericNodeListContext<ClassContext>
+class NestedClassListContext::Private : public GenericNodeListContext
{
};
-NestedClassListContext::NestedClassListContext()
+NestedClassListContext::NestedClassListContext() : RefCountedContext("NestedClassListContext")
{
p = new Private;
}
@@ -3712,18 +3822,18 @@ void NestedClassListContext::append(ClassDef *cd)
{
if (cd)
{
- p->append(new ClassContext(cd));
+ p->append(ClassContext::alloc(cd));
}
}
//------------------------------------------------------------------------
//%% list NestedClassList[Class] : list of nested namespaces
-class NestedNamespaceListContext::Private : public GenericNodeListContext<NamespaceContext>
+class NestedNamespaceListContext::Private : public GenericNodeListContext
{
};
-NestedNamespaceListContext::NestedNamespaceListContext()
+NestedNamespaceListContext::NestedNamespaceListContext() : RefCountedContext("NestedNamespaceListContext")
{
p = new Private;
}
@@ -3753,14 +3863,14 @@ void NestedNamespaceListContext::append(NamespaceDef *cd)
{
if (cd)
{
- p->append(new NamespaceContext(cd));
+ p->append(NamespaceContext::alloc(cd));
}
}
//------------------------------------------------------------------------
//%% list ClassList[Class] : list of classes
-class ClassListContext::Private : public GenericNodeListContext<ClassContext>
+class ClassListContext::Private : public GenericNodeListContext
{
public:
void addClasses(const ClassSDict &classSDict)
@@ -3778,13 +3888,13 @@ class ClassListContext::Private : public GenericNodeListContext<ClassContext>
}
if (cd->isLinkableInProject() && cd->templateMaster()==0)
{
- append(new ClassContext(cd));
+ append(ClassContext::alloc(cd));
}
}
}
};
-ClassListContext::ClassListContext()
+ClassListContext::ClassListContext() : RefCountedContext("ClassListContext")
{
p = new Private;
p->addClasses(*Doxygen::classSDict);
@@ -3819,7 +3929,7 @@ TemplateListIntf::ConstIterator *ClassListContext::createIterator() const
class ClassInheritanceNodeContext::Private : public PropertyMapper
{
public:
- Private(ClassDef *cd) : m_classContext(cd)
+ Private(ClassDef *cd) : m_classDef(cd)
{
//%% bool is_leaf_node: true if this node does not have any children
addProperty("is_leaf_node",this,&Private::isLeafNode);
@@ -3883,15 +3993,24 @@ class ClassInheritanceNodeContext::Private : public PropertyMapper
}
TemplateVariant getClass() const
{
- return TemplateVariant(&m_classContext);
+ if (!m_cache.classContext)
+ {
+ m_cache.classContext.reset(ClassContext::alloc(m_classDef));
+ }
+ return m_cache.classContext.get();
}
private:
- GenericNodeListContext<ClassInheritanceNodeContext> m_children;
- ClassContext m_classContext;
+ ClassDef *m_classDef;
+ GenericNodeListContext m_children;
+ struct Cachable
+ {
+ SharedPtr<ClassContext> classContext;
+ };
+ mutable Cachable m_cache;
};
//%% }
-ClassInheritanceNodeContext::ClassInheritanceNodeContext(ClassDef *cd)
+ClassInheritanceNodeContext::ClassInheritanceNodeContext(ClassDef *cd) : RefCountedContext("ClassInheritanceNodeContext")
{
p = new Private(cd);
}
@@ -3914,8 +4033,7 @@ void ClassInheritanceNodeContext::addChildren(const BaseClassList *bcl,bool hide
//------------------------------------------------------------------------
//%% list ClassInheritance[ClassInheritanceNode]: list of classes
-class ClassInheritanceContext::Private : public
- GenericNodeListContext<ClassInheritanceNodeContext>
+class ClassInheritanceContext::Private : public GenericNodeListContext
{
public:
void addClasses(const ClassSDict &classSDict)
@@ -3942,7 +4060,7 @@ class ClassInheritanceContext::Private : public
if (cd->isVisibleInHierarchy()) // should it be visible
{
// new root level class
- ClassInheritanceNodeContext *tnc = new ClassInheritanceNodeContext(cd);
+ ClassInheritanceNodeContext *tnc = ClassInheritanceNodeContext::alloc(cd);
append(tnc);
bool hasChildren = !cd->visited && classHasVisibleChildren(cd);
if (cd->getLanguage()==SrcLangExt_VHDL && hasChildren)
@@ -3961,7 +4079,7 @@ class ClassInheritanceContext::Private : public
}
};
-ClassInheritanceContext::ClassInheritanceContext()
+ClassInheritanceContext::ClassInheritanceContext() : RefCountedContext("ClassInheritanceContext")
{
p = new Private;
initClassHierarchy(Doxygen::classSDict);
@@ -4005,7 +4123,11 @@ class ClassHierarchyContext::Private : public PropertyMapper
public:
TemplateVariant tree() const
{
- return TemplateVariant(&m_classTree);
+ if (!m_cache.classTree)
+ {
+ m_cache.classTree.reset(ClassInheritanceContext::alloc());
+ }
+ return m_cache.classTree.get();
}
TemplateVariant fileName() const
{
@@ -4046,11 +4168,15 @@ class ClassHierarchyContext::Private : public PropertyMapper
addProperty("title",this,&Private::title);
}
private:
- ClassInheritanceContext m_classTree;
+ struct Cachable
+ {
+ SharedPtr<ClassInheritanceContext> classTree;
+ };
+ mutable Cachable m_cache;
};
//%% }
-ClassHierarchyContext::ClassHierarchyContext()
+ClassHierarchyContext::ClassHierarchyContext() : RefCountedContext("ClassHierarchyContext")
{
p = new Private;
}
@@ -4074,8 +4200,9 @@ class NestingNodeContext::Private : public PropertyMapper
public:
Private(const NestingNodeContext *parent,const NestingNodeContext *thisNode,
Definition *d,int index,int level,bool addCls)
- : m_parent(parent), m_def(d), m_children(thisNode,level+1), m_level(level), m_index(index)
+ : m_parent(parent), m_def(d), m_level(level), m_index(index)
{
+ m_children.reset(NestingContext::alloc(thisNode,level+1));
//%% bool is_leaf_node: true if this node does not have any children
addProperty("is_leaf_node",this,&Private::isLeafNode);
//%% Nesting children: list of nested classes/namespaces
@@ -4085,9 +4212,9 @@ class NestingNodeContext::Private : public PropertyMapper
//%% [optional] Namespace namespace: namespace info (if this node represents a namespace)
addProperty("namespace",this,&Private::getNamespace);
//%% [optional] File file: file info (if this node represents a file)
- addProperty("file",this,&Private::file);
+ addProperty("file",this,&Private::getFile);
//%% [optional] Dir dir: directory info (if this node represents a directory)
- addProperty("dir",this,&Private::dir);
+ addProperty("dir",this,&Private::getDir);
//%% int id
addProperty("id",this,&Private::id);
//%% string level
@@ -4103,20 +4230,21 @@ class NestingNodeContext::Private : public PropertyMapper
addNamespaces(addCls);
addClasses();
+ addDirFiles();
}
TemplateVariant isLeafNode() const
{
- return m_children.count()==0;
+ return m_children->count()==0;
}
TemplateVariant children() const
{
- return TemplateVariant(&m_children);
+ return m_children.get();
}
TemplateVariant getClass() const
{
if (!m_cache.classContext && m_def->definitionType()==Definition::TypeClass)
{
- m_cache.classContext.reset(new ClassContext((ClassDef*)m_def));
+ m_cache.classContext.reset(ClassContext::alloc((ClassDef*)m_def));
}
if (m_cache.classContext)
{
@@ -4131,7 +4259,7 @@ class NestingNodeContext::Private : public PropertyMapper
{
if (!m_cache.namespaceContext && m_def->definitionType()==Definition::TypeNamespace)
{
- m_cache.namespaceContext.reset(new NamespaceContext((NamespaceDef*)m_def));
+ m_cache.namespaceContext.reset(NamespaceContext::alloc((NamespaceDef*)m_def));
}
if (m_cache.namespaceContext)
{
@@ -4142,13 +4270,35 @@ class NestingNodeContext::Private : public PropertyMapper
return TemplateVariant(FALSE);
}
}
- TemplateVariant file() const
+ TemplateVariant getDir() const
{
- return FALSE;
+ if (!m_cache.dirContext && m_def->definitionType()==Definition::TypeDir)
+ {
+ m_cache.dirContext.reset(DirContext::alloc((DirDef*)m_def));
+ }
+ if (m_cache.dirContext)
+ {
+ return m_cache.dirContext.get();
+ }
+ else
+ {
+ return TemplateVariant(FALSE);
+ }
}
- TemplateVariant dir() const
+ TemplateVariant getFile() const
{
- return FALSE;
+ if (!m_cache.fileContext && m_def->definitionType()==Definition::TypeFile)
+ {
+ m_cache.fileContext.reset(FileContext::alloc((FileDef*)m_def));
+ }
+ if (m_cache.fileContext)
+ {
+ return m_cache.fileContext.get();
+ }
+ else
+ {
+ return TemplateVariant(FALSE);
+ }
}
TemplateVariant level() const
{
@@ -4163,7 +4313,7 @@ class NestingNodeContext::Private : public PropertyMapper
}
TemplateVariant name() const
{
- return m_def->name();
+ return m_def->displayName(FALSE);
}
QCString relPathAsString() const
{
@@ -4204,7 +4354,7 @@ class NestingNodeContext::Private : public PropertyMapper
ClassDef *cd = m_def->definitionType()==Definition::TypeClass ? (ClassDef*)m_def : 0;
if (cd && cd->getClassSDict())
{
- m_children.addClasses(*cd->getClassSDict(),FALSE);
+ m_children->addClasses(*cd->getClassSDict(),FALSE);
}
}
void addNamespaces(bool addClasses)
@@ -4212,23 +4362,37 @@ class NestingNodeContext::Private : public PropertyMapper
NamespaceDef *nd = m_def->definitionType()==Definition::TypeNamespace ? (NamespaceDef*)m_def : 0;
if (nd && nd->getNamespaceSDict())
{
- m_children.addNamespaces(*nd->getNamespaceSDict(),FALSE,addClasses);
+ m_children->addNamespaces(*nd->getNamespaceSDict(),FALSE,addClasses);
}
if (addClasses && nd && nd->getClassSDict())
{
- m_children.addClasses(*nd->getClassSDict(),FALSE);
+ m_children->addClasses(*nd->getClassSDict(),FALSE);
+ }
+ }
+ void addDirFiles()
+ {
+ DirDef *dd = m_def->definitionType()==Definition::TypeDir ? (DirDef*)m_def : 0;
+ if (dd)
+ {
+ m_children->addDirs(dd->subDirs());
+ if (dd && dd->getFiles())
+ {
+ m_children->addFiles(*dd->getFiles());
+ }
}
}
private:
const NestingNodeContext *m_parent;
Definition *m_def;
- NestingContext m_children;
+ SharedPtr<NestingContext> m_children;
int m_level;
int m_index;
struct Cachable
{
- ScopedPtr<ClassContext> classContext;
- ScopedPtr<NamespaceContext> namespaceContext;
+ SharedPtr<ClassContext> classContext;
+ SharedPtr<NamespaceContext> namespaceContext;
+ SharedPtr<DirContext> dirContext;
+ SharedPtr<FileContext> fileContext;
ScopedPtr<TemplateVariant> brief;
};
mutable Cachable m_cache;
@@ -4236,7 +4400,7 @@ class NestingNodeContext::Private : public PropertyMapper
//%% }
NestingNodeContext::NestingNodeContext(const NestingNodeContext *parent,
- Definition *d,int index,int level,bool addClass)
+ Definition *d,int index,int level,bool addClass) : RefCountedContext("NestingNodeContext")
{
p = new Private(parent,this,d,index,level,addClass);
}
@@ -4259,7 +4423,7 @@ QCString NestingNodeContext::id() const
//------------------------------------------------------------------------
//%% list Nesting[NestingNode]: namespace and class nesting relations
-class NestingContext::Private : public GenericNodeListContext<NestingNodeContext>
+class NestingContext::Private : public GenericNodeListContext
{
public:
Private(const NestingNodeContext *parent,int level)
@@ -4278,7 +4442,7 @@ class NestingContext::Private : public GenericNodeListContext<NestingNodeContext
bool isLinkable = nd->isLinkableInProject();
if (isLinkable || hasChildren)
{
- NestingNodeContext *nnc = new NestingNodeContext(m_parent,nd,m_index,m_level,addClasses);
+ NestingNodeContext *nnc = NestingNodeContext::alloc(m_parent,nd,m_index,m_level,addClasses);
append(nnc);
m_index++;
}
@@ -4307,20 +4471,71 @@ class NestingContext::Private : public GenericNodeListContext<NestingNodeContext
{
if (classVisibleInIndex(cd) && cd->templateMaster()==0)
{
- NestingNodeContext *nnc = new NestingNodeContext(m_parent,cd,m_index,m_level,TRUE);
+ NestingNodeContext *nnc = NestingNodeContext::alloc(m_parent,cd,m_index,m_level,TRUE);
append(nnc);
m_index++;
}
}
}
}
+ void addDirs(const DirSDict &dirDict)
+ {
+ SDict<DirDef>::Iterator dli(dirDict);
+ DirDef *dd;
+ for (dli.toFirst();(dd=dli.current());++dli)
+ {
+ if (dd->getOuterScope()==Doxygen::globalScope)
+ {
+ append(NestingNodeContext::alloc(m_parent,dd,m_index,m_level,FALSE));
+ m_index++;
+ }
+ }
+ }
+ void addDirs(const DirList &dirList)
+ {
+ QListIterator<DirDef> li(dirList);
+ DirDef *dd;
+ for (li.toFirst();(dd=li.current());++li)
+ {
+ append(NestingNodeContext::alloc(m_parent,dd,m_index,m_level,FALSE));
+ m_index++;
+ }
+ }
+ void addFiles(const FileNameList &fnList)
+ {
+ FileNameListIterator fnli(fnList);
+ FileName *fn;
+ for (fnli.toFirst();(fn=fnli.current());++fnli)
+ {
+ FileNameIterator fni(*fn);
+ FileDef *fd;
+ for (;(fd=fni.current());++fni)
+ {
+ if (fd->getDirDef()==0) // top level file
+ {
+ append(NestingNodeContext::alloc(m_parent,fd,m_index,m_level,FALSE));
+ m_index++;
+ }
+ }
+ }
+ }
+ void addFiles(const FileList &fList)
+ {
+ QListIterator<FileDef> li(fList);
+ FileDef *fd;
+ for (li.toFirst();(fd=li.current());++li)
+ {
+ append(NestingNodeContext::alloc(m_parent,fd,m_index,m_level,FALSE));
+ m_index++;
+ }
+ }
private:
const NestingNodeContext *m_parent;
int m_level;
int m_index;
};
-NestingContext::NestingContext(const NestingNodeContext *parent,int level)
+NestingContext::NestingContext(const NestingNodeContext *parent,int level) : RefCountedContext("NestingContext")
{
p = new Private(parent,level);
}
@@ -4356,6 +4571,27 @@ void NestingContext::addNamespaces(const NamespaceSDict &nsDict,bool rootOnly,bo
p->addNamespaces(nsDict,rootOnly,addClasses);
}
+void NestingContext::addDirs(const DirSDict &dirs)
+{
+ p->addDirs(dirs);
+}
+
+void NestingContext::addDirs(const DirList &dirs)
+{
+ p->addDirs(dirs);
+}
+
+void NestingContext::addFiles(const FileNameList &files)
+{
+ p->addFiles(files);
+}
+
+void NestingContext::addFiles(const FileList &files)
+{
+ p->addFiles(files);
+}
+
+
//------------------------------------------------------------------------
static int computeMaxDepth(const TemplateListIntf *list)
@@ -4398,20 +4634,52 @@ static int computeNumNodesAtLevel(const TemplateStructIntf *s,int level,int maxL
return num;
}
+static int computePreferredDepth(const TemplateListIntf *list,int maxDepth)
+{
+ int preferredNumEntries = Config_getInt("HTML_INDEX_NUM_ENTRIES");
+ int preferredDepth=1;
+ if (preferredNumEntries>0)
+ {
+ int depth = maxDepth;
+ for (int i=1;i<=depth;i++)
+ {
+ int num=0;
+ TemplateListIntf::ConstIterator *it = list->createIterator();
+ TemplateVariant v;
+ for (it->toFirst();it->current(v);it->toNext())
+ {
+ num+=computeNumNodesAtLevel(v.toStruct(),0,i);
+ }
+ delete it;
+ if (num<=preferredNumEntries)
+ {
+ preferredDepth=i;
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+ return preferredDepth;
+}
+
+
//%% struct ClassTree: Class nesting relations
//%% {
class ClassTreeContext::Private : public PropertyMapper
{
public:
- Private() : m_classTree(0,0)
+ Private()
{
+ m_classTree.reset(NestingContext::alloc(0,0));
if (Doxygen::namespaceSDict)
{
- m_classTree.addNamespaces(*Doxygen::namespaceSDict,TRUE,TRUE);
+ m_classTree->addNamespaces(*Doxygen::namespaceSDict,TRUE,TRUE);
}
if (Doxygen::classSDict)
{
- m_classTree.addClasses(*Doxygen::classSDict,TRUE);
+ m_classTree->addClasses(*Doxygen::classSDict,TRUE);
}
//%% Nesting tree
addProperty("tree",this,&Private::tree);
@@ -4425,7 +4693,7 @@ class ClassTreeContext::Private : public PropertyMapper
}
TemplateVariant tree() const
{
- return TemplateVariant(&m_classTree);
+ return m_classTree.get();
}
TemplateVariant fileName() const
{
@@ -4464,7 +4732,7 @@ class ClassTreeContext::Private : public PropertyMapper
{
if (!m_cache.maxDepthComputed)
{
- m_cache.maxDepth = computeMaxDepth(&m_classTree);
+ m_cache.maxDepth = computeMaxDepth(m_classTree.get());
m_cache.maxDepthComputed=TRUE;
}
return m_cache.maxDepth;
@@ -4473,37 +4741,13 @@ class ClassTreeContext::Private : public PropertyMapper
{
if (!m_cache.preferredDepthComputed)
{
- int preferredNumEntries = Config_getInt("HTML_INDEX_NUM_ENTRIES");
- m_cache.preferredDepth=1;
- if (preferredNumEntries>0)
- {
- int depth = maxDepth().toInt();
- for (int i=1;i<=depth;i++)
- {
- int num=0;
- TemplateListIntf::ConstIterator *it = m_classTree.createIterator();
- TemplateVariant v;
- for (it->toFirst();it->current(v);it->toNext())
- {
- num+=computeNumNodesAtLevel(v.toStruct(),0,i);
- }
- delete it;
- if (num<=preferredNumEntries)
- {
- m_cache.preferredDepth=i;
- }
- else
- {
- break;
- }
- }
- }
+ m_cache.preferredDepth = computePreferredDepth(m_classTree.get(),maxDepth().toInt());
m_cache.preferredDepthComputed=TRUE;
}
return m_cache.preferredDepth;
}
private:
- NestingContext m_classTree;
+ SharedPtr<NestingContext> m_classTree;
struct Cachable
{
Cachable() : maxDepthComputed(FALSE), preferredDepthComputed(FALSE) {}
@@ -4516,7 +4760,7 @@ class ClassTreeContext::Private : public PropertyMapper
};
//%% }
-ClassTreeContext::ClassTreeContext()
+ClassTreeContext::ClassTreeContext() : RefCountedContext("ClassTreeContext")
{
p = new Private;
}
@@ -4534,7 +4778,7 @@ TemplateVariant ClassTreeContext::get(const char *name) const
//------------------------------------------------------------------------
//%% list NamespaceList[Namespace] : list of namespaces
-class NamespaceListContext::Private : public GenericNodeListContext<NamespaceContext>
+class NamespaceListContext::Private : public GenericNodeListContext
{
public:
void addNamespaces(const NamespaceSDict &nsDict)
@@ -4545,13 +4789,13 @@ class NamespaceListContext::Private : public GenericNodeListContext<NamespaceCon
{
if (nd->isLinkableInProject())
{
- append(new NamespaceContext(nd));
+ append(NamespaceContext::alloc(nd));
}
}
}
};
-NamespaceListContext::NamespaceListContext()
+NamespaceListContext::NamespaceListContext() : RefCountedContext("NamespaceListContext")
{
p = new Private;
p->addNamespaces(*Doxygen::namespaceSDict);
@@ -4623,11 +4867,12 @@ class NamespaceTreeContext::Private : public PropertyMapper
return theTranslator->trNamespaceList();
}
}
- Private() : m_namespaceTree(0,0)
+ Private()
{
+ m_namespaceTree.reset(NestingContext::alloc(0,0));
if (Doxygen::namespaceSDict)
{
- m_namespaceTree.addNamespaces(*Doxygen::namespaceSDict,TRUE,FALSE);
+ m_namespaceTree->addNamespaces(*Doxygen::namespaceSDict,TRUE,FALSE);
}
//%% Nesting tree
addProperty("tree",this,&Private::tree);
@@ -4638,11 +4883,11 @@ class NamespaceTreeContext::Private : public PropertyMapper
addProperty("title",this,&Private::title);
}
private:
- NestingContext m_namespaceTree;
+ SharedPtr<NestingContext> m_namespaceTree;
};
//%% }
-NamespaceTreeContext::NamespaceTreeContext()
+NamespaceTreeContext::NamespaceTreeContext() : RefCountedContext("NamespaceTreeContext")
{
p = new Private;
}
@@ -4660,7 +4905,7 @@ TemplateVariant NamespaceTreeContext::get(const char *name) const
//------------------------------------------------------------------------
//%% list FileList[File] : list of files
-class FileListContext::Private : public GenericNodeListContext<FileContext>
+class FileListContext::Private : public GenericNodeListContext
{
public:
void addFiles(const FileNameList &fnList)
@@ -4679,14 +4924,14 @@ class FileListContext::Private : public GenericNodeListContext<FileContext>
bool nameOk = !fd->isDocumentationFile();
if (nameOk && (doc || src) && !fd->isReference())
{
- append(new FileContext(fd));
+ append(FileContext::alloc(fd));
}
}
}
}
};
-FileListContext::FileListContext()
+FileListContext::FileListContext() : RefCountedContext("FileListContext")
{
p = new Private;
if (Doxygen::inputNameList) p->addFiles(*Doxygen::inputNameList);
@@ -4715,246 +4960,100 @@ TemplateListIntf::ConstIterator *FileListContext::createIterator() const
//------------------------------------------------------------------------
-//%% list UsedFiles[File] : list of files
-class UsedFilesContext::Private : public GenericNodeListContext<FileContext>
+//%% list DirList[Dir] : list of files
+class DirListContext::Private : public GenericNodeListContext
{
public:
- void addFile(FileDef *fd)
+ Private()
{
- append(new FileContext(fd));
+ DirDef *dir;
+ DirSDict::Iterator sdi(*Doxygen::directories);
+ for (sdi.toFirst();(dir=sdi.current());++sdi)
+ {
+ append(DirContext::alloc(dir));
+ }
}
};
-UsedFilesContext::UsedFilesContext(ClassDef *cd)
+DirListContext::DirListContext() : RefCountedContext("DirListContext")
{
p = new Private;
- if (cd)
- {
- QListIterator<FileDef> li(cd->usedFiles());
- FileDef *fd;
- for (li.toFirst();(fd=li.current());++li)
- {
- p->addFile(fd);
- }
- }
}
-UsedFilesContext::~UsedFilesContext()
+DirListContext::~DirListContext()
{
delete p;
}
// TemplateListIntf
-int UsedFilesContext::count() const
+int DirListContext::count() const
{
return p->count();
}
-TemplateVariant UsedFilesContext::at(int index) const
+TemplateVariant DirListContext::at(int index) const
{
return p->at(index);
}
-TemplateListIntf::ConstIterator *UsedFilesContext::createIterator() const
+TemplateListIntf::ConstIterator *DirListContext::createIterator() const
{
return p->createIterator();
}
-void UsedFilesContext::addFile(FileDef *fd)
-{
- p->addFile(fd);
-}
//------------------------------------------------------------------------
-
-//%% struct DirFileNode: node is a directory hierarchy
-//%% {
-class DirFileNodeContext::Private : public PropertyMapper
+//%% list UsedFiles[File] : list of files
+class UsedFilesContext::Private : public GenericNodeListContext
{
public:
- Private(Definition *d) : m_def(d),
- m_dirContext (m_def->definitionType()==Definition::TypeDir ? (DirDef*)d : 0),
- m_fileContext(m_def->definitionType()==Definition::TypeFile ? (FileDef*)d : 0)
- {
- //%% bool is_leaf_node: true if this node does not have any children
- addProperty("is_leaf_node",this,&Private::isLeafNode);
- //%% DirFile children: list of nested classes/namespaces
- addProperty("children",this,&Private::children);
- //%% [optional] Dir dir: directory info (if this node represents a directory)
- addProperty("dir",this,&Private::getDir);
- //%% [optional] File file: file info (if this node represents a file)
- addProperty("file",this,&Private::getFile);
- addDirFiles();
- }
- TemplateVariant isLeafNode() const
- {
- return m_children.count()==0;
- }
- TemplateVariant children() const
- {
- return TemplateVariant(&m_children);
- }
- TemplateVariant getDir() const
- {
- if (m_def->definitionType()==Definition::TypeDir)
- {
- return TemplateVariant(&m_dirContext);
- }
- else
- {
- return TemplateVariant(FALSE);
- }
- }
- TemplateVariant getFile() const
- {
- if (m_def->definitionType()==Definition::TypeFile)
- {
- return TemplateVariant(&m_fileContext);
- }
- else
- {
- return TemplateVariant(FALSE);
- }
- }
- void addDirFiles()
+ void addFile(FileDef *fd)
{
- DirDef *dd = m_def->definitionType()==Definition::TypeDir ? (DirDef*)m_def : 0;
- if (dd)
- {
- m_children.addDirs(dd->subDirs());
- if (dd && dd->getFiles())
- {
- m_children.addFiles(*dd->getFiles());
- }
- }
+ append(FileContext::alloc(fd));
}
- private:
- Definition *m_def;
- DirFileContext m_children;
- DirContext m_dirContext;
- FileContext m_fileContext;
};
-//%% }
-DirFileNodeContext::DirFileNodeContext(Definition *d)
+UsedFilesContext::UsedFilesContext(ClassDef *cd) : RefCountedContext("UsedFilesContext")
{
- p = new Private(d);
-}
-
-DirFileNodeContext::~DirFileNodeContext()
-{
- delete p;
-}
-
-TemplateVariant DirFileNodeContext::get(const char *n) const
-{
- return p->get(n);
-}
-
-
-//------------------------------------------------------------------------
-
-//%% list DirFile[DirFileNode]: list of directories and/or files
-class DirFileContext::Private : public GenericNodeListContext<DirFileNodeContext>
-{
- public:
- void addDirs(const DirSDict &dirDict)
- {
- SDict<DirDef>::Iterator dli(dirDict);
- DirDef *dd;
- for (dli.toFirst();(dd=dli.current());++dli)
- {
- if (dd->getOuterScope()==Doxygen::globalScope)
- {
- append(new DirFileNodeContext(dd));
- }
- }
- }
- void addDirs(const DirList &dirList)
- {
- QListIterator<DirDef> li(dirList);
- DirDef *dd;
- for (li.toFirst();(dd=li.current());++li)
- {
- append(new DirFileNodeContext(dd));
- }
- }
- void addFiles(const FileNameList &fnList)
- {
- FileNameListIterator fnli(fnList);
- FileName *fn;
- for (fnli.toFirst();(fn=fnli.current());++fnli)
- {
- FileNameIterator fni(*fn);
- FileDef *fd;
- for (;(fd=fni.current());++fni)
- {
- if (fd->getDirDef()==0) // top level file
- {
- append(new DirFileNodeContext(fd));
- }
- }
- }
- }
- void addFiles(const FileList &fList)
+ p = new Private;
+ if (cd)
+ {
+ QListIterator<FileDef> li(cd->usedFiles());
+ FileDef *fd;
+ for (li.toFirst();(fd=li.current());++li)
{
- QListIterator<FileDef> li(fList);
- FileDef *fd;
- for (li.toFirst();(fd=li.current());++li)
- {
- append(new DirFileNodeContext(fd));
- }
+ p->addFile(fd);
}
-};
-
-DirFileContext::DirFileContext()
-{
- p = new Private;
+ }
}
-DirFileContext::~DirFileContext()
+UsedFilesContext::~UsedFilesContext()
{
delete p;
}
// TemplateListIntf
-int DirFileContext::count() const
+int UsedFilesContext::count() const
{
return p->count();
}
-TemplateVariant DirFileContext::at(int index) const
+TemplateVariant UsedFilesContext::at(int index) const
{
return p->at(index);
}
-TemplateListIntf::ConstIterator *DirFileContext::createIterator() const
+TemplateListIntf::ConstIterator *UsedFilesContext::createIterator() const
{
return p->createIterator();
}
-void DirFileContext::addDirs(const DirSDict &dirs)
-{
- p->addDirs(dirs);
-}
-
-void DirFileContext::addDirs(const DirList &dirs)
-{
- p->addDirs(dirs);
-}
-
-void DirFileContext::addFiles(const FileNameList &files)
-{
- p->addFiles(files);
-}
-
-void DirFileContext::addFiles(const FileList &files)
+void UsedFilesContext::addFile(FileDef *fd)
{
- p->addFiles(files);
+ p->addFile(fd);
}
-
//------------------------------------------------------------------------
//%% struct FileTree: tree of directories and files
@@ -4962,6 +5061,28 @@ void DirFileContext::addFiles(const FileList &files)
class FileTreeContext::Private : public PropertyMapper
{
public:
+ Private()
+ {
+ // Add dirs tree
+ m_dirFileTree.reset(NestingContext::alloc(0,0));
+ if (Doxygen::directories)
+ {
+ m_dirFileTree->addDirs(*Doxygen::directories);
+ }
+ if (Doxygen::inputNameList)
+ {
+ m_dirFileTree->addFiles(*Doxygen::inputNameList);
+ }
+ //%% DirFile tree:
+ addProperty("tree",this,&Private::tree);
+ addProperty("fileName",this,&Private::fileName);
+ addProperty("relPath",this,&Private::relPath);
+ addProperty("highlight",this,&Private::highlight);
+ addProperty("subhighlight",this,&Private::subhighlight);
+ addProperty("title",this,&Private::title);
+ addProperty("preferredDepth",this,&Private::preferredDepth);
+ addProperty("maxDepth",this,&Private::maxDepth);
+ }
TemplateVariant tree() const
{
return TemplateVariant(&m_dirFileTree);
@@ -4986,31 +5107,39 @@ class FileTreeContext::Private : public PropertyMapper
{
return theTranslator->trFileList();
}
- Private()
+ TemplateVariant maxDepth() const
{
- // Add dirs tree
- if (Doxygen::directories)
+ if (!m_cache.maxDepthComputed)
{
- m_dirFileTree.addDirs(*Doxygen::directories);
+ m_cache.maxDepth = computeMaxDepth(m_dirFileTree.get());
+ m_cache.maxDepthComputed=TRUE;
}
- if (Doxygen::inputNameList)
+ return m_cache.maxDepth;
+ }
+ TemplateVariant preferredDepth() const
+ {
+ if (!m_cache.preferredDepthComputed)
{
- m_dirFileTree.addFiles(*Doxygen::inputNameList);
+ m_cache.preferredDepth = computePreferredDepth(m_dirFileTree.get(),maxDepth().toInt());
+ m_cache.preferredDepthComputed=TRUE;
}
- //%% DirFile tree:
- addProperty("tree",this,&Private::tree);
- addProperty("fileName",this,&Private::fileName);
- addProperty("relPath",this,&Private::relPath);
- addProperty("highlight",this,&Private::highlight);
- addProperty("subhighlight",this,&Private::subhighlight);
- addProperty("title",this,&Private::title);
+ return m_cache.preferredDepth;
}
private:
- DirFileContext m_dirFileTree;
+ SharedPtr<NestingContext> m_dirFileTree;
+ struct Cachable
+ {
+ Cachable() : maxDepthComputed(FALSE), preferredDepthComputed(FALSE) {}
+ int maxDepth;
+ bool maxDepthComputed;
+ int preferredDepth;
+ bool preferredDepthComputed;
+ };
+ mutable Cachable m_cache;
};
//%% }
-FileTreeContext::FileTreeContext()
+FileTreeContext::FileTreeContext() : RefCountedContext("FileTreeContext")
{
p = new Private;
}
@@ -5032,8 +5161,10 @@ TemplateVariant FileTreeContext::get(const char *name) const
class PageNodeContext::Private : public PropertyMapper
{
public:
- Private(PageDef *pd) : m_pageDef(pd), m_pageContext(pd)
+ Private(PageDef *pd) : m_pageDef(pd)
{
+ m_children.reset(PageNodeListContext::alloc());
+ m_pageContext.reset(PageContext::alloc(pd));
//%% bool is_leaf_node: true if this node does not have any children
addProperty("is_leaf_node",this,&Private::isLeafNode);
//%% PageList children: list of nested classes/namespaces
@@ -5044,31 +5175,31 @@ class PageNodeContext::Private : public PropertyMapper
}
TemplateVariant isLeafNode() const
{
- return m_children.count()==0;
+ return m_children->count()==0;
}
TemplateVariant children() const
{
- return TemplateVariant(&m_children);
+ return m_children.get();
}
TemplateVariant getPage() const
{
- return TemplateVariant(&m_pageContext);
+ return m_pageContext.get();
}
void addPages()
{
if (m_pageDef->getSubPages())
{
- m_children.addPages(*m_pageDef->getSubPages(),FALSE);
+ m_children->addPages(*m_pageDef->getSubPages(),FALSE);
}
}
private:
- PageDef *m_pageDef;
- PageNodeListContext m_children;
- PageContext m_pageContext;
+ PageDef *m_pageDef;
+ SharedPtr<PageNodeListContext> m_children;
+ SharedPtr<PageContext> m_pageContext;
};
//%% }
-PageNodeContext::PageNodeContext(PageDef *pd)
+PageNodeContext::PageNodeContext(PageDef *pd) : RefCountedContext("PageNodeContext")
{
p = new Private(pd);
}
@@ -5086,7 +5217,7 @@ TemplateVariant PageNodeContext::get(const char *n) const
//------------------------------------------------------------------------
//%% list PageList[PageNode]: list of directories and/or files
-class PageNodeListContext::Private : public GenericNodeListContext<PageNodeContext>
+class PageNodeListContext::Private : public GenericNodeListContext
{
public:
void addPages(const PageSDict &pages,bool rootOnly)
@@ -5099,13 +5230,13 @@ class PageNodeListContext::Private : public GenericNodeListContext<PageNodeConte
pd->getOuterScope()==0 ||
pd->getOuterScope()->definitionType()!=Definition::TypePage)
{
- append(new PageNodeContext(pd));
+ append(PageNodeContext::alloc(pd));
}
}
}
};
-PageNodeListContext::PageNodeListContext()
+PageNodeListContext::PageNodeListContext() : RefCountedContext("PageNodeListContext")
{
p = new Private;
}
@@ -5145,7 +5276,7 @@ class PageTreeContext::Private : public PropertyMapper
public:
TemplateVariant tree() const
{
- return TemplateVariant(&m_pageList);
+ return m_pageList.get();
}
TemplateVariant fileName() const
{
@@ -5169,10 +5300,11 @@ class PageTreeContext::Private : public PropertyMapper
}
Private()
{
+ m_pageList.reset(PageNodeListContext::alloc());
// Add pages
if (Doxygen::pageSDict)
{
- m_pageList.addPages(*Doxygen::pageSDict,TRUE);
+ m_pageList->addPages(*Doxygen::pageSDict,TRUE);
}
//%% PageNodeList tree:
@@ -5184,11 +5316,11 @@ class PageTreeContext::Private : public PropertyMapper
addProperty("title",this,&Private::title);
}
private:
- PageNodeListContext m_pageList;
+ SharedPtr<PageNodeListContext> m_pageList;
};
//%% }
-PageTreeContext::PageTreeContext()
+PageTreeContext::PageTreeContext() : RefCountedContext("PageTreeContext")
{
p = new Private;
}
@@ -5212,7 +5344,7 @@ class PageListContext::Private : public PropertyMapper
public:
TemplateVariant items() const
{
- return TemplateVariant(&m_pageList);
+ return m_pageList.get();
}
TemplateVariant fileName() const
{
@@ -5236,6 +5368,7 @@ class PageListContext::Private : public PropertyMapper
}
Private()
{
+ m_pageList.reset(new GenericNodeListContext);
// Add pages
PageSDict::Iterator pdi(*Doxygen::pageSDict);
PageDef *pd=0;
@@ -5243,7 +5376,7 @@ class PageListContext::Private : public PropertyMapper
{
if (!pd->getGroupDef() && !pd->isReference())
{
- m_pageList.append(new PageContext(pd));
+ m_pageList->append(PageContext::alloc(pd));
}
}
@@ -5256,11 +5389,11 @@ class PageListContext::Private : public PropertyMapper
addProperty("title",this,&Private::title);
}
private:
- GenericNodeListContext<PageContext> m_pageList;
+ SharedPtr<GenericNodeListContext> m_pageList;
};
//%% }
-PageListContext::PageListContext()
+PageListContext::PageListContext() : RefCountedContext("PageListContext")
{
p = new Private;
}
@@ -5283,8 +5416,10 @@ TemplateVariant PageListContext::get(const char *name) const
class ModuleNodeContext::Private : public PropertyMapper
{
public:
- Private(GroupDef *gd) : m_groupDef(gd), m_moduleContext(gd)
+ Private(GroupDef *gd) : m_groupDef(gd)
{
+ m_children.reset(ModuleListContext::alloc());
+ m_moduleContext.reset(ModuleContext::alloc(gd));
//%% bool is_leaf_node: true if this node does not have any children
addProperty("is_leaf_node",this,&Private::isLeafNode);
//%% ModuleList children: list of submodules
@@ -5295,31 +5430,31 @@ class ModuleNodeContext::Private : public PropertyMapper
}
TemplateVariant isLeafNode() const
{
- return m_children.count()==0;
+ return m_children->count()==0;
}
TemplateVariant children() const
{
- return TemplateVariant(&m_children);
+ return m_children.get();
}
TemplateVariant getModule() const
{
- return TemplateVariant(&m_moduleContext);
+ return m_moduleContext.get();
}
void addModules()
{
if (m_groupDef->getSubGroups())
{
- m_children.addModules(*m_groupDef->getSubGroups());
+ m_children->addModules(*m_groupDef->getSubGroups());
}
}
private:
- GroupDef *m_groupDef;
- ModuleListContext m_children;
- ModuleContext m_moduleContext;
+ GroupDef *m_groupDef;
+ SharedPtr<ModuleListContext> m_children;
+ SharedPtr<ModuleContext> m_moduleContext;
};
//%% }
-ModuleNodeContext::ModuleNodeContext(GroupDef *gd)
+ModuleNodeContext::ModuleNodeContext(GroupDef *gd) : RefCountedContext("ModuleNodeContext")
{
p = new Private(gd);
}
@@ -5337,7 +5472,7 @@ TemplateVariant ModuleNodeContext::get(const char *n) const
//------------------------------------------------------------------------
//%% list ModuleList[ModuleNode]: list of directories and/or files
-class ModuleListContext::Private : public GenericNodeListContext<ModuleNodeContext>
+class ModuleListContext::Private : public GenericNodeListContext
{
public:
void addModules(const GroupSDict &modules)
@@ -5349,7 +5484,7 @@ class ModuleListContext::Private : public GenericNodeListContext<ModuleNodeConte
{
if (!gd->isASubGroup() && gd->isVisible() && (!gd->isReference() || externalGroups))
{
- append(new ModuleNodeContext(gd));
+ append(ModuleNodeContext::alloc(gd));
}
}
}
@@ -5359,12 +5494,12 @@ class ModuleListContext::Private : public GenericNodeListContext<ModuleNodeConte
GroupDef *gd;
for (gli.toFirst();(gd=gli.current());++gli)
{
- append(new ModuleNodeContext(gd));
+ append(ModuleNodeContext::alloc(gd));
}
}
};
-ModuleListContext::ModuleListContext()
+ModuleListContext::ModuleListContext() : RefCountedContext("ModuleListContext")
{
p = new Private;
}
@@ -5434,10 +5569,11 @@ class ModuleTreeContext::Private : public PropertyMapper
}
Private()
{
+ m_moduleList.reset(ModuleListContext::alloc());
// Add modules
if (Doxygen::groupSDict)
{
- m_moduleList.addModules(*Doxygen::groupSDict);
+ m_moduleList->addModules(*Doxygen::groupSDict);
}
//%% ModuleList tree:
@@ -5449,11 +5585,11 @@ class ModuleTreeContext::Private : public PropertyMapper
addProperty("title",this,&Private::title);
}
private:
- ModuleListContext m_moduleList;
+ SharedPtr<ModuleListContext> m_moduleList;
};
//%% }
-ModuleTreeContext::ModuleTreeContext()
+ModuleTreeContext::ModuleTreeContext() : RefCountedContext("ModuleTreeContext")
{
p = new Private;
}
@@ -5520,7 +5656,7 @@ class NavPathElemContext::Private : public PropertyMapper
};
//%% }
-NavPathElemContext::NavPathElemContext(Definition *def)
+NavPathElemContext::NavPathElemContext(Definition *def) : RefCountedContext("NavPathElemContext")
{
p = new Private(def);
}
@@ -5569,10 +5705,11 @@ class ExampleListContext::Private : public PropertyMapper
}
Private()
{
+ m_pageList.reset(PageNodeListContext::alloc());
// Add pages
if (Doxygen::exampleSDict)
{
- m_pageList.addPages(*Doxygen::exampleSDict,FALSE);
+ m_pageList->addPages(*Doxygen::exampleSDict,FALSE);
}
//%% PageNodeList items:
@@ -5584,11 +5721,11 @@ class ExampleListContext::Private : public PropertyMapper
addProperty("title",this,&Private::title);
}
private:
- PageNodeListContext m_pageList;
+ SharedPtr<PageNodeListContext> m_pageList;
};
//%% }
-ExampleListContext::ExampleListContext()
+ExampleListContext::ExampleListContext() : RefCountedContext("ExampleListContext")
{
p = new Private;
}
@@ -5611,26 +5748,31 @@ TemplateVariant ExampleListContext::get(const char *name) const
class InheritanceNodeContext::Private : public PropertyMapper
{
public:
- Private(ClassDef *cd,const QCString &name) : m_classContext(cd), m_name(name)
+ Private(ClassDef *cd,const QCString &name) : m_classDef(cd), m_name(name)
{
addProperty("class",this,&Private::getClass);
addProperty("name",this,&Private::name);
}
TemplateVariant getClass() const
{
- return &m_classContext;
+ if (!m_classContext)
+ {
+ m_classContext.reset(ClassContext::alloc(m_classDef));
+ }
+ return m_classContext.get();
}
TemplateVariant name() const
{
return m_name;
}
private:
- ClassContext m_classContext;
+ ClassDef *m_classDef;
+ mutable SharedPtr<ClassContext> m_classContext;
QCString m_name;
};
//%% }
-InheritanceNodeContext::InheritanceNodeContext(ClassDef *cd,const QCString &name)
+InheritanceNodeContext::InheritanceNodeContext(ClassDef *cd,const QCString &name) : RefCountedContext("InheritanceNodeContext")
{
p = new Private(cd,name);
}
@@ -5648,16 +5790,16 @@ TemplateVariant InheritanceNodeContext::get(const char *name) const
//------------------------------------------------------------------------
//%% list InheritanceList[InheritanceNode] : list of inherited classes
-class InheritanceListContext::Private : public GenericNodeListContext<InheritanceNodeContext>
+class InheritanceListContext::Private : public GenericNodeListContext
{
public:
void addClass(ClassDef *cd,const QCString &name)
{
- append(new InheritanceNodeContext(cd,name));
+ append(InheritanceNodeContext::alloc(cd,name));
}
};
-InheritanceListContext::InheritanceListContext(const BaseClassList *list, bool baseClasses)
+InheritanceListContext::InheritanceListContext(const BaseClassList *list, bool baseClasses) : RefCountedContext("InheritanceListContext")
{
p = new Private;
if (list)
@@ -5707,21 +5849,21 @@ TemplateListIntf::ConstIterator *InheritanceListContext::createIterator() const
//------------------------------------------------------------------------
//%% list MemberList[Member] : list of inherited classes
-class MemberListContext::Private : public GenericNodeListContext<MemberContext>
+class MemberListContext::Private : public GenericNodeListContext
{
public:
void addMember(MemberDef *md)
{
- append(new MemberContext(md));
+ append(MemberContext::alloc(md));
}
};
-MemberListContext::MemberListContext()
+MemberListContext::MemberListContext() : RefCountedContext("MemberListContext")
{
p = new Private;
}
-MemberListContext::MemberListContext(const MemberList *list)
+MemberListContext::MemberListContext(const MemberList *list) : RefCountedContext("MemberListContext")
{
p = new Private;
if (list)
@@ -5741,7 +5883,7 @@ MemberListContext::MemberListContext(const MemberList *list)
}
}
-MemberListContext::MemberListContext(MemberSDict *list,bool doSort)
+MemberListContext::MemberListContext(MemberSDict *list,bool doSort) : RefCountedContext("MemberListContext")
{
p = new Private;
if (list)
@@ -5827,7 +5969,7 @@ class MemberInfoContext::Private : public PropertyMapper
{
if (!m_member && m_memberInfo->memberDef)
{
- m_member.reset(new MemberContext(m_memberInfo->memberDef));
+ m_member.reset(MemberContext::alloc(m_memberInfo->memberDef));
}
if (m_member)
{
@@ -5840,11 +5982,11 @@ class MemberInfoContext::Private : public PropertyMapper
}
private:
const MemberInfo *m_memberInfo;
- mutable ScopedPtr<MemberContext> m_member;
+ mutable SharedPtr<MemberContext> m_member;
};
//%% }
-MemberInfoContext::MemberInfoContext(const MemberInfo *mi)
+MemberInfoContext::MemberInfoContext(const MemberInfo *mi) : RefCountedContext("MemberInfoContext")
{
p = new Private(mi);
}
@@ -5863,7 +6005,7 @@ TemplateVariant MemberInfoContext::get(const char *name) const
//------------------------------------------------------------------------
//%% list AllMembersList[MemberList] : list of inherited classes
-class AllMembersListContext::Private : public GenericNodeListContext<MemberInfoContext>
+class AllMembersListContext::Private : public GenericNodeListContext
{
public:
Private(const MemberNameInfoSDict *ml)
@@ -5889,7 +6031,7 @@ class AllMembersListContext::Private : public GenericNodeListContext<MemberInfoC
)
)
{
- append(new MemberInfoContext(mi));
+ append(MemberInfoContext::alloc(mi));
}
}
}
@@ -5898,12 +6040,12 @@ class AllMembersListContext::Private : public GenericNodeListContext<MemberInfoC
}
};
-AllMembersListContext::AllMembersListContext()
+AllMembersListContext::AllMembersListContext() : RefCountedContext("AllMembersListContext")
{
p = new Private(0);
}
-AllMembersListContext::AllMembersListContext(const MemberNameInfoSDict *ml)
+AllMembersListContext::AllMembersListContext(const MemberNameInfoSDict *ml) : RefCountedContext("AllMembersListContext")
{
p = new Private(ml);
}
@@ -5939,8 +6081,7 @@ class MemberGroupInfoContext::Private : public PropertyMapper
Private(Definition *def,const QCString &relPath,const MemberGroup *mg) :
m_def(def),
m_relPath(relPath),
- m_memberListContext(mg->members()),
- m_memberGroups(def,relPath,0), m_memberGroup(mg)
+ m_memberGroup(mg)
{
addProperty("members", this,&Private::members);
addProperty("title", this,&Private::groupTitle);
@@ -5952,7 +6093,11 @@ class MemberGroupInfoContext::Private : public PropertyMapper
}
TemplateVariant members() const
{
- return &m_memberListContext;
+ if (!m_cache.memberListContext)
+ {
+ m_cache.memberListContext.reset(MemberListContext::alloc(m_memberGroup->members()));
+ }
+ return m_cache.memberListContext.get();
}
TemplateVariant groupTitle() const
{
@@ -5968,26 +6113,30 @@ class MemberGroupInfoContext::Private : public PropertyMapper
}
TemplateVariant memberGroups() const
{
- return &m_memberGroups;
+ if (!m_cache.memberGroups)
+ {
+ m_cache.memberGroups.reset(MemberGroupListContext::alloc(m_def,m_relPath,0));
+ }
+ return m_cache.memberGroups.get();
}
TemplateVariant docs() const
{
- if (!m_docs)
+ if (!m_cache.docs)
{
QCString docs = m_memberGroup->documentation();
if (!docs.isEmpty())
{
- m_docs.reset(new TemplateVariant(
+ m_cache.docs.reset(new TemplateVariant(
parseDoc(m_def,"[@name docs]",-1, // TODO store file & line
m_relPath,
m_memberGroup->documentation()+"\n",FALSE)));
}
else
{
- m_docs.reset(new TemplateVariant(""));
+ m_cache.docs.reset(new TemplateVariant(""));
}
}
- return *m_docs;
+ return *m_cache.docs;
}
TemplateVariant inherited() const
{
@@ -5996,15 +6145,19 @@ class MemberGroupInfoContext::Private : public PropertyMapper
private:
Definition *m_def;
QCString m_relPath;
- MemberListContext m_memberListContext;
- MemberGroupListContext m_memberGroups;
const MemberGroup *m_memberGroup;
- mutable ScopedPtr<TemplateVariant> m_docs;
+ struct Cachable
+ {
+ SharedPtr<MemberListContext> memberListContext;
+ SharedPtr<MemberGroupListContext> memberGroups;
+ ScopedPtr<TemplateVariant> docs;
+ };
+ mutable Cachable m_cache;
};
//%% }
MemberGroupInfoContext::MemberGroupInfoContext(Definition *def,
- const QCString &relPath,const MemberGroup *mg)
+ const QCString &relPath,const MemberGroup *mg) : RefCountedContext("MemberGroupInfoContext")
{
p = new Private(def,relPath,mg);
}
@@ -6022,21 +6175,21 @@ TemplateVariant MemberGroupInfoContext::get(const char *name) const
//------------------------------------------------------------------------
//%% list MemberGroupList[MemberGroupInfo] : list of member groups
-class MemberGroupListContext::Private : public GenericNodeListContext<MemberGroupInfoContext>
+class MemberGroupListContext::Private : public GenericNodeListContext
{
public:
void addMemberGroup(Definition *def,const QCString &relPath,const MemberGroup *mg)
{
- append(new MemberGroupInfoContext(def,relPath,mg));
+ append(MemberGroupInfoContext::alloc(def,relPath,mg));
}
};
-MemberGroupListContext::MemberGroupListContext()
+MemberGroupListContext::MemberGroupListContext() : RefCountedContext("MemberGroupListContext")
{
p = new Private;
}
-MemberGroupListContext::MemberGroupListContext(Definition *def,const QCString &relPath,const MemberGroupList *list)
+MemberGroupListContext::MemberGroupListContext(Definition *def,const QCString &relPath,const MemberGroupList *list) : RefCountedContext("MemberGroupListContext")
{
p = new Private;
if (list)
@@ -6050,7 +6203,7 @@ MemberGroupListContext::MemberGroupListContext(Definition *def,const QCString &r
}
}
-MemberGroupListContext::MemberGroupListContext(Definition *def,const QCString &relPath,const MemberGroupSDict *dict,bool subGrouping)
+MemberGroupListContext::MemberGroupListContext(Definition *def,const QCString &relPath,const MemberGroupSDict *dict,bool subGrouping) : RefCountedContext("MemberGroupListContext")
{
p = new Private;
if (dict)
@@ -6098,9 +6251,8 @@ class MemberListInfoContext::Private : public PropertyMapper
public:
Private(Definition *def,const QCString &relPath,const MemberList *ml,const QCString &title,const QCString &subtitle) :
m_def(def),
- m_memberListContext(ml),
- m_memberGroups(def,relPath,ml ? ml->getMemberGroupList() : 0),
m_memberList(ml),
+ m_relPath(relPath),
m_title(title),
m_subtitle(subtitle)
{
@@ -6113,7 +6265,11 @@ class MemberListInfoContext::Private : public PropertyMapper
}
TemplateVariant members() const
{
- return &m_memberListContext;
+ if (!m_cache.memberListContext)
+ {
+ m_cache.memberListContext.reset(MemberListContext::alloc(m_memberList));
+ }
+ return m_cache.memberListContext.get();
}
TemplateVariant title() const
{
@@ -6129,20 +6285,24 @@ class MemberListInfoContext::Private : public PropertyMapper
}
TemplateVariant memberGroups() const
{
- return &m_memberGroups;
+ if (!m_cache.memberGroups)
+ {
+ m_cache.memberGroups.reset(MemberGroupListContext::alloc(m_def,m_relPath,m_memberList->getMemberGroupList()));
+ }
+ return m_cache.memberGroups.get();
}
TemplateVariant inherited() const
{
- if (!m_inherited && (m_memberList->listType()&MemberListType_detailedLists)==0 &&
+ if (!m_cache.inherited && (m_memberList->listType()&MemberListType_detailedLists)==0 &&
m_def->definitionType()==Definition::TypeClass)
{
- InheritedMemberInfoListContext *ctx = new InheritedMemberInfoListContext;
+ InheritedMemberInfoListContext *ctx = InheritedMemberInfoListContext::alloc();
ctx->addMemberList((ClassDef*)m_def,m_memberList->listType(),m_title,FALSE);
- m_inherited.reset(ctx);
+ m_cache.inherited.reset(ctx);
}
- if (m_inherited)
+ if (m_cache.inherited)
{
- return m_inherited.get();
+ return m_cache.inherited.get();
}
else
{
@@ -6151,18 +6311,23 @@ class MemberListInfoContext::Private : public PropertyMapper
}
private:
Definition *m_def;
- MemberListContext m_memberListContext;
- MemberGroupListContext m_memberGroups;
const MemberList *m_memberList;
+ QCString m_relPath;
QCString m_title;
QCString m_subtitle;
- mutable ScopedPtr<InheritedMemberInfoListContext> m_inherited;
+ struct Cachable
+ {
+ SharedPtr<MemberListContext> memberListContext;
+ SharedPtr<MemberGroupListContext> memberGroups;
+ SharedPtr<InheritedMemberInfoListContext> inherited;
+ };
+ mutable Cachable m_cache;
};
//%% }
MemberListInfoContext::MemberListInfoContext(
Definition *def,const QCString &relPath,const MemberList *ml,
- const QCString &title,const QCString &subtitle)
+ const QCString &title,const QCString &subtitle) : RefCountedContext("MemberListInfoContext")
{
p = new Private(def,relPath,ml,title,subtitle);
}
@@ -6201,7 +6366,7 @@ class InheritedMemberInfoContext::Private : public PropertyMapper
{
if (!m_classCtx)
{
- m_classCtx.reset(new ClassContext(m_class));
+ m_classCtx.reset(ClassContext::alloc(m_class));
}
return m_classCtx.get();
}
@@ -6213,7 +6378,7 @@ class InheritedMemberInfoContext::Private : public PropertyMapper
{
if (!m_memberListCtx)
{
- m_memberListCtx.reset(new MemberListContext(m_memberList));
+ m_memberListCtx.reset(MemberListContext::alloc(m_memberList));
}
return m_memberListCtx.get();
}
@@ -6224,26 +6389,27 @@ class InheritedMemberInfoContext::Private : public PropertyMapper
}
TemplateVariant inheritedFrom() const
{
- if (m_inheritedFrom.count()==0)
+ if (!m_inheritedFrom)
{
- m_inheritedFrom.append(title());
- m_inheritedFrom.append(getClass());
+ m_inheritedFrom.reset(TemplateList::alloc());
+ m_inheritedFrom->append(title());
+ m_inheritedFrom->append(getClass());
}
- return &m_inheritedFrom;
+ return m_inheritedFrom.get();
}
private:
ClassDef * m_class;
MemberList *m_memberList;
QCString m_title;
- mutable ScopedPtr<ClassContext> m_classCtx;
- mutable ScopedPtr<MemberListContext> m_memberListCtx;
- mutable TemplateList m_inheritedFrom;
+ mutable SharedPtr<ClassContext> m_classCtx;
+ mutable SharedPtr<MemberListContext> m_memberListCtx;
+ mutable SharedPtr<TemplateList> m_inheritedFrom;
};
//%% }
InheritedMemberInfoContext::InheritedMemberInfoContext(ClassDef *cd,MemberList *ml,
- const QCString &title)
+ const QCString &title) : RefCountedContext("InheritedMemberInfoContext")
{
p = new Private(cd,ml,title);
}
@@ -6261,7 +6427,7 @@ TemplateVariant InheritedMemberInfoContext::get(const char *name) const
//------------------------------------------------------------------------
//%% list InheritedMemberList[InheritedMemberInfo] : list of inherited classes
-class InheritedMemberInfoListContext::Private : public GenericNodeListContext<InheritedMemberInfoContext>
+class InheritedMemberInfoListContext::Private : public GenericNodeListContext
{
public:
void addMemberList(ClassDef *inheritedFrom,MemberList *ml,MemberList *combinedList)
@@ -6335,7 +6501,7 @@ class InheritedMemberInfoListContext::Private : public GenericNodeListContext<In
addMemberListIncludingGrouped(inheritedFrom,ml2,combinedList);
addMemberGroupsOfClass(inheritedFrom,cd,lt,combinedList);
if (lt2!=-1) addMemberGroupsOfClass(inheritedFrom,cd,(MemberListType)lt2,combinedList);
- append(new InheritedMemberInfoContext(cd,combinedList,title));
+ append(InheritedMemberInfoContext::alloc(cd,combinedList,title));
}
}
void findInheritedMembers(ClassDef *inheritedFrom,ClassDef *cd,MemberListType lt,
@@ -6374,7 +6540,7 @@ class InheritedMemberInfoListContext::Private : public GenericNodeListContext<In
}
};
-InheritedMemberInfoListContext::InheritedMemberInfoListContext()
+InheritedMemberInfoListContext::InheritedMemberInfoListContext() : RefCountedContext("InheritedMemberInfoListContext")
{
p = new Private;
}
@@ -6492,7 +6658,7 @@ class ArgumentContext::Private : public PropertyMapper
};
//%% }
-ArgumentContext::ArgumentContext(const Argument *al,Definition *def,const QCString &relPath)
+ArgumentContext::ArgumentContext(const Argument *al,Definition *def,const QCString &relPath) : RefCountedContext("ArgumentContext")
{
p = new Private(al,def,relPath);
}
@@ -6510,22 +6676,22 @@ TemplateVariant ArgumentContext::get(const char *name) const
//------------------------------------------------------------------------
//%% list ArgumentList[Argument] : list of inherited classes
-class ArgumentListContext::Private : public GenericNodeListContext<ArgumentContext>
+class ArgumentListContext::Private : public GenericNodeListContext
{
public:
void addArgument(const Argument *arg,Definition *def,const QCString &relPath)
{
- append(new ArgumentContext(arg,def,relPath));
+ append(ArgumentContext::alloc(arg,def,relPath));
}
};
-ArgumentListContext::ArgumentListContext()
+ArgumentListContext::ArgumentListContext() : RefCountedContext("ArgumentListContext")
{
p = new Private;
}
ArgumentListContext::ArgumentListContext(const ArgumentList *list,
- Definition *def,const QCString &relPath)
+ Definition *def,const QCString &relPath) : RefCountedContext("ArgumentListContext")
{
p = new Private;
if (list)
@@ -6642,56 +6808,64 @@ class HtmlSpaceless : public TemplateSpacelessIntf
//------------------------------------------------------------------------
+#if DEBUG_REF
+int RefCountedContext::s_totalCount;
+#endif
+
void generateOutputViaTemplate()
{
+ {
TemplateEngine e;
TemplateContext *ctx = e.createContext();
if (ctx)
{
- DoxygenContext doxygen;
- ConfigContext config;
- TranslateContext tr;
- ClassListContext classList;
- ClassTreeContext classTree;
- ClassHierarchyContext classHierarchy;
- NamespaceListContext namespaceList;
- NamespaceTreeContext namespaceTree;
- FileListContext fileList;
- FileTreeContext fileTree;
- PageTreeContext pageTree;
- PageListContext pageList;
- ModuleTreeContext moduleTree;
- ExampleListContext exampleList;
+ SharedPtr<DoxygenContext> doxygen (DoxygenContext::alloc());
+ SharedPtr<ConfigContext> config (ConfigContext::alloc());
+ SharedPtr<TranslateContext> tr (TranslateContext::alloc());
+ SharedPtr<ClassListContext> classList (ClassListContext::alloc());
+ SharedPtr<ClassTreeContext> classTree (ClassTreeContext::alloc());
+ SharedPtr<ClassHierarchyContext> classHierarchy (ClassHierarchyContext::alloc());
+ SharedPtr<NamespaceListContext> namespaceList (NamespaceListContext::alloc());
+ SharedPtr<NamespaceTreeContext> namespaceTree (NamespaceTreeContext::alloc());
+ SharedPtr<DirListContext> dirList (DirListContext::alloc());
+ SharedPtr<FileListContext> fileList (FileListContext::alloc());
+ SharedPtr<FileTreeContext> fileTree (FileTreeContext::alloc());
+ SharedPtr<PageTreeContext> pageTree (PageTreeContext::alloc());
+ SharedPtr<PageListContext> pageList (PageListContext::alloc());
+ SharedPtr<ModuleTreeContext> moduleTree (ModuleTreeContext::alloc());
+ SharedPtr<ExampleListContext> exampleList (ExampleListContext::alloc());
//%% Doxygen doxygen:
- ctx->set("doxygen",&doxygen);
+ ctx->set("doxygen",doxygen.get());
//%% Translator tr:
- ctx->set("tr",&tr);
+ ctx->set("tr",tr.get());
//%% Config config:
- ctx->set("config",&config);
+ ctx->set("config",config.get());
//%% ClassList classList:
- ctx->set("classList",&classList); // not used for standard HTML
+ ctx->set("classList",classList.get()); // not used for standard HTML
//%% ClassTree classTree:
- ctx->set("classTree",&classTree);
+ ctx->set("classTree",classTree.get());
// classIndex
//%% ClassHierarchy classHierarchy:
- ctx->set("classHierarchy",&classHierarchy);
+ ctx->set("classHierarchy",classHierarchy.get());
//%% NamespaceList namespaceList:
- ctx->set("namespaceList",&namespaceList);
+ ctx->set("namespaceList",namespaceList.get());
//%% NamespaceTree namespaceTree:
- ctx->set("namespaceTree",&namespaceTree);
+ ctx->set("namespaceTree",namespaceTree.get());
//%% FileList fileList:
- ctx->set("fileList",&fileList);
+ ctx->set("fileList",fileList.get());
//%% FileTree fileTree:
- ctx->set("fileTree",&fileTree);
+ ctx->set("fileTree",fileTree.get());
//%% PageList pageList
- ctx->set("pageList",&pageList);
+ ctx->set("pageList",pageList.get());
//%% PageTree pageTree
- ctx->set("pageTree",&pageTree);
+ ctx->set("pageTree",pageTree.get());
//%% ModuleTree moduleTree
- ctx->set("moduleTree",&moduleTree);
+ ctx->set("moduleTree",moduleTree.get());
//%% ExampleList exampleList
- ctx->set("exampleList",&exampleList);
+ ctx->set("exampleList",exampleList.get());
+ //%% DirList dirList
+ ctx->set("dirList",dirList.get());
// render HTML output
Template *tpl = e.loadByName("htmllayout.tpl",1);
@@ -6700,8 +6874,8 @@ void generateOutputViaTemplate()
g_globals.outputFormat = ContextGlobals::Html;
g_globals.dynSectionId = 0;
g_globals.outputDir = Config_getString("HTML_OUTPUT");
- HtmlEscaper esc;
- ctx->setEscapeIntf(&esc);
+ HtmlEscaper htmlEsc;
+ ctx->setEscapeIntf(Config_getString("HTML_FILE_EXTENSION"),&htmlEsc);
HtmlSpaceless spl;
ctx->setSpacelessIntf(&spl);
ctx->setOutputDirectory(g_globals.outputDir);
@@ -6712,5 +6886,10 @@ void generateOutputViaTemplate()
// TODO: render other outputs
}
+ delete ctx;
+ }
+#if DEBUG_REF
+ printf("==== total ref count %d\n",RefCountedContext::s_totalCount);
+#endif
}
diff --git a/src/context.h b/src/context.h
index 589a873..18fa519 100644
--- a/src/context.h
+++ b/src/context.h
@@ -4,6 +4,7 @@
#include "types.h"
#include "template.h"
#include <qlist.h>
+#include <stdio.h>
class Definition;
class ClassDef;
@@ -38,102 +39,190 @@ class MemberGroupList;
//----------------------------------------------------
-class ConfigContext : public TemplateStructIntf
+#define DEBUG_REF 0
+
+/** @brief Helper class to support reference counting */
+#if DEBUG_REF
+class RefCountedContext
{
public:
- ConfigContext();
- ~ConfigContext();
+ RefCountedContext(const char *className) : m_refCount(0)
+ {
+ m_className=className;
+ m_insideRelease = FALSE;
+ }
+ virtual ~RefCountedContext()
+ {
+ if (!m_insideRelease) abort();
+ }
+ int addRef()
+ {
+ ++s_totalCount;
+ printf("%p:%s::addRef()=%d\n",this,m_className.data(),m_refCount);
+ return ++m_refCount;
+ }
+ int release()
+ {
+ --s_totalCount;
+ printf("%p:%s::release()=%d\n",this,m_className.data(),m_refCount-1);
+ int count = --m_refCount;
+ if (count<=0)
+ {
+ m_insideRelease=TRUE;
+ delete this;
+ }
+ return count;
+ }
+ private:
+ int m_refCount;
+ QCString m_className;
+ bool m_insideRelease;
+ public:
+ static int s_totalCount;
+};
+
+#else // release version
+
+class RefCountedContext
+{
+ public:
+ RefCountedContext(const char *) : m_refCount(0) {}
+ virtual ~RefCountedContext() {}
+ int addRef() { return ++m_refCount; }
+ int release()
+ {
+ int count = --m_refCount;
+ if (count<=0)
+ {
+ delete this;
+ }
+ return count;
+ }
+ private:
+ int m_refCount;
+};
+#endif
+
+
+//----------------------------------------------------
+
+class ConfigContext : public RefCountedContext, public TemplateStructIntf
+{
+ public:
+ static ConfigContext *alloc() { return new ConfigContext; }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ ConfigContext();
+ ~ConfigContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class DoxygenContext : public TemplateStructIntf
+class DoxygenContext : public RefCountedContext, public TemplateStructIntf
{
public:
- DoxygenContext();
- ~DoxygenContext();
+ static DoxygenContext *alloc() { return new DoxygenContext; }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ DoxygenContext();
+ ~DoxygenContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class TranslateContext : public TemplateStructIntf
+class TranslateContext : public RefCountedContext, public TemplateStructIntf
{
public:
- TranslateContext();
- ~TranslateContext();
+ static TranslateContext *alloc() { return new TranslateContext; }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ TranslateContext();
+ ~TranslateContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class UsedFilesContext : public TemplateListIntf
+class UsedFilesContext : public RefCountedContext, public TemplateListIntf
{
public:
- UsedFilesContext(ClassDef *cd);
- ~UsedFilesContext();
+ static UsedFilesContext *alloc(ClassDef *cd) { return new UsedFilesContext(cd); }
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
void addFile(FileDef *fd);
private:
+ UsedFilesContext(ClassDef *cd);
+ ~UsedFilesContext();
+
class Private;
Private *p;
};
//----------------------------------------------------
-class IncludeInfoContext : public TemplateStructIntf
+class IncludeInfoContext : public RefCountedContext, public TemplateStructIntf
{
public:
- IncludeInfoContext(const IncludeInfo *,SrcLangExt lang);
- ~IncludeInfoContext();
+ static IncludeInfoContext *alloc(const IncludeInfo *info,SrcLangExt lang)
+ { return new IncludeInfoContext(info,lang); }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ IncludeInfoContext(const IncludeInfo *,SrcLangExt lang);
+ ~IncludeInfoContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class IncludeInfoListContext : public TemplateListIntf
+class IncludeInfoListContext : public RefCountedContext, public TemplateListIntf
{
public:
- IncludeInfoListContext(const QList<IncludeInfo> &list,SrcLangExt lang);
- ~IncludeInfoListContext();
+ static IncludeInfoListContext *alloc(const QList<IncludeInfo> &list,SrcLangExt lang)
+ { return new IncludeInfoListContext(list,lang); }
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ IncludeInfoListContext(const QList<IncludeInfo> &list,SrcLangExt lang);
+ ~IncludeInfoListContext();
class Private;
Private *p;
};
@@ -141,63 +230,75 @@ class IncludeInfoListContext : public TemplateListIntf
//----------------------------------------------------
-class ClassContext : public TemplateStructIntf
+class ClassContext : public RefCountedContext, public TemplateStructIntf
{
public:
- ClassContext(ClassDef *);
- ~ClassContext();
+ static ClassContext *alloc(ClassDef *cd) { return new ClassContext(cd); }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ ClassContext(ClassDef *);
+ ~ClassContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class NamespaceContext : public TemplateStructIntf
+class NamespaceContext : public RefCountedContext, public TemplateStructIntf
{
public:
- NamespaceContext(NamespaceDef *);
- ~NamespaceContext();
+ static NamespaceContext *alloc(NamespaceDef *nd) { return new NamespaceContext(nd); }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ NamespaceContext(NamespaceDef *);
+ ~NamespaceContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class FileContext : public TemplateStructIntf
+class FileContext : public RefCountedContext, public TemplateStructIntf
{
public:
- FileContext(FileDef *);
- ~FileContext();
+ static FileContext *alloc(FileDef *fd) { return new FileContext(fd); }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ FileContext(FileDef *);
+ ~FileContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class DirContext : public TemplateStructIntf
+class DirContext : public RefCountedContext, public TemplateStructIntf
{
public:
- DirContext(DirDef *);
- ~DirContext();
+ static DirContext *alloc(DirDef *dd) { return new DirContext(dd); }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ DirContext(DirDef *);
+ ~DirContext();
class Private;
Private *p;
};
@@ -205,32 +306,38 @@ class DirContext : public TemplateStructIntf
//----------------------------------------------------
-class PageContext : public TemplateStructIntf
+class PageContext : public RefCountedContext, public TemplateStructIntf
{
public:
- PageContext(PageDef *);
- ~PageContext();
+ static PageContext *alloc(PageDef *pd) { return new PageContext(pd); }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ PageContext(PageDef *);
+ ~PageContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class MemberContext : public TemplateStructIntf
+class MemberContext : public RefCountedContext, public TemplateStructIntf
{
public:
- MemberContext(MemberDef *);
- ~MemberContext();
+ static MemberContext *alloc(MemberDef *md) { return new MemberContext(md); }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ MemberContext(MemberDef *);
+ ~MemberContext();
class Private;
Private *p;
};
@@ -238,436 +345,501 @@ class MemberContext : public TemplateStructIntf
//----------------------------------------------------
-class ModuleContext : public TemplateStructIntf
+class ModuleContext : public RefCountedContext, public TemplateStructIntf
{
public:
- ModuleContext(GroupDef *);
- ~ModuleContext();
+ static ModuleContext *alloc(GroupDef *gd) { return new ModuleContext(gd); }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ ModuleContext(GroupDef *);
+ ~ModuleContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class NestedClassListContext : public TemplateListIntf
+class NestedClassListContext : public RefCountedContext, public TemplateListIntf
{
public:
- NestedClassListContext();
- ~NestedClassListContext();
+ static NestedClassListContext *alloc() { return new NestedClassListContext; }
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
void append(ClassDef *cd);
private:
+ NestedClassListContext();
+ ~NestedClassListContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class NestedNamespaceListContext : public TemplateListIntf
+class NestedNamespaceListContext : public RefCountedContext, public TemplateListIntf
{
public:
- NestedNamespaceListContext();
- ~NestedNamespaceListContext();
+ static NestedNamespaceListContext *alloc() { return new NestedNamespaceListContext; }
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
void append(NamespaceDef *cd);
private:
+ NestedNamespaceListContext();
+ ~NestedNamespaceListContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class ClassListContext : public TemplateListIntf
+class ClassListContext : public RefCountedContext, public TemplateListIntf
{
public:
- ClassListContext();
- ~ClassListContext();
+ static ClassListContext *alloc() { return new ClassListContext; }
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ ClassListContext();
+ ~ClassListContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class ClassInheritanceNodeContext : public TemplateStructIntf
+class ClassInheritanceNodeContext : public RefCountedContext, public TemplateStructIntf
{
public:
- ClassInheritanceNodeContext(ClassDef *);
- ~ClassInheritanceNodeContext();
+ static ClassInheritanceNodeContext *alloc(ClassDef *cd)
+ { return new ClassInheritanceNodeContext(cd); }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
void addChildren(const BaseClassList *bcl,bool hideSuper);
+
private:
+ ClassInheritanceNodeContext(ClassDef *);
+ ~ClassInheritanceNodeContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class ClassInheritanceContext : public TemplateListIntf
+class ClassInheritanceContext : public RefCountedContext, public TemplateListIntf
{
public:
- ClassInheritanceContext();
- ~ClassInheritanceContext();
+ static ClassInheritanceContext *alloc() { return new ClassInheritanceContext; }
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ ClassInheritanceContext();
+ ~ClassInheritanceContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class ClassHierarchyContext : public TemplateStructIntf
+class ClassHierarchyContext : public RefCountedContext, public TemplateStructIntf
{
public:
- ClassHierarchyContext();
- ~ClassHierarchyContext();
+ static ClassHierarchyContext *alloc() { return new ClassHierarchyContext; }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ ClassHierarchyContext();
+ ~ClassHierarchyContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class NestingNodeContext : public TemplateStructIntf
+class NestingNodeContext : public RefCountedContext, public TemplateStructIntf
{
public:
- NestingNodeContext(const NestingNodeContext *parent,
- Definition *,int index,int level,bool addClasses);
- ~NestingNodeContext();
+ static NestingNodeContext *alloc(const NestingNodeContext *parent,Definition *def,
+ int index,int level,bool addClasses)
+ { return new NestingNodeContext(parent,def,index,level,addClasses); }
+
QCString id() const;
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ NestingNodeContext(const NestingNodeContext *parent,
+ Definition *,int index,int level,bool addClasses);
+ ~NestingNodeContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class NestingContext : public TemplateListIntf
+class NestingContext : public RefCountedContext, public TemplateListIntf
{
public:
- NestingContext(const NestingNodeContext *parent,int level);
- ~NestingContext();
+ static NestingContext *alloc(const NestingNodeContext *parent,int level)
+ { return new NestingContext(parent,level); }
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
void addNamespaces(const NamespaceSDict &nsDict,bool rootOnly,bool addClasses);
void addClasses(const ClassSDict &clDict,bool rootOnly);
+ void addDirs(const DirSDict &);
+ void addDirs(const DirList &);
+ void addFiles(const FileNameList &);
+ void addFiles(const FileList &);
+
private:
+ NestingContext(const NestingNodeContext *parent,int level);
+ ~NestingContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class ClassTreeContext : public TemplateStructIntf
+class ClassTreeContext : public RefCountedContext, public TemplateStructIntf
{
public:
- ClassTreeContext();
- ~ClassTreeContext();
+ static ClassTreeContext *alloc() { return new ClassTreeContext; }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ ClassTreeContext();
+ ~ClassTreeContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class NamespaceListContext : public TemplateListIntf
+class NamespaceListContext : public RefCountedContext, public TemplateListIntf
{
public:
- NamespaceListContext();
- ~NamespaceListContext();
+ static NamespaceListContext *alloc() { return new NamespaceListContext; }
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ NamespaceListContext();
+ ~NamespaceListContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class NamespaceTreeContext : public TemplateStructIntf
-{
- public:
- NamespaceTreeContext();
- ~NamespaceTreeContext();
-
- // TemplateStructIntf methods
- virtual TemplateVariant get(const char *name) const;
-
- private:
- class Private;
- Private *p;
-};
-
-//----------------------------------------------------
-
-class DirFileNodeContext : public TemplateStructIntf
+class NamespaceTreeContext : public RefCountedContext, public TemplateStructIntf
{
public:
- DirFileNodeContext(Definition *);
- ~DirFileNodeContext();
+ static NamespaceTreeContext *alloc() { return new NamespaceTreeContext; }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ NamespaceTreeContext();
+ ~NamespaceTreeContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class DirFileContext : public TemplateListIntf
+class DirListContext : public RefCountedContext, public TemplateListIntf
{
public:
- DirFileContext();
- ~DirFileContext();
+ static DirListContext *alloc() { return new DirListContext; }
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
- void addDirs(const DirSDict &);
- void addDirs(const DirList &);
- void addFiles(const FileNameList &);
- void addFiles(const FileList &);
private:
+ DirListContext();
+ ~DirListContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class FileListContext : public TemplateListIntf
+class FileListContext : public RefCountedContext, public TemplateListIntf
{
public:
- FileListContext();
- ~FileListContext();
+ static FileListContext *alloc() { return new FileListContext; }
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ FileListContext();
+ ~FileListContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class FileTreeContext : public TemplateStructIntf
+class FileTreeContext : public RefCountedContext, public TemplateStructIntf
{
public:
- FileTreeContext();
- ~FileTreeContext();
+ static FileTreeContext *alloc() { return new FileTreeContext; }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ FileTreeContext();
+ ~FileTreeContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class PageNodeContext : public TemplateStructIntf
+class PageNodeContext : public RefCountedContext, public TemplateStructIntf
{
public:
- PageNodeContext(PageDef *);
- ~PageNodeContext();
+ static PageNodeContext *alloc(PageDef *pd) { return new PageNodeContext(pd); }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ PageNodeContext(PageDef *);
+ ~PageNodeContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class PageNodeListContext : public TemplateListIntf
+class PageNodeListContext : public RefCountedContext, public TemplateListIntf
{
public:
- PageNodeListContext();
- ~PageNodeListContext();
+ static PageNodeListContext *alloc() { return new PageNodeListContext; }
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
void addPages(const PageSDict &,bool rootOnly);
+
private:
+ PageNodeListContext();
+ ~PageNodeListContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class PageListContext : public TemplateStructIntf
+class PageListContext : public RefCountedContext, public TemplateStructIntf
{
public:
- PageListContext();
- ~PageListContext();
+ static PageListContext *alloc() { return new PageListContext; }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ PageListContext();
+ ~PageListContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class PageTreeContext : public TemplateStructIntf
+class PageTreeContext : public RefCountedContext, public TemplateStructIntf
{
public:
- PageTreeContext();
- ~PageTreeContext();
+ static PageTreeContext *alloc() { return new PageTreeContext; }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ PageTreeContext();
+ ~PageTreeContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class ModuleNodeContext : public TemplateStructIntf
+class ModuleNodeContext : public RefCountedContext, public TemplateStructIntf
{
public:
- ModuleNodeContext(GroupDef *);
- ~ModuleNodeContext();
+ static ModuleNodeContext *alloc(GroupDef *gd) { return new ModuleNodeContext(gd); }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ ModuleNodeContext(GroupDef *);
+ ~ModuleNodeContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class ModuleListContext : public TemplateListIntf
+class ModuleListContext : public RefCountedContext, public TemplateListIntf
{
public:
- ModuleListContext();
- ~ModuleListContext();
+ static ModuleListContext *alloc() { return new ModuleListContext(); }
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
void addModules(const GroupSDict &);
void addModules(const GroupList &);
+
private:
+ ModuleListContext();
+ ~ModuleListContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class ModuleTreeContext : public TemplateStructIntf
+class ModuleTreeContext : public RefCountedContext, public TemplateStructIntf
{
public:
- ModuleTreeContext();
- ~ModuleTreeContext();
+ static ModuleTreeContext *alloc() { return new ModuleTreeContext(); }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ ModuleTreeContext();
+ ~ModuleTreeContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class ExampleListContext : public TemplateStructIntf
+class ExampleListContext : public RefCountedContext, public TemplateStructIntf
{
public:
- ExampleListContext();
- ~ExampleListContext();
+ static ExampleListContext *alloc() { return new ExampleListContext(); }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ ExampleListContext();
+ ~ExampleListContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class NavPathElemContext : public TemplateStructIntf
+class NavPathElemContext : public RefCountedContext, public TemplateStructIntf
{
public:
- NavPathElemContext(Definition *def);
- ~NavPathElemContext();
+ static NavPathElemContext *alloc(Definition *def) { return new NavPathElemContext(def); }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ NavPathElemContext(Definition *def);
+ ~NavPathElemContext();
class Private;
Private *p;
};
@@ -675,90 +847,118 @@ class NavPathElemContext : public TemplateStructIntf
//----------------------------------------------------
-class InheritanceNodeContext : public TemplateStructIntf
+class InheritanceNodeContext : public RefCountedContext, public TemplateStructIntf
{
public:
- InheritanceNodeContext(ClassDef *cd,const QCString &name);
- ~InheritanceNodeContext();
+ static InheritanceNodeContext *alloc(ClassDef *cd,const QCString &name)
+ { return new InheritanceNodeContext(cd,name); }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ InheritanceNodeContext(ClassDef *cd,const QCString &name);
+ ~InheritanceNodeContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class InheritanceListContext : public TemplateListIntf
+class InheritanceListContext : public RefCountedContext, public TemplateListIntf
{
public:
- InheritanceListContext(const BaseClassList *list,bool baseClasses);
- ~InheritanceListContext();
+ static InheritanceListContext *alloc(const BaseClassList *list,bool baseClasses)
+ { return new InheritanceListContext(list,baseClasses); }
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ InheritanceListContext(const BaseClassList *list,bool baseClasses);
+ ~InheritanceListContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class MemberListContext : public TemplateListIntf
+class MemberListContext : public RefCountedContext, public TemplateListIntf
{
public:
- MemberListContext();
- MemberListContext(const MemberList *ml);
- MemberListContext(MemberSDict *ml,bool doSort);
- ~MemberListContext();
+ static MemberListContext *alloc()
+ { return new MemberListContext; }
+ static MemberListContext *alloc(const MemberList *ml)
+ { return new MemberListContext(ml); }
+ static MemberListContext *alloc(MemberSDict *ml,bool doSort)
+ { return new MemberListContext(ml,doSort); }
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ MemberListContext();
+ MemberListContext(const MemberList *ml);
+ MemberListContext(MemberSDict *ml,bool doSort);
+ ~MemberListContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class MemberGroupInfoContext : public TemplateStructIntf
+class MemberGroupInfoContext : public RefCountedContext, public TemplateStructIntf
{
public:
- MemberGroupInfoContext(Definition *def,const QCString &relPath,const MemberGroup *mg);
- ~MemberGroupInfoContext();
+ static MemberGroupInfoContext *alloc(Definition *def,const QCString &relPath,const MemberGroup *mg)
+ { return new MemberGroupInfoContext(def,relPath,mg); }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ MemberGroupInfoContext(Definition *def,const QCString &relPath,const MemberGroup *mg);
+ ~MemberGroupInfoContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class MemberGroupListContext : public TemplateListIntf
+class MemberGroupListContext : public RefCountedContext, public TemplateListIntf
{
public:
- MemberGroupListContext();
- MemberGroupListContext(Definition *def,const QCString &relPath,const MemberGroupList *list);
- MemberGroupListContext(Definition *def,const QCString &relPath,const MemberGroupSDict *mgDict,bool subGrouping);
- ~MemberGroupListContext();
+ static MemberGroupListContext *alloc()
+ { return new MemberGroupListContext; }
+ static MemberGroupListContext *alloc(Definition *def,const QCString &relPath,const MemberGroupList *list)
+ { return new MemberGroupListContext(def,relPath,list); }
+ static MemberGroupListContext *alloc(Definition *def,const QCString &relPath,const MemberGroupSDict *dict,bool subGrouping)
+ { return new MemberGroupListContext(def,relPath,dict,subGrouping); }
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ MemberGroupListContext();
+ MemberGroupListContext(Definition *def,const QCString &relPath,const MemberGroupList *list);
+ MemberGroupListContext(Definition *def,const QCString &relPath,const MemberGroupSDict *mgDict,bool subGrouping);
+ ~MemberGroupListContext();
class Private;
Private *p;
};
@@ -766,123 +966,154 @@ class MemberGroupListContext : public TemplateListIntf
//----------------------------------------------------
-class MemberListInfoContext : public TemplateStructIntf
+class MemberListInfoContext : public RefCountedContext, public TemplateStructIntf
{
public:
- MemberListInfoContext(Definition *def,const QCString &relPath,
+ static MemberListInfoContext *alloc(Definition *def,const QCString &relPath,
const MemberList *ml,const QCString &title,
- const QCString &subtitle=QCString());
- ~MemberListInfoContext();
+ const QCString &subtitle=QCString())
+ { return new MemberListInfoContext(def,relPath,ml,title,subtitle); }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ MemberListInfoContext(Definition *def,const QCString &relPath,
+ const MemberList *ml,const QCString &title,
+ const QCString &subtitle=QCString());
+ ~MemberListInfoContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class MemberInfoContext : public TemplateStructIntf
+class MemberInfoContext : public RefCountedContext, public TemplateStructIntf
{
public:
- MemberInfoContext(const MemberInfo *mi);
- ~MemberInfoContext();
+ static MemberInfoContext *alloc(const MemberInfo *mi) { return new MemberInfoContext(mi); }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ MemberInfoContext(const MemberInfo *mi);
+ ~MemberInfoContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class InheritedMemberInfoContext : public TemplateStructIntf
+class InheritedMemberInfoContext : public RefCountedContext, public TemplateStructIntf
{
public:
- InheritedMemberInfoContext(ClassDef *cd,MemberList *ml,const QCString &title);
- ~InheritedMemberInfoContext();
+ static InheritedMemberInfoContext *alloc(ClassDef *cd,MemberList *ml,const QCString &title)
+ { return new InheritedMemberInfoContext(cd,ml,title); }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ InheritedMemberInfoContext(ClassDef *cd,MemberList *ml,const QCString &title);
+ ~InheritedMemberInfoContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class InheritedMemberInfoListContext : public TemplateListIntf
+class InheritedMemberInfoListContext : public RefCountedContext, public TemplateListIntf
{
public:
- InheritedMemberInfoListContext();
+ static InheritedMemberInfoListContext *alloc() { return new InheritedMemberInfoListContext; }
void addMemberList(ClassDef *cd,MemberListType lt,const QCString &title,bool additionalList=TRUE);
- ~InheritedMemberInfoListContext();
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ InheritedMemberInfoListContext();
+ ~InheritedMemberInfoListContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class AllMembersListContext : public TemplateListIntf
+class AllMembersListContext : public RefCountedContext, public TemplateListIntf
{
public:
- AllMembersListContext();
- AllMembersListContext(const MemberNameInfoSDict *ml);
- ~AllMembersListContext();
+ static AllMembersListContext *alloc()
+ { return new AllMembersListContext; }
+ static AllMembersListContext *alloc(const MemberNameInfoSDict *ml)
+ { return new AllMembersListContext(ml); }
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ AllMembersListContext();
+ AllMembersListContext(const MemberNameInfoSDict *ml);
+ ~AllMembersListContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class ArgumentContext : public TemplateStructIntf
+class ArgumentContext : public RefCountedContext, public TemplateStructIntf
{
public:
- ArgumentContext(const Argument *arg,Definition *def,const QCString &relPath);
- ~ArgumentContext();
+ static ArgumentContext *alloc(const Argument *arg,Definition *def,const QCString &relPath)
+ { return new ArgumentContext(arg,def,relPath); }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ ArgumentContext(const Argument *arg,Definition *def,const QCString &relPath);
+ ~ArgumentContext();
class Private;
Private *p;
};
//----------------------------------------------------
-class ArgumentListContext : public TemplateListIntf
+class ArgumentListContext : public RefCountedContext, public TemplateListIntf
{
public:
- ArgumentListContext();
- ArgumentListContext(const ArgumentList *al,Definition *def,const QCString &relPath);
- ~ArgumentListContext();
+ static ArgumentListContext *alloc() { return new ArgumentListContext; }
+ static ArgumentListContext *alloc(const ArgumentList *al,Definition *def,const QCString &relPath)
+ { return new ArgumentListContext(al,def,relPath); }
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
+ virtual int addRef() { return RefCountedContext::addRef(); }
+ virtual int release() { return RefCountedContext::release(); }
private:
+ ArgumentListContext();
+ ArgumentListContext(const ArgumentList *al,Definition *def,const QCString &relPath);
+ ~ArgumentListContext();
class Private;
Private *p;
};
diff --git a/src/dirdef.cpp b/src/dirdef.cpp
index ab4e5c2..284d1ee 100644
--- a/src/dirdef.cpp
+++ b/src/dirdef.cpp
@@ -335,6 +335,12 @@ QCString DirDef::shortTitle() const
return theTranslator->trDirReference(m_shortName);
}
+bool DirDef::hasDetailedDescription() const
+{
+ static bool repeatBrief = Config_getBool("REPEAT_BRIEF");
+ return (!briefDescription().isEmpty() && repeatBrief) || !documentation().isEmpty();
+}
+
void DirDef::writeDocumentation(OutputList &ol)
{
static bool generateTreeView = Config_getBool("GENERATE_TREEVIEW");
diff --git a/src/dirdef.h b/src/dirdef.h
index 6650d45..8f4fbc2 100644
--- a/src/dirdef.h
+++ b/src/dirdef.h
@@ -67,6 +67,7 @@ class DirDef : public Definition
bool isParentOf(DirDef *dir) const;
bool depGraphIsTrivial() const;
QCString shortTitle() const;
+ bool hasDetailedDescription() const;
// generate output
void writeDocumentation(OutputList &ol);
diff --git a/src/filedef.cpp b/src/filedef.cpp
index 04c56de..b6cfb80 100644
--- a/src/filedef.cpp
+++ b/src/filedef.cpp
@@ -172,8 +172,9 @@ void FileDef::findSectionsInDocumentation()
bool FileDef::hasDetailedDescription() const
{
+ static bool repeatBrief = Config_getBool("REPEAT_BRIEF");
static bool sourceBrowser = Config_getBool("SOURCE_BROWSER");
- return ((!briefDescription().isEmpty() && Config_getBool("REPEAT_BRIEF")) ||
+ return ((!briefDescription().isEmpty() && repeatBrief) ||
!documentation().stripWhiteSpace().isEmpty() || // avail empty section
(sourceBrowser && getStartBodyLine()!=-1 && getBodyDef())
);
diff --git a/src/fortranscanner.l b/src/fortranscanner.l
index f34ad21..e083b2d 100644
--- a/src/fortranscanner.l
+++ b/src/fortranscanner.l
@@ -567,7 +567,7 @@ SCOPENAME ({ID}{BS}"::"{BS})*
/*------- type definition -------------------------------------------------------------------------------*/
-<Start,ModuleBody>^{BS}type/[^a-z0-9] {
+<Start,ModuleBody>^{BS}type/[^a-z0-9_] {
if(YY_START == Start)
{
addModule(NULL);
diff --git a/src/ftextstream.cpp b/src/ftextstream.cpp
index f72185f..3038af3 100644
--- a/src/ftextstream.cpp
+++ b/src/ftextstream.cpp
@@ -165,6 +165,7 @@ FTextStream::FTextStream( FILE *fh )
{
m_dev = new QFile;
((QFile *)m_dev)->open( IO_WriteOnly, fh);
+ m_owndev = TRUE;
}
FTextStream::~FTextStream()
diff --git a/src/memberdef.cpp b/src/memberdef.cpp
index 8c5194e..8476568 100644
--- a/src/memberdef.cpp
+++ b/src/memberdef.cpp
@@ -1418,6 +1418,7 @@ void MemberDef::writeDeclaration(OutputList &ol,
if (cd) d=cd; else if (nd) d=nd; else if (fd) d=fd; else d=gd;
_writeTagData(compoundType);
+ _addToSearchIndex();
QCString cname = d->name();
QCString cdname = d->displayName();
@@ -3610,7 +3611,6 @@ void MemberDef::_writeTagData(const DefType compoundType)
}
writeDocAnchorsToTagFile();
Doxygen::tagFile << " </member>" << endl;
- _addToSearchIndex();
}
m_impl->tagDataWritten |= typeMask;
}
@@ -3740,6 +3740,7 @@ void MemberDef::writeEnumDeclaration(OutputList &typeDecl,
if (isLinkableInProject() || hasDocumentedEnumValues())
{
_writeTagData(compoundType);
+ _addToSearchIndex();
writeLink(typeDecl,cd,nd,fd,gd);
}
else
@@ -3788,6 +3789,7 @@ void MemberDef::writeEnumDeclaration(OutputList &typeDecl,
if (fmd->hasDocumentation()) // enum value has docs
{
fmd->_writeTagData(compoundType);
+ fmd->_addToSearchIndex();
fmd->writeLink(typeDecl,cd,nd,fd,gd);
}
else // no docs for this enum value
diff --git a/src/template.cpp b/src/template.cpp
index da4ff6a..16d1c98 100644
--- a/src/template.cpp
+++ b/src/template.cpp
@@ -103,8 +103,8 @@ class TemplateVariant::Private
int intVal;
QCString strVal;
bool boolVal;
- const TemplateStructIntf *strukt;
- const TemplateListIntf *list;
+ TemplateStructIntf *strukt;
+ TemplateListIntf *list;
Delegate delegate;
bool raw;
};
@@ -145,17 +145,20 @@ TemplateVariant::TemplateVariant(const QCString &s,bool raw)
p->raw = raw;
}
-TemplateVariant::TemplateVariant(const TemplateStructIntf *s)
+TemplateVariant::TemplateVariant(TemplateStructIntf *s)
{
p = new Private;
p->type = Struct;
- p->strukt = s; }
+ p->strukt = s;
+ p->strukt->addRef();
+}
-TemplateVariant::TemplateVariant(const TemplateListIntf *l)
+TemplateVariant::TemplateVariant(TemplateListIntf *l)
{
p = new Private;
p->type = List;
p->list = l;
+ p->list->addRef();
}
TemplateVariant::TemplateVariant(const TemplateVariant::Delegate &delegate)
@@ -167,6 +170,8 @@ TemplateVariant::TemplateVariant(const TemplateVariant::Delegate &delegate)
TemplateVariant::~TemplateVariant()
{
+ if (p->type==Struct) p->strukt->release();
+ else if (p->type==List) p->list->release();
delete p;
}
@@ -181,14 +186,20 @@ TemplateVariant::TemplateVariant(const TemplateVariant &v)
case Bool: p->boolVal = v.p->boolVal; break;
case Integer: p->intVal = v.p->intVal; break;
case String: p->strVal = v.p->strVal; break;
- case Struct: p->strukt = v.p->strukt; break;
- case List: p->list = v.p->list; break;
+ case Struct: p->strukt = v.p->strukt; p->strukt->addRef(); break;
+ case List: p->list = v.p->list; p->list->addRef(); break;
case Function: p->delegate= v.p->delegate;break;
}
}
TemplateVariant &TemplateVariant::operator=(const TemplateVariant &v)
{
+ // assignment can change the type of the variable, so we have to be
+ // careful with reference counted content.
+ TemplateStructIntf *tmpStruct = p->type==Struct ? p->strukt : 0;
+ TemplateListIntf *tmpList = p->type==List ? p->list : 0;
+ Type tmpType = p->type;
+
p->type = v.p->type;
p->raw = v.p->raw;
switch (p->type)
@@ -197,10 +208,14 @@ TemplateVariant &TemplateVariant::operator=(const TemplateVariant &v)
case Bool: p->boolVal = v.p->boolVal; break;
case Integer: p->intVal = v.p->intVal; break;
case String: p->strVal = v.p->strVal; break;
- case Struct: p->strukt = v.p->strukt; break;
- case List: p->list = v.p->list; break;
+ case Struct: p->strukt = v.p->strukt; p->strukt->addRef(); break;
+ case List: p->list = v.p->list; p->list->addRef(); break;
case Function: p->delegate= v.p->delegate;break;
}
+
+ // release overwritten reference counted values
+ if (tmpType==Struct && tmpStruct) tmpStruct->release();
+ else if (tmpType==List && tmpList ) tmpList->release();
return *this;
}
@@ -353,9 +368,10 @@ bool TemplateVariant::raw() const
class TemplateStruct::Private
{
public:
- Private() : fields(17)
+ Private() : fields(17), refCount(0)
{ fields.setAutoDelete(TRUE); }
QDict<TemplateVariant> fields;
+ int refCount;
};
TemplateStruct::TemplateStruct()
@@ -368,6 +384,21 @@ TemplateStruct::~TemplateStruct()
delete p;
}
+int TemplateStruct::addRef()
+{
+ return ++p->refCount;
+}
+
+int TemplateStruct::release()
+{
+ int count = --p->refCount;
+ if (count<=0)
+ {
+ delete this;
+ }
+ return count;
+}
+
void TemplateStruct::set(const char *name,const TemplateVariant &v)
{
TemplateVariant *pv = p->fields.find(name);
@@ -387,6 +418,11 @@ TemplateVariant TemplateStruct::get(const char *name) const
return v ? *v : TemplateVariant();
}
+TemplateStruct *TemplateStruct::alloc()
+{
+ return new TemplateStruct;
+}
+
//- Template list implementation ----------------------------------------------
@@ -394,9 +430,10 @@ TemplateVariant TemplateStruct::get(const char *name) const
class TemplateList::Private
{
public:
- Private() : index(-1) {}
+ Private() : index(-1), refCount(0) {}
QValueList<TemplateVariant> elems;
int index;
+ int refCount;
};
@@ -410,6 +447,21 @@ TemplateList::~TemplateList()
delete p;
}
+int TemplateList::addRef()
+{
+ return ++p->refCount;
+}
+
+int TemplateList::release()
+{
+ int count = --p->refCount;
+ if (count<=0)
+ {
+ delete this;
+ }
+ return count;
+}
+
int TemplateList::count() const
{
return p->elems.count();
@@ -492,6 +544,11 @@ TemplateVariant TemplateList::at(int index) const
}
}
+TemplateList *TemplateList::alloc()
+{
+ return new TemplateList;
+}
+
//- Operator types ------------------------------------------------------------
/** @brief Class representing operators that can appear in template expressions */
@@ -584,8 +641,17 @@ class TemplateContextImpl : public TemplateContext
const TemplateVariant *getRef(const QCString &name) const;
void setOutputDirectory(const QCString &dir)
{ m_outputDir = dir; }
- void setEscapeIntf(TemplateEscapeIntf *intf)
- { m_escapeIntf = intf; }
+ void setEscapeIntf(const QCString &ext,TemplateEscapeIntf *intf)
+ {
+ int i=(!ext.isEmpty() && ext.at(0)=='.') ? 1 : 0;
+ m_escapeIntfDict.insert(ext.mid(i),new TemplateEscapeIntf*(intf));
+ }
+ void selectEscapeIntf(const QCString &ext)
+ { TemplateEscapeIntf **ppIntf = m_escapeIntfDict.find(ext);
+ m_activeEscapeIntf = ppIntf ? *ppIntf : 0;
+ }
+ void setActiveEscapeIntf(TemplateEscapeIntf *intf)
+ { m_activeEscapeIntf = intf; }
void setSpacelessIntf(TemplateSpacelessIntf *intf)
{ m_spacelessIntf = intf; }
@@ -597,7 +663,7 @@ class TemplateContextImpl : public TemplateContext
QCString templateName() const { return m_templateName; }
int line() const { return m_line; }
QCString outputDirectory() const { return m_outputDir; }
- TemplateEscapeIntf *escapeIntf() const { return m_escapeIntf; }
+ TemplateEscapeIntf *escapeIntf() const { return m_activeEscapeIntf; }
TemplateSpacelessIntf *spacelessIntf() const { return m_spacelessIntf; }
void enableSpaceless(bool b) { m_spacelessEnabled=b; }
bool spacelessEnabled() const { return m_spacelessEnabled && m_spacelessIntf; }
@@ -610,7 +676,8 @@ class TemplateContextImpl : public TemplateContext
QCString m_outputDir;
QList< QDict<TemplateVariant> > m_contextStack;
TemplateBlockContext m_blockContext;
- TemplateEscapeIntf *m_escapeIntf;
+ QDict<TemplateEscapeIntf*> m_escapeIntfDict;
+ TemplateEscapeIntf *m_activeEscapeIntf;
TemplateSpacelessIntf *m_spacelessIntf;
bool m_spacelessEnabled;
};
@@ -1763,10 +1830,11 @@ class TemplateImpl : public TemplateNode, public Template
TemplateContextImpl::TemplateContextImpl(const TemplateEngine *e)
- : m_engine(e), m_templateName("<unknown>"), m_line(1), m_escapeIntf(0),
+ : m_engine(e), m_templateName("<unknown>"), m_line(1), m_activeEscapeIntf(0),
m_spacelessIntf(0), m_spacelessEnabled(FALSE)
{
m_contextStack.setAutoDelete(TRUE);
+ m_escapeIntfDict.setAutoDelete(TRUE);
push();
}
@@ -2145,14 +2213,14 @@ class TemplateNodeRepeat : public TemplateNodeCreator<TemplateNodeRepeat>
int i, n = v.toInt();
for (i=0;i<n;i++)
{
- TemplateStruct s;
- s.set("counter0", (int)i);
- s.set("counter", (int)(i+1));
- s.set("revcounter", (int)(n-i));
- s.set("revcounter0", (int)(n-i-1));
- s.set("first",i==0);
- s.set("last", i==n-1);
- c->set("repeatloop",&s);
+ TemplateAutoRef<TemplateStruct> s(TemplateStruct::alloc());
+ s->set("counter0", (int)i);
+ s->set("counter", (int)(i+1));
+ s->set("revcounter", (int)(n-i));
+ s->set("revcounter0", (int)(n-i-1));
+ s->set("first",i==0);
+ s->set("last", i==n-1);
+ c->set("repeatloop",s.get());
// render all items for this iteration of the loop
m_repeatNodes.render(ts,c);
}
@@ -2274,15 +2342,15 @@ class TemplateNodeRange : public TemplateNodeCreator<TemplateNodeRange>
while (!done)
{
// set the forloop meta-data variable
- TemplateStruct s;
- s.set("counter0", (int)index);
- s.set("counter", (int)(index+1));
- s.set("revcounter", (int)(l-index));
- s.set("revcounter0", (int)(l-index-1));
- s.set("first",index==0);
- s.set("last", (int)index==l-1);
- s.set("parentloop",parentLoop ? *parentLoop : TemplateVariant());
- c->set("forloop",&s);
+ TemplateAutoRef<TemplateStruct> s(TemplateStruct::alloc());
+ s->set("counter0", (int)index);
+ s->set("counter", (int)(index+1));
+ s->set("revcounter", (int)(l-index));
+ s->set("revcounter0", (int)(l-index-1));
+ s->set("first",index==0);
+ s->set("last", (int)index==l-1);
+ s->set("parentloop",parentLoop ? *parentLoop : TemplateVariant());
+ c->set("forloop",s.get());
// set the iterator variable
c->set(m_var,i);
@@ -2436,15 +2504,15 @@ class TemplateNodeFor : public TemplateNodeCreator<TemplateNodeFor>
(it->current(v));
m_reversed ? it->toPrev() : it->toNext())
{
- TemplateStruct s;
- s.set("counter0", (int)index);
- s.set("counter", (int)(index+1));
- s.set("revcounter", (int)(listSize-index));
- s.set("revcounter0", (int)(listSize-index-1));
- s.set("first",index==0);
- s.set("last", index==listSize-1);
- s.set("parentloop",parentLoop ? *parentLoop : TemplateVariant());
- c->set("forloop",&s);
+ TemplateAutoRef<TemplateStruct> s(TemplateStruct::alloc());
+ s->set("counter0", (int)index);
+ s->set("counter", (int)(index+1));
+ s->set("revcounter", (int)(listSize-index));
+ s->set("revcounter0", (int)(listSize-index-1));
+ s->set("first",index==0);
+ s->set("last", index==listSize-1);
+ s->set("parentloop",parentLoop ? *parentLoop : TemplateVariant());
+ c->set("forloop",s.get());
// add variables for this loop to the context
//obj->addVariableToContext(index,m_vars,c);
@@ -2510,13 +2578,13 @@ class TemplateNodeMsg : public TemplateNodeCreator<TemplateNodeMsg>
TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c);
ci->setLocation(m_templateName,m_line);
TemplateEscapeIntf *escIntf = ci->escapeIntf();
- ci->setEscapeIntf(0); // avoid escaping things we send to standard out
+ ci->setActiveEscapeIntf(0); // avoid escaping things we send to standard out
bool enable = ci->spacelessEnabled();
ci->enableSpaceless(FALSE);
FTextStream ts(stdout);
m_nodes.render(ts,c);
ts << endl;
- ci->setEscapeIntf(escIntf);
+ ci->setActiveEscapeIntf(escIntf);
ci->enableSpaceless(enable);
}
private:
@@ -2571,9 +2639,9 @@ class TemplateNodeBlock : public TemplateNodeCreator<TemplateNodeBlock>
m_nodes.render(ss,c); // render parent of nb to string
}
// add 'block.super' variable to allow access to parent block content
- TemplateStruct superBlock;
- superBlock.set("super",TemplateVariant(super.data(),TRUE));
- ci->set("block",&superBlock);
+ TemplateAutoRef<TemplateStruct> superBlock(TemplateStruct::alloc());
+ superBlock->set("super",TemplateVariant(super.data(),TRUE));
+ ci->set("block",superBlock.get());
// render the overruled block contents
t->engine()->enterBlock(nb->m_templateName,nb->m_blockName,nb->m_line);
nb->m_nodes.render(ts,c);
@@ -2809,6 +2877,12 @@ class TemplateNodeCreate : public TemplateNodeCreator<TemplateNodeCreate>
TemplateImpl *createTemplate = ct ? dynamic_cast<TemplateImpl*>(ct) : 0;
if (createTemplate)
{
+ QCString extension=outputFile;
+ int i=extension.findRev('.');
+ if (i!=-1)
+ {
+ extension=extension.right(extension.length()-i-1);
+ }
if (!ci->outputDirectory().isEmpty())
{
outputFile.prepend(ci->outputDirectory()+"/");
@@ -2816,9 +2890,12 @@ class TemplateNodeCreate : public TemplateNodeCreator<TemplateNodeCreate>
QFile f(outputFile);
if (f.open(IO_WriteOnly))
{
+ TemplateEscapeIntf *escIntf = ci->escapeIntf();
+ ci->selectEscapeIntf(extension);
FTextStream ts(&f);
createTemplate->render(ts,c);
t->engine()->unload(t);
+ ci->setActiveEscapeIntf(escIntf);
}
else
{
@@ -3215,9 +3292,9 @@ class TemplateNodeMarkers : public TemplateNodeCreator<TemplateNodeMarkers>
for (it->toFirst(); (it->current(var)) && i<entryIndex; it->toNext(),i++) {}
if (ok && i==entryIndex) // found element
{
- TemplateStruct s;
- s.set("id",(int)i);
- c->set("markers",&s);
+ TemplateAutoRef<TemplateStruct> s(TemplateStruct::alloc());
+ s->set("id",(int)i);
+ c->set("markers",s.get());
c->set(m_var,var); // define local variable to hold element of list type
bool wasSpaceless = ci->spacelessEnabled();
ci->enableSpaceless(TRUE);
diff --git a/src/template.h b/src/template.h
index 62cea34..c227530 100644
--- a/src/template.h
+++ b/src/template.h
@@ -145,16 +145,14 @@ class TemplateVariant
TemplateVariant(const QCString &s,bool raw=FALSE);
/** Constructs a new variant with a struct value \a s.
- * @note. Only a pointer to the struct is stored. The caller
- * is responsible to manage the memory for the struct object.
+ * @note. The variant will hold a reference to the object.
*/
- TemplateVariant(const TemplateStructIntf *s);
+ TemplateVariant(TemplateStructIntf *s);
/** Constructs a new variant with a list value \a l.
- * @note. Only a pointer to the struct is stored. The caller
- * is responsible to manage the memory for the list object.
+ * @note. The variant will hold a reference to the object.
*/
- TemplateVariant(const TemplateListIntf *l);
+ TemplateVariant(TemplateListIntf *l);
/** Constructs a new variant which represents a method call
* @param[in] delegate Delegate object to invoke when
@@ -223,6 +221,27 @@ class TemplateVariant
//------------------------------------------------------------------------
+template<class T> class TemplateAutoRef
+{
+ public:
+ TemplateAutoRef(T *obj) : m_obj(obj)
+ {
+ m_obj->addRef();
+ }
+ ~TemplateAutoRef()
+ {
+ m_obj->release();
+ }
+ T &operator*() const { return *m_obj; }
+ T *operator->() const { return m_obj; }
+ T *get() const { return m_obj; }
+
+ private:
+ T *m_obj;
+};
+
+//------------------------------------------------------------------------
+
/** @brief Abstract read-only interface for a context value of type list.
* @note The values of the list are TemplateVariants.
*/
@@ -264,26 +283,37 @@ class TemplateListIntf
* @note the user should call delete on the returned pointer.
*/
virtual TemplateListIntf::ConstIterator *createIterator() const = 0;
+
+ /** Increase object's reference count */
+ virtual int addRef() = 0;
+
+ /** Decreases object's referenc count, destroy object if 0 */
+ virtual int release() = 0;
};
/** @brief Default implementation of a context value of type list. */
class TemplateList : public TemplateListIntf
{
public:
- /** Creates a list */
- TemplateList();
- /** Destroys the list */
- ~TemplateList();
-
// TemplateListIntf methods
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
+ virtual int addRef();
+ virtual int release();
+
+ /** Creates an instance with ref count set to 0 */
+ static TemplateList *alloc();
/** Appends element \a v to the end of the list */
virtual void append(const TemplateVariant &v);
private:
+ /** Creates a list */
+ TemplateList();
+ /** Destroys the list */
+ ~TemplateList();
+
friend class TemplateListConstIterator;
class Private;
Private *p;
@@ -302,6 +332,12 @@ class TemplateStructIntf
* @param[in] name The name of the field.
*/
virtual TemplateVariant get(const char *name) const = 0;
+
+ /** Increase object's reference count */
+ virtual int addRef() = 0;
+
+ /** Decreases object's referenc count, destroy object if 0 */
+ virtual int release() = 0;
};
@@ -309,13 +345,13 @@ class TemplateStructIntf
class TemplateStruct : public TemplateStructIntf
{
public:
- /** Creates a struct */
- TemplateStruct();
- /** Destroys the struct */
- virtual ~TemplateStruct();
-
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
+ virtual int addRef();
+ virtual int release();
+
+ /** Creates an instance with ref count set to 0. */
+ static TemplateStruct *alloc();
/** Sets the value the field of a struct
* @param[in] name The name of the field.
@@ -323,7 +359,13 @@ class TemplateStruct : public TemplateStructIntf
*/
virtual void set(const char *name,const TemplateVariant &v);
+
private:
+ /** Creates a struct */
+ TemplateStruct();
+ /** Destroys the struct */
+ virtual ~TemplateStruct();
+
class Private;
Private *p;
};
@@ -399,7 +441,7 @@ class TemplateContext
/** Sets the interface that will be used for escaping the result
* of variable expansion before writing it to the output.
*/
- virtual void setEscapeIntf(TemplateEscapeIntf *intf) = 0;
+ virtual void setEscapeIntf(const QCString &extension, TemplateEscapeIntf *intf) = 0;
/** Sets the interface that will be used inside a spaceless block
* to remove any redundant whitespace.