aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/functions-builtin.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/functions-builtin.cxx')
-rw-r--r--libbuild2/functions-builtin.cxx15
1 files changed, 15 insertions, 0 deletions
diff --git a/libbuild2/functions-builtin.cxx b/libbuild2/functions-builtin.cxx
index c4f0314..4e28741 100644
--- a/libbuild2/functions-builtin.cxx
+++ b/libbuild2/functions-builtin.cxx
@@ -27,6 +27,21 @@ namespace build2
return (*s)[convert<string> (move (name))].defined ();
};
+ // Return variable visibility if it exists and NULL otherwise.
+ //
+ f["visibility"] = [](const scope* s, names name)
+ {
+ if (s == nullptr)
+ fail << "visibility() called out of scope" << endf;
+
+ const variable* var (
+ s->ctx.var_pool.find (convert<string> (move (name))));
+
+ return (var != nullptr
+ ? optional<string> (to_string (var->visibility))
+ : nullopt);
+ };
+
f["type"] = [](value* v) {return v->type != nullptr ? v->type->name : "";};
f["null"] = [](value* v) {return v->null;};
f["empty"] = [](value* v) {return v->null || v->empty ();};