Mercurial > projects > ldc
diff dmd/doc.c @ 336:aaade6ded589 trunk
[svn r357] Merged DMD 1.033
author | lindquist |
---|---|
date | Sat, 12 Jul 2008 19:38:31 +0200 |
parents | 5acec6b2eef8 |
children | 6aee82889553 |
line wrap: on
line diff
--- a/dmd/doc.c Sat Jul 12 17:04:36 2008 +0200 +++ b/dmd/doc.c Sat Jul 12 19:38:31 2008 +0200 @@ -400,7 +400,7 @@ void ScopeDsymbol::emitMemberComments(Scope *sc) { - //printf("ScopeDsymbol::emitMemberComments()\n"); + //printf("ScopeDsymbol::emitMemberComments() %s\n", toChars()); OutBuffer *buf = sc->docbuf; if (members) @@ -417,8 +417,9 @@ else if (isTemplateDeclaration()) m = "$(DDOC_TEMPLATE_MEMBERS \n"; - // BUG: if no members are actually printed, we should not emit DDOC_MEMBERS + unsigned offset1 = buf->offset; // save starting offset buf->writestring(m); + unsigned offset2 = buf->offset; // to see if we write anything sc = sc->push(this); for (int i = 0; i < members->dim; i++) { @@ -427,7 +428,14 @@ s->emitComment(sc); } sc->pop(); - buf->writestring(")\n"); + if (buf->offset == offset2) + { + /* Didn't write out any members, so back out last write + */ + buf->offset = offset1; + } + else + buf->writestring(")\n"); } } @@ -448,7 +456,9 @@ void Dsymbol::emitComment(Scope *sc) { } void InvariantDeclaration::emitComment(Scope *sc) { } -//void PostBlitDeclaration::emitComment(Scope *sc) { } +#if DMDV2 +void PostBlitDeclaration::emitComment(Scope *sc) { } +#endif void DtorDeclaration::emitComment(Scope *sc) { } void StaticCtorDeclaration::emitComment(Scope *sc) { } void StaticDtorDeclaration::emitComment(Scope *sc) { } @@ -525,12 +535,8 @@ //printf("TemplateDeclaration::emitComment() '%s', kind = %s\n", toChars(), kind()); if (prot() == PROTprivate) return; - if (!comment) - return; - OutBuffer *buf = sc->docbuf; - DocComment *dc = DocComment::parse(sc, this, comment); - unsigned o; + unsigned char *com = comment; int hasmembers = 1; Dsymbol *ss = this; @@ -542,12 +548,22 @@ { ss = onemember->isFuncDeclaration(); if (ss) - hasmembers = 0; + { hasmembers = 0; + if (com != ss->comment) + com = Lexer::combineComments(com, ss->comment); + } else ss = this; } } + if (!com) + return; + + OutBuffer *buf = sc->docbuf; + DocComment *dc = DocComment::parse(sc, this, com); + unsigned o; + if (!dc) { ss->emitDitto(sc); @@ -667,7 +683,7 @@ buf->writestring("static "); if (d->isConst()) buf->writestring("const "); -#if V2 +#if DMDV2 if (d->isInvariant()) buf->writestring("invariant "); #endif @@ -743,7 +759,9 @@ if (parent && (td = parent->isTemplateDeclaration()) != NULL && td->onemember == this) - { HdrGenState hgs; + { /* It's a function template + */ + HdrGenState hgs; unsigned o = buf->offset; TypeFunction *tf = (TypeFunction *)type; @@ -1581,7 +1599,13 @@ */ if (f && f->type) { - TypeFunction *tf = (TypeFunction *)f->type; + TypeFunction *tf; + if (f->originalType) + { + tf = (TypeFunction *)f->originalType; + } + else + tf = (TypeFunction *)f->type; if (tf->parameters) {