From 4c1cdfd8f09182d8a6c87772b7fc0946c691e18b Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Tue, 10 Aug 2021 01:04:32 +0300 Subject: [PATCH] Refactor: Keep `cmWhileFunctionBlocker` members private Particularly `Args`. --- Source/cmWhileCommand.cxx | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 1285baf3b6..7d9eec0ff8 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -23,7 +23,7 @@ class cmWhileFunctionBlocker : public cmFunctionBlocker { public: - cmWhileFunctionBlocker(cmMakefile* mf); + cmWhileFunctionBlocker(cmMakefile* mf, std::vector args); ~cmWhileFunctionBlocker() override; cm::string_view StartCommandName() const override { return "while"_s; } @@ -35,14 +35,15 @@ public: bool Replay(std::vector functions, cmExecutionStatus& inStatus) override; - std::vector Args; - private: cmMakefile* Makefile; + std::vector Args; }; -cmWhileFunctionBlocker::cmWhileFunctionBlocker(cmMakefile* mf) - : Makefile(mf) +cmWhileFunctionBlocker::cmWhileFunctionBlocker( + cmMakefile* const mf, std::vector args) + : Makefile{ mf } + , Args{ std::move(args) } { this->Makefile->PushLoopBlock(); } @@ -132,11 +133,9 @@ bool cmWhileCommand(std::vector const& args, } // create a function blocker - { - auto& makefile = status.GetMakefile(); - auto fb = cm::make_unique(&makefile); - fb->Args = args; - makefile.AddFunctionBlocker(std::move(fb)); - } + auto& makefile = status.GetMakefile(); + makefile.AddFunctionBlocker( + cm::make_unique(&makefile, args)); + return true; }