Skip to content

Commit

Permalink
issue #2732: Adding support for C++ concepts (Origin: bugzilla #499352)
Browse files Browse the repository at this point in the history
  • Loading branch information
doxygen committed Apr 8, 2021
1 parent a9e4a9e commit e03e2a2
Show file tree
Hide file tree
Showing 58 changed files with 2,466 additions and 157 deletions.
10 changes: 10 additions & 0 deletions doc/commands.doc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ documentation:
\refitem cmdcite \\cite
\refitem cmdclass \\class
\refitem cmdcode \\code
\refitem cmdconcept \\concept
\refitem cmdcond \\cond
\refitem cmdcopybrief \\copybrief
\refitem cmdcopydetails \\copydetails
Expand Down Expand Up @@ -456,6 +457,15 @@ Structural indicators
for the corresponding \mbox{\LaTeX} documentation that is generated by doxygen.
\endlatexonly

<hr>
\section cmdconcept \\concept <name>

\addindex \\concept
Indicates that a comment block contains documentation for a
C++20 concept with name \<name\>.
See also the \ref cmdheaderfile "\\headerfile" command to specify the
header a user should be included to use the concept.

<hr>
\section cmddef \\def <name>

Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ add_library(doxymain STATIC
classdef.cpp
classlist.cpp
cmdmapper.cpp
conceptdef.cpp
condparser.cpp
context.cpp
cppvalue.cpp
Expand Down
65 changes: 43 additions & 22 deletions src/classdef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class ClassDefImpl : public DefinitionMixin<ClassDefMutable>
virtual bool isVisibleInHierarchy() const;
virtual bool visibleInParentsDeclList() const;
virtual const ArgumentList &templateArguments() const;
virtual NamespaceDef *getNamespaceDef() const;
//virtual NamespaceDef *getNamespaceDef() const;
virtual FileDef *getFileDef() const;
virtual const MemberDef *getMemberByName(const QCString &) const;
virtual bool isBaseClass(const ClassDef *bcd,bool followInstances,int level=0) const;
Expand Down Expand Up @@ -250,7 +250,7 @@ class ClassDefImpl : public DefinitionMixin<ClassDefMutable>
virtual void insertUsedFile(const FileDef *);
virtual bool addExample(const char *anchor,const char *name, const char *file);
virtual void mergeCategory(ClassDef *category);
virtual void setNamespace(NamespaceDef *nd);
//virtual void setNamespace(NamespaceDef *nd);
virtual void setFileDef(FileDef *fd);
virtual void setSubGrouping(bool enabled);
virtual void setProtection(Protection p);
Expand Down Expand Up @@ -355,6 +355,8 @@ class ClassDefImpl : public DefinitionMixin<ClassDefMutable>
QCString &title,QCString &subtitle) const;
QCString includeStatement() const;
void addTypeConstraint(const QCString &typeConstraint,const QCString &type);
void writeTemplateSpec(OutputList &ol,const Definition *d,
const QCString &type,SrcLangExt lang) const;

// PIMPL idiom
class IMPL;
Expand Down Expand Up @@ -428,8 +430,8 @@ class ClassDefAliasImpl : public DefinitionAliasMixin<ClassDef>
{ return getCdAlias()->visibleInParentsDeclList(); }
virtual const ArgumentList &templateArguments() const
{ return getCdAlias()->templateArguments(); }
virtual NamespaceDef *getNamespaceDef() const
{ return getCdAlias()->getNamespaceDef(); }
//virtual NamespaceDef *getNamespaceDef() const
//{ return getCdAlias()->getNamespaceDef(); }
virtual FileDef *getFileDef() const
{ return getCdAlias()->getFileDef(); }
virtual const MemberDef *getMemberByName(const QCString &s) const
Expand Down Expand Up @@ -551,8 +553,6 @@ class ClassDefAliasImpl : public DefinitionAliasMixin<ClassDef>
virtual void updateSubClasses(const BaseClassList &) {}
};



ClassDef *createClassDefAlias(const Definition *newScope,const ClassDef *cd)
{
ClassDef *acd = new ClassDefAliasImpl(newScope,cd);
Expand Down Expand Up @@ -605,7 +605,7 @@ class ClassDefImpl::IMPL
/*! Namespace this class is part of
* (this is the inner most namespace in case of nested namespaces)
*/
NamespaceDef *nspace = 0;
//NamespaceDef *nspace = 0;

/*! File this class is defined in */
FileDef *fileDef = 0;
Expand Down Expand Up @@ -725,7 +725,7 @@ void ClassDefImpl::IMPL::init(const char *defFileName, const char *name,
fileName=ctStr+name;
}
prot=Public;
nspace=0;
//nspace=0;
fileDef=0;
subGrouping=Config_getBool(SUBGROUPING);
templateMaster =0;
Expand Down Expand Up @@ -1296,23 +1296,29 @@ static void searchTemplateSpecs(/*in*/ const Definition *d,
}
}

