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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « tools/gn/deps_iterator.h ('k') | tools/gn/function_toolchain.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 #include "tools/gn/deps_iterator.h"
6
7 #include "tools/gn/target.h"
8
9 DepsIterator::DepsIterator(const Target* t) : current_index_(0) {
10 vect_stack_[0] = &t->public_deps();
11 vect_stack_[1] = &t->private_deps();
12 vect_stack_[2] = &t->data_deps();
13
14 if (vect_stack_[0]->empty())
15 Advance();
16 }
17
18 // Iterate over the public and private linked deps, but not the data deps.
19 DepsIterator::DepsIterator(const Target* t, LinkedOnly) : current_index_(0) {
20 vect_stack_[0] = &t->public_deps();
21 vect_stack_[1] = &t->private_deps();
22 vect_stack_[2] = NULL;
23
24 if (vect_stack_[0]->empty())
25 Advance();
26 }
27
28 // Advance to the next position. This assumes there are more vectors.
29 //
30 // For internal use, this function tolerates an initial index equal to the
31 // length of the current vector. In this case, it will advance to the next
32 // one.
33 void DepsIterator::Advance() {
34 DCHECK(vect_stack_[0]);
35
36 current_index_++;
37 if (current_index_ >= vect_stack_[0]->size()) {
38 // Advance to next vect. Shift the elements left by one.
39 vect_stack_[0] = vect_stack_[1];
40 vect_stack_[1] = vect_stack_[2];
41 vect_stack_[2] = NULL;
42
43 current_index_ = 0;
44
45 if (vect_stack_[0] && vect_stack_[0]->empty())
46 Advance();
47 }
48 }
OLDNEW
« 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