From ceab7bda44b06fc6fdb842b7a51ccc662c907fb9 Mon Sep 17 00:00:00 2001
From: Gabor Bencze <b.gabor98@gmail.com>
Date: Fri, 2 Aug 2019 18:35:08 +0200
Subject: cmCommand refactor: cmIncludeGuardCommand

---
 Source/cmCommands.cxx            |  3 +--
 Source/cmIncludeGuardCommand.cxx | 12 ++++++------
 Source/cmIncludeGuardCommand.h   | 26 +++-----------------------
 3 files changed, 10 insertions(+), 31 deletions(-)

diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index b6008f5..aafbf14 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -143,8 +143,7 @@ void GetScriptingCommands(cmState* state)
   state->AddBuiltinCommand("get_property", cmGetPropertyCommand);
   state->AddBuiltinCommand("if", cmIfCommand);
   state->AddBuiltinCommand("include", cmIncludeCommand);
-  state->AddBuiltinCommand("include_guard",
-                           cm::make_unique<cmIncludeGuardCommand>());
+  state->AddBuiltinCommand("include_guard", cmIncludeGuardCommand);
   state->AddBuiltinCommand("list", cm::make_unique<cmListCommand>());
   state->AddBuiltinCommand("macro", cm::make_unique<cmMacroCommand>());
   state->AddBuiltinCommand("make_directory",
diff --git a/Source/cmIncludeGuardCommand.cxx b/Source/cmIncludeGuardCommand.cxx
index e560910..ccb4496 100644
--- a/Source/cmIncludeGuardCommand.cxx
+++ b/Source/cmIncludeGuardCommand.cxx
@@ -50,11 +50,11 @@ bool CheckIncludeGuardIsSet(cmMakefile* mf, std::string const& includeGuardVar)
 } // anonymous namespace
 
 // cmIncludeGuardCommand
-bool cmIncludeGuardCommand::InitialPass(std::vector<std::string> const& args,
-                                        cmExecutionStatus& status)
+bool cmIncludeGuardCommand(std::vector<std::string> const& args,
+                           cmExecutionStatus& status)
 {
   if (args.size() > 1) {
-    this->SetError(
+    status.SetError(
       "given an invalid number of arguments. The command takes at "
       "most 1 argument.");
     return false;
@@ -69,15 +69,15 @@ bool cmIncludeGuardCommand::InitialPass(std::vector<std::string> const& args,
     } else if (arg == "GLOBAL") {
       scope = GLOBAL;
     } else {
-      this->SetError("given an invalid scope: " + arg);
+      status.SetError("given an invalid scope: " + arg);
       return false;
     }
   }
 
   std::string includeGuardVar = GetIncludeGuardVariableName(
-    this->Makefile->GetDefinition("CMAKE_CURRENT_LIST_FILE"));
+    status.GetMakefile().GetDefinition("CMAKE_CURRENT_LIST_FILE"));
 
-  cmMakefile* const mf = this->Makefile;
+  cmMakefile* const mf = &status.GetMakefile();
 
   switch (scope) {
     case VARIABLE:
diff --git a/Source/cmIncludeGuardCommand.h b/Source/cmIncludeGuardCommand.h
index 4306c4c..b86b760 100644
--- a/Source/cmIncludeGuardCommand.h
+++ b/Source/cmIncludeGuardCommand.h
@@ -8,35 +8,15 @@
 #include <string>
 #include <vector>
 
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
 class cmExecutionStatus;
 
-/** \class cmIncludeGuardCommand
+/**
  * \brief cmIncludeGuardCommand identical to C++ #pragma_once command
  * Can work in 3 modes: GLOBAL (works on global properties),
  * DIRECTORY(use directory property), VARIABLE(unnamed overload without
  * arguments) define an ordinary variable to be used as include guard checker
  */
-class cmIncludeGuardCommand : public cmCommand
-{
-public:
-  /**
-   * This is a virtual constructor for the command.
-   */
-  std::unique_ptr<cmCommand> Clone() override
-  {
-    return cm::make_unique<cmIncludeGuardCommand>();
-  }
-
-  /**
-   * 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 cmIncludeGuardCommand(std::vector<std::string> const& args,
+                           cmExecutionStatus& status);
 
 #endif
-- 
cgit v0.12