aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/variable.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-10-12 08:31:54 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-10-13 06:49:26 +0200
commit3ba17db6300d7e0cfc4fa001b5a8eb91bf417ea3 (patch)
tree2c0878097ba9b049ea472c2c8c99a0e4ff77e959 /libbuild2/variable.hxx
parentd66e21ffa3ac9520fb15dd3859339b178d6e6540 (diff)
Switch to public/private variables model
Now unqualified variables are project-private and can be typified.
Diffstat (limited to 'libbuild2/variable.hxx')
-rw-r--r--libbuild2/variable.hxx11
1 files changed, 9 insertions, 2 deletions
diff --git a/libbuild2/variable.hxx b/libbuild2/variable.hxx
index bfe3b87..9206cbb 100644
--- a/libbuild2/variable.hxx
+++ b/libbuild2/variable.hxx
@@ -1270,7 +1270,7 @@ namespace build2
//
// Note also that a pattern and later insertions may restrict (but not
// relax) visibility and overridability.
-
+ //
const variable&
insert (string name)
{
@@ -1357,6 +1357,8 @@ namespace build2
// don't allow this (manually handle multiple names by merging their
// values instead).
//
+ // Note: currently only public variables can be aliased.
+ //
const variable&
insert_alias (const variable& var, string name);
@@ -1380,6 +1382,8 @@ namespace build2
// true null -- public variable pool in context
// true not null -- project-private pool in scope::root_extra
// with outer pointing to context::var_pool
+ // false not null -- temporary scope-private pool in temp_scope
+ // with outer pointing to context::var_pool
// false null -- script-private pool in script::environment
//
// Notice that the script-private pool doesn't rely on outer and does
@@ -1388,6 +1392,7 @@ namespace build2
//
private:
friend class context;
+ friend class temp_scope;
friend void setup_root_extra (scope&, optional<bool>&);
// Shared pool (public or project-private). The shared argument is
@@ -1440,6 +1445,8 @@ namespace build2
const bool* overridable,
bool pattern = true);
+ // Note: the variable must belong to this pool.
+ //
void
update (variable&,
const value_type*,
@@ -1457,7 +1464,7 @@ namespace build2
// gets hairy very quickly (there is no std::hash for C-strings). So
// let's rely on small object-optimized std::string for now.
//
- string n (var.name);
+ string n (var.name); // @@ PERF (maybe keep reuse buffer at least?)
auto r (map_.insert (map::value_type (&n, move (var))));
if (r.second)