summaryrefslogtreecommitdiffstats
path: root/Source/cmMacroCommand.cxx
diff options
context:
space:
mode:
authorRegina Pfeifer <regina@mailbox.org>2019-07-30 16:15:13 (GMT)
committerRegina Pfeifer <regina@mailbox.org>2019-07-30 22:03:17 (GMT)
commitaf24e4ef6e216184b8c207728d6b0312ce3c1525 (patch)
treed6bf6ab881d5bac857339b2c0e86bb660d13d54c /Source/cmMacroCommand.cxx
parentef38ff22f71ad0ffe83db42d903d26d4a41f4114 (diff)
downloadCMake-af24e4ef6e216184b8c207728d6b0312ce3c1525.zip
CMake-af24e4ef6e216184b8c207728d6b0312ce3c1525.tar.gz
CMake-af24e4ef6e216184b8c207728d6b0312ce3c1525.tar.bz2
cmFunctionBlocker: Move common logic to base
Diffstat (limited to 'Source/cmMacroCommand.cxx')
-rw-r--r--Source/cmMacroCommand.cxx35
1 files changed, 6 insertions, 29 deletions
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index e82d6fa..030bb66 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -7,6 +7,8 @@
#include <utility>
#include "cm_memory.hxx"
+#include "cm_static_string_view.hxx"
+#include "cm_string_view.hxx"
#include "cmAlgorithms.h"
#include "cmExecutionStatus.h"
@@ -141,41 +143,16 @@ bool cmMacroHelperCommand::operator()(
class cmMacroFunctionBlocker : public cmFunctionBlocker
{
public:
- bool IsFunctionBlocked(const cmListFileFunction&, cmMakefile& mf,
- cmExecutionStatus&) override;
+ cm::string_view StartCommandName() const override { return "macro"_s; }
+ cm::string_view EndCommandName() const override { return "endmacro"_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 cmMacroFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
- cmMakefile& mf,
- cmExecutionStatus& status)
-{
- // record commands until we hit the ENDMACRO
- // at the ENDMACRO call we shift gears and start looking for invocations
- if (lff.Name.Lower == "macro") {
- this->Depth++;
- } else if (lff.Name.Lower == "endmacro") {
- // if this is the endmacro for this macro then execute
- if (!this->Depth) {
- auto self = mf.RemoveFunctionBlocker(this, lff);
- return this->Replay(this->Functions, status);
- }
- // decrement for each nested macro that ends
- this->Depth--;
- }
-
- // if it wasn't an endmacro and we are not executing then we must be
- // recording
- this->Functions.push_back(lff);
- return true;
-}
-
bool cmMacroFunctionBlocker::ShouldRemove(const cmListFileFunction& lff,
cmMakefile& mf)
{