diff options
author | Regina Pfeifer <regina@mailbox.org> | 2019-07-30 16:15:13 (GMT) |
---|---|---|
committer | Regina Pfeifer <regina@mailbox.org> | 2019-07-30 22:03:17 (GMT) |
commit | af24e4ef6e216184b8c207728d6b0312ce3c1525 (patch) | |
tree | d6bf6ab881d5bac857339b2c0e86bb660d13d54c /Source/cmForEachCommand.cxx | |
parent | ef38ff22f71ad0ffe83db42d903d26d4a41f4114 (diff) | |
download | CMake-af24e4ef6e216184b8c207728d6b0312ce3c1525.zip CMake-af24e4ef6e216184b8c207728d6b0312ce3c1525.tar.gz CMake-af24e4ef6e216184b8c207728d6b0312ce3c1525.tar.bz2 |
cmFunctionBlocker: Move common logic to base
Diffstat (limited to 'Source/cmForEachCommand.cxx')
-rw-r--r-- | Source/cmForEachCommand.cxx | 43 |
1 files changed, 7 insertions, 36 deletions
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index af32040..53ae479 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -8,6 +8,8 @@ #include <utility> #include "cm_memory.hxx" +#include "cm_static_string_view.hxx" +#include "cm_string_view.hxx" #include "cmExecutionStatus.h" #include "cmFunctionBlocker.h" @@ -22,23 +24,22 @@ class cmForEachFunctionBlocker : public cmFunctionBlocker public: cmForEachFunctionBlocker(cmMakefile* mf); ~cmForEachFunctionBlocker() override; - bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf, - cmExecutionStatus&) override; + + cm::string_view StartCommandName() const override { return "foreach"_s; } + cm::string_view EndCommandName() const override { return "endforeach"_s; } + bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) override; bool Replay(std::vector<cmListFileFunction> const& functions, - cmExecutionStatus& inStatus); + cmExecutionStatus& inStatus) override; std::vector<std::string> Args; - std::vector<cmListFileFunction> Functions; private: cmMakefile* Makefile; - int Depth; }; cmForEachFunctionBlocker::cmForEachFunctionBlocker(cmMakefile* mf) : Makefile(mf) - , Depth(0) { this->Makefile->PushLoopBlock(); } @@ -48,36 +49,6 @@ cmForEachFunctionBlocker::~cmForEachFunctionBlocker() this->Makefile->PopLoopBlock(); } -bool cmForEachFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, - cmMakefile& mf, - cmExecutionStatus& inStatus) -{ - if (lff.Name.Lower == "foreach") { - // record the number of nested foreach commands - this->Depth++; - } else if (lff.Name.Lower == "endforeach") { - // if this is the endofreach for this statement - if (!this->Depth) { - // Remove the function blocker for this scope or bail. - std::unique_ptr<cmFunctionBlocker> fb( - mf.RemoveFunctionBlocker(this, lff)); - if (!fb) { - return false; - } - - return this->Replay(this->Functions, inStatus); - } - // close out a nested foreach - this->Depth--; - } - - // record the command - this->Functions.push_back(lff); - - // always return true - return true; -} - bool cmForEachFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) { |