summaryrefslogtreecommitdiff
path: root/src/perlmodgen.cpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2021-10-15 11:13:31 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2021-10-15 11:13:31 +0900
commit6034e81193d784e8af78fa8ab56438ab1e0d7839 (patch)
tree27f894681430b733eb8711442a4c9312b7cc3535 /src/perlmodgen.cpp
parent3b6ea7abb3d529f7805ed54071d597f01b578740 (diff)
downloaddoxygen-6034e81193d784e8af78fa8ab56438ab1e0d7839.tar.gz
doxygen-6034e81193d784e8af78fa8ab56438ab1e0d7839.tar.bz2
doxygen-6034e81193d784e8af78fa8ab56438ab1e0d7839.zip
Imported Upstream version 1.8.18upstream/1.8.18
Diffstat (limited to 'src/perlmodgen.cpp')
-rw-r--r--src/perlmodgen.cpp208
1 files changed, 114 insertions, 94 deletions
diff --git a/src/perlmodgen.cpp b/src/perlmodgen.cpp
index 4ecee5e..eb566ff 100644
--- a/src/perlmodgen.cpp
+++ b/src/perlmodgen.cpp
@@ -92,7 +92,7 @@ void PerlModOutputStream::add(int n)
if (m_t != 0)
(*m_t) << n;
else
- m_s += n;
+ m_s += QCString().setNum(n);
}
void PerlModOutputStream::add(unsigned int n)
@@ -100,7 +100,7 @@ void PerlModOutputStream::add(unsigned int n)
if (m_t != 0)
(*m_t) << n;
else
- m_s += n;
+ m_s += QCString().setNum(n);
}
class PerlModOutput
@@ -171,10 +171,10 @@ public:
inline PerlModOutput &closeHash() { close('}'); return *this; }
protected:
-
+
void iopenSave();
void icloseSave(QCString &);
-
+
void incIndent();
void decIndent();
@@ -187,7 +187,7 @@ protected:
void iclose(char);
private:
-
+
PerlModOutputStream *m_stream;
int m_indentation;
bool m_blockstart;
@@ -226,7 +226,7 @@ void PerlModOutput::decIndent()
m_spaces[m_indentation * 2] = 0;
}
-void PerlModOutput::iaddQuoted(const char *s)
+void PerlModOutput::iaddQuoted(const char *s)
{
char c;
while ((c = *s++) != 0) {
@@ -235,7 +235,7 @@ void PerlModOutput::iaddQuoted(const char *s)
m_stream->add(c);
}
}
-
+
void PerlModOutput::iaddField(const char *s)
{
continueBlock();
@@ -276,10 +276,10 @@ void PerlModOutput::iopen(char c, const char *s)
void PerlModOutput::iclose(char c)
{
- decIndent();
+ decIndent();
indent();
if (c != 0)
- m_stream->add(c);
+ m_stream->add(c);
m_blockstart = false;
}
@@ -291,11 +291,11 @@ public:
virtual ~PerlModDocVisitor() { }
void finish();
-
+
//--------------------------------------
// visitor functions for leaf nodes
//--------------------------------------
-
+
void visit(DocWord *);
void visit(DocLinkedWord *);
void visit(DocWhiteSpace *);
@@ -317,7 +317,7 @@ public:
//--------------------------------------
// visitor functions for compound nodes
//--------------------------------------
-
+
void visitPre(DocAutoList *);
void visitPost(DocAutoList *);
void visitPre(DocAutoListItem *);
@@ -405,7 +405,7 @@ private:
void addLink(const QCString &ref, const QCString &file,
const QCString &anchor);
-
+
void enterText();
void leaveText();
@@ -653,7 +653,7 @@ void PerlModDocVisitor::visit(DocStyleChange *s)
case DocStyleChange::Preformatted: style = "preformatted"; break;
case DocStyleChange::Div: style = "div"; break;
case DocStyleChange::Span: style = "span"; break;
-
+
}
openItem("style");
m_output.addFieldQuotedString("style", style)
@@ -712,12 +712,12 @@ void PerlModDocVisitor::visit(DocInclude *inc)
{
case DocInclude::IncWithLines:
#if 0
- {
+ {
m_t << "<div class=\"fragment\"><pre>";
QFileInfo cfi( inc->file() );
FileDef fd( cfi.dirPath(), cfi.fileName() );
parseCode(m_ci,inc->context(),inc->text().latin1(),inc->isExample(),inc->exampleFile(), &fd);
- m_t << "</pre></div>";
+ m_t << "</pre></div>";
}
break;
#endif
@@ -733,11 +733,15 @@ void PerlModDocVisitor::visit(DocInclude *inc)
case DocInclude::DontIncWithLines: return;
case DocInclude::HtmlInclude: type = "htmlonly"; break;
case DocInclude::LatexInclude: type = "latexonly"; break;
+ case DocInclude::RtfInclude: type = "rtfonly"; break;
+ case DocInclude::ManInclude: type = "manonly"; break;
+ case DocInclude::XmlInclude: type = "xmlonly"; break;
+ case DocInclude::DocbookInclude: type = "docbookonly"; break;
case DocInclude::VerbInclude: type = "preformatted"; break;
case DocInclude::Snippet: return;
case DocInclude::SnipWithLines: return;
- case DocInclude::SnippetDoc:
- case DocInclude::IncludeDoc:
+ case DocInclude::SnippetDoc:
+ case DocInclude::IncludeDoc:
err("Internal inconsistency: found switch SnippetDoc / IncludeDoc in file: %s"
"Please create a bug report\n",__FILE__);
break;
@@ -760,7 +764,7 @@ void PerlModDocVisitor::visit(DocIncOperator *)
{
parseCode(m_ci,op->context(),op->text(),FALSE,0);
}
- if (op->isLast())
+ if (op->isLast())
{
m_output.add("</programlisting>");
}
@@ -775,7 +779,7 @@ void PerlModDocVisitor::visit(DocFormula *f)
{
openItem("formula");
QCString id;
- id += f->id();
+ id += QCString().setNum(f->id());
m_output.addFieldQuotedString("id", id).addFieldQuotedString("content", f->text());
closeItem();
}
@@ -910,7 +914,7 @@ void PerlModDocVisitor::visitPost(DocTitle *)
closeItem();
}
-void PerlModDocVisitor::visitPre(DocSimpleList *)
+void PerlModDocVisitor::visitPre(DocSimpleList *)
{
openItem("list");
m_output.addFieldQuotedString("style", "itemized");
@@ -1122,7 +1126,7 @@ void PerlModDocVisitor::visitPre(DocImage *)
case DocImage::Rtf: m_output.add("rtf"); break;
}
m_output.add("\"");
-
+
QCString baseName=img->name();
int i;
if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1)
@@ -1480,7 +1484,7 @@ static void addPerlModDocBlock(PerlModOutput &output,
}
}
-static const char *getProtectionName(Protection prot)
+static const char *getProtectionName(Protection prot)
{
switch (prot)
{
@@ -1534,6 +1538,7 @@ public:
inline PerlModGenerator(bool pretty) : m_output(pretty) { }
void generatePerlModForMember(const MemberDef *md, const Definition *);
+ void generatePerlUserDefinedSection(const Definition *d, const MemberGroupSDict *gsd);
void generatePerlModSection(const Definition *d, MemberList *ml,
const char *name, const char *header=0);
void addListOfAllMembers(const ClassDef *cd);
@@ -1542,7 +1547,7 @@ public:
void generatePerlModForFile(const FileDef *fd);
void generatePerlModForGroup(const GroupDef *gd);
void generatePerlModForPage(PageDef *pi);
-
+
bool createOutputFile(QFile &f, const char *s);
bool createOutputDir(QDir &perlModDir);
bool generateDoxyLatexTex();
@@ -1571,7 +1576,7 @@ void PerlModGenerator::generatePerlModForMember(const MemberDef *md,const Defini
// - body code
// - template arguments
// (templateArguments(), definitionTemplateParameterLists())
-
+
QCString memType;
bool isFunc=FALSE;
switch (md->memberType())
@@ -1600,13 +1605,13 @@ void PerlModGenerator::generatePerlModForMember(const MemberDef *md,const Defini
.addFieldQuotedString("virtualness", getVirtualnessName(md->virtualness()))
.addFieldQuotedString("protection", getProtectionName(md->protection()))
.addFieldBoolean("static", md->isStatic());
-
+
addPerlModDocBlock(m_output,"brief",md->getDefFileName(),md->getDefLine(),md->getOuterScope(),md,md->briefDescription());
addPerlModDocBlock(m_output,"detailed",md->getDefFileName(),md->getDefLine(),md->getOuterScope(),md,md->documentation());
if (md->memberType()!=MemberType_Define &&
md->memberType()!=MemberType_Enumeration)
m_output.addFieldQuotedString("type", md->typeString());
-
+
const ArgumentList &al = md->argumentList();
if (isFunc) //function
{
@@ -1645,7 +1650,7 @@ void PerlModGenerator::generatePerlModForMember(const MemberDef *md,const Defini
if (!a.attrib.isEmpty())
m_output.addFieldQuotedString("attributes", a.attrib);
-
+
m_output.closeHash();
}
}
@@ -1663,17 +1668,17 @@ void PerlModGenerator::generatePerlModForMember(const MemberDef *md,const Defini
}
m_output.closeList();
}
- else if (md->argsString()!=0)
+ else if (md->argsString()!=0)
{
m_output.addFieldQuotedString("arguments", md->argsString());
}
if (!md->initializer().isEmpty())
m_output.addFieldQuotedString("initializer", md->initializer());
-
+
if (md->excpString())
m_output.addFieldQuotedString("exceptions", md->excpString());
-
+
if (md->memberType()==MemberType_Enumeration) // enum
{
const MemberList *enumFields = md->enumFieldList();
@@ -1686,7 +1691,7 @@ void PerlModGenerator::generatePerlModForMember(const MemberDef *md,const Defini
{
m_output.openHash()
.addFieldQuotedString("name", emd->name());
-
+
if (!emd->initializer().isEmpty())
m_output.addFieldQuotedString("initializer", emd->initializer());
@@ -1717,7 +1722,7 @@ void PerlModGenerator::generatePerlModForMember(const MemberDef *md,const Defini
.closeHash();
m_output.closeList();
}
-
+
m_output.closeHash();
}
@@ -1730,7 +1735,7 @@ void PerlModGenerator::generatePerlModSection(const Definition *d,
if (header)
m_output.addFieldQuotedString("header", header);
-
+
m_output.openList("members");
MemberListIterator mli(*ml);
const MemberDef *md;
@@ -1756,9 +1761,9 @@ void PerlModGenerator::addListOfAllMembers(const ClassDef *cd)
for (mii.toFirst();(mi=mii.current());++mii)
{
const MemberDef *md=mi->memberDef;
- const ClassDef *cd=md->getClassDef();
+ const ClassDef *mcd=md->getClassDef();
const Definition *d=md->getGroupDef();
- if (d==0) d = cd;
+ if (d==0) d = mcd;
m_output.openHash()
.addFieldQuotedString("name", md->name())
@@ -1768,7 +1773,7 @@ void PerlModGenerator::addListOfAllMembers(const ClassDef *cd)
if (!mi->ambiguityResolutionScope.isEmpty())
m_output.addFieldQuotedString("ambiguity_scope", mi->ambiguityResolutionScope);
- m_output.addFieldQuotedString("scope", cd->name())
+ m_output.addFieldQuotedString("scope", mcd->name())
.closeHash();
}
}
@@ -1776,6 +1781,38 @@ void PerlModGenerator::addListOfAllMembers(const ClassDef *cd)
m_output.closeList();
}
+/* DGA: fix #7490 Perlmod generation issue with multiple grouped functions (member groups) */
+void PerlModGenerator::generatePerlUserDefinedSection(const Definition *d, const MemberGroupSDict *gsd)
+{
+ if (gsd)
+ {
+ MemberGroupSDict::Iterator mgli(*gsd);
+ MemberGroup *mg;
+ m_output.openList("user_defined");
+ for (; (mg = mgli.current()); ++mgli)
+ {
+ m_output.openHash();
+ if (mg->header())
+ m_output.addFieldQuotedString("header", mg->header());
+
+ if (mg->members())
+ {
+ m_output.openList("members");
+ MemberListIterator mli(*mg->members());
+ const MemberDef *md;
+ for (mli.toFirst(); (md = mli.current()); ++mli)
+ {
+ generatePerlModForMember(md, d);
+ }
+ m_output.closeList();
+ }
+ m_output.closeHash();
+ }
+ m_output.closeList();
+ }
+}
+/* DGA: end of fix #7490 */
+
void PerlModGenerator::generatePerlModForClass(const ClassDef *cd)
{
// + brief description
@@ -1800,7 +1837,7 @@ void PerlModGenerator::generatePerlModForClass(const ClassDef *cd)
m_output.openHash()
.addFieldQuotedString("name", cd->name());
-
+
if (cd->baseClasses())
{
m_output.openList("base");
@@ -1834,10 +1871,10 @@ void PerlModGenerator::generatePerlModForClass(const ClassDef *cd)
{
m_output.openList("inner");
ClassSDict::Iterator cli(*cl);
- const ClassDef *cd;
- for (cli.toFirst();(cd=cli.current());++cli)
+ const ClassDef *icd;
+ for (cli.toFirst();(icd=cli.current());++cli)
m_output.openHash()
- .addFieldQuotedString("name", cd->name())
+ .addFieldQuotedString("name", icd->name())
.closeHash();
m_output.closeList();
}
@@ -1862,13 +1899,7 @@ void PerlModGenerator::generatePerlModForClass(const ClassDef *cd)
addTemplateList(cd,m_output);
addListOfAllMembers(cd);
- if (cd->getMemberGroupSDict())
- {
- MemberGroupSDict::Iterator mgli(*cd->getMemberGroupSDict());
- MemberGroup *mg;
- for (;(mg=mgli.current());++mgli)
- generatePerlModSection(cd,mg->members(),"user_defined",mg->header());
- }
+ generatePerlUserDefinedSection(cd, cd->getMemberGroupSDict());
generatePerlModSection(cd,cd->getMemberList(MemberListType_pubTypes),"public_typedefs");
generatePerlModSection(cd,cd->getMemberList(MemberListType_pubMethods),"public_methods");
@@ -1912,12 +1943,12 @@ void PerlModGenerator::generatePerlModForClass(const ClassDef *cd)
collaborationGraph.writePerlMod(t);
t << " </collaborationgraph>" << endl;
}
- t << " <location file=\""
- << cd->getDefFileName() << "\" line=\""
+ t << " <location file=\""
+ << cd->getDefFileName() << "\" line=\""
<< cd->getDefLine() << "\"";
if (cd->getStartBodyLine()!=-1)
{
- t << " bodystart=\"" << cd->getStartBodyLine() << "\" bodyend=\""
+ t << " bodystart=\"" << cd->getStartBodyLine() << "\" bodyend=\""
<< cd->getEndBodyLine() << "\"";
}
t << "/>" << endl;
@@ -1941,7 +1972,7 @@ void PerlModGenerator::generatePerlModForNamespace(const NamespaceDef *nd)
m_output.openHash()
.addFieldQuotedString("name", nd->name());
-
+
ClassSDict *cl = nd->getClassSDict();
if (cl)
{
@@ -1960,21 +1991,15 @@ void PerlModGenerator::generatePerlModForNamespace(const NamespaceDef *nd)
{
m_output.openList("namespaces");
NamespaceSDict::Iterator nli(*nl);
- const NamespaceDef *nd;
- for (nli.toFirst();(nd=nli.current());++nli)
+ const NamespaceDef *ind;
+ for (nli.toFirst();(ind=nli.current());++nli)
m_output.openHash()
- .addFieldQuotedString("name", nd->name())
+ .addFieldQuotedString("name", ind->name())
.closeHash();
m_output.closeList();
}
- if (nd->getMemberGroupSDict())
- {
- MemberGroupSDict::Iterator mgli(*nd->getMemberGroupSDict());
- const MemberGroup *mg;
- for (;(mg=mgli.current());++mgli)
- generatePerlModSection(nd,mg->members(),"user-defined",mg->header());
- }
+ generatePerlUserDefinedSection(nd, nd->getMemberGroupSDict());
generatePerlModSection(nd,nd->getMemberList(MemberListType_decDefineMembers),"defines");
generatePerlModSection(nd,nd->getMemberList(MemberListType_decProtoMembers),"prototypes");
@@ -2004,12 +2029,12 @@ void PerlModGenerator::generatePerlModForFile(const FileDef *fd)
// - source code
// - location
// - number of lines
-
+
if (fd->isReference()) return;
m_output.openHash()
.addFieldQuotedString("name", fd->name());
-
+
IncludeInfo *inc;
m_output.openList("includes");
if (fd->includeFileList())
@@ -2027,7 +2052,7 @@ void PerlModGenerator::generatePerlModForFile(const FileDef *fd)
}
}
m_output.closeList();
-
+
m_output.openList("included_by");
if (fd->includedByFileList())
{
@@ -2044,7 +2069,10 @@ void PerlModGenerator::generatePerlModForFile(const FileDef *fd)
}
}
m_output.closeList();
-
+
+ /* DGA: fix #7494 Perlmod does not generate grouped members from files */
+ generatePerlUserDefinedSection(fd, fd->getMemberGroupSDict());
+
generatePerlModSection(fd,fd->getMemberList(MemberListType_decDefineMembers),"defines");
generatePerlModSection(fd,fd->getMemberList(MemberListType_decProtoMembers),"prototypes");
generatePerlModSection(fd,fd->getMemberList(MemberListType_decTypedefMembers),"typedefs");
@@ -2143,13 +2171,7 @@ void PerlModGenerator::generatePerlModForGroup(const GroupDef *gd)
m_output.closeList();
}
- if (gd->getMemberGroupSDict())
- {
- MemberGroupSDict::Iterator mgli(*gd->getMemberGroupSDict());
- MemberGroup *mg;
- for (;(mg=mgli.current());++mgli)
- generatePerlModSection(gd,mg->members(),"user-defined",mg->header());
- }
+ generatePerlUserDefinedSection(gd, gd->getMemberGroupSDict());
generatePerlModSection(gd,gd->getMemberList(MemberListType_decDefineMembers),"defines");
generatePerlModSection(gd,gd->getMemberList(MemberListType_decProtoMembers),"prototypes");
@@ -2174,10 +2196,10 @@ void PerlModGenerator::generatePerlModForPage(PageDef *pd)
m_output.openHash()
.addFieldQuotedString("name", pd->name());
-
- SectionInfo *si = Doxygen::sectionDict->find(pd->name());
+
+ const SectionInfo *si = SectionManager::instance().find(pd->name());
if (si)
- m_output.addFieldQuotedString("title4", filterTitle(si->title));
+ m_output.addFieldQuotedString("title4", filterTitle(si->title()));
addPerlModDocBlock(m_output,"detailed",pd->docFile(),pd->docLine(),0,0,pd->documentation());
m_output.closeHash();
@@ -2188,12 +2210,12 @@ bool PerlModGenerator::generatePerlModOutput()
QFile outputFile;
if (!createOutputFile(outputFile, pathDoxyDocsPM))
return false;
-
+
FTextStream outputTextStream(&outputFile);
PerlModOutputStream outputStream(&outputTextStream);
m_output.setPerlModOutputStream(&outputStream);
m_output.add("$doxydocs=").openHash();
-
+
m_output.openList("classes");
ClassSDict::Iterator cli(*Doxygen::classSDict);
const ClassDef *cd;
@@ -2209,14 +2231,12 @@ bool PerlModGenerator::generatePerlModOutput()
m_output.closeList();
m_output.openList("files");
- FileNameListIterator fnli(*Doxygen::inputNameList);
- FileName *fn;
- for (;(fn=fnli.current());++fnli)
+ for (const auto &fn : *Doxygen::inputNameLinkedMap)
{
- FileNameIterator fni(*fn);
- const FileDef *fd;
- for (;(fd=fni.current());++fni)
- generatePerlModForFile(fd);
+ for (const auto &fd : *fn)
+ {
+ generatePerlModForFile(fd.get());
+ }
}
m_output.closeList();
@@ -2295,7 +2315,7 @@ bool PerlModGenerator::createOutputDir(QDir &perlModDir)
return false;
}
}
-
+
perlModDir.setPath(outputDirectory+"/perlmod");
if (!perlModDir.exists() && !perlModDir.mkdir(outputDirectory+"/perlmod"))
{
@@ -2312,7 +2332,7 @@ bool PerlModGenerator::generateDoxyStructurePM()
return false;
FTextStream doxyModelPMStream(&doxyModelPM);
- doxyModelPMStream <<
+ doxyModelPMStream <<
"sub memberlist($) {\n"
" my $prefix = $_[0];\n"
" return\n"
@@ -2442,7 +2462,7 @@ bool PerlModGenerator::generateDoxyStructurePM()
"\t\tclasses =>\n"
"\t\t [ \"list\", \"Classes\",\n"
"\t\t [ \"hash\", \"Class\",\n"
- "\t\t {\n"
+ "\t\t {\n"
"\t\t name => [ \"string\", \"Classname\" ]\n"
"\t\t }\n"
"\t\t ],\n"
@@ -2450,7 +2470,7 @@ bool PerlModGenerator::generateDoxyStructurePM()
"\t\tnamespaces =>\n"
"\t\t [ \"list\", \"Namespaces\",\n"
"\t\t [ \"hash\", \"Namespace\",\n"
- "\t\t {\n"
+ "\t\t {\n"
"\t\t name => [ \"string\", \"NamespaceName\" ]\n"
"\t\t }\n"
"\t\t ],\n"
@@ -2620,7 +2640,7 @@ bool PerlModGenerator::generateDoxyLatexStructurePL()
return false;
FTextStream doxyLatexStructurePLStream(&doxyLatexStructurePL);
- doxyLatexStructurePLStream <<
+ doxyLatexStructurePLStream <<
"use DoxyStructure;\n"
"\n"
"sub process($) {\n"
@@ -2654,7 +2674,7 @@ bool PerlModGenerator::generateDoxyLatexPL()
return false;
FTextStream doxyLatexPLStream(&doxyLatexPL);
- doxyLatexPLStream <<
+ doxyLatexPLStream <<
"use DoxyStructure;\n"
"use DoxyDocs;\n"
"\n"
@@ -2777,7 +2797,7 @@ bool PerlModGenerator::generateDoxyFormatTex()
return false;
FTextStream doxyFormatTexStream(&doxyFormatTex);
- doxyFormatTexStream <<
+ doxyFormatTexStream <<
"\\def\\Defcs#1{\\long\\expandafter\\def\\csname#1\\endcsname}\n"
"\\Defcs{Empty}{}\n"
"\\def\\IfEmpty#1{\\expandafter\\ifx\\csname#1\\endcsname\\Empty}\n"
@@ -3023,12 +3043,12 @@ void generatePerlMod()
(global-set-key '(control z) (lambda () (interactive)
(save-excursion
(if (< (mark) (point)) (exchange-point-and-mark))
- (let ((start (point)) (replacers
+ (let ((start (point)) (replacers
'(("\\\\" "\\\\\\\\")
("\"" "\\\\\"")
("\t" "\\\\t")
("^.*$" "\"\\&\\\\n\""))))
- (while replacers
+ (while replacers
(while (re-search-forward (caar replacers) (mark) t)
(replace-match (cadar replacers) t))
(goto-char start)