diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2021-08-09 14:37:14 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2021-08-09 14:37:14 (GMT) |
commit | 97ed474431426a50e6080a1cef8098fce297a940 (patch) | |
tree | fca450c5d1c37a8066c826b58b71bde6f6156885 | |
parent | 7e3250da2fa0155a8c83b3aadef0407a701f2953 (diff) | |
download | CMake-97ed474431426a50e6080a1cef8098fce297a940.zip CMake-97ed474431426a50e6080a1cef8098fce297a940.tar.gz CMake-97ed474431426a50e6080a1cef8098fce297a940.tar.bz2 |
Refactor: cmTest::GetProperty returns cmProp
-rw-r--r-- | Source/cmGetPropertyCommand.cxx | 19 | ||||
-rw-r--r-- | Source/cmGetTestPropertyCommand.cxx | 5 | ||||
-rw-r--r-- | Source/cmTest.cxx | 6 | ||||
-rw-r--r-- | Source/cmTest.h | 3 |
4 files changed, 19 insertions, 14 deletions
diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index cb657f9..bb3a40b 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -268,6 +268,11 @@ bool StoreResult(OutType infoType, cmMakefile& makefile, } return true; } +bool StoreResult(OutType infoType, cmMakefile& makefile, + const std::string& variable, cmProp value) +{ + return StoreResult(infoType, makefile, variable, value.GetCStr()); +} bool HandleGlobalMode(cmExecutionStatus& status, const std::string& name, OutType infoType, const std::string& variable, @@ -280,9 +285,8 @@ bool HandleGlobalMode(cmExecutionStatus& status, const std::string& name, // Get the property. cmake* cm = status.GetMakefile().GetCMakeInstance(); - return StoreResult( - infoType, status.GetMakefile(), variable, - cmToCStr(cm->GetState()->GetGlobalProperty(propertyName))); + return StoreResult(infoType, status.GetMakefile(), variable, + cm->GetState()->GetGlobalProperty(propertyName)); } bool HandleDirectoryMode(cmExecutionStatus& status, const std::string& name, @@ -329,7 +333,7 @@ bool HandleDirectoryMode(cmExecutionStatus& status, const std::string& name, // Get the property. return StoreResult(infoType, status.GetMakefile(), variable, - cmToCStr(mf->GetProperty(propertyName))); + mf->GetProperty(propertyName)); } bool HandleTargetMode(cmExecutionStatus& status, const std::string& name, @@ -365,8 +369,7 @@ bool HandleTargetMode(cmExecutionStatus& status, const std::string& name, if (!prop) { prop = target->GetProperty(propertyName); } - return StoreResult(infoType, status.GetMakefile(), variable, - cmToCStr(prop)); + return StoreResult(infoType, status.GetMakefile(), variable, prop); } status.SetError(cmStrCat("could not find TARGET ", name, ". Perhaps it has not yet been created.")); @@ -391,7 +394,7 @@ bool HandleSourceMode(cmExecutionStatus& status, const std::string& name, if (cmSourceFile* sf = directory_makefile.GetOrCreateSource(source_file_absolute_path)) { return StoreResult(infoType, status.GetMakefile(), variable, - cmToCStr(sf->GetPropertyForUser(propertyName))); + sf->GetPropertyForUser(propertyName)); } status.SetError( cmStrCat("given SOURCE name that could not be found or created: ", @@ -447,7 +450,7 @@ bool HandleCacheMode(cmExecutionStatus& status, const std::string& name, value = status.GetMakefile().GetState()->GetCacheEntryProperty( name, propertyName); } - StoreResult(infoType, status.GetMakefile(), variable, cmToCStr(value)); + StoreResult(infoType, status.GetMakefile(), variable, value); return true; } diff --git a/Source/cmGetTestPropertyCommand.cxx b/Source/cmGetTestPropertyCommand.cxx index cf8c1d5..077353e 100644 --- a/Source/cmGetTestPropertyCommand.cxx +++ b/Source/cmGetTestPropertyCommand.cxx @@ -4,6 +4,7 @@ #include "cmExecutionStatus.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmTest.h" bool cmGetTestPropertyCommand(std::vector<std::string> const& args, @@ -19,12 +20,12 @@ bool cmGetTestPropertyCommand(std::vector<std::string> const& args, cmMakefile& mf = status.GetMakefile(); cmTest* test = mf.GetTest(testName); if (test) { - const char* prop = nullptr; + cmProp prop; if (!args[1].empty()) { prop = test->GetProperty(args[1]); } if (prop) { - mf.AddDefinition(var, prop); + mf.AddDefinition(var, prop->c_str()); return true; } } diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx index a26bef3..5bc10c2 100644 --- a/Source/cmTest.cxx +++ b/Source/cmTest.cxx @@ -32,7 +32,7 @@ void cmTest::SetCommand(std::vector<std::string> const& command) this->Command = command; } -const char* cmTest::GetProperty(const std::string& prop) const +cmProp cmTest::GetProperty(const std::string& prop) const { cmProp retVal = this->Properties.GetPropertyValue(prop); if (!retVal) { @@ -40,12 +40,12 @@ const char* cmTest::GetProperty(const std::string& prop) const this->Makefile->GetState()->IsPropertyChained(prop, cmProperty::TEST); if (chain) { if (cmProp p = this->Makefile->GetProperty(prop, chain)) { - return p->c_str(); + return p; } } return nullptr; } - return retVal->c_str(); + return retVal; } bool cmTest::GetPropertyAsBool(const std::string& prop) const diff --git a/Source/cmTest.h b/Source/cmTest.h index f33b7e2..63e5e87 100644 --- a/Source/cmTest.h +++ b/Source/cmTest.h @@ -8,6 +8,7 @@ #include <vector> #include "cmListFileCache.h" +#include "cmProperty.h" #include "cmPropertyMap.h" class cmMakefile; @@ -36,7 +37,7 @@ public: void SetProperty(const std::string& prop, const char* value); void AppendProperty(const std::string& prop, const std::string& value, bool asString = false); - const char* GetProperty(const std::string& prop) const; + cmProp GetProperty(const std::string& prop) const; bool GetPropertyAsBool(const std::string& prop) const; cmPropertyMap& GetProperties() { return this->Properties; } |