vhdldocgen.cpp 65.7 KB
Newer Older
1 2
/******************************************************************************
 *
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3
 * Copyright (C) 1997-2014 by Dimitri van Heesch.
4 5
 *
 * Permission to use, copy, modify, and distribute this software and its
6 7
 * documentation under the terms of the GNU General Public License is hereby
 * granted. No representations are made about the suitability of this software
8 9 10 11 12 13 14 15 16 17
 * for any purpose. It is provided "as is" without express or implied warranty.
 * See the GNU General Public License for more details.
 *
 * Documents produced by Doxygen are derivative works derived from the
 * input used in their production; they are not affected by this license.
 *
 */
/******************************************************************************
 * Parser for VHDL subset
 * written by M. Kreis
18
 * supports VHDL-87
19
 * does not support VHDL-AMS
20 21 22 23 24 25 26 27 28 29
 ******************************************************************************/

// global includes
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <qcstring.h>
#include <qfileinfo.h>
#include <qstringlist.h>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
30

31 32 33 34 35 36 37 38 39 40 41 42 43 44
/* --------------------------------------------------------------- */

// local includes
#include "vhdldocgen.h"
#include "message.h"
#include "config.h"
#include "doxygen.h"
#include "util.h"
#include "language.h"
#include "commentscan.h"
#include "index.h"
#include "definition.h"
#include "searchindex.h"
#include "outputlist.h"
Dimitri van Heesch's avatar
Dimitri van Heesch committed
45
#include "parserintf.h"
46 47
#include "classlist.h"
#include "entry.h"
48
#include "arguments.h"
49 50
#include "groupdef.h"
#include "namespacedef.h"
51
/* --------------------------------------------------------------- */
52

53
//#define theTranslator_vhdlType theTranslator->trVhdlType
54 55
#define theTranslator_vhdlType VhdlDocGen::trVhdlType

56 57
static QDict<QCString> g_vhdlKeyDict0(17,FALSE);
static QDict<QCString> g_vhdlKeyDict1(17,FALSE);
58
static QDict<QCString> g_vhdlKeyDict2(17,FALSE);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
59

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
// keywords
static const char* g_vhdlKeyWordMap0[] =
{
  "std","ieee","work","standard","textio","std_logic_1164",
  "std_logic_arith","std_logic_misc","std_logic_signed","std_logic_textio",
  "std_logic_unsigned","numeric_bit","numeric_std","math_complex","math_real",
  "vital_primitives","vital_timing","severity_level","time","delay_length",
  "natural", "positive", "bit_vector","file_open_kind","file_open_status",
  "line","text","side", "width","event","rising_edge", "falling_edge",
  "access","after","alias", "all","architecture","array", "assert","attribute",
  "begin","block","body", "buffer", "bus", "case", "component", "configuration",
  "constant", "disconnect", "downto", "else", "elsif", "end", "entity", "exit",
  "file", "for", "function", "generate", "generic", "group", "guarded", "if",
  "impure", "in", "inertial", "inout", "is","label", "library", "linkage",
  "literal", "loop","map", "new", "next", "null", "of", "on", "open", "others",
  "out", "package", "port", "postponed", "procedure", "process", "pure",
  "range", "record", "register", "reject", "report", "return","select",
  "severity", "shared", "signal", "subtype", "then", "to", "transport",
  "type","unaffected", "units", "until", "use","variable", "wait", "when",
  "while", "with","true","false","protected",0
};
Dimitri van Heesch's avatar
Dimitri van Heesch committed
81

82 83
// type
static const char* g_vhdlKeyWordMap1[] =
Dimitri van Heesch's avatar
Dimitri van Heesch committed
84
{
85 86 87 88
  "natural","unsigned","signed","string","boolean", "bit","character",
  "std_ulogic","std_ulogic_vector","sTd_logic","std_logic_vector","integer",
  "real","zzz",0
};
Dimitri van Heesch's avatar
Dimitri van Heesch committed
89

90 91
// logic
static const char* g_vhdlKeyWordMap2[] =
Dimitri van Heesch's avatar
Dimitri van Heesch committed
92
{
93 94 95
  "abs","and","or","not","mod", "xor","rem","xnor","ror","rol","sla",
  "sll",0
};
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138

VhdlDocGen::VhdlDocGen()
{
}

VhdlDocGen::~VhdlDocGen()
{
}

void VhdlDocGen::init()
{
  int j=0;
  g_vhdlKeyDict0.setAutoDelete(TRUE);
  g_vhdlKeyDict1.setAutoDelete(TRUE);
  g_vhdlKeyDict2.setAutoDelete(TRUE);

  j=0;
  while (g_vhdlKeyWordMap0[j])
  {
    g_vhdlKeyDict0.insert(g_vhdlKeyWordMap0[j],
	               new QCString(g_vhdlKeyWordMap0[j]));
    j++;
  }

  j=0;
  while (g_vhdlKeyWordMap1[j])
  {
    g_vhdlKeyDict1.insert(g_vhdlKeyWordMap1[j],
	               new QCString(g_vhdlKeyWordMap1[j]));
    j++;
  }

  j=0;
  while (g_vhdlKeyWordMap2[j])
  {
    g_vhdlKeyDict2.insert(g_vhdlKeyWordMap2[j],
	               new QCString(g_vhdlKeyWordMap2[j]));
    j++;
  }

}// buildKeyMap

/*!
139 140
 * returns the color of a keyword
 */
141 142 143

QCString* VhdlDocGen::findKeyWord(const QCString& word)
{
144 145 146 147
  static  QCString g_vhdlkeyword("vhdlkeyword");
  static  QCString g_vhdltype("comment");
  static  QCString g_vhdllogic("vhdllogic");

148
  if (word.isEmpty() || word.at(0)=='\0') return 0;
149 150
  //printf("VhdlDocGen::findKeyWord(%s)\n",word.data());

151
  if (g_vhdlKeyDict0.find(word.lower()))
152 153
    return &g_vhdlkeyword;

154
  if (g_vhdlKeyDict1.find(word.lower()))
155 156
    return &g_vhdltype;

157
  if (g_vhdlKeyDict2.find(word.lower()))
158 159 160 161 162 163 164 165 166
    return &g_vhdllogic;

  return 0;
}

ClassDef *VhdlDocGen::getClass(const char *name)
{
  if (name==0 || name[0]=='\0') return 0;

167
  ClassDef *cd=0;
168 169 170 171 172 173 174
  QCString temp(name);
  //temp=temp.lower();
  temp=temp.stripWhiteSpace();
  cd= Doxygen::classSDict->find(temp.data());
  return cd;
}

175 176 177 178
/*!
 * adds architectures to their entity
 */
void VhdlDocGen::computeVhdlComponentRelations()
179
{
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
  printf("VhdlDocGen::computeVhdlComponentRelations()\n");
  ClassSDict::Iterator cli(*Doxygen::classSDict);
  ClassDef *cd;
  for (cli.toFirst();(cd=cli.current());++cli)
  {
    printf("  cd=%s\n",cd->name().data());
    if (cd->getLanguage()==SrcLangExt_VHDL &&
        ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::ARCHITECTURECLASS ||
         (VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKBODYCLASS
        )
       )
    {
      QCString bName=cd->name();
      int i=bName.find("::");
      if (i>0)
      {
        QCString entityName=bName.left(i);
        entityName.stripPrefix("_");
        ClassDef *classEntity=Doxygen::classSDict->find(entityName);
        printf("  entity=%s p=%p\n",entityName.data(),classEntity);
        // entity for architecutre ?
        if (classEntity)
        {
          MemberList *ml = cd->getMemberList(MemberListType_pubAttribs);
          //printf("    found %d members\n",ml->count());
          if (ml)
          {
            MemberListIterator mli(*ml);
            MemberDef *md;
            for (mli.toFirst();(md=mli.current());++mli)
            {
              int spec=md->getMemberSpecifiers();
              if (spec==VhdlDocGen::COMPONENT)
              {
                printf("       name %s\n",md->name().data());
                ClassDef *baseEntity=Doxygen::classSDict->find(md->name());
                if (baseEntity)
                {
                  classEntity->insertBaseClass(baseEntity,baseEntity->name(),Public,Normal,0);
                  baseEntity->insertSubClass(classEntity,Public,Normal,0);
                }
              }
            }
          }
        }
      }
    }
  }
} // computeVhdlComponentRelations
229 230


231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
/*
 * returns a reference, if one class [package(body),entity or an architecture is found]
 */

ClassDef* VhdlDocGen::findComponent(int type)
{
  ClassSDict::Iterator cli(*Doxygen::classSDict);
  ClassDef *cd=0;

  for ( ; (cd=cli.current()) ; ++cli )
  {
    if (cd->protection()==type)
      return cd;
  }
  return cd;
}

ClassDef* VhdlDocGen::getPackageName(const QCString & name)
{
  ClassDef* cd=0;
  QStringList ql=QStringList::split(".",name,FALSE);
  cd=getClass(name);

  return cd;
}

MemberDef* VhdlDocGen::findMember(const QCString& className, const QCString& memName)
{
  QDict<QCString> packages(17,FALSE);
  packages.setAutoDelete(TRUE);
  ClassDef* cd;
  MemberDef *mdef=0;
263 264 265 266 267

  cd=getClass(className);
  //printf("VhdlDocGen::findMember(%s,%s)=%p\n",className.data(),memName.data(),cd);
  if (cd==0) return 0;

268
  mdef=VhdlDocGen::findMemberDef(cd,memName,MemberListType_variableMembers);
269
  if (mdef) return mdef;
270
  mdef=VhdlDocGen::findMemberDef(cd,memName,MemberListType_pubMethods);
271 272
  if (mdef) return mdef;

273
  // nothing found so far
274 275
  // if we are an architecture or package body search in entitiy

276
  if ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::ARCHITECTURECLASS ||
277 278 279
      (VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKBODYCLASS)
  {
    Definition *d = cd->getOuterScope();
280
     // searching upper/lower case names
281

282
    QCString tt=d->name();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
283 284
    ClassDef *ecd =getClass(tt);
    if (!ecd)
285
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
286 287 288
      tt=tt.upper();
      ecd =getClass(tt);
    }
289
    if (!ecd)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
290 291
    {
      tt=tt.lower();
292
      ecd =getClass(tt);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
293 294 295 296 297
    }

    if (ecd) //d && d->definitionType()==Definition::TypeClass)
    {
      //ClassDef *ecd = (ClassDef*)d;
298
      mdef=VhdlDocGen::findMemberDef(ecd,memName,MemberListType_variableMembers);
299
      if (mdef) return mdef;
300 301
       mdef=VhdlDocGen::findMemberDef(cd,memName,MemberListType_pubMethods);
       if (mdef) return mdef;
302 303 304 305
    }
    //cd=getClass(getClassName(cd));
    //if (!cd) return 0;
  }
306
  // nothing found , so we are now searching all included packages
307 308
  VhdlDocGen::findAllPackages(className,packages);
  //cd=getClass(className.data());
309
  if ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::ARCHITECTURECLASS ||
