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/cmFunctionCommand.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/cmFunctionCommand.cxx')
-rw-r--r-- | Source/cmFunctionCommand.cxx | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index 51b6970..6a04196 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -5,6 +5,9 @@ #include <sstream> #include <utility> +#include "cm_static_string_view.hxx" +#include "cm_string_view.hxx" + #include "cmAlgorithms.h" #include "cmExecutionStatus.h" #include "cmFunctionBlocker.h" @@ -107,40 +110,16 @@ bool cmFunctionHelperCommand::operator()( class cmFunctionFunctionBlocker : public cmFunctionBlocker { public: - bool IsFunctionBlocked(const cmListFileFunction&, cmMakefile& mf, - cmExecutionStatus&) override; + cm::string_view StartCommandName() const override { return "function"_s; } + cm::string_view EndCommandName() const override { return "endfunction"_s; } + bool ShouldRemove(const cmListFileFunction&, cmMakefile& mf) override; bool Replay(std::vector<cmListFileFunction> const& functions, - cmExecutionStatus& status); + cmExecutionStatus& status) override; std::vector<std::string> Args; - std::vector<cmListFileFunction> Functions; - int Depth = 0; }; -bool cmFunctionFunctionBlocker::IsFunctionBlocked( - const cmListFileFunction& lff, cmMakefile& mf, cmExecutionStatus& status) -{ - // record commands until we hit the ENDFUNCTION - // at the ENDFUNCTION call we shift gears and start looking for invocations - if (lff.Name.Lower == "function") { - this->Depth++; - } else if (lff.Name.Lower == "endfunction") { - // if this is the endfunction for this function then execute - if (!this->Depth) { - auto self = mf.RemoveFunctionBlocker(this, lff); - return this->Replay(this->Functions, status); - } - // decrement for each nested function that ends - this->Depth--; - } - - // if it wasn't an endfunction and we are not executing then we must be - // recording - this->Functions.push_back(lff); - return true; -} - bool cmFunctionFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) { |