memberdef.cpp 124 KB
Newer Older
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1 2
/******************************************************************************
 *
3
 * 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
4
 *
5
 * Copyright (C) 1997-2008 by Dimitri van Heesch.
Dimitri van Heesch's avatar
Dimitri van Heesch committed
6 7 8 9 10 11 12
 *
 * 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.
 *
Dimitri van Heesch's avatar
Dimitri van Heesch committed
13 14
 * Documents produced by Doxygen are derivative works derived from the
 * input used in their production; they are not affected by this license.
Dimitri van Heesch's avatar
Dimitri van Heesch committed
15 16 17 18 19
 *
 */

#include <stdio.h>
#include <qregexp.h>
20
#include <assert.h>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
21
#include <md5.h>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
22 23 24 25
#include "memberdef.h"
#include "membername.h"
#include "doxygen.h"
#include "util.h"
26
#include "code.h"
27
#include "message.h"
28 29
#include "htmlhelp.h"
#include "language.h"
30 31 32
#include "outputlist.h"
#include "example.h"
#include "membergroup.h"
Dimitri van Heesch's avatar
Dimitri van Heesch committed
33
#include "groupdef.h"
34
#include "defargs.h"
35
#include "docparser.h"
36
#include "dot.h"
Dimitri van Heesch's avatar
Dimitri van Heesch committed
37
#include "searchindex.h"
38
#include "parserintf.h"
39
#include "marshal.h"
40
#include "objcache.h"
41 42
#include "vhdlscanner.h"
#include "vhdldocgen.h"
43 44 45

#define START_MARKER 0x4D454D5B // MEM[
#define END_MARKER   0x4D454D5D // MEM]
46 47 48 49 50

//-----------------------------------------------------------------------------

int MemberDef::s_indentLevel = 0;

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
//-----------------------------------------------------------------------------

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;
}

87
static bool writeDefArgumentList(OutputList &ol,ClassDef *cd,
88
                                 const QCString & /*scopeName*/,MemberDef *md)
89
{
90
  LockingPtr<ArgumentList> defArgList=(md->isDocsForDefinition()) ? 
91 92
                             md->argumentList() : md->declArgumentList();
  //printf("writeDefArgumentList `%s' isDocsForDefinition()=%d\n",md->name().data(),md->isDocsForDefinition());
93
  if (defArgList==0 || md->isProperty()) 
94 95 96
  {
    return FALSE; // member has no function like argument list
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
97
  if (!md->isDefine()) ol.docify(" ");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
98

Dimitri van Heesch's avatar
Dimitri van Heesch committed
99
  //printf("writeDefArgList(%d)\n",defArgList->count());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
100 101
  ol.pushGeneratorState();
  ol.disableAllBut(OutputGenerator::Html);
102 103 104 105 106
  {
    // html
    ol.endMemberDocName();
    ol.startParameterList(!md->isObjCMethod()); 
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
107 108
  ol.enableAll();
  ol.disable(OutputGenerator::Html);
109 110 111 112 113
  {
    // other formats
    if (!md->isObjCMethod()) ol.docify("("); // start argument list
    ol.endMemberDocName();
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
114 115 116
  ol.popGeneratorState();
  //printf("===> name=%s isDefine=%d\n",md->name().data(),md->isDefine());

117
  Argument *a=defArgList->first();
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
  QCString cName;
  if (cd)
  {
    cName=cd->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 (cd->templateArguments())
    {
      cName=tempArgListToString(cd->templateArguments()); 
      //printf("2. cName=%s\n",cName.data());
    }
    else // no template specifier
    {
      cName.resize(0);
    }
  }
  //printf("~~~ %s cName=%s\n",md->name().data(),cName.data());
140

141
  //if (!md->isDefine()) ol.startParameter(TRUE); else ol.docify(" ");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
142
  bool first=TRUE;
143
  bool paramTypeStarted=FALSE;
144 145
  while (a)
  {
146 147 148 149 150
    if (md->isDefine() || first) 
    {
      ol.startParameterType(first,md->isObjCMethod()?"dummy":0);
      paramTypeStarted=TRUE;
    }
151 152 153 154 155 156 157 158 159
    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; 

    // or use the following to put the function pointer as it appears in
    // the prototype.
Dimitri van Heesch's avatar
Dimitri van Heesch committed
160
    //bool hasFuncPtrType=vp!=-1 && wp!=-1 && wp<vp; 
161

Dimitri van Heesch's avatar
Dimitri van Heesch committed
162
    if (!a->attrib.isEmpty() && !md->isObjCMethod()) // argument has an IDL attribute
163 164 165
    {
      ol.docify(a->attrib+" ");
    }
166
    if (hasFuncPtrType) // argument type is a function pointer
167
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
168
      //printf("a->type=`%s' a->name=`%s'\n",a->type.data(),a->name.data());
169
      QCString n=a->type.left(vp);
170
      if (hasFuncPtrType) n=a->type.left(wp);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
171
      if (md->isObjCMethod()) { n.prepend("("); n.append(")"); }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
172
      if (!cName.isEmpty()) n=addTemplateNames(n,cd->name(),cName);
173
      linkifyText(TextGeneratorOLImpl(ol),cd,md->getBodyDef(),md->name(),n);
174 175 176 177
    }
    else // non-function pointer type
    {
      QCString n=a->type;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
178
      if (md->isObjCMethod()) { n.prepend("("); n.append(")"); }
179 180 181 182 183
      if (a->type!="...")
      {
        if (!cName.isEmpty()) n=addTemplateNames(n,cd->name(),cName);
        linkifyText(TextGeneratorOLImpl(ol),cd,md->getBodyDef(),md->name(),n);
      }
184
    }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
185 186
    if (!md->isDefine())
    {
187 188 189 190 191
      if (paramTypeStarted) 
      {
        ol.endParameterType();
        paramTypeStarted=FALSE;
      }
192
      ol.startParameterName(defArgList->count()<2);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
193
    }
194 195 196 197
    if (hasFuncPtrType)
    {
      ol.docify(a->type.mid(wp,vp-wp)); 
    }
198
    if (!a->name.isEmpty() || (a->name.isEmpty() && a->type=="...")) // argument has a name
199
    { 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
200
      if (!hasFuncPtrType)
201 202 203
      {
        ol.docify(" ");
      }
204 205 206
      ol.disable(OutputGenerator::Man);
      ol.startEmphasis();
      ol.enable(OutputGenerator::Man);
207
      if (a->name.isEmpty()) ol.docify(a->type); else ol.docify(a->name);
208 209 210 211
      ol.disable(OutputGenerator::Man);
      ol.endEmphasis();
      ol.enable(OutputGenerator::Man);
    }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
212 213 214 215
    if (!a->array.isEmpty())
    {
      ol.docify(a->array);
    }
216 217
    if (hasFuncPtrType) // write the part of the argument type 
                        // that comes after the name
218
    {
219
      linkifyText(TextGeneratorOLImpl(ol),cd,md->getBodyDef(),
Dimitri van Heesch's avatar
Dimitri van Heesch committed
220
                  md->name(),a->type.right(a->type.length()-vp));
221
    }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
222
    if (!a->defval.isEmpty()) // write the default value
223 224
    {
      QCString n=a->defval;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
225
      if (!cName.isEmpty()) n=addTemplateNames(n,cd->name(),cName);
226
      ol.docify(" = ");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
227 228 229 230 231

      ol.startTypewriter();
      linkifyText(TextGeneratorOLImpl(ol),cd,md->getBodyDef(),md->name(),n,FALSE,TRUE,TRUE); 
      ol.endTypewriter();

232
    }
233
    a=defArgList->next();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
234 235
    if (a) 
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
236
      if (!md->isObjCMethod()) ol.docify(", "); // there are more arguments
237 238
      if (!md->isDefine()) 
      {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
239
        QCString key;
240
        if (md->isObjCMethod() && a->attrib.length()>=2)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
241 242 243
        {
          //printf("Found parameter keyword %s\n",a->attrib.data());
          // strip [ and ]
244 245
          key=a->attrib.mid(1,a->attrib.length()-2);
          if (key!=",") key+=":"; // for normal keywords add colon
Dimitri van Heesch's avatar
Dimitri van Heesch committed
246
        }
247
        ol.endParameterName(FALSE,FALSE,!md->isObjCMethod());
248 249 250 251
        if (paramTypeStarted) 
        {
          ol.endParameterType();
        }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
252
        ol.startParameterType(FALSE,key);
253 254 255 256 257
        paramTypeStarted=TRUE;
      }
      else
      {
        ol.endParameterName(FALSE,FALSE,TRUE);
258
      }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
259
    }
260
    first=FALSE;
261
  }
262
  ol.pushGeneratorState();
263
  bool htmlOn = ol.isEnabled(OutputGenerator::Html);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
264 265
  ol.disable(OutputGenerator::Html);
  //if (!first) ol.writeString("&nbsp;");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
266
  if (!md->isObjCMethod()) ol.docify(")"); // end argument list
Dimitri van Heesch's avatar
Dimitri van Heesch committed
267
  ol.enableAll();
268
  ol.disableAllBut(OutputGenerator::Html);
269
  if (!htmlOn) ol.disable(OutputGenerator::Html);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
270 271
  if (!md->isDefine()) 
  {
272
    if (first) ol.startParameterName(defArgList->count()<2);
273
    ol.endParameterName(TRUE,defArgList->count()<2,!md->isObjCMethod());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
274 275 276 277
  }
  else 
  {
    ol.endParameterType();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
278
    ol.startParameterName(TRUE);
279
    ol.endParameterName(TRUE,TRUE,!md->isObjCMethod());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
280
  }
281
  ol.popGeneratorState();
282 283 284 285
  if (md->extraTypeChars())
  {
    ol.docify(md->extraTypeChars());
  }
286
  if (defArgList->constSpecifier)
287 288 289
  {
    ol.docify(" const");
  }
290
  if (defArgList->volatileSpecifier)
291 292 293
  {
    ol.docify(" volatile");
  }
294
  return TRUE;
295 296
}

297
static void writeTemplatePrefix(OutputList &ol,ArgumentList *al)
298 299 300 301 302 303
{
  ol.docify("template<");
  Argument *a=al->first();
  while (a)
  {
    ol.docify(a->type);
304
    ol.docify(" ");
305 306 307 308 309 310 311 312 313 314 315 316
    ol.docify(a->name);
    if (a->defval.length()!=0)
    {
      ol.docify(" = ");
      ol.docify(a->defval);
    } 
    a=al->next();
    if (a) ol.docify(", ");
  }
  ol.docify("> ");
}

317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
QCString extractDirection(QCString &docs)
{
  QRegExp re("\\[[^\\]]+\\]"); // [...]
  int l=0;
  if (re.match(docs,0,&l)==0)
  {
    int  inPos  = docs.find("in", 1,FALSE);
    int outPos  = docs.find("out",1,FALSE);
    bool input  =  inPos!=-1 &&  inPos<l;
    bool output = outPos!=-1 && outPos<l;
    if (input || output) // in,out attributes
    {
      docs = docs.mid(l); // strip attributes
      if (input && output) return "[in,out]";
      else if (input)      return "[in]";
      else if (output)     return "[out]";
    }
  }
  return QCString();
}

338 339 340 341 342 343 344 345 346 347
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------

class MemberDefImpl
{
  public:
    MemberDefImpl();
   ~MemberDefImpl();
    void init(Definition *def,const char *t,const char *a,const char *e,
348 349 350
              Protection p,Specifier v,bool s,Relationship r,
              MemberDef::MemberType mt,const ArgumentList *tal,
              const ArgumentList *al
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
             );

    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
    MemberDef  *annEnumType;  // the annonymous 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 type
    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
383
    QCString extraTypeChars;  // extra type info found after the argument list
384 385 386 387 388 389 390 391 392 393 394 395
    int initLines;            // number of lines in the initializer

    int  memSpec;             // The specifiers present for this member
    MemberDef::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
396
    ArgumentList *typeConstraints; // type constraints for template parameters
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418
    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;
419
    QCString cachedResolvedType;
420 421
    
    // inbody documentation
422 423 424
    //int inbodyLine;
    //QCString inbodyFile;
    //QCString inbodyDocs;
425 426 427 428 429 430 431 432 433 434 435 436 437

    // 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;
438
    Relationship related;     // relationship of this to the class
439 440 441 442 443 444 445 446 447 448 449 450 451
    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.
452 453

    ClassDef *category;
454 455 456 457 458 459 460 461 462
};

MemberDefImpl::MemberDefImpl() :
    enumFields(0),
    redefinedBy(0),
    exampleSDict(0),
    defArgList(0),
    declArgList(0),
    tArgList(0),
463
    typeConstraints(0),
464
    defTmpArgLists(0),
465 466
    classSectionSDict(0),
    category(0)
467 468 469 470 471 472 473 474 475 476
{
}

MemberDefImpl::~MemberDefImpl()
{
  delete redefinedBy;
  delete exampleSDict;
  delete enumFields;
  delete defArgList;
  delete tArgList;
477
  delete typeConstraints;
478 479 480 481 482 483 484
  delete defTmpArgLists;
  delete classSectionSDict;
  delete declArgList;
}

void MemberDefImpl::init(Definition *def,
                     const char *t,const char *a,const char *e,
485 486 487
                     Protection p,Specifier v,bool s,Relationship r,
                     MemberDef::MemberType mt,const ArgumentList *tal,
                     const ArgumentList *al
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508
                    )
{
  classDef=0;
  fileDef=0;
  redefines=0;
  relatedAlso=0;
  redefinedBy=0;
  nspace=0;
  memDef=0;
  memDec=0;
  group=0;
  grpId=-1;
  exampleSDict=0;
  enumFields=0;
  enumScope=0;
  defTmpArgLists=0;
  hasCallGraph = FALSE;
  hasCallerGraph = FALSE;
  initLines=0;
  type=t;
  if (mt==MemberDef::Typedef) type.stripPrefix("typedef ");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
509 510 511
  //  type.stripPrefix("struct ");
  //  type.stripPrefix("class " );
  //  type.stripPrefix("union " );
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
  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 = new ArgumentList;
    tArgList->setAutoDelete(TRUE);
    ArgumentListIterator ali(*tal);
    Argument *a;
    for (;(a=ali.current());++ali)
    {
      tArgList->append(new Argument(*a));
    }
  }
  else
  {
    tArgList=0;
  }
  //printf("new member al=%p\n",al);
  // copy function definition arguments (if any)
  if (al)
  {
    defArgList = new ArgumentList;
    defArgList->setAutoDelete(TRUE);
    ArgumentListIterator ali(*al);
    Argument *a;
    for (;(a=ali.current());++ali)
    {
      //printf("copy argument %s (doc=%s)\n",a->name.data(),a->docs.data());
      defArgList->append(new Argument(*a));
    }
    defArgList->constSpecifier    = al->constSpecifier;
    defArgList->volatileSpecifier = al->volatileSpecifier;
    defArgList->pureSpecifier     = al->pureSpecifier;
    //printf("defArgList(%p)->constSpecifier=%d\n",defArgList,defArgList->constSpecifier);
  }
  else
  {
    defArgList=0;
  }
  // convert function declaration arguments (if any)
  if (!args.isEmpty())
  {
    declArgList = new ArgumentList;
579
    stringToArgumentList(args,declArgList,&extraTypeChars);
580 581
    //printf("setDeclArgList %s to %s const=%d\n",args.data(),
    //    argListToString(declArgList).data(),declArgList->constSpecifier);
582 583 584 585 586 587 588 589 590 591
  }
  else
  {
    declArgList = 0;
  }
  templateMaster = 0;
  classSectionSDict = 0;
  docsForDefinition = TRUE;
  isTypedefValCached = FALSE;
  cachedTypedefValue = 0;
592
  //inbodyLine = -1;
593 594 595 596 597 598 599 600 601 602 603
  implOnly=FALSE;
  groupMember = 0;
  hasDocumentedParams = FALSE;
  hasDocumentedReturnType = FALSE;
  docProvider = 0;
  isDMember = def->getDefFileName().right(2).lower()==".d";
}


//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
604
//-----------------------------------------------------------------------------
Dimitri van Heesch's avatar
Dimitri van Heesch committed
605 606 607

/*! Creates a new member definition.
 *
Dimitri van Heesch's avatar
Dimitri van Heesch committed
608 609 610
 * \param df File containing the definition of this member.
 * \param dl Line at which the member definition was found.
 * \param t  A string representing the type of the member.
611
 * \param na A string representing the name of the member.
Dimitri van Heesch's avatar
Dimitri van Heesch committed
612
 * \param a  A string representing the arguments of the member.
613 614
 * \param e  A string representing the throw clause of the members.
 * \param p  The protection context of the member, possible values are:
Dimitri van Heesch's avatar
Dimitri van Heesch committed
615
 *           \c Public, \c Protected, \c Private.
616
 * \param v  The degree of `virtualness' of the member, possible values are:
Dimitri van Heesch's avatar
Dimitri van Heesch committed
617
 *           \c Normal, \c Virtual, \c Pure.
618
 * \param s  A boolean that is true iff the member is static.
619
 * \param r  The relationship between the class and the member.
Dimitri van Heesch's avatar
Dimitri van Heesch committed
620 621
 * \param mt The kind of member. See #MemberDef::MemberType for a list of 
 *           all types.
622 623 624
 * \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.
Dimitri van Heesch's avatar
Dimitri van Heesch committed
625 626
 */

627 628
MemberDef::MemberDef(const char *df,int dl,
                     const char *t,const char *na,const char *a,const char *e,
629
                     Protection p,Specifier v,bool s,Relationship r,MemberType mt,
Dimitri van Heesch's avatar
Dimitri van Heesch committed
630
                     const ArgumentList *tal,const ArgumentList *al
631
                    ) : Definition(df,dl,removeRedundantWhiteSpace(na))
Dimitri van Heesch's avatar
Dimitri van Heesch committed
632
{
633 634
  m_storagePos=-1;
  m_cacheHandle=-1;
635 636
  m_impl = new MemberDefImpl;
  m_impl->init(this,t,a,e,p,v,s,r,mt,tal,al);
637
  m_flushPending = FALSE;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
638 639
}

640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657
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;
   }
}


