From 80b9f0cbe263c64613acd18e4e94505924fce40e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 22 Feb 2015 21:30:44 +0100 Subject: Genex: Extract an evaluateWithContext method. Make it easier to make modifications to the context before evaluating with it. --- Source/cmGeneratorExpression.cxx | 32 ++++++++++++++++++++------------ Source/cmGeneratorExpression.h | 4 ++++ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 0a27016..a4990dc 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -72,18 +72,6 @@ const char *cmCompiledGeneratorExpression::Evaluate( cmGeneratorExpressionDAGChecker *dagChecker, std::string const& language) const { - if (!this->NeedsEvaluation) - { - return this->Input.c_str(); - } - - this->Output = ""; - - std::vector::const_iterator it - = this->Evaluators.begin(); - const std::vector::const_iterator end - = this->Evaluators.end(); - cmGeneratorExpressionContext context; context.Makefile = mf; context.Config = config; @@ -98,6 +86,26 @@ const char *cmCompiledGeneratorExpression::Evaluate( context.Backtrace = this->Backtrace; context.Language = language; + return this->EvaluateWithContext(context, dagChecker); +} + +//---------------------------------------------------------------------------- +const char* cmCompiledGeneratorExpression::EvaluateWithContext( + cmGeneratorExpressionContext& context, + cmGeneratorExpressionDAGChecker *dagChecker) const +{ + if (!this->NeedsEvaluation) + { + return this->Input.c_str(); + } + + this->Output = ""; + + std::vector::const_iterator it + = this->Evaluators.begin(); + const std::vector::const_iterator end + = this->Evaluators.end(); + for ( ; it != end; ++it) { this->Output += (*it)->Evaluate(&context, dagChecker); diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index 55d9691..11c27fd 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -24,6 +24,7 @@ class cmMakefile; class cmListFileBacktrace; struct cmGeneratorExpressionEvaluator; +struct cmGeneratorExpressionContext; struct cmGeneratorExpressionDAGChecker; class cmCompiledGeneratorExpression; @@ -131,6 +132,9 @@ public: std::map& mapping); private: + const char* EvaluateWithContext(cmGeneratorExpressionContext& context, + cmGeneratorExpressionDAGChecker *dagChecker) const; + cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace, const std::string& input); -- cgit v0.12