mirror of
https://github.com/reactos/CMake.git
synced 2025-02-23 13:32:49 +00:00
cmUnexpectedCommand: Replace with lambda expression
This commit is contained in:
parent
015001aaf1
commit
0101ace131
@ -662,8 +662,6 @@ set(SRCS
|
||||
cmTryCompileCommand.h
|
||||
cmTryRunCommand.cxx
|
||||
cmTryRunCommand.h
|
||||
cmUnexpectedCommand.cxx
|
||||
cmUnexpectedCommand.h
|
||||
cmUnsetCommand.cxx
|
||||
cmUnsetCommand.h
|
||||
cmUseMangledMesaCommand.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()
|
||||
@ -419,11 +421,15 @@ 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,
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
@ -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
|
Loading…
x
Reference in New Issue
Block a user