310 311 312
      (VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKBODYCLASS)
  {
    Definition *d = cd->getOuterScope();
313

Dimitri van Heesch's avatar
Dimitri van Heesch committed
314 315 316 317 318 319 320 321 322 323
    QCString tt=d->name();
    ClassDef *ecd =getClass(tt);
    if (!ecd)
    {
      tt=tt.upper();
      ecd =getClass(tt);
    }
    if (!ecd)
    {
      tt=tt.lower();
324
      ecd =getClass(tt);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
325 326 327
    }

    if (ecd) //d && d->definitionType()==Definition::TypeClass)
328
    {
329
      VhdlDocGen::findAllPackages(ecd->className(),packages);
330 331 332 333 334 335 336 337 338 339
    }
  }

  QDictIterator<QCString> packli(packages);
  QCString *curString;
  for (packli.toFirst();(curString=packli.current());++packli)
  {
    if (curString)
    {
      cd=VhdlDocGen::getPackageName(*curString);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
340 341 342 343 344 345 346 347
      if (!cd)
      {
        *curString=curString->upper();
        cd=VhdlDocGen::getPackageName(*curString);
      }
      if (!cd)
      {
        *curString=curString->lower();
348
        cd=VhdlDocGen::getPackageName(*curString);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
349
      }
350 351
    }
    if (cd)
352
    {
353
      mdef=VhdlDocGen::findMemberDef(cd,memName,MemberListType_variableMembers);
354
      if (mdef)  return mdef;
355
      mdef=VhdlDocGen::findMemberDef(cd,memName,MemberListType_pubMethods);
356 357 358 359 360 361 362 363 364 365 366
      if (mdef) return mdef;
    }
  } // for
  return 0;
}//findMember

/**
 *  This function returns the entity|package
 *  in which the key (type) is found
 */

367
MemberDef* VhdlDocGen::findMemberDef(ClassDef* cd,const QCString& key,MemberListType type)
368
{
369
  //    return cd->getMemberByName(key);//does not work
370 371 372 373 374 375 376 377 378
  MemberDef *md=0;

  MemberList *ml=    cd->getMemberList(type);
  if (ml==0) return 0;

  MemberListIterator fmni(*ml);

  for (fmni.toFirst();(md=fmni.current());++fmni)
  {
379
    if (qstricmp(key.data(),md->name().data())==0)
380
      return md;
381
  }
382 383 384 385 386 387 388 389 390 391 392 393
  return 0;
}//findMemberDef

/*!
 * finds all included packages of an Entity or Package
 */

void VhdlDocGen::findAllPackages(const QCString& className,QDict<QCString>& qdict)
{
  ClassDef *cdef=getClass(className);
  if (cdef)
  {
394
    MemberList *mem=cdef->getMemberList(MemberListType_variableMembers);
395 396 397 398 399 400 401
    MemberDef *md;

    if (mem)
    {
      MemberListIterator fmni(*mem);
      for (fmni.toFirst();(md=fmni.current());++fmni)
      {
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
	if (VhdlDocGen::isPackage(md))
	{
	  QCString *temp1=new QCString(md->name().data());
	  //*temp1=temp1->lower();
	  QCString p(md->name().data());
	  //p=p.lower();
	  ClassDef* cd=VhdlDocGen::getPackageName(*temp1);
	  if (cd)
	  {
	    QCString *ss=qdict.find(*temp1);
	    if (ss==0)
	    {
	      qdict.insert(p,temp1);
	      QCString tmp=cd->className();
	      VhdlDocGen::findAllPackages(tmp,qdict);
	    }
	    else delete temp1;
	  }
	  else delete temp1;
	}
422 423 424 425 426 427 428 429 430 431 432
      }//for
    }//if
  }//cdef
}// findAllPackages

/*!
 * returns the function with the matching argument list
 * is called in vhdlcode.l
 */

MemberDef* VhdlDocGen::findFunction(const QList<Argument> &ql,
433 434
                                    const QCString& funcname,
				    const QCString& package, bool type)
435 436
{
  MemberDef* mdef=0;
437
  int funcType;
438 439 440
  ClassDef *cdef=getClass(package.data());
  if (cdef==0) return 0;

441 442 443 444 445
  if (type)
    funcType=VhdlDocGen::PROCEDURE;
  else
    funcType=VhdlDocGen::FUNCTION;

446
  MemberList *mem=cdef->getMemberList(MemberListType_pubMethods);
447 448 449 450 451 452 453

  if (mem)
  {
    MemberListIterator fmni(*mem);
    for (fmni.toFirst();(mdef=fmni.current());++fmni)
    {
      QCString mname=mdef->name();
454
      if ((VhdlDocGen::isProcedure(mdef) || VhdlDocGen::isVhdlFunction(mdef)) && (VhdlDocGen::compareString(funcname,mname)==0))
455
      {
456
	ArgumentList *alp = mdef->argumentList();
457

458 459
	//  ArgumentList* arg2=mdef->getArgumentList();
	if (alp==0) break;
460
        ArgumentListIterator ali(*alp);
461 462
        ArgumentListIterator ali1(ql);

463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486
	if (ali.count() != ali1.count()) break;

	Argument *arg,*arg1;
	int equ=0;

	for (;(arg=ali.current());++ali)
	{
	  arg1=ali1.current(); ++ali1;
	  equ+=abs(VhdlDocGen::compareString(arg->type,arg1->type));

	  QCString s1=arg->type;
	  QCString s2=arg1->type;
	  VhdlDocGen::deleteAllChars(s1,' ');
	  VhdlDocGen::deleteAllChars(s2,' ');
	  equ+=abs(VhdlDocGen::compareString(s1,s2));
	  s1=arg->attrib;
	  s2=arg1->attrib;
	  VhdlDocGen::deleteAllChars(s1,' ');
	  VhdlDocGen::deleteAllChars(s2,' ');
	  equ+=abs(VhdlDocGen::compareString(s1,s2));
	  // printf("\n 1. type [%s] name [%s] attrib [%s]",arg->type,arg->name,arg->attrib);
	  // printf("\n 2. type [%s] name [%s] attrib [%s]",arg1->type,arg1->name,arg1->attrib);
	} // for
	if (equ==0) return mdef;
487
      }//if
488 489
    }//for
  }//if
490 491 492
  return mdef;
} //findFunction

493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601
/*!
 * returns the function with the matching argument list
 * is called in vhdscan.l
 */

Entry* VhdlDocGen::findFunction( Entry* root, Entry* func)
{
  //bool found=FALSE;
  Entry *found=0;
  uint64 functype=func->spec;
  EntryListIterator eli(*root->children());
  Entry *rt;
  for (;(rt=eli.current());++eli)
  {
    if (rt->spec==functype && VhdlDocGen::compareString(rt->name,func->name)==0 && rt!=func )
    {
      if (VhdlDocGen::compareArgList(func->argList,rt->argList))
      {
	found=rt;
	return found;
      }
    }//if1
    if (!found)
    {
      found = VhdlDocGen::findFunction(rt,func);
    }
  } // for
  return found;
}// findFunction

/*
 * compares two argument list of a fuction|procedure
 */

bool VhdlDocGen::compareArgList(ArgumentList* l1,ArgumentList* l2)
{
  if (l1== 0 || l2== 0) return FALSE;

  ArgumentListIterator ali(*l1);
  ArgumentListIterator ali1(*l2);

  if (ali.count() != ali1.count()) return FALSE;

  Argument *arg,*arg1;
  int equ=0;

  for (;(arg=ali.current());++ali)
  {
    bool found = FALSE;
    for (ali1.toFirst();(arg1=ali1.current());++ali1)
    {
      equ=0;
      QCString s1=arg->type;
      QCString s2=arg1->type;
      VhdlDocGen::deleteAllChars(s1,' '); // remove whitespaces
      VhdlDocGen::deleteAllChars(s2,' ');
      equ+=abs(VhdlDocGen::compareString(s1,s2));
      s1=arg->attrib;
      s2=arg1->attrib;
      VhdlDocGen::deleteAllChars(s1,' ');
      VhdlDocGen::deleteAllChars(s2,' ');
      equ+=abs(VhdlDocGen::compareString(s1,s2));
      if (equ==0) found=TRUE;
    }
    if (!found) return FALSE;
  }
  return TRUE;
}// compareArgList

/*
 * finds a matching prototype for a function description
 */

Entry* VhdlDocGen::findFunction(Entry* func)
{
  ClassSDict::Iterator cli(*Doxygen::classSDict);
  ClassDef *cd;
  for (;(cd=cli.current());++cli)
  {
    MemberList *mf = cd->getMemberList (MemberListType_pubMethods);
    if (mf)
    {
      MemberListIterator fmni(*mf);
      MemberDef *mdd;
      for (fmni.toFirst();(mdd=fmni.current());++fmni)
      {
	int type=mdd->getMemberSpecifiers();
	if (type==VhdlDocGen::PROCEDURE || type==VhdlDocGen::FUNCTION)
	{
	  QCString nnk=mdd->name();
	  QCString ff=func->name;

	  if (qstricmp(mdd->name(),ff.data())==0)
	  {
	    ArgumentList *l=mdd->argumentList();
	    if (VhdlDocGen::compareArgList(l,func->argList))
	    {
	      mdd->setDocumentation(func->doc.data(),func->docFile.data(),func->docLine,TRUE);
	      mdd->setBriefDescription(func->brief,func->briefFile,func->briefLine);
	      addMemberToGroups(func,mdd);// do not forget grouping!
	      return func;
	    }
	  }
	}
      }
    }// if
  }//for
  return 0;
}// findFunction
602

603 604 605
/*
 * adds the documentation for a function|procedure
 */
606

607 608 609 610 611 612 613 614 615 616 617 618 619 620 621
void VhdlDocGen::addFuncDoc(EntryNav* rootNav)
{
  Entry *root = rootNav->entry();
  if (root &&  root->spec==VhdlDocGen::DOCUMENT)
  {
    Entry *func=VhdlDocGen::findFunction(root);
    if (!func && Config_getBool("WARNINGS"))
    {
      warn(root->fileName,root->docLine,
      "warning: documentation for unknown function %s found.\n",
      root->name.data()
      );
    }
  }
}// AddFuncDoc
622

623
/*!
624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647
 * returns the class title+ref
 */

QCString VhdlDocGen::getClassTitle(const ClassDef *cd)
{
  QCString pageTitle;
  if (cd==0) return "";
  pageTitle+=cd->displayName();
  pageTitle=VhdlDocGen::getClassName(cd);
  int ii=cd->protection();
  pageTitle+=" ";
  pageTitle+=theTranslator_vhdlType(ii+2,TRUE);
  pageTitle+=" ";
  return pageTitle;
} // getClassTitle

/* returns the class name without their prefixes */

QCString VhdlDocGen::getClassName(const ClassDef* cd)
{
  QCString temp;
  if (cd==0) return "";

  if ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKBODYCLASS)
648
  {
649 650 651
    temp=cd->name();
    temp.stripPrefix("_");
    return temp;
652
  }
653 654 655 656 657 658 659
  //if ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::ARCHITECTURECLASS)
  //{
  //  QStringList qlist=QStringList::split("-",cd->className(),FALSE);
  //  if (qlist.count()>1)
  //    return (QCString)qlist[1];
  //  return "";
  //}
660 661 662
  return substitute(cd->className(),"::",".");
}

663
/*!
664 665 666 667 668 669 670 671 672 673 674 675
 * writes an inline link form entity|package to architecture|package body and vice verca
 */

