aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-01-27 07:19:43 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-01-27 08:39:31 +0200
commitba637925b32e85c22c9dc81820e407ebdacfe5f7 (patch)
tree587bdb789333a1f0b94b61d9fff2e04f3f097514 /libbuild2
parent9dbf67ecdf737eea60fb2a12348e4b7157c2f096 (diff)
Add scope::{insert_rule,var_pool}() convenience functions
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/scope.hxx34
1 files changed, 32 insertions, 2 deletions
diff --git a/libbuild2/scope.hxx b/libbuild2/scope.hxx
index 2ed8f18..655a1a0 100644
--- a/libbuild2/scope.hxx
+++ b/libbuild2/scope.hxx
@@ -181,6 +181,14 @@ namespace build2
return vars.assign (ctx.var_pool.rw (*this).insert<T> (move (name)));
}
+ template <typename T>
+ T&
+ assign (string name, T&& val)
+ {
+ value& v (assign<T> (move (name)) = forward<T> (val));
+ return v.as<T> ();
+ }
+
// Return a value suitable for appending. If the variable does not
// exist in this scope's map, then outer scopes are searched for
// the same variable. If found then a new variable with the found
@@ -289,6 +297,22 @@ namespace build2
public:
rule_map rules;
+ template <typename T>
+ void
+ insert_rule (action_id a, const char* hint, const rule& r)
+ {
+ rules.insert<T> (a, hint, r);
+ }
+
+ template <typename T>
+ void
+ insert_rule (meta_operation_id mid, operation_id oid,
+ const char* hint,
+ const rule& r)
+ {
+ rules.insert<T> (mid, oid, hint, r);
+ }
+
// Operation callbacks.
//
// An entity (module, core) can register a function that will be called
@@ -374,9 +398,9 @@ namespace build2
template <typename T>
T*
- lookup_module (const string& name) const
+ find_module (const string& name) const
{
- return root_extra->modules.lookup<T> (name);
+ return root_extra->modules.find_module<T> (name);
}
public:
@@ -389,6 +413,12 @@ namespace build2
return const_cast<scope&> (*this);
}
+ variable_pool&
+ var_pool ()
+ {
+ return ctx.var_pool.rw (*this);
+ }
+
private:
friend class parser;
friend class scope_map;