Permalink
Browse files

fix D2 pull #856

  • Loading branch information...
WalterBright committed Nov 11, 2012
1 parent 0ca88aa commit b940d6d2cb4fda8cfea5e8ae45559a39130fba58
Showing with 17 additions and 29 deletions.
  1. +4 −11 src/attrib.c
  2. +1 −8 src/doc.c
  3. +3 −0 src/dsymbol.h
  4. +9 −10 src/json.c
View
@@ -655,17 +655,10 @@ void ProtDeclaration::protectionToCBuffer(OutBuffer *buf, enum PROT protection)
{
const char *p;
- switch (protection)
- {
- case PROTprivate: p = "private"; break;
- case PROTpackage: p = "package"; break;
- case PROTprotected: p = "protected"; break;
- case PROTpublic: p = "public"; break;
- case PROTexport: p = "export"; break;
- default:
- assert(0);
- break;
- }
+ p = Pprotectionnames[protection];
+
+ assert(p);
+
buf->writestring(p);
buf->writeByte(' ');
}
View
@@ -560,15 +560,8 @@ void ScopeDsymbol::emitMemberComments(Scope *sc)
void emitProtection(OutBuffer *buf, PROT prot)
{
- const char *p;
+ const char *p = (prot == PROTpublic) ? NULL : Pprotectionnames[prot];
- switch (prot)
- {
- case PROTpackage: p = "package"; break;
- case PROTprotected: p = "protected"; break;
- case PROTexport: p = "export"; break;
- default: p = NULL; break;
- }
if (p)
buf->printf("%s ", p);
}
View
@@ -94,6 +94,9 @@ enum PROT
PROTexport,
};
+// this is used for printing the protection in json, traits, docs, etc.
+static const char* Pprotectionnames[] = {NULL, "none", "private", "package", "protected", "public", "export"};
+
/* State of symbol in winding its way through the passes of the compiler
*/
enum PASS
View
@@ -1,6 +1,6 @@
// Compiler implementation of the D programming language
-// Copyright (c) 1999-2011 by Digital Mars
+// Copyright (c) 1999-2012 by Digital Mars
// All Rights Reserved
// written by Walter Bright
// http://www.digitalmars.com
@@ -44,7 +44,6 @@ const char Ptype[] = "type";
const char Pcomment[] = "comment";
const char Pmembers[] = "members";
const char Pprotection[] = "protection";
-const char* Pprotectionnames[] = {NULL, "none", "private", "package", "protected", "public", "export"};
void JsonRemoveComma(OutBuffer *buf);
@@ -53,7 +52,7 @@ void json_generate(Modules *modules)
buf.writestring("[\n");
for (size_t i = 0; i < modules->dim; i++)
- { Module *m = modules->tdata()[i];
+ { Module *m = (*modules)[i];
if (global.params.verbose)
printf("json gen %s\n", m->toChars());
m->toJsonBuffer(&buf);
@@ -66,7 +65,7 @@ void json_generate(Modules *modules)
char *arg = global.params.xfilename;
if (!arg || !*arg)
{ // Generate lib file name from first obj name
- char *n = global.params.objfiles->tdata()[0];
+ char *n = (*global.params.objfiles)[0];
n = FileName::name(n);
FileName *fn = FileName::forceExt(n, global.json_ext);
@@ -195,7 +194,7 @@ void Module::toJsonBuffer(OutBuffer *buf)
size_t offset = buf->offset;
for (size_t i = 0; i < members->dim; i++)
- { Dsymbol *s = members->tdata()[i];
+ { Dsymbol *s = (*members)[i];
if (offset != buf->offset)
{ buf->writestring(",\n");
offset = buf->offset;
@@ -219,7 +218,7 @@ void AttribDeclaration::toJsonBuffer(OutBuffer *buf)
{
size_t offset = buf->offset;
for (unsigned i = 0; i < d->dim; i++)
- { Dsymbol *s = d->tdata()[i];
+ { Dsymbol *s = (*d)[i];
//printf("AttribDeclaration::toJsonBuffer %s\n", s->toChars());
if (offset != buf->offset)
{ buf->writestring(",\n");
@@ -332,7 +331,7 @@ void AggregateDeclaration::toJsonBuffer(OutBuffer *buf)
buf->writestring(" : [\n");
size_t offset = buf->offset;
for (size_t i = 0; i < members->dim; i++)
- { Dsymbol *s = members->tdata()[i];
+ { Dsymbol *s = (*members)[i];
if (offset != buf->offset)
{ buf->writestring(",\n");
offset = buf->offset;
@@ -369,7 +368,7 @@ void TemplateDeclaration::toJsonBuffer(OutBuffer *buf)
buf->writestring(" : [\n");
size_t offset = buf->offset;
for (size_t i = 0; i < members->dim; i++)
- { Dsymbol *s = members->tdata()[i];
+ { Dsymbol *s = (*members)[i];
if (offset != buf->offset)
{ buf->writestring(",\n");
offset = buf->offset;
@@ -391,7 +390,7 @@ void EnumDeclaration::toJsonBuffer(OutBuffer *buf)
{
for (size_t i = 0; i < members->dim; i++)
{
- Dsymbol *s = members->tdata()[i];
+ Dsymbol *s = (*members)[i];
s->toJsonBuffer(buf);
buf->writestring(",\n");
}
@@ -423,7 +422,7 @@ void EnumDeclaration::toJsonBuffer(OutBuffer *buf)
buf->writestring(" : [\n");
size_t offset = buf->offset;
for (size_t i = 0; i < members->dim; i++)
- { Dsymbol *s = members->tdata()[i];
+ { Dsymbol *s = (*members)[i];
if (offset != buf->offset)
{ buf->writestring(",\n");
offset = buf->offset;

0 comments on commit b940d6d

Please sign in to comment.