658
/*! Destroys the member definition. */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
659 660
MemberDef::~MemberDef()
{
661
  delete m_impl;
662 663 664 665 666
  if (m_cacheHandle!=-1)
  {
    Doxygen::symbolCache->del(m_cacheHandle);
    m_cacheHandle=-1;
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
667 668
}

669 670
void MemberDef::setReimplements(MemberDef *md)   
{ 
671
  makeResident();
672 673 674
  //if (redefines==0) redefines = new MemberList;
  //if (redefines->find(md)==-1) redefines->inSort(md);

675
  m_impl->redefines = md;
676 677
}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
678 679
void MemberDef::insertReimplementedBy(MemberDef *md)
{
680 681
  makeResident();
  if (m_impl->templateMaster)
682
  {
683
    m_impl->templateMaster->insertReimplementedBy(md);
684
  }
685 686
  if (m_impl->redefinedBy==0) m_impl->redefinedBy = new MemberList(MemberList::redefinedBy);
  if (m_impl->redefinedBy->findRef(md)==-1) 
687
  {
688
    m_impl->redefinedBy->inSort(md);
689
  }
690 691
}

692
MemberDef *MemberDef::reimplements() const      
693
{ 
694 695
  makeResident();
  return m_impl->redefines; 
696 697
}

698
LockingPtr<MemberList> MemberDef::reimplementedBy() const   
699
{ 
700 701
  makeResident();
  return LockingPtr<MemberList>(this,m_impl->redefinedBy); 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
702 703 704 705
}

void MemberDef::insertEnumField(MemberDef *md)
{
706 707 708
  makeResident();
  if (m_impl->enumFields==0) m_impl->enumFields=new MemberList(MemberList::enumFields);
  m_impl->enumFields->append(md);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
709 710 711 712 713
}

bool MemberDef::addExample(const char *anchor,const char *nameStr,
                           const char *file)
{
714
  makeResident();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
715
  //printf("%s::addExample(%s,%s,%s)\n",name().data(),anchor,nameStr,file);
716 717
  if (m_impl->exampleSDict==0) m_impl->exampleSDict = new ExampleSDict;
  if (m_impl->exampleSDict->find(nameStr)==0) 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
718 719 720 721 722 723
  {
    //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;
724
    m_impl->exampleSDict->inSort(nameStr,e);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
725 726 727 728 729 730 731
    return TRUE;
  }
  return FALSE; 
}

bool MemberDef::hasExamples()
{
732 733
  makeResident();
  if (m_impl->exampleSDict==0) 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
734 735
    return FALSE;
  else
736
    return m_impl->exampleSDict->count()>0;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
737 738
}

739
QCString MemberDef::getOutputFileBase() const
740
{
741
  makeResident();
742
  static bool separateMemberPages = Config_getBool("SEPARATE_MEMBER_PAGES");
743
  QCString baseName;
744 745 746 747
  //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())
748
  {
749
    return m_impl->explicitOutputFileBase;
750
  }
751
  else if (m_impl->templateMaster)
752
  {
753
    return m_impl->templateMaster->getOutputFileBase();
754
  }
755
  else if (m_impl->group)
756
  {
757
    baseName=m_impl->group->getOutputFileBase();
758
  }
759
  else if (m_impl->classDef)
760
  {
761
    baseName=m_impl->classDef->getOutputFileBase();
762
  }
763
  else if (m_impl->nspace)
764
  {
765
    baseName=m_impl->nspace->getOutputFileBase();
766
  }
767
  else if (m_impl->fileDef)
768
  {
769
    baseName=m_impl->fileDef->getOutputFileBase();
770
  }
771 772 773
  
  if (baseName.isEmpty())
  {
774
    warn(getDefFileName(),getDefLine(),
775 776 777
       "Warning: Internal inconsistency: member %s does not belong to any"
       " container!",name().data()
      );
778 779
    return "dummy";
  }
780
  else if (separateMemberPages)
781 782 783 784 785 786 787 788 789 790 791
  {
    if (getEnumScope()) // enum value, which is part of enum's documentation
    {
      baseName+="_"+getEnumScope()->anchor();
    }
    else
    {
      baseName+="_"+anchor();
    }
  }
  return baseName;
792
}
793

794 795
QCString MemberDef::getReference() const
{
796
  makeResident();
797 798 799 800 801
  QCString ref = Definition::getReference();
  if (!ref.isEmpty())
  {
    return ref;
  }
802
  if (m_impl->templateMaster)
803
  {
804
    return m_impl->templateMaster->getReference();
805
  }
806
  else if (m_impl->group)
807
  {
808
    return m_impl->group->getReference();
809
  }
810
  else if (m_impl->classDef)
811
  {
812
    return m_impl->classDef->getReference();
813
  }
814
  else if (m_impl->nspace)
815
  {
816
    return m_impl->nspace->getReference();
817
  }
818
  else if (m_impl->fileDef)
819
  {
820
    return m_impl->fileDef->getReference();
821 822 823 824 825 826
  }
  return "";
}

QCString MemberDef::anchor() const
{
827 828 829 830
  makeResident();
  QCString result=m_impl->anc;
  if (m_impl->groupAlias)     return m_impl->groupAlias->anchor();
  if (m_impl->templateMaster) return m_impl->templateMaster->anchor();
831 832 833 834
  if (m_impl->enumScope && m_impl->enumScope!=this) // avoid recursion for C#'s public enum E { E, F }
  {
    result.prepend(m_impl->enumScope->anchor());
  }
835
  if (m_impl->group) 
836
  {
837
    if (m_impl->groupMember)
838
    {
839
      result=m_impl->groupMember->anchor();
840
    }
841
    else if (getReference().isEmpty())
842 843 844 845
    {
      result.prepend("g");
    }
  }
846 847 848 849 850
  return result;
}

bool MemberDef::isLinkableInProject() const
{
851 852
  static bool extractPrivate = Config_getBool("EXTRACT_PRIVATE");
  static bool extractStatic  = Config_getBool("EXTRACT_STATIC");
853
  makeResident();
854

855
  //printf("MemberDef::isLinkableInProject(name=%s)\n",name().data());
856 857 858 859 860
  if (isHidden()) 
  {
    //printf("is hidden\n");
    return FALSE;
  }
861
  if (m_impl->templateMaster)
862
  {
863
    //printf("has template master\n");
864
    return m_impl->templateMaster->isLinkableInProject();
865 866 867 868 869 870 871 872 873 874 875
  }
  if (name().isEmpty() || name().at(0)=='@') 
  {
    //printf("name invalid\n");
    return FALSE; // not a valid or a dummy name
  }
  if (!hasDocumentation() && !isReference()) 
  {
    //printf("no docs or reference\n");
    return FALSE; // no documentation
  }
876
  if (m_impl->group && !m_impl->group->isLinkableInProject()) 
877 878 879 880
  {
    //printf("group but group not linkable!\n");
    return FALSE; // group but group not linkable
  }
881
  if (!m_impl->group && m_impl->classDef && !m_impl->classDef->isLinkableInProject()) 
882 883 884 885
  {
    //printf("in a class but class not linkable!\n");
    return FALSE; // in class but class not linkable
  }
886
  if (!m_impl->group && m_impl->nspace && !m_impl->related && !m_impl->nspace->isLinkableInProject()) 
887 888 889 890
  {
    //printf("in a namespace but namespace not linkable!\n");
    return FALSE; // in namespace but namespace not linkable
  }
891 892 893
  if (!m_impl->group && !m_impl->nspace && 
      !m_impl->related && !m_impl->classDef && 
      m_impl->fileDef && !m_impl->fileDef->isLinkableInProject()) 
894 895
  {
    //printf("in a file but file not linkable!\n");
896
    return FALSE; // in file (and not in namespace) but file not linkable
897
  }
898
  if (m_impl->prot==Private && !extractPrivate && m_impl->mtype!=Friend) 
899 900 901 902
  {
    //printf("private and invisible!\n");
    return FALSE; // hidden due to protection
  }
903
  if (m_impl->stat && m_impl->classDef==0 && !extractStatic) 
904 905 906 907 908 909 910 911 912 913
  {
    //printf("static and invisible!\n");
    return FALSE; // hidden due to staticness
  }
  //printf("linkable!\n");
  return TRUE; // linkable!
}

bool MemberDef::isLinkable() const
{
914 915
  makeResident();
  if (m_impl->templateMaster)
916
  {
917
    return m_impl->templateMaster->isLinkable();
918 919 920 921 922 923 924 925
  }
  else
  {
    return isLinkableInProject() || isReference();
  }
}


926
void MemberDef::setDefinitionTemplateParameterLists(QList<ArgumentList> *lists)
927
{
928
  if (lists)
929
  {
930 931 932
    makeResident();
    if (m_impl->defTmpArgLists) delete m_impl->defTmpArgLists;
    m_impl->defTmpArgLists = copyArgumentLists(lists);
933 934 935
  }
}

936
void MemberDef::writeLink(OutputList &ol,ClassDef *,NamespaceDef *,
937
                      FileDef *fd,GroupDef *gd,bool onlyText)
938
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
939 940
  static bool optimizeOutputJava = Config_getBool("OPTIMIZE_OUTPUT_JAVA");
  static bool hideScopeNames     = Config_getBool("HIDE_SCOPE_NAMES");
941 942
  makeResident();
  LockingPtr<MemberDef> lock(this,this);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
943
  QCString sep = optimizeOutputJava ? "." : "::";
Dimitri van Heesch's avatar
Dimitri van Heesch committed
944
  QCString n = name();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
945 946
  if (!hideScopeNames && m_impl->classDef && gd) n.prepend(m_impl->classDef->name()+sep);
  else if (!hideScopeNames && m_impl->nspace && (gd || fd)) n.prepend(m_impl->nspace->name()+sep);
947 948 949 950
  if (isObjCMethod())
  {
    if (isStatic()) ol.docify("+ "); else ol.docify("- ");
  }
951 952
  if (!onlyText) // write link
  {
953
    if (m_impl->mtype==EnumValue && getGroupDef()==0 &&          // enum value is not grouped
Dimitri van Heesch's avatar
Dimitri van Heesch committed
954 955 956 957 958 959 960 961 962 963 964
        getEnumScope() && getEnumScope()->getGroupDef()) // but its container is
    {
      GroupDef *enumValGroup = getEnumScope()->getGroupDef();
      ol.writeObjectLink(enumValGroup->getReference(),
                         enumValGroup->getOutputFileBase(),
                         anchor(),n);
    }
    else
    {
      ol.writeObjectLink(getReference(),getOutputFileBase(),anchor(),n);
    }
965 966 967 968 969 970 971
  }
  else // write only text
  {
    ol.startBold();
    ol.docify(n);
    ol.endBold();
  }
972 973
}

974 975 976
/*! If this member has an anonymous class/struct/union as its type, then
 *  this method will return the ClassDef that describes this return type.
 */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
977
ClassDef *MemberDef::getClassDefOfAnonymousType() 
978
{
979 980 981
  makeResident();
  if (m_impl->cachedAnonymousType) return m_impl->cachedAnonymousType;
  LockingPtr<MemberDef> lock(this,this);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
982 983 984 985 986 987 988 989 990 991

  QCString cname;
  if (getClassDef()!=0) 
  {
    cname=getClassDef()->name().copy();
  }
  else if (getNamespaceDef()!=0)
  {
    cname=getNamespaceDef()->name().copy();
  }
992
  QCString ltype(m_impl->type);
993
  // strip `static' keyword from ltype
994
  //if (ltype.left(7)=="static ") ltype=ltype.right(ltype.length()-7);
995
  // strip `friend' keyword from ltype
996
  ltype.stripPrefix("friend ");
997
  static QRegExp r("@[0-9]+");
998
  int l,i=r.match(ltype,0,&l);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
999
  //printf("ltype=`%s' i=%d\n",ltype.data(),i);
1000 1001 1002
  // search for the last anonymous scope in the member type
  ClassDef *annoClassDef=0;
  if (i!=-1) // found anonymous scope in type
1003
  {
1004 1005 1006
    int il=i-1,ir=i+l;
    // extract anonymous scope
    while (il>=0 && (isId(ltype.at(il)) || ltype.at(il)==':' || ltype.at(il)=='@')) il--;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1007
    if (il>0) il++; else if (il<0) il=0;
1008 1009 1010 1011 1012 1013
    while (ir<(int)ltype.length() && (isId(ltype.at(ir)) || ltype.at(ir)==':' || ltype.at(ir)=='@')) ir++;

    QCString annName = ltype.mid(il,ir-il);

    // if inside a class or namespace try to prepend the scope name
    if (!cname.isEmpty() && annName.left(cname.length()+2)!=cname+"::") 
1014
    {
1015 1016 1017
      QCString ts=stripAnonymousNamespaceScope(cname+"::"+annName);
      //printf("Member::writeDeclaration: Trying %s\n",ts.data());
      annoClassDef=getClass(ts);
1018
    }
1019 1020
    // if not found yet, try without scope name
    if (annoClassDef==0)
1021
    {
1022 1023 1024
      QCString ts=stripAnonymousNamespaceScope(annName);
      //printf("Member::writeDeclaration: Trying %s\n",ts.data());
      annoClassDef=getClass(ts);
1025
    }
1026
  }
1027
  m_impl->cachedAnonymousType = annoClassDef;
1028 1029 1030 1031 1032 1033 1034 1035
  return annoClassDef;
}
    
/*! This methods returns TRUE iff the brief section (also known as
 *  declaration section) is visible in the documentation.
 */
bool MemberDef::isBriefSectionVisible() const
{
1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051
  static bool extractStatic       = Config_getBool("EXTRACT_STATIC");
  static bool hideUndocMembers    = Config_getBool("HIDE_UNDOC_MEMBERS");
  static bool briefMemberDesc     = Config_getBool("BRIEF_MEMBER_DESC");
  static bool repeatBrief         = Config_getBool("REPEAT_BRIEF");
  static bool hideFriendCompounds = Config_getBool("HIDE_FRIEND_COMPOUNDS");
  static bool extractPrivate      = Config_getBool("EXTRACT_PRIVATE");

  //printf("Member %s grpId=%d docs=%s file=%s args=%s\n",
  //    name().data(),
  //    0,"", //grpId,grpId==-1?"<none>":Doxygen::memberDocDict[grpId]->data(),
  //    "", //getFileDef()->name().data(),
  //    argsString());

  makeResident();
  LockingPtr<MemberDef> lock(this,this);
  MemberGroupInfo *info = Doxygen::memGrpInfoDict[m_impl->grpId];
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1052
  //printf("name=%s m_impl->grpId=%d info=%p\n",name().data(),m_impl->grpId,info);
1053 1054 1055
  //QCString *pMemGrp = Doxygen::memberDocDict[grpId];
  bool hasDocs = hasDocumentation() || 
                  // part of a documented member group
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1056
                 (m_impl->grpId!=-1 && info && !(info->doc.isEmpty() && info->header.isEmpty()));
1057 1058 1059 1060 1061 1062 1063

  // only include static members with file/namespace scope if 
  // explicitly enabled in the config file
  bool visibleIfStatic = !(getClassDef()==0 && 
                           isStatic() && 
                           !extractStatic
                          );
1064

1065 1066 1067 1068 1069
  // only include members is the are documented or 
  // HIDE_UNDOC_MEMBERS is NO in the config file
  bool visibleIfDocumented = (!hideUndocMembers || 
                              hasDocs || 
                              isDocumentedFriendClass()
1070 1071
                             );

1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114
  // hide members with no detailed description and brief descriptions 
  // explicitly disabled.
  bool visibleIfEnabled = !(hideUndocMembers && 
                            documentation().isEmpty() &&
                            !briefMemberDesc && 
                            !repeatBrief
                           );

  // Hide friend (class|struct|union) declarations if HIDE_FRIEND_COMPOUNDS is true
  bool visibleIfFriendCompound = !(hideFriendCompounds &&
                                   isFriend() &&
                                   (m_impl->type=="friend class" || 
                                    m_impl->type=="friend struct" ||
                                    m_impl->type=="friend union"
                                   )
                                  );
  
  // only include members that are non-private unless EXTRACT_PRIVATE is
  // set to YES or the member is part of a group
  bool visibleIfPrivate = (protection()!=Private || 
                           extractPrivate ||
                           m_impl->mtype==Friend
                          );
  
  // hide member if it overrides a member in a superclass and has no
  // documentation of its own
  //bool visibleIfDocVirtual = !reimplements() || 
  //                           !Config_getBool("INHERIT_DOCS") ||  
  //                           hasDocs;

  // true if this member is a constructor or destructor
  bool cOrDTor = isConstructor() || isDestructor();

  // hide default constructors or destructors (no args) without
  // documentation
  bool visibleIfNotDefaultCDTor = !(cOrDTor &&
                                   m_impl->defArgList &&
                                   (m_impl->defArgList->isEmpty() ||
                                    m_impl->defArgList->first()->type == "void"
                                   ) &&
                                   !hasDocs
                                  );

1115
  //printf("visibleIfStatic=%d visibleIfDocumented=%d visibleIfEnabled=%d "
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1116
  //       "visibleIfPrivate=%d visibltIfNotDefaultCDTor=%d "
1117 1118
  //       "visibleIfFriendCompound=%d !annScope=%d\n",
  //       visibleIfStatic,visibleIfDocumented,
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1119
  //       visibleIfEnabled,visibleIfPrivate,visibleIfNotDefaultCDTor,
1120
  //       visibleIfFriendCompound,!m_impl->annScope);
1121 1122 1123 1124 1125 1126 1127 1128
  
  bool visible = visibleIfStatic     && visibleIfDocumented      && 
                 visibleIfEnabled    && visibleIfPrivate         &&
                 /*visibleIfDocVirtual &&*/ visibleIfNotDefaultCDTor && 
                 visibleIfFriendCompound &&
                 !m_impl->annScope;
  //printf("MemberDef::isBriefSectionVisible() %d\n",visible);
  return visible;
1129
}
1130

1131

1132 1133 1134 1135 1136
void MemberDef::writeDeclaration(OutputList &ol,
               ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
               bool inGroup
               )
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1137
  //printf("%s MemberDef::writeDeclaration() inGroup=%d\n",name().data(),inGroup);
1138

1139 1140
  // hide enum value, since they appear already as part of the enum, unless they
  // are explicitly grouped.
1141 1142 1143
  makeResident();
  if (!inGroup && m_impl->mtype==EnumValue) return;
  LockingPtr<MemberDef> lock(this,this);
1144

1145
  // hide members whose brief section should not be visible
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1146
  //if (!isBriefSectionVisible()) return;
1147

1148 1149 1150 1151
  Definition *d=0;
  ASSERT (cd!=0 || nd!=0 || fd!=0 || gd!=0); // member should belong to something
  if (cd) d=cd; else if (nd) d=nd; else if (fd) d=fd; else d=gd;

1152
  // write tag file information of this member
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1153
  if (!Config_getString("GENERATE_TAGFILE").isEmpty() && !isReference())
