From 9ae9f3e77e375c143e5200624f12d15e2bba02d4 Mon Sep 17 00:00:00 2001 From: Gabor Bencze Date: Fri, 2 Aug 2019 18:42:44 +0200 Subject: cmCommand refactor: cmMacroCommand --- Source/cmCommands.cxx | 2 +- Source/cmMacroCommand.cxx | 11 +++++++---- Source/cmMacroCommand.h | 24 ++---------------------- 3 files changed, 10 insertions(+), 27 deletions(-) diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index aafbf14..08bf182 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -145,7 +145,7 @@ void GetScriptingCommands(cmState* state) state->AddBuiltinCommand("include", cmIncludeCommand); state->AddBuiltinCommand("include_guard", cmIncludeGuardCommand); state->AddBuiltinCommand("list", cm::make_unique()); - state->AddBuiltinCommand("macro", cm::make_unique()); + state->AddBuiltinCommand("macro", cmMacroCommand); state->AddBuiltinCommand("make_directory", cm::make_unique()); state->AddBuiltinCommand("mark_as_advanced", diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 8689c8f..bc3c3ac 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -21,6 +21,8 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" +namespace { + // define the class for macro commands class cmMacroHelperCommand { @@ -178,12 +180,13 @@ bool cmMacroFunctionBlocker::Replay(std::vector functions, mf.GetState()->AddScriptedCommand(this->Args[0], std::move(f)); return true; } +} -bool cmMacroCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool cmMacroCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.empty()) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } @@ -191,7 +194,7 @@ bool cmMacroCommand::InitialPass(std::vector const& args, { auto fb = cm::make_unique(); cmAppend(fb->Args, args); - this->Makefile->AddFunctionBlocker(std::move(fb)); + status.GetMakefile().AddFunctionBlocker(std::move(fb)); } return true; } diff --git a/Source/cmMacroCommand.h b/Source/cmMacroCommand.h index 0d7083a..25091ea 100644 --- a/Source/cmMacroCommand.h +++ b/Source/cmMacroCommand.h @@ -8,30 +8,10 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; /// Starts macro() ... endmacro() block -class cmMacroCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmMacroCommand(std::vector const& args, + cmExecutionStatus& status); #endif -- cgit v0.12