From 7c83c192056536defb35df36acf753701a2e78a2 Mon Sep 17 00:00:00 2001 From: Gabor Bencze Date: Fri, 9 Aug 2019 14:24:17 +0200 Subject: cmCommand refactor: cmSetDirectoryPropertiesCommand --- Source/cmCommands.cxx | 2 +- Source/cmSetDirectoryPropertiesCommand.cxx | 29 ++++++++++++++++++----------- Source/cmSetDirectoryPropertiesCommand.h | 30 ++---------------------------- 3 files changed, 21 insertions(+), 40 deletions(-) diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index df61b4e..6a66c7b 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -155,7 +155,7 @@ void GetScriptingCommands(cmState* state) state->AddBuiltinCommand("separate_arguments", cmSeparateArgumentsCommand); state->AddBuiltinCommand("set", cmSetCommand); state->AddBuiltinCommand("set_directory_properties", - cm::make_unique()); + cmSetDirectoryPropertiesCommand); state->AddBuiltinCommand("set_property", cm::make_unique()); state->AddBuiltinCommand("site_name", cmSiteNameCommand); diff --git a/Source/cmSetDirectoryPropertiesCommand.cxx b/Source/cmSetDirectoryPropertiesCommand.cxx index 8d3961a..35daca6 100644 --- a/Source/cmSetDirectoryPropertiesCommand.cxx +++ b/Source/cmSetDirectoryPropertiesCommand.cxx @@ -2,31 +2,37 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmSetDirectoryPropertiesCommand.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" -class cmExecutionStatus; +namespace { +bool RunCommand(cmMakefile& mf, std::vector::const_iterator ait, + std::vector::const_iterator aitend, + std::string& errors); +} // cmSetDirectoryPropertiesCommand -bool cmSetDirectoryPropertiesCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +bool cmSetDirectoryPropertiesCommand(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; } std::string errors; - bool ret = cmSetDirectoryPropertiesCommand::RunCommand( - this->Makefile, args.begin() + 1, args.end(), errors); + bool ret = + RunCommand(status.GetMakefile(), args.begin() + 1, args.end(), errors); if (!ret) { - this->SetError(errors); + status.SetError(errors); } return ret; } -bool cmSetDirectoryPropertiesCommand::RunCommand( - cmMakefile* mf, std::vector::const_iterator ait, - std::vector::const_iterator aitend, std::string& errors) +namespace { +bool RunCommand(cmMakefile& mf, std::vector::const_iterator ait, + std::vector::const_iterator aitend, + std::string& errors) { for (; ait != aitend; ait += 2) { if (ait + 1 == aitend) { @@ -43,8 +49,9 @@ bool cmSetDirectoryPropertiesCommand::RunCommand( errors = "Commands and macros cannot be set using SET_CMAKE_PROPERTIES"; return false; } - mf->SetProperty(prop, value.c_str()); + mf.SetProperty(prop, value.c_str()); } return true; } +} diff --git a/Source/cmSetDirectoryPropertiesCommand.h b/Source/cmSetDirectoryPropertiesCommand.h index 5416127..c243dd7 100644 --- a/Source/cmSetDirectoryPropertiesCommand.h +++ b/Source/cmSetDirectoryPropertiesCommand.h @@ -8,35 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -class cmMakefile; - -class cmSetDirectoryPropertiesCommand : public cmCommand -{ -public: - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the input file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - /** - * Static entry point for use by other commands - */ - static bool RunCommand(cmMakefile* mf, - std::vector::const_iterator ait, - std::vector::const_iterator aitend, - std::string& errors); -}; +bool cmSetDirectoryPropertiesCommand(std::vector const& args, + cmExecutionStatus& status); #endif -- cgit v0.12