diff options
author | Brad King <brad.king@kitware.com> | 2020-03-16 15:40:25 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-03-16 15:40:59 (GMT) |
commit | 6f4b1ba96d724cbbc1642a7beb6ae9ec2b51d3bc (patch) | |
tree | 8cb5a17b019716f1818fb62ec559fbd2fd19b404 /Source | |
parent | c6def2107f7a07e5a184935543963cfd326c8195 (diff) | |
parent | 73d52a862bfe73f591458b47a016b7400057ecab (diff) | |
download | CMake-6f4b1ba96d724cbbc1642a7beb6ae9ec2b51d3bc.zip CMake-6f4b1ba96d724cbbc1642a7beb6ae9ec2b51d3bc.tar.gz CMake-6f4b1ba96d724cbbc1642a7beb6ae9ec2b51d3bc.tar.bz2 |
Merge topic 'define-property'
73d52a862b cmPropertyDefinition: Construct directly in defined state
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4470
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCPluginAPI.cxx | 5 | ||||
-rw-r--r-- | Source/cmDefinePropertyCommand.cxx | 2 | ||||
-rw-r--r-- | Source/cmPropertyDefinition.cxx | 26 | ||||
-rw-r--r-- | Source/cmPropertyDefinition.h | 11 | ||||
-rw-r--r-- | Source/cmPropertyDefinitionMap.cxx | 18 | ||||
-rw-r--r-- | Source/cmPropertyDefinitionMap.h | 4 | ||||
-rw-r--r-- | Source/cmState.cxx | 4 | ||||
-rw-r--r-- | Source/cmState.h | 4 |
8 files changed, 35 insertions, 39 deletions
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index f6c1e47..80441be 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -775,8 +775,9 @@ void CCONV DefineSourceFileProperty(void* arg, const char* name, const char* longDocs, int chained) { cmMakefile* mf = static_cast<cmMakefile*>(arg); - mf->GetState()->DefineProperty(name, cmProperty::SOURCE_FILE, briefDocs, - longDocs, chained != 0); + mf->GetState()->DefineProperty(name, cmProperty::SOURCE_FILE, + briefDocs ? briefDocs : "", + longDocs ? longDocs : "", chained != 0); } } // close the extern "C" scope diff --git a/Source/cmDefinePropertyCommand.cxx b/Source/cmDefinePropertyCommand.cxx index f4e4fda..4e2d9b0 100644 --- a/Source/cmDefinePropertyCommand.cxx +++ b/Source/cmDefinePropertyCommand.cxx @@ -95,7 +95,7 @@ bool cmDefinePropertyCommand(std::vector<std::string> const& args, // Actually define the property. status.GetMakefile().GetState()->DefineProperty( - PropertyName, scope, BriefDocs.c_str(), FullDocs.c_str(), inherited); + PropertyName, scope, BriefDocs, FullDocs, inherited); return true; } diff --git a/Source/cmPropertyDefinition.cxx b/Source/cmPropertyDefinition.cxx index 6a3174c..c8efaf6 100644 --- a/Source/cmPropertyDefinition.cxx +++ b/Source/cmPropertyDefinition.cxx @@ -2,19 +2,17 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmPropertyDefinition.h" -void cmPropertyDefinition::DefineProperty(const std::string& name, - cmProperty::ScopeType scope, - const char* shortDescription, - const char* fullDescription, - bool chain) +#include <utility> + +cmPropertyDefinition::cmPropertyDefinition(std::string name, + cmProperty::ScopeType scope, + std::string shortDescription, + std::string fullDescription, + bool chain) + : Name(std::move(name)) + , ShortDescription(std::move(shortDescription)) + , FullDescription(std::move(fullDescription)) + , Scope(scope) + , Chained(chain) { - this->Name = name; - this->Scope = scope; - this->Chained = chain; - if (shortDescription) { - this->ShortDescription = shortDescription; - } - if (fullDescription) { - this->FullDescription = fullDescription; - } } diff --git a/Source/cmPropertyDefinition.h b/Source/cmPropertyDefinition.h index 0d68c32..d2e4467 100644 --- a/Source/cmPropertyDefinition.h +++ b/Source/cmPropertyDefinition.h @@ -21,13 +21,10 @@ class cmPropertyDefinition { public: - /// Define this property - void DefineProperty(const std::string& name, cmProperty::ScopeType scope, - const char* ShortDescription, - const char* FullDescription, bool chained); - - /// Default constructor - cmPropertyDefinition() { this->Chained = false; } + /// Constructor + cmPropertyDefinition(std::string name, cmProperty::ScopeType scope, + std::string ShortDescription, + std::string FullDescription, bool chained = false); /// Is the property chained? bool IsChained() const { return this->Chained; } diff --git a/Source/cmPropertyDefinitionMap.cxx b/Source/cmPropertyDefinitionMap.cxx index f752ed7..614d5a4 100644 --- a/Source/cmPropertyDefinitionMap.cxx +++ b/Source/cmPropertyDefinitionMap.cxx @@ -2,20 +2,20 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmPropertyDefinitionMap.h" +#include <tuple> #include <utility> -void cmPropertyDefinitionMap::DefineProperty(const std::string& name, - cmProperty::ScopeType scope, - const char* ShortDescription, - const char* FullDescription, - bool chain) +void cmPropertyDefinitionMap::DefineProperty( + const std::string& name, cmProperty::ScopeType scope, + const std::string& ShortDescription, const std::string& FullDescription, + bool chain) { auto it = this->find(name); - cmPropertyDefinition* prop; if (it == this->end()) { - prop = &(*this)[name]; - prop->DefineProperty(name, scope, ShortDescription, FullDescription, - chain); + // try_emplace() since C++17 + this->emplace(std::piecewise_construct, std::forward_as_tuple(name), + std::forward_as_tuple(name, scope, ShortDescription, + FullDescription, chain)); } } diff --git a/Source/cmPropertyDefinitionMap.h b/Source/cmPropertyDefinitionMap.h index 8ec7910..2ae6efb 100644 --- a/Source/cmPropertyDefinitionMap.h +++ b/Source/cmPropertyDefinitionMap.h @@ -17,8 +17,8 @@ class cmPropertyDefinitionMap public: // define the property void DefineProperty(const std::string& name, cmProperty::ScopeType scope, - const char* ShortDescription, - const char* FullDescription, bool chain); + const std::string& ShortDescription, + const std::string& FullDescription, bool chain); // has a named property been defined bool IsPropertyDefined(const std::string& name) const; diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 9fc7615..51e4976 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -335,8 +335,8 @@ cmStateSnapshot cmState::Reset() void cmState::DefineProperty(const std::string& name, cmProperty::ScopeType scope, - const char* ShortDescription, - const char* FullDescription, bool chained) + const std::string& ShortDescription, + const std::string& FullDescription, bool chained) { this->PropertyDefinitions[scope].DefineProperty( name, scope, ShortDescription, FullDescription, chained); diff --git a/Source/cmState.h b/Source/cmState.h index 6ee2b0c..460c6bb 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -121,8 +121,8 @@ public: cmStateSnapshot Reset(); // Define a property void DefineProperty(const std::string& name, cmProperty::ScopeType scope, - const char* ShortDescription, - const char* FullDescription, bool chain = false); + const std::string& ShortDescription, + const std::string& FullDescription, bool chain = false); // get property definition cmPropertyDefinition const* GetPropertyDefinition( |