From b1acc711f4cdf62a850c09a85256482db2e2af2e Mon Sep 17 00:00:00 2001 From: Gabor Bencze Date: Fri, 9 Aug 2019 11:51:17 +0200 Subject: cmCommand refactor: cmRemoveCommand --- Source/cmCommands.cxx | 2 +- Source/cmRemoveCommand.cxx | 11 +++++------ Source/cmRemoveCommand.h | 26 +++----------------------- 3 files changed, 9 insertions(+), 30 deletions(-) diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index ff21df8..6a3af27 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -202,7 +202,7 @@ void GetScriptingCommands(cmState* state) #if !defined(CMAKE_BOOTSTRAP) state->AddBuiltinCommand("cmake_host_system_information", cmCMakeHostSystemInformationCommand); - state->AddBuiltinCommand("remove", cm::make_unique()); + state->AddBuiltinCommand("remove", cmRemoveCommand); state->AddBuiltinCommand("variable_watch", cm::make_unique()); state->AddBuiltinCommand("write_file", diff --git a/Source/cmRemoveCommand.cxx b/Source/cmRemoveCommand.cxx index 4ba21fa..457b708 100644 --- a/Source/cmRemoveCommand.cxx +++ b/Source/cmRemoveCommand.cxx @@ -2,14 +2,13 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmRemoveCommand.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmStringAlgorithms.h" -class cmExecutionStatus; - // cmRemoveCommand -bool cmRemoveCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool cmRemoveCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.empty()) { return true; @@ -17,7 +16,7 @@ bool cmRemoveCommand::InitialPass(std::vector const& args, std::string const& variable = args[0]; // VAR is always first // get the old value - const char* cacheValue = this->Makefile->GetDefinition(variable); + const char* cacheValue = status.GetMakefile().GetDefinition(variable); // if there is no old value then return if (!cacheValue) { @@ -51,7 +50,7 @@ bool cmRemoveCommand::InitialPass(std::vector const& args, } // add the definition - this->Makefile->AddDefinition(variable, value); + status.GetMakefile().AddDefinition(variable, value); return true; } diff --git a/Source/cmRemoveCommand.h b/Source/cmRemoveCommand.h index 088d8ad..fb72ab5 100644 --- a/Source/cmRemoveCommand.h +++ b/Source/cmRemoveCommand.h @@ -8,34 +8,14 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmRemoveCommand +/** * \brief remove command * * cmRemoveCommand implements the remove CMake command */ -class cmRemoveCommand : 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 cmRemoveCommand(std::vector const& args, + cmExecutionStatus& status); #endif -- cgit v0.12