From 9ca783f9fab41eac40b96313749533ea5c965426 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 28 Jun 2018 11:04:24 +0200 Subject: Add prerequisite variable visibility specification/enforcement --- build2/variable.hxx | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) (limited to 'build2/variable.hxx') diff --git a/build2/variable.hxx b/build2/variable.hxx index 4d11b25..e11d00c 100644 --- a/build2/variable.hxx +++ b/build2/variable.hxx @@ -94,17 +94,48 @@ namespace build2 bool (*const empty) (const value&); }; - enum class variable_visibility + // The order of the enumerators is arranged so that their integral values + // indicate whether one is more restrictive than the other. + // + enum class variable_visibility: uint8_t { // Note that the search for target type/pattern-specific terminates at // the project boundary. // - target, // Target and target type/pattern-specific. - scope, // This scope (no outer scopes). - project, // This project (no outer projects). - normal // All outer scopes. + normal, // All outer scopes. + project, // This project (no outer projects). + scope, // This scope (no outer scopes). + target, // Target and target type/pattern-specific. + prereq // Prerequisite-specific. }; + inline bool + operator> (variable_visibility l, variable_visibility r) + { + return static_cast (l) > static_cast (r); + } + + inline bool + operator>= (variable_visibility l, variable_visibility r) + { + return static_cast (l) >= static_cast (r); + } + + inline bool + operator< (variable_visibility l, variable_visibility r) + { + return r > l; + } + + inline bool + operator<= (variable_visibility l, variable_visibility r) + { + return r >= l; + } + + ostream& + operator<< (ostream&, variable_visibility); + // variable // // The two variables are considered the same if they have the same name. -- cgit v1.1