Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: tools/gn/deps_iterator.cc

Issue 561273003: Add public deps to GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/deps_iterator.h ('k') | tools/gn/function_toolchain.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/deps_iterator.cc
diff --git a/tools/gn/deps_iterator.cc b/tools/gn/deps_iterator.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1f964f38461af15f1caf71dfada67cb4d42158bc
--- /dev/null
+++ b/tools/gn/deps_iterator.cc
@@ -0,0 +1,48 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "tools/gn/deps_iterator.h"
+
+#include "tools/gn/target.h"
+
+DepsIterator::DepsIterator(const Target* t) : current_index_(0) {
+ vect_stack_[0] = &t->public_deps();
+ vect_stack_[1] = &t->private_deps();
+ vect_stack_[2] = &t->data_deps();
+
+ if (vect_stack_[0]->empty())
+ Advance();
+}
+
+// Iterate over the public and private linked deps, but not the data deps.
+DepsIterator::DepsIterator(const Target* t, LinkedOnly) : current_index_(0) {
+ vect_stack_[0] = &t->public_deps();
+ vect_stack_[1] = &t->private_deps();
+ vect_stack_[2] = NULL;
+
+ if (vect_stack_[0]->empty())
+ Advance();
+}
+
+// Advance to the next position. This assumes there are more vectors.
+//
+// For internal use, this function tolerates an initial index equal to the
+// length of the current vector. In this case, it will advance to the next
+// one.
+void DepsIterator::Advance() {
+ DCHECK(vect_stack_[0]);
+
+ current_index_++;
+ if (current_index_ >= vect_stack_[0]->size()) {
+ // Advance to next vect. Shift the elements left by one.
+ vect_stack_[0] = vect_stack_[1];
+ vect_stack_[1] = vect_stack_[2];
+ vect_stack_[2] = NULL;
+
+ current_index_ = 0;
+
+ if (vect_stack_[0] && vect_stack_[0]->empty())
+ Advance();
+ }
+}
« no previous file with comments | « tools/gn/deps_iterator.h ('k') | tools/gn/function_toolchain.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698