Commit 86b15955 authored by bonnell's avatar bonnell
Browse files

Clean up generated atts that contain switch statements with no case labels

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@21173 18c085ea-50e0-402c-830e-de6fd14e8384
parent 5fac871a
......@@ -586,10 +586,7 @@ ThresholdAttributes::SetFromNode(DataNode *parentNode)
std::string
ThresholdAttributes::GetFieldName(int index) const
{
switch (index)
{
default: return ThresholdOpAttributes::GetFieldName(index);
}
return ThresholdOpAttributes::GetFieldName(index);
}
// ****************************************************************************
......@@ -610,10 +607,7 @@ ThresholdAttributes::GetFieldName(int index) const
AttributeGroup::FieldType
ThresholdAttributes::GetFieldType(int index) const
{
switch (index)
{
default: return ThresholdOpAttributes::GetFieldType(index);
}
return ThresholdOpAttributes::GetFieldType(index);
}
// ****************************************************************************
......@@ -634,10 +628,7 @@ ThresholdAttributes::GetFieldType(int index) const
std::string
ThresholdAttributes::GetFieldTypeName(int index) const
{
switch (index)
{
default: return ThresholdOpAttributes::GetFieldTypeName(index);
}
return ThresholdOpAttributes::GetFieldTypeName(index);
}
// ****************************************************************************
......@@ -658,14 +649,7 @@ ThresholdAttributes::GetFieldTypeName(int index) const
bool
ThresholdAttributes::FieldsEqual(int index_, const AttributeGroup *rhs) const
{
const ThresholdAttributes &obj = *((const ThresholdAttributes*)rhs);
bool retval = false;
switch (index_)
{
default: retval = ThresholdOpAttributes::FieldsEqual(index_, rhs);
}
return retval;
return ThresholdOpAttributes::FieldsEqual(index_, rhs);
}
///////////////////////////////////////////////////////////////////////////////
......
......@@ -208,6 +208,11 @@
// Kathleen Biagas, Tue Mar 1 11:01:51 PST 2011
// Added Generator for MapNode type.
//
// Kathleen Biagas, Tue Jun 18 10:28:36 PDT 2013
// Added logic to forego switch statements on GetField* calls that have
// no fields, as in the case of derived or place-holder atts that define
// no new fields beyond what the base class has defined.
//
// ****************************************************************************
// ----------------------------------------------------------------------------
......@@ -2975,18 +2980,28 @@ private:
c << "std::string" << Endl;
c << name << "::GetFieldName(int index) const" << Endl;
c << "{" << Endl;
c << " switch (index)" << Endl;
c << " {" << Endl;
for (size_t i=0; i<fields.size(); i++)
if (fields.size() > 0)
{
QString fieldID(PadStringWithSpaces(fields[i]->FieldID() + QString(":"), maxlen));
c << " case "<<fieldID<<" return \""<<fields[i]->name<<"\";" << Endl;
c << " switch (index)" << Endl;
c << " {" << Endl;
for (size_t i=0; i<fields.size(); i++)
{
QString fieldID(PadStringWithSpaces(fields[i]->FieldID() + QString(":"), maxlen));
c << " case "<<fieldID<<" return \""<<fields[i]->name<<"\";" << Endl;
}
if (custombase)
c << " default: return " << baseClass << "::GetFieldName(index);" << Endl;
else
c << " default: return \"invalid index\";" << Endl;
c << " }" << Endl;
}
if (custombase)
c << " default: return " << baseClass << "::GetFieldName(index);" << Endl;
else
c << " default: return \"invalid index\";" << Endl;
c << " }" << Endl;
{
if (custombase)
c << " return " << baseClass << "::GetFieldName(index);" << Endl;
else
c << " return \"invalid index\";" << Endl;
}
c << "}" << Endl;
c << Endl;
......@@ -2996,18 +3011,28 @@ private:
c << "AttributeGroup::FieldType" << Endl;
c << name << "::GetFieldType(int index) const" << Endl;
c << "{" << Endl;
c << " switch (index)" << Endl;
c << " {" << Endl;
for (size_t i=0; i<fields.size(); i++)
if (fields.size() > 0)
{
QString fieldID(PadStringWithSpaces(fields[i]->FieldID() + QString(":"), maxlen));
c << " case "<<fieldID<<" return FieldType_"<<fields[i]->GetFieldType()<<";" << Endl;
c << " switch (index)" << Endl;
c << " {" << Endl;
for (size_t i=0; i<fields.size(); i++)
{
QString fieldID(PadStringWithSpaces(fields[i]->FieldID() + QString(":"), maxlen));
c << " case "<<fieldID<<" return FieldType_"<<fields[i]->GetFieldType()<<";" << Endl;
}
if (custombase)
c << " default: return " << baseClass << "::GetFieldType(index);" << Endl;
else
c << " default: return FieldType_unknown;" << Endl;
c << " }" << Endl;
}
if (custombase)
c << " default: return " << baseClass << "::GetFieldType(index);" << Endl;
else
c << " default: return FieldType_unknown;" << Endl;
c << " }" << Endl;
{
if (custombase)
c << " return " << baseClass << "::GetFieldType(index);" << Endl;
else
c << " return FieldType_unknown;" << Endl;
}
c << "}" << Endl;
c << Endl;
......@@ -3017,18 +3042,28 @@ private:
c << "std::string" << Endl;
c << name << "::GetFieldTypeName(int index) const" << Endl;
c << "{" << Endl;
c << " switch (index)" << Endl;
c << " {" << Endl;
for (size_t i=0; i<fields.size(); i++)
if (fields.size() > 0)
{
QString fieldID(PadStringWithSpaces(fields[i]->FieldID() + QString(":"), maxlen));
c << " case "<<fieldID<<" return \""<<fields[i]->type<<"\";" << Endl;
c << " switch (index)" << Endl;
c << " {" << Endl;
for (size_t i=0; i<fields.size(); i++)
{
QString fieldID(PadStringWithSpaces(fields[i]->FieldID() + QString(":"), maxlen));
c << " case "<<fieldID<<" return \""<<fields[i]->type<<"\";" << Endl;
}
if (custombase)
c << " default: return " << baseClass << "::GetFieldTypeName(index);" << Endl;
else
c << " default: return \"invalid index\";" << Endl;
c << " }" << Endl;
}
if (custombase)
c << " default: return " << baseClass << "::GetFieldTypeName(index);" << Endl;
else
c << " default: return \"invalid index\";" << Endl;
c << " }" << Endl;
{
if (custombase)
c << " return " << baseClass << "::GetFieldTypeName(index);" << Endl;
else
c << " return \"invalid index\";" << Endl;
}
c << "}" << Endl;
c << Endl;
......@@ -3039,30 +3074,40 @@ private:
c << name << "::FieldsEqual(int index_, const AttributeGroup *rhs) const" << Endl;
c << "{" << Endl;
c << " const "<<name<<" &obj = *((const "<<name<<"*)rhs);" << Endl;
// Create bool values to evaluate the arrays.
c << " bool retval = false;" << Endl;
c << " switch (index_)" << Endl;
c << " {" << Endl;
if (fields.size() > 0)
{
c << " const "<<name<<" &obj = *((const "<<name<<"*)rhs);"<<Endl;
c << " bool retval = false;" << Endl;
c << " switch (index_)" << Endl;
c << " {" << Endl;
// Create a big boolean return statement.
for (size_t i=0; i<fields.size(); i++)
// Create a big boolean return statement.
for (size_t i=0; i<fields.size(); i++)
{
c << " case "<<fields[i]->FieldID()<<":" << Endl;
c << " { // new scope" << Endl;
fields[i]->WriteSourceComparisonPrecalc(c, " ");
c << " retval = ";
fields[i]->WriteSourceComparison(c);
c << ";" << Endl << " }" << Endl;
c << " break;" << Endl;
}
if (custombase)
c << " default: retval = " << baseClass << "::FieldsEqual(index_, rhs);" << Endl;
else
c << " default: retval = false;" << Endl;
c << " }" << Endl << Endl;
c << " return retval;" << Endl;
}
else
{
c << " case "<<fields[i]->FieldID()<<":" << Endl;
c << " { // new scope" << Endl;
fields[i]->WriteSourceComparisonPrecalc(c, " ");
c << " retval = ";
fields[i]->WriteSourceComparison(c);
c << ";" << Endl << " }" << Endl;
c << " break;" << Endl;
if (custombase)
c << " return " << baseClass << "::FieldsEqual(index_, rhs);" << Endl;
else
c << " return false;" << Endl;
}
if (custombase)
c << " default: retval = " << baseClass << "::FieldsEqual(index_, rhs);" << Endl;
else
c << " default: retval = false;" << Endl;
c << " }" << Endl << Endl;
c << " return retval;" << Endl;
c << "}" << Endl << Endl;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment