summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-12-17 23:32:35 (GMT)
committerStephen Kelly <steveire@gmail.com>2013-12-19 15:17:59 (GMT)
commitd36b48940114c7cc33f5592f06c372084a6b48f0 (patch)
tree58843ecb3103b9bfda3da9cdafebc81992a96bfd
parent218ad35f96e89dc1c311ff52445c8ec03b828d5b (diff)
downloadCMake-d36b48940114c7cc33f5592f06c372084a6b48f0.zip
CMake-d36b48940114c7cc33f5592f06c372084a6b48f0.tar.gz
CMake-d36b48940114c7cc33f5592f06c372084a6b48f0.tar.bz2
Genex: Allow single param expressions to accept arbirary input.
Existing single-parameter expressions work due to special casing which assumes that if there is only one parameter, and the node accepts arbitrary content, then the result is the input. This is true for the existing expressions matching that pattern - namely the "1" and "TARGET_NAME" expressions. However, the LOWER_CASE, and UPPER_CASE expressions should also accept arbitrary content, and in their case, the result is not the input. Refactor the cmGeneratorExpressionEvaluator to allow that extension. Actually evaluate the "1" and "0" nodes.
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx54
1 files changed, 23 insertions, 31 deletions
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 0f8c4e3..34d4434 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -82,7 +82,6 @@ static const struct ZeroNode : public cmGeneratorExpressionNode
const GeneratorExpressionContent *,
cmGeneratorExpressionDAGChecker *) const
{
- // Unreachable
return std::string();
}
} zeroNode;
@@ -94,13 +93,12 @@ static const struct OneNode : public cmGeneratorExpressionNode
virtual bool AcceptsArbitraryContentParameter() const { return true; }
- std::string Evaluate(const std::vector<std::string> &,
+ std::string Evaluate(const std::vector<std::string> &parameters,
cmGeneratorExpressionContext *,
const GeneratorExpressionContent *,
cmGeneratorExpressionDAGChecker *) const
{
- // Unreachable
- return std::string();
+ return parameters.front();
}
} oneNode;
@@ -1634,14 +1632,6 @@ std::string GeneratorExpressionContent::Evaluate(
return std::string();
}
- if (node->NumExpectedParameters() == 1
- && node->AcceptsArbitraryContentParameter())
- {
- return this->ProcessArbitraryContent(node, identifier, context,
- dagChecker,
- this->ParamChildren.begin());
- }
-
std::vector<std::string> parameters;
this->EvaluateParameters(node, identifier, context, dagChecker, parameters);
if (context->HadError)
@@ -1669,33 +1659,35 @@ std::string GeneratorExpressionContent::EvaluateParameters(
pend = this->ParamChildren.end();
const bool acceptsArbitraryContent
= node->AcceptsArbitraryContentParameter();
- for ( ; pit != pend; ++pit)
+ int counter = 1;
+ for ( ; pit != pend; ++pit, ++counter)
{
- std::string parameter;
- std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
- pit->begin();
- const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end =
- pit->end();
- for ( ; it != end; ++it)
- {
- parameter += (*it)->Evaluate(context, dagChecker);
- if (context->HadError)
- {
- return std::string();
- }
- }
- parameters.push_back(parameter);
- if (acceptsArbitraryContent
- && parameters.size() == (unsigned int)numExpected - 1)
+ if (acceptsArbitraryContent && counter == numExpected)
{
- assert(pit != pend);
std::string lastParam = this->ProcessArbitraryContent(node, identifier,
context,
dagChecker,
- pit + 1);
+ pit);
parameters.push_back(lastParam);
return std::string();
}
+ else
+ {
+ std::string parameter;
+ std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
+ pit->begin();
+ const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end =
+ pit->end();
+ for ( ; it != end; ++it)
+ {
+ parameter += (*it)->Evaluate(context, dagChecker);
+ if (context->HadError)
+ {
+ return std::string();
+ }
+ }
+ parameters.push_back(parameter);
+ }
}
}