mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-24 07:08:38 -05:00
cmCommand refactor: cmMacroCommand
This commit is contained in:
@@ -145,7 +145,7 @@ void GetScriptingCommands(cmState* state)
|
||||
state->AddBuiltinCommand("include", cmIncludeCommand);
|
||||
state->AddBuiltinCommand("include_guard", cmIncludeGuardCommand);
|
||||
state->AddBuiltinCommand("list", cm::make_unique<cmListCommand>());
|
||||
state->AddBuiltinCommand("macro", cm::make_unique<cmMacroCommand>());
|
||||
state->AddBuiltinCommand("macro", cmMacroCommand);
|
||||
state->AddBuiltinCommand("make_directory",
|
||||
cm::make_unique<cmMakeDirectoryCommand>());
|
||||
state->AddBuiltinCommand("mark_as_advanced",
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
namespace {
|
||||
|
||||
// define the class for macro commands
|
||||
class cmMacroHelperCommand
|
||||
{
|
||||
@@ -178,12 +180,13 @@ bool cmMacroFunctionBlocker::Replay(std::vector<cmListFileFunction> functions,
|
||||
mf.GetState()->AddScriptedCommand(this->Args[0], std::move(f));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool cmMacroCommand::InitialPass(std::vector<std::string> const& args,
|
||||
cmExecutionStatus&)
|
||||
bool cmMacroCommand(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status)
|
||||
{
|
||||
if (args.empty()) {
|
||||
this->SetError("called with incorrect number of arguments");
|
||||
status.SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -191,7 +194,7 @@ bool cmMacroCommand::InitialPass(std::vector<std::string> const& args,
|
||||
{
|
||||
auto fb = cm::make_unique<cmMacroFunctionBlocker>();
|
||||
cmAppend(fb->Args, args);
|
||||
this->Makefile->AddFunctionBlocker(std::move(fb));
|
||||
status.GetMakefile().AddFunctionBlocker(std::move(fb));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
+2
-22
@@ -8,30 +8,10 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "cm_memory.hxx"
|
||||
|
||||
#include "cmCommand.h"
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
||||
/// Starts macro() ... endmacro() block
|
||||
class cmMacroCommand : public cmCommand
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This is a virtual constructor for the command.
|
||||
*/
|
||||
std::unique_ptr<cmCommand> Clone() override
|
||||
{
|
||||
return cm::make_unique<cmMacroCommand>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 cmMacroCommand(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user