void VhdlDocGen::writeInlineClassLink(const ClassDef* cd ,OutputList& ol)
{
  QList<QCString> ql;
  ql.setAutoDelete(TRUE);
  QCString nn=cd->className();
  int ii=(int)cd->protection()+2;

  QCString type;
  if (ii==VhdlDocGen::ENTITY)
676
    type=theTranslator_vhdlType(VhdlDocGen::ARCHITECTURE,TRUE);
677
  else if (ii==VhdlDocGen::ARCHITECTURE)
678
    type=theTranslator_vhdlType(VhdlDocGen::ENTITY,TRUE);
679
  else if (ii==VhdlDocGen::PACKAGE_BODY)
680
    type=theTranslator_vhdlType(VhdlDocGen::PACKAGE,TRUE);
681
  else if (ii==VhdlDocGen::PACKAGE)
682
    type=theTranslator_vhdlType(VhdlDocGen::PACKAGE_BODY,TRUE);
683

684
  //type=type.lower();
685
  type+=" >> ";
686
  ol.disable(OutputGenerator::RTF);
687 688
  ol.disable(OutputGenerator::Man);

689
  if (ii==VhdlDocGen::PACKAGE_BODY)
690 691 692 693
  {
    nn.stripPrefix("_");
    cd=getClass(nn.data());
  }
694
  else  if (ii==VhdlDocGen::PACKAGE)
695 696 697 698 699 700 701
  {
    nn.prepend("_");
    cd=getClass(nn.data());
  }
  else if (ii==VhdlDocGen::ARCHITECTURE)
  {
    QStringList qlist=QStringList::split("-",nn,FALSE);
702
    nn=qlist[1].utf8();
703
    cd=VhdlDocGen::getClass(nn.data());
704
  }
705 706 707

  QCString opp;
  if (ii==VhdlDocGen::ENTITY)
708
  {
709 710 711 712 713 714
    VhdlDocGen::findAllArchitectures(ql,cd);
    int j=ql.count();
    for (int i=0;i<j;i++)
    {
      QCString *temp=ql.at(i);
      QStringList qlist=QStringList::split("-",*temp,FALSE);
715 716
      QCString s1=(QCString)qlist[0].utf8();
      QCString s2=(QCString)qlist[1].utf8();
717 718 719 720 721
      s1.stripPrefix("_");
      if (j==1) s1.resize(0);
      ClassDef*cc = getClass(temp->data());
      if (cc)
      {
722
	VhdlDocGen::writeVhdlLink(cc,ol,type,s2,s1);
723
      }
724 725
    }
  }
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748
  else
  {
    VhdlDocGen::writeVhdlLink(cd,ol,type,nn,opp);
  }

  ol.enable(OutputGenerator::Man);
  ol.enable(OutputGenerator::RTF);

}// write

/*
 * finds all architectures which belongs to an entiy
 */
void VhdlDocGen::findAllArchitectures(QList<QCString>& qll,const ClassDef *cd)
{
  ClassDef *citer;
  ClassSDict::Iterator cli(*Doxygen::classSDict);
  for ( ; (citer=cli.current()) ; ++cli )
  {
    QCString jj=citer->className();
    if (cd != citer && jj.contains('-')!=-1)
    {
      QStringList ql=QStringList::split("-",jj,FALSE);
749 750
      QCString temp=(QCString)ql[1].utf8();
      if (qstricmp(cd->className().data(),temp.data())==0)
751
      {
752 753
	QCString *cl=new QCString(jj.data());
	qll.insert(0,cl);
754
      }
755
    }
756 757 758 759
  }// for
}//findAllArchitectures

/*
760
 * writes the link entity >> .... or architecture >> ...
761 762 763 764 765 766 767 768 769 770
 */

void VhdlDocGen::writeVhdlLink(const ClassDef* ccd ,OutputList& ol,QCString& type,QCString& nn,QCString& behav)
{
  if (ccd==0)  return;
  QCString temp=ccd->getOutputFileBase();
  ol.startBold();
  ol.docify(type.data());
  ol.endBold();
  nn.stripPrefix("_");
771
  ol.writeObjectLink(ccd->getReference(),ccd->getOutputFileBase(),ccd->anchor(),nn.data());
772

773
  if (!behav.isEmpty())
774 775 776 777 778 779
  {
    behav.prepend("  ");
    ol.startBold();
    ol.docify(behav.data());
    ol.endBold();
  }
780 781 782 783 784 785 786 787 788 789 790 791 792
  /*
     if (Config_getBool("SOURCE_BROWSER")) { // writes a source link for latex docu
     ol.pushGeneratorState();
     ol.disableAllBut(OutputGenerator::Latex);
     ol.docify(" | ");
     ol.startEmphasis();
     FileDef* fd=ccd->getFileDef();
     if (fd)
     ol.writeObjectLink(0,fd->getSourceFileBase(),0,theTranslator->trGotoSourceCode().data());
     ol.endEmphasis();
     ol.popGeneratorState();
     }
   */
793 794 795
  ol.lineBreak();
}

796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949
bool VhdlDocGen::compareString(const QCString& s1,const QCString& s2)
{
  QCString str1=s1.stripWhiteSpace();
  QCString str2=s2.stripWhiteSpace();

  return qstricmp(str1.data(),str2.data());
}

bool VhdlDocGen::getSigTypeName(QList<QCString>& ql, const char* str,QCString& buffer)
{
  //QCString temp(str);
  //QStringList qlist=QStringList::split(" is ",temp,FALSE);
  //if (qlist.count()!=2) return FALSE;
  //temp.resize(0);
  //temp+=(QCString)qlist[0]+":"+(QCString)qlist[1];
  //return VhdlDocGen::getSigName(ql,temp.data(),buffer);
  return VhdlDocGen::getSigName(ql,str,buffer);
}

/*!
 * divides a port input   in its name,direction and type
 * @param ql stores the input name(s)
 * @param str input string
 * @param buffer stores the input direction
 * @returns FALSE if it is a port
 */

bool VhdlDocGen::getSigName(QList<QCString>& ql,
                            const char* str,QCString& buffer)
{
  int j,ll,index;
  const char *signal = "signal ";
  QCString qmem;
  QCString temp(str);
  QCString st(str);

  //QRegExp semi(",");
  //QRegExp r(":");

  // colon position
  j = temp.find(':');
  if (j < 0) return FALSE; // no input definition
  st=st.left(j); // name only
  index=st.find(signal,0,FALSE);
  if (index > -1) // found "signal "
  {
    qmem=st.remove(index,strlen(signal)); // strip it
    temp=qmem;
    st=qmem;
  }
  else
  {
    qmem=temp;
  }

  ll=st.find(',');

  if (ll>0) // multiple names
  {
    while (TRUE)
    {
      st=st.left(ll).stripWhiteSpace(); // one name

      QCString *sig =new QCString(st);
      ql.insert(0,sig);
      qmem=qmem.right(qmem.length()-ll-1); // strip from list
      st=qmem; // remainder
      ll=st.find(',');
      if (ll<0) // last name
      {
	ll = st.find(':');
	st=st.left(ll).stripWhiteSpace();
	ql.insert(0,new QCString(st));
	break;
      }
    }
  }
  else // single name
  {
    st=st.stripWhiteSpace();
    ql.insert(0,new QCString(st));
  }
  QCString *qdir=new QCString(str);
  st=qdir->mid(j+1); // part after :
  st=st.lower().stripWhiteSpace();
  *qdir=st;
  ql.insert(0,qdir);

  if (st.stripPrefix("inout"))
  {
    buffer+="inout";
    return TRUE;
  }
  if (st.stripPrefix("INOUT"))
  {
    buffer+="inout";
    return TRUE;
  }

  if (st.stripPrefix("out"))
  {
    buffer+="out";
    return TRUE;
  }
  if (st.stripPrefix("OUT"))
  {
    buffer+="out";
    return TRUE;
  }

  if (st.stripPrefix("in"))
  {
    buffer+="in";
    return TRUE;
  }
  if (st.stripPrefix("IN"))
  {
    buffer+="in";
    return TRUE;
  }
  return FALSE;
}

/*!
 * divides a process string in its name and types
 * @param text process text
 * @param name points to the process name
 * @param ql stores the process types
 */

void VhdlDocGen::parseProcessProto(const char* text,
                                  QCString& name,QStringList& ql)
{
  int index,end;
  const char *s=":";
  QCString temp;
  QCString s1(text);
  index=s1.find(s,0,FALSE);
  if (index >=0)
  {
    name=s1.left(index);
    //  strcpy(name,tt.data());
  }

  index=s1.find("(",0,FALSE);
  end=s1.findRev(")",s1.length(),FALSE);
  // end=s1.find(")",0,FALSE);

  if ((end-index)>1)
  {
    temp=s1.mid(index+1,(end-index-1));
    ql=QStringList::split(",",temp,FALSE);
  }
}//parseProcessProto
950 951

/*!
952
 * strips the "--" prefixes of vhdl comments
953 954 955
 */
void VhdlDocGen::prepareComment(QCString& qcs)
{
956
  QCString temp;
957
  const char* s="--!";
958 959
  //const char *start="--!{";
  //const char *end="--!}";
960
  int index=0;
961

962 963 964 965 966 967 968 969 970 971 972
#if 0
  index=qcs.find(start,0,TRUE);
  if (index>0)
    temp=qcs.remove(index,strlen(start));
  qcs=temp;

  index=qcs.find(end,0,TRUE);
  if (index>0)
    temp=qcs.remove(index,strlen(end));
  qcs=temp;
#endif
973 974 975 976
  while (TRUE)
  {
    index=qcs.find(s,0,TRUE);
    if (index<0) break;
977 978
    temp=qcs.remove(index,strlen(s));
    qcs=temp;
979 980 981 982 983 984 985 986 987 988 989 990 991 992
  }
  qcs=qcs.stripWhiteSpace();
}


/*!
 * parses a function proto
 * @param text function string
 * @param qlist stores the function types
 * @param name points to the function name
 * @param ret Stores the return type
 * @param doc ???
 */
void VhdlDocGen::parseFuncProto(const char* text,QList<Argument>& qlist,
993
                                QCString& name,QCString& ret,bool doc)
994
{
995
  (void)qlist; //unused
996 997 998 999 1000 1001 1002
  int index,end;
  QCString s1(text);
  QCString temp;

  index=s1.find("(");
  end=s1.findRev(")");

1003
  if ((end-index)>0)
1004 1005 1006
  {
    QCString tt=s1.mid(index,(end-index+1));
    temp=s1.mid(index+1,(end-index-1));
1007
    //getFuncParams(qlist,temp);
1008
  }
1009 1010 1011 1012
  if (doc)
  {
    name=s1.left(index);
    name=name.stripWhiteSpace();
1013 1014
    if ((end-index)>0)
    {
1015
      ret="function";
1016
    }
1017 1018 1019
    return;
  }
  else
1020
  {
1021 1022 1023
    QCString s1(text);
    s1=s1.stripWhiteSpace();
    int i=s1.find("(",0,FALSE);
1024 1025
    int s=s1.find(QRegExp("[ \\t]"));
    if (i==-1 || i<s)
1026
      s1=VhdlDocGen::getIndexWord(s1.data(),1);
1027
    else // s<i, s=start of name, i=end of name
1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048
      s1=s1.mid(s,(i-s));

    name=s1.stripWhiteSpace();
  }
  index=s1.findRev("return",-1,FALSE);
  if (index !=-1)
  {
    ret=s1.mid(index+6,s1.length());
    ret=ret.stripWhiteSpace();
    VhdlDocGen::deleteCharRev(ret,';');
  }
}

