diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-06-28 11:04:24 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-06-28 11:04:24 +0200 |
commit | 9ca783f9fab41eac40b96313749533ea5c965426 (patch) | |
tree | cf1ee86bc0153fb972e99dc882b4d1823805725b /build2/variable.hxx | |
parent | 3cc5e3bd441fc9d18fece3d9e99fae75c78438e7 (diff) |
Add prerequisite variable visibility specification/enforcement
Diffstat (limited to 'build2/variable.hxx')
-rw-r--r-- | build2/variable.hxx | 41 |
1 files changed, 36 insertions, 5 deletions
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<uint8_t> (l) > static_cast<uint8_t> (r); + } + + inline bool + operator>= (variable_visibility l, variable_visibility r) + { + return static_cast<uint8_t> (l) >= static_cast<uint8_t> (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. |