1154 1155
  {
    Doxygen::tagFile << "    <member kind=\"";
1156
    switch (m_impl->mtype)
1157
    {
1158 1159 1160
      case Define:      Doxygen::tagFile << "define";      break;
      case EnumValue:   Doxygen::tagFile << "enumvalue";   break;
      case Property:    Doxygen::tagFile << "property";    break;
1161
      case Event:       Doxygen::tagFile << "event";       break;
1162 1163 1164 1165 1166
      case Variable:    Doxygen::tagFile << "variable";    break;
      case Typedef:     Doxygen::tagFile << "typedef";     break;
      case Enumeration: Doxygen::tagFile << "enumeration"; break;
      case Function:    Doxygen::tagFile << "function";    break;
      case Signal:      Doxygen::tagFile << "signal";      break;
1167
      //case Prototype:   Doxygen::tagFile << "prototype";   break;
1168 1169 1170
      case Friend:      Doxygen::tagFile << "friend";      break;
      case DCOP:        Doxygen::tagFile << "dcop";        break;
      case Slot:        Doxygen::tagFile << "slot";        break;
1171
    }
1172
    if (m_impl->prot!=Public)
1173
    {
1174
      Doxygen::tagFile << "\" protection=\"";
1175 1176 1177
      if (m_impl->prot==Protected)    Doxygen::tagFile << "protected";
      else if (m_impl->prot==Package) Doxygen::tagFile << "package";
      else /* Private */              Doxygen::tagFile << "private"; 
1178
    }
1179
    if (m_impl->virt!=Normal)
1180
    {
1181
      Doxygen::tagFile << "\" virtualness=\"";
1182 1183
      if (m_impl->virt==Virtual) Doxygen::tagFile << "virtual";
      else /* Pure */            Doxygen::tagFile << "pure"; 
1184
    }
1185
    if (isStatic())
1186
    {
1187
      Doxygen::tagFile << "\" static=\"yes";
1188
    }
1189
    Doxygen::tagFile << "\">" << endl;
1190
    Doxygen::tagFile << "      <type>" << convertToXML(typeString()) << "</type>" << endl;
1191
    Doxygen::tagFile << "      <name>" << convertToXML(name()) << "</name>" << endl;
1192
    Doxygen::tagFile << "      <anchorfile>" << convertToXML(getOutputFileBase()+Doxygen::htmlFileExtension) << "</anchorfile>" << endl;
1193 1194 1195 1196 1197 1198
    Doxygen::tagFile << "      <anchor>" << convertToXML(anchor()) << "</anchor>" << endl;
    Doxygen::tagFile << "      <arglist>" << convertToXML(argsString()) << "</arglist>" << endl;
    writeDocAnchorsToTagFile();
    Doxygen::tagFile << "    </member>" << endl;
  }

1199
  // write search index info
1200 1201 1202 1203 1204 1205
  //if (Config_getBool("SEARCHENGINE") && !isReference())
  //{
  //  Doxygen::searchIndex->setCurrentDoc(qualifiedName(),getOutputFileBase(),anchor());
  //  Doxygen::searchIndex->addWord(localName(),TRUE);
  //  Doxygen::searchIndex->addWord(qualifiedName(),FALSE);
  //}
1206

1207
  QCString cname  = d->name();
1208
  QCString cfname = getOutputFileBase();
1209
  //QCString osname = cname;
1210 1211
  // in case of class members that are put in a group the name of the outerscope
  // differs from the cname.
1212
  //if (getOuterScope()) osname=getOuterScope()->name();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1213

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1214 1215 1216
  //HtmlHelp *htmlHelp=0;
  //bool hasHtmlHelp = Config_getBool("GENERATE_HTML") && Config_getBool("GENERATE_HTMLHELP");
  //if (hasHtmlHelp) htmlHelp = HtmlHelp::getInstance();
1217 1218

  // search for the last anonymous scope in the member type
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1219
  ClassDef *annoClassDef=getClassDefOfAnonymousType();
1220 1221

  // start a new member declaration
1222
  bool isAnonymous = annoClassDef || m_impl->annMemb || m_impl->annEnumType;
1223
  ///printf("startMemberItem for %s\n",name().data());
1224
  ol.startMemberItem( isAnonymous ? 1 : m_impl->tArgList ? 3 : 0);
1225 1226

  // If there is no detailed description we need to write the anchor here.
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1227
  bool detailsVisible = isDetailedSectionLinkable();
1228
  if (!detailsVisible && !m_impl->annMemb)
1229 1230 1231
  {
    QCString doxyName=name().copy();
    if (!cname.isEmpty()) doxyName.prepend(cname+"::");
1232 1233
    QCString doxyArgs=argsString();
    ol.startDoxyAnchor(cfname,cname,anchor(),doxyName,doxyArgs);
1234 1235 1236

    ol.pushGeneratorState();
    ol.disable(OutputGenerator::Man);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1237
    ol.disable(OutputGenerator::Latex);
1238 1239 1240
    ol.docify("\n");
    ol.popGeneratorState();
  }
1241

1242
  if (annoClassDef || m_impl->annMemb)
1243 1244
  {
    int j;
1245
    for (j=0;j<s_indentLevel;j++) 
1246
    {
1247
      ol.writeNonBreakableSpace(3);
1248
    }
1249 1250
  }

1251
  // *** write template lists
1252
  if (m_impl->tArgList)
1253
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1254
    if (!isAnonymous) ol.startMemberTemplateParams();
1255
    writeTemplatePrefix(ol,m_impl->tArgList);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1256
    if (!isAnonymous) ol.endMemberTemplateParams();
1257 1258
  }

1259
  // *** write type
1260 1261
  QCString ltype(m_impl->type);
  if (m_impl->mtype==Typedef) ltype.prepend("typedef ");
1262
  // strip `friend' keyword from ltype
1263
  ltype.stripPrefix("friend ");
1264 1265
  static QRegExp r("@[0-9]+");

1266
  bool endAnonScopeNeeded=FALSE;
1267 1268 1269 1270 1271 1272 1273
  int l,i=r.match(ltype,0,&l);
  if (i!=-1) // member has an anonymous type
  {
    //printf("annoClassDef=%p annMemb=%p scopeName=`%s' anonymous=`%s'\n",
    //    annoClassDef,annMemb,cname.data(),ltype.mid(i,l).data());

    if (annoClassDef) // type is an anonymous compound
1274
    {
1275
      int ir=i+l;
1276 1277
      //printf("<<<<<<<<<<<<<<\n");
      ol.startAnonTypeScope(s_indentLevel++);
1278
      annoClassDef->writeDeclaration(ol,m_impl->annMemb,inGroup);
1279
      //printf(">>>>>>>>>>>>>> startMemberItem(2)\n");
1280 1281
      ol.startMemberItem(2);
      int j;
1282
      for (j=0;j< s_indentLevel-1;j++) 
1283 1284 1285 1286 1287 1288 1289 1290 1291 1292
      {
        ol.writeNonBreakableSpace(3);
      }
      QCString varName=ltype.right(ltype.length()-ir).stripWhiteSpace();
      //printf(">>>>>> indDepth=%d ltype=`%s' varName=`%s'\n",indDepth,ltype.data(),varName.data());
      ol.docify("}");
      if (varName.isEmpty() && (name().isEmpty() || name().at(0)=='@')) 
      {
        ol.docify(";"); 
      }
1293
      endAnonScopeNeeded=TRUE;
1294
    }
1295
    else
1296
    {
1297
      if (getAnonymousEnumType()) // type is an anonymous enum
1298
      {
1299
        linkifyText(TextGeneratorOLImpl(ol),d,getBodyDef(),name(),ltype.left(i),TRUE); 
1300 1301
        getAnonymousEnumType()->writeEnumDeclaration(ol,cd,nd,fd,gd);
        //ol+=*getAnonymousEnumType()->enumDecl();
1302
        linkifyText(TextGeneratorOLImpl(ol),d,m_impl->fileDef,name(),ltype.right(ltype.length()-i-l),TRUE); 
1303
      }
1304
      else
1305
      {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1306
        ltype = ltype.left(i) + " { ... } " + removeAnonymousScopes(ltype.right(ltype.length()-i-l));
1307
        linkifyText(TextGeneratorOLImpl(ol),d,getBodyDef(),name(),ltype,TRUE); 
1308 1309
      }
    }
1310
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1311 1312 1313 1314
  else if (ltype=="@") // rename type from enum values
  {
    ltype="";
  }
1315 1316
  else
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1317 1318 1319 1320 1321
    if (isObjCMethod())
    {
      ltype.prepend("(");
      ltype.append(")");
    }
1322
    linkifyText(TextGeneratorOLImpl(ol),d,getBodyDef(),name(),ltype,TRUE); 
1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333
  }
  bool htmlOn = ol.isEnabled(OutputGenerator::Html);
  if (htmlOn && Config_getBool("HTML_ALIGN_MEMBERS") && !ltype.isEmpty())
  {
    ol.disable(OutputGenerator::Html);
  }
  if (!ltype.isEmpty()) ol.docify(" ");
  if (htmlOn) 
  {
    ol.enable(OutputGenerator::Html);
  }
1334

1335
  if (m_impl->annMemb) 
1336 1337 1338 1339 1340 1341 1342 1343
  {
    ol.pushGeneratorState();
    ol.disableAllBut(OutputGenerator::Html);
    ol.writeNonBreakableSpace(3);
    ol.popGeneratorState();
  }
  else
  {
1344
    ol.insertMemberAlign(m_impl->tArgList!=0);
1345
  }
1346

1347
  // *** write name
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1348
  if (!name().isEmpty() && name().at(0)!='@') // hide annonymous stuff 
1349
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1350
    //printf("Member name=`%s gd=%p md->groupDef=%p inGroup=%d isLinkable()=%d\n",name().data(),gd,getGroupDef(),inGroup,isLinkable());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1351 1352
    if (!(name().isEmpty() || name().at(0)=='@') && // name valid
        (hasDocumentation() || isReference()) && // has docs
1353 1354
        !(m_impl->prot==Private && !Config_getBool("EXTRACT_PRIVATE") && m_impl->mtype!=Friend) && // hidden due to protection
        !(isStatic() && m_impl->classDef==0 && !Config_getBool("EXTRACT_STATIC")) // hidden due to static-ness
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1355
       )
1356
    {
1357
      if (m_impl->annMemb)
1358 1359
      {
        //printf("anchor=%s ann_anchor=%s\n",anchor(),annMemb->anchor());
1360 1361 1362 1363 1364
        m_impl->annMemb->writeLink(ol,
            m_impl->annMemb->getClassDef(),
            m_impl->annMemb->getNamespaceDef(),
            m_impl->annMemb->getFileDef(),
            m_impl->annMemb->getGroupDef()
1365
                          );
1366 1367
        m_impl->annMemb->setAnonymousUsed();
        setAnonymousUsed();
1368 1369
      }
      else
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1370
      {
1371
        //printf("writeLink %s->%d\n",name.data(),hasDocumentation());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1372
        ClassDef *rcd = cd;
1373
        if (isReference() && m_impl->classDef) rcd = m_impl->classDef; 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1374
        writeLink(ol,rcd,nd,fd,gd);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1375
      }
1376
    }
1377 1378 1379 1380 1381 1382 1383 1384
    else if (isDocumentedFriendClass())
      // if the member is an undocumented friend declaration for some class, 
      // then maybe we can link to the class
    {
      writeLink(ol,getClass(name()),0,0,0);
    }
    else
      // there is a brief member description and brief member 
1385
      // descriptions are enabled or there is no detailed description.
1386
    {
1387 1388 1389 1390 1391
      if (m_impl->annMemb)  
      {
        m_impl->annMemb->setAnonymousUsed();
        setAnonymousUsed();
      }
1392
      ClassDef *rcd = cd;
1393
      if (isReference() && m_impl->classDef) rcd = m_impl->classDef; 
1394
      writeLink(ol,rcd,nd,fd,gd,TRUE);
1395
    }
1396 1397
  }

1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416
  // add to index
  if (isEnumerate() && name().at(0)=='@')
  {
    // don't add to index
  }
  else // index member
  {
    static bool separateMemPages = Config_getBool("SEPARATE_MEMBER_PAGES");
    QCString cfname = getOutputFileBase();
    QCString cfiname = d->getOutputFileBase();
    Doxygen::indexList.addIndexItem(
        cname,                                 // level1
        name(),                                // level2
        separateMemPages ? cfname : cfiname,   // contRef
        cfname,                                // memRef
        anchor(),                              // anchor
        this);                                 // memberdef
  }

1417
  // *** write arguments
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1418
  if (argsString() && !isObjCMethod()) 
1419 1420 1421
  {
    if (!isDefine()) ol.writeString(" ");
    //ol.docify(argsString());
1422
    linkifyText(TextGeneratorOLImpl(ol),d,getBodyDef(),name(),argsString()); 
1423 1424
  }

1425
  // *** write exceptions
1426 1427 1428 1429 1430
  if (excpString())
  {
    ol.writeString(" ");
    ol.docify(excpString());
  }
1431

1432
  // *** write bitfields
1433
  if (!m_impl->bitfields.isEmpty()) // add bitfields
1434
  {
1435
    linkifyText(TextGeneratorOLImpl(ol),d,getBodyDef(),name(),m_impl->bitfields.simplifyWhiteSpace());
1436
  }
1437 1438 1439
  else if (hasOneLineInitializer()
      //!init.isEmpty() && initLines==0 && // one line initializer
      //((maxInitLines>0 && userInitLines==-1) || userInitLines>0) // enabled by default or explicitly
1440 1441 1442
          ) // add initializer
  {
    if (!isDefine()) 
1443
    {
1444
      ol.writeString(" = "); 
1445
      linkifyText(TextGeneratorOLImpl(ol),d,getBodyDef(),name(),m_impl->initializer.simplifyWhiteSpace());
1446
    }
1447
    else 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1448
    {
1449
      ol.writeNonBreakableSpace(3);
1450
      linkifyText(TextGeneratorOLImpl(ol),d,getBodyDef(),name(),m_impl->initializer);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1451
    }
1452
  }
1453

1454 1455 1456 1457 1458 1459
  if (isObjCMethod() && isImplementation())
  {
    ol.startTypewriter();
    ol.docify(" [implementation]");
    ol.endTypewriter();
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1460

1461
  if (isProperty() && (isSettable() || isGettable()))
1462 1463 1464 1465 1466
  {
      ol.writeLatexSpacing();
      ol.startTypewriter();
      ol.docify(" [");
      QStrList sl;
1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488
      if (isGettable())  sl.append("get");
      if (isSettable())  sl.append("set");
      const char *s=sl.first();
      while (s)
      {
         ol.docify(s);
         s=sl.next();
         if (s) ol.docify(", ");
      }
      ol.docify("]");
      ol.endTypewriter();
  }

  if (isEvent() && (isAddable() || isRemovable() || isRaisable()))
  {
      ol.writeLatexSpacing();
      ol.startTypewriter();
      ol.docify(" [");
      QStrList sl;
      if (isAddable())   sl.append("add");
      if (isRemovable()) sl.append("remove");
      if (isRaisable())  sl.append("raise");
1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499
      const char *s=sl.first();
      while (s)
      {
         ol.docify(s);
         s=sl.next();
         if (s) ol.docify(", ");
      }
      ol.docify("]");
      ol.endTypewriter();
  }

1500
  if (!detailsVisible && !m_impl->annMemb)
1501 1502 1503
  {
    ol.endDoxyAnchor(cfname,anchor());
  }
1504

1505 1506 1507
  //printf("endMember %s annoClassDef=%p annEnumType=%p\n",
  //    name().data(),annoClassDef,annEnumType);
  ol.endMemberItem();
1508 1509 1510 1511
  if (endAnonScopeNeeded) 
  {
    ol.endAnonTypeScope(--s_indentLevel);
  }
1512 1513

  // write brief description
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1514
  if (!briefDescription().isEmpty() && 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1515 1516 1517
      Config_getBool("BRIEF_MEMBER_DESC") 
      /* && !annMemb */
     )
1518 1519
  {
    ol.startMemberDescription();
1520 1521 1522
    ol.parseDoc(briefFile(),briefLine(),
                getOuterScope()?getOuterScope():d,this,briefDescription(),
                TRUE,FALSE,0,TRUE,FALSE);
1523
    if (detailsVisible) 
1524
    {
1525 1526
      ol.pushGeneratorState();
      ol.disableAllBut(OutputGenerator::Html);
1527
      //ol.endEmphasis();
1528
      ol.docify(" ");
1529
      if (m_impl->group!=0 && gd==0) // forward link to the group
1530
      {
1531
        ol.startTextLink(getOutputFileBase(),anchor());
1532
      }
1533
      else // local link
1534 1535
      {
        ol.startTextLink(0,anchor());
1536
      }
1537
      ol.endTextLink();
1538
      //ol.startEmphasis();
1539
      ol.popGeneratorState();
1540
    }
1541
    ol.endMemberDescription();
1542
  }
1543
  warnIfUndocumented();
1544 1545
}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1546
bool MemberDef::isDetailedSectionLinkable() const          
1547
{ 
1548 1549 1550 1551 1552 1553 1554 1555
  static bool extractAll        = Config_getBool("EXTRACT_ALL");
  static bool alwaysDetailedSec = Config_getBool("ALWAYS_DETAILED_SEC");
  static bool repeatBrief       = Config_getBool("REPEAT_BRIEF");
  static bool briefMemberDesc   = Config_getBool("BRIEF_MEMBER_DESC");
  static bool hideUndocMembers  = Config_getBool("HIDE_UNDOC_MEMBERS");
  static bool extractStatic     = Config_getBool("EXTRACT_STATIC");
  static bool extractPrivate    = Config_getBool("EXTRACT_PRIVATE");

1556
  makeResident();
1557 1558 1559
  // the member has details documentation for any of the following reasons
  bool docFilter = 
         // treat everything as documented
1560
         extractAll ||          
1561 1562
         // has detailed docs
         !documentation().isEmpty() ||             
1563 1564
         // has inbody docs
         !inbodyDocumentation().isEmpty() ||
1565
         // is an enum with values that are documented
1566
         (m_impl->mtype==Enumeration && m_impl->docEnumValues) ||  
1567
         // is documented enum value
1568
         (m_impl->mtype==EnumValue && !briefDescription().isEmpty()) || 
1569
         // has brief description that is part of the detailed description
1570
         (!briefDescription().isEmpty() &&           // has brief docs
1571 1572 1573
          (alwaysDetailedSec &&  // they or visible in
           repeatBrief ||        // detailed section or
           !briefMemberDesc      // they are explicitly not
1574
          )                                          // shown in brief section
1575 1576
         ) ||
         // has a multi-line initialization block
1577
         //(initLines>0 && initLines<maxInitLines) || 
1578
         (hasMultiLineInitializer() && !hideUndocMembers) ||
1579
         // has one or more documented arguments
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1580 1581 1582 1583
         (m_impl->defArgList!=0 && m_impl->defArgList->hasDocumentation()) ||
         // has user comments
         Doxygen::userComments
         ; 
1584 1585
         
  // this is not a global static or global statics should be extracted
1586
  bool staticFilter = getClassDef()!=0 || !isStatic() || extractStatic; 
1587
         
1588 1589
  // only include members that are non-private unless EXTRACT_PRIVATE is
  // set to YES or the member is part of a group
1590
  bool privateFilter = (protection()!=Private || extractPrivate ||
1591
                           m_impl->mtype==Friend
1592 1593
                          );

1594 1595 1596
  // member is part of an anonymous scope that is the type of
  // another member in the list.
  //
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1597
  //bool inAnonymousScope = !briefDescription().isEmpty() && annUsed;
1598

1599 1600 1601 1602
  // hide friend (class|struct|union) member if HIDE_FRIEND_COMPOUNDS
  // is true
  bool friendCompoundFilter = !(Config_getBool("HIDE_FRIEND_COMPOUNDS") &&
                                isFriend() &&
1603 1604 1605
                                (m_impl->type=="friend class" || 
                                 m_impl->type=="friend struct" ||
                                 m_impl->type=="friend union"
1606 1607 1608
                                )
                               );
  
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1609
  return ((docFilter && staticFilter && privateFilter && friendCompoundFilter) /*|| inAnonymousScope*/);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1610 1611
}

