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

Unified Diff: tools/gn/deps_iterator.h

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/copy_target_generator.cc ('k') | tools/gn/deps_iterator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/deps_iterator.h
diff --git a/tools/gn/deps_iterator.h b/tools/gn/deps_iterator.h
new file mode 100644
index 0000000000000000000000000000000000000000..5fc3c01e019f33eff2e9714bc4fb9fbf8d6d1fd4
--- /dev/null
+++ b/tools/gn/deps_iterator.h
@@ -0,0 +1,61 @@
+// 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.
+
+#ifndef TOOLS_GN_DEPS_ITERATOR_H_
+#define TOOLS_GN_DEPS_ITERATOR_H_
+
+#include "base/basictypes.h"
+#include "tools/gn/label_ptr.h"
+
+class Target;
+
+// Iterates over the deps of a target.
+//
+// Since there are multiple kinds of deps, this iterator allows looping over
+// each one in one loop.
+class DepsIterator {
+ public:
+ enum LinkedOnly {
+ LINKED_ONLY,
+ };
+
+ // Iterate over public, private, and data deps.
+ explicit DepsIterator(const Target* t);
+
+ // Iterate over the public and private linked deps, but not the data deps.
+ DepsIterator(const Target* t, LinkedOnly);
+
+ // Returns true when there are no more targets.
+ bool done() const {
+ return !vect_stack_[0];
+ }
+
+ // Advance to the next position. This assumes !done().
+ //
+ // 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 Advance();
+
+ // The current dependency.
+ const LabelTargetPair& pair() const {
+ DCHECK_LT(current_index_, vect_stack_[0]->size());
+ return (*vect_stack_[0])[current_index_];
+ }
+
+ // The pointer to the current dependency.
+ const Target* target() const { return pair().ptr; }
+
+ // The label of the current dependency.
+ const Label& label() const { return pair().label; }
+
+ private:
+ const LabelTargetVector* vect_stack_[3];
+
+ size_t current_index_;
+
+ DISALLOW_COPY_AND_ASSIGN(DepsIterator);
+};
+
+#endif // TOOLS_GN_DEPS_ITERATOR_H_
« no previous file with comments | « tools/gn/copy_target_generator.cc ('k') | tools/gn/deps_iterator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698