From 53f02bf28dae507a51515ed6ac03226d68816494 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 2 Feb 2017 10:20:50 +0200 Subject: Store extension in target map key rather than in target This is in preparation for locking its modification/access. --- build2/target | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'build2/target') diff --git a/build2/target b/build2/target index 05e4281..42c0361 100644 --- a/build2/target +++ b/build2/target @@ -108,7 +108,7 @@ namespace build2 class target { public: - typedef build2::action action_type; + using action_type = build2::action; // For targets that are in the src tree of a project we also keep the // corresponding out directory. As a result we may end up with multiple @@ -127,7 +127,9 @@ namespace build2 const dir_path dir; // Absolute and normalized. const dir_path out; // Empty or absolute and normalized. const string name; - optional ext; // Absent - unspecified, empty - no extension. + optional ext () const {return *ext_;} + + optional* ext_; // Reference to value in target_key. const dir_path& out_dir () const {return out.empty () ? dir : out;} @@ -249,7 +251,7 @@ namespace build2 // to the targets's members will be reflected in the key. // target_key - key () const {return target_key {&type (), &dir, &out, &name, ext};} + key () const {return target_key {&type (), &dir, &out, &name, ext ()};} // Scoping. // @@ -548,8 +550,10 @@ namespace build2 // The only way to create a target should be via the targets set below. // public: - target (dir_path d, dir_path o, string n, optional e) - : dir (move (d)), out (move (o)), name (move (n)), ext (move (e)), + friend class target_set; + + target (dir_path d, dir_path o, string n) + : dir (move (d)), out (move (o)), name (move (n)), vars (false) // Note: not global. {} }; @@ -967,10 +971,9 @@ namespace build2 // map. The key's hash ignores the extension, so the hash will stay stable // across extension updates. // - struct target_set + class target_set { - // @@ Why do we dynalloc target? - // + public: typedef std::unordered_map> map; typedef butl::map_iterator_adapter iterator; @@ -1342,14 +1345,14 @@ namespace build2 // search functions. // template - target* + pair> target_factory (const target_type&, dir_path d, dir_path o, string n, optional e) { - return new T (move (d), move (o), move (n), move (e)); + return make_pair (new T (move (d), move (o), move (n)), move (e)); } // Return fixed target extension. -- cgit v1.1