Structure type json using "components".

This commit is contained in:
chriseth
2017-09-16 12:12:44 +01:00
committed by Alex Beregszaszi
parent 36a90289e6
commit 7e1b9c1652
2 changed files with 151 additions and 114 deletions
+8 -8
View File
@@ -136,25 +136,25 @@ Json::Value ABI::formatType(string const& _name, Type const& _type, bool _forLib
suffix = string("[") + arrayType->length().str() + "]";
solAssert(arrayType->baseType(), "");
Json::Value subtype = formatType("", *arrayType->baseType(), _forLibrary);
if (subtype["type"].isString() && !subtype.isMember("subtype"))
ret["type"] = subtype["type"].asString() + suffix;
else
if (subtype.isMember("components"))
{
ret["type"] = suffix;
solAssert(!subtype.isMember("subtype"), "");
ret["subtype"] = subtype["type"];
ret["type"] = subtype["type"].asString() + suffix;
ret["components"] = subtype["components"];
}
else
ret["type"] = subtype["type"].asString() + suffix;
}
}
else if (StructType const* structType = dynamic_cast<StructType const*>(&_type))
{
ret["type"] = Json::arrayValue;
ret["type"] = string();
ret["components"] = Json::arrayValue;
for (auto const& member: structType->members(nullptr))
{
solAssert(member.type, "");
auto t = member.type->interfaceType(_forLibrary);
solAssert(t, "");
ret["type"].append(formatType(member.name, *t, _forLibrary));
ret["components"].append(formatType(member.name, *t, _forLibrary));
}
}
else