56
56
57
57
58
58
/* * Implementation of the ClassDef interface */
59
- class ClassDefImpl : public DefinitionImpl , public ClassDefMutable
59
+ class ClassDefImpl : public DefinitionMixin < ClassDefMutable>
60
60
{
61
61
public:
62
62
ClassDefImpl (const char *fileName,int startLine,int startColumn,
@@ -283,14 +283,15 @@ ClassDefMutable *createClassDef(
283
283
}
284
284
// -----------------------------------------------------------------------------
285
285
286
- class ClassDefAliasImpl : public DefinitionAliasImpl , public ClassDef
286
+ class ClassDefAliasImpl : public DefinitionAliasMixin < ClassDef>
287
287
{
288
288
public:
289
- ClassDefAliasImpl (const Definition *newScope,const ClassDef *cd) : DefinitionAliasImpl(newScope,cd) {}
289
+ ClassDefAliasImpl (const Definition *newScope,const ClassDef *cd)
290
+ : DefinitionAliasMixin(newScope,cd) {}
290
291
virtual ~ClassDefAliasImpl () {}
291
292
virtual DefType definitionType () const { return TypeClass; }
292
293
293
- const ClassDef *getCdAlias () const { return dynamic_cast < const ClassDef*> (getAlias ()); }
294
+ const ClassDef *getCdAlias () const { return toClassDef (getAlias ()); }
294
295
virtual ClassDef *resolveAlias () { return const_cast <ClassDef*>(getCdAlias ()); }
295
296
296
297
virtual QCString getOutputFileBase () const
@@ -726,7 +727,7 @@ ClassDefImpl::ClassDefImpl(
726
727
const char *nm,CompoundType ct,
727
728
const char *lref,const char *fName ,
728
729
bool isSymbol,bool isJavaEnum)
729
- : DefinitionImpl (defFileName,defLine,defColumn,removeRedundantWhiteSpace(nm),0,0,isSymbol)
730
+ : DefinitionMixin (defFileName,defLine,defColumn,removeRedundantWhiteSpace(nm),0,0,isSymbol)
730
731
{
731
732
m_visited=FALSE ;
732
733
setReference (lref);
@@ -1217,7 +1218,7 @@ void ClassDefImpl::insertUsedFile(FileDef *fd)
1217
1218
ClassDef *cd;
1218
1219
for (qdi.toFirst ();(cd=qdi.current ());++qdi)
1219
1220
{
1220
- ClassDefMutable *cdm = ClassDef::make_mutable (cd);
1221
+ ClassDefMutable *cdm = toClassDefMutable (cd);
1221
1222
if (cdm)
1222
1223
{
1223
1224
cdm->insertUsedFile (fd);
@@ -1298,7 +1299,7 @@ static void searchTemplateSpecs(/*in*/ const Definition *d,
1298
1299
{
1299
1300
searchTemplateSpecs (d->getOuterScope (),result,name,lang);
1300
1301
}
1301
- const ClassDef *cd=dynamic_cast < const ClassDef *> (d);
1302
+ const ClassDef *cd=toClassDef (d);
1302
1303
if (!name.isEmpty ()) name+=" ::" ;
1303
1304
QCString clName = d->localName ();
1304
1305
if (/* clName.right(2)=="-g" ||*/ clName.right (2 )==" -p" )
@@ -2851,7 +2852,7 @@ void ClassDefImpl::writeDocumentationForInnerClasses(OutputList &ol) const
2851
2852
ClassDef *innerCd;
2852
2853
for (cli.toFirst ();(innerCd=cli.current ());++cli)
2853
2854
{
2854
- ClassDefMutable *innerCdm = ClassDef::make_mutable (innerCd);
2855
+ ClassDefMutable *innerCdm = toClassDefMutable (innerCd);
2855
2856
if (innerCdm)
2856
2857
{
2857
2858
if (
@@ -3398,7 +3399,7 @@ bool ClassDefImpl::isVisibleInHierarchy() const
3398
3399
3399
3400
bool ClassDefImpl::hasDocumentation () const
3400
3401
{
3401
- return DefinitionImpl ::hasDocumentation ();
3402
+ return DefinitionMixin ::hasDocumentation ();
3402
3403
}
3403
3404
3404
3405
// ----------------------------------------------------------------------
@@ -3474,7 +3475,7 @@ void ClassDefImpl::mergeMembers()
3474
3475
static bool extractPrivate = Config_getBool (EXTRACT_PRIVATE);
3475
3476
for (const auto &bcd : baseClasses ())
3476
3477
{
3477
- ClassDefMutable *bClass=ClassDef::make_mutable (bcd.classDef );
3478
+ ClassDefMutable *bClass=toClassDefMutable (bcd.classDef );
3478
3479
if (bClass)
3479
3480
{
3480
3481
// merge the members in the base class of this inheritance branch first
@@ -3689,7 +3690,7 @@ void ClassDefImpl::mergeMembers()
3689
3690
*/
3690
3691
void ClassDefImpl::mergeCategory (ClassDef *cat)
3691
3692
{
3692
- ClassDefMutable *category = ClassDef::make_mutable (cat);
3693
+ ClassDefMutable *category = toClassDefMutable (cat);
3693
3694
if (category)
3694
3695
{
3695
3696
static bool extractLocalMethods = Config_getBool (EXTRACT_LOCAL_METHODS);
@@ -3737,8 +3738,8 @@ void ClassDefImpl::mergeCategory(ClassDef *cat)
3737
3738
auto &srcMi = srcMni->front ();
3738
3739
if (srcMi && dstMi)
3739
3740
{
3740
- MemberDefMutable *smdm = MemberDef::make_mutable (srcMi->memberDef ());
3741
- MemberDefMutable *dmdm = MemberDef::make_mutable (dstMi->memberDef ());
3741
+ MemberDefMutable *smdm = toMemberDefMutable (srcMi->memberDef ());
3742
+ MemberDefMutable *dmdm = toMemberDefMutable (dstMi->memberDef ());
3742
3743
if (smdm && dmdm)
3743
3744
{
3744
3745
combineDeclarationAndDefinition (smdm,dmdm);
@@ -3760,7 +3761,7 @@ void ClassDefImpl::mergeCategory(ClassDef *cat)
3760
3761
// printf("Adding '%s'\n",mi->memberDef->name().data());
3761
3762
Protection prot = mi->prot ();
3762
3763
// if (makePrivate) prot = Private;
3763
- std::unique_ptr<MemberDefMutable> newMd { MemberDef::make_mutable (mi->memberDef ()->deepCopy ()) };
3764
+ std::unique_ptr<MemberDefMutable> newMd { toMemberDefMutable (mi->memberDef ()->deepCopy ()) };
3764
3765
if (newMd)
3765
3766
{
3766
3767
// printf("Copying member %s\n",mi->memberDef->name().data());
@@ -3782,7 +3783,7 @@ void ClassDefImpl::mergeCategory(ClassDef *cat)
3782
3783
newMd->setCategory (category);
3783
3784
newMd->setCategoryRelation (mi->memberDef ());
3784
3785
}
3785
- MemberDefMutable *mdm = MemberDef::make_mutable (mi->memberDef ());
3786
+ MemberDefMutable *mdm = toMemberDefMutable (mi->memberDef ());
3786
3787
if (mdm)
3787
3788
{
3788
3789
mdm->setCategoryRelation (newMd.get ());
@@ -3955,7 +3956,7 @@ QCString ClassDefImpl::getSourceFileBase() const
3955
3956
}
3956
3957
else
3957
3958
{
3958
- return DefinitionImpl ::getSourceFileBase ();
3959
+ return DefinitionMixin ::getSourceFileBase ();
3959
3960
}
3960
3961
}
3961
3962
@@ -3967,12 +3968,12 @@ void ClassDefImpl::setGroupDefForAllMembers(GroupDef *gd,Grouping::GroupPri_t pr
3967
3968
{
3968
3969
for (auto &mi : *mni)
3969
3970
{
3970
- MemberDefMutable *md = MemberDef::make_mutable (mi->memberDef ());
3971
+ MemberDefMutable *md = toMemberDefMutable (mi->memberDef ());
3971
3972
if (md)
3972
3973
{
3973
3974
md->setGroupDef (gd,pri,fileName,startLine,hasDocs);
3974
3975
gd->insertMember (md,TRUE );
3975
- ClassDefMutable *innerClass = ClassDef::make_mutable (md->getClassDefOfAnonymousType ());
3976
+ ClassDefMutable *innerClass = toClassDefMutable (md->getClassDefOfAnonymousType ());
3976
3977
if (innerClass) innerClass->setGroupDefForAllMembers (gd,pri,fileName,startLine,hasDocs);
3977
3978
}
3978
3979
}
@@ -3989,7 +3990,7 @@ void ClassDefImpl::addInnerCompound(const Definition *d)
3989
3990
{
3990
3991
m_impl->innerClasses = new ClassSDict (17 );
3991
3992
}
3992
- m_impl->innerClasses ->inSort (d->localName (),dynamic_cast < const ClassDef *> (d));
3993
+ m_impl->innerClasses ->inSort (d->localName (),toClassDef (d));
3993
3994
}
3994
3995
}
3995
3996
@@ -4012,7 +4013,7 @@ ClassDef *ClassDefImpl::insertTemplateInstance(const QCString &fileName,
4012
4013
{
4013
4014
m_impl->templateInstances = new QDict<ClassDef>(17 );
4014
4015
}
4015
- ClassDefMutable *templateClass=ClassDef::make_mutable (m_impl->templateInstances ->find (templSpec));
4016
+ ClassDefMutable *templateClass=toClassDefMutable (m_impl->templateInstances ->find (templSpec));
4016
4017
if (templateClass==0 )
4017
4018
{
4018
4019
Debug::print (Debug::Classes,0 ," New template instance class '%s''%s'\n " ,qPrint (name ()),qPrint (templSpec));
@@ -4035,7 +4036,7 @@ ClassDef *ClassDefImpl::getVariableInstance(const char *templSpec) const
4035
4036
m_impl->variableInstances = new QDict<ClassDef>(17 );
4036
4037
m_impl->variableInstances ->setAutoDelete (TRUE );
4037
4038
}
4038
- ClassDefMutable *templateClass=ClassDef::make_mutable (m_impl->variableInstances ->find (templSpec));
4039
+ ClassDefMutable *templateClass=toClassDefMutable (m_impl->variableInstances ->find (templSpec));
4039
4040
if (templateClass==0 )
4040
4041
{
4041
4042
Debug::print (Debug::Classes,0 ," New template variable instance class '%s' '%s'\n " ,qPrint (name ()),qPrint (templSpec));
@@ -4112,7 +4113,7 @@ QCString ClassDefImpl::getReference() const
4112
4113
}
4113
4114
else
4114
4115
{
4115
- return DefinitionImpl ::getReference ();
4116
+ return DefinitionMixin ::getReference ();
4116
4117
}
4117
4118
}
4118
4119
@@ -4124,7 +4125,7 @@ bool ClassDefImpl::isReference() const
4124
4125
}
4125
4126
else
4126
4127
{
4127
- return DefinitionImpl ::isReference ();
4128
+ return DefinitionMixin ::isReference ();
4128
4129
}
4129
4130
}
4130
4131
@@ -4134,7 +4135,7 @@ ArgumentLists ClassDefImpl::getTemplateParameterLists() const
4134
4135
Definition *d=getOuterScope ();
4135
4136
while (d && d->definitionType ()==Definition::TypeClass)
4136
4137
{
4137
- result.insert (result.begin (),dynamic_cast <ClassDef*> (d)->templateArguments ());
4138
+ result.insert (result.begin (),toClassDef (d)->templateArguments ());
4138
4139
d = d->getOuterScope ();
4139
4140
}
4140
4141
if (!templateArguments ().empty ())
@@ -4156,7 +4157,7 @@ QCString ClassDefImpl::qualifiedNameWithTemplateParameters(
4156
4157
{
4157
4158
if (d->definitionType ()==Definition::TypeClass)
4158
4159
{
4159
- ClassDef *cd=dynamic_cast <ClassDef *> (d);
4160
+ ClassDef *cd=toClassDef (d);
4160
4161
scName = cd->qualifiedNameWithTemplateParameters (actualParams,actualParamIndex);
4161
4162
}
4162
4163
else if (!hideScopeNames)
@@ -4329,7 +4330,7 @@ void ClassDefImpl::addMemberToList(MemberListType lt,MemberDef *md,bool isBrief)
4329
4330
// for members in the declaration lists we set the section, needed for member grouping
4330
4331
if ((ml->listType ()&MemberListType_detailedLists)==0 )
4331
4332
{
4332
- MemberDefMutable *mdm = MemberDef::make_mutable (md);
4333
+ MemberDefMutable *mdm = toMemberDefMutable (md);
4333
4334
if (mdm)
4334
4335
{
4335
4336
mdm->setSectionList (this ,ml);
@@ -4456,7 +4457,7 @@ int ClassDefImpl::countInheritedDecMembers(MemberListType lt,
4456
4457
{
4457
4458
for (const auto &ibcd : m_impl->inherits )
4458
4459
{
4459
- ClassDefMutable *icd=ClassDef::make_mutable (ibcd.classDef );
4460
+ ClassDefMutable *icd=toClassDefMutable (ibcd.classDef );
4460
4461
int lt1,lt2;
4461
4462
if (icd && icd->isLinkable ())
4462
4463
{
@@ -4592,7 +4593,7 @@ void ClassDefImpl::writeInheritedMemberDeclarations(OutputList &ol,
4592
4593
{
4593
4594
for (const auto &ibcd : m_impl->inherits )
4594
4595
{
4595
- ClassDefMutable *icd=ClassDef::make_mutable (ibcd.classDef );
4596
+ ClassDefMutable *icd=toClassDefMutable (ibcd.classDef );
4596
4597
if (icd && icd->isLinkable ())
4597
4598
{
4598
4599
int lt1,lt3;
@@ -5104,7 +5105,7 @@ bool ClassDefImpl::isSliceLocal() const
5104
5105
5105
5106
void ClassDefImpl::setName (const char *name)
5106
5107
{
5107
- DefinitionImpl ::setName (name);
5108
+ DefinitionMixin ::setName (name);
5108
5109
}
5109
5110
5110
5111
void ClassDefImpl::setMetaData (const char *md)
@@ -5122,3 +5123,67 @@ QCString ClassDefImpl::inheritanceGraphFileName() const
5122
5123
return m_impl->inheritFileName ;
5123
5124
}
5124
5125
5126
+ // --- Cast functions
5127
+ //
5128
+ ClassDef *toClassDef (Definition *d)
5129
+ {
5130
+ if (d && (typeid (*d)==typeid (ClassDefImpl) || typeid (*d)==typeid (ClassDefAliasImpl)))
5131
+ {
5132
+ return static_cast <ClassDef*>(d);
5133
+ }
5134
+ else
5135
+ {
5136
+ return 0 ;
5137
+ }
5138
+ }
5139
+
5140
+ ClassDef *toClassDef (DefinitionMutable *md)
5141
+ {
5142
+ Definition *d = toDefinition (md);
5143
+ if (d && typeid (*d)==typeid (ClassDefImpl))
5144
+ {
5145
+ return static_cast <ClassDef*>(d);
5146
+ }
5147
+ else
5148
+ {
5149
+ return 0 ;
5150
+ }
5151
+ }
5152
+
5153
+ const ClassDef *toClassDef (const Definition *d)
5154
+ {
5155
+ if (d && (typeid (*d)==typeid (ClassDefImpl) || typeid (*d)==typeid (ClassDefAliasImpl)))
5156
+ {
5157
+ return static_cast <const ClassDef*>(d);
5158
+ }
5159
+ else
5160
+ {
5161
+ return 0 ;
5162
+ }
5163
+ }
5164
+
5165
+ ClassDefMutable *toClassDefMutable (Definition *d)
5166
+ {
5167
+ if (d && typeid (*d)==typeid (ClassDefImpl))
5168
+ {
5169
+ return static_cast <ClassDefMutable*>(d);
5170
+ }
5171
+ else
5172
+ {
5173
+ return 0 ;
5174
+ }
5175
+ }
5176
+
5177
+ ClassDefMutable *toClassDefMutable (const Definition *d)
5178
+ {
5179
+ if (d && typeid (*d)==typeid (ClassDefImpl))
5180
+ {
5181
+ return const_cast <ClassDefMutable*>(static_cast <const ClassDefMutable*>(d));
5182
+ }
5183
+ else
5184
+ {
5185
+ return 0 ;
5186
+ }
5187
+ }
5188
+
5189
+
0 commit comments