From 79a309d786abefef1a4f354c2973a14cba882850 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 10 Oct 2015 15:42:02 +0200 Subject: [PATCH] cmState: Port away from cmake instance. --- Source/cmState.cxx | 47 +++++++++++++++++++++++----------------------- Source/cmState.h | 5 +++-- Source/cmake.cxx | 5 +---- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/Source/cmState.cxx b/Source/cmState.cxx index c5bbf42cc..72c7330f9 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -82,9 +82,8 @@ struct cmState::BuildsystemDirectoryStateType std::vector Children; }; -cmState::cmState(cmake* cm) - : CMakeInstance(cm), - IsInTryCompile(false), +cmState::cmState() + : IsInTryCompile(false), WindowsShell(false), WindowsVSIDE(false), WatcomWMake(false), @@ -92,10 +91,12 @@ cmState::cmState(cmake* cm) NMake(false), MSYSShell(false) { + this->CacheManager = new cmCacheManager; } cmState::~cmState() { + delete this->CacheManager; cmDeleteAll(this->Commands); } @@ -151,26 +152,26 @@ bool cmState::LoadCache(const std::string& path, bool internal, std::set& excludes, std::set& includes) { - return this->CMakeInstance->GetCacheManager()->LoadCache(path, internal, - excludes, includes); + return this->CacheManager->LoadCache(path, internal, + excludes, includes); } bool cmState::SaveCache(const std::string& path) { - return this->CMakeInstance->GetCacheManager()->SaveCache(path); + return this->CacheManager->SaveCache(path); } bool cmState::DeleteCache(const std::string& path) { - return this->CMakeInstance->GetCacheManager()->DeleteCache(path); + return this->CacheManager->DeleteCache(path); } std::vector cmState::GetCacheEntryKeys() const { std::vector definitions; - definitions.reserve(this->CMakeInstance->GetCacheManager()->GetSize()); + definitions.reserve(this->CacheManager->GetSize()); cmCacheManager::CacheIterator cit = - this->CMakeInstance->GetCacheManager()->GetCacheIterator(); + this->CacheManager->GetCacheIterator(); for ( cit.Begin(); !cit.IsAtEnd(); cit.Next() ) { definitions.push_back(cit.GetName()); @@ -180,7 +181,7 @@ std::vector cmState::GetCacheEntryKeys() const const char* cmState::GetCacheEntryValue(std::string const& key) const { - cmCacheManager::CacheEntry* e = this->CMakeInstance->GetCacheManager() + cmCacheManager::CacheEntry* e = this->CacheManager ->GetCacheEntry(key); if (!e) { @@ -192,21 +193,21 @@ const char* cmState::GetCacheEntryValue(std::string const& key) const const char* cmState::GetInitializedCacheValue(std::string const& key) const { - return this->CMakeInstance->GetCacheManager()->GetInitializedCacheValue(key); + return this->CacheManager->GetInitializedCacheValue(key); } cmState::CacheEntryType cmState::GetCacheEntryType(std::string const& key) const { cmCacheManager::CacheIterator it = - this->CMakeInstance->GetCacheManager()->GetCacheIterator(key.c_str()); + this->CacheManager->GetCacheIterator(key.c_str()); return it.GetType(); } void cmState::SetCacheEntryValue(std::string const& key, std::string const& value) { - this->CMakeInstance->GetCacheManager()->SetCacheEntryValue(key, value); + this->CacheManager->SetCacheEntryValue(key, value); } void cmState::SetCacheEntryProperty(std::string const& key, @@ -214,7 +215,7 @@ void cmState::SetCacheEntryProperty(std::string const& key, std::string const& value) { cmCacheManager::CacheIterator it = - this->CMakeInstance->GetCacheManager()->GetCacheIterator(key.c_str()); + this->CacheManager->GetCacheIterator(key.c_str()); it.SetProperty(propertyName, value.c_str()); } @@ -223,14 +224,14 @@ void cmState::SetCacheEntryBoolProperty(std::string const& key, bool value) { cmCacheManager::CacheIterator it = - this->CMakeInstance->GetCacheManager()->GetCacheIterator(key.c_str()); + this->CacheManager->GetCacheIterator(key.c_str()); it.SetProperty(propertyName, value); } const char* cmState::GetCacheEntryProperty(std::string const& key, std::string const& propertyName) { - cmCacheManager::CacheIterator it = this->CMakeInstance->GetCacheManager() + cmCacheManager::CacheIterator it = this->CacheManager ->GetCacheIterator(key.c_str()); if (!it.PropertyExists(propertyName)) { @@ -242,7 +243,7 @@ const char* cmState::GetCacheEntryProperty(std::string const& key, bool cmState::GetCacheEntryPropertyAsBool(std::string const& key, std::string const& propertyName) { - return this->CMakeInstance->GetCacheManager() + return this->CacheManager ->GetCacheIterator(key.c_str()).GetPropertyAsBool(propertyName); } @@ -250,13 +251,13 @@ void cmState::AddCacheEntry(const std::string& key, const char* value, const char* helpString, cmState::CacheEntryType type) { - this->CMakeInstance->GetCacheManager()->AddCacheEntry(key, value, + this->CacheManager->AddCacheEntry(key, value, helpString, type); } void cmState::RemoveCacheEntry(std::string const& key) { - this->CMakeInstance->GetCacheManager()->RemoveCacheEntry(key); + this->CacheManager->RemoveCacheEntry(key); } void cmState::AppendCacheEntryProperty(const std::string& key, @@ -264,7 +265,7 @@ void cmState::AppendCacheEntryProperty(const std::string& key, const std::string& value, bool asString) { - this->CMakeInstance->GetCacheManager() + this->CacheManager ->GetCacheIterator(key.c_str()).AppendProperty(property, value.c_str(), asString); @@ -273,7 +274,7 @@ void cmState::AppendCacheEntryProperty(const std::string& key, void cmState::RemoveCacheEntryProperty(std::string const& key, std::string const& propertyName) { - this->CMakeInstance->GetCacheManager() + this->CacheManager ->GetCacheIterator(key.c_str()).SetProperty(propertyName, (void*)0); } @@ -679,12 +680,12 @@ bool cmState::UseMSYSShell() const unsigned int cmState::GetCacheMajorVersion() const { - return this->CMakeInstance->GetCacheManager()->GetCacheMajorVersion(); + return this->CacheManager->GetCacheMajorVersion(); } unsigned int cmState::GetCacheMinorVersion() const { - return this->CMakeInstance->GetCacheManager()->GetCacheMinorVersion(); + return this->CacheManager->GetCacheMinorVersion(); } const char* cmState::GetBinaryDirectory() const diff --git a/Source/cmState.h b/Source/cmState.h index fbc9275de..2f66f7f8e 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -23,6 +23,7 @@ class cmake; class cmCommand; class cmDefinitions; class cmListFileBacktrace; +class cmCacheManager; class cmState { @@ -32,7 +33,7 @@ class cmState typedef cmLinkedTree::iterator PositionType; friend class Snapshot; public: - cmState(cmake* cm); + cmState(); ~cmState(); enum SnapshotType @@ -320,7 +321,7 @@ private: std::vector EnabledLanguages; std::map Commands; cmPropertyMap GlobalProperties; - cmake* CMakeInstance; + cmCacheManager* CacheManager; cmLinkedTree BuildsystemDirectory; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index b1c270919..6846f1b52 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -10,7 +10,6 @@ See the License for more information. ============================================================================*/ #include "cmake.h" -#include "cmCacheManager.h" #include "cmMakefile.h" #include "cmLocalGenerator.h" #include "cmExternalMakefileProjectGenerator.h" @@ -135,7 +134,7 @@ cmake::cmake() this->ClearBuildSystem = false; this->FileComparison = new cmFileTimeComparison; - this->State = new cmState(this); + this->State = new cmState; this->CurrentSnapshot = this->State->CreateBaseSnapshot(); #ifdef __APPLE__ @@ -151,7 +150,6 @@ cmake::cmake() #endif this->Verbose = false; - this->CacheManager = new cmCacheManager; this->GlobalGenerator = 0; this->ProgressCallback = 0; this->ProgressCallbackClientData = 0; @@ -171,7 +169,6 @@ cmake::cmake() cmake::~cmake() { - delete this->CacheManager; delete this->State; if (this->GlobalGenerator) {