diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-05-04 20:40:07 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-05-14 18:36:28 (GMT) |
commit | ed41a8e7b4cf665ebab8e4780f8b0b299113fd11 (patch) | |
tree | eeb53d0736527eb3a8b54040377ea1d746e01058 /Source | |
parent | 48a9e91b02090ba263cd46ef5c33ba3d2aa873ba (diff) | |
download | CMake-ed41a8e7b4cf665ebab8e4780f8b0b299113fd11.zip CMake-ed41a8e7b4cf665ebab8e4780f8b0b299113fd11.tar.gz CMake-ed41a8e7b4cf665ebab8e4780f8b0b299113fd11.tar.bz2 |
cmLocalGenerator: Port loops to cmState::Snapshot.
Make this code less dependent on being part of cmLocalGenerator,
where it doesn't really belong.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 1099f0f..5ef0a3b 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2853,15 +2853,15 @@ std::string cmLocalGenerator::Convert(RelativeRoot remote, //---------------------------------------------------------------------------- std::string cmLocalGenerator::FindRelativePathTopSource() { - cmLocalGenerator* gen = this; - std::vector<cmLocalGenerator*> gens; - gens.push_back(gen); + cmState::Snapshot snapshot = this->StateSnapshot; + std::vector<cmState::Snapshot> snapshots; + snapshots.push_back(snapshot); while (true) { - gen = gen->GetParent(); - if (gen) + snapshot = snapshot.GetParent(); + if (snapshot.IsValid()) { - gens.push_back(gen); + snapshots.push_back(snapshot); } else { @@ -2869,13 +2869,12 @@ std::string cmLocalGenerator::FindRelativePathTopSource() } } - std::string result = gens.front()->StateSnapshot.GetCurrentSourceDirectory(); + std::string result = snapshots.front().GetCurrentSourceDirectory(); - for (std::vector<cmLocalGenerator*>::const_iterator it = gens.begin() + 1; - it != gens.end(); ++it) + for (std::vector<cmState::Snapshot>::const_iterator it = + snapshots.begin() + 1; it != snapshots.end(); ++it) { - std::string currentSource = - (*it)->StateSnapshot.GetCurrentSourceDirectory(); + std::string currentSource = it->GetCurrentSourceDirectory(); if(cmSystemTools::IsSubDirectory(result, currentSource)) { result = currentSource; @@ -2888,15 +2887,15 @@ std::string cmLocalGenerator::FindRelativePathTopSource() //---------------------------------------------------------------------------- std::string cmLocalGenerator::FindRelativePathTopBinary() { - cmLocalGenerator* gen = this; - std::vector<cmLocalGenerator*> gens; - gens.push_back(gen); + cmState::Snapshot snapshot = this->StateSnapshot; + std::vector<cmState::Snapshot> snapshots; + snapshots.push_back(snapshot); while (true) { - gen = gen->GetParent(); - if (gen) + snapshot = snapshot.GetParent(); + if (snapshot.IsValid()) { - gens.push_back(gen); + snapshots.push_back(snapshot); } else { @@ -2904,13 +2903,12 @@ std::string cmLocalGenerator::FindRelativePathTopBinary() } } - std::string result = gens.front()->StateSnapshot.GetCurrentBinaryDirectory(); + std::string result = snapshots.front().GetCurrentBinaryDirectory(); - for (std::vector<cmLocalGenerator*>::const_iterator it = gens.begin() + 1; - it != gens.end(); ++it) + for (std::vector<cmState::Snapshot>::const_iterator it = + snapshots.begin() + 1; it != snapshots.end(); ++it) { - std::string currentBinary = - (*it)->StateSnapshot.GetCurrentBinaryDirectory(); + std::string currentBinary = it->GetCurrentBinaryDirectory(); if(cmSystemTools::IsSubDirectory(result, currentBinary)) { result = currentBinary; |