1612
bool MemberDef::isDetailedSectionVisible(bool inGroup,bool inFile) const          
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1613
{ 
1614 1615
  static bool separateMemPages = Config_getBool("SEPARATE_MEMBER_PAGES");
  bool groupFilter = getGroupDef()==0 || inGroup || separateMemPages; 
1616
  bool fileFilter  = getNamespaceDef()==0 || !inFile;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1617

1618 1619
  bool visible = isDetailedSectionLinkable() && groupFilter && fileFilter && 
                 !isReference();
1620 1621
  //printf("MemberDef::isDetailedSectionVisible() %d\n",visible);
  return visible;
1622 1623
}

1624 1625 1626
/*! Writes the "detailed documentation" section of this member to
 *  all active output formats.
 */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1627
void MemberDef::writeDocumentation(MemberList *ml,OutputList &ol,
1628
                                   const char *scName,
1629
                                   Definition *container,
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1630 1631
                                   bool inGroup,
                                   bool showEnumValues
1632
                                  )
1633
{
1634
  // if this member is in a group find the real scope name.
1635
  bool hasParameterList = FALSE;
1636 1637
  bool inFile = container->definitionType()==Definition::TypeFile;
  bool hasDocs = isDetailedSectionVisible(inGroup,inFile);
1638
  static bool separateMemPages = Config_getBool("SEPARATE_MEMBER_PAGES");
1639
  static bool optVhdl          = Config_getBool("OPTIMIZE_OUTPUT_VHDL");
1640 1641
  //printf("MemberDef::writeDocumentation(): name=`%s' hasDocs=`%d' containerType=%d inGroup=%d\n",
  //    name().data(),hasDocs,container->definitionType(),inGroup);
1642
  if ( !hasDocs ) return;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1643
  if (isEnumValue() && !showEnumValues) return;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1644

1645 1646 1647
  makeResident();
  LockingPtr<MemberDef> lock(this,this);

1648
  QCString scopeName = scName;
1649
  QCString memAnchor = anchor();
1650
  QCString ciname = container->name();
1651
  if (container->definitionType()==TypeGroup)
1652
  {
1653 1654 1655
    if (getClassDef())          scopeName=getClassDef()->name();
    else if (getNamespaceDef()) scopeName=getNamespaceDef()->name();
    else if (getFileDef())      scopeName=getFileDef()->name();
1656
    ciname = ((GroupDef *)container)->groupTitle();
1657
  }
1658 1659 1660 1661 1662
  else if (container->definitionType()==TypeFile && getNamespaceDef())
  { // member is in a namespace, but is written as part of the file documentation
    // as well, so we need to make sure its label is unique.
    memAnchor.prepend("file_");
  }
1663

1664
  QCString cname  = container->name();
1665 1666
  QCString cfname = getOutputFileBase();
  QCString cfiname = container->getOutputFileBase();
1667

1668 1669
  // the next part is moved to declaration
  //if (isEnumerate() && name().at(0)=='@')
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1670
  //{
1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681
  //  // don't add to index
  //}
  //else
  //{
  //  Doxygen::indexList.addIndexItem(
  //      ciname,                                // level1
  //      name(),                                // level2
  //      separateMemPages ? cfname : cfiname,   // contRef
  //      cfname,                                // memRef
  //      memAnchor,                             // anchor
  //      this);                                 // memberdef
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1682
  //}
1683 1684

  // get member name
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1685
  QCString doxyName=name();
1686 1687
  // prepend scope if there is any. TODO: make this optional for C only docs
  if (scopeName) doxyName.prepend((QCString)scopeName+"::");
1688
  QCString doxyArgs=argsString();
1689

1690 1691 1692 1693 1694
  QCString ldef = definition();
  //printf("member `%s' def=`%s'\n",name().data(),ldef.data());
  if (isEnumerate()) 
  {
    if (name().at(0)=='@')
1695
    {
1696
      ldef = "anonymous enum";
1697
    }
1698 1699 1700 1701 1702
    else
    {
      ldef.prepend("enum ");
    }
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1703 1704 1705 1706 1707 1708 1709
  else if (isEnumValue())
  {
    if (ldef.at(0)=='@')
    {
      ldef=ldef.mid(2);
    }
  }
1710 1711
  int i=0,l;
  static QRegExp r("@[0-9]+");
1712

1713
  //----------------------------------------
1714

1715
  ol.pushGeneratorState();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1716

1717

1718 1719 1720 1721 1722 1723 1724
  if ((isVariable() || isTypedef()) && (i=r.match(ldef,0,&l))!=-1)
  {
    // find enum type and insert it in the definition
    MemberListIterator vmli(*ml);
    MemberDef *vmd;
    bool found=FALSE;
    for ( ; (vmd=vmli.current()) && !found ; ++vmli)
1725
    {
1726
      if (vmd->isEnumerate() && ldef.mid(i,l)==vmd->name())
1727
      {
1728
        ol.startDoxyAnchor(cfname,cname,memAnchor,doxyName,doxyArgs);
1729
        ol.startMemberDoc(cname,name(),memAnchor,name());
1730 1731 1732 1733 1734
        linkifyText(TextGeneratorOLImpl(ol),container,getBodyDef(),name(),ldef.left(i));
        vmd->writeEnumDeclaration(ol,getClassDef(),getNamespaceDef(),getFileDef(),getGroupDef());
        linkifyText(TextGeneratorOLImpl(ol),container,getBodyDef(),name(),ldef.right(ldef.length()-i-l));

        found=TRUE;
1735
      }
1736
    }
1737
    if (!found) // anonymous compound
1738
    {
1739
      //printf("Anonymous compound `%s'\n",cname.data());
1740
      ol.startDoxyAnchor(cfname,cname,memAnchor,doxyName,doxyArgs);
1741
      ol.startMemberDoc(cname,name(),memAnchor,name());
1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757
      // strip anonymous compound names from definition
      int si=ldef.find(' '),pi,ei=i+l;
      if (si==-1) si=0;
      while ((pi=r.match(ldef,i+l,&l))!=-1) ei=i=pi+l;
      // first si characters of ldef contain compound type name
      ol.startMemberDocName(isObjCMethod());
      ol.docify(ldef.left(si));
      ol.docify(" { ... } ");
      // last ei characters of ldef contain pointer/reference specifiers
      int ni=ldef.find("::",si);
      if (ni>=ei) ei=ni+2;
      linkifyText(TextGeneratorOLImpl(ol),container,getBodyDef(),name(),ldef.right(ldef.length()-ei));
    }
  }
  else // not an enum value
  {
1758
    ol.startDoxyAnchor(cfname,cname,memAnchor,doxyName,doxyArgs);
1759
    ol.startMemberDoc(cname,name(),memAnchor,name());
1760

1761 1762 1763 1764
    ClassDef *cd=getClassDef();
    if (!Config_getBool("HIDE_SCOPE_NAMES"))
    {
      bool first=TRUE;
1765
      if (m_impl->defTmpArgLists) 
1766 1767
        // definition has explicit template parameter declarations
      {
1768
        QListIterator<ArgumentList> ali(*m_impl->defTmpArgLists);
1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782
        ArgumentList *tal;
        for (ali.toFirst();(tal=ali.current());++ali)
        {
          if (tal->count()>0)
          {
            if (!first) ol.docify(" ");
            ol.startMemberDocPrefixItem();
            writeTemplatePrefix(ol,tal);
            ol.endMemberDocPrefixItem();
          }
        }
      }
      else // definition gets it template parameters from its class
        // (since no definition was found)
1783
      {
1784
        if (cd && !isTemplateSpecialization())
1785
        {
1786 1787 1788 1789
          QList<ArgumentList> tempParamLists;
          cd->getTemplateParameterLists(tempParamLists);
          //printf("#tempParamLists=%d\n",tempParamLists.count());
          QListIterator<ArgumentList> ali(tempParamLists);
1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800
          ArgumentList *tal;
          for (ali.toFirst();(tal=ali.current());++ali)
          {
            if (tal->count()>0)
            {
              if (!first) ol.docify(" ");
              ol.startMemberDocPrefixItem();
              writeTemplatePrefix(ol,tal);
              ol.endMemberDocPrefixItem();
            }
          }
1801
        }
1802
        if (m_impl->tArgList) // function template prefix
1803
        {
1804
          ol.startMemberDocPrefixItem();
1805
          writeTemplatePrefix(ol,m_impl->tArgList);
1806
          ol.endMemberDocPrefixItem();
1807 1808
        }
      }
1809
    }
1810

1811 1812 1813 1814 1815 1816
    ol.startMemberDocName(isObjCMethod());
    if (cd && cd->isObjectiveC())
    {
      // strip scope name
      int ep = ldef.find("::");
      if (ep!=-1) 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1817
      {
1818 1819
        int sp=ldef.findRev(' ',ep);
        if (sp!=-1)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1820
        {
1821
          ldef=ldef.left(sp+1)+ldef.mid(ep+2);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1822 1823
        }
      }
1824 1825 1826
      // strip keywords
      int dp = ldef.find(':');
      if (dp!=-1)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1827
      {
1828
        ldef=ldef.left(dp+1);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1829
      }
1830 1831 1832 1833 1834 1835
      int l=ldef.length();
      //printf("start >%s<\n",ldef.data());
      int i=l-1;
      while (i>=0 && (isId(ldef.at(i)) || ldef.at(i)==':')) i--;
      while (i>=0 && isspace((uchar)ldef.at(i))) i--;
      if (i>0)
1836
      {
1837 1838 1839
        // insert braches around the type
        QCString tmp("("+ldef.left(i+1)+")"+ldef.mid(i+1));
        ldef=tmp;
1840
      }
1841 1842
      //printf("end   >%s< i=%d\n",ldef.data(),i);
      if (isStatic()) ldef.prepend("+ "); else ldef.prepend("- ");
1843
    }
1844

1845 1846 1847 1848 1849 1850 1851 1852 1853
    if (optVhdl)
    {
      VhdlDocGen::writeVHDLTypeDocumentation(this,container,ol);
    }
    else
    {
      linkifyText(TextGeneratorOLImpl(ol),container,getBodyDef(),name(),ldef);
      hasParameterList=writeDefArgumentList(ol,cd,scopeName,this);
    }
1854

1855
    if (hasOneLineInitializer()) // add initializer
1856
    {
1857
      if (!isDefine()) 
1858
      {
1859
        ol.docify(" = "); 
1860
        linkifyText(TextGeneratorOLImpl(ol),container,getBodyDef(),name(),m_impl->initializer.simplifyWhiteSpace());
1861
      }
1862
      else 
1863
      {
1864
        ol.writeNonBreakableSpace(3);
1865
        linkifyText(TextGeneratorOLImpl(ol),container,getBodyDef(),name(),m_impl->initializer);
1866 1867
      }
    }
1868
    if (excpString()) // add exception list
1869
    {
1870 1871
      ol.docify(" ");
      linkifyText(TextGeneratorOLImpl(ol),container,getBodyDef(),name(),excpString());
1872
    }
1873
  }
1874

1875
  Specifier lvirt=virtualness();
1876

1877
  if ((!isObjCMethod() || isOptional() || isRequired()) &&
1878
      (protection()!=Public || lvirt!=Normal ||
1879 1880
       isFriend() || isRelated() || 
       (isInline() && Config_getBool("INLINE_INFO")) ||
1881
       isSignal() || isSlot() ||
1882
       isStatic() || (m_impl->classDef && m_impl->classDef!=container) ||
1883
       (m_impl->memSpec & ~Entry::Inline)!=0 
1884 1885 1886 1887 1888 1889 1890 1891
      )
     )
  {
    // write the member specifier list
    ol.writeLatexSpacing();
    ol.startTypewriter();
    ol.docify(" [");
    QStrList sl;
1892 1893 1894 1895
    if (optVhdl)
    {
      sl.append(VhdlDocGen::trTypeString(getMemberSpecifiers()));
    }
1896
    else
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1897
    {
1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923
      if (isFriend()) sl.append("friend");
      else if (isRelated()) sl.append("related");
      else
      {
        if      (Config_getBool("INLINE_INFO") && isInline()) sl.append("inline");
        if      (isExplicit())            sl.append("explicit");
        if      (isMutable())             sl.append("mutable");
        if      (isStatic())              sl.append("static");
        if      (isGettable())            sl.append("get");
        if      (isSettable())            sl.append("set");
        if      (isAddable())             sl.append("add");
        if      (isRemovable())           sl.append("remove");
        if      (isRaisable())            sl.append("raise");
        if      (isReadable())            sl.append("read");
        if      (isWritable())            sl.append("write");
        if      (isFinal())               sl.append("final");
        if      (isAbstract())            sl.append("abstract");
        if      (isOverride())            sl.append("override");
        if      (isInitonly())            sl.append("initonly");
        if      (isSealed())              sl.append("sealed");
        if      (isNew())                 sl.append("new");
        if      (isOptional())            sl.append("optional");
        if      (isRequired())            sl.append("required");
        if      (isAssign())              sl.append("assign");
        else if (isCopy())                sl.append("copy");
        else if (isRetain())              sl.append("retain");
1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935

        if (!isObjCMethod())
        {
          if      (protection()==Protected) sl.append("protected");
          else if (protection()==Private)   sl.append("private");
          else if (protection()==Package)   sl.append("package");

          if      (lvirt==Virtual)          sl.append("virtual");
          else if (lvirt==Pure)             sl.append("pure virtual");
          if      (isSignal())              sl.append("signal");
          if      (isSlot())                sl.append("slot");
        }
1936 1937 1938
      }
      if (m_impl->classDef && m_impl->classDef!=container) sl.append("inherited");
    }
1939 1940 1941 1942 1943 1944
    const char *s=sl.first();
    while (s)
    {
      ol.docify(s);
      s=sl.next();
      if (s) ol.docify(", ");
1945
    }
1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965
    ol.docify("]");
    ol.endTypewriter();
  }
  else if (isObjCMethod() && isImplementation())
  {
    ol.writeLatexSpacing();
    ol.startTypewriter();
    ol.docify(" [implementation]");
    ol.endTypewriter();
  }
  if (hasParameterList) 
  {
    ol.endParameterList();
    ol.endMemberDoc(TRUE);
  }
  else
  {
    ol.endMemberDocName();
    ol.endMemberDoc(FALSE);
  }
1966
  ol.endDoxyAnchor(cfname,memAnchor);
1967
  ol.startIndent();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1968

1969 1970 1971 1972 1973
  // FIXME:PARA
  //ol.pushGeneratorState();
  //ol.disable(OutputGenerator::RTF);
  //ol.newParagraph();
  //ol.popGeneratorState();
1974 1975 1976 1977 1978 1979 1980 1981 1982 1983

  /* write multi-line initializer (if any) */
  if (hasMultiLineInitializer()
      //initLines>0 && ((initLines<maxInitLines && userInitLines==-1) // implicitly enabled
      //                || initLines<userInitLines // explicitly enabled
      //               )
     )
  {
    //printf("md=%s initLines=%d init=`%s'\n",name().data(),initLines,init.data());
    ol.startBold();
1984
    if (m_impl->mtype==Define)
1985 1986 1987 1988
      ol.parseText(theTranslator->trDefineValue());
    else
      ol.parseText(theTranslator->trInitialValue());
    ol.endBold();
1989 1990
    ParserInterface *pIntf = Doxygen::parserManager->getParser(getDefFileExtension());
    pIntf->resetCodeParserState();
1991
    ol.startCodeFragment();
1992
    pIntf->parseCode(ol,scopeName,m_impl->initializer,FALSE,0);
1993 1994 1995
    ol.endCodeFragment();
  }

1996 1997 1998 1999 2000 2001 2002 2003 2004
  QCString brief           = briefDescription();
  QCString detailed        = documentation();
  LockingPtr<ArgumentList> docArgList = LockingPtr<ArgumentList>(this,m_impl->defArgList);
  if (m_impl->templateMaster)
  {
    brief      = m_impl->templateMaster->briefDescription();
    detailed   = m_impl->templateMaster->documentation();
    docArgList = m_impl->templateMaster->argumentList();
  }
2005 2006 2007 2008 2009 2010 2011 2012

  /* write brief description */
  if (!brief.isEmpty() && 
      (Config_getBool("REPEAT_BRIEF") || 
       !Config_getBool("BRIEF_MEMBER_DESC")
      ) 
     )  
  { 
2013 2014 2015 2016 2017
    ol.startParagraph();
    ol.parseDoc(briefFile(),briefLine(),
                getOuterScope()?getOuterScope():container,this,
                brief,FALSE,FALSE,0,TRUE,FALSE);
    ol.endParagraph();
2018 2019 2020
  }

  /* write detailed description */
2021 2022
  if (!detailed.isEmpty() || 
      !inbodyDocumentation().isEmpty())
2023 2024
  { 
    ol.parseDoc(docFile(),docLine(),getOuterScope()?getOuterScope():container,this,detailed+"\n",TRUE,FALSE);
2025
    if (!inbodyDocumentation().isEmpty())
2026
    {
2027
      ol.startParagraph();
2028
      ol.parseDoc(inbodyFile(),inbodyLine(),getOuterScope()?getOuterScope():container,this,inbodyDocumentation()+"\n",TRUE,FALSE);
2029
      ol.endParagraph();
2030
    }
2031
  }
2032
  else if (!brief.isEmpty() && (Config_getBool("REPEAT_BRIEF") ||
2033 2034
        !Config_getBool("BRIEF_MEMBER_DESC")))
  {
2035
    if (!inbodyDocumentation().isEmpty())
2036
    {
2037
      ol.parseDoc(inbodyFile(),inbodyLine(),getOuterScope()?getOuterScope():container,this,inbodyDocumentation()+"\n",TRUE,FALSE);
2038
    }
2039
  }
2040

2041

2042 2043 2044
  //printf("***** defArgList=%p name=%s docs=%s hasDocs=%d\n",
  //     defArgList, 
  //     defArgList?defArgList->hasDocumentation():-1);
2045
  if (docArgList!=0 && docArgList->hasDocumentation())
2046
  {
2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069
    QCString paramDocs;
    ArgumentListIterator ali(*docArgList);
    Argument *a;
    // convert the parameter documentation into a list of @param commands
    for (ali.toFirst();(a=ali.current());++ali)
    {
      if (a->hasDocumentation())
      {
        QCString direction = extractDirection(a->docs);
        paramDocs+="@param"+direction+" "+a->name+" "+a->docs;
      }
    }
    // feed the result to the documentation parser
    ol.parseDoc(
        docFile(),docLine(),
        getOuterScope()?getOuterScope():container,
        this,         // memberDef
        paramDocs,    // docStr
        TRUE,         // indexWords
        FALSE         // isExample
        );

#if 0  // old, now obsolete way to add parameter documentation
2070 2071 2072 2073 2074 2075 2076
    //printf("***** argumentList is documented\n");
    ol.startParamList(BaseOutputDocInterface::Param,theTranslator->trParameters()+": ");
    ol.writeDescItem();
    ol.startDescTable();
    ArgumentListIterator ali(*docArgList);
    Argument *a;
    for (ali.toFirst();(a=ali.current());++ali)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2077
    {
2078
      if (a->hasDocumentation())
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2079
      {
2080 2081 2082
        ol.startDescTableTitle();
        ol.docify(a->name);
        ol.endDescTableTitle();
2083
        QCString doc = a->docs+"\n";
2084
        ol.startDescTableData();
2085 2086
        ol.parseDoc(docFile(),docLine(),
                    getOuterScope()?getOuterScope():container,
2087
                    this,         // memberDef
2088 2089
                    a->docs+"\n", // docStr
                    TRUE,         // indexWords
2090
                    FALSE         // isExample
2091
                   );
2092
        ol.endDescTableData();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2093 2094
      }
    }
2095 2096
    ol.endDescTable();
    ol.endParamList();
2097
#endif
2098 2099
  }

2100
  // For enum, we also write the documented enum values
2101 2102 2103
  if (isEnumerate())
  {
    bool first=TRUE;
2104 2105
    LockingPtr<MemberList> fmdl=enumFieldList();
    if (fmdl!=0)
2106
    {
2107 2108
      MemberDef *fmd=fmdl->first();
      while (fmd)
2109
      {
2110
        //printf("Enum: isLinkable()=%d\n",fmd->isLinkable());
2111
        if (fmd->isLinkable())
2112
        {
2113
          if (first)
2114
          {
2115
            ol.startSimpleSect(BaseOutputDocInterface::EnumValues,0,0,theTranslator->trEnumerationValues()+": ");
2116
            ol.startDescForItem();
2117
            ol.startDescTable();
2118 2119
          }

2120 2121
          ol.addIndexItem(fmd->name(),cname);
          ol.addIndexItem(cname,fmd->name());
2122

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135
          //if (hasHtmlHelp)
          //{
          //   htmlHelp->addIndexItem(ciname,                                // level1
          //                          fmd->name(),                           // level2
          //                          separateMemPages ? cfname : cfiname,   // contRef
          //                          cfname,                                // memRef
          //                          fmd->anchor());                        // anchor
          //}
          Doxygen::indexList.addIndexItem(
                                 ciname,                                // level1
                                 fmd->name(),                           // level2
                                 separateMemPages ? cfname : cfiname,   // contRef
                                 cfname,                                // memRef
2136 2137
                                 fmd->anchor(),                         // anchor
                                 fmd);                                  // memberdef
2138 2139
          //ol.writeListItem();
          ol.startDescTableTitle(); // this enables emphasis!
2140
          ol.startDoxyAnchor(cfname,cname,fmd->anchor(),fmd->name(),fmd->argsString());
2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155
          first=FALSE;
          //ol.startEmphasis();
          ol.docify(fmd->name());
          //ol.endEmphasis();
          ol.disableAllBut(OutputGenerator::Man);
          ol.writeString(" ");
          ol.enableAll();
          ol.endDoxyAnchor(cfname,fmd->anchor());
          ol.endDescTableTitle();
          //ol.newParagraph();
          ol.startDescTableData();

          if (!fmd->briefDescription().isEmpty())
          { 
            ol.parseDoc(fmd->briefFile(),fmd->briefLine(),getOuterScope()?getOuterScope():container,fmd,fmd->briefDescription(),TRUE,FALSE);
2156
          }
2157 2158 2159 2160 2161 2162
          // FIXME:PARA
          //if (!fmd->briefDescription().isEmpty() && 
          //    !fmd->documentation().isEmpty())
          //{
          //  ol.newParagraph();
          //}
2163 2164 2165 2166 2167
          if (!fmd->documentation().isEmpty())
          { 
            ol.parseDoc(fmd->docFile(),fmd->docLine(),getOuterScope()?getOuterScope():container,fmd,fmd->documentation()+"\n",TRUE,FALSE);
          }
          ol.endDescTableData();
2168
        }
2169
        fmd=fmdl->next();
2170
      }
2171
    }
2172 2173 2174 2175
    if (!first) 
    { 
      //ol.endItemList(); 
      ol.endDescTable();
2176
      ol.endDescForItem();
2177 2178 2179 2180
      ol.endSimpleSect();
      ol.writeChar('\n'); 
    }
  }
2181

2182 2183 2184 2185 2186 2187
  MemberDef *bmd=reimplements();
  ClassDef *bcd=0;
  if (bmd && (bcd=bmd->getClassDef()))
  {
    // write class that contains a member that is reimplemented by this one
    if (bcd->isLinkable())
2188
    {
2189
      ol.startParagraph();
2190 2191
      QCString reimplFromLine; 
      if (bmd->virtualness()!=Pure && bcd->compoundType()!=ClassDef::Interface)
2192
      {
2193
        reimplFromLine = theTranslator->trReimplementedFromList(1);
2194
      }
2195
      else
2196
      {
2197 2198 2199 2200 2201 2202 2203
        reimplFromLine = theTranslator->trImplementedFromList(1);
      }
      int markerPos = reimplFromLine.find("@0");
      if (markerPos!=-1) // should always pass this.
      {
        ol.parseText(reimplFromLine.left(markerPos)); //text left from marker
        if (bmd->isLinkable()) // replace marker with link
2204
        {
2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215
          //Definition *bd=bmd->group;
          //if (bd==0) bd=bcd;
          ol.writeObjectLink(bmd->getReference(),bmd->getOutputFileBase(),
              bmd->anchor(),bcd->displayName());

          //ol.writeObjectLink(bcd->getReference(),bcd->getOutputFileBase(),
          //    bmd->anchor(),bcd->name());
          if ( bmd->isLinkableInProject() ) 
          {
            writePageRef(ol,bmd->getOutputFileBase(),bmd->anchor());
          }
2216 2217 2218
        }
        else
        {
2219 2220 2221
          ol.writeObjectLink(bcd->getReference(),bcd->getOutputFileBase(),
              0,bcd->displayName());
          if (bcd->isLinkableInProject()/* && !Config_getBool("PDF_HYPERLINKS")*/ )
2222
          {
2223
            writePageRef(ol,bcd->getOutputFileBase(),0);
2224
          }
2225 2226 2227
        }
        ol.parseText(reimplFromLine.right(
              reimplFromLine.length()-markerPos-2)); // text right from marker
2228 2229

      }
2230 2231 2232 2233
      else
      {
        err("Error: translation error: no marker in trReimplementsFromList()\n");
      }
2234
      ol.endParagraph();
2235
    }
2236 2237 2238 2239

    //ol.writeString(".");
  }

2240 2241
  LockingPtr<MemberList> bml=reimplementedBy();
  if (bml!=0)
2242 2243 2244 2245 2246 2247
  {
    MemberListIterator mli(*bml);
    MemberDef *bmd=0;
    uint count=0;
    ClassDef *bcd=0;
    for (mli.toFirst();(bmd=mli.current()) && (bcd=bmd->getClassDef());++mli)
2248
    {
2249 2250 2251 2252 2253 2254
      // count the members that directly inherit from md and for
      // which the member and class are visible in the docs.
      if ( bmd->isLinkable() && bcd->isLinkable() ) 
      {
        count++;
      }
2255
    }
2256 2257 2258 2259
    if (count>0)
    {
      mli.toFirst();
      // write the list of classes that overwrite this member
2260
      ol.startParagraph();
2261

2262
      QCString reimplInLine;
2263
      if (m_impl->virt==Pure || (m_impl->classDef && m_impl->classDef->compoundType()==ClassDef::Interface))
2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290
      {
        reimplInLine = theTranslator->trImplementedInList(count);
      }
      else
      {
        reimplInLine = theTranslator->trReimplementedInList(count);
      }
      static QRegExp marker("@[0-9]+");
      int index=0,newIndex,matchLen;
      // now replace all markers in reimplInLine with links to the classes
      while ((newIndex=marker.match(reimplInLine,index,&matchLen))!=-1)
      {
        ol.parseText(reimplInLine.mid(index,newIndex-index));
        bool ok;
        uint entryIndex = reimplInLine.mid(newIndex+1,matchLen-1).toUInt(&ok);
        //bmd=bml->at(entryIndex);

        count=0;
        // find the entryIndex-th documented entry in the inheritance list.
        for (mli.toLast();(bmd=mli.current()) && (bcd=bmd->getClassDef());--mli)
        {
          if ( bmd->isLinkable() && bcd->isLinkable()) 
          {
            if (count==entryIndex) break;
            count++;
          }
        }
2291

2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307
        if (ok && bcd && bmd) // write link for marker
        {
          //ol.writeObjectLink(bcd->getReference(),bcd->getOutputFileBase(),
          //    bmd->anchor(),bcd->name());
          ol.writeObjectLink(bmd->getReference(),bmd->getOutputFileBase(),
              bmd->anchor(),bcd->displayName());

          if (bmd->isLinkableInProject() ) 
          {
            writePageRef(ol,bmd->getOutputFileBase(),bmd->anchor());
          }
        }
        ++mli;
        index=newIndex+matchLen;
      } 
      ol.parseText(reimplInLine.right(reimplInLine.length()-index));
2308
      ol.endParagraph();
2309 2310
    }
  }
2311

2312 2313 2314 2315
  // write the list of examples that use this member
  if (hasExamples())
  {
    ol.startSimpleSect(BaseOutputDocInterface::Examples,0,0,theTranslator->trExamples()+": ");
2316
    ol.startDescForItem();
2317
    writeExample(ol,m_impl->exampleSDict);
2318
    ol.endDescForItem();
2319 2320
    ol.endSimpleSect();
  }
2321

2322 2323 2324 2325 2326
  if (m_impl->typeConstraints)
  {
    writeTypeConstraints(ol,this,m_impl->typeConstraints);
  }

2327 2328 2329 2330 2331
  // write reference to the source
  writeSourceDef(ol,cname);
  writeSourceRefs(ol,cname);
  writeSourceReffedBy(ol,cname);
  writeInlineCode(ol,cname);
2332

2333
  // write call graph
2334
  if ((m_impl->hasCallGraph || Config_getBool("CALL_GRAPH")) 
2335
      && (isFunction() || isSlot() || isSignal()) && Config_getBool("HAVE_DOT")
2336 2337
     )
  {
2338
    DotCallGraph callGraph(this,FALSE);
2339
    if (!callGraph.isTrivial() && !callGraph.isTooBig())
2340
    {
2341 2342
      msg("Generating call graph for function %s\n",qualifiedName().data());
      ol.disable(OutputGenerator::Man);
2343
      ol.startParagraph();
2344 2345 2346
      ol.startCallGraph();
      ol.parseText(theTranslator->trCallGraph());
      ol.endCallGraph(callGraph);
2347
      ol.endParagraph(); 
2348
      ol.enableAll();
2349
    }
2350
  }
2351
  if ((m_impl->hasCallerGraph || Config_getBool("CALLER_GRAPH")) 
2352
      && (isFunction() || isSlot() || isSignal()) && Config_getBool("HAVE_DOT")
2353 2354
     )
  {
2355 2356
    DotCallGraph callerGraph(this, TRUE);
    if (!callerGraph.isTrivial() && !callerGraph.isTooBig())
2357 2358 2359
    {
      msg("Generating caller graph for function %s\n",qualifiedName().data());
      ol.disable(OutputGenerator::Man);
2360
      ol.startParagraph();
2361 2362 2363
      ol.startCallGraph();
      ol.parseText(theTranslator->trCallerGraph());
      ol.endCallGraph(callerGraph);
2364
      ol.endParagraph();
2365 2366 2367
      ol.enableAll();
    }
  }
2368

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379
  if (Doxygen::userComments)
  {
    ol.pushGeneratorState();
    ol.disableAllBut(OutputGenerator::Html);
    QCString cmd = "<? $root=$_SERVER['DOCUMENT_ROOT']; "
                   "passthru(\"$root/doxynotes --lookup "+
                   getOutputFileBase()+":"+anchor()+"\") ?>";
    ol.writeString(cmd);
    ol.popGeneratorState();
  }

2380 2381
  ol.endIndent();

2382 2383 2384 2385
  // enable LaTeX again
  //if (Config_getBool("EXTRACT_ALL") && !hasDocs) ol.enable(OutputGenerator::Latex); 
  ol.popGeneratorState();

2386 2387
  //------------------------------------------------

2388 2389
  if (!Config_getBool("EXTRACT_ALL") &&
      Config_getBool("WARN_IF_UNDOCUMENTED") &&
2390 2391
      Config_getBool("WARN_NO_PARAMDOC") &&
      !Doxygen::suppressDocWarnings)
2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406
  {
    if (!hasDocumentedParams())
    {
      warn_doc_error(docFile(),docLine(),
          "Warning: parameters of member %s are not (all) documented",
          qualifiedName().data());
    }
    if (!hasDocumentedReturnType())
    {
      warn_doc_error(docFile(),docLine(),
          "Warning: return type of member %s is not documented",
          qualifiedName().data());
    }
  }

2407 2408
}

2409 2410
QCString MemberDef::memberTypeName() const
{
2411 2412
  makeResident();
  switch (m_impl->mtype)
2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429
  {
    case Define:      return "define";
    case Function:    return "function";
    case Variable:    return "variable";
    case Typedef:     return "typedef";
    case Enumeration: return "enumeration"; 
    case EnumValue:   return "enumvalue";
    case Signal:      return "signal";
    case Slot:        return "slot";
    case Friend:      return "friend";
    case DCOP:        return "dcop";
    case Property:    return "property";
    case Event:       return "event";
    default:          return "unknown";
  }
}

2430 2431
void MemberDef::warnIfUndocumented()
{
2432 2433
  makeResident();
  if (m_impl->memberGroup) return;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2434 2435
  ClassDef     *cd = getClassDef();
  NamespaceDef *nd = getNamespaceDef();
2436
  FileDef      *fd = getFileDef();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2437
  GroupDef     *gd = getGroupDef();
2438 2439 2440 2441 2442 2443
  Definition *d=0;
  const char *t=0;
  if (cd) 
    t="class", d=cd; 
  else if (nd) 
    t="namespace", d=nd; 
2444
  else if (gd)
2445
    t="group", d=gd;
2446 2447
  else
    t="file", d=fd;
2448
  static bool extractAll = Config_getBool("EXTRACT_ALL");
2449

2450 2451 2452 2453
  //printf("warnIfUndoc: d->isLinkable()=%d isLinkable()=%d "
  //       "isDocumentedFriendClass()=%d name()=%s prot=%d\n",
  //       d->isLinkable(),isLinkable(),isDocumentedFriendClass(),
  //       name().data(),prot);
2454
  if ((!hasUserDocumentation() && !extractAll) &&
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2455
      !isFriendClass() && 
2456
      name().find('@')==-1 && d->name().find('@')==-1 &&
2457
      (m_impl->prot!=Private || Config_getBool("EXTRACT_PRIVATE"))
2458 2459
     )
  {
2460
    warn_undoc(getDefFileName(),getDefLine(),"Warning: Member %s%s (%s) of %s %s is not documented.",
2461
         name().data(),argsString()?argsString():"",memberTypeName().data(),t,d->name().data());
2462
  }
2463 2464 2465
}


2466

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2467
bool MemberDef::isFriendClass() const
2468
{
2469
  makeResident();
2470
  return (isFriend() && 
2471 2472
         (m_impl->type=="friend class" || m_impl->type=="friend struct" || 
          m_impl->type=="friend union"));
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2473 2474 2475 2476
}

bool MemberDef::isDocumentedFriendClass() const
{
2477
  makeResident();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2478 2479 2480 2481 2482 2483
  ClassDef *fcd=0;
  QCString baseName=name();
  int i=baseName.find('<');
  if (i!=-1) baseName=baseName.left(i);
  return (isFriendClass() &&
         (fcd=getClass(baseName)) && fcd->isLinkable()); 
2484 2485
}

2486
bool MemberDef::hasDocumentation() const
2487
{ 
2488
  makeResident();
2489
  return Definition::hasDocumentation() || 
2490 2491
         (m_impl->mtype==Enumeration && m_impl->docEnumValues) ||  // has enum values
         (m_impl->defArgList!=0 && m_impl->defArgList->hasDocumentation()); // has doc arguments
2492
}
2493

2494
#if 0
2495 2496
bool MemberDef::hasUserDocumentation() const
{
2497
  bool hasDocs = Definition::hasUserDocumentation();
2498 2499
  return hasDocs;
}
2500
#endif
2501 2502


2503 2504
void MemberDef::setMemberGroup(MemberGroup *grp)
{
2505 2506
  makeResident();
  m_impl->memberGroup = grp;
2507
}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2508 2509 2510

bool MemberDef::visibleMemberGroup(bool hideNoHeader) 
{ 
2511 2512 2513
  makeResident();
  return m_impl->memberGroup!=0 && 
          (!hideNoHeader || m_impl->memberGroup->header()!="[NOHEADER]"); 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2514
}
2515 2516 2517

QCString MemberDef::getScopeString() const
{
2518
  makeResident();
2519
  QCString result;
2520 2521
  if (getClassDef()) result=getClassDef()->displayName();
  else if (getNamespaceDef()) result=getNamespaceDef()->displayName();
2522 2523
  return result;
}
2524

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2525
#if 0
2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547
static QCString escapeAnchor(const QCString &anchor)
{
  QCString result;
  int l = anchor.length(),i;
  for (i=0;i<l;i++)
  {
    char c = anchor.at(i);
    if ((c>='a' && c<='z') || (c>='A' && c<='Z'))
    {
      result+=c;
    }
    else
    {
      static char hexStr[]="0123456789ABCDEF";
      char escChar[]={ '_', 0, 0, 0 };
      escChar[1]=hexStr[c>>4];
      escChar[2]=hexStr[c&0xf];
      result+=escChar;
    }
  }
  return result;
}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2548
#endif
2549

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2550 2551
void MemberDef::setAnchor(const char *a)
{
2552
  makeResident();
2553 2554 2555
  //anc=a;
  a=a;
  QCString memAnchor = name();
2556
  if (!m_impl->args.isEmpty()) memAnchor+=m_impl->args;
2557 2558 2559 2560

  // include definition as well, to distinguish between two template
  // specializations that only differ in the template parameters.
  memAnchor.prepend(definition());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2561 2562 2563 2564 2565 2566
  
  // convert to md5 hash
  uchar md5_sig[16];
  QCString sigStr(33);
  MD5Buffer((const unsigned char *)memAnchor.data(),memAnchor.length(),md5_sig);
  MD5SigToString(md5_sig,sigStr.data(),33);
2567
  m_impl->anc = "a"+sigStr;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2568 2569
}

2570 2571 2572
void MemberDef::setGroupDef(GroupDef *gd,Grouping::GroupPri_t pri,
                            const QCString &fileName,int startLine,
                            bool hasDocs,MemberDef *member)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2573
{
2574
  //printf("%s MemberDef::setGroupDef(%s)\n",name().data(),gd->name().data());
2575 2576 2577 2578 2579 2580 2581
  makeResident();
  m_impl->group=gd;
  m_impl->grouppri=pri;
  m_impl->groupFileName=fileName;
  m_impl->groupStartLine=startLine;
  m_impl->groupHasDocs=hasDocs;
  m_impl->groupMember=member;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2582
}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2583 2584 2585

void MemberDef::setEnumScope(MemberDef *md) 
{ 
2586 2587 2588
  makeResident();
  m_impl->enumScope=md; 
  if (md->getGroupDef())
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2589
  {
2590 2591 2592 2593 2594
    m_impl->group=md->getGroupDef();
    m_impl->grouppri=md->getGroupPri();
    m_impl->groupFileName=md->getGroupFileName();
    m_impl->groupStartLine=md->getGroupStartLine();
    m_impl->groupHasDocs=md->getGroupHasDocs();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2595 2596 2597
  }
}

2598 2599
void MemberDef::setMemberClass(ClassDef *cd)     
{ 
2600 2601
  makeResident();
  m_impl->classDef=cd; 
2602 2603 2604 2605 2606
  setOuterScope(cd); 
}

void MemberDef::setNamespace(NamespaceDef *nd) 
{ 
2607 2608
  makeResident();
  m_impl->nspace=nd; 
2609 2610 2611
  setOuterScope(nd); 
}

2612 2613 2614
MemberDef *MemberDef::createTemplateInstanceMember(
        ArgumentList *formalArgs,ArgumentList *actualArgs)
{
2615 2616
  makeResident();
  LockingPtr<MemberDef> lock(this,this);
2617 2618
  //printf("  Member %s %s %s\n",typeString(),name().data(),argsString());
  ArgumentList *actualArgList = 0;
2619
  if (m_impl->defArgList)
2620 2621
  {
    actualArgList = new ArgumentList;
2622
    ArgumentListIterator ali(*m_impl->defArgList);
2623 2624 2625 2626 2627 2628 2629
    Argument *arg;
    for (;(arg=ali.current());++ali)
    {
      Argument *actArg = new Argument(*arg);
      actArg->type = substituteTemplateArgumentsInString(actArg->type,formalArgs,actualArgs);
      actualArgList->append(actArg);
    }
2630 2631 2632
    actualArgList->constSpecifier    = m_impl->defArgList->constSpecifier;
    actualArgList->volatileSpecifier = m_impl->defArgList->volatileSpecifier;
    actualArgList->pureSpecifier     = m_impl->defArgList->pureSpecifier;
2633 2634
  }

2635 2636 2637 2638 2639 2640
  QCString methodName=name();
  if (methodName.left(9)=="operator ") // conversion operator
  {
    methodName=substituteTemplateArgumentsInString(methodName,formalArgs,actualArgs);
  }

2641 2642
  MemberDef *imd = new MemberDef(
                       getDefFileName(),getDefLine(),
2643
                       substituteTemplateArgumentsInString(m_impl->type,formalArgs,actualArgs), 
2644
                       methodName, 
2645 2646 2647
                       substituteTemplateArgumentsInString(m_impl->args,formalArgs,actualArgs), 
                       m_impl->exception, m_impl->prot,
                       m_impl->virt, m_impl->stat, m_impl->related, m_impl->mtype, 0, 0
2648
                   );
2649 2650
  imd->setArgumentList(actualArgList);
  imd->setDefinition(substituteTemplateArgumentsInString(m_impl->def,formalArgs,actualArgs));
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2651 2652
  imd->setBodyDef(getBodyDef());
  imd->setBodySegment(getStartBodyLine(),getEndBodyLine());
2653
  //imd->setBodyMember(this);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2654

2655
  // TODO: init other member variables (if needed).
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2656
  // TODO: reimplemented info
2657 2658 2659
  return imd; 
}

2660 2661
bool MemberDef::hasOneLineInitializer() const
{
2662
  makeResident();
2663
  //printf("%s: init=%s, initLines=%d maxInitLines=%d userInitLines=%d\n",
2664 2665
  //    name().data(),m_impl->initializer.data(),m_impl->initLines,
  //    m_impl->maxInitLines,m_impl->userInitLines);
2666 2667
  return !m_impl->initializer.isEmpty() && m_impl->initLines==0 && // one line initializer
         ((m_impl->maxInitLines>0 && m_impl->userInitLines==-1) || m_impl->userInitLines>0); // enabled by default or explicitly
2668 2669 2670 2671
}

bool MemberDef::hasMultiLineInitializer() const
{
2672
  makeResident();
2673 2674
  //printf("initLines=%d userInitLines=%d maxInitLines=%d\n",
  //    initLines,userInitLines,maxInitLines);
2675 2676 2677
  return m_impl->initLines>0 && 
         ((m_impl->initLines<m_impl->maxInitLines && m_impl->userInitLines==-1) // implicitly enabled
          || m_impl->initLines<m_impl->userInitLines // explicitly enabled
2678 2679
         );
}
2680 2681 2682

void MemberDef::setInitializer(const char *initializer)    
{ 
2683 2684 2685 2686 2687 2688
  makeResident();
  m_impl->initializer=initializer; 
  int p=m_impl->initializer.length()-1;
  while (p>=0 && isspace((uchar)m_impl->initializer.at(p))) p--;
  m_impl->initializer=m_impl->initializer.left(p+1);
  m_impl->initLines=m_impl->initializer.contains('\n');
2689
}
2690

2691
void MemberDef::addListReference(Definition *)
2692
{
2693
  makeResident();
2694 2695 2696
  static bool optimizeOutputForC = Config_getBool("OPTIMIZE_OUTPUT_FOR_C");
  static bool hideScopeNames     = Config_getBool("HIDE_SCOPE_NAMES");
  static bool optimizeOutputJava = Config_getBool("OPTIMIZE_OUTPUT_JAVA");
2697
  static bool fortranOpt = Config_getBool("OPTIMIZE_FOR_FORTRAN");  
2698
  visited=TRUE;
2699
  if (!isLinkableInProject()) return;
2700
  QCString memLabel;
2701
  if (optimizeOutputForC) 
2702 2703 2704
  {
    memLabel=theTranslator->trGlobal(TRUE,TRUE);
  }
2705 2706 2707 2708
  else if (fortranOpt)
  {
    memLabel=theTranslator->trSubprogram(TRUE,TRUE);
  }
2709 2710 2711 2712
  else
  {
    memLabel=theTranslator->trMember(TRUE,TRUE);
  }
2713
  QCString memName = name();
2714
  Definition *pd=getOuterScope();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2715
  QCString memArgs;
2716 2717
  if (!isRelated() &&
      (
2718
       (!hideScopeNames && // there is a scope
2719
        pd && pd!=Doxygen::globalScope)       // and we can show it
2720 2721
       ||
       (pd=getClassDef())                     // it's a class so we
2722
                                              // show the scope anyway
2723
      )
2724
     )
2725
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2726 2727 2728 2729 2730
    if (isObjCMethod())
    {
      memName = "[" + pd->name() + " " + name() + "]";
    }
    else if (optimizeOutputJava)
2731
    {
2732
      memName.prepend(pd->name()+".");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2733
      memArgs = argsString();
2734 2735 2736 2737
    }
    else
    {
      memName.prepend(pd->name()+"::");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2738
      memArgs = argsString();
2739 2740
    }
  }
2741 2742
  LockingPtr< QList<ListItemInfo> > xrefItems = xrefListItems();
  if (xrefItems!=0)
2743
  {
2744
    addRefItem(xrefItems.pointer(),memLabel,
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2745
        getOutputFileBase()+"#"+anchor(),memName,memArgs);
2746
  }
2747 2748
}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2749 2750
MemberList *MemberDef::getSectionList(Definition *d) const 
{ 
2751 2752 2753 2754
  makeResident();
  char key[20];
  sprintf(key,"%p",d);
  return (d!=0 && m_impl->classSectionSDict) ? m_impl->classSectionSDict->find(key) : 0;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2755 2756 2757 2758
}

