Autogen: Add cmQtAutogenGlobalInitializer::Keywords class

The new `cmQtAutogenGlobalInitializer::Keywords` class instance is bound to
the lifetime of the `cmQtAutogenGlobalInitializer` instance.  Global static
const strings would be allocated at program start and deallocated at program
end.  Keeping keyword strings alive only in the context where they're
needed helps to reduce the memory footprint.
This commit is contained in:
Sebastian Holtermann
2019-04-02 18:53:34 +02:00
parent 78eccc7836
commit 5431395d68
2 changed files with 22 additions and 0 deletions

View File

@@ -20,6 +20,13 @@
#include <memory>
#include <utility>
cmQtAutoGenGlobalInitializer::Keywords::Keywords()
: AUTOMOC("AUTOMOC")
, AUTOUIC("AUTOUIC")
, AUTORCC("AUTORCC")
{
}
cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer(
std::vector<cmLocalGenerator*> const& localGenerators)
{

View File

@@ -17,11 +17,25 @@ class cmQtAutoGenInitializer;
/// @brief Initializes the QtAutoGen generators
class cmQtAutoGenGlobalInitializer
{
public:
/// @brief Collection of QtAutogen related keywords
class Keywords
{
public:
Keywords();
std::string AUTOMOC;
std::string AUTOUIC;
std::string AUTORCC;
};
public:
cmQtAutoGenGlobalInitializer(
std::vector<cmLocalGenerator*> const& localGenerators);
~cmQtAutoGenGlobalInitializer();
Keywords const* kw() const { return Keywords_.get(); };
bool generate();
private:
@@ -48,6 +62,7 @@ private:
std::map<cmLocalGenerator*, std::string> GlobalAutoGenTargets_;
std::map<cmLocalGenerator*, std::string> GlobalAutoRccTargets_;
std::unordered_map<std::string, std::string> ExecutableTestOutputs_;
std::unique_ptr<Keywords> Keywords_;
};
#endif