From be14801929cf2a6caced87df034ae12a85f42aa6 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 30 Nov 2016 17:32:43 +0200 Subject: Add support for typed/untyped concatenated expansion --- build2/variable.cxx | 68 ++++++++++++++++++++--------------------------------- 1 file changed, 26 insertions(+), 42 deletions(-) (limited to 'build2/variable.cxx') diff --git a/build2/variable.cxx b/build2/variable.cxx index 5a52557..41dbd5f 100644 --- a/build2/variable.cxx +++ b/build2/variable.cxx @@ -58,13 +58,11 @@ namespace build2 value& value:: operator= (value&& v) { - assert (type == nullptr || type == v.type); - if (this != &v) { // Prepare the receiving value. // - if (type == nullptr && v.type != nullptr) + if (type != v.type) { *this = nullptr; type = v.type; @@ -99,13 +97,11 @@ namespace build2 value& value:: operator= (const value& v) { - assert (type == nullptr || type == v.type); - if (this != &v) { // Prepare the receiving value. // - if (type == nullptr && v.type != nullptr) + if (type != v.type) { *this = nullptr; type = v.type; @@ -212,7 +208,7 @@ namespace build2 ns.insert (ns.end (), make_move_iterator (p.begin ()), make_move_iterator (p.end ())); - p.swap (ns); + p = move (ns); } } } @@ -388,8 +384,7 @@ namespace build2 if (n.simple ()) m += "'" + n.value + "'"; else if (n.directory ()) - m += "'" + - (n.original ? n.dir.representation () : n.dir.string ()) + "'"; + m += "'" + n.dir.representation () + "'"; else m += "complex name"; } @@ -428,9 +423,9 @@ namespace build2 nullptr, // No dtor (POD). nullptr, // No copy_ctor (POD). nullptr, // No copy_assign (POD). - &simple_assign, // No empty value. - &simple_append, - &simple_append, // Prepend same as append. + &simple_assign, + &simple_append, + &simple_append, // Prepend same as append. &simple_reverse, nullptr, // No cast (cast data_ directly). nullptr, // No compare (compare as POD). @@ -469,9 +464,9 @@ namespace build2 nullptr, // No dtor (POD). nullptr, // No copy_ctor (POD). nullptr, // No copy_assign (POD). - &simple_assign, // No empty value. - &simple_append, - &simple_append, // Prepend same as append. + &simple_assign, + &simple_append, + &simple_append, // Prepend same as append. &simple_reverse, nullptr, // No cast (cast data_ directly). nullptr, // No compare (compare as POD). @@ -497,13 +492,10 @@ namespace build2 string s; if (n.directory (true)) - // Use either the precise or traditional representation depending on - // whether this is the original name (if it is, then this might not be - // a path after all; think s/foo/bar/). + // Note that here we cannot assume what's in dir is really a + // path (think s/foo/bar/) so we have to reverse it exactly. // - s = n.original - ? move (n.dir).representation () // Move out of path. - : move (n.dir).string (); + s = move (n.dir).representation (); // Move out of path. else s.swap (n.value); @@ -530,12 +522,7 @@ namespace build2 } if (r->directory (true)) - { - if (r->original) - s += move (r->dir).representation (); - else - s += r->dir.string (); - } + s += move (r->dir).representation (); else s += r->value; } @@ -553,9 +540,9 @@ namespace build2 &default_dtor, &default_copy_ctor, &default_copy_assign, - &simple_assign, // Allow empty strings. - &simple_append, - &simple_prepend, + &simple_assign, + &simple_append, + &simple_prepend, &simple_reverse, nullptr, // No cast (cast data_ directly). &simple_compare, @@ -599,9 +586,9 @@ namespace build2 &default_dtor, &default_copy_ctor, &default_copy_assign, - &simple_assign, // Allow empty paths. - &simple_append, - &simple_prepend, + &simple_assign, + &simple_append, + &simple_prepend, &simple_reverse, nullptr, // No cast (cast data_ directly). &simple_compare, @@ -643,9 +630,9 @@ namespace build2 &default_dtor, &default_copy_ctor, &default_copy_assign, - &simple_assign, // Allow empty paths. - &simple_append, - &simple_prepend, + &simple_assign, + &simple_append, + &simple_prepend, &simple_reverse, nullptr, // No cast (cast data_ directly). &simple_compare, @@ -689,8 +676,8 @@ namespace build2 &default_dtor, &default_copy_ctor, &default_copy_assign, - &simple_assign, // Allow empty paths. - &simple_append, + &simple_assign, + &simple_append, nullptr, // No prepend. &simple_reverse, nullptr, // No cast (cast data_ directly). @@ -704,10 +691,7 @@ namespace build2 convert (name&& n, name* r) { if (r == nullptr) - { - n.original = false; return move (n); - } throw_invalid_argument (n, r, "name"); } @@ -729,7 +713,7 @@ namespace build2 &default_dtor, &default_copy_ctor, &default_copy_assign, - &simple_assign, // Allow empty names. + &simple_assign, nullptr, // Append not supported. nullptr, // Prepend not supported. &name_reverse, -- cgit v1.1