From 2a9299782ece0e2c5f990fcab2162d141aedb833 Mon Sep 17 00:00:00 2001 From: Gabor Bencze Date: Sun, 4 Aug 2019 19:05:36 +0200 Subject: cmCommand refactor: cmSeparateArgumentsCommand --- Source/cmCommands.cxx | 3 +-- Source/cmSeparateArgumentsCommand.cxx | 17 ++++++++--------- Source/cmSeparateArgumentsCommand.h | 26 +++----------------------- 3 files changed, 12 insertions(+), 34 deletions(-) diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 406954a..c23a9ca 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -153,8 +153,7 @@ void GetScriptingCommands(cmState* state) state->AddBuiltinCommand("option", cmOptionCommand); state->AddBuiltinCommand("cmake_parse_arguments", cmParseArgumentsCommand); state->AddBuiltinCommand("return", cmReturnCommand); - state->AddBuiltinCommand("separate_arguments", - cm::make_unique()); + state->AddBuiltinCommand("separate_arguments", cmSeparateArgumentsCommand); state->AddBuiltinCommand("set", cm::make_unique()); state->AddBuiltinCommand("set_directory_properties", cm::make_unique()); diff --git a/Source/cmSeparateArgumentsCommand.cxx b/Source/cmSeparateArgumentsCommand.cxx index ab4a0c7..27f45a8 100644 --- a/Source/cmSeparateArgumentsCommand.cxx +++ b/Source/cmSeparateArgumentsCommand.cxx @@ -5,17 +5,16 @@ #include #include +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmSystemTools.h" -class cmExecutionStatus; - // cmSeparateArgumentsCommand -bool cmSeparateArgumentsCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +bool cmSeparateArgumentsCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.empty()) { - this->SetError("must be given at least one argument."); + status.SetError("must be given at least one argument."); return false; } @@ -59,17 +58,17 @@ bool cmSeparateArgumentsCommand::InitialPass( } else { std::ostringstream e; e << "given unknown argument " << arg; - this->SetError(e.str()); + status.SetError(e.str()); return false; } } if (mode == ModeOld) { // Original space-replacement version of command. - if (const char* def = this->Makefile->GetDefinition(var)) { + if (const char* def = status.GetMakefile().GetDefinition(var)) { std::string value = def; std::replace(value.begin(), value.end(), ' ', ';'); - this->Makefile->AddDefinition(var, value); + status.GetMakefile().AddDefinition(var, value); } } else { // Parse the command line. @@ -97,7 +96,7 @@ bool cmSeparateArgumentsCommand::InitialPass( value += si; } } - this->Makefile->AddDefinition(var, value); + status.GetMakefile().AddDefinition(var, value); } return true; diff --git a/Source/cmSeparateArgumentsCommand.h b/Source/cmSeparateArgumentsCommand.h index 76e2002..e000c51 100644 --- a/Source/cmSeparateArgumentsCommand.h +++ b/Source/cmSeparateArgumentsCommand.h @@ -8,34 +8,14 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmSeparateArgumentsCommand +/** * \brief separate_arguments command * * cmSeparateArgumentsCommand implements the separate_arguments CMake command */ -class cmSeparateArgumentsCommand : 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 cmSeparateArgumentsCommand(std::vector const& args, + cmExecutionStatus& status); #endif -- cgit v0.12