|
@@ -631,6 +631,9 @@ Esdl2Array::Esdl2Array(Esdl2Transformer *xformer, IEsdlDefObject *def) : Esdl2Ba
|
|
|
type_unknown=false;
|
|
|
inited=false;
|
|
|
|
|
|
+ IEsdlDefArray* defArray = dynamic_cast<IEsdlDefArray*>(def);
|
|
|
+ isEsdlList = defArray->checkIsEsdlList();
|
|
|
+
|
|
|
const char *atype = def->queryProp("type");
|
|
|
if (atype)
|
|
|
{
|
|
@@ -700,6 +703,18 @@ void Esdl2Array::process(Esdl2TransformerContext &ctx, IPropertyTree *pt, const
|
|
|
if (ctx.writer->length() != curlen && count)
|
|
|
ctx.counter++;
|
|
|
}
|
|
|
+ else if (isEsdlList)
|
|
|
+ {
|
|
|
+ int curlen = ctx.writer->length();
|
|
|
+ const char *tagname = queryOutputName(ctx);
|
|
|
+ if (esdl_type)
|
|
|
+ esdl_type->process(ctx, pt, tagname, NULL, count_output);
|
|
|
+ else
|
|
|
+ output_content(ctx, pt, tagname);
|
|
|
+
|
|
|
+ if (ctx.writer->length() != curlen && count)
|
|
|
+ ctx.counter++;
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
const char *tagname = queryOutputName(ctx);
|
|
@@ -773,6 +788,18 @@ void Esdl2Array::process(Esdl2TransformerContext &ctx, const char *out_name, Esd
|
|
|
if (ctx.writer->length() != curlen && count)
|
|
|
ctx.counter++;
|
|
|
}
|
|
|
+ else if (isEsdlList)
|
|
|
+ {
|
|
|
+ int curlen = ctx.writer->length();
|
|
|
+ const char *tagname = queryOutputName(ctx);
|
|
|
+ if (esdl_type)
|
|
|
+ esdl_type->process(ctx, tagname, NULL, count_output);
|
|
|
+ else
|
|
|
+ output_content(ctx, tagname);
|
|
|
+
|
|
|
+ if (ctx.writer->length() != curlen && count)
|
|
|
+ ctx.counter++;
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
Owned<IInterface> prevLocation = ctx.writer->saveLocation();
|
|
@@ -895,7 +922,53 @@ void Esdl2Struct::process(Esdl2TransformerContext &ctx, IPropertyTree *pt, const
|
|
|
{
|
|
|
const char *tagname = child.queryInputName(ctx);
|
|
|
if (pt->hasProp(tagname)||child.hasDefaults())
|
|
|
- child.process(ctx, pt->queryPropTree(tagname), child.queryOutputName(ctx), &local, count);
|
|
|
+ {
|
|
|
+ unsigned numChildren = pt->getCount(tagname);
|
|
|
+ bool isEsdlList = false;
|
|
|
+ IEsdlDefObject* def = child.queryEsdlDefObject();
|
|
|
+ if (def->getEsdlType() == EsdlTypeArray)
|
|
|
+ {
|
|
|
+ IEsdlDefArray* defArray = dynamic_cast<IEsdlDefArray*>(def);
|
|
|
+ isEsdlList = defArray->checkIsEsdlList();
|
|
|
+ }
|
|
|
+ if (!isEsdlList)
|
|
|
+ {
|
|
|
+ if (numChildren < 2)
|
|
|
+ child.process(ctx, pt->queryPropTree(tagname), child.queryOutputName(ctx), &local, count);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Owned<IPropertyTreeIterator> iter = pt->getElements(tagname);
|
|
|
+ ForEach(*iter)
|
|
|
+ child.process(ctx, &iter->query(), child.queryOutputName(ctx), &local, count);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Owned<IInterface> prevLocation = ctx.writer->saveLocation();
|
|
|
+ ctx.writer->outputBeginArray(tagname);
|
|
|
+ int curlen = ctx.writer->length();
|
|
|
+
|
|
|
+ if (numChildren < 2)
|
|
|
+ child.process(ctx, pt->queryPropTree(tagname), child.queryOutputName(ctx), &local, count);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Owned<IPropertyTreeIterator> iter = pt->getElements(tagname);
|
|
|
+ ForEach(*iter)
|
|
|
+ child.process(ctx, &iter->query(), child.queryOutputName(ctx), &local, count);
|
|
|
+ }
|
|
|
+ if (ctx.writer->length()==curlen) //nothing was added... empty content remove opening tag
|
|
|
+ {
|
|
|
+ ///ctx.writer->outputEndArray(tagname);
|
|
|
+ ctx.writer->rewindTo(prevLocation); //rewind
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ctx.writer->outputEndArray(tagname);
|
|
|
+ if (count)
|
|
|
+ ctx.counter++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -955,6 +1028,8 @@ void Esdl2Struct::process(Esdl2TransformerContext &ctx, const char *out_name, Es
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ StringBuffer esdlListName;
|
|
|
+ unsigned esdlListItemCount = 0;
|
|
|
Esdl2LocalContext local;
|
|
|
StringBuffer completeContent;
|
|
|
for (int type=ctx.xppp->next(); type!=XmlPullParser::END_TAG; type=ctx.xppp->next())
|
|
@@ -1013,6 +1088,34 @@ void Esdl2Struct::process(Esdl2TransformerContext &ctx, const char *out_name, Es
|
|
|
Owned<IInterface> location = ctx.writer->saveLocation();
|
|
|
local.dataForProcessed = false;
|
|
|
|
|
|
+ const char* tagName = child_start.getLocalName();
|
|
|
+ if (!esdlListName.isEmpty())
|
|
|
+ {
|
|
|
+ if (streq(tagName, esdlListName.str()))
|
|
|
+ esdlListItemCount++;
|
|
|
+ else
|
|
|
+ { //A different esdl tag is coming. We need to close the last EsdlList.
|
|
|
+ ctx.writer->outputEndArray(esdlListName.str());
|
|
|
+ esdlListName.clear();
|
|
|
+ esdlListItemCount = 0;
|
|
|
+ location.setown(ctx.writer->saveLocation());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (esdlListName.isEmpty())
|
|
|
+ {
|
|
|
+ IEsdlDefObject* def = child->queryEsdlDefObject();
|
|
|
+ if (def->getEsdlType() == EsdlTypeArray)
|
|
|
+ {
|
|
|
+ IEsdlDefArray* defArray = dynamic_cast<IEsdlDefArray*>(def);
|
|
|
+ if (defArray->checkIsEsdlList())
|
|
|
+ {
|
|
|
+ ctx.writer->outputBeginArray(tagName);
|
|
|
+ esdlListName.set(tagName);
|
|
|
+ esdlListItemCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
chd.process(ctx, NULL, &local);
|
|
|
|
|
|
if (local.dataForProcessed)
|
|
@@ -1024,6 +1127,11 @@ void Esdl2Struct::process(Esdl2TransformerContext &ctx, const char *out_name, Es
|
|
|
ESDL_DBG("Taking out data for DataFor '%s' from out buffer", chd.queryDataFor()->queryName());
|
|
|
local.setDataFor(chd.queryDataFor()->queryName(), ctx.writer->str()+len);
|
|
|
ctx.writer->rewindTo(location);
|
|
|
+ if (esdlListItemCount == 1)
|
|
|
+ {// Not call outputEndArray()
|
|
|
+ esdlListName.clear();
|
|
|
+ esdlListItemCount = 0;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1043,6 +1151,8 @@ void Esdl2Struct::process(Esdl2TransformerContext &ctx, const char *out_name, Es
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if (!esdlListName.isEmpty())
|
|
|
+ ctx.writer->outputEndArray(esdlListName.str());
|
|
|
|
|
|
if (completeContent.length()>0)
|
|
|
ctx.writer->outputUtf8(rtlUtf8Length(completeContent.length(),completeContent.str()),completeContent.str(),NULL);
|