diff options
author | Regina Pfeifer <regina@mailbox.org> | 2019-04-07 18:40:59 (GMT) |
---|---|---|
committer | Regina Pfeifer <regina@mailbox.org> | 2019-07-21 07:25:32 (GMT) |
commit | 0101ace1319b5c97472649ec809b67299e2a46ce (patch) | |
tree | bfe5efb6d3e133e4b96994f5cd65d5417a26ff12 | |
parent | 015001aaf138119f4825e3c84c0845c5127f9088 (diff) | |
download | CMake-0101ace1319b5c97472649ec809b67299e2a46ce.zip CMake-0101ace1319b5c97472649ec809b67299e2a46ce.tar.gz CMake-0101ace1319b5c97472649ec809b67299e2a46ce.tar.bz2 |
cmUnexpectedCommand: Replace with lambda expression
-rw-r--r-- | Source/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Source/cmState.cxx | 26 | ||||
-rw-r--r-- | Source/cmState.h | 1 | ||||
-rw-r--r-- | Source/cmUnexpectedCommand.cxx | 22 | ||||
-rw-r--r-- | Source/cmUnexpectedCommand.h | 40 | ||||
-rwxr-xr-x | bootstrap | 1 |
6 files changed, 22 insertions, 70 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 0316532..8117916 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -662,8 +662,6 @@ set(SRCS cmTryCompileCommand.h cmTryRunCommand.cxx cmTryRunCommand.h - cmUnexpectedCommand.cxx - cmUnexpectedCommand.h cmUnsetCommand.cxx cmUnsetCommand.h cmUseMangledMesaCommand.cxx diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 57ae324..82b0a52 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -5,6 +5,7 @@ #include "cmsys/RegularExpression.hxx" #include <algorithm> #include <assert.h> +#include <stdlib.h> #include <string.h> #include <utility> @@ -15,12 +16,13 @@ #include "cmCommand.h" #include "cmDefinitions.h" #include "cmDisallowedCommand.h" +#include "cmExecutionStatus.h" #include "cmGlobVerificationManager.h" #include "cmListFileCache.h" +#include "cmMakefile.h" #include "cmStatePrivate.h" #include "cmStateSnapshot.h" #include "cmSystemTools.h" -#include "cmUnexpectedCommand.h" #include "cmake.h" cmState::cmState() @@ -420,10 +422,14 @@ void cmState::SetIsGeneratorMultiConfig(bool b) void cmState::AddBuiltinCommand(std::string const& name, std::unique_ptr<cmCommand> command) { + this->AddBuiltinCommand(name, cmLegacyCommandWrapper(std::move(command))); +} + +void cmState::AddBuiltinCommand(std::string const& name, Command command) +{ assert(name == cmSystemTools::LowerCase(name)); assert(this->BuiltinCommands.find(name) == this->BuiltinCommands.end()); - this->BuiltinCommands.emplace(name, - cmLegacyCommandWrapper(std::move(command))); + this->BuiltinCommands.emplace(name, std::move(command)); } void cmState::AddDisallowedCommand(std::string const& name, @@ -438,8 +444,18 @@ void cmState::AddDisallowedCommand(std::string const& name, void cmState::AddUnexpectedCommand(std::string const& name, const char* error) { - this->AddBuiltinCommand(name, - cm::make_unique<cmUnexpectedCommand>(name, error)); + this->AddBuiltinCommand( + name, + [name, error](std::vector<cmListFileArgument> const&, + cmExecutionStatus& status) -> bool { + const char* versionValue = + status.GetMakefile().GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION"); + if (name == "endif" && (!versionValue || atof(versionValue) <= 1.4)) { + return true; + } + status.SetError(error); + return false; + }); } void cmState::AddScriptedCommand(std::string const& name, diff --git a/Source/cmState.h b/Source/cmState.h index ed70bd6..a6e9386 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -153,6 +153,7 @@ public: void AddBuiltinCommand(std::string const& name, std::unique_ptr<cmCommand> command); + void AddBuiltinCommand(std::string const& name, Command command); void AddDisallowedCommand(std::string const& name, std::unique_ptr<cmCommand> command, cmPolicies::PolicyID policy, const char* message); diff --git a/Source/cmUnexpectedCommand.cxx b/Source/cmUnexpectedCommand.cxx deleted file mode 100644 index a8de9e6..0000000 --- a/Source/cmUnexpectedCommand.cxx +++ /dev/null @@ -1,22 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmUnexpectedCommand.h" - -#include <stdlib.h> - -#include "cmMakefile.h" - -class cmExecutionStatus; - -bool cmUnexpectedCommand::InitialPass(std::vector<std::string> const&, - cmExecutionStatus&) -{ - const char* versionValue = - this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION"); - if (this->Name == "endif" && (!versionValue || atof(versionValue) <= 1.4)) { - return true; - } - - this->SetError(this->Error); - return false; -} diff --git a/Source/cmUnexpectedCommand.h b/Source/cmUnexpectedCommand.h deleted file mode 100644 index 6e4cee5..0000000 --- a/Source/cmUnexpectedCommand.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cmUnexpectedCommand_h -#define cmUnexpectedCommand_h - -#include "cmConfigure.h" // IWYU pragma: keep - -#include <string> -#include <utility> -#include <vector> - -#include "cm_memory.hxx" - -#include "cmCommand.h" - -class cmExecutionStatus; - -class cmUnexpectedCommand : public cmCommand -{ -public: - cmUnexpectedCommand(std::string name, const char* error) - : Name(std::move(name)) - , Error(error) - { - } - - std::unique_ptr<cmCommand> Clone() override - { - return cm::make_unique<cmUnexpectedCommand>(this->Name, this->Error); - } - - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; - -private: - std::string Name; - const char* Error; -}; - -#endif @@ -440,7 +440,6 @@ CMAKE_CXX_SOURCES="\ cmTimestamp \ cmTryCompileCommand \ cmTryRunCommand \ - cmUnexpectedCommand \ cmUnsetCommand \ cmUVHandlePtr \ cmUVProcessChain \ |