Skip to content

Commit

Permalink
Merge pull request #247 from CyberShadow/json-protection
Browse files Browse the repository at this point in the history
Include symbol protection in JSON output
  • Loading branch information
WalterBright committed Jul 15, 2011
2 parents b6ac09f + 81a2010 commit 28f8c95
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/json.c
Expand Up @@ -43,6 +43,8 @@ const char Pline[] = "line";
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);

Expand Down Expand Up @@ -259,6 +261,10 @@ void Declaration::toJsonBuffer(OutBuffer *buf)

JsonProperty(buf, Pname, toChars());
JsonProperty(buf, Pkind, kind());

if (prot())
JsonProperty(buf, Pprotection, Pprotectionnames[prot()]);

if (type)
JsonProperty(buf, Ptype, type->toChars());

Expand All @@ -285,8 +291,13 @@ void AggregateDeclaration::toJsonBuffer(OutBuffer *buf)

JsonProperty(buf, Pname, toChars());
JsonProperty(buf, Pkind, kind());

if (prot())
JsonProperty(buf, Pprotection, Pprotectionnames[prot()]);

if (comment)
JsonProperty(buf, Pcomment, (const char *)comment);

if (loc.linnum)
JsonProperty(buf, Pline, loc.linnum);

Expand Down Expand Up @@ -344,6 +355,10 @@ void TemplateDeclaration::toJsonBuffer(OutBuffer *buf)

JsonProperty(buf, Pname, toChars());
JsonProperty(buf, Pkind, kind());

if (prot())
JsonProperty(buf, Pprotection, Pprotectionnames[prot()]);

if (comment)
JsonProperty(buf, Pcomment, (const char *)comment);

Expand Down Expand Up @@ -389,6 +404,10 @@ void EnumDeclaration::toJsonBuffer(OutBuffer *buf)

JsonProperty(buf, Pname, toChars());
JsonProperty(buf, Pkind, kind());

if (prot())
JsonProperty(buf, Pprotection, Pprotectionnames[prot()]);

if (comment)
JsonProperty(buf, Pcomment, (const char *)comment);

Expand Down Expand Up @@ -427,6 +446,9 @@ void EnumMember::toJsonBuffer(OutBuffer *buf)
JsonProperty(buf, Pname, toChars());
JsonProperty(buf, Pkind, kind());

if (prot())
JsonProperty(buf, Pprotection, Pprotectionnames[prot()]);

if (comment)
JsonProperty(buf, Pcomment, (const char *)comment);

Expand Down

0 comments on commit 28f8c95

Please sign in to comment.