/*
 *  returns the n'th word of a string
 */

QCString VhdlDocGen::getIndexWord(const char* c,int index)
{
  QStringList ql;
  QCString temp(c);
1049
  QRegExp reg("[\\s]");
1050 1051 1052 1053 1054

  ql=QStringList::split(reg,temp,FALSE);

  if (ql.count() > (unsigned int)index)
  {
1055
    return ql[index].utf8();
1056 1057 1058 1059 1060 1061
  }

  return "";
}


Dimitri van Heesch's avatar
Dimitri van Heesch committed
1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074
QCString VhdlDocGen::getProtectionName(int prot)
{
  if (prot==VhdlDocGen::ENTITYCLASS)
    return "entity";
  else if (prot==VhdlDocGen::ARCHITECTURECLASS)
    return "architecture";
  else if (prot==VhdlDocGen::PACKAGECLASS)
    return "package";
  else if (prot==VhdlDocGen::PACKBODYCLASS)
    return "package body";

  return "";
}
1075

1076
QCString VhdlDocGen::trTypeString(uint64 type)
1077 1078 1079
{
  switch(type)
  {
1080
    case VhdlDocGen::LIBRARY:        return "Library";
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097
    case VhdlDocGen::ENTITY:         return "Entity";
    case VhdlDocGen::PACKAGE_BODY:   return "Package Body";
    case VhdlDocGen::ATTRIBUTE:      return "Attribute";
    case VhdlDocGen::PACKAGE:        return "Package";
    case VhdlDocGen::SIGNAL:         return "Signal";
    case VhdlDocGen::COMPONENT:      return "Component";
    case VhdlDocGen::CONSTANT:       return "Constant";
    case VhdlDocGen::TYPE:           return "Type";
    case VhdlDocGen::SUBTYPE:        return "Subtype";
    case VhdlDocGen::FUNCTION:       return "Function";
    case VhdlDocGen::RECORD:         return "Record";
    case VhdlDocGen::PROCEDURE:      return "Procedure";
    case VhdlDocGen::ARCHITECTURE:   return "Architecture";
    case VhdlDocGen::USE:            return "Package";
    case VhdlDocGen::PROCESS:        return "Process";
    case VhdlDocGen::PORT:           return "Port";
    case VhdlDocGen::GENERIC:        return "Generic";
1098
    case VhdlDocGen::DOCUMENT:       return "Doc";
1099
    case VhdlDocGen::UNITS:          return "Units";
1100
    //case VhdlDocGen::PORTMAP:        return "Port Map";
1101 1102 1103
    case VhdlDocGen::SHAREDVARIABLE: return "Shared Variable";
    case VhdlDocGen::GROUP:          return "Group";
    case VhdlDocGen::VFILE:          return "File";
1104
    case VhdlDocGen::COMPONENT_INST: return "Component Instantiation";
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1105
    case VhdlDocGen::ALIAS:          return "Alias";
1106 1107
    case VhdlDocGen::CONFIG:         return "Configuration";
    case VhdlDocGen::MISCELLANEOUS:  return "Miscellaneous";
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1108
    default:                         return "";
1109 1110 1111 1112
  }
} // convertType

/*!
1113
 * deletes a char backwards in a string
1114 1115 1116 1117 1118 1119 1120
 */

bool VhdlDocGen::deleteCharRev(QCString &s,char c)
{
  int index=s.findRev(c,-1,FALSE);
  if (index > -1)
  {
1121
    QCString qcs=s.remove(index,1);
1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132
    s=qcs;
    return TRUE;
  }
  return FALSE;
}

void VhdlDocGen::deleteAllChars(QCString &s,char c)
{
  int index=s.findRev(c,-1,FALSE);
  while (index > -1)
  {
1133
    QCString qcs=s.remove(index,1);
1134 1135
    s=qcs;
    index=s.findRev(c,-1,FALSE);
1136
  }
1137 1138 1139
}


1140
static int recordCounter=0;
1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168

/*!
 * returns the next number of a record|unit member
 */

QCString VhdlDocGen::getRecordNumber()
{
  char buf[12];
  sprintf(buf,"%d",recordCounter++);
  QCString qcs(&buf[0]);
  return qcs;
}

/*!
 * returns the next number of an anonymous process
 */

QCString VhdlDocGen::getProcessNumber()
{
  static int stringCounter;
  char buf[8];
  QCString qcs("PROCESS_");
  sprintf(buf,"%d",stringCounter++);
  qcs.append(&buf[0]);
  return qcs;
}

/*!
1169
 * writes a colored and formatted string
1170 1171
 */

1172
void VhdlDocGen::writeFormatString(const QCString& s,OutputList&ol,const MemberDef* mdef)
1173
{
1174
  QRegExp reg("[\\/\\:\\<\\>\\:\\s\\,\\;\\'\\+\\-\\*\\|\\&\\=\\(\\)\"]");
1175
  QCString qcs = s;
1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194
  qcs+=QCString(" ");// parsing the last sign
  QCString *ss;
  QCString find=qcs;
  QCString temp=qcs;
  char buf[2];
  buf[1]='\0';

  int j;
  int len;
  j = reg.match(temp.data(),0,&len);

  ol.startBold();
  if (j>=0)
  {
    while (j>=0)
    {
      find=find.left(j);
      buf[0]=temp[j];
      ss=VhdlDocGen::findKeyWord(find);
1195
      bool k=VhdlDocGen::isNumber(find); // is this a number
1196 1197
      if (k)
      {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1198
        ol.docify(" ");
1199
        VhdlDocGen::startFonts(find,"vhdldigit",ol);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1200
        ol.docify(" ");
1201 1202 1203
      }
      else if (j != 0 && ss)
      {
1204
	VhdlDocGen::startFonts(find,ss->data(),ol);
1205 1206 1207
      }
      else
      {
1208 1209 1210 1211
	if (j>0)
	{
	  VhdlDocGen::writeStringLink(mdef,find,ol);
	}
1212
      }
1213
      VhdlDocGen::startFonts(&buf[0],"vhdlchar",ol);
1214 1215 1216

      QCString st=temp.remove(0,j+1);
      find=st;
1217
      temp=st;
1218 1219 1220 1221 1222
      j = reg.match(temp.data(),0,&len);
    }//while
  }//if
  else
  {
1223
    VhdlDocGen::startFonts(find,"vhdlchar",ol);
1224 1225 1226 1227 1228 1229 1230
  }
  ol.endBold();
}// writeFormatString

/*!
 * returns TRUE if this string is a number
 */
1231

1232 1233
bool VhdlDocGen::isNumber(const QCString& s)
{
1234
  static QRegExp regg("[0-9][0-9eEfFbBcCdDaA_.#-]*");
1235

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1236
  if (s.isEmpty()) return FALSE;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1237 1238
  int j,len;
  j = regg.match(s.data(),0,&len);
1239
  if ((j==0) && (len==(int)s.length())) return TRUE;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1240
  return FALSE;
1241

1242 1243 1244 1245 1246 1247 1248 1249 1250 1251
  #if 0
  int len=s.length();
  if (len==0) return FALSE;
  for (int j=0;j<len;j++)
  {
    if (isdigit((int)(s.at(j) & 0xff))==0)
      return FALSE;
  }
  return TRUE;
  #endif
1252 1253
}// isNumber

1254 1255 1256 1257 1258 1259
void VhdlDocGen::startFonts(const QCString& q, const char *keyword,OutputList& ol)
{
  ol.startFontClass(keyword);
  ol.docify(q.data());
  ol.endFontClass();
}
1260 1261

/*!
1262
 * inserts white spaces for  better readings
1263 1264 1265
 * and writes a colored string to the output
 */

1266
void VhdlDocGen::formatString(QCString & qcs, OutputList& ol,const MemberDef* mdef)
1267 1268
{
  QCString temp(qcs.length());
1269 1270 1271 1272 1273 1274
  qcs.stripPrefix(":");
  qcs.stripPrefix("is");
  qcs.stripPrefix("IS");
  qcs.stripPrefix("of");
  qcs.stripPrefix("OF");

1275
  VhdlDocGen::deleteCharRev(qcs,';');
1276 1277 1278 1279 1280 1281 1282 1283 1284
  //char white='\t';
  int len = qcs.length();
  unsigned int index=1;//temp.length();

  for (int j=0;j<len;j++)
  {
    char c=qcs[j];
    char b=c;
    if (j>0) b=qcs[j-1];
1285
    if (c=='"' || c==',' || c==';' || c=='\''|| c=='(' || c==')'  || c==':' ) // || (c==':' && b!='=')) // || (c=='=' && b!='>'))
1286 1287 1288
    {
      if (temp.at(index-1) != ' ')
      {
1289
	temp+=" ";
1290
      }
1291
      temp+=c;
1292
      temp+=" ";
1293
    }
1294
    else if (c=='=')
1295 1296
    {
      if (b==':') // := operator
1297
      {
1298 1299
	temp.replace(index-1,1,"=");
	temp+=" ";
1300 1301 1302
      }
      else // = operator
      {
1303 1304 1305
	temp+=" ";
	temp+=c;
	temp+=" ";
1306 1307
      }
    }
1308
    else
1309
    {
1310
      temp+=c;
1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329
    }

    index=temp.length();
  }// for
  temp=temp.stripWhiteSpace();
  // printf("\n [%s]",qcs.data());
  VhdlDocGen::writeFormatString(temp,ol,mdef);
}

/*!
 * writes a procedure prototype to the output
 */

void VhdlDocGen::writeProcedureProto(OutputList& ol,const ArgumentList* al,const MemberDef* mdef)
{
  ArgumentListIterator ali(*al);
  Argument *arg;
  bool sem=FALSE;
  int len=al->count();
1330
  ol.docify("( ");
1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345
  if (len > 2)
  {
    ol.lineBreak();
  }
  for (;(arg=ali.current());++ali)
  {
    ol.startBold();
    if (sem && len <3)
      ol.writeChar(',');

    QCString nn=arg->name;
    nn+=": ";

    QCString *str=VhdlDocGen::findKeyWord(arg->defval);
    arg->defval+=" ";
1346
    if (str)
1347
    {
1348
      VhdlDocGen::startFonts(arg->defval,str->data(),ol);
1349 1350 1351
    }
    else
    {
1352
      VhdlDocGen::startFonts(arg->defval,"vhdlchar",ol); // write type (variable,constant etc.)
1353 1354
    }

1355 1356
    VhdlDocGen::startFonts(nn,"vhdlchar",ol); // write name
    if (qstricmp(arg->attrib.data(),arg->type.data()) != 0)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1357
    {
1358
      VhdlDocGen::startFonts(arg->attrib.lower(),"stringliteral",ol); // write in|out
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1359
    }
1360 1361 1362 1363 1364
    ol.docify(" ");
    VhdlDocGen::formatString(arg->type,ol,mdef);
    sem=TRUE;
    ol.endBold();
    if (len > 2)
1365
    {
1366 1367 1368 1369 1370
      ol.lineBreak();
      ol.docify("  ");
    }
  }//for

1371
  ol.docify(" )");
1372 1373


1374
}
1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387

