cmCommand refactor: cmContinueCommand

This commit is contained in:
Gabor Bencze 2019-07-25 16:52:50 +02:00 committed by Brad King
parent 01949a02df
commit 0005e17d50
3 changed files with 15 additions and 33 deletions

View File

@ -121,7 +121,7 @@ void GetScriptingCommands(cmState* state)
state->AddBuiltinCommand("cmake_policy",
cm::make_unique<cmCMakePolicyCommand>());
state->AddBuiltinCommand("configure_file", cmConfigureFileCommand);
state->AddBuiltinCommand("continue", cm::make_unique<cmContinueCommand>());
state->AddBuiltinCommand("continue", cmContinueCommand);
state->AddBuiltinCommand("exec_program",
cm::make_unique<cmExecProgramCommand>());
state->AddBuiltinCommand("execute_process",

View File

@ -8,13 +8,14 @@
#include "cmSystemTools.h"
// cmContinueCommand
bool cmContinueCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status)
bool cmContinueCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
if (!this->Makefile->IsLoopBlock()) {
this->Makefile->IssueMessage(MessageType::FATAL_ERROR,
"A CONTINUE command was found outside of a "
"proper FOREACH or WHILE loop scope.");
if (!status.GetMakefile().IsLoopBlock()) {
status.GetMakefile().IssueMessage(
MessageType::FATAL_ERROR,
"A CONTINUE command was found outside of a "
"proper FOREACH or WHILE loop scope.");
cmSystemTools::SetFatalErrorOccured();
return true;
}
@ -22,9 +23,10 @@ bool cmContinueCommand::InitialPass(std::vector<std::string> const& args,
status.SetContinueInvoked();
if (!args.empty()) {
this->Makefile->IssueMessage(MessageType::FATAL_ERROR,
"The CONTINUE command does not accept any "
"arguments.");
status.GetMakefile().IssueMessage(
MessageType::FATAL_ERROR,
"The CONTINUE command does not accept any "
"arguments.");
cmSystemTools::SetFatalErrorOccured();
return true;
}

View File

@ -8,34 +8,14 @@
#include <string>
#include <vector>
#include "cm_memory.hxx"
#include "cmCommand.h"
class cmExecutionStatus;
/** \class cmContinueCommand
/**
* \brief Continue from an enclosing foreach or while loop
*
* cmContinueCommand returns from an enclosing foreach or while loop
*/
class cmContinueCommand : public cmCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
std::unique_ptr<cmCommand> Clone() override
{
return cm::make_unique<cmContinueCommand>();
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status) override;
};
bool cmContinueCommand(std::vector<std::string> const& args,
cmExecutionStatus& status);
#endif