|
@@ -2,6 +2,7 @@
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
|
|
#include "cmMathCommand.h"
|
|
#include "cmMathCommand.h"
|
|
|
|
|
|
|
|
|
|
+#include "cmExecutionStatus.h"
|
|
|
#include "cmExprParserHelper.h"
|
|
#include "cmExprParserHelper.h"
|
|
|
#include "cmMakefile.h"
|
|
#include "cmMakefile.h"
|
|
|
#include "cmMessageType.h"
|
|
#include "cmMessageType.h"
|
|
@@ -9,28 +10,33 @@
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
-class cmExecutionStatus;
|
|
|
|
|
|
|
+namespace {
|
|
|
|
|
+bool HandleExprCommand(std::vector<std::string> const& args,
|
|
|
|
|
+ cmExecutionStatus& status);
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
-bool cmMathCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
|
|
- cmExecutionStatus&)
|
|
|
|
|
|
|
+bool cmMathCommand(std::vector<std::string> const& args,
|
|
|
|
|
+ cmExecutionStatus& status)
|
|
|
{
|
|
{
|
|
|
if (args.empty()) {
|
|
if (args.empty()) {
|
|
|
- this->SetError("must be called with at least one argument.");
|
|
|
|
|
|
|
+ status.SetError("must be called with at least one argument.");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
const std::string& subCommand = args[0];
|
|
const std::string& subCommand = args[0];
|
|
|
if (subCommand == "EXPR") {
|
|
if (subCommand == "EXPR") {
|
|
|
- return this->HandleExprCommand(args);
|
|
|
|
|
|
|
+ return HandleExprCommand(args, status);
|
|
|
}
|
|
}
|
|
|
std::string e = "does not recognize sub-command " + subCommand;
|
|
std::string e = "does not recognize sub-command " + subCommand;
|
|
|
- this->SetError(e);
|
|
|
|
|
|
|
+ status.SetError(e);
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-bool cmMathCommand::HandleExprCommand(std::vector<std::string> const& args)
|
|
|
|
|
|
|
+namespace {
|
|
|
|
|
+bool HandleExprCommand(std::vector<std::string> const& args,
|
|
|
|
|
+ cmExecutionStatus& status)
|
|
|
{
|
|
{
|
|
|
if ((args.size() != 3) && (args.size() != 5)) {
|
|
if ((args.size() != 3) && (args.size() != 5)) {
|
|
|
- this->SetError("EXPR called with incorrect arguments.");
|
|
|
|
|
|
|
+ status.SetError("EXPR called with incorrect arguments.");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -46,7 +52,7 @@ bool cmMathCommand::HandleExprCommand(std::vector<std::string> const& args)
|
|
|
size_t argumentIndex = 3;
|
|
size_t argumentIndex = 3;
|
|
|
NumericFormat outputFormat = NumericFormat::UNINITIALIZED;
|
|
NumericFormat outputFormat = NumericFormat::UNINITIALIZED;
|
|
|
|
|
|
|
|
- this->Makefile->AddDefinition(outputVariable, "ERROR");
|
|
|
|
|
|
|
+ status.GetMakefile().AddDefinition(outputVariable, "ERROR");
|
|
|
|
|
|
|
|
if (argumentIndex < args.size()) {
|
|
if (argumentIndex < args.size()) {
|
|
|
const std::string messageHint = "sub-command EXPR ";
|
|
const std::string messageHint = "sub-command EXPR ";
|
|
@@ -61,19 +67,19 @@ bool cmMathCommand::HandleExprCommand(std::vector<std::string> const& args)
|
|
|
} else {
|
|
} else {
|
|
|
std::string error = messageHint + "value \"" + argument +
|
|
std::string error = messageHint + "value \"" + argument +
|
|
|
"\" for option \"" + option + "\" is invalid.";
|
|
"\" for option \"" + option + "\" is invalid.";
|
|
|
- this->SetError(error);
|
|
|
|
|
|
|
+ status.SetError(error);
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
std::string error =
|
|
std::string error =
|
|
|
messageHint + "missing argument for option \"" + option + "\".";
|
|
messageHint + "missing argument for option \"" + option + "\".";
|
|
|
- this->SetError(error);
|
|
|
|
|
|
|
+ status.SetError(error);
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
std::string error =
|
|
std::string error =
|
|
|
messageHint + "option \"" + option + "\" is unknown.";
|
|
messageHint + "option \"" + option + "\" is unknown.";
|
|
|
- this->SetError(error);
|
|
|
|
|
|
|
+ status.SetError(error);
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -84,7 +90,7 @@ bool cmMathCommand::HandleExprCommand(std::vector<std::string> const& args)
|
|
|
|
|
|
|
|
cmExprParserHelper helper;
|
|
cmExprParserHelper helper;
|
|
|
if (!helper.ParseString(expression.c_str(), 0)) {
|
|
if (!helper.ParseString(expression.c_str(), 0)) {
|
|
|
- this->SetError(helper.GetError());
|
|
|
|
|
|
|
+ status.SetError(helper.GetError());
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -104,9 +110,10 @@ bool cmMathCommand::HandleExprCommand(std::vector<std::string> const& args)
|
|
|
|
|
|
|
|
std::string const& w = helper.GetWarning();
|
|
std::string const& w = helper.GetWarning();
|
|
|
if (!w.empty()) {
|
|
if (!w.empty()) {
|
|
|
- this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, w);
|
|
|
|
|
|
|
+ status.GetMakefile().IssueMessage(MessageType::AUTHOR_WARNING, w);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- this->Makefile->AddDefinition(outputVariable, buffer);
|
|
|
|
|
|
|
+ status.GetMakefile().AddDefinition(outputVariable, buffer);
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
+}
|