static void writeTemplateSpec(OutputList &ol,const Definition *d,
const QCString &type,SrcLangExt lang)
void ClassDefImpl::writeTemplateSpec(OutputList &ol,const Definition *d,
const QCString &type,SrcLangExt lang) const
{
ArgumentLists specs;
QCString name;
searchTemplateSpecs(d,specs,name,lang);
if (!specs.empty()) // class has template scope specifiers
{
ol.startSubsubsection();
ol.startCompoundTemplateParams();
for (const ArgumentList &al : specs)
{
ol.docify("template<");
auto it = al.begin();
while (it!=al.end())
{
Argument a = *it;
ol.docify(a.type);
linkifyText(TextGeneratorOLImpl(ol), // out
d, // scope
getFileDef(), // fileScope
this, // self
a.type, // text
FALSE // autoBreak
);
if (!a.name.isEmpty())
{
ol.docify(" ");
Expand All @@ -1329,9 +1335,20 @@ static void writeTemplateSpec(OutputList &ol,const Definition *d,
ol.docify(">");
ol.lineBreak();
}
if (!m_impl->requiresClause.isEmpty())
{
ol.docify("requires ");
linkifyText(TextGeneratorOLImpl(ol), // out
d, // scope
getFileDef(), // fileScope
this, // self
m_impl->requiresClause, // text
FALSE // autoBreak
);
ol.lineBreak();
}
ol.docify(type.lower()+" "+name);
ol.endSubsubsection();
ol.writeString("\n");
ol.endCompoundTemplateParams();
}
}

Expand Down Expand Up @@ -2557,11 +2574,14 @@ void ClassDefImpl::writeDocumentationContents(OutputList &ol,const QCString & /*
case LayoutDocEntry::NamespaceNestedNamespaces:
case LayoutDocEntry::NamespaceNestedConstantGroups:
case LayoutDocEntry::NamespaceClasses:
case LayoutDocEntry::NamespaceConcepts:
case LayoutDocEntry::NamespaceInterfaces:
case LayoutDocEntry::NamespaceStructs:
case LayoutDocEntry::NamespaceExceptions:
case LayoutDocEntry::NamespaceInlineClasses:
case LayoutDocEntry::ConceptDefinition:
case LayoutDocEntry::FileClasses:
case LayoutDocEntry::FileConcepts:
case LayoutDocEntry::FileInterfaces:
case LayoutDocEntry::FileStructs:
case LayoutDocEntry::FileExceptions:
Expand All @@ -2573,6 +2593,7 @@ void ClassDefImpl::writeDocumentationContents(OutputList &ol,const QCString & /*
case LayoutDocEntry::FileSourceLink:
case LayoutDocEntry::FileInlineClasses:
case LayoutDocEntry::GroupClasses:
case LayoutDocEntry::GroupConcepts:
case LayoutDocEntry::GroupInlineClasses:
case LayoutDocEntry::GroupNamespaces:
case LayoutDocEntry::GroupDirs:
Expand Down Expand Up @@ -4557,10 +4578,10 @@ const ArgumentList &ClassDefImpl::templateArguments() const
return m_impl->tempArgs;
}

NamespaceDef *ClassDefImpl::getNamespaceDef() const
{
return m_impl->nspace;
}
//NamespaceDef *ClassDefImpl::getNamespaceDef() const
//{
// return m_impl->nspace;
//}

FileDef *ClassDefImpl::getFileDef() const
{
Expand Down Expand Up @@ -4667,10 +4688,10 @@ const MemberGroupList &ClassDefImpl::getMemberGroups() const
return m_impl->memberGroups;
}

void ClassDefImpl::setNamespace(NamespaceDef *nd)
{
m_impl->nspace = nd;
}
//void ClassDefImpl::setNamespace(NamespaceDef *nd)
//{
// m_impl->nspace = nd;
//}

void ClassDefImpl::setFileDef(FileDef *fd)
{
Expand Down
4 changes: 2 additions & 2 deletions src/classdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class ClassDef : public Definition
/** Returns the namespace this compound is in, or 0 if it has a global
* scope.
*/
virtual NamespaceDef *getNamespaceDef() const = 0;
//virtual NamespaceDef *getNamespaceDef() const = 0;

/** Returns the file in which this compound's definition can be found.
* Should not return 0 (but it might be a good idea to check anyway).
Expand Down Expand Up @@ -389,7 +389,7 @@ class ClassDefMutable : public DefinitionMutable, public ClassDef
//-----------------------------------------------------------------------------------

virtual void setIncludeFile(FileDef *fd,const char *incName,bool local,bool force) = 0;
virtual void setNamespace(NamespaceDef *nd) = 0;
//virtual void setNamespace(NamespaceDef *nd) = 0;
virtual void setFileDef(FileDef *fd) = 0;
virtual void setSubGrouping(bool enabled) = 0;
virtual void setProtection(Protection p) = 0;
Expand Down
Loading

0 comments on commit e03e2a2

Please sign in to comment.