void MemberDef::setSectionList(Definition *d, MemberList *sl)   
{ 
2759
  makeResident();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2760
  //printf("MemberDef::setSectionList(%p,%p) name=%s\n",d,sl,name().data());
2761 2762 2763 2764 2765 2766 2767
  char key[20];
  sprintf(key,"%p",d);
  if (m_impl->classSectionSDict==0) 
  {
    m_impl->classSectionSDict = new SDict<MemberList>(7);
  }
  m_impl->classSectionSDict->append(key,sl);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2768 2769
}

2770
Specifier MemberDef::virtualness(int count) const
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2771
{
2772 2773 2774 2775 2776 2777 2778 2779
  if (count>25) 
  {
     warn(getDefFileName(),getDefLine(),
       "Warning: Internal inconsistency: recursion detected in overload relation for member %s!"
       ,name().data()
      );
     return Normal;
  }
2780 2781
  makeResident();
  Specifier v = m_impl->virt;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2782 2783 2784
  MemberDef *rmd = reimplements();
  while (rmd && v==Normal)
  {
2785
    v = rmd->virtualness(count+1)==Normal ? Normal : Virtual;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2786 2787 2788 2789 2790
    rmd = rmd->reimplements();
  }
  return v;
}

2791 2792
bool MemberDef::isConstructor() const            
{ 
2793 2794
  makeResident();
  if (m_impl->classDef) 
2795
  {
2796
    if (m_impl->isDMember) // for D
2797 2798 2799
    {
      return name()=="this";
    }
2800 2801
    else if (m_impl->fileDef && 
             getLanguageFromFileName(m_impl->fileDef->name())==SrcLangExt_PHP)
2802 2803 2804
    {                // for PHP
      return name()=="__construct";
    }
2805 2806
    else // for other languages
    {
2807
      QCString locName = m_impl->classDef->localName();
2808 2809 2810 2811 2812 2813 2814 2815 2816
      int i=locName.find('<');
      if (i==-1) // not a template class
      {
        return name()==locName;
      }
      else
      {
        return name()==locName.left(i);
      }
2817 2818
    }
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2819 2820
  else
     return FALSE; 
2821 2822 2823 2824
}

bool MemberDef::isDestructor() const
{ 
2825 2826
  makeResident();
  if (m_impl->isDMember) // for D
2827 2828 2829
  {
    return name()=="~this";
  }
2830 2831
  else if (m_impl->fileDef && 
      getLanguageFromFileName(m_impl->fileDef->name())==SrcLangExt_PHP)
2832 2833 2834
  {                // for PHP
    return name()=="__destruct";
  }
2835 2836
  else // other languages
  {
2837 2838
    return (name().find('~')!=-1 || name().find('!')!=-1)  // The ! is for C++/CLI
           && name().find("operator")==-1; 
2839
  }
2840 2841
}

2842 2843 2844
void MemberDef::writeEnumDeclaration(OutputList &typeDecl,
     ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd)
{
2845 2846
  makeResident();
  LockingPtr<MemberDef> lock(this,this);
2847 2848
  int enumMemCount=0;

2849
  QList<MemberDef> *fmdl=m_impl->enumFields;
2850 2851 2852 2853 2854 2855 2856 2857 2858 2859
  uint numVisibleEnumValues=0;
  if (fmdl)
  {
    MemberDef *fmd=fmdl->first();
    while (fmd)
    {
      if (fmd->isBriefSectionVisible()) numVisibleEnumValues++;
      fmd=fmdl->next();
    }
  }
2860 2861 2862 2863
  if (numVisibleEnumValues==0 && !isBriefSectionVisible()) 
  {
    return;
  }
2864 2865 2866 2867 2868 2869 2870 2871

  QCString n = name();
  int i=n.findRev("::");
  if (i!=-1) n=n.right(n.length()-i-2); // strip scope (TODO: is this needed?)
  if (n[0]!='@') // not an anonymous enum
  {
    if (isLinkableInProject() || hasDocumentedEnumValues())
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2872
      if (!Config_getString("GENERATE_TAGFILE").isEmpty() && !isReference())
2873 2874 2875
      {
        Doxygen::tagFile << "    <member kind=\"enumeration\">" << endl;
        Doxygen::tagFile << "      <name>" << convertToXML(name()) << "</name>" << endl; 
2876
        Doxygen::tagFile << "      <anchorfile>" << convertToXML(getOutputFileBase()+Doxygen::htmlFileExtension) << "</anchorfile>" << endl;
2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894
        Doxygen::tagFile << "      <anchor>" << convertToXML(anchor()) << "</anchor>" << endl; 
        Doxygen::tagFile << "      <arglist>" << convertToXML(argsString()) << "</arglist>" << endl; 
        Doxygen::tagFile << "    </member>" << endl;
      }
      writeLink(typeDecl,cd,nd,fd,gd);
    }
    else
    {
      typeDecl.startBold();
      typeDecl.docify(n);
      typeDecl.endBold();
    }
    typeDecl.writeChar(' ');
  }

  if (numVisibleEnumValues>0)
  {
    uint enumValuesPerLine = (uint)Config_getInt("ENUM_VALUES_PER_LINE");
2895
    if (enumValuesPerLine==0) enumValuesPerLine=1;
2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911
    typeDecl.docify("{ ");
    if (fmdl)
    {
      MemberDef *fmd=fmdl->first();
      bool fmdVisible = fmd->isBriefSectionVisible();
      while (fmd)
      {
        if (fmdVisible)
        {
          /* in html we start a new line after a number of items */
          if (numVisibleEnumValues>enumValuesPerLine
              && (enumMemCount%enumValuesPerLine)==0
             )
          {
            typeDecl.pushGeneratorState();
            typeDecl.disableAllBut(OutputGenerator::Html);
2912
            typeDecl.enable(OutputGenerator::Latex);
2913
            typeDecl.lineBreak(); 
2914
            typeDecl.disable(OutputGenerator::Latex);
2915 2916 2917 2918 2919 2920
            typeDecl.writeString("&nbsp;&nbsp;");
            typeDecl.popGeneratorState();
          }

          if (fmd->hasDocumentation()) // enum value has docs
          {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2921
            if (!Config_getString("GENERATE_TAGFILE").isEmpty() && !fmd->isReference())
2922 2923 2924
            {
              Doxygen::tagFile << "    <member kind=\"enumvalue\">" << endl;
              Doxygen::tagFile << "      <name>" << convertToXML(fmd->name()) << "</name>" << endl; 
2925
              Doxygen::tagFile << "      <anchorfile>" << convertToXML(getOutputFileBase()+Doxygen::htmlFileExtension) << "</anchorfile>" << endl;              
2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970
              Doxygen::tagFile << "      <anchor>" << convertToXML(fmd->anchor()) << "</anchor>" << endl; 
              Doxygen::tagFile << "      <arglist>" << convertToXML(fmd->argsString()) << "</arglist>" << endl; 
              Doxygen::tagFile << "    </member>" << endl;
            }
            fmd->writeLink(typeDecl,cd,nd,fd,gd);
          }
          else // no docs for this enum value
          {
            typeDecl.startBold();
            typeDecl.docify(fmd->name());
            typeDecl.endBold();
          }
          if (fmd->hasOneLineInitializer()) // enum value has initializer
          {
            typeDecl.writeString(" = ");
            typeDecl.parseText(fmd->initializer());
          }
        }

        bool prevVisible = fmdVisible;
        fmd=fmdl->next();
        if (fmd && (fmdVisible=fmd->isBriefSectionVisible())) 
        {
          typeDecl.writeString(", ");
        }
        if (prevVisible)
        {
          typeDecl.disable(OutputGenerator::Man);
          typeDecl.writeString("\n"); // to prevent too long lines in LaTeX
          typeDecl.enable(OutputGenerator::Man);
          enumMemCount++;
        }
      }
      if (numVisibleEnumValues>enumValuesPerLine)
      {
        typeDecl.pushGeneratorState();
        typeDecl.disableAllBut(OutputGenerator::Html);
        typeDecl.lineBreak(); 
        typeDecl.popGeneratorState();
      }
    }
    typeDecl.docify(" }");
  }
}