/*!
 * writes a function prototype to the output
 */

void VhdlDocGen::writeFunctionProto(OutputList& ol,const ArgumentList* al,const MemberDef* mdef)
{
  if (al==0) return;
  ArgumentListIterator ali(*al);
  Argument *arg;
  bool sem=FALSE;
  int len=al->count();
  ol.startBold();
1388
  ol.docify(" ( ");
1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400
  ol.endBold();
  if (len>2)
  {
    ol.lineBreak();
  }
  for (;(arg=ali.current());++ali)
  {
    ol.startBold();
    if (sem && len < 3)
    {
      ol.docify(" , ");
    }
1401
    QCString att=arg->defval;
1402 1403
    if (!att.isEmpty())
    {
1404 1405 1406
      QCString *str=VhdlDocGen::findKeyWord(att);
      att+=" ";
      if (str)
1407
	VhdlDocGen::formatString(att,ol,mdef);
1408
      else
1409
	VhdlDocGen::startFonts(att,"vhdlchar",ol);
1410
    }
1411 1412 1413

    QCString nn=arg->name;
    nn+=": ";
1414 1415 1416 1417
    QCString ss=arg->type; //.lower();
    QCString w=ss;//.upper();
    VhdlDocGen::startFonts(nn,"vhdlchar",ol);
    VhdlDocGen::startFonts("in ","stringliteral",ol);
1418 1419 1420 1421
    QCString *str=VhdlDocGen::findKeyWord(ss);
    if (str)
      VhdlDocGen::formatString(w,ol,mdef);
    else
1422
      VhdlDocGen::startFonts(w,"vhdlchar",ol);
1423

1424
    sem=TRUE;
1425
    ol.endBold();
1426
    if (len > 2)
1427 1428 1429 1430
    {
      ol.lineBreak();
    }
  }
1431 1432
  ol.startBold();
  ol.docify(" )");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1433
  const char *exp=mdef->excpString();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1434
  if (exp)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1435 1436 1437 1438 1439 1440
  {
    ol.insertMemberAlign();
    ol.docify("[ ");
    ol.docify(exp);
    ol.docify(" ]");
  }
1441
  ol.endBold();
1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454
}

/*!
 * writes a process prototype to the output
 */

void VhdlDocGen::writeProcessProto(OutputList& ol,const ArgumentList* al,const MemberDef* mdef)
{
  if (al==0) return;
  ArgumentListIterator ali(*al);
  Argument *arg;
  bool sem=FALSE;
  ol.startBold();
1455
  ol.docify(" ( ");
1456 1457 1458 1459 1460
  for (;(arg=ali.current());++ali)
  {
    if (sem)
      ol.docify(" , ");
    QCString nn=arg->name;
1461
    // VhdlDocGen::startFonts(nn,"vhdlchar",ol);
1462
    VhdlDocGen::writeFormatString(nn,ol,mdef);
1463 1464 1465
    sem=TRUE;
  }
  ol.docify(" )");
1466 1467 1468 1469 1470 1471 1472 1473
  ol.endBold();
}


/*!
 * writes a function|procedure documentation to the output
 */

1474
bool VhdlDocGen::writeFuncProcDocu(
1475
    const MemberDef *md,
1476 1477 1478 1479
    OutputList& ol,
    const ArgumentList* al,
    bool /*type*/)
{
1480
  if (al==0) return FALSE;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1481
  //bool sem=FALSE;
1482 1483 1484 1485
  ol.enableAll();

  ArgumentListIterator ali(*al);
  int index=ali.count();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1486 1487
  if (index==0)
  {
1488
    ol.docify(" ( ) ");
1489
    return FALSE;
1490
  }
1491
  ol.endMemberDocName();
1492
  ol.startParameterList(TRUE);
1493 1494 1495
  Argument *arg;
  bool first=TRUE;
  for (;(arg=ali.current());++ali)
1496 1497
  {
    ol.startParameterType(first,"");
1498
    //if (first) ol.writeChar('(');
1499 1500 1501 1502 1503
    QCString attl=arg->defval;
    bool bGen=attl.stripPrefix("gen!");
    if (bGen)
      VhdlDocGen::writeFormatString(QCString("generic "),ol,md);

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1504
    if (VhdlDocGen::isProcedure(md))
1505
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1506
      startFonts(arg->defval,"keywordtype",ol);
1507
      ol.docify(" ");
1508
    }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1509 1510 1511 1512
    ol.endParameterType();

    ol.startParameterName(TRUE);
    VhdlDocGen::writeFormatString(arg->name,ol,md);
1513

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1514
    if (VhdlDocGen::isProcedure(md))
1515
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1516
      startFonts(arg->attrib,"stringliteral",ol);
1517
    }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1518
    else if (VhdlDocGen::isVhdlFunction(md))
1519
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1520
      startFonts(QCString("in"),"stringliteral",ol);
1521
    }
1522 1523 1524 1525 1526 1527

    ol.docify(" ");
    ol.disable(OutputGenerator::Man);
    ol.startEmphasis();
    ol.enable(OutputGenerator::Man);
    if (!VhdlDocGen::isProcess(md))
1528
    {
1529
      VhdlDocGen::writeFormatString(arg->type,ol,md);
1530
    }
1531 1532 1533 1534
    ol.disable(OutputGenerator::Man);
    ol.endEmphasis();
    ol.enable(OutputGenerator::Man);

1535
    if (--index)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1536
    {
1537
      ol.docify(" , ");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1538
    }
1539
    else
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1540 1541
    {
      ol.endParameterName(TRUE,FALSE,TRUE);
1542
      break;
1543
      //ol.docify(" ) ");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1544
    }
1545
    ol.endParameterName(FALSE,FALSE,FALSE);
1546

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1547
    //sem=TRUE;
1548 1549
    first=FALSE;
  }
1550
  //ol.endParameterList();
1551
  return TRUE;
1552 1553 1554

} // writeDocFunProc

1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571
/*!
 * returns TRUE if this string is a function prototype or
 * FALSE if this is a procedure
 */

bool VhdlDocGen::isFunctionProto(QCString& ss)
{
  QCString name=ss;
  QCString proc("procedure");
  QCString func("function");
  name=name.stripWhiteSpace();
  QStringList ql=QStringList::split(QRegExp("[\\s]"),name,FALSE);
  int j=ql.count();
  if (j<2) return FALSE;
  QCString tt=ql[0].utf8().lower();

  if (tt=="impure" || tt=="pure") tt=ql[1].utf8();
1572

1573 1574
  if (VhdlDocGen::compareString(tt,proc)!=0 && VhdlDocGen::compareString(tt,func)!=0)
    return FALSE;
1575

1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586
  QCString temp=ql[j-1].utf8();
  temp=temp.stripWhiteSpace();
  if (qstricmp(temp.data(),"is")==0)
  {
    VhdlDocGen::deleteCharRev(name,'s');
    VhdlDocGen::deleteCharRev(name,'i');
    ss=name;
    return TRUE;
  }
  return FALSE;
}
1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601

QCString VhdlDocGen::convertArgumentListToString(const ArgumentList* al,bool func)
{
  QCString argString;
  bool sem=FALSE;
  ArgumentListIterator ali(*al);
  Argument *arg;

  for (;(arg=ali.current());++ali)
  {
    if (sem) argString.append(", ");
    if (func)
    {
      argString+=arg->name;
      argString+=":";
1602
      argString+=arg->type;
1603 1604 1605 1606 1607 1608 1609
    }
    else
    {
      argString+=arg->defval+" ";
      argString+=arg->name+" :";
      argString+=arg->attrib+" ";
      argString+=arg->type;
1610
    }
1611 1612 1613 1614 1615 1616 1617
    sem=TRUE;
  }
  return argString;
}


void VhdlDocGen::writeVhdlDeclarations(MemberList* ml,
1618
                        OutputList& ol,GroupDef* gd,ClassDef* cd,FileDef *fd,NamespaceDef *nd)
1619 1620
{
  static ClassDef *cdef;
1621
  //static GroupDef* gdef;
1622 1623 1624 1625 1626 1627
  if (cd && cdef!=cd)
  { // only one inline link
    VhdlDocGen::writeInlineClassLink(cd,ol);
    cdef=cd;
  }

1628
  /*
1629 1630 1631 1632 1633 1634
  if (gd && gdef==gd) return;
  if (gd && gdef!=gd)
  {
    gdef=gd;
  }
*/
1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::LIBRARY,FALSE),0,FALSE,VhdlDocGen::LIBRARY);
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::USE,FALSE),0,FALSE,VhdlDocGen::USE);
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::FUNCTION,FALSE),0,FALSE,VhdlDocGen::FUNCTION);
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::COMPONENT,FALSE),0,FALSE,VhdlDocGen::COMPONENT);
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::CONSTANT,FALSE),0,FALSE,VhdlDocGen::CONSTANT);
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::TYPE,FALSE),0,FALSE,VhdlDocGen::TYPE);
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::SUBTYPE,FALSE),0,FALSE,VhdlDocGen::SUBTYPE);
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::GENERIC,FALSE),0,FALSE,VhdlDocGen::GENERIC);
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::PORT,FALSE),0,FALSE,VhdlDocGen::PORT);
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::PROCESS,FALSE),0,FALSE,VhdlDocGen::PROCESS);
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::SIGNAL,FALSE),0,FALSE,VhdlDocGen::SIGNAL);
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::ATTRIBUTE,FALSE),0,FALSE,VhdlDocGen::ATTRIBUTE);
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::PROCEDURE,FALSE),0,FALSE,VhdlDocGen::PROCEDURE);
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::RECORD,FALSE),0,FALSE,VhdlDocGen::RECORD);
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::UNITS,FALSE),0,FALSE,VhdlDocGen::UNITS);
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::SHAREDVARIABLE,FALSE),0,FALSE,VhdlDocGen::SHAREDVARIABLE);
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::VFILE,FALSE),0,FALSE,VhdlDocGen::VFILE);
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::GROUP,FALSE),0,FALSE,VhdlDocGen::GROUP);
1653
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::COMPONENT_INST,FALSE),0,FALSE,VhdlDocGen::COMPONENT_INST);
1654 1655 1656
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::ALIAS,FALSE),0,FALSE,VhdlDocGen::ALIAS);
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::MISCELLANEOUS),0,FALSE,VhdlDocGen::MISCELLANEOUS);

1657
  // configurations must be added to global file definitions.
1658
  VhdlDocGen::writeVHDLDeclarations(ml,ol,cd,nd,fd,gd,theTranslator_vhdlType(VhdlDocGen::CONFIG,FALSE),0,FALSE,VhdlDocGen::CONFIG);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1659
}
1660

1661
static void setGlobalType(MemberList *ml)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1662 1663 1664 1665 1666 1667
{
  if (ml==0) return;
  MemberDef *mdd=0;
  MemberListIterator mmli(*ml);
  for ( ; (mdd=mmli.current()); ++mmli )
  {
1668
    if (qstricmp(mdd->argsString(),"configuration")==0)
1669 1670
    {
      mdd->setMemberSpecifiers(VhdlDocGen::CONFIG);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1671
    }
1672
    else if (qstricmp(mdd->typeString(),"library")==0)
1673
    {
1674
      mdd->setMemberSpecifiers(VhdlDocGen::LIBRARY);
1675
    }
1676
    else if (qstricmp(mdd->typeString(),"package")==0)
1677
    {
1678 1679
      mdd->setMemberSpecifiers(VhdlDocGen::USE);
    }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1680
    else if (qstricmp(mdd->typeString(),"misc")==0)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1681
    {
1682 1683
      mdd->setMemberSpecifiers(VhdlDocGen::MISCELLANEOUS);
    }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1684
  }
1685 1686 1687
}

