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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef TOOLS_GN_DEPS_ITERATOR_H_
6 #define TOOLS_GN_DEPS_ITERATOR_H_
7
8 #include "base/basictypes.h"
9 #include "tools/gn/label_ptr.h"
10
11 class Target;
12
13 // Iterates over the deps of a target.
14 //
15 // Since there are multiple kinds of deps, this iterator allows looping over
16 // each one in one loop.
17 class DepsIterator {
18 public:
19 enum LinkedOnly {
20 LINKED_ONLY,
21 };
22
23 // Iterate over public, private, and data deps.
24 explicit DepsIterator(const Target* t);
25
26 // Iterate over the public and private linked deps, but not the data deps.
27 DepsIterator(const Target* t, LinkedOnly);
28
29 // Returns true when there are no more targets.
30 bool done() const {
31 return !vect_stack_[0];
32 }
33
34 // Advance to the next position. This assumes !done().
35 //
36 // For internal use, this function tolerates an initial index equal to the
37 // length of the current vector. In this case, it will advance to the next
38 // one.
39 void Advance();
40
41 // The current dependency.
42 const LabelTargetPair& pair() const {
43 DCHECK_LT(current_index_, vect_stack_[0]->size());
44 return (*vect_stack_[0])[current_index_];
45 }
46
47 // The pointer to the current dependency.
48 const Target* target() const { return pair().ptr; }
49
50 // The label of the current dependency.
51 const Label& label() const { return pair().label; }
52
53 private:
54 const LabelTargetVector* vect_stack_[3];
55
56 size_t current_index_;
57
58 DISALLOW_COPY_AND_ASSIGN(DepsIterator);
59 };
60
61 #endif // TOOLS_GN_DEPS_ITERATOR_H_
OLDNEW
« 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