diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-04-01 12:18:40 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-04-01 12:18:40 +0200 |
commit | e0de4f26fcf598b4f6beaa2847c4d43a4c761f5b (patch) | |
tree | 42e79e141d5b3488cb98843589a68001c875ed01 /build/variable | |
parent | 0dee00f28e623830e816c4002c8004c86055df85 (diff) |
Warn about configured/command line value mismatch
Also store configured but unspecified values
Diffstat (limited to 'build/variable')
-rw-r--r-- | build/variable | 63 |
1 files changed, 26 insertions, 37 deletions
diff --git a/build/variable b/build/variable index 0688a3e..500cc00 100644 --- a/build/variable +++ b/build/variable @@ -63,6 +63,9 @@ namespace build virtual value_ptr clone (scope_type& s) const = 0; + virtual bool + compare (const value&) const = 0; + virtual ~value () = default; }; @@ -88,8 +91,15 @@ namespace build data.emplace_back (std::move (d)); } - value_ptr + virtual value_ptr clone (scope_type& s) const {return value_ptr (new list_value (s, data));} + + virtual bool + compare (const value& v) const + { + const list_value* lv (dynamic_cast<const list_value*> (&v)); + return lv != nullptr && data == lv->data; + } }; typedef std::unique_ptr<list_value> list_value_ptr; @@ -114,49 +124,18 @@ namespace build // Set interface. // const value_proxy& - operator= (value_ptr v) const - { - assert (v == nullptr || &v->scope == s); - *p = std::move (v); - return *this; - } + operator= (value_ptr) const; const value_proxy& - operator= (const value_proxy& v) const - { - if (this != &v) - { - if (v) - { - const value_ptr& vp (v); - *p = vp->clone (*s); - } - else - p->reset (); - } - - return *this; - } + operator= (const value_proxy&) const; const value_proxy& - operator= (std::string v) const - { - // In most cases this is used to initialize a new variable, so - // don't bother trying to optimize for the case where p is not - // NULL. - // - p->reset (new list_value (*s, std::move (v))); - return *this; - } + operator= (std::string) const; // Note: stored in name as a directory. // const value_proxy& - operator= (path v) const - { - p->reset (new list_value (*s, std::move (v))); - return *this; - } + operator= (path) const; // Implementation details. // @@ -169,6 +148,14 @@ namespace build }; template <> + inline value& value_proxy:: + as<value&> () const {return **p;} + + template <> + inline const value& value_proxy:: + as<const value&> () const {return **p;} + + template <> list_value& value_proxy:: as<list_value&> () const; @@ -180,7 +167,7 @@ namespace build const std::string& value_proxy:: as<const std::string&> () const; - // Note: get the name's directory. + // Note: get the name's dir. // template <> const path& value_proxy:: @@ -273,4 +260,6 @@ namespace build }; } +#include <build/variable.ixx> + #endif // BUILD_VARIABLE |