diff options
author | Brad King <brad.king@kitware.com> | 2022-07-20 19:52:45 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-07-25 17:51:43 (GMT) |
commit | f95a5832c7ce6e88bd623e818471fa8c23fa77f4 (patch) | |
tree | 59264f579af5b4c07ad21fe07c6101bf03088777 | |
parent | 9a7efb681331f77a3873bd9fb5694ad46338c0f7 (diff) | |
download | CMake-f95a5832c7ce6e88bd623e818471fa8c23fa77f4.zip CMake-f95a5832c7ce6e88bd623e818471fa8c23fa77f4.tar.gz CMake-f95a5832c7ce6e88bd623e818471fa8c23fa77f4.tar.bz2 |
cmArgumentParser: Drop unused keywordsMissingValue argument to Parse()
All clients have been converted to encoding this requirement in their
bindings.
-rw-r--r-- | Source/CTest/cmCTestHandlerCommand.cxx | 3 | ||||
-rw-r--r-- | Source/cmArgumentParser.cxx | 3 | ||||
-rw-r--r-- | Source/cmArgumentParser.h | 13 | ||||
-rw-r--r-- | Source/cmFileCommand.cxx | 5 | ||||
-rw-r--r-- | Tests/CMakeLib/testArgumentParser.cxx | 24 |
5 files changed, 13 insertions, 35 deletions
diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx index af365ad..528115e 100644 --- a/Source/CTest/cmCTestHandlerCommand.cxx +++ b/Source/CTest/cmCTestHandlerCommand.cxx @@ -83,8 +83,7 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args, // Process input arguments. std::vector<std::string> unparsedArguments; std::vector<cm::string_view> parsedKeywords; - this->Parse(args, &unparsedArguments, /*keywordsMissingValue=*/nullptr, - &parsedKeywords); + this->Parse(args, &unparsedArguments, &parsedKeywords); this->CheckArguments(); std::sort(parsedKeywords.begin(), parsedKeywords.end()); diff --git a/Source/cmArgumentParser.cxx b/Source/cmArgumentParser.cxx index fcced96..fafae13 100644 --- a/Source/cmArgumentParser.cxx +++ b/Source/cmArgumentParser.cxx @@ -113,9 +113,6 @@ void Instance::FinishKeyword() this->ParseResults->AddKeywordError(this->Keyword, " missing required value\n"); } - if (this->KeywordsMissingValue != nullptr) { - this->KeywordsMissingValue->emplace_back(this->Keyword); - } if (this->Bindings.KeywordMissingValue) { this->Bindings.KeywordMissingValue(*this, this->Keyword); } diff --git a/Source/cmArgumentParser.h b/Source/cmArgumentParser.h index ae3a000..70deaa6 100644 --- a/Source/cmArgumentParser.h +++ b/Source/cmArgumentParser.h @@ -115,13 +115,11 @@ class Instance public: Instance(ActionMap const& bindings, ParseResult* parseResult, std::vector<std::string>* unparsedArguments, - std::vector<cm::string_view>* keywordsMissingValue, std::vector<cm::string_view>* parsedKeywords, void* result = nullptr) : Bindings(bindings) , ParseResults(parseResult) , UnparsedArguments(unparsedArguments) - , KeywordsMissingValue(keywordsMissingValue) , ParsedKeywords(parsedKeywords) , Result(result) { @@ -157,7 +155,6 @@ private: ActionMap const& Bindings; ParseResult* ParseResults = nullptr; std::vector<std::string>* UnparsedArguments = nullptr; - std::vector<cm::string_view>* KeywordsMissingValue = nullptr; std::vector<cm::string_view>* ParsedKeywords = nullptr; void* Result = nullptr; @@ -193,25 +190,22 @@ public: template <typename Range> bool Parse(Result& result, Range const& args, std::vector<std::string>* unparsedArguments, - std::vector<cm::string_view>* keywordsMissingValue = nullptr, std::vector<cm::string_view>* parsedKeywords = nullptr) const { using ArgumentParser::AsParseResultPtr; ParseResult* parseResultPtr = AsParseResultPtr(result); Instance instance(this->Bindings, parseResultPtr, unparsedArguments, - keywordsMissingValue, parsedKeywords, &result); + parsedKeywords, &result); instance.Parse(args); return parseResultPtr ? static_cast<bool>(*parseResultPtr) : true; } template <typename Range> Result Parse(Range const& args, std::vector<std::string>* unparsedArguments, - std::vector<cm::string_view>* keywordsMissingValue = nullptr, std::vector<cm::string_view>* parsedKeywords = nullptr) const { Result result; - this->Parse(result, args, unparsedArguments, keywordsMissingValue, - parsedKeywords); + this->Parse(result, args, unparsedArguments, parsedKeywords); return result; } }; @@ -230,12 +224,11 @@ public: template <typename Range> ParseResult Parse( Range const& args, std::vector<std::string>* unparsedArguments, - std::vector<cm::string_view>* keywordsMissingValue = nullptr, std::vector<cm::string_view>* parsedKeywords = nullptr) const { ParseResult parseResult; Instance instance(this->Bindings, &parseResult, unparsedArguments, - keywordsMissingValue, parsedKeywords); + parsedKeywords); instance.Parse(args); return parseResult; } diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index c7ba424..987f40e 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2498,9 +2498,8 @@ bool HandleGenerateCommand(std::vector<std::string> const& args, std::vector<std::string> unparsedArguments; std::vector<cm::string_view> parsedKeywords; - Arguments const arguments = - parser.Parse(cmMakeRange(args).advance(1), &unparsedArguments, - /*keywordsMissingValue=*/nullptr, &parsedKeywords); + Arguments const arguments = parser.Parse( + cmMakeRange(args).advance(1), &unparsedArguments, &parsedKeywords); if (arguments.MaybeReportError(status.GetMakefile())) { return true; diff --git a/Tests/CMakeLib/testArgumentParser.cxx b/Tests/CMakeLib/testArgumentParser.cxx index f0ace50..9db7936 100644 --- a/Tests/CMakeLib/testArgumentParser.cxx +++ b/Tests/CMakeLib/testArgumentParser.cxx @@ -63,14 +63,10 @@ std::initializer_list<cm::string_view> const args = { }; bool verifyResult(Result const& result, - std::vector<std::string> const& unparsedArguments, - std::vector<cm::string_view> const& keywordsMissingValue) + std::vector<std::string> const& unparsedArguments) { static std::vector<std::string> const foobar = { "foo", "bar" }; static std::vector<std::string> const barfoo = { "bar", "foo" }; - static std::vector<cm::string_view> const missing = { "STRING_1"_s, - "LIST_1"_s, - "LIST_4"_s }; static std::map<cm::string_view, std::string> const keywordErrors = { { "STRING_1"_s, " missing required value\n" }, { "LIST_1"_s, " missing required value\n" }, @@ -117,7 +113,6 @@ bool verifyResult(Result const& result, ASSERT_TRUE(unparsedArguments.size() == 1); ASSERT_TRUE(unparsedArguments[0] == "bar"); - ASSERT_TRUE(keywordsMissingValue == missing); ASSERT_TRUE(result.GetKeywordErrors().size() == keywordErrors.size()); for (auto const& ke : result.GetKeywordErrors()) { @@ -133,7 +128,6 @@ bool testArgumentParserDynamic() { Result result; std::vector<std::string> unparsedArguments; - std::vector<cm::string_view> keywordsMissingValue; static_cast<ArgumentParser::ParseResult&>(result) = cmArgumentParser<void>{} @@ -153,9 +147,9 @@ bool testArgumentParserDynamic() .Bind("MULTI_2"_s, result.Multi2) .Bind("MULTI_3"_s, result.Multi3) .Bind("MULTI_4"_s, result.Multi4) - .Parse(args, &unparsedArguments, &keywordsMissingValue); + .Parse(args, &unparsedArguments); - return verifyResult(result, unparsedArguments, keywordsMissingValue); + return verifyResult(result, unparsedArguments); } static auto const parserStatic = // @@ -181,20 +175,16 @@ static auto const parserStatic = // bool testArgumentParserStatic() { std::vector<std::string> unparsedArguments; - std::vector<cm::string_view> keywordsMissingValue; - Result const result = - parserStatic.Parse(args, &unparsedArguments, &keywordsMissingValue); - return verifyResult(result, unparsedArguments, keywordsMissingValue); + Result const result = parserStatic.Parse(args, &unparsedArguments); + return verifyResult(result, unparsedArguments); } bool testArgumentParserStaticBool() { std::vector<std::string> unparsedArguments; - std::vector<cm::string_view> keywordsMissingValue; Result result; - ASSERT_TRUE(parserStatic.Parse(result, args, &unparsedArguments, - &keywordsMissingValue) == false); - return verifyResult(result, unparsedArguments, keywordsMissingValue); + ASSERT_TRUE(parserStatic.Parse(result, args, &unparsedArguments) == false); + return verifyResult(result, unparsedArguments); } } // namespace |