mirror of
https://github.com/reactos/CMake.git
synced 2025-01-19 18:02:20 +00:00
cmCommand refactor: cmFunctionCommand
This commit is contained in:
parent
cce3600e3f
commit
9bbe95a0e7
@ -134,7 +134,7 @@ void GetScriptingCommands(cmState* state)
|
||||
state->AddBuiltinCommand("find_program",
|
||||
cm::make_unique<cmFindProgramCommand>());
|
||||
state->AddBuiltinCommand("foreach", cmForEachCommand);
|
||||
state->AddBuiltinCommand("function", cm::make_unique<cmFunctionCommand>());
|
||||
state->AddBuiltinCommand("function", cmFunctionCommand);
|
||||
state->AddBuiltinCommand("get_cmake_property",
|
||||
cm::make_unique<cmGetCMakePropertyCommand>());
|
||||
state->AddBuiltinCommand("get_directory_property",
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
|
||||
#include "cm_memory.hxx"
|
||||
#include "cm_static_string_view.hxx"
|
||||
#include "cm_string_view.hxx"
|
||||
|
||||
@ -18,6 +19,7 @@
|
||||
#include "cmState.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
|
||||
namespace {
|
||||
// define the class for function commands
|
||||
class cmFunctionHelperCommand
|
||||
{
|
||||
@ -34,6 +36,7 @@ public:
|
||||
cmPolicies::PolicyMap Policies;
|
||||
std::string FilePath;
|
||||
};
|
||||
}
|
||||
|
||||
bool cmFunctionHelperCommand::operator()(
|
||||
std::vector<cmListFileArgument> const& args,
|
||||
@ -145,11 +148,11 @@ bool cmFunctionFunctionBlocker::Replay(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cmFunctionCommand::InitialPass(std::vector<std::string> const& args,
|
||||
cmExecutionStatus&)
|
||||
bool cmFunctionCommand(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;
|
||||
}
|
||||
|
||||
@ -157,7 +160,7 @@ bool cmFunctionCommand::InitialPass(std::vector<std::string> const& args,
|
||||
{
|
||||
auto fb = cm::make_unique<cmFunctionFunctionBlocker>();
|
||||
cmAppend(fb->Args, args);
|
||||
this->Makefile->AddFunctionBlocker(std::move(fb));
|
||||
status.GetMakefile().AddFunctionBlocker(std::move(fb));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -8,30 +8,10 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "cm_memory.hxx"
|
||||
|
||||
#include "cmCommand.h"
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
||||
/// Starts function() ... endfunction() block
|
||||
class cmFunctionCommand : public cmCommand
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This is a virtual constructor for the command.
|
||||
*/
|
||||
std::unique_ptr<cmCommand> Clone() override
|
||||
{
|
||||
return cm::make_unique<cmFunctionCommand>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 cmFunctionCommand(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user