From a94dcda7f00b10cb22b5f2138b1c29bcfbe7de37 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 24 Mar 2015 08:53:06 +0200 Subject: Make meta-operations control build loop; add disfigure skeleton --- build/target | 70 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 34 deletions(-) (limited to 'build/target') diff --git a/build/target b/build/target index c961315..050696c 100644 --- a/build/target +++ b/build/target @@ -165,41 +165,46 @@ namespace build std::ostream& operator<< (std::ostream&, const target&); - struct target_set + // Light-weight (by being shallow-pointing) target key. + // + struct target_key { - struct key + mutable const target_type* type; + mutable const path* dir; + mutable const std::string* name; + mutable const std::string* const* ext; + + friend bool + operator< (const target_key& x, const target_key& y) { - mutable const target_type* type; - mutable const path* dir; - mutable const std::string* name; - mutable const std::string* const* ext; - - friend bool - operator< (const key& x, const key& y) - { - const std::type_index& xt (x.type->id); - const std::type_index& yt (y.type->id); - - //@@ TODO: use compare() to compare once. - - // Unspecified and specified extension are assumed equal. The - // extension strings are from the pool, so we can just compare - // pointers. - // - return - (xt < yt) || - (xt == yt && *x.name < *y.name) || - (xt == yt && *x.name == *y.name && *x.dir < *y.dir) || - (xt == yt && *x.name == *y.name && *x.dir == *y.dir && - *x.ext != nullptr && *y.ext != nullptr && **x.ext < **y.ext); - } - }; - - typedef std::map> map; + const std::type_index& xt (x.type->id); + const std::type_index& yt (y.type->id); + + //@@ TODO: use compare() to compare once. + + // Unspecified and specified extension are assumed equal. The + // extension strings are from the pool, so we can just compare + // pointers. + // + return + (xt < yt) || + (xt == yt && *x.name < *y.name) || + (xt == yt && *x.name == *y.name && *x.dir < *y.dir) || + (xt == yt && *x.name == *y.name && *x.dir == *y.dir && + *x.ext != nullptr && *y.ext != nullptr && **x.ext < **y.ext); + } + }; + + std::ostream& + operator<< (std::ostream&, const target_key&); + + struct target_set + { + typedef std::map> map; typedef map_iterator_adapter iterator; iterator - find (const key& k, tracer& trace) const; + find (const target_key& k, tracer& trace) const; iterator find (const target_type& type, @@ -209,7 +214,7 @@ namespace build tracer& trace) const { const std::string* e (ext); - return find (key {&type, &dir, &name, &e}, trace); + return find (target_key {&type, &dir, &name, &e}, trace); } iterator begin () const {return map_.begin ();} @@ -226,9 +231,6 @@ namespace build map map_; }; - std::ostream& - operator<< (std::ostream&, const target_set::key&); - extern target_set targets; class target_type_map: public std::map< -- cgit v1.1