diff --git a/Source/cmState.cxx b/Source/cmState.cxx index c6fb2998e..4691a00de 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -18,6 +18,12 @@ #include +struct cmState::SnapshotDataType +{ + cmState::PositionType DirectoryParent; + cmState::SnapshotType SnapshotType; +}; + cmState::cmState(cmake* cm) : CMakeInstance(cm), IsInTryCompile(false), @@ -202,7 +208,7 @@ void cmState::Reset() assert(this->Locations.size() > 0); assert(this->OutputLocations.size() > 0); - assert(this->ParentPositions.size() > 0); + assert(this->SnapshotData.size() > 0); assert(this->CurrentSourceDirectoryComponents.size() > 0); assert(this->CurrentBinaryDirectoryComponents.size() > 0); assert(this->RelativePathTopSource.size() > 0); @@ -211,8 +217,8 @@ void cmState::Reset() this->Locations.erase(this->Locations.begin() + 1, this->Locations.end()); this->OutputLocations.erase(this->OutputLocations.begin() + 1, this->OutputLocations.end()); - this->ParentPositions.erase(this->ParentPositions.begin() + 1, - this->ParentPositions.end()); + this->SnapshotData.erase(this->SnapshotData.begin() + 1, + this->SnapshotData.end()); this->CurrentSourceDirectoryComponents.erase( this->CurrentSourceDirectoryComponents.begin() + 1, this->CurrentSourceDirectoryComponents.end()); @@ -662,7 +668,10 @@ void cmState::Snapshot::ComputeRelativePathTopBinary() cmState::Snapshot cmState::CreateBaseSnapshot() { PositionType pos = 0; - this->ParentPositions.push_back(pos); + this->SnapshotData.resize(1); + SnapshotDataType& snp = this->SnapshotData.back(); + snp.DirectoryParent = 0; + snp.SnapshotType = BuildsystemDirectoryType; this->Locations.resize(1); this->OutputLocations.resize(1); this->CurrentSourceDirectoryComponents.resize(1); @@ -676,8 +685,11 @@ cmState::Snapshot cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot) { assert(originSnapshot.IsValid()); - PositionType pos = this->ParentPositions.size(); - this->ParentPositions.push_back(originSnapshot.Position); + PositionType pos = this->SnapshotData.size(); + this->SnapshotData.resize(this->SnapshotData.size() + 1); + SnapshotDataType& snp = this->SnapshotData.back(); + snp.DirectoryParent = originSnapshot.Position; + snp.SnapshotType = BuildsystemDirectoryType; this->Locations.resize(this->Locations.size() + 1); this->OutputLocations.resize(this->OutputLocations.size() + 1); this->CurrentSourceDirectoryComponents.resize( @@ -782,7 +794,8 @@ cmState::Snapshot cmState::Snapshot::GetBuildsystemDirectoryParent() const { return snapshot; } - PositionType parentPos = this->State->ParentPositions[this->Position]; + PositionType parentPos = + this->State->SnapshotData[this->Position].DirectoryParent; snapshot = Snapshot(this->State, parentPos); return snapshot; diff --git a/Source/cmState.h b/Source/cmState.h index 60b024f33..024c9a98f 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -21,12 +21,18 @@ class cmCommand; class cmState { + struct SnapshotDataType; typedef std::vector::size_type PositionType; friend class Snapshot; public: cmState(cmake* cm); ~cmState(); + enum SnapshotType + { + BuildsystemDirectoryType + }; + class Snapshot { public: Snapshot(cmState* state = 0, PositionType position = 0); @@ -160,7 +166,7 @@ private: cmake* CMakeInstance; std::vector Locations; std::vector OutputLocations; - std::vector ParentPositions; + std::vector SnapshotData; std::vector > CurrentSourceDirectoryComponents; std::vector > CurrentBinaryDirectoryComponents;