예제 #1
0
파일: json.c 프로젝트: MartinNowak/GDC
void EnumDeclaration::toJsonBuffer(OutBuffer *buf)
{
    //printf("EnumDeclaration::toJsonBuffer()\n");
    if (isAnonymous())
    {
        if (members)
        {
            for (size_t i = 0; i < members->dim; i++)
            {
                Dsymbol *s = (*members)[i];
                s->toJsonBuffer(buf);
                buf->writestring(",\n");
            }
            JsonRemoveComma(buf);
        }
        return;
    }

    buf->writestring("{\n");

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

    if (memtype)
        JsonProperty(buf, "base", memtype->toChars());

    if (members)
    {
        JsonString(buf, Pmembers);
        buf->writestring(" : [\n");
        size_t offset = buf->offset;
        for (size_t i = 0; i < members->dim; i++)
        {   Dsymbol *s = (*members)[i];
            if (offset != buf->offset)
            {   buf->writestring(",\n");
                offset = buf->offset;
            }
            s->toJsonBuffer(buf);
        }
        JsonRemoveComma(buf);
        buf->writestring("]\n");
    }
    JsonRemoveComma(buf);

    buf->writestring("}\n");
}
예제 #2
0
파일: json.c 프로젝트: Geod24/dnet
void TemplateDeclaration::toJsonBuffer(OutBuffer *buf)
{
    //printf("TemplateDeclaration::toJsonBuffer()\n");

    buf->writestring("{\n");

    JsonProperty(buf, Pname, toChars());
    JsonProperty(buf, Pkind, kind());
    if (comment)
	JsonProperty(buf, Pcomment, (const char *)comment);

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

    JsonString(buf, Pmembers);
    buf->writestring(" : [\n");
    size_t offset = buf->offset;
    for (int i = 0; i < members->dim; i++)
    {	Dsymbol *s = (Dsymbol *)members->data[i];
	if (offset != buf->offset)
	{   buf->writestring(",\n");
	    offset = buf->offset;
	}
	s->toJsonBuffer(buf);
    }
    JsonRemoveComma(buf);
    buf->writestring("]\n");

    buf->writestring("}\n");
}
예제 #3
0
파일: json.c 프로젝트: Geod24/dnet
void Module::toJsonBuffer(OutBuffer *buf)
{
    buf->writestring("{\n");

    if (md)
	JsonProperty(buf, Pname, md->toChars());

    JsonProperty(buf, Pkind, kind());

    JsonProperty(buf, Pfile, srcfile->toChars());

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

    JsonString(buf, Pmembers);
    buf->writestring(" : [\n");

    size_t offset = buf->offset;
    for (int i = 0; i < members->dim; i++)
    {	Dsymbol *s = (Dsymbol *)members->data[i];
	if (offset != buf->offset)
	{   buf->writestring(",\n");
	    offset = buf->offset;
	}
	s->toJsonBuffer(buf);
    }

    JsonRemoveComma(buf);
    buf->writestring("]\n");

    buf->writestring("}\n");
}
예제 #4
0
파일: json.c 프로젝트: gr0v3r/dmd
void AggregateDeclaration::toJsonBuffer(OutBuffer *buf)
{
    //printf("AggregateDeclaration::toJsonBuffer()\n");
    buf->writestring("{\n");

    JsonProperty(buf, Pname, toChars());
    JsonProperty(buf, Pkind, kind());
    if (comment)
        JsonProperty(buf, Pcomment, (const char *)comment);
    if (loc.linnum)
        JsonProperty(buf, Pline, loc.linnum);

    ClassDeclaration *cd = isClassDeclaration();
    if (cd)
    {
        if (cd->baseClass)
        {
            JsonProperty(buf, "base", cd->baseClass->toChars());
        }
        if (cd->interfaces_dim)
        {
            JsonString(buf, "interfaces");
            buf->writestring(" : [\n");
            size_t offset = buf->offset;
            for (int i = 0; i < cd->interfaces_dim; i++)
            {   BaseClass *b = cd->interfaces[i];
                if (offset != buf->offset)
                {   buf->writestring(",\n");
                    offset = buf->offset;
                }
                JsonString(buf, b->base->toChars());
            }
            JsonRemoveComma(buf);
            buf->writestring("],\n");
        }
    }

    if (members)
    {
        JsonString(buf, Pmembers);
        buf->writestring(" : [\n");
        size_t offset = buf->offset;
        for (int i = 0; i < members->dim; i++)
        {   Dsymbol *s = (Dsymbol *)members->data[i];
            if (offset != buf->offset)
            {   buf->writestring(",\n");
                offset = buf->offset;
            }
            s->toJsonBuffer(buf);
        }
        JsonRemoveComma(buf);
        buf->writestring("]\n");
    }
    JsonRemoveComma(buf);

    buf->writestring("}\n");
}
예제 #5
0
파일: json.c 프로젝트: Geod24/dnet
void AttribDeclaration::toJsonBuffer(OutBuffer *buf)
{
    //printf("AttribDeclaration::toJsonBuffer()\n");

    Array *d = include(NULL, NULL);

    if (d)
    {
	for (unsigned i = 0; i < d->dim; i++)
	{   Dsymbol *s = (Dsymbol *)d->data[i];
	    //printf("AttribDeclaration::toJsonBuffer %s\n", s->toChars());
	    s->toJsonBuffer(buf);
	}
    }
}
예제 #6
0
파일: json.c 프로젝트: gr0v3r/dmd
void AttribDeclaration::toJsonBuffer(OutBuffer *buf)
{
    //printf("AttribDeclaration::toJsonBuffer()\n");

    Array *d = include(NULL, NULL);

    if (d)
    {
        size_t offset = buf->offset;
        for (unsigned i = 0; i < d->dim; i++)
        {   Dsymbol *s = (Dsymbol *)d->data[i];
            //printf("AttribDeclaration::toJsonBuffer %s\n", s->toChars());
            if (offset != buf->offset)
            {   buf->writestring(",\n");
                offset = buf->offset;
            }
            s->toJsonBuffer(buf);
        }
        JsonRemoveComma(buf);
    }
}