/* writes a vhdl type documentation */
1688
bool VhdlDocGen::writeVHDLTypeDocumentation(const MemberDef* mdef, const Definition *d, OutputList &ol)
1689 1690
{
  ClassDef *cd=(ClassDef*)d;
1691 1692
  bool hasParams = FALSE;
  if (cd==0) return hasParams;
1693 1694 1695 1696 1697 1698
  if ((VhdlDocGen::isVhdlFunction(mdef) || VhdlDocGen::isProcedure(mdef) || VhdlDocGen::isProcess(mdef)))
  {
    QCString nn=mdef->typeString();
    nn=nn.stripWhiteSpace();
    QCString na=cd->name();
    MemberDef* memdef=VhdlDocGen::findMember(na,nn);
1699 1700
    if (memdef && memdef->isLinkable())
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1701
      ol.docify(" ");
1702
      ol.startBold();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1703
      writeLink(memdef,ol);
1704 1705 1706 1707 1708
      ol.endBold();
      ol.docify(" ");
    }
    else
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1709
      ol.docify(" ");
1710
      QCString ttype=mdef->typeString();
1711
      VhdlDocGen::formatString(ttype,ol,mdef);
1712
      ol.docify(" ");
1713 1714
    }
    ol.docify(mdef->name());
1715
    hasParams = VhdlDocGen::writeFuncProcDocu(mdef,ol, mdef->argumentList());
1716 1717
  }

1718 1719 1720 1721 1722
  if (VhdlDocGen::isMisc(mdef))
  {
    writeLink(mdef,ol);
    return hasParams;
  }
1723
  if (mdef->isVariable())
1724
  {
1725 1726 1727 1728 1729 1730
    writeLink(mdef,ol);
    ol.docify(" ");
    QCString ttype=mdef->typeString();
    VhdlDocGen::formatString(ttype,ol,mdef);
    ol.docify(" ");
    if (VhdlDocGen::isPort(mdef))
1731
    {
1732
      QCString largs=mdef->argsString();
1733 1734 1735 1736
      VhdlDocGen::formatString(largs,ol,mdef);
      ol.docify(" ");
    }
  }
1737
  return hasParams;
1738 1739 1740 1741 1742 1743
}

/* writes a vhdl type declaration */

void VhdlDocGen::writeVHDLDeclaration(MemberDef* mdef,OutputList &ol,
    ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
1744
    bool /*inGroup*/)
1745 1746
{
  Definition *d=0;
1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759

  /* some vhdl files contain only a configuration  description

     library work;
     configuration cfg_tb_jtag_gotoBackup of tb_jtag_gotoBackup is
     for RTL
     end for;
     end cfg_tb_jtag_gotoBackup;

     in this case library work does not belong to an entity, package ...

   */

1760
  ASSERT(cd!=0 || nd!=0 || fd!=0 || gd!=0 ||
1761 1762 1763
         mdef->getMemberSpecifiers()==VhdlDocGen::LIBRARY ||
         mdef->getMemberSpecifiers()==VhdlDocGen::USE
        ); // member should belong to something
1764 1765 1766 1767
  if (cd) d=cd;
  else if (nd) d=nd;
  else if (fd) d=fd;
  else if (gd) d=gd;
1768
  else d=(Definition*)mdef;
1769 1770 1771 1772 1773

  // write tag file information of this member
  if (!Config_getString("GENERATE_TAGFILE").isEmpty())
  {
    Doxygen::tagFile << "    <member kind=\"";
1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794
    if      (VhdlDocGen::isGeneric(mdef))      Doxygen::tagFile << "generic";
    if      (VhdlDocGen::isPort(mdef))         Doxygen::tagFile << "port";
    if      (VhdlDocGen::isEntity(mdef))       Doxygen::tagFile << "entity";
    if      (VhdlDocGen::isComponent(mdef))    Doxygen::tagFile << "component";
    if      (VhdlDocGen::isVType(mdef))        Doxygen::tagFile << "type";
    if      (VhdlDocGen::isConstant(mdef))     Doxygen::tagFile << "constant";
    if      (VhdlDocGen::isSubType(mdef))      Doxygen::tagFile << "subtype";
    if      (VhdlDocGen::isVhdlFunction(mdef)) Doxygen::tagFile << "function";
    if      (VhdlDocGen::isProcedure(mdef))    Doxygen::tagFile << "procedure";
    if      (VhdlDocGen::isProcess(mdef))      Doxygen::tagFile << "process";
    if      (VhdlDocGen::isSignals(mdef))      Doxygen::tagFile << "signal";
    if      (VhdlDocGen::isAttribute(mdef))    Doxygen::tagFile << "attribute";
    if      (VhdlDocGen::isRecord(mdef))       Doxygen::tagFile << "record";
    if      (VhdlDocGen::isLibrary(mdef))      Doxygen::tagFile << "library";
    if      (VhdlDocGen::isPackage(mdef))      Doxygen::tagFile << "package";
    if      (VhdlDocGen::isVariable(mdef))     Doxygen::tagFile << "shared variable";
    if      (VhdlDocGen::isFile(mdef))         Doxygen::tagFile << "file";
    if      (VhdlDocGen::isGroup(mdef))        Doxygen::tagFile << "group";
    if      (VhdlDocGen::isCompInst(mdef))     Doxygen::tagFile << "component instantiation";
    if      (VhdlDocGen::isAlias(mdef))        Doxygen::tagFile << "alias";
    if      (VhdlDocGen::isCompInst(mdef))     Doxygen::tagFile << "configuration";
1795 1796 1797 1798 1799 1800 1801 1802

    Doxygen::tagFile << "\">" << endl;
    Doxygen::tagFile << "      <type>" << convertToXML(mdef->typeString()) << "</type>" << endl;
    Doxygen::tagFile << "      <name>" << convertToXML(mdef->name()) << "</name>" << endl;
    Doxygen::tagFile << "      <anchorfile>" << convertToXML(mdef->getOutputFileBase()+Doxygen::htmlFileExtension) << "</anchorfile>" << endl;
    Doxygen::tagFile << "      <anchor>" << convertToXML(mdef->anchor()) << "</anchor>" << endl;

    if (VhdlDocGen::isVhdlFunction(mdef))
1803
      Doxygen::tagFile << "      <arglist>" << convertToXML(VhdlDocGen::convertArgumentListToString(mdef->argumentList(),TRUE)) << "</arglist>" << endl;
1804
    else if (VhdlDocGen::isProcedure(mdef))
1805
      Doxygen::tagFile << "      <arglist>" << convertToXML(VhdlDocGen::convertArgumentListToString(mdef->argumentList(),FALSE)) << "</arglist>" << endl;
1806 1807 1808 1809 1810 1811 1812 1813 1814
    else
      Doxygen::tagFile << "      <arglist>" << convertToXML(mdef->argsString()) << "</arglist>" << endl;

    mdef->writeDocAnchorsToTagFile();
    Doxygen::tagFile << "    </member>" << endl;

  }

  // write search index info
1815 1816
  if (Doxygen::searchIndex)
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1817
    Doxygen::searchIndex->setCurrentDoc(mdef,mdef->anchor(),FALSE);
1818 1819 1820
    Doxygen::searchIndex->addWord(mdef->localName(),TRUE);
    Doxygen::searchIndex->addWord(mdef->qualifiedName(),FALSE);
  }
1821 1822

  QCString cname  = d->name();
1823
  QCString cfname = mdef->getOutputFileBase();
1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834

  //HtmlHelp *htmlHelp=0;
  //  bool hasHtmlHelp = Config_getBool("GENERATE_HTML") && Config_getBool("GENERATE_HTMLHELP");
  //  if (hasHtmlHelp) htmlHelp = HtmlHelp::getInstance();

  // search for the last anonymous scope in the member type
  ClassDef *annoClassDef=mdef->getClassDefOfAnonymousType();

  // start a new member declaration
  bool isAnonymous = annoClassDef; // || m_impl->annMemb || m_impl->annEnumType;
  ///printf("startMemberItem for %s\n",name().data());
1835

1836 1837
  int mm=mdef->getMemberSpecifiers();
  if (mm==VhdlDocGen::MISCELLANEOUS)
1838
    isAnonymous=TRUE;
1839

1840
  ol.startMemberItem( mdef->anchor(), isAnonymous ); //? 1 : m_impl->tArgList ? 3 : 0);
1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859

  // If there is no detailed description we need to write the anchor here.
  bool detailsVisible = mdef->isDetailedSectionLinkable();
  if (!detailsVisible) // && !m_impl->annMemb)
  {
    QCString doxyName=mdef->name().copy();
    if (!cname.isEmpty()) doxyName.prepend(cname+"::");
    QCString doxyArgs=mdef->argsString();
    ol.startDoxyAnchor(cfname,cname,mdef->anchor(),doxyName,doxyArgs);

    ol.pushGeneratorState();
    ol.disable(OutputGenerator::Man);
    ol.disable(OutputGenerator::Latex);
    ol.docify("\n");
    ol.popGeneratorState();

  }
  // *** write type
  /*VHDL CHANGE */
1860
  bool bRec,bUnit;
1861
  QCString ltype(mdef->typeString());
1862
  QCString largs(mdef->argsString());
1863 1864
  mdef->setType(ltype.data());
  mdef->setArgsString(largs.data());
1865 1866 1867
  //printf(":: ltype=%s largs=%s name=%s mm=%d\n",
  //    ltype.data(),largs.data(),mdef->name().data(),mm);

1868
  ClassDef *kl=0;
1869
  //FileDef *fdd=0;
1870
  ArgumentList *alp = mdef->argumentList();
1871 1872
  QCString nn;
  if (gd) gd=0;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1873
  switch (mm)
1874
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1875
    case VhdlDocGen::MISCELLANEOUS:
1876
      VhdlDocGen::writeCodeFragment(mdef,ol);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1877
      break;
1878
    case VhdlDocGen::PROCEDURE:
1879
    case VhdlDocGen::FUNCTION:
1880 1881 1882 1883
      ol.startBold();
      VhdlDocGen::formatString(ltype,ol,mdef);
      ol.endBold();
      ol.insertMemberAlign();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1884
      ol.docify(" ");
1885

1886 1887
      writeLink(mdef,ol);
      if (alp!=0 && mm==VhdlDocGen::FUNCTION)
1888
	VhdlDocGen::writeFunctionProto(ol,alp,mdef);
1889 1890

      if (alp!=0 && mm==VhdlDocGen::PROCEDURE)
1891
	VhdlDocGen::writeProcedureProto(ol,alp,mdef);
1892 1893

      break;
1894 1895 1896
    case VhdlDocGen::USE:
      kl=VhdlDocGen::getClass(mdef->name());
      if (kl && ((VhdlDocGen::VhdlClasses)kl->protection()==VhdlDocGen::ENTITYCLASS)) break;
1897
      writeLink(mdef,ol);
