瀏覽代碼

cmCommand refactor: cmContinueCommand

Gabor Bencze 6 年之前
父節點
當前提交
0005e17d50
共有 3 個文件被更改,包括 15 次插入33 次删除
  1. 1 1
      Source/cmCommands.cxx
  2. 11 9
      Source/cmContinueCommand.cxx
  3. 3 23
      Source/cmContinueCommand.h

+ 1 - 1
Source/cmCommands.cxx

@@ -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",

+ 11 - 9
Source/cmContinueCommand.cxx

@@ -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;
   }

+ 3 - 23
Source/cmContinueCommand.h

@@ -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