aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/config
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/config')
-rw-r--r--libbuild2/config/init.cxx2
-rw-r--r--libbuild2/config/operation.cxx6
-rw-r--r--libbuild2/config/utility.cxx3
-rw-r--r--libbuild2/config/utility.hxx58
-rw-r--r--libbuild2/config/utility.txx22
5 files changed, 46 insertions, 45 deletions
diff --git a/libbuild2/config/init.cxx b/libbuild2/config/init.cxx
index 57b6290..8dd4d8b 100644
--- a/libbuild2/config/init.cxx
+++ b/libbuild2/config/init.cxx
@@ -120,7 +120,7 @@ namespace build2
m.save_module ("config", INT32_MIN);
m.save_module ("import", INT32_MIN);
- m.save_variable (c_p, omit_null);
+ m.save_variable (c_p, save_null_omitted);
}
// Register the config function family if this is the first instance of
diff --git a/libbuild2/config/operation.cxx b/libbuild2/config/operation.cxx
index 3758c87..2138986 100644
--- a/libbuild2/config/operation.cxx
+++ b/libbuild2/config/operation.cxx
@@ -306,7 +306,7 @@ namespace build2
// inherited. We might also not have any value at all (see
// unconfigured()).
//
- if (!l.defined () || (l->null && sv.flags & omit_null))
+ if (!l.defined () || (l->null && sv.flags & save_null_omitted))
continue;
// Handle inherited from outer scope values.
@@ -449,11 +449,11 @@ namespace build2
first = false;
}
- // Handle the save_commented flag.
+ // Handle the save_default_commented flag.
//
if ((org.first.defined () && org.first->extra) && // Default value.
org.first == ovr.first && // Not overriden.
- (sv.flags & save_commented) == save_commented)
+ (sv.flags & save_default_commented) != 0)
{
os << '#' << n << " =" << endl;
continue;
diff --git a/libbuild2/config/utility.cxx b/libbuild2/config/utility.cxx
index 98047b7..a39d3e0 100644
--- a/libbuild2/config/utility.cxx
+++ b/libbuild2/config/utility.cxx
@@ -19,8 +19,7 @@ namespace build2
pair<lookup, bool>
omitted (scope& rs, const variable& var)
{
- // This is a stripped-down version of the required() twisted
- // implementation.
+ // This is a stripped-down version of the required()'s twisted logic.
pair<lookup, size_t> org (rs.find_original (var));
diff --git a/libbuild2/config/utility.hxx b/libbuild2/config/utility.hxx
index 6890574..3e01cd1 100644
--- a/libbuild2/config/utility.hxx
+++ b/libbuild2/config/utility.hxx
@@ -39,38 +39,37 @@ namespace build2
//
template <typename T>
pair<lookup, bool>
- required (scope& root,
+ required (scope& rs,
const variable&,
T&& default_value,
bool override = false,
uint64_t save_flags = 0);
- // Note that the variable is expected to have already been registered.
+ // Note that the variable is expected to have already been entered.
//
template <typename T>
inline pair<lookup, bool>
- required (scope& root,
- const string& name,
+ required (scope& rs,
+ const string& var,
T&& default_value,
bool override = false,
uint64_t save_flags = 0)
{
- return required (root,
- root.ctx.var_pool[name],
+ return required (rs,
+ rs.ctx.var_pool[var],
std::forward<T> (default_value), // VC14
override,
save_flags);
}
inline pair<lookup, bool>
- required (scope& root,
- const string& name,
+ required (scope& rs,
+ const string& var,
const char* default_value,
bool override = false,
uint64_t save_flags = 0)
{
- return required (
- root, name, string (default_value), override, save_flags);
+ return required (rs, var, string (default_value), override, save_flags);
}
// As above, but leave the unspecified value as undefined rather than
@@ -80,14 +79,14 @@ namespace build2
// out some fallback. See config.bin.target for an example.
//
LIBBUILD2_SYMEXPORT pair<lookup, bool>
- omitted (scope& root, const variable&);
+ omitted (scope& rs, const variable&);
- // Note that the variable is expected to have already been registered.
+ // Note that the variable is expected to have already been entered.
//
inline pair<lookup, bool>
- omitted (scope& root, const string& name)
+ omitted (scope& rs, const string& var)
{
- return omitted (root, root.ctx.var_pool[name]);
+ return omitted (rs, rs.ctx.var_pool[var]);
}
// Set, if necessary, an optional config.* variable. In particular, an
@@ -98,15 +97,18 @@ namespace build2
//
// @@ Rename since clashes with the optional class template.
//
+ // @@ Does it make sense to return the new indicator here as well,
+ // for consistency/generality.
+ //
LIBBUILD2_SYMEXPORT lookup
- optional (scope& root, const variable&);
+ optional (scope& rs, const variable&);
// Note that the variable is expected to have already been registered.
//
inline lookup
- optional (scope& root, const string& name)
+ optional (scope& rs, const string& var)
{
- return optional (root, root.ctx.var_pool[name]);
+ return optional (rs, rs.ctx.var_pool[var]);
}
// Check whether there are any variables specified from the config
@@ -122,35 +124,35 @@ namespace build2
// running the tests, etc).
//
LIBBUILD2_SYMEXPORT bool
- specified (scope& root, const string& name);
+ specified (scope& rs, const string& var);
// Check if there is a false config.*.configured value. This mechanism can
// be used to "remember" that the module is left unconfigured in order to
// avoid re-running the tests, etc.
//
LIBBUILD2_SYMEXPORT bool
- unconfigured (scope& root, const string& name);
+ unconfigured (scope& rs, const string& var);
// Set the config.*.configured value. Note that you only need to set it to
// false. It will be automatically ignored if there are any other config.*
// values for this module. Return true if this sets a new value.
//
LIBBUILD2_SYMEXPORT bool
- unconfigured (scope& root, const string& name, bool);
+ unconfigured (scope& rs, const string& var, bool value);
// Enter the variable so that it is saved during configuration. See
// config::module for details.
//
- const uint64_t save_commented = 0x01; // Save default value as commented.
- const uint64_t omit_null = 0x02; // Treat NULL as undefined.
+ const uint64_t save_default_commented = 0x01; // Based on value::extra.
+ const uint64_t save_null_omitted = 0x02; // Treat NULL as undefined.
LIBBUILD2_SYMEXPORT void
- save_variable (scope& root, const variable&, uint64_t flags = 0);
+ save_variable (scope& rs, const variable&, uint64_t flags = 0);
// Establish module order/priority. See config::module for details.
//
LIBBUILD2_SYMEXPORT void
- save_module (scope& root, const char* name, int prio = 0);
+ save_module (scope& rs, const char* module, int prio = 0);
// Create a project in the specified directory.
//
@@ -167,11 +169,11 @@ namespace build2
uint16_t verbosity = 1); // Diagnostic verbosity.
inline path
- config_file (const scope& root)
+ config_file (const scope& rs)
{
- return (root.out_path () /
- root.root_extra->build_dir /
- "config." + root.root_extra->build_ext);
+ return (rs.out_path () /
+ rs.root_extra->build_dir /
+ "config." + rs.root_extra->build_ext);
}
}
}
diff --git a/libbuild2/config/utility.txx b/libbuild2/config/utility.txx
index b5d2174..670a701 100644
--- a/libbuild2/config/utility.txx
+++ b/libbuild2/config/utility.txx
@@ -10,17 +10,17 @@ namespace build2
{
template <typename T>
pair<lookup, bool>
- required (scope& root,
+ required (scope& rs,
const variable& var,
T&& def_val,
bool def_ovr,
- uint64_t save_flags)
+ uint64_t sflags)
{
// Note: see also omitted() if changing anything here.
- save_variable (root, var, save_flags);
+ save_variable (rs, var, sflags);
- pair<lookup, size_t> org (root.find_original (var));
+ pair<lookup, size_t> org (rs.find_original (var));
bool n (false); // New flag.
lookup l (org.first);
@@ -31,23 +31,23 @@ namespace build2
// are going to do is first ignore overrides and perform the normal
// logic on the original. Then we apply the overrides on the result.
//
- if (!l.defined () || (def_ovr && !l.belongs (root)))
+ if (!l.defined () || (def_ovr && !l.belongs (rs)))
{
- value& v (root.assign (var) = std::forward<T> (def_val)); // VC14
+ value& v (rs.assign (var) = std::forward<T> (def_val)); // VC14
v.extra = true; // Default value flag.
- n = (save_flags & save_commented) == 0; // Absence means default.
- l = lookup (v, var, root);
- org = make_pair (l, 1); // Lookup depth is 1 since it's in root.vars.
+ n = (sflags & save_default_commented) == 0; // Absence means default.
+ l = lookup (v, var, rs);
+ org = make_pair (l, 1); // Lookup depth is 1 since it's in rs.vars.
}
// Treat an inherited value that was set to default as new.
//
else if (l->extra)
- n = (save_flags & save_commented) == 0; // Absence means default.
+ n = (sflags & save_default_commented) == 0; // Absence means default.
if (var.overrides != nullptr)
{
- pair<lookup, size_t> ovr (root.find_override (var, move (org)));
+ pair<lookup, size_t> ovr (rs.find_override (var, move (org)));
if (l != ovr.first) // Overriden?
{