1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908
      ol.insertMemberAlign();
      ol.docify("  ");

      if (kl)
      {
        nn=kl->getOutputFileBase();
        ol.pushGeneratorState();
        ol.disableAllBut(OutputGenerator::Html);
        ol.docify(" ");
        QCString name=theTranslator_vhdlType(VhdlDocGen::PACKAGE,TRUE);
        ol.startBold();
1909
        ol.docify(name.data());
1910 1911 1912 1913 1914
        name.resize(0);
        ol.endBold();
        name+=" <"+mdef->name()+">";
        ol.startEmphasis();
        ol.writeObjectLink(kl->getReference(),kl->getOutputFileBase(),0,name.data());
1915
        ol.endEmphasis();
1916 1917 1918 1919 1920 1921
        ol.popGeneratorState();
      }
      break;
    case VhdlDocGen::LIBRARY:
      writeLink(mdef,ol);
      ol.insertMemberAlign();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1922 1923 1924 1925 1926
      if (largs=="context")
      {
        VhdlDocGen::writeRecorUnit(ltype,ol,mdef);
      }
      break;
1927 1928
    case VhdlDocGen::GENERIC:
    case VhdlDocGen::PORT:
1929
    case VhdlDocGen::ALIAS:
1930

1931
      writeLink(mdef,ol);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1932
      ol.docify(" ");
1933 1934 1935
      ol.insertMemberAlign();
      if (mm==VhdlDocGen::GENERIC)
      {
1936 1937 1938
	ol.startBold();
	VhdlDocGen::formatString(largs,ol,mdef);
	ol.endBold();
1939 1940 1941
      }
      else
      {
1942 1943 1944 1945 1946 1947
	ol.docify(" ");
	ol.startBold();
	VhdlDocGen::formatString(ltype,ol,mdef);
	ol.endBold();
	ol.docify(" ");
	VhdlDocGen::formatString(largs,ol,mdef);
1948 1949 1950
      }
      break;
    case VhdlDocGen::PROCESS:
1951
      writeLink(mdef,ol);
1952
      ol.insertMemberAlign();
1953
      VhdlDocGen::writeProcessProto(ol,alp,mdef);
1954 1955 1956 1957
      break;
    case VhdlDocGen::PACKAGE:
    case VhdlDocGen::ENTITY:
    case VhdlDocGen::COMPONENT:
1958
    case VhdlDocGen::COMPONENT_INST:
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1959
    case VhdlDocGen::CONFIG:
1960 1961
      if (VhdlDocGen::isCompInst(mdef) )
      {
1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972
        nn=largs;
        if(nn.stripPrefix("function") || nn.stripPrefix("package"))
        {
          VhdlDocGen::formatString(largs,ol,mdef);
          ol.insertMemberAlign();
          writeLink(mdef,ol);
          ol.docify(" ");
          VhdlDocGen::formatString(ltype,ol,mdef);
          break;
        }

1973
        largs.prepend("::");
1974
        largs.prepend(mdef->name());
1975 1976 1977 1978 1979 1980
        ol.writeObjectLink(mdef->getReference(),
            cfname,
            mdef->anchor(),
            mdef->name());
      }
      else
1981
      {
1982
        writeLink(mdef,ol);
1983
      }
1984
      ol.insertMemberAlign();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1985
      ol.docify("  ");
1986

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1987
      ol.startBold();
1988
      ol.docify(ltype);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1989
      ol.endBold();
1990
      ol.docify("  ");
1991
      if (VhdlDocGen::isComponent(mdef) ||
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1992 1993
          VhdlDocGen::isConfig(mdef)    ||
          VhdlDocGen::isCompInst(mdef))
1994
      {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1995 1996 1997 1998 1999 2000
        if (VhdlDocGen::isConfig(mdef) || VhdlDocGen::isCompInst(mdef))
        {
          nn=ltype;
        }
        else
        {
2001
	  nn=mdef->name();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2002
        }
2003 2004 2005 2006 2007 2008 2009
	kl=getClass(nn.data());
	if (kl)
	{
	  nn=kl->getOutputFileBase();
	  ol.pushGeneratorState();
	  ol.disableAllBut(OutputGenerator::Html);
	  ol.startEmphasis();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2010 2011 2012 2013 2014 2015 2016 2017 2018
          QCString name("<Entity ");
          if (VhdlDocGen::isConfig(mdef) || VhdlDocGen::isCompInst(mdef))
          {
            name+=ltype+">";
          }
          else
          {
            name+=mdef->name()+"> ";
          }
2019 2020 2021 2022
	  ol.writeObjectLink(kl->getReference(),kl->getOutputFileBase(),0,name.data());
	  ol.endEmphasis();
	  ol.popGeneratorState();
	}
2023
      }
2024
      break;
2025 2026 2027
    case VhdlDocGen::SIGNAL:
    case VhdlDocGen::ATTRIBUTE:
    case VhdlDocGen::SUBTYPE:
2028 2029
    case VhdlDocGen::CONSTANT:
    case VhdlDocGen::SHAREDVARIABLE:
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2030
    case VhdlDocGen::VFILE:
2031
    case VhdlDocGen::GROUP:
2032 2033 2034 2035 2036
      writeLink(mdef,ol);
      ol.docify(" ");
      ol.insertMemberAlign();
      VhdlDocGen::formatString(ltype,ol,mdef);
      break;
2037
    case VhdlDocGen::TYPE:
2038 2039
      bRec=largs.stripPrefix("record") ;
      bUnit=largs.stripPrefix("units") ;
2040
      ol.startBold();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2041 2042
      if (bRec)  ol.docify("record: ");
      if (bUnit) ol.docify("units: ");
2043 2044
      writeLink(mdef,ol);
      ol.insertMemberAlign();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2045
      if (!bRec) VhdlDocGen::formatString(ltype,ol,mdef);
2046
      if (bUnit) ol.lineBreak();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2047
      if (bRec || bUnit) writeRecorUnit(largs,ol,mdef);
2048
      ol.endBold();
2049 2050 2051 2052 2053
      break;
    default: break;
  }

  bool htmlOn = ol.isEnabled(OutputGenerator::Html);
2054
  if (htmlOn && !ltype.isEmpty())
2055 2056 2057 2058 2059
  {
    ol.disable(OutputGenerator::Html);
  }
  if (!ltype.isEmpty()) ol.docify(" ");

2060
  if (htmlOn)
2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074
  {
    ol.enable(OutputGenerator::Html);
  }

  if (!detailsVisible)// && !m_impl->annMemb)
  {
    ol.endDoxyAnchor(cfname,mdef->anchor());
  }

  //printf("endMember %s annoClassDef=%p annEnumType=%p\n",
  //    name().data(),annoClassDef,annEnumType);
  ol.endMemberItem();
  if (!mdef->briefDescription().isEmpty() &&   Config_getBool("BRIEF_MEMBER_DESC") /* && !annMemb */)
  {
2075
    ol.startMemberDescription(mdef->anchor());
2076
    ol.generateDoc(mdef->briefFile(),mdef->briefLine(),
2077 2078
                mdef->getOuterScope()?mdef->getOuterScope():d,
                mdef,mdef->briefDescription(),TRUE,FALSE,0,TRUE,FALSE);
2079
    if (detailsVisible)
2080 2081 2082 2083 2084 2085 2086
    {
      ol.pushGeneratorState();
      ol.disableAllBut(OutputGenerator::Html);
      //ol.endEmphasis();
      ol.docify(" ");
      if (mdef->getGroupDef()!=0 && gd==0) // forward link to the group
      {
2087
	ol.startTextLink(mdef->getOutputFileBase(),mdef->anchor());
2088 2089 2090
      }
      else // local link
      {
2091
	ol.startTextLink(0,mdef->anchor());
2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103
      }
      ol.endTextLink();
      //ol.startEmphasis();
      ol.popGeneratorState();
    }
    //ol.newParagraph();
    ol.endMemberDescription();
  }
  mdef->warnIfUndocumented();

}// end writeVhdlDeclaration

2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122
void VhdlDocGen::writeRecorUnit(QCString & largs,OutputList& ol ,const MemberDef *mdef)
{
  QStringList ql=QStringList::split("#",largs,FALSE);
  uint len=ql.count();
  for(uint i=0;i<len;i++)
  {
    QCString n=ql[i].utf8();
    VhdlDocGen::formatString(n,ol,mdef);
    if ((len-i)>1) ol.lineBreak();
  }
}

void VhdlDocGen::writeLink(const MemberDef* mdef,OutputList &ol)
{
  ol.writeObjectLink(mdef->getReference(),
                     mdef->getOutputFileBase(),
		     mdef->anchor(),
		     mdef->name());
}
2123 2124 2125 2126 2127 2128 2129 2130

void VhdlDocGen::writePlainVHDLDeclarations(
    MemberList* mlist,OutputList &ol,
    ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,int specifier)
{

  SDict<QCString> pack(1009);

2131 2132
  ol.pushGeneratorState();

2133 2134 2135 2136
  bool first=TRUE;
  MemberDef *md;
  MemberListIterator mli(*mlist);
  for ( ; (md=mli.current()); ++mli )
2137
  {
2138 2139 2140 2141 2142 2143 2144 2145 2146 2147
    int mems=md->getMemberSpecifiers();
    if (md->isBriefSectionVisible() && (mems==specifier) && (mems!=VhdlDocGen::LIBRARY) )
    {
      if (first) {ol.startMemberList();first=FALSE;}
      VhdlDocGen::writeVHDLDeclaration(md,ol,cd,nd,fd,gd,FALSE);
    } //if
    else if (md->isBriefSectionVisible() && (mems==specifier))
    {
      if (!pack.find(md->name().data()))
      {
2148 2149 2150
	if (first) ol.startMemberList(),first=FALSE;
	VhdlDocGen::writeVHDLDeclaration(md,ol,cd,nd,fd,gd,FALSE);
	pack.append(md->name().data(),new QCString(md->name().data()));
2151 2152 2153
      }
    } //if
  } //for
2154
  if (!first) ol.endMemberList();
2155 2156 2157
  pack.clear();
}//plainDeclaration

2158
bool VhdlDocGen::membersHaveSpecificType(MemberList *ml,uint64 type)
2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187
{
  if (ml==0) return FALSE;
  MemberDef *mdd=0;
  MemberListIterator mmli(*ml);
  for ( ; (mdd=mmli.current()); ++mmli )
  {
    if (mdd->getMemberSpecifiers()==type) //is type in class
    {
      return TRUE;
    }
  }
  if (ml->getMemberGroupList())
  {
    MemberGroupListIterator mgli(*ml->getMemberGroupList());
    MemberGroup *mg;
    while ((mg=mgli.current()))
    {
      if (mg->members())
      {
        if (membersHaveSpecificType(mg->members(),type)) return TRUE;
      }
      ++mgli;
    }
  }
  return FALSE;
}

void VhdlDocGen::writeVHDLDeclarations(MemberList* ml,OutputList &ol,
    ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
2188
    const char *title,const char *subtitle,bool /*showEnumValues*/,int type)
2189
{
2190
  setGlobalType(ml);
2191 2192
  if (!membersHaveSpecificType(ml,type)) return;

2193
  if (title)
2194
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2195
    ol.startMemberHeader(title);
2196 2197 2198 2199
    ol.parseText(title);
    ol.endMemberHeader();
    ol.docify(" ");
  }
