summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-03-27 11:49:23 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-03-27 11:49:30 (GMT)
commit7e3d81b1df9e2c192585d83300344546439e50bd (patch)
treebefbf08daebf622c4b2bf4f3ac91afdc8a4459d6
parentae96b772fa8c957dfc4cbb334f45874bd4043966 (diff)
parenta7f2ff16a48486ec0ef5a1a2d73e13cf4106a50e (diff)
downloadCMake-7e3d81b1df9e2c192585d83300344546439e50bd.zip
CMake-7e3d81b1df9e2c192585d83300344546439e50bd.tar.gz
CMake-7e3d81b1df9e2c192585d83300344546439e50bd.tar.bz2
Merge topic 'cmprop-state'
a7f2ff16a4 cmState::GetCacheEntryProperty: return cmProp Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4522
-rw-r--r--Source/CursesDialog/cmCursesCacheEntryComposite.cxx4
-rw-r--r--Source/CursesDialog/cmCursesMainForm.cxx9
-rw-r--r--Source/QtDialog/QCMake.cxx11
-rw-r--r--Source/cmFileAPICache.cxx3
-rw-r--r--Source/cmFindBase.cxx4
-rw-r--r--Source/cmGetPropertyCommand.cxx5
-rw-r--r--Source/cmServerProtocol.cxx2
-rw-r--r--Source/cmState.cxx7
-rw-r--r--Source/cmState.h4
-rw-r--r--Source/cmake.cxx4
-rw-r--r--Source/cmakemain.cxx8
11 files changed, 32 insertions, 29 deletions
diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx
index 9a0d966..9250fbc 100644
--- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx
+++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx
@@ -71,11 +71,11 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
break;
}
case cmStateEnums::STRING: {
- const char* stringsProp = state->GetCacheEntryProperty(key, "STRINGS");
+ cmProp stringsProp = state->GetCacheEntryProperty(key, "STRINGS");
if (stringsProp) {
auto ow =
cm::make_unique<cmCursesOptionsWidget>(this->EntryWidth, 1, 1, 1);
- for (std::string const& opt : cmExpandedList(stringsProp)) {
+ for (std::string const& opt : cmExpandedList(*stringsProp)) {
ow->AddOption(opt);
}
ow->SetOption(*value);
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index 9670595..7752a68 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -407,9 +407,10 @@ void cmCursesMainForm::UpdateStatusBar(cm::optional<std::string> message)
auto cmakeState = this->CMakeInstance->GetState();
cmProp existingValue = cmakeState->GetCacheEntryValue(labelValue);
if (existingValue) {
- auto help = cmakeState->GetCacheEntryProperty(labelValue, "HELPSTRING");
+ cmProp help =
+ cmakeState->GetCacheEntryProperty(labelValue, "HELPSTRING");
if (help) {
- bar += help;
+ bar += *help;
}
}
}
@@ -802,7 +803,7 @@ void cmCursesMainForm::HandleInput()
cmCursesWidget* lbl = reinterpret_cast<cmCursesWidget*>(
field_userptr(this->Fields[findex - 2]));
const char* curField = lbl->GetValue();
- const char* helpString = nullptr;
+ cmProp helpString = nullptr;
cmProp existingValue =
this->CMakeInstance->GetState()->GetCacheEntryValue(curField);
@@ -813,7 +814,7 @@ void cmCursesMainForm::HandleInput()
if (helpString) {
this->HelpMessage[1] =
cmStrCat("Current option is: ", curField, '\n',
- "Help string for this option is: ", helpString, '\n');
+ "Help string for this option is: ", *helpString, '\n');
} else {
this->HelpMessage[1] = "";
}
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index 2543215..776af81 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -306,8 +306,9 @@ QCMakePropertyList QCMake::properties() const
QCMakeProperty prop;
prop.Key = QString::fromLocal8Bit(key.c_str());
- prop.Help =
- QString::fromLocal8Bit(state->GetCacheEntryProperty(key, "HELPSTRING"));
+ if (cmProp hs = state->GetCacheEntryProperty(key, "HELPSTRING")) {
+ prop.Help = QString::fromLocal8Bit(hs->c_str());
+ }
prop.Value = QString::fromLocal8Bit(cachedValue->c_str());
prop.Advanced = state->GetCacheEntryPropertyAsBool(key, "ADVANCED");
if (t == cmStateEnums::BOOL) {
@@ -319,10 +320,10 @@ QCMakePropertyList QCMake::properties() const
prop.Type = QCMakeProperty::FILEPATH;
} else if (t == cmStateEnums::STRING) {
prop.Type = QCMakeProperty::STRING;
- const char* stringsProperty =
- state->GetCacheEntryProperty(key, "STRINGS");
+ cmProp stringsProperty = state->GetCacheEntryProperty(key, "STRINGS");
if (stringsProperty) {
- prop.Strings = QString::fromLocal8Bit(stringsProperty).split(";");
+ prop.Strings =
+ QString::fromLocal8Bit(stringsProperty->c_str()).split(";");
}
}
diff --git a/Source/cmFileAPICache.cxx b/Source/cmFileAPICache.cxx
index 639df52..5d2ddf9 100644
--- a/Source/cmFileAPICache.cxx
+++ b/Source/cmFileAPICache.cxx
@@ -94,7 +94,8 @@ Json::Value Cache::DumpEntryProperty(std::string const& name,
{
Json::Value property = Json::objectValue;
property["name"] = prop;
- property["value"] = this->State->GetCacheEntryProperty(name, prop);
+ cmProp p = this->State->GetCacheEntryProperty(name, prop);
+ property["value"] = p ? *p : "";
return property;
}
}
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
index 4d627bd..b5553b8 100644
--- a/Source/cmFindBase.cxx
+++ b/Source/cmFindBase.cxx
@@ -312,9 +312,9 @@ bool cmFindBase::CheckForVariableInCache()
return true;
}
if (cached) {
- const char* hs =
+ cmProp hs =
state->GetCacheEntryProperty(this->VariableName, "HELPSTRING");
- this->VariableDocumentation = hs ? hs : "(none)";
+ this->VariableDocumentation = hs ? *hs : "(none)";
}
}
return false;
diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx
index 2c3adde..9623514 100644
--- a/Source/cmGetPropertyCommand.cxx
+++ b/Source/cmGetPropertyCommand.cxx
@@ -387,12 +387,13 @@ bool HandleCacheMode(cmExecutionStatus& status, const std::string& name,
return false;
}
- const char* value = nullptr;
+ cmProp value = nullptr;
if (status.GetMakefile().GetState()->GetCacheEntryValue(name)) {
value = status.GetMakefile().GetState()->GetCacheEntryProperty(
name, propertyName);
}
- StoreResult(infoType, status.GetMakefile(), variable, value);
+ StoreResult(infoType, status.GetMakefile(), variable,
+ value ? value->c_str() : nullptr);
return true;
}
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx
index 83a7f7b..c5f3463 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -450,7 +450,7 @@ cmServerResponse cmServerProtocol1::ProcessCache(
bool haveProperties = false;
for (auto const& prop : state->GetCacheEntryPropertyList(key)) {
haveProperties = true;
- props[prop] = state->GetCacheEntryProperty(key, prop);
+ props[prop] = *state->GetCacheEntryProperty(key, prop);
}
if (haveProperties) {
entry[kPROPERTIES_KEY] = props;
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 6d95c7a..3f692d3 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -206,15 +206,14 @@ std::vector<std::string> cmState::GetCacheEntryPropertyList(
return it.GetPropertyList();
}
-const char* cmState::GetCacheEntryProperty(std::string const& key,
- std::string const& propertyName)
+cmProp cmState::GetCacheEntryProperty(std::string const& key,
+ std::string const& propertyName)
{
cmCacheManager::CacheIterator it = this->CacheManager->GetCacheIterator(key);
if (!it.PropertyExists(propertyName)) {
return nullptr;
}
- cmProp retVal = it.GetProperty(propertyName);
- return retVal ? retVal->c_str() : nullptr;
+ return it.GetProperty(propertyName);
}
bool cmState::GetCacheEntryPropertyAsBool(std::string const& key,
diff --git a/Source/cmState.h b/Source/cmState.h
index 89400d6..9d1b3c7 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -105,8 +105,8 @@ public:
void SetCacheEntryBoolProperty(std::string const& key,
std::string const& propertyName, bool value);
std::vector<std::string> GetCacheEntryPropertyList(std::string const& key);
- const char* GetCacheEntryProperty(std::string const& key,
- std::string const& propertyName);
+ cmProp GetCacheEntryProperty(std::string const& key,
+ std::string const& propertyName);
bool GetCacheEntryPropertyAsBool(std::string const& key,
std::string const& propertyName);
void AppendCacheEntryProperty(std::string const& key,
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 59e7a37..0b7c4bc 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -1410,9 +1410,9 @@ int cmake::HandleDeleteCacheVariables(const std::string& var)
cmProp existingValue = this->State->GetCacheEntryValue(save.key);
if (existingValue) {
save.type = this->State->GetCacheEntryType(save.key);
- if (const char* help =
+ if (cmProp help =
this->State->GetCacheEntryProperty(save.key, "HELPSTRING")) {
- save.help = help;
+ save.help = *help;
}
}
saved.push_back(std::move(save));
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 0e99117..84d0538 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -292,13 +292,13 @@ int do_cmake(int ac, char const* const* av)
cmStateEnums::CacheEntryType t = cm.GetState()->GetCacheEntryType(k);
if (t != cmStateEnums::INTERNAL && t != cmStateEnums::STATIC &&
t != cmStateEnums::UNINITIALIZED) {
- const char* advancedProp =
+ cmProp advancedProp =
cm.GetState()->GetCacheEntryProperty(k, "ADVANCED");
if (list_all_cached || !advancedProp) {
if (list_help) {
- std::cout << "// "
- << cm.GetState()->GetCacheEntryProperty(k, "HELPSTRING")
- << std::endl;
+ cmProp help =
+ cm.GetState()->GetCacheEntryProperty(k, "HELPSTRING");
+ std::cout << "// " << (help ? *help : "") << std::endl;
}
std::cout << k << ":" << cmState::CacheEntryTypeToString(t) << "="
<< cm.GetState()->GetSafeCacheEntryValue(k) << std::endl;