-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
memberdef.cpp
5171 lines (4693 loc) · 144 KB
/
memberdef.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/******************************************************************************
*
* Copyright (C) 1997-2015 by Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation under the terms of the GNU General Public License is hereby
* granted. No representations are made about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
* See the GNU General Public License for more details.
*
* Documents produced by Doxygen are derivative works derived from the
* input used in their production; they are not affected by this license.
*
*/
#include <stdio.h>
#include <qglobal.h>
#include <qregexp.h>
#include <assert.h>
#include "md5.h"
#include "memberdef.h"
#include "membername.h"
#include "doxygen.h"
#include "util.h"
#include "code.h"
#include "message.h"
#include "htmlhelp.h"
#include "language.h"
#include "outputlist.h"
#include "example.h"
#include "membergroup.h"
#include "groupdef.h"
#include "defargs.h"
#include "docparser.h"
#include "dot.h"
#include "searchindex.h"
#include "parserintf.h"
#include "marshal.h"
#include "objcache.h"
#include "vhdldocgen.h"
#include "arguments.h"
#include "memberlist.h"
#include "namespacedef.h"
#include "filedef.h"
#include "config.h"
//-----------------------------------------------------------------------------
int MemberDef::s_indentLevel = 0;
//-----------------------------------------------------------------------------
static QCString addTemplateNames(const QCString &s,const QCString &n,const QCString &t)
{
QCString result;
QCString clRealName=n;
int p=0,i;
if ((i=clRealName.find('<'))!=-1)
{
clRealName=clRealName.left(i); // strip template specialization
}
if ((i=clRealName.findRev("::"))!=-1)
{
clRealName=clRealName.right(clRealName.length()-i-2);
}
while ((i=s.find(clRealName,p))!=-1)
{
result+=s.mid(p,i-p);
uint j=clRealName.length()+i;
if (s.length()==j || (s.at(j)!='<' && !isId(s.at(j))))
{ // add template names
//printf("Adding %s+%s\n",clRealName.data(),t.data());
result+=clRealName+t;
}
else
{ // template names already present
//printf("Adding %s\n",clRealName.data());
result+=clRealName;
}
p=i+clRealName.length();
}
result+=s.right(s.length()-p);
//printf("addTemplateNames(%s,%s,%s)=%s\n",s.data(),n.data(),t.data(),result.data());
return result;
}
// ol.startMemberDocName has already been done before this is called.
// when this function returns TRUE, ol.endParameterList will be called.
//
// typical sequence:
// ol.startMemberDoc
// ol.startMemberDocName
// --- enter writeDefArgumentList
// ol.endMemberDocName
// ol.startParameterList
// ...
// ol.startParameterType(first=TRUE)
// ol.endParameterType
// ol.startParameterName
// ol.endParameterName(last==FALSE)
// ...
// ol.startParameterType(first=FALSE)
// ol.endParamtereType
// ol.startParameterName
// ol.endParameterName(last==TRUE)
// ...
// --- leave writeDefArgumentList with return value TRUE
// ol.endParameterList
// ol.endMemberDoc(hasArgs=TRUE)
//
// For an empty list the function should return FALSE, the sequence is
// ol.startMemberDoc
// ol.startMemberDocName
// --- enter writeDefArgumentList
// --- leave writeDefArgumentList with return value FALSE
// ol.endMemberDocName
// ol.endMemberDoc(hasArgs=FALSE);
//
static bool writeDefArgumentList(OutputList &ol,Definition *scope,MemberDef *md)
{
ArgumentList *defArgList=(md->isDocsForDefinition()) ?
md->argumentList() : md->declArgumentList();
//printf("writeDefArgumentList `%s' isDocsForDefinition()=%d\n",md->name().data(),md->isDocsForDefinition());
if (defArgList==0 || md->isProperty())
{
return FALSE; // member has no function like argument list
}
// simple argument list for tcl
if (md->getLanguage()==SrcLangExt_Tcl)
{
if (defArgList->count()==0) return FALSE;
ArgumentListIterator ali(*defArgList);
Argument *a;
ol.endMemberDocName();
ol.startParameterList(FALSE);
ol.startParameterType(TRUE,0);
ol.endParameterType();
ol.startParameterName(FALSE);
for (;(a=ali.current());++ali)
{
if (a->defval.isEmpty())
{
ol.docify(a->name+" ");
}
else
{
ol.docify("?"+a->name+"? ");
}
}
ol.endParameterName(TRUE,FALSE,FALSE);
return TRUE;
}
if (!md->isDefine()) ol.docify(" ");
//printf("writeDefArgList(%d)\n",defArgList->count());
ol.pushGeneratorState();
//ol.disableAllBut(OutputGenerator::Html);
bool htmlOn = ol.isEnabled(OutputGenerator::Html);
bool latexOn = ol.isEnabled(OutputGenerator::Latex);
{
// html and latex
if (htmlOn) ol.enable(OutputGenerator::Html);
if (latexOn) ol.enable(OutputGenerator::Latex);
ol.endMemberDocName();
ol.startParameterList(!md->isObjCMethod());
}
ol.enableAll();
ol.disable(OutputGenerator::Html);
ol.disable(OutputGenerator::Latex);
{
// other formats
if (!md->isObjCMethod()) ol.docify("("); // start argument list
ol.endMemberDocName();
}
ol.popGeneratorState();
//printf("===> name=%s isDefine=%d\n",md->name().data(),md->isDefine());
QCString cName;
if (scope)
{
cName=scope->name();
int il=cName.find('<');
int ir=cName.findRev('>');
if (il!=-1 && ir!=-1 && ir>il)
{
cName=cName.mid(il,ir-il+1);
//printf("1. cName=%s\n",cName.data());
}
else if (scope->definitionType()==Definition::TypeClass && ((ClassDef*)scope)->templateArguments())
{
cName=tempArgListToString(((ClassDef*)scope)->templateArguments(),scope->getLanguage());
//printf("2. cName=%s\n",cName.data());
}
else // no template specifier
{
cName.resize(0);
}
}
//printf("~~~ %s cName=%s\n",md->name().data(),cName.data());
bool first=TRUE;
bool paramTypeStarted=FALSE;
bool isDefine = md->isDefine();
ArgumentListIterator ali(*defArgList);
Argument *a=ali.current();
while (a)
{
if (isDefine || first)
{
ol.startParameterType(first,0);
paramTypeStarted=TRUE;
if (isDefine)
{
ol.endParameterType();
ol.startParameterName(TRUE);
}
}
QRegExp re(")("),res("(.*\\*");
int vp=a->type.find(re);
int wp=a->type.find(res);
// use the following to put the function pointer type before the name
bool hasFuncPtrType=FALSE;
if (!a->attrib.isEmpty() && !md->isObjCMethod()) // argument has an IDL attribute
{
ol.docify(a->attrib+" ");
}
if (hasFuncPtrType) // argument type is a function pointer
{
//printf("a->type=`%s' a->name=`%s'\n",a->type.data(),a->name.data());
QCString n=a->type.left(vp);
if (hasFuncPtrType) n=a->type.left(wp);
if (md->isObjCMethod()) { n.prepend("("); n.append(")"); }
if (!cName.isEmpty()) n=addTemplateNames(n,scope->name(),cName);
linkifyText(TextGeneratorOLImpl(ol),scope,md->getBodyDef(),md,n);
}
else // non-function pointer type
{
QCString n=a->type;
if (md->isObjCMethod()) { n.prepend("("); n.append(")"); }
if (a->type!="...")
{
if (!cName.isEmpty()) n=addTemplateNames(n,scope->name(),cName);
linkifyText(TextGeneratorOLImpl(ol),scope,md->getBodyDef(),md,n);
}
}
if (!isDefine)
{
if (paramTypeStarted)
{
ol.endParameterType();
paramTypeStarted=FALSE;
}
ol.startParameterName(defArgList->count()<2);
}
if (hasFuncPtrType)
{
ol.docify(a->type.mid(wp,vp-wp));
}
if (!a->name.isEmpty() || a->type=="...") // argument has a name
{
//if (!hasFuncPtrType)
//{
// ol.docify(" ");
//}
ol.disable(OutputGenerator::Latex);
ol.disable(OutputGenerator::Html);
ol.docify(" "); /* man page */
if (htmlOn) ol.enable(OutputGenerator::Html);
ol.disable(OutputGenerator::Man);
ol.startEmphasis();
ol.enable(OutputGenerator::Man);
if (latexOn) ol.enable(OutputGenerator::Latex);
if (a->name.isEmpty()) ol.docify(a->type); else ol.docify(a->name);
ol.disable(OutputGenerator::Man);
ol.disable(OutputGenerator::Latex);
ol.endEmphasis();
ol.enable(OutputGenerator::Man);
if (latexOn) ol.enable(OutputGenerator::Latex);
}
if (!a->array.isEmpty())
{
ol.docify(a->array);
}
if (hasFuncPtrType) // write the part of the argument type
// that comes after the name
{
linkifyText(TextGeneratorOLImpl(ol),scope,md->getBodyDef(),
md,a->type.right(a->type.length()-vp));
}
if (!a->defval.isEmpty()) // write the default value
{
QCString n=a->defval;
if (!cName.isEmpty()) n=addTemplateNames(n,scope->name(),cName);
ol.docify(" = ");
ol.startTypewriter();
linkifyText(TextGeneratorOLImpl(ol),scope,md->getBodyDef(),md,n,FALSE,TRUE,TRUE);
ol.endTypewriter();
}
++ali;
a=ali.current();
if (a)
{
if (!md->isObjCMethod()) ol.docify(", "); // there are more arguments
if (!isDefine)
{
QCString key;
if (md->isObjCMethod() && a->attrib.length()>=2)
{
//printf("Found parameter keyword %s\n",a->attrib.data());
// strip [ and ]
key=a->attrib.mid(1,a->attrib.length()-2);
if (key!=",") key+=":"; // for normal keywords add colon
}
ol.endParameterName(FALSE,FALSE,!md->isObjCMethod());
if (paramTypeStarted)
{
ol.endParameterType();
}
ol.startParameterType(FALSE,key);
paramTypeStarted=TRUE;
}
else // isDefine
{
ol.endParameterName(FALSE,FALSE,TRUE);
}
}
first=FALSE;
}
ol.pushGeneratorState();
ol.disable(OutputGenerator::Html);
ol.disable(OutputGenerator::Latex);
if (!md->isObjCMethod()) ol.docify(")"); // end argument list
ol.enableAll();
if (htmlOn) ol.enable(OutputGenerator::Html);
if (latexOn) ol.enable(OutputGenerator::Latex);
if (first) ol.startParameterName(defArgList->count()<2);
ol.endParameterName(TRUE,defArgList->count()<2,!md->isObjCMethod());
ol.popGeneratorState();
if (md->extraTypeChars())
{
ol.docify(md->extraTypeChars());
}
if (defArgList->constSpecifier)
{
ol.docify(" const");
}
if (defArgList->volatileSpecifier)
{
ol.docify(" volatile");
}
if (defArgList->refQualifier==RefQualifierLValue)
{
ol.docify(" &");
}
else if (defArgList->refQualifier==RefQualifierRValue)
{
ol.docify(" &&");
}
if (!defArgList->trailingReturnType.isEmpty())
{
linkifyText(TextGeneratorOLImpl(ol), // out
scope, // scope
md->getBodyDef(), // fileScope
md, // self
defArgList->trailingReturnType, // text
FALSE // autoBreak
);
}
return TRUE;
}
static void writeExceptionListImpl(
OutputList &ol, ClassDef *cd, MemberDef *md, QCString const& exception)
{
// this is ordinary exception spec - there must be a '('
//printf("exception='%s'\n",exception.data());
int index = exception.find('(');
if (index!=-1)
{
ol.exceptionEntry(exception.left(index),false);
++index; // paren in second column so skip it here
for (int comma = exception.find(',', index); comma!=-1; )
{
++comma; // include comma
linkifyText(TextGeneratorOLImpl(ol),cd,md->getBodyDef(),md,
exception.mid(index,comma-index));
ol.exceptionEntry(0,false);
index=comma;
comma = exception.find(',', index);
}
int close = exception.find(')', index);
if (close!=-1)
{
QCString type=removeRedundantWhiteSpace(exception.mid(index,close-index));
linkifyText(TextGeneratorOLImpl(ol),cd,md->getBodyDef(),md,type);
ol.exceptionEntry(0,true);
}
else
{
warn(md->getDefFileName(),md->getDefLine(),
"missing ) in exception list on member %s",qPrint(md->name()));
}
}
else // Java Exception
{
ol.docify(" ");
linkifyText(TextGeneratorOLImpl(ol),cd,md->getBodyDef(),md,exception);
}
}
static void writeExceptionList(OutputList &ol, ClassDef *cd, MemberDef *md)
{
QCString exception(QCString(md->excpString()).stripWhiteSpace());
if ('{'==exception.at(0))
{
// this is an UNO IDL attribute - need special handling
int index = exception.find(';');
int oldIndex = 1;
while (-1 != index) // there should be no more than 2 (set / get)
{
// omit '{' and ';' -> "set raises (...)"
writeExceptionListImpl(ol,cd,md,exception.mid(oldIndex,index-oldIndex));
oldIndex=index+1;
index = exception.find(';',oldIndex);
}
// the rest is now just '}' - omit that
}
else
{
writeExceptionListImpl(ol,cd,md,exception);
}
}
static void writeTemplatePrefix(OutputList &ol,ArgumentList *al)
{
ol.docify("template<");
ArgumentListIterator ali(*al);
Argument *a = ali.current();
while (a)
{
ol.docify(a->type);
ol.docify(" ");
ol.docify(a->name);
if (a->defval.length()!=0)
{
ol.docify(" = ");
ol.docify(a->defval);
}
++ali;
a=ali.current();
if (a) ol.docify(", ");
}
ol.docify("> ");
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
class MemberDefImpl
{
public:
MemberDefImpl();
~MemberDefImpl();
void init(Definition *def,const char *t,const char *a,const char *e,
Protection p,Specifier v,bool s,Relationship r,
MemberType mt,const ArgumentList *tal,
const ArgumentList *al
);
ClassDef *classDef; // member of or related to
FileDef *fileDef; // member of file definition
NamespaceDef *nspace; // the namespace this member is in.
MemberDef *enumScope; // the enclosing scope, if this is an enum field
bool livesInsideEnum;
MemberDef *annEnumType; // the anonymous enum that is the type of this member
MemberList *enumFields; // enumeration fields
MemberDef *redefines; // the members that this member redefines
MemberList *redefinedBy; // the list of members that redefine this one
MemberDef *memDef; // member definition for this declaration
MemberDef *memDec; // member declaration for this definition
ClassDef *relatedAlso; // points to class marked by relatedAlso
ExampleSDict *exampleSDict; // a dictionary of all examples for quick access
QCString type; // return actual type
QCString accessorType; // return type that tell how to get to this member
ClassDef *accessorClass; // class that this member accesses (for anonymous types)
QCString args; // function arguments/variable array specifiers
QCString def; // member definition in code (fully qualified name)
QCString anc; // HTML anchor name
Specifier virt; // normal/virtual/pure virtual
Protection prot; // protection type [Public/Protected/Private]
QCString decl; // member declaration in class
QCString bitfields; // struct member bitfields
QCString read; // property read accessor
QCString write; // property write accessor
QCString exception; // exceptions that can be thrown
QCString initializer; // initializer
QCString extraTypeChars; // extra type info found after the argument list
QCString enumBaseType; // base type of the enum (C++11)
int initLines; // number of lines in the initializer
uint64 memSpec; // The specifiers present for this member
MemberType mtype; // returns the kind of member
int maxInitLines; // when the initializer will be displayed
int userInitLines; // result of explicit \hideinitializer or \showinitializer
MemberDef *annMemb;
ArgumentList *defArgList; // argument list of this member definition
ArgumentList *declArgList; // argument list of this member declaration
ArgumentList *tArgList; // template argument list of function template
ArgumentList *typeConstraints; // type constraints for template parameters
MemberDef *templateMaster;
QList<ArgumentList> *defTmpArgLists; // lists of template argument lists
// (for template functions in nested template classes)
ClassDef *cachedAnonymousType; // if the member has an anonymous compound
// as its type then this is computed by
// getClassDefOfAnonymousType() and
// cached here.
SDict<MemberList> *classSectionSDict; // not accessible
MemberDef *groupAlias; // Member containing the definition
int grpId; // group id
MemberGroup *memberGroup; // group's member definition
GroupDef *group; // group in which this member is in
Grouping::GroupPri_t grouppri; // priority of this definition
QCString groupFileName; // file where this grouping was defined
int groupStartLine; // line " " " " "
MemberDef *groupMember;
bool isTypedefValCached;
ClassDef *cachedTypedefValue;
QCString cachedTypedefTemplSpec;
QCString cachedResolvedType;
// inbody documentation
//int inbodyLine;
//QCString inbodyFile;
//QCString inbodyDocs;
// documentation inheritance
MemberDef *docProvider;
// to store the output file base from tag files
QCString explicitOutputFileBase;
// objective-c
bool implOnly; // function found in implementation but not
// in the interface
bool hasDocumentedParams;
bool hasDocumentedReturnType;
bool isDMember;
Relationship related; // relationship of this to the class
bool stat; // is it a static function?
bool proto; // is it a prototype;
bool docEnumValues; // is an enum with documented enum values.
bool annScope; // member is part of an annoymous scope
bool annUsed;
bool hasCallGraph;
bool hasCallerGraph;
bool explExt; // member was explicitly declared external
bool tspec; // member is a template specialization
bool groupHasDocs; // true if the entry that caused the grouping was documented
bool docsForDefinition; // TRUE => documentation block is put before
// definition.
// FALSE => block is put before declaration.
ClassDef *category;
MemberDef *categoryRelation;
};
MemberDefImpl::MemberDefImpl() :
enumFields(0),
redefinedBy(0),
exampleSDict(0),
defArgList(0),
declArgList(0),
tArgList(0),
typeConstraints(0),
defTmpArgLists(0),
classSectionSDict(0),
category(0),
categoryRelation(0)
{
}
MemberDefImpl::~MemberDefImpl()
{
delete redefinedBy;
delete exampleSDict;
delete enumFields;
delete defArgList;
delete tArgList;
delete typeConstraints;
delete defTmpArgLists;
delete classSectionSDict;
delete declArgList;
}
void MemberDefImpl::init(Definition *def,
const char *t,const char *a,const char *e,
Protection p,Specifier v,bool s,Relationship r,
MemberType mt,const ArgumentList *tal,
const ArgumentList *al
)
{
classDef=0;
fileDef=0;
redefines=0;
relatedAlso=0;
redefinedBy=0;
accessorClass=0;
nspace=0;
memDef=0;
memDec=0;
group=0;
grpId=-1;
exampleSDict=0;
enumFields=0;
enumScope=0;
livesInsideEnum=FALSE;
defTmpArgLists=0;
hasCallGraph = FALSE;
hasCallerGraph = FALSE;
initLines=0;
type=t;
if (mt==MemberType_Typedef) type.stripPrefix("typedef ");
// type.stripPrefix("struct ");
// type.stripPrefix("class " );
// type.stripPrefix("union " );
type=removeRedundantWhiteSpace(type);
args=a;
args=removeRedundantWhiteSpace(args);
if (type.isEmpty()) decl=def->name()+args; else decl=type+" "+def->name()+args;
memberGroup=0;
virt=v;
prot=p;
related=r;
stat=s;
mtype=mt;
exception=e;
proto=FALSE;
annScope=FALSE;
memSpec=0;
annMemb=0;
annUsed=FALSE;
annEnumType=0;
groupAlias=0;
explExt=FALSE;
tspec=FALSE;
cachedAnonymousType=0;
maxInitLines=Config_getInt(MAX_INITIALIZER_LINES);
userInitLines=-1;
docEnumValues=FALSE;
// copy function template arguments (if any)
if (tal)
{
tArgList = tal->deepCopy();
}
else
{
tArgList=0;
}
//printf("new member al=%p\n",al);
// copy function definition arguments (if any)
if (al)
{
defArgList = al->deepCopy();
}
else
{
defArgList=0;
}
// convert function declaration arguments (if any)
if (!args.isEmpty())
{
declArgList = new ArgumentList;
stringToArgumentList(args,declArgList,&extraTypeChars);
//printf("setDeclArgList %s to %s const=%d\n",args.data(),
// argListToString(declArgList).data(),declArgList->constSpecifier);
}
else
{
declArgList = 0;
}
templateMaster = 0;
classSectionSDict = 0;
docsForDefinition = TRUE;
isTypedefValCached = FALSE;
cachedTypedefValue = 0;
//inbodyLine = -1;
implOnly=FALSE;
groupMember = 0;
hasDocumentedParams = FALSE;
hasDocumentedReturnType = FALSE;
docProvider = 0;
isDMember = def->getDefFileName().right(2).lower()==".d";
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
/*! Creates a new member definition.
*
* \param df File containing the definition of this member.
* \param dl Line at which the member definition was found.
* \param dc Column at which the member definition was found.
* \param t A string representing the type of the member.
* \param na A string representing the name of the member.
* \param a A string representing the arguments of the member.
* \param e A string representing the throw clause of the members.
* \param p The protection context of the member, possible values are:
* \c Public, \c Protected, \c Private.
* \param v The degree of `virtualness' of the member, possible values are:
* \c Normal, \c Virtual, \c Pure.
* \param s A boolean that is true iff the member is static.
* \param r The relationship between the class and the member.
* \param mt The kind of member. See #MemberType for a list of
* all types.
* \param tal The template arguments of this member.
* \param al The arguments of this member. This is a structured form of
* the string past as argument \a a.
*/
MemberDef::MemberDef(const char *df,int dl,int dc,
const char *t,const char *na,const char *a,const char *e,
Protection p,Specifier v,bool s,Relationship r,MemberType mt,
const ArgumentList *tal,const ArgumentList *al
) : Definition(df,dl,dc,removeRedundantWhiteSpace(na)), visited(FALSE)
{
//printf("MemberDef::MemberDef(%s)\n",na);
m_impl = new MemberDefImpl;
m_impl->init(this,t,a,e,p,v,s,r,mt,tal,al);
number_of_flowkw = 1;
m_isLinkableCached = 0;
m_isConstructorCached = 0;
m_isDestructorCached = 0;
}
MemberDef::MemberDef(const MemberDef &md) : Definition(md), visited(FALSE)
{
m_impl = new MemberDefImpl;
m_isLinkableCached = 0;
m_isConstructorCached = 0;
m_isDestructorCached = 0;
}
MemberDef *MemberDef::deepCopy() const
{
//MemberDef *result = new MemberDef(getDefFileName(),getDefLine(),name());
MemberDef *result = new MemberDef(*this);
// first copy everything by reference
*result->m_impl = *m_impl;
// clear pointers owned by object
result->m_impl->redefinedBy= 0;
result->m_impl->exampleSDict=0;
result->m_impl->enumFields=0;
result->m_impl->defArgList=0;
result->m_impl->tArgList=0;
result->m_impl->typeConstraints=0;
result->m_impl->defTmpArgLists=0;
result->m_impl->classSectionSDict=0;
result->m_impl->declArgList=0;
// replace pointers owned by the object by deep copies
if (m_impl->redefinedBy)
{
MemberListIterator mli(*m_impl->redefinedBy);
MemberDef *md;
for (mli.toFirst();(md=mli.current());++mli)
{
result->insertReimplementedBy(md);
}
}
if (m_impl->exampleSDict)
{
ExampleSDict::Iterator it(*m_impl->exampleSDict);
Example *e;
for (it.toFirst();(e=it.current());++it)
{
result->addExample(e->anchor,e->name,e->file);
}
}
if (m_impl->enumFields)
{
MemberListIterator mli(*m_impl->enumFields);
MemberDef *md;
for (mli.toFirst();(md=mli.current());++mli)
{
result->insertEnumField(md);
}
}
if (m_impl->defArgList)
{
result->m_impl->defArgList = m_impl->defArgList->deepCopy();
}
if (m_impl->tArgList)
{
result->m_impl->tArgList = m_impl->tArgList->deepCopy();
}
if (m_impl->typeConstraints)
{
result->m_impl->typeConstraints = m_impl->typeConstraints->deepCopy();
}
result->setDefinitionTemplateParameterLists(m_impl->defTmpArgLists);
if (m_impl->classSectionSDict)
{
result->m_impl->classSectionSDict = new SDict<MemberList>(7);
SDict<MemberList>::IteratorDict it(*m_impl->classSectionSDict);
MemberList *ml;
for (it.toFirst();(ml=it.current());++it)
{
result->m_impl->classSectionSDict->append(it.currentKey(),ml);
}
}
if (m_impl->declArgList)
{
result->m_impl->declArgList = m_impl->declArgList->deepCopy();
}
return result;
}
void MemberDef::moveTo(Definition *scope)
{
setOuterScope(scope);
if (scope->definitionType()==Definition::TypeClass)
{
m_impl->classDef = (ClassDef*)scope;
}
else if (scope->definitionType()==Definition::TypeFile)
{
m_impl->fileDef = (FileDef*)scope;
}
else if (scope->definitionType()==Definition::TypeNamespace)
{
m_impl->nspace = (NamespaceDef*)scope;
}
m_isLinkableCached = 0;
m_isConstructorCached = 0;
}
/*! Destroys the member definition. */
MemberDef::~MemberDef()
{
delete m_impl;
//printf("%p: ~MemberDef()\n",this);
m_impl=0;
}
void MemberDef::setReimplements(MemberDef *md)
{
m_impl->redefines = md;
}
void MemberDef::insertReimplementedBy(MemberDef *md)
{
if (m_impl->templateMaster)
{
m_impl->templateMaster->insertReimplementedBy(md);
}
if (m_impl->redefinedBy==0) m_impl->redefinedBy = new MemberList(MemberListType_redefinedBy);
if (m_impl->redefinedBy->findRef(md)==-1)
{
m_impl->redefinedBy->inSort(md);
}
}
MemberDef *MemberDef::reimplements() const
{
return m_impl->redefines;
}
MemberList *MemberDef::reimplementedBy() const
{
return m_impl->redefinedBy;
}
bool MemberDef::isReimplementedBy(ClassDef *cd) const
{
if (cd && m_impl->redefinedBy)
{
MemberListIterator mi(*m_impl->redefinedBy);
MemberDef *md;
for (mi.toFirst();(md=mi.current());++mi)
{
ClassDef *mcd = md->getClassDef();
if (mcd)
{
if (cd==mcd || cd->isBaseClass(mcd,TRUE))
{
return TRUE;
}
}
}
}
return FALSE;
}
void MemberDef::insertEnumField(MemberDef *md)
{
if (m_impl->enumFields==0) m_impl->enumFields=new MemberList(MemberListType_enumFields);
m_impl->enumFields->append(md);
}
bool MemberDef::addExample(const char *anchor,const char *nameStr,
const char *file)
{
//printf("%s::addExample(%s,%s,%s)\n",name().data(),anchor,nameStr,file);
if (m_impl->exampleSDict==0) m_impl->exampleSDict = new ExampleSDict;
if (m_impl->exampleSDict->find(nameStr)==0)
{
//printf("Add reference to example %s to member %s\n",nameStr,name.data());
Example *e=new Example;
e->anchor=anchor;
e->name=nameStr;
e->file=file;
m_impl->exampleSDict->inSort(nameStr,e);
return TRUE;
}
return FALSE;
}
bool MemberDef::hasExamples()
{
if (m_impl->exampleSDict==0)
return FALSE;
else
return m_impl->exampleSDict->count()>0;
}
QCString MemberDef::getOutputFileBase() const
{
static bool separateMemberPages = Config_getBool(SEPARATE_MEMBER_PAGES);
static bool inlineSimpleClasses = Config_getBool(INLINE_SIMPLE_STRUCTS);
QCString baseName;
//printf("Member: %s: templateMaster=%p group=%p classDef=%p nspace=%p fileDef=%p\n",
// name().data(),m_impl->templateMaster,m_impl->group,m_impl->classDef,
// m_impl->nspace,m_impl->fileDef);
if (!m_impl->explicitOutputFileBase.isEmpty())
{
return m_impl->explicitOutputFileBase;
}
else if (m_impl->templateMaster)
{
return m_impl->templateMaster->getOutputFileBase();
}
else if (m_impl->group)
{
baseName=m_impl->group->getOutputFileBase();
}
else if (m_impl->classDef)
{
baseName=m_impl->classDef->getOutputFileBase();
if (inlineSimpleClasses && m_impl->classDef->isSimple())
{
return baseName;
}
}
else if (m_impl->nspace && m_impl->nspace->isLinkableInProject())
{
baseName=m_impl->nspace->getOutputFileBase();
}
else if (m_impl->fileDef)
{
baseName=m_impl->fileDef->getOutputFileBase();
}
if (baseName.isEmpty())
{
warn(getDefFileName(),getDefLine(),
"Internal inconsistency: member %s does not belong to any"
" container!",qPrint(name())
);
return "dummy";
}
else if (separateMemberPages && isDetailedSectionLinkable())
{
if (getEnumScope()) // enum value, which is part of enum's documentation
{
baseName+="_"+getEnumScope()->anchor();