2200
  if (subtitle && subtitle[0]!=0)
2201 2202
  {
    ol.startMemberSubtitle();
2203
    ol.generateDoc("[generated]",-1,0,0,subtitle,FALSE,FALSE,0,TRUE,FALSE);
2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228
    ol.endMemberSubtitle();
  } //printf("memberGroupList=%p\n",memberGroupList);

  VhdlDocGen::writePlainVHDLDeclarations(ml,ol,cd,nd,fd,gd,type);

  if (ml->getMemberGroupList())
  {
    MemberGroupListIterator mgli(*ml->getMemberGroupList());
    MemberGroup *mg;
    while ((mg=mgli.current()))
    {
      if (membersHaveSpecificType(mg->members(),type))
      {
        //printf("mg->header=%s\n",mg->header().data());
        bool hasHeader=mg->header()!="[NOHEADER]";
        ol.startMemberGroupHeader(hasHeader);
        if (hasHeader)
        {
          ol.parseText(mg->header());
        }
        ol.endMemberGroupHeader();
        if (!mg->documentation().isEmpty())
        {
          //printf("Member group has docs!\n");
          ol.startMemberGroupDocs();
2229
          ol.generateDoc("[generated]",-1,0,0,mg->documentation()+"\n",FALSE,FALSE);
2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241
          ol.endMemberGroupDocs();
        }
        ol.startMemberGroup();
        //printf("--- mg->writePlainDeclarations ---\n");
        VhdlDocGen::writePlainVHDLDeclarations(mg->members(),ol,cd,nd,fd,gd,type);
        ol.endMemberGroup(hasHeader);
      }
      ++mgli;
    }
  }
}// writeVHDLDeclarations

2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255
/* strips the prefix for record and unit members*/
void VhdlDocGen::adjustRecordMember(MemberDef *mdef)
{ //,OutputList & ol) {
  QRegExp regg("[_a-zA-Z]");
  QCString nn=mdef->name();
  int j=nn.find(regg,0);
  if (j>0)
  {
    nn=nn.mid(j,nn.length());
    mdef->setName(nn.data());
  }
}//adjustRecordMember

/* strips the prefix for package and package body */
2256

2257 2258
bool VhdlDocGen::writeClassType( ClassDef * cd,
                                 OutputList &ol ,QCString & cname)
2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269
{
  int id=cd->protection();
  QCString qcs = VhdlDocGen::trTypeString(id+2);
  cname=VhdlDocGen::getClassName(cd);
  ol.startBold();
  ol.writeString(qcs.data());
  ol.writeString(" ");
  ol.endBold();
  return FALSE;
}// writeClassLink

2270
QCString VhdlDocGen::trVhdlType(uint64 type,bool sing)
2271 2272 2273
{
  switch(type)
  {
2274
    case VhdlDocGen::LIBRARY:
2275
      if (sing) return "Library";
2276 2277 2278
      else      return "Libraries";
    case VhdlDocGen::PACKAGE:
      if (sing) return "Package";
2279
      else      return "Packages";
2280 2281
    case VhdlDocGen::SIGNAL:
      if (sing) return "Signal";
2282
      else      return "Signals";
2283 2284 2285 2286 2287
    case VhdlDocGen::COMPONENT:
      if (sing) return "Component";
      else      return "Components";
    case VhdlDocGen::CONSTANT:
      if (sing) return "Constant";
2288
      else      return "Constants";
2289 2290
    case VhdlDocGen::ENTITY:
      if (sing) return "Entity";
2291
      else      return "Entities";
2292 2293
    case VhdlDocGen::TYPE:
      if (sing) return "Type";
2294
      else      return "Types";
2295 2296
    case VhdlDocGen::SUBTYPE:
      if (sing) return "Subtype";
2297
      else      return "Subtypes";
2298 2299
    case VhdlDocGen::FUNCTION:
      if (sing) return "Function";
2300
      else      return "Functions";
2301 2302
    case VhdlDocGen::RECORD:
      if (sing) return "Record";
2303
      else      return "Records";
2304 2305 2306 2307 2308
    case VhdlDocGen::PROCEDURE:
      if (sing) return "Procedure";
      else      return "Procedures";
    case VhdlDocGen::ARCHITECTURE:
      if (sing) return "Architecture";
2309
      else      return "Architectures";
2310 2311
    case VhdlDocGen::ATTRIBUTE:
      if (sing) return "Attribute";
2312
      else      return "Attributes";
2313 2314
    case VhdlDocGen::PROCESS:
      if (sing) return "Process";
2315
      else      return "Processes";
2316 2317
    case VhdlDocGen::PORT:
      if (sing) return "Port";
2318
      else      return "Ports";
2319
    case VhdlDocGen::USE:
2320 2321
      if (sing) return "Package";
      else      return "Packages";
2322 2323
    case VhdlDocGen::GENERIC:
      if (sing) return "Generic";
2324
      else      return "Generics";
2325
    case VhdlDocGen::PACKAGE_BODY:
2326
      return "Package Body";
2327 2328
    case VhdlDocGen::DOCUMENT:
      return "Doc";
2329 2330 2331 2332 2333 2334 2335 2336 2337 2338
    case VhdlDocGen::UNITS:
      return "Units";
    case VhdlDocGen::SHAREDVARIABLE:
      if (sing) return "Shared Variable";
      return "Shared Variables";
    case VhdlDocGen::VFILE:
      if (sing) return "File";
      return "Files";
    case VhdlDocGen::GROUP:
      if (sing) return "Group";
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2339
      return "Groups";
2340 2341 2342
    case VhdlDocGen::COMPONENT_INST:
      if (sing) return "Component Instantiation";
      else      return "Component Instantiations";
2343 2344
    case VhdlDocGen::ALIAS:
      if (sing) return "Alias";
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2345
      return "Aliases";
2346 2347
    case VhdlDocGen::CONFIG:
      if (sing) return "Configuration";
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2348
      return "Configurations";
2349
     case VhdlDocGen::MISCELLANEOUS:
2350 2351
      return "Miscellaneous";
    default:
2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373
      return "Class";
  }
}

QCString VhdlDocGen::trDesignUnitHierarchy()
{
  return "Design Unit Hierarchy";
}

QCString VhdlDocGen::trDesignUnitList()
{
  return "Design Unit List";
}

QCString VhdlDocGen::trDesignUnitMembers()
{
  return "Design Unit Members";
}

QCString VhdlDocGen::trDesignUnitListDescription()
{
  return "Here is a list of all design unit members with links to "
2374
         "the Entities and Packages they belong to:";
2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393
}

QCString VhdlDocGen::trDesignUnitIndex()
{
  return "Design Unit Index";
}

QCString VhdlDocGen::trDesignUnits()
{
  return "Design Units";
}

QCString VhdlDocGen::trFunctionAndProc()
{
  return "Functions/Procedures/Processes";
}



2394 2395
/*! adds  documentation to a function/procedure */
bool VhdlDocGen::writeDoc(EntryNav* rootNav)
2396
{
2397 2398 2399
  Entry *e=rootNav->entry();
  //if (e->section==Entry::Entry::OVERLOADDOC_SEC)
  if (qstricmp(e->type.data(),"function")==0)
2400
  {
2401
    VhdlDocGen::addFuncDoc(rootNav);
2402
  }
2403 2404 2405

  return FALSE;
}// writeDoc
2406

2407

2408
/* do not insert the same component twice */
2409

2410
bool VhdlDocGen::foundInsertedComponent(const QCString & name,Entry* root)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2411
{
2412 2413 2414
  QListIterator<BaseInfo> bii(*root->extends);
  BaseInfo *bi=0;
  for (bii.toFirst();(bi=bii.current());++bii)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2415
  {
2416
    if (bi->name==name)
2417
    {
2418
      return TRUE; //
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2419 2420
    }
  }
2421

2422 2423
  return FALSE;
}// found component
2424

2425
/*! writes a link if the string is linkable else a formatted string */
2426

2427
void VhdlDocGen::writeStringLink(const MemberDef *mdef,QCString mem, OutputList& ol)
2428
{
2429
  if (mdef)
2430
  {
2431 2432
    ClassDef *cd=mdef->getClassDef();
    if (cd)
2433
    {
2434 2435 2436
      QCString n=cd->name();
      MemberDef* memdef=VhdlDocGen::findMember(n,mem);
      if (memdef && memdef->isLinkable())
2437
      {
2438 2439 2440 2441 2442
	ol.startBold();
	writeLink(memdef,ol);
	ol.endBold();
	ol.docify(" ");
	return;
2443
      }
2444
    }
2445
  }
2446 2447
  VhdlDocGen::startFonts(mem,"vhdlchar",ol);
}// found component
2448

2449
void VhdlDocGen::writeCodeFragment( MemberDef *mdef,OutputList& ol)
2450
{
2451 2452 2453 2454 2455
  //  Definition d=(Definition)mdef;
  //	QCString fdd=mdef->getDefFileExtension();
  //	QCString scope=mdef->getScopeString();
  QCString codeFragment=mdef->documentation();
  //FileDef *fd=mdef->getFileDef();
2456

2457 2458 2459
  //int start=mdef->getStartBodyLine();
  //int end=mdef->getEndBodyLine();
  QStringList qsl=QStringList::split("\n",codeFragment);
2460

2461
  writeLink(mdef,ol);
2462
  ol.docify(" ");
2463 2464 2465 2466
  ol.insertMemberAlign();
  int len = qsl.count();
  int j;
  for (j=0;j<len;j++)
2467
  {
2468 2469 2470 2471
    QCString q=qsl[j].utf8();
    VhdlDocGen::writeFormatString(q,ol,mdef);
    ol.lineBreak();
    if (j==2) // only the first three lines are shown
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2472
    {
2473 2474 2475
      q="...";
      VhdlDocGen::writeFormatString(q,ol,mdef);
      break;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2476
    }
2477 2478 2479
  }
}

2480
void VhdlDocGen::writeSource(MemberDef *mdef,OutputList& ol,QCString & cname)
2481
{
2482 2483 2484 2485 2486 2487 2488 2489
  //  Definition d=(Definition)mdef;
  QCString fdd=mdef->getDefFileExtension();
  QCString scope=mdef->getScopeString();
  QCString codeFragment=mdef->documentation();
  FileDef *fd=mdef->getFileDef();
  int start=mdef->getStartBodyLine();
  int end=mdef->getEndBodyLine();
  QStringList qsl=QStringList::split("\n",codeFragment);
2490

2491 2492
  ParserInterface *pIntf = Doxygen::parserManager->getParser(fdd.data());
  pIntf->resetCodeParserState();
2493

2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510
  ol.startParagraph();
  ol.startCodeFragment();
  pIntf->parseCode(ol,               // codeOutIntf
                   scope,            // scope
                   codeFragment,     // input
                   SrcLangExt_VHDL,  // lang
                   FALSE,            // isExample
                   0,                // exampleName
                   fd,               // fileDef
                   start,            // startLine
                   end,              // endLine
                   TRUE,             // inlineFragment
                   mdef,             // memberDef
                   FALSE             // show line numbers
                   );
  ol.endCodeFragment();
  ol.endParagraph();
2511

2512 2513 2514
  mdef->writeSourceDef(ol,cname);
  mdef->writeSourceRefs(ol,cname);
  mdef->writeSourceReffedBy(ol,cname);
2515 2516
}