Commit 36052330 authored by Chuck Atkins's avatar Chuck Atkins
Browse files

PVSC: Let Switch statements in PVSC XML have a default Case

parent c34720f0
...@@ -474,11 +474,16 @@ void handleSwitchCases(const pqServerConfiguration& configuration, QProcessEnvir ...@@ -474,11 +474,16 @@ void handleSwitchCases(const pqServerConfiguration& configuration, QProcessEnvir
qWarning() << "'<Switch/> element can only contain <Case/> elements"; qWarning() << "'<Switch/> element can only contain <Case/> elements";
continue; continue;
} }
const char* case_value = caseXML->GetAttribute("value"); const char* case_value = caseXML->GetAttribute("value");
if (!case_value || value != case_value)
// Case: Explicitly does not match
if (case_value && value != case_value)
{ {
continue; continue;
} }
// Case: Either matches or is default, i.e. no value
handled = true; handled = true;
for (unsigned int i = 0; i < caseXML->GetNumberOfNestedElements(); i++) for (unsigned int i = 0; i < caseXML->GetNumberOfNestedElements(); i++)
{ {
...@@ -495,6 +500,17 @@ void handleSwitchCases(const pqServerConfiguration& configuration, QProcessEnvir ...@@ -495,6 +500,17 @@ void handleSwitchCases(const pqServerConfiguration& configuration, QProcessEnvir
<< setXML->GetName() << "'"; << setXML->GetName() << "'";
} }
} }
// Case: Default needs early exit; warn if not the last case
if(!case_value)
{
if(kk+1 < switchXML->GetNumberOfNestedElements())
{
qWarning() << "Default 'Case' possibly overshadows explicit 'Case' "
<< "statements for variable '" << variable << "'";
}
break;
}
} }
if (!handled) if (!handled)
{ {
......
Supports Markdown
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