2971 2972
void MemberDef::setArgumentList(ArgumentList *al) 
{ 
2973 2974 2975
  makeResident();
  if (m_impl->defArgList) delete m_impl->defArgList;
  m_impl->defArgList = al;
2976
}
2977

2978 2979
void MemberDef::setDeclArgumentList(ArgumentList *al)
{
2980 2981 2982
  makeResident();
  if (m_impl->declArgList) delete m_impl->declArgList;
  m_impl->declArgList = al;
2983
}
2984

2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999
void MemberDef::setTypeConstraints(ArgumentList *al)
{
  if (al==0) return;
  makeResident();
  if (m_impl->typeConstraints) delete m_impl->typeConstraints;
  m_impl->typeConstraints = new ArgumentList;
  m_impl->typeConstraints->setAutoDelete(TRUE);
  ArgumentListIterator ali(*al);
  Argument *a;
  for (;(a=ali.current());++ali)
  {
    m_impl->typeConstraints->append(new Argument(*a));
  }
}

3000 3001
void MemberDef::findSectionsInDocumentation()
{
3002
  makeResident();
3003
  docFindSections(documentation(),this,0,docFile());  
3004 3005
}

3006 3007
void MemberDef::enableCallGraph(bool e) 
{ 
3008 3009
  makeResident();
  m_impl->hasCallGraph=e; 
3010 3011 3012
  if (e) Doxygen::parseSourcesNeeded = TRUE;
}

