diff options
-rw-r--r-- | src/build.cc | 8 | ||||
-rw-r--r-- | src/graph.cc | 2 | ||||
-rw-r--r-- | src/graph.h | 7 | ||||
-rw-r--r-- | src/ninja.cc | 8 | ||||
-rw-r--r-- | src/state.cc | 4 |
5 files changed, 15 insertions, 14 deletions
diff --git a/src/build.cc b/src/build.cc index 3b478fa..a6d8bf1 100644 --- a/src/build.cc +++ b/src/build.cc @@ -286,8 +286,8 @@ void Plan::EdgeFinished(Edge* edge) { void Plan::NodeFinished(Node* node) { // See if we we want any edges from this node. - for (vector<Edge*>::iterator i = node->out_edges_.begin(); - i != node->out_edges_.end(); ++i) { + for (vector<Edge*>::const_iterator i = node->out_edges().begin(); + i != node->out_edges().end(); ++i) { map<Edge*, bool>::iterator want_i = want_.find(*i); if (want_i == want_.end()) continue; @@ -308,8 +308,8 @@ void Plan::NodeFinished(Node* node) { void Plan::CleanNode(BuildLog* build_log, Node* node) { node->set_dirty(false); - for (vector<Edge*>::iterator ei = node->out_edges_.begin(); - ei != node->out_edges_.end(); ++ei) { + for (vector<Edge*>::const_iterator ei = node->out_edges().begin(); + ei != node->out_edges().end(); ++ei) { // Don't process edges that we don't actually want. map<Edge*, bool>::iterator want_i = want_.find(*ei); if (want_i == want_.end() || !want_i->second) diff --git a/src/graph.cc b/src/graph.cc index 15df856..fdbbb0a 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -234,7 +234,7 @@ bool Edge::LoadDepFile(State* state, DiskInterface* disk_interface, Node* node = state->GetNode(path); *implicit_dep = node; - node->out_edges_.push_back(this); + node->AddOutEdge(this); // If we don't have a edge that generates this input already, // create one; this makes us not abort if the input is missing, diff --git a/src/graph.h b/src/graph.h index b6f5139..6756417 100644 --- a/src/graph.h +++ b/src/graph.h @@ -71,6 +71,9 @@ struct Node { Edge* in_edge() const { return in_edge_; } void set_in_edge(Edge* edge) { in_edge_ = edge; } + const vector<Edge*>& out_edges() const { return out_edges_; } + void AddOutEdge(Edge* edge) { out_edges_.push_back(edge); } + private: string path_; /// Possible values of mtime_: @@ -88,9 +91,7 @@ private: /// known edge to produce it. Edge* in_edge_; - // TODO: make these private as well. But don't just blindly add - // setters/getters, instead pay attention to the proper API. -public: + /// All Edges that use this Node as an input. vector<Edge*> out_edges_; }; diff --git a/src/ninja.cc b/src/ninja.cc index 1024401..8535d57 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -151,11 +151,11 @@ bool CollectTargetsFromArgs(State* state, int argc, char* argv[], Node* node = state->LookupNode(path); if (node) { if (first_dependent) { - if (node->out_edges_.empty()) { + if (node->out_edges().empty()) { *err = "'" + path + "' has no out edge"; return false; } - Edge* edge = node->out_edges_[0]; + Edge* edge = node->out_edges()[0]; if (edge->outputs_.empty()) { edge->Dump(); Fatal("edge has no outputs"); @@ -210,8 +210,8 @@ int CmdQuery(State* state, int argc, char* argv[]) { printf(" %s\n", (*in)->path().c_str()); } } - for (vector<Edge*>::iterator edge = node->out_edges_.begin(); - edge != node->out_edges_.end(); ++edge) { + for (vector<Edge*>::const_iterator edge = node->out_edges().begin(); + edge != node->out_edges().end(); ++edge) { printf(" output: %s\n", (*edge)->rule_->name_.c_str()); for (vector<Node*>::iterator out = (*edge)->outputs_.begin(); out != (*edge)->outputs_.end(); ++out) { diff --git a/src/state.cc b/src/state.cc index 930c361..00192b0 100644 --- a/src/state.cc +++ b/src/state.cc @@ -83,7 +83,7 @@ Node* State::SpellcheckNode(const string& path) { void State::AddIn(Edge* edge, const string& path) { Node* node = GetNode(path); edge->inputs_.push_back(node); - node->out_edges_.push_back(edge); + node->AddOutEdge(edge); } void State::AddOut(Edge* edge, const string& path) { @@ -112,7 +112,7 @@ vector<Node*> State::RootNodes(string* err) { for (vector<Edge*>::iterator e = edges_.begin(); e != edges_.end(); ++e) { for (vector<Node*>::iterator out = (*e)->outputs_.begin(); out != (*e)->outputs_.end(); ++out) { - if ((*out)->out_edges_.empty()) + if ((*out)->out_edges().empty()) root_nodes.push_back(*out); } } |