Extract the ProcessArbitraryContent method.

This commit is contained in:
Stephen Kelly 2013-04-25 13:54:18 +02:00
parent 05bf9721e4
commit dc742fe4be
2 changed files with 62 additions and 41 deletions

View File

@ -992,6 +992,57 @@ std::string GeneratorExpressionContent::GetOriginalExpression() const
return std::string(this->StartContent, this->ContentLength); return std::string(this->StartContent, this->ContentLength);
} }
//----------------------------------------------------------------------------
std::string GeneratorExpressionContent::ProcessArbitraryContent(
const cmGeneratorExpressionNode *node,
const std::string &identifier,
cmGeneratorExpressionContext *context,
cmGeneratorExpressionDAGChecker *dagChecker,
std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
pit) const
{
std::string result;
const
std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
pend = this->ParamChildren.end();
for ( ; pit != pend; ++pit)
{
std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it
= pit->begin();
const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end
= pit->end();
for ( ; it != end; ++it)
{
if (node->RequiresLiteralInput())
{
if ((*it)->GetType() != cmGeneratorExpressionEvaluator::Text)
{
reportError(context, this->GetOriginalExpression(),
"$<" + identifier + "> expression requires literal input.");
return std::string();
}
}
result += (*it)->Evaluate(context, dagChecker);
if (context->HadError)
{
return std::string();
}
}
if ((pit + 1) != pend)
{
result += ",";
}
}
if (node->RequiresLiteralInput())
{
std::vector<std::string> parameters;
parameters.push_back(result);
return node->Evaluate(parameters, context, this, dagChecker);
}
return result;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string GeneratorExpressionContent::Evaluate( std::string GeneratorExpressionContent::Evaluate(
cmGeneratorExpressionContext *context, cmGeneratorExpressionContext *context,
@ -1043,47 +1094,9 @@ std::string GeneratorExpressionContent::Evaluate(
if (node->AcceptsSingleArbitraryContentParameter()) if (node->AcceptsSingleArbitraryContentParameter())
{ {
std::string result; return this->ProcessArbitraryContent(node, identifier, context,
std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator dagChecker,
pit = this->ParamChildren.begin(); this->ParamChildren.begin());
const
std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
pend = this->ParamChildren.end();
for ( ; pit != pend; ++pit)
{
std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it
= pit->begin();
const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end
= pit->end();
for ( ; it != end; ++it)
{
if (node->RequiresLiteralInput())
{
if ((*it)->GetType() != cmGeneratorExpressionEvaluator::Text)
{
reportError(context, this->GetOriginalExpression(),
"$<" + identifier + "> expression requires literal input.");
return std::string();
}
}
result += (*it)->Evaluate(context, dagChecker);
if (context->HadError)
{
return std::string();
}
}
if ((pit + 1) != pend)
{
result += ",";
}
}
if (node->RequiresLiteralInput())
{
std::vector<std::string> parameters;
parameters.push_back(result);
return node->Evaluate(parameters, context, this, dagChecker);
}
return result;
} }
std::vector<std::string> parameters; std::vector<std::string> parameters;

View File

@ -129,6 +129,14 @@ private:
cmGeneratorExpressionDAGChecker *dagChecker, cmGeneratorExpressionDAGChecker *dagChecker,
std::vector<std::string> &parameters) const; std::vector<std::string> &parameters) const;
std::string ProcessArbitraryContent(
const cmGeneratorExpressionNode *node,
const std::string &identifier,
cmGeneratorExpressionContext *context,
cmGeneratorExpressionDAGChecker *dagChecker,
std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
pit) const;
private: private:
std::vector<cmGeneratorExpressionEvaluator*> IdentifierChildren; std::vector<cmGeneratorExpressionEvaluator*> IdentifierChildren;
std::vector<std::vector<cmGeneratorExpressionEvaluator*> > ParamChildren; std::vector<std::vector<cmGeneratorExpressionEvaluator*> > ParamChildren;