Skip to content

Commit 61b1efe

Browse files
committed
Parameter names were shown at wrong place for function pointer types
1 parent dba1577 commit 61b1efe

File tree

12 files changed

+127
-93
lines changed

12 files changed

+127
-93
lines changed

src/docbookgen.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,15 +1061,26 @@ DB_GEN_C
10611061
m_t << " ";
10621062
}
10631063

1064-
void DocbookGenerator::endParameterName(bool last,bool /*emptyList*/,bool closeBracket)
1064+
void DocbookGenerator::endParameterName()
10651065
{
10661066
DB_GEN_C
1067-
if (last)
1067+
}
1068+
1069+
void DocbookGenerator::startParameterExtra()
1070+
{
1071+
DB_GEN_C
1072+
}
1073+
1074+
void DocbookGenerator::endParameterExtra(bool last,bool /*emptyList*/,bool closeBracket)
1075+
{
1076+
DB_GEN_C
1077+
if (last && closeBracket)
10681078
{
1069-
if (closeBracket) m_t << ")";
1079+
m_t << ")";
10701080
}
10711081
}
10721082

1083+
10731084
void DocbookGenerator::startParameterDefVal(const char *sep)
10741085
{
10751086
DB_GEN_C

src/docbookgen.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,9 @@ class DocbookGenerator : public OutputGenerator
267267
void startParameterType(bool,const QCString &){DB_GEN_EMPTY};
268268
void endParameterType(){DB_GEN_EMPTY};
269269
void startParameterName(bool);
270-
void endParameterName(bool,bool,bool);
270+
void endParameterName();
271+
void startParameterExtra();
272+
void endParameterExtra(bool,bool,bool);
271273
void startParameterDefVal(const char *sep);
272274
void endParameterDefVal();
273275
void startParameterList(bool);

src/htmlgen.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,13 +2306,23 @@ void HtmlGenerator::endParameterType()
23062306
void HtmlGenerator::startParameterName(bool /*oneArgOnly*/)
23072307
{
23082308
DBG_HTML(m_t << "<!-- startParameterName -->\n";)
2309-
m_t << " <td class=\"paramname\"><span class=\"paramname\">";
2309+
m_t << " <td class=\"paramname\"><span class=\"paramname\"><em>";
23102310
}
23112311

2312-
void HtmlGenerator::endParameterName(bool last,bool emptyList,bool closeBracket)
2312+
void HtmlGenerator::endParameterName()
23132313
{
23142314
DBG_HTML(m_t << "<!-- endParameterName -->\n";)
2315-
m_t << "</span>";
2315+
m_t << "</em></span>";
2316+
}
2317+
2318+
void HtmlGenerator::startParameterExtra()
2319+
{
2320+
DBG_HTML(m_t << "<!-- startParameterExtra -->\n";)
2321+
}
2322+
2323+
void HtmlGenerator::endParameterExtra(bool last,bool emptyList, bool closeBracket)
2324+
{
2325+
DBG_HTML(m_t << "<!-- endParameterExtra -->\n";)
23162326
if (last)
23172327
{
23182328
if (emptyList)

src/htmlgen.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,9 @@ class HtmlGenerator : public OutputGenerator
269269
void startParameterType(bool first,const QCString &key);
270270
void endParameterType();
271271
void startParameterName(bool);
272-
void endParameterName(bool last,bool emptyList,bool closeBracket);
272+
void endParameterName();
273+
void startParameterExtra();
274+
void endParameterExtra(bool last,bool emptyList,bool closeBracket);
273275
void startParameterDefVal(const char *sep);
274276
void endParameterDefVal();
275277
void startParameterList(bool);

src/latexgen.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,9 +2001,19 @@ void LatexGenerator::startParameterName(bool /*oneArgOnly*/)
20012001
m_t << "{";
20022002
}
20032003

2004-
void LatexGenerator::endParameterName(bool last,bool /*emptyList*/,bool closeBracket)
2004+
void LatexGenerator::endParameterName()
20052005
{
2006-
m_t << " }";
2006+
m_t << "}";
2007+
}
2008+
2009+
void LatexGenerator::startParameterExtra()
2010+
{
2011+
m_t << "{";
2012+
}
2013+
2014+
void LatexGenerator::endParameterExtra(bool last,bool /*emptyList*/,bool closeBracket)
2015+
{
2016+
m_t << "}";
20072017
if (last)
20082018
{
20092019
m_t << "\\end{DoxyParamCaption}";

src/latexgen.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,9 @@ class LatexGenerator : public OutputGenerator
262262
void startParameterType(bool,const QCString &);
263263
void endParameterType();
264264
void startParameterName(bool);
265-
void endParameterName(bool,bool,bool);
265+
void endParameterName();
266+
void startParameterExtra();
267+
void endParameterExtra(bool last,bool one,bool bracket);
266268
void startParameterDefVal(const char *s) { docify(s); startTypewriter(); }
267269
void endParameterDefVal() { endTypewriter(); }
268270
void startParameterList(bool);

src/mangen.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,9 @@ class ManGenerator : public OutputGenerator
232232
void startParameterType(bool,const QCString &) {}
233233
void endParameterType() {}
234234
void startParameterName(bool) {}
235-
void endParameterName(bool,bool,bool) {}
235+
void endParameterName() {}
236+
void startParameterExtra() {}
237+
void endParameterExtra(bool,bool,bool) {}
236238
void startParameterDefVal(const char *s) { docify(s); startTypewriter(); }
237239
void endParameterDefVal() { endTypewriter(); }
238240
void startParameterList(bool) {}

src/memberdef.cpp

Lines changed: 54 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -996,12 +996,18 @@ static QCString addTemplateNames(const QCString &s,const QCString &n,const QCStr
996996
// ol.startParameterType(first=TRUE)
997997
// ol.endParameterType
998998
// ol.startParameterName
999-
// ol.endParameterName(last==FALSE)
999+
// ol.endParameterName
1000+
// ol.startParameterExtra
1001+
// ol.startParameterDefVal [optional]
1002+
// ol.endParameterDefVal [optional]
1003+
// ol.endParameterExtra(last==FALSE)
10001004
// ...
10011005
// ol.startParameterType(first=FALSE)
10021006
// ol.endParameterType
10031007
// ol.startParameterName
1004-
// ol.endParameterName(last==TRUE)
1008+
// ol.endParameterName
1009+
// ol.startParameterExtra
1010+
// ol.endParameterExtra(last==TRUE)
10051011
// ...
10061012
// --- leave writeDefArgumentList with return value TRUE
10071013
// ol.endParameterList
@@ -1030,30 +1036,8 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me
10301036
if (!md->isDefine()) ol.docify(" ");
10311037

10321038
//printf("writeDefArgList(%d)\n",defArgList->count());
1033-
ol.pushGeneratorState();
1034-
//ol.disableAllBut(OutputType::Html);
1035-
bool htmlOn = ol.isEnabled(OutputType::Html);
1036-
bool latexOn = ol.isEnabled(OutputType::Latex);
1037-
bool docbookOn = ol.isEnabled(OutputType::Docbook);
1038-
{
1039-
// html and latex
1040-
if (htmlOn) ol.enable(OutputType::Html);
1041-
if (latexOn) ol.enable(OutputType::Latex);
1042-
if (docbookOn) ol.enable(OutputType::Docbook);
1043-
1044-
ol.endMemberDocName();
1045-
ol.startParameterList(!md->isObjCMethod());
1046-
}
1047-
ol.enableAll();
1048-
ol.disable(OutputType::Html);
1049-
ol.disable(OutputType::Latex);
1050-
ol.disable(OutputType::Docbook);
1051-
{
1052-
// other formats
1053-
if (!md->isObjCMethod()) ol.docify("("); // start argument list
1054-
ol.endMemberDocName();
1055-
}
1056-
ol.popGeneratorState();
1039+
ol.endMemberDocName();
1040+
ol.startParameterList(!md->isObjCMethod());
10571041
//printf("===> name=%s isDefine=%d\n",qPrint(md->name()),md->isDefine());
10581042

10591043
QCString cName;
@@ -1080,6 +1064,8 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me
10801064
}
10811065
//printf("~~~ %s cName=%s\n",qPrint(md->name()),qPrint(cName));
10821066

1067+
QCString sep = getLanguageSpecificSeparator(md->getLanguage(),true);
1068+
10831069
bool first=TRUE;
10841070
bool paramTypeStarted=FALSE;
10851071
bool isDefine = md->isDefine();
@@ -1090,7 +1076,7 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me
10901076
if (isDefine || first)
10911077
{
10921078
ol.startParameterType(first,QCString());
1093-
paramTypeStarted=TRUE;
1079+
paramTypeStarted=true;
10941080
if (isDefine)
10951081
{
10961082
ol.endParameterType();
@@ -1103,21 +1089,22 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me
11031089
ol.docify(a.attrib+" ");
11041090
}
11051091

1092+
QCString atype = a.type;
1093+
if (sep!="::") { atype=substitute(atype,"::",sep); }
1094+
1095+
int funcPtrPos=-1;
11061096
{
1107-
QCString n=a.type;
1108-
if (md->isObjCMethod()) { n.prepend("("); n.append(")"); }
1109-
if (a.type!="...")
1097+
if (md->isObjCMethod()) { atype.prepend("("); atype.append(")"); }
1098+
if (atype!="...")
11101099
{
11111100
if (!cName.isEmpty() && scope && scope!=Doxygen::globalScope)
11121101
{
1113-
n=addTemplateNames(n,scope->name(),cName);
1114-
}
1115-
QCString sep = getLanguageSpecificSeparator(md->getLanguage(),true);
1116-
if (sep!="::")
1117-
{
1118-
n=substitute(n,"::",sep);
1102+
atype=addTemplateNames(atype,scope->name(),cName);
11191103
}
1120-
linkifyText(TextGeneratorOLImpl(ol),scope,md->getBodyDef(),md,n);
1104+
funcPtrPos = atype.find("*)(");
1105+
if (funcPtrPos!=-1) funcPtrPos++;
1106+
linkifyText(TextGeneratorOLImpl(ol),scope,md->getBodyDef(),md,
1107+
funcPtrPos==-1 ? atype : atype.left(funcPtrPos));
11211108
}
11221109
}
11231110

@@ -1130,26 +1117,32 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me
11301117
}
11311118
ol.startParameterName(defArgList.size()<2);
11321119
}
1133-
if (!a.name.isEmpty() || a.type=="...") // argument has a name
1120+
else
11341121
{
1135-
ol.disable(OutputType::Latex);
1136-
ol.disable(OutputType::Docbook);
1137-
ol.disable(OutputType::Html);
1138-
ol.docify(" "); /* man page */
1139-
if (htmlOn) ol.enable(OutputType::Html);
1140-
ol.disable(OutputType::Man);
1141-
ol.startEmphasis();
1142-
ol.enable(OutputType::Man);
1143-
if (latexOn) ol.enable(OutputType::Latex);
1144-
if (docbookOn) ol.enable(OutputType::Docbook);
1145-
if (a.name.isEmpty()) ol.docify(a.type); else ol.docify(a.name);
1146-
ol.disable(OutputType::Man);
1147-
ol.disable(OutputType::Latex);
1148-
ol.disable(OutputType::Docbook);
1149-
ol.endEmphasis();
1150-
ol.enable(OutputType::Man);
1151-
if (latexOn) ol.enable(OutputType::Latex);
1152-
if (docbookOn) ol.enable(OutputType::Docbook);
1122+
ol.endParameterName();
1123+
}
1124+
1125+
if (atype=="...")
1126+
{
1127+
ol.docify(atype);
1128+
}
1129+
else if (!a.name.isEmpty()) // argument has a name
1130+
{
1131+
ol.docify(a.name);
1132+
}
1133+
if (!isDefine)
1134+
{
1135+
if (funcPtrPos!=-1)
1136+
{
1137+
ol.writeNonBreakableSpace(1);
1138+
}
1139+
ol.endParameterName();
1140+
}
1141+
ol.startParameterExtra();
1142+
if (funcPtrPos!=-1)
1143+
{
1144+
linkifyText(TextGeneratorOLImpl(ol),scope,md->getBodyDef(),md,
1145+
atype.mid(funcPtrPos));
11531146
}
11541147
if (!a.array.isEmpty())
11551148
{
@@ -1163,12 +1156,8 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me
11631156
n=addTemplateNames(n,scope->name(),cName);
11641157
}
11651158
ol.startParameterDefVal(" = ");
1166-
//ol.docify(" = ");
1167-
//ol.startTypewriter();
11681159
linkifyText(TextGeneratorOLImpl(ol),scope,md->getBodyDef(),md,n,FALSE,TRUE,TRUE);
1169-
//ol.endTypewriter();
11701160
ol.endParameterDefVal();
1171-
11721161
}
11731162
++alIt;
11741163
if (alIt!=defArgList.end())
@@ -1185,7 +1174,7 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me
11851174
key=a.attrib.mid(1,a.attrib.length()-2);
11861175
if (key!=",") key+=":"; // for normal keywords add colon
11871176
}
1188-
ol.endParameterName(FALSE,FALSE,!md->isObjCMethod());
1177+
ol.endParameterExtra(false,false,!md->isObjCMethod());
11891178
if (paramTypeStarted)
11901179
{
11911180
ol.endParameterType();
@@ -1195,23 +1184,15 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me
11951184
}
11961185
else // isDefine
11971186
{
1198-
ol.endParameterName(FALSE,FALSE,TRUE);
1187+
ol.endParameterExtra(false,false,true);
11991188
}
12001189
}
12011190
first=FALSE;
12021191
}
1203-
ol.pushGeneratorState();
1204-
ol.disable(OutputType::Html);
1205-
ol.disable(OutputType::Latex);
1206-
ol.disable(OutputType::Docbook);
1207-
if (!md->isObjCMethod()) ol.docify(")"); // end argument list
1208-
ol.enableAll();
1209-
if (htmlOn) ol.enable(OutputType::Html);
1210-
if (latexOn) ol.enable(OutputType::Latex);
1211-
if (docbookOn) ol.enable(OutputType::Docbook);
12121192
if (first) ol.startParameterName(defArgList.size()<2);
1213-
ol.endParameterName(TRUE,defArgList.size()<2,!md->isObjCMethod());
1214-
ol.popGeneratorState();
1193+
ol.endParameterName();
1194+
ol.startParameterExtra();
1195+
ol.endParameterExtra(TRUE,defArgList.size()<2,!md->isObjCMethod());
12151196
if (!md->extraTypeChars().isEmpty())
12161197
{
12171198
ol.docify(md->extraTypeChars());

src/outputlist.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,8 @@ namespace OutputGenIntf
492492
template<class T> struct endParameterType { static constexpr auto method = &T::endParameterType; };
493493
template<class T> struct startParameterName { static constexpr auto method = &T::startParameterName; };
494494
template<class T> struct endParameterName { static constexpr auto method = &T::endParameterName; };
495+
template<class T> struct startParameterExtra { static constexpr auto method = &T::startParameterExtra; };
496+
template<class T> struct endParameterExtra { static constexpr auto method = &T::endParameterExtra; };
495497
template<class T> struct startParameterDefVal { static constexpr auto method = &T::startParameterDefVal; };
496498
template<class T> struct endParameterDefVal { static constexpr auto method = &T::endParameterDefVal; };
497499
template<class T> struct startParameterList { static constexpr auto method = &T::startParameterList; };
@@ -872,8 +874,12 @@ class OutputList
872874
{ foreach<OutputGenIntf::endParameterType>(); }
873875
void startParameterName(bool one)
874876
{ foreach<OutputGenIntf::startParameterName>(one); }
875-
void endParameterName(bool last,bool one,bool bracket)
876-
{ foreach<OutputGenIntf::endParameterName>(last,one,bracket); }
877+
void endParameterName()
878+
{ foreach<OutputGenIntf::endParameterName>(); }
879+
void startParameterExtra()
880+
{ foreach<OutputGenIntf::startParameterExtra>(); }
881+
void endParameterExtra(bool last,bool one,bool bracket)
882+
{ foreach<OutputGenIntf::endParameterExtra>(last,one,bracket); }
877883
void startParameterDefVal(const char *separator)
878884
{ foreach<OutputGenIntf::startParameterDefVal>(separator); }
879885
void endParameterDefVal()

src/rtfgen.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,9 @@ class RTFGenerator : public OutputGenerator
249249
void startParameterType(bool,const QCString &);
250250
void endParameterType();
251251
void startParameterName(bool) {}
252-
void endParameterName(bool,bool,bool) {}
252+
void endParameterName() {}
253+
void startParameterExtra() {}
254+
void endParameterExtra(bool,bool,bool) {}
253255
void startParameterDefVal(const char *s) { docify(s); startTypewriter(); }
254256
void endParameterDefVal() { endTypewriter(); }
255257
void startParameterList(bool) {}

0 commit comments

Comments
 (0)