3013 3014
void MemberDef::enableCallerGraph(bool e) 
{ 
3015 3016
  makeResident();
  m_impl->hasCallerGraph=e; 
3017 3018 3019
  if (e) Doxygen::parseSourcesNeeded = TRUE;
}

3020 3021
bool MemberDef::protectionVisible() const
{
3022 3023 3024 3025 3026
  makeResident();
  return m_impl->prot==Public || 
         (m_impl->prot==Private   && Config_getBool("EXTRACT_PRIVATE"))   ||
         (m_impl->prot==Protected && Config_getBool("EXTRACT_PROTECTED")) ||
         (m_impl->prot==Package   && Config_getBool("EXTRACT_PACKAGE"));
3027 3028
}

3029
#if 0
3030 3031 3032
void MemberDef::setInbodyDocumentation(const char *docs,
                  const char *docFile,int docLine)
{
3033 3034 3035 3036 3037
  makeResident();
  m_impl->inbodyDocs = docs;
  m_impl->inbodyDocs = m_impl->inbodyDocs.stripWhiteSpace();
  m_impl->inbodyLine = docLine;
  m_impl->inbodyFile = docFile;
3038
}
3039
#endif
3040

Dimitri van Heesch's avatar
Dimitri van Heesch committed
3041 3042
bool MemberDef::isObjCMethod() const
{
3043 3044
  makeResident();
  if (m_impl->classDef && m_impl->classDef->isObjectiveC() && isFunction()) return TRUE;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3045 3046 3047
  return FALSE; 
}

3048
QCString MemberDef::qualifiedName() const
3049
{
3050
  makeResident();
3051 3052 3053 3054 3055
  if (isObjCMethod())
  {
    QCString qm;
    if (isStatic()) qm="+"; else qm="-";
    qm+="[";
3056
    qm+=m_impl->classDef->name()+" ";
3057 3058 3059 3060 3061 3062 3063 3064 3065
    qm+=name();
    qm+="]";
    return qm;
  }
  else
  {
    return Definition::qualifiedName();
  }  
}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3066

3067 3068 3069 3070
void MemberDef::setTagInfo(TagInfo *ti)
{
  if (ti)
  {
3071
    makeResident();
3072
    //printf("%s: Setting tag name=%s anchor=%s\n",name().data(),ti->tagName.data(),ti->anchor.data());
3073
    m_impl->anc=ti->anchor;
3074
    setReference(ti->tagName);
3075
    m_impl->explicitOutputFileBase = stripExtension(ti->fileName);
3076 3077 3078
  }
}

3079 3080
QCString MemberDef::objCMethodName(bool localLink,bool showStatic) const
{
3081
  makeResident();
3082 3083 3084 3085 3086 3087 3088 3089 3090
  QCString qm;
  if (showStatic)
  {
    if (isStatic()) qm="+ "; else qm="- ";
  }
  qm+=name();
  if (!localLink) // link to method of same class
  {
    qm+=" (";
3091
    qm+=m_impl->classDef->name();
3092 3093 3094 3095 3096
    qm+=")";
  }
  return qm;
}

3097 3098 3099 3100 3101 3102 3103 3104 3105
const char *MemberDef::declaration() const
{ 
  makeResident();
  return m_impl->decl; 
}

const char *MemberDef::definition() const
{ 
  makeResident();
3106 3107 3108 3109 3110 3111 3112
  return m_impl->def;
}

const char *MemberDef::extraTypeChars() const
{
  makeResident();
  return m_impl->extraTypeChars;
3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303
}

const char *MemberDef::typeString() const
{ 
  makeResident();
  return m_impl->type; 
}

const char *MemberDef::argsString() const
{ 
  makeResident();
  return m_impl->args; 
}

const char *MemberDef::excpString() const
{ 
  makeResident();
  return m_impl->exception; 
}

const char *MemberDef::bitfieldString() const
{ 
  makeResident();
  return m_impl->bitfields; 
}

const QCString &MemberDef::initializer() const
{ 
  makeResident();
  return m_impl->initializer; 
}

int MemberDef::initializerLines() const
{ 
  makeResident();
  return m_impl->initLines; 
}

int  MemberDef::getMemberSpecifiers() const
{ 
  makeResident();
  return m_impl->memSpec; 
}

ClassDef *MemberDef::getClassDef() const
{ 
  makeResident();
  return m_impl->classDef; 
}

FileDef  *MemberDef::getFileDef() const
{ 
  makeResident();
  return m_impl->fileDef; 
}

NamespaceDef* MemberDef::getNamespaceDef() const
{ 
  makeResident();
  return m_impl->nspace; 
}

const char *MemberDef::getReadAccessor() const
{ 
  makeResident();
  return m_impl->read; 
}

const char *MemberDef::getWriteAccessor() const
{ 
  makeResident();
  return m_impl->write; 
}

GroupDef *MemberDef::getGroupDef() const
{ 
  makeResident();
  return m_impl->group; 
}

Grouping::GroupPri_t MemberDef::getGroupPri() const
{ 
  makeResident();
  return m_impl->grouppri; 
}

const char *MemberDef::getGroupFileName() const
{ 
  makeResident();
  return m_impl->groupFileName; 
}

int MemberDef::getGroupStartLine() const
{ 
  makeResident();
  return m_impl->groupStartLine; 
}

bool MemberDef::getGroupHasDocs() const
{ 
  makeResident();
  return m_impl->groupHasDocs; 
}

Protection MemberDef::protection() const
{ 
  makeResident();
  return m_impl->prot; 
}

MemberDef::MemberType MemberDef::memberType() const
{ 
  makeResident();
  return m_impl->mtype; 
}

bool MemberDef::isSignal() const
{ 
  makeResident();
  return m_impl->mtype==Signal;      
}

bool MemberDef::isSlot() const
{ 
  makeResident();
  return m_impl->mtype==Slot;        
}

bool MemberDef::isVariable() const
{ 
  makeResident();
  return m_impl->mtype==Variable;    
}

bool MemberDef::isEnumerate() const
{ 
  makeResident();
  return m_impl->mtype==Enumeration; 
}

bool MemberDef::isEnumValue() const
{ 
  makeResident();
  return m_impl->mtype==EnumValue;   
}

bool MemberDef::isTypedef() const
{ 
  makeResident();
  return m_impl->mtype==Typedef;     
}

bool MemberDef::isFunction() const
{ 
  makeResident();
  return m_impl->mtype==Function;    
}

bool MemberDef::isDefine() const
{ 
  makeResident();
  return m_impl->mtype==Define;      
}

bool MemberDef::isFriend() const
{ 
  makeResident();
  return m_impl->mtype==Friend;      
}

bool MemberDef::isDCOP() const
{ 
  makeResident();
  return m_impl->mtype==DCOP;        
}

bool MemberDef::isProperty() const
{ 
  makeResident();
  return m_impl->mtype==Property;    
}

bool MemberDef::isEvent() const
{ 
  makeResident();
  return m_impl->mtype==Event;       
}

bool MemberDef::isRelated() const
{ 
  makeResident();
3304 3305 3306 3307 3308 3309 3310
  return m_impl->related == Related;
}

bool MemberDef::isForeign() const
{ 
  makeResident();
  return m_impl->related == Foreign; 
3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348
}

bool MemberDef::isStatic() const
{ 
  makeResident();
  return m_impl->stat; 
}

bool MemberDef::isInline() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::Inline)!=0; 
}

bool MemberDef::isExplicit() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::Explicit)!=0; 
}

bool MemberDef::isMutable() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::Mutable)!=0; 
}

bool MemberDef::isGettable() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::Gettable)!=0; 
}

bool MemberDef::isSettable() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::Settable)!=0; 
}

3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366
bool MemberDef::isAddable() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::Addable)!=0; 
}

bool MemberDef::isRemovable() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::Removable)!=0; 
}

bool MemberDef::isRaisable() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::Raisable)!=0; 
}

3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384
bool MemberDef::isReadable() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::Readable)!=0; 
}

bool MemberDef::isWritable() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::Writable)!=0; 
}

bool MemberDef::isFinal() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::Final)!=0; 
}

3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408
bool MemberDef::isNew() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::New)!=0; 
}

bool MemberDef::isSealed() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::Sealed)!=0; 
}

bool MemberDef::isOverride() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::Override)!=0; 
}

bool MemberDef::isInitonly() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::Initonly)!=0; 
}

3409 3410 3411 3412 3413 3414
bool MemberDef::isAbstract() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::Abstract)!=0; 
}

3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451
bool MemberDef::isOptional() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::Optional)!=0; 
}

bool MemberDef::isRequired() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::Required)!=0; 
}

bool MemberDef::isNonAtomic() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::NonAtomic)!=0; 
}

bool MemberDef::isCopy() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::Copy)!=0; 
}

bool MemberDef::isAssign() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::Assign)!=0; 
}

bool MemberDef::isRetain() const
{ 
  makeResident();
  return (m_impl->memSpec&Entry::Retain)!=0; 
}


3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481
bool MemberDef::isImplementation() const
{ 
  makeResident();
  return m_impl->implOnly; 
}

bool MemberDef::isExternal() const
{ 
  makeResident();
  return m_impl->explExt; 
}

bool MemberDef::isTemplateSpecialization() const
{ 
  makeResident();
  return m_impl->tspec; 
}

bool MemberDef::hasDocumentedParams() const
{ 
  makeResident();
  return m_impl->hasDocumentedParams; 
}

bool MemberDef::hasDocumentedReturnType() const
{ 
  makeResident();
  return m_impl->hasDocumentedReturnType; 
}

3482
#if 0
3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499
int MemberDef::inbodyLine() const
{ 
  makeResident();
  return m_impl->inbodyLine; 
}

QCString MemberDef::inbodyFile() const
{ 
  makeResident();
  return m_impl->inbodyFile; 
}

const QCString &MemberDef::inbodyDocumentation() const
{ 
  makeResident();
  return m_impl->inbodyDocs; 
}
3500
#endif
3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639

ClassDef *MemberDef::relatedAlso() const
{ 
  makeResident();
  return m_impl->relatedAlso; 
}

bool MemberDef::hasDocumentedEnumValues() const
{ 
  makeResident();
  return m_impl->docEnumValues; 
}

MemberDef *MemberDef::getAnonymousEnumType() const
{ 
  makeResident();
  return m_impl->annEnumType; 
}

bool MemberDef::isDocsForDefinition() const
{ 
  makeResident();
  return m_impl->docsForDefinition; 
}

MemberDef *MemberDef::getEnumScope() const
{ 
  makeResident();
  return m_impl->enumScope; 
}

LockingPtr<MemberList> MemberDef::enumFieldList() const
{ 
  makeResident();
  return LockingPtr<MemberList>(this,m_impl->enumFields); 
}

LockingPtr<ExampleSDict> MemberDef::getExamples() const
{ 
  makeResident();
  return LockingPtr<ExampleSDict>(this,m_impl->exampleSDict); 
}

bool MemberDef::isPrototype() const
{ 
  makeResident();
  return m_impl->proto; 
}

LockingPtr<ArgumentList> MemberDef::argumentList() const
{ 
  makeResident();
  return LockingPtr<ArgumentList>(this,m_impl->defArgList); 
}

LockingPtr<ArgumentList> MemberDef::declArgumentList() const
{ 
  makeResident();
  return LockingPtr<ArgumentList>(this,m_impl->declArgList); 
}

LockingPtr<ArgumentList> MemberDef::templateArguments() const
{ 
  makeResident();
  return LockingPtr<ArgumentList>(this,m_impl->tArgList); 
}

LockingPtr< QList<ArgumentList> > MemberDef::definitionTemplateParameterLists() const
{ 
  makeResident();
  return LockingPtr< QList<ArgumentList> >(this,m_impl->defTmpArgLists); 
}

int MemberDef::getMemberGroupId() const
{ 
  makeResident();
  return m_impl->grpId; 
}

MemberGroup *MemberDef::getMemberGroup() const
{ 
  makeResident();
  return m_impl->memberGroup; 
}

bool MemberDef::fromAnonymousScope() const
{ 
  makeResident();
  return m_impl->annScope; 
}

bool MemberDef::anonymousDeclShown() const
{ 
  makeResident();
  return m_impl->annUsed; 
}

void MemberDef::setAnonymousUsed() 
{
  makeResident();
  m_impl->annUsed = TRUE;
}

bool MemberDef::hasCallGraph() const
{ 
  makeResident();
  return m_impl->hasCallGraph; 
}

bool MemberDef::hasCallerGraph() const
{ 
  makeResident();
  return m_impl->hasCallerGraph; 
}

MemberDef *MemberDef::templateMaster() const
{ 
  makeResident();
  return m_impl->templateMaster; 
}

bool MemberDef::isTypedefValCached() const
{ 
  makeResident();
  return m_impl->isTypedefValCached; 
}

ClassDef *MemberDef::getCachedTypedefVal() const
{ 
  makeResident();
  return m_impl->cachedTypedefValue; 
}

QCString MemberDef::getCachedTypedefTemplSpec() const
{ 
  makeResident();
  return m_impl->cachedTypedefTemplSpec; 
}

3640 3641 3642
QCString MemberDef::getCachedResolvedTypedef() const
{ 
  makeResident();
3643
  //printf("MemberDef::getCachedResolvedTypedef()=%s m_impl=%p\n",m_impl->cachedResolvedType.data(),m_impl);
3644 3645 3646
  return m_impl->cachedResolvedType; 
}

3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714
MemberDef *MemberDef::memberDefinition() const
{ 
  makeResident();
  return m_impl->memDef; 
}

MemberDef *MemberDef::memberDeclaration() const
{ 
  makeResident();
  return m_impl->memDec; 
}

MemberDef *MemberDef::inheritsDocsFrom() const
{ 
  makeResident();
  return m_impl->docProvider; 
}

MemberDef *MemberDef::getGroupAlias() const
{ 
  makeResident();
  return m_impl->groupAlias; 
}

void MemberDef::setMemberType(MemberType t)
{ 
  makeResident();
  m_impl->mtype=t; 
}

void MemberDef::setDefinition(const char *d)
{ 
  makeResident();
  m_impl->def=d; 
}

void MemberDef::setFileDef(FileDef *fd)
{ 
  makeResident();
  m_impl->fileDef=fd; 
}

void MemberDef::setProtection(Protection p)
{ 
  makeResident();
  m_impl->prot=p; 
}

void MemberDef::setMemberSpecifiers(int s)
{ 
  makeResident();
  m_impl->memSpec=s; 
}

void MemberDef::mergeMemberSpecifiers(int s)
{ 
  makeResident();
  m_impl->memSpec|=s; 
}

void MemberDef::setBitfields(const char *s)
{ 
  makeResident();
  m_impl->bitfields = s; 
}

void MemberDef::setMaxInitLines(int lines)
{ 
3715 3716 3717 3718 3719
  if (lines!=-1)
  {
    makeResident();
    m_impl->userInitLines=lines; 
  }
3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748
}

void MemberDef::setExplicitExternal(bool b)
{ 
  makeResident();
  m_impl->explExt=b; 
}

void MemberDef::setReadAccessor(const char *r)
{ 
  makeResident();
  m_impl->read=r; 
}

void MemberDef::setWriteAccessor(const char *w)
{ 
  makeResident();
  m_impl->write=w; 
}

void MemberDef::setTemplateSpecialization(bool b)
{ 
  makeResident();
  m_impl->tspec=b; 
}

void MemberDef::makeRelated()
{ 
  makeResident();
3749 3750 3751 3752 3753 3754 3755
  m_impl->related = Related; 
}

void MemberDef::makeForeign()
{ 
  makeResident();
  m_impl->related = Foreign; 
3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871
}

void MemberDef::setHasDocumentedParams(bool b)
{ 
  makeResident();
  m_impl->hasDocumentedParams = b; 
}

void MemberDef::setHasDocumentedReturnType(bool b)
{ 
  makeResident();
  m_impl->hasDocumentedReturnType = b; 
}

void MemberDef::setInheritsDocsFrom(MemberDef *md)
{ 
  makeResident();
  m_impl->docProvider = md; 
}

void MemberDef::setArgsString(const char *as)
{ 
  makeResident();
  m_impl->args = as; 
}

void MemberDef::setRelatedAlso(ClassDef *cd)
{ 
  makeResident();
  m_impl->relatedAlso=cd; 
}

void MemberDef::setEnumClassScope(ClassDef *cd)
{ 
  makeResident();
  m_impl->classDef = cd; 
}

void MemberDef::setDocumentedEnumValues(bool value)
{ 
  makeResident();
  m_impl->docEnumValues=value; 
}

void MemberDef::setAnonymousEnumType(MemberDef *md)
{ 
  makeResident();
  m_impl->annEnumType = md; 
}

void MemberDef::setPrototype(bool p)
{ 
  makeResident();
  m_impl->proto=p; 
}

void MemberDef::setMemberGroupId(int id)
{ 
  makeResident();
  m_impl->grpId=id; 
}

void MemberDef::makeImplementationDetail()
{ 
  makeResident();
  m_impl->implOnly=TRUE; 
}

void MemberDef::setFromAnonymousScope(bool b)
{ 
  makeResident();
  m_impl->annScope=b; 
}

void MemberDef::setFromAnonymousMember(MemberDef *m)
{ 
  makeResident();
  m_impl->annMemb=m; 
}

void MemberDef::setTemplateMaster(MemberDef *mt)
{ 
  makeResident();
  m_impl->templateMaster=mt; 
}

void MemberDef::setDocsForDefinition(bool b)
{ 
  makeResident();
  m_impl->docsForDefinition = b; 
}

void MemberDef::setGroupAlias(MemberDef *md)
{ 
  makeResident();
  m_impl->groupAlias = md; 
}

void MemberDef::invalidateTypedefValCache()
{ 
  makeResident();
  m_impl->isTypedefValCached=FALSE; 
}

void MemberDef::setMemberDefinition(MemberDef *md)
{ 
  makeResident();
  m_impl->memDef=md; 
}

void MemberDef::setMemberDeclaration(MemberDef *md)
{ 
  makeResident();
  m_impl->memDec=md; 
}

3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884
ClassDef *MemberDef::category() const
{
  makeResident();
  return m_impl->category;
}

void MemberDef::setCategory(ClassDef *def)
{
  makeResident();
  m_impl->category = def;
}


3885
void MemberDef::cacheTypedefVal(ClassDef*val, const QCString & templSpec, const QCString &resolvedType)
3886 3887 3888 3889 3890
{
  makeResident();
  m_impl->isTypedefValCached=TRUE; 
  m_impl->cachedTypedefValue=val; 
  m_impl->cachedTypedefTemplSpec=templSpec; 
3891
  m_impl->cachedResolvedType=resolvedType;
3892
  //printf("MemberDef::cacheTypedefVal=%s m_impl=%p\n",m_impl->cachedResolvedType.data(),m_impl);
3893 3894 3895 3896
}

