aboutsummaryrefslogtreecommitdiff
path: root/build2/config
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-01-11 10:14:23 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-01-12 10:58:19 +0200
commit9bf93c1ab73ee3cd2b763285fc5fc5456e972854 (patch)
tree0357c36e12fe2137ef6c9bd228e9d69bb2489a02 /build2/config
parent33ed305eac57bff406fa3f672ba8acc4941e8f13 (diff)
Implement support for narrowing down tests (config.test)
Diffstat (limited to 'build2/config')
-rw-r--r--build2/config/utility31
-rw-r--r--build2/config/utility.cxx12
-rw-r--r--build2/config/utility.txx4
3 files changed, 24 insertions, 23 deletions
diff --git a/build2/config/utility b/build2/config/utility
index 1f1fba2..6c18715 100644
--- a/build2/config/utility
+++ b/build2/config/utility
@@ -28,14 +28,16 @@ namespace build2
// the value is "new", that is, it was set to the default value (inherited
// or not, including overrides). We also treat command line overrides
// (inherited or not) as new. This flag is usually used to test that the
- // new value is valid, print report, etc.
+ // new value is valid, print report, etc. We return the value as lookup
+ // (always defined) to pass alone its location (could be used to detect
+ // inheritance, etc).
//
// Note also that if save_flags has save_commented, then a default value
// is never considered "new" since for such variables absence of a value
// means the default value.
//
template <typename T>
- pair<reference_wrapper<const value>, bool>
+ pair<lookup, bool>
required (scope& root,
const variable&,
const T& default_value,
@@ -43,7 +45,7 @@ namespace build2
uint64_t save_flags = 0);
template <typename T>
- inline pair<reference_wrapper<const value>, bool>
+ inline pair<lookup, bool>
required (scope& root,
const string& name,
const T& default_value,
@@ -54,7 +56,7 @@ namespace build2
root, var_pool[name], default_value, override, save_flags);
}
- inline pair<reference_wrapper<const value>, bool>
+ inline pair<lookup, bool>
required (scope& root,
const string& name,
const char* default_value,
@@ -65,32 +67,31 @@ namespace build2
root, name, string (default_value), override, save_flags);
}
- // As above, but leave the unspecified value as undefined (and return
- // NULL pointer) rather than setting it to the default value.
+ // As above, but leave the unspecified value as undefined rather than
+ // setting it to the default value.
//
// This can be useful when we don't have a default value but may figure
// out some fallback. See config.bin.target for an example.
//
- pair<const value*, bool>
+ pair<lookup, bool>
omitted (scope& root, const variable&);
- inline pair<const value*, bool>
+ inline pair<lookup, bool>
omitted (scope& root, const string& name)
{
return omitted (root, var_pool[name]);
}
- // Set, if necessary, an optional config.* variable. In particular,
- // an unspecified variable is set to NULL which is used to distinguish
- // between the "configured as unspecified" and "not yet configured"
- // cases.
+ // Set, if necessary, an optional config.* variable. In particular, an
+ // unspecified variable is set to NULL which is used to distinguish
+ // between the "configured as unspecified" and "not yet configured" cases.
//
- // Return the value, which can be NULL.
+ // Return the value (as always defined lookup), which can be NULL.
//
- const value&
+ lookup
optional (scope& root, const variable&);
- inline const value&
+ inline lookup
optional (scope& root, const string& var)
{
return optional (root, var_pool[var]);
diff --git a/build2/config/utility.cxx b/build2/config/utility.cxx
index dac11c2..7a3fa9c 100644
--- a/build2/config/utility.cxx
+++ b/build2/config/utility.cxx
@@ -14,7 +14,7 @@ namespace build2
{
namespace config
{
- pair<const value*, bool>
+ pair<lookup, bool>
omitted (scope& r, const variable& var)
{
// This is a stripped-down version of the required() twisted
@@ -44,12 +44,12 @@ namespace build2
}
if (l.defined () && current_mif->id == configure_id)
- save_variable (r, var);
+ save_variable (r, var);
- return pair<const value*, bool> (l.value, n);
+ return pair<lookup, bool> (l, n);
}
- const value&
+ lookup
optional (scope& r, const variable& var)
{
if (current_mif->id == configure_id)
@@ -57,8 +57,8 @@ namespace build2
auto l (r[var]);
return l.defined ()
- ? *l
- : r.assign (var); // NULL.
+ ? l
+ : lookup (r.assign (var), r); // NULL.
}
bool
diff --git a/build2/config/utility.txx b/build2/config/utility.txx
index b6859d0..1434406 100644
--- a/build2/config/utility.txx
+++ b/build2/config/utility.txx
@@ -10,7 +10,7 @@ namespace build2
namespace config
{
template <typename T>
- pair<reference_wrapper<const value>, bool>
+ pair<lookup, bool>
required (scope& root,
const variable& var,
const T& def_val,
@@ -60,7 +60,7 @@ namespace build2
}
}
- return pair<reference_wrapper<const value>, bool> (*l, n);
+ return pair<lookup, bool> (l, n);
}
}
}