void MemberDef::flushToDisk() const
{
3897 3898 3899
  if (isLocked()) return;
  MemberDef *that = (MemberDef*)this;
  that->m_storagePos = Doxygen::symbolStorage->alloc();
3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931
  //printf("%p: MemberDef::flushToDisk()\n",this);
  // write the definition base class member variables to disk
  Definition::flushToDisk();

  //printf("%p:   flushing specific part\n",this);

  // write the memberdef member variables to disk
  marshalUInt(Doxygen::symbolStorage,START_MARKER);
  marshalObjPointer   (Doxygen::symbolStorage,m_impl->classDef);
  marshalObjPointer   (Doxygen::symbolStorage,m_impl->fileDef);
  marshalObjPointer   (Doxygen::symbolStorage,m_impl->nspace);
  marshalObjPointer   (Doxygen::symbolStorage,m_impl->enumScope);
  marshalObjPointer   (Doxygen::symbolStorage,m_impl->annEnumType);
  marshalMemberList   (Doxygen::symbolStorage,m_impl->enumFields);
  marshalObjPointer   (Doxygen::symbolStorage,m_impl->redefines);
  marshalMemberList   (Doxygen::symbolStorage,m_impl->redefinedBy);
  marshalObjPointer   (Doxygen::symbolStorage,m_impl->memDef);
  marshalObjPointer   (Doxygen::symbolStorage,m_impl->memDec);
  marshalObjPointer   (Doxygen::symbolStorage,m_impl->relatedAlso);
  marshalExampleSDict (Doxygen::symbolStorage,m_impl->exampleSDict);
  marshalQCString     (Doxygen::symbolStorage,m_impl->type);
  marshalQCString     (Doxygen::symbolStorage,m_impl->args);
  marshalQCString     (Doxygen::symbolStorage,m_impl->def);
  marshalQCString     (Doxygen::symbolStorage,m_impl->anc);
  marshalInt          (Doxygen::symbolStorage,(int)m_impl->virt);
  marshalInt          (Doxygen::symbolStorage,(int)m_impl->prot);
  marshalQCString     (Doxygen::symbolStorage,m_impl->decl);
  marshalQCString     (Doxygen::symbolStorage,m_impl->bitfields);
  marshalQCString     (Doxygen::symbolStorage,m_impl->read);
  marshalQCString     (Doxygen::symbolStorage,m_impl->write);
  marshalQCString     (Doxygen::symbolStorage,m_impl->exception);
  marshalQCString     (Doxygen::symbolStorage,m_impl->initializer);
3932
  marshalQCString     (Doxygen::symbolStorage,m_impl->extraTypeChars);
3933 3934 3935 3936 3937 3938 3939 3940 3941
  marshalInt          (Doxygen::symbolStorage,m_impl->initLines);
  marshalInt          (Doxygen::symbolStorage,m_impl->memSpec);
  marshalInt          (Doxygen::symbolStorage,(int)m_impl->mtype);
  marshalInt          (Doxygen::symbolStorage,m_impl->maxInitLines);
  marshalInt          (Doxygen::symbolStorage,m_impl->userInitLines);
  marshalObjPointer   (Doxygen::symbolStorage,m_impl->annMemb);
  marshalArgumentList (Doxygen::symbolStorage,m_impl->defArgList);
  marshalArgumentList (Doxygen::symbolStorage,m_impl->declArgList);
  marshalArgumentList (Doxygen::symbolStorage,m_impl->tArgList);
3942
  marshalArgumentList (Doxygen::symbolStorage,m_impl->typeConstraints);
3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957
  marshalObjPointer   (Doxygen::symbolStorage,m_impl->templateMaster);
  marshalArgumentLists(Doxygen::symbolStorage,m_impl->defTmpArgLists);
  marshalObjPointer   (Doxygen::symbolStorage,m_impl->cachedAnonymousType);
  marshalMemberLists  (Doxygen::symbolStorage,m_impl->classSectionSDict);
  marshalObjPointer   (Doxygen::symbolStorage,m_impl->groupAlias);
  marshalInt          (Doxygen::symbolStorage,m_impl->grpId);
  marshalObjPointer   (Doxygen::symbolStorage,m_impl->memberGroup);
  marshalObjPointer   (Doxygen::symbolStorage,m_impl->group);
  marshalInt          (Doxygen::symbolStorage,(int)m_impl->grouppri);
  marshalQCString     (Doxygen::symbolStorage,m_impl->groupFileName);
  marshalInt          (Doxygen::symbolStorage,m_impl->groupStartLine);
  marshalObjPointer   (Doxygen::symbolStorage,m_impl->groupMember);
  marshalBool         (Doxygen::symbolStorage,m_impl->isTypedefValCached);
  marshalObjPointer   (Doxygen::symbolStorage,m_impl->cachedTypedefValue);
  marshalQCString     (Doxygen::symbolStorage,m_impl->cachedTypedefTemplSpec);
3958
  marshalQCString     (Doxygen::symbolStorage,m_impl->cachedResolvedType);
3959 3960 3961 3962 3963 3964
  marshalObjPointer   (Doxygen::symbolStorage,m_impl->docProvider);
  marshalQCString     (Doxygen::symbolStorage,m_impl->explicitOutputFileBase);
  marshalBool         (Doxygen::symbolStorage,m_impl->implOnly); 
  marshalBool         (Doxygen::symbolStorage,m_impl->hasDocumentedParams);
  marshalBool         (Doxygen::symbolStorage,m_impl->hasDocumentedReturnType);
  marshalBool         (Doxygen::symbolStorage,m_impl->isDMember);
3965
  marshalInt          (Doxygen::symbolStorage,(int)m_impl->related);
3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976
  marshalBool         (Doxygen::symbolStorage,m_impl->stat);
  marshalBool         (Doxygen::symbolStorage,m_impl->proto);
  marshalBool         (Doxygen::symbolStorage,m_impl->docEnumValues);
  marshalBool         (Doxygen::symbolStorage,m_impl->annScope);
  marshalBool         (Doxygen::symbolStorage,m_impl->annUsed);
  marshalBool         (Doxygen::symbolStorage,m_impl->hasCallGraph);
  marshalBool         (Doxygen::symbolStorage,m_impl->hasCallerGraph);
  marshalBool         (Doxygen::symbolStorage,m_impl->explExt);
  marshalBool         (Doxygen::symbolStorage,m_impl->tspec);
  marshalBool         (Doxygen::symbolStorage,m_impl->groupHasDocs);
  marshalBool         (Doxygen::symbolStorage,m_impl->docsForDefinition);
3977
  marshalObjPointer   (Doxygen::symbolStorage,m_impl->category);
3978 3979 3980 3981 3982
  marshalUInt(Doxygen::symbolStorage,END_MARKER);

  // function doesn't modify the object conceptually but compiler doesn't know this.
  delete that->m_impl;
  that->m_impl=0;
3983
  that->m_flushPending=FALSE;
3984 3985 3986 3987 3988
}

void MemberDef::loadFromDisk() const
{
  //printf("%p: MemberDef::loadFromDisk()\n",this);
3989
  MemberDef *that = (MemberDef *)this;
3990 3991 3992 3993 3994 3995
  if (isLocked()) 
  {
    assert(m_impl!=0);
    return;
  }
  assert(m_impl==0);
3996 3997 3998 3999

  Doxygen::symbolStorage->seek(m_storagePos);
  Definition::loadFromDisk();

4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029
  //printf("%p:   loading specific part\n",this);

  that->m_impl = new MemberDefImpl;

  uint marker = unmarshalUInt(Doxygen::symbolStorage);
  assert(marker==START_MARKER);
  m_impl->classDef                = (ClassDef*)unmarshalObjPointer     (Doxygen::symbolStorage);
  m_impl->fileDef                 = (FileDef*)unmarshalObjPointer      (Doxygen::symbolStorage);
  m_impl->nspace                  = (NamespaceDef*)unmarshalObjPointer (Doxygen::symbolStorage);
  m_impl->enumScope               = (MemberDef*)unmarshalObjPointer    (Doxygen::symbolStorage);
  m_impl->annEnumType             = (MemberDef*)unmarshalObjPointer    (Doxygen::symbolStorage);
  m_impl->enumFields              = unmarshalMemberList                (Doxygen::symbolStorage);
  m_impl->redefines               = (MemberDef*)unmarshalObjPointer    (Doxygen::symbolStorage);
  m_impl->redefinedBy             = unmarshalMemberList                (Doxygen::symbolStorage);
  m_impl->memDef                  = (MemberDef*)unmarshalObjPointer    (Doxygen::symbolStorage);
  m_impl->memDec                  = (MemberDef*)unmarshalObjPointer    (Doxygen::symbolStorage);
  m_impl->relatedAlso             = (ClassDef*)unmarshalObjPointer     (Doxygen::symbolStorage);
  m_impl->exampleSDict            = unmarshalExampleSDict (Doxygen::symbolStorage);
  m_impl->type                    = unmarshalQCString     (Doxygen::symbolStorage);
  m_impl->args                    = unmarshalQCString     (Doxygen::symbolStorage);
  m_impl->def                     = unmarshalQCString     (Doxygen::symbolStorage);
  m_impl->anc                     = unmarshalQCString     (Doxygen::symbolStorage);
  m_impl->virt                    = (Specifier)unmarshalInt (Doxygen::symbolStorage);
  m_impl->prot                    = (Protection)unmarshalInt(Doxygen::symbolStorage);
  m_impl->decl                    = unmarshalQCString     (Doxygen::symbolStorage);
  m_impl->bitfields               = unmarshalQCString     (Doxygen::symbolStorage);
  m_impl->read                    = unmarshalQCString     (Doxygen::symbolStorage);
  m_impl->write                   = unmarshalQCString     (Doxygen::symbolStorage);
  m_impl->exception               = unmarshalQCString     (Doxygen::symbolStorage);
  m_impl->initializer             = unmarshalQCString     (Doxygen::symbolStorage);
4030
  m_impl->extraTypeChars          = unmarshalQCString     (Doxygen::symbolStorage);
4031 4032 4033 4034 4035 4036 4037 4038 4039
  m_impl->initLines               = unmarshalInt          (Doxygen::symbolStorage);
  m_impl->memSpec                 = unmarshalInt          (Doxygen::symbolStorage);
  m_impl->mtype                   = (MemberDef::MemberType)unmarshalInt          (Doxygen::symbolStorage);
  m_impl->maxInitLines            = unmarshalInt          (Doxygen::symbolStorage);
  m_impl->userInitLines           = unmarshalInt          (Doxygen::symbolStorage);
  m_impl->annMemb                 = (MemberDef*)unmarshalObjPointer   (Doxygen::symbolStorage);
  m_impl->defArgList              = unmarshalArgumentList (Doxygen::symbolStorage);
  m_impl->declArgList             = unmarshalArgumentList (Doxygen::symbolStorage);
  m_impl->tArgList                = unmarshalArgumentList (Doxygen::symbolStorage);
4040
  m_impl->typeConstraints         = unmarshalArgumentList (Doxygen::symbolStorage);
4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055
  m_impl->templateMaster          = (MemberDef*)unmarshalObjPointer   (Doxygen::symbolStorage);
  m_impl->defTmpArgLists          = unmarshalArgumentLists(Doxygen::symbolStorage);
  m_impl->cachedAnonymousType     = (ClassDef*)unmarshalObjPointer   (Doxygen::symbolStorage);
  m_impl->classSectionSDict       = unmarshalMemberLists  (Doxygen::symbolStorage);
  m_impl->groupAlias              = (MemberDef*)unmarshalObjPointer   (Doxygen::symbolStorage);
  m_impl->grpId                   = unmarshalInt          (Doxygen::symbolStorage);
  m_impl->memberGroup             = (MemberGroup*)unmarshalObjPointer   (Doxygen::symbolStorage);
  m_impl->group                   = (GroupDef*)unmarshalObjPointer   (Doxygen::symbolStorage);
  m_impl->grouppri                = (Grouping::GroupPri_t)unmarshalInt          (Doxygen::symbolStorage);
  m_impl->groupFileName           = unmarshalQCString     (Doxygen::symbolStorage);
  m_impl->groupStartLine          = unmarshalInt          (Doxygen::symbolStorage);
  m_impl->groupMember             = (MemberDef*)unmarshalObjPointer   (Doxygen::symbolStorage);
  m_impl->isTypedefValCached      = unmarshalBool         (Doxygen::symbolStorage);
  m_impl->cachedTypedefValue      = (ClassDef*)unmarshalObjPointer   (Doxygen::symbolStorage);
  m_impl->cachedTypedefTemplSpec  = unmarshalQCString     (Doxygen::symbolStorage);
4056
  m_impl->cachedResolvedType      = unmarshalQCString     (Doxygen::symbolStorage);
4057 4058 4059 4060 4061 4062
  m_impl->docProvider             = (MemberDef*)unmarshalObjPointer   (Doxygen::symbolStorage);
  m_impl->explicitOutputFileBase  = unmarshalQCString     (Doxygen::symbolStorage);
  m_impl->implOnly                = unmarshalBool         (Doxygen::symbolStorage); 
  m_impl->hasDocumentedParams     = unmarshalBool         (Doxygen::symbolStorage);
  m_impl->hasDocumentedReturnType = unmarshalBool         (Doxygen::symbolStorage);
  m_impl->isDMember               = unmarshalBool         (Doxygen::symbolStorage);
4063
  m_impl->related                 = (Relationship)unmarshalInt(Doxygen::symbolStorage);
4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074
  m_impl->stat                    = unmarshalBool         (Doxygen::symbolStorage);
  m_impl->proto                   = unmarshalBool         (Doxygen::symbolStorage);
  m_impl->docEnumValues           = unmarshalBool         (Doxygen::symbolStorage);
  m_impl->annScope                = unmarshalBool         (Doxygen::symbolStorage);
  m_impl->annUsed                 = unmarshalBool         (Doxygen::symbolStorage);
  m_impl->hasCallGraph            = unmarshalBool         (Doxygen::symbolStorage);
  m_impl->hasCallerGraph          = unmarshalBool         (Doxygen::symbolStorage);
  m_impl->explExt                 = unmarshalBool         (Doxygen::symbolStorage);
  m_impl->tspec                   = unmarshalBool         (Doxygen::symbolStorage);
  m_impl->groupHasDocs            = unmarshalBool         (Doxygen::symbolStorage);
  m_impl->docsForDefinition       = unmarshalBool         (Doxygen::symbolStorage);
4075
  m_impl->category                = (ClassDef*)unmarshalObjPointer   (Doxygen::symbolStorage);
4076 4077 4078 4079
  marker = unmarshalUInt(Doxygen::symbolStorage);
  assert(marker==END_MARKER);
}

4080 4081
void MemberDef::makeResident() const
{ 
4082
  if (Doxygen::symbolCache==0) return;
4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159
  if (m_cacheHandle==-1) // not yet in cache
  { 
    MemberDef *victim = 0;
    MemberDef *that = (MemberDef*)this; // fake method constness
    that->m_cacheHandle = Doxygen::symbolCache->add(that,(void **)&victim);
    //printf("adding %s to cache, handle=%d\n",m_impl->name.data(),that->m_cacheHandle);
    if (victim)  // cache was full, victim was the least recently used item and has to go
    {
      victim->m_cacheHandle=-1; // invalidate cache handle
      victim->saveToDisk();     // store the item on disk
    }
    else // cache not yet full
    {
      //printf("Adding %s to cache, handle=%d\n",m_impl->name.data(),m_cacheHandle);
    }
    if (m_storagePos!=-1) // already been written to disk
    {
      if (isLocked()) // locked in memory
      {
        assert(m_impl!=0);
        that->m_flushPending=FALSE; // no need to flush anymore
      }
      else // not locked in memory
      {
        assert(m_impl==0);
        loadFromDisk();
      }
    }
  }
  else // already cached, make this object the most recently used.
  {
    assert(m_impl!=0);
    //printf("Touching symbol %s\n",m_impl->name.data());
    Doxygen::symbolCache->use(m_cacheHandle);
  }
}

void MemberDef::saveToDisk() const
{
  assert(m_impl!=0);
  MemberDef *that = (MemberDef *)this;
  if (isLocked()) // cannot flush the item as it is locked
  {
    that->m_flushPending=TRUE; // flush when unlocked
  }
  else // ready to flush the item to disk
  {
    //printf("Adding %s to cache, handle=%d by replacing %s\n",
    //    m_impl->name.data(),m_cacheHandle,victim->m_impl->name.data());
    if (m_storagePos!=-1) 
      // if victim was stored on disk already and is not locked
    {
      // free the storage space occupied by the old store item
      Doxygen::symbolStorage->release(m_storagePos); // free up space for others
    }
    // write a the new (possibly modified) instance to disk
    flushToDisk();
    // end to write sequence (unless nothing was written due to the lock)
    Doxygen::symbolStorage->end();
  }
}

void MemberDef::lock() const
{
}

void MemberDef::unlock() const
{
  if (m_flushPending && !isLocked())
  {
    // write a the new (possibly modified) instance to disk
    flushToDisk();
    // end to write sequence (unless nothing was written due to the lock)
    Doxygen::symbolStorage->end();
  }
}

4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177
void MemberDef::copyArgumentNames(MemberDef *bmd)
{
  makeResident();
  {
    LockingPtr<ArgumentList> arguments = bmd->argumentList();
    if (m_impl->defArgList && arguments!=0)
    {
      ArgumentListIterator aliDst(*m_impl->defArgList);
      ArgumentListIterator aliSrc(*arguments);
      Argument *argDst, *argSrc;
      for (;(argDst=aliDst.current()) && (argSrc=aliSrc.current());++aliDst,++aliSrc)
      {
        argDst->name = argSrc->name;
      }
    }
  }
  {
    LockingPtr<ArgumentList> arguments = bmd->declArgumentList();
4178
    if (m_impl->declArgList && arguments!=0)
4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189
    {
      ArgumentListIterator aliDst(*m_impl->declArgList);
      ArgumentListIterator aliSrc(*arguments);
      Argument *argDst, *argSrc;
      for (;(argDst=aliDst.current()) && (argSrc=aliSrc.current());++aliDst,++aliSrc)
      {
        argDst->name = argSrc->name;
      }
    }
  }
}
4190

4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209
static void invalidateCachedTypesInArgumentList(ArgumentList *al)
{
  if (al)
  {
    ArgumentListIterator ali(*al);
    Argument *a;
    for (ali.toFirst();(a=ali.current());++ali)
    {
      a->canType.resize(0);
    }
  }
}

void MemberDef::invalidateCachedArgumentTypes()
{
  makeResident();
  invalidateCachedTypesInArgumentList(m_impl->defArgList);
  invalidateCachedTypesInArgumentList(m_impl->declArgList);
}
4210