diff options
Diffstat (limited to 'libbuild2/functions-builtin.cxx')
-rw-r--r-- | libbuild2/functions-builtin.cxx | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/libbuild2/functions-builtin.cxx b/libbuild2/functions-builtin.cxx index 2adff38..378ffbc 100644 --- a/libbuild2/functions-builtin.cxx +++ b/libbuild2/functions-builtin.cxx @@ -11,6 +11,27 @@ using namespace std; namespace build2 { + // Note: not static since used by type-specific sort() implementations. + // + bool + functions_sort_flags (optional<names> fs) + { + bool r (false); + if (fs) + { + for (name& f: *fs) + { + string s (convert<string> (move (f))); + + if (s == "dedup") + r = true; + else + throw invalid_argument ("invalid flag '" + s + '\''); + } + } + return r; + }; + void builtin_functions (function_map& m) { @@ -39,7 +60,7 @@ namespace build2 fail << "visibility() called out of scope" << endf; const variable* var ( - s->ctx.var_pool.find (convert<string> (move (name)))); + s->var_pool ().find (convert<string> (move (name)))); return (var != nullptr ? optional<string> (to_string (var->visibility)) @@ -52,13 +73,6 @@ namespace build2 f["identity"] += [](value* v) {return move (*v);}; - // string - // - f["string"] += [](bool b) {return b ? "true" : "false";}; - f["string"] += [](int64_t i) {return to_string (i);}; - f["string"] += [](uint64_t i) {return to_string (i);}; - f["string"] += [](name n) {return to_string (n);}; - // Quote a value returning its string representation. If escape is true, // then also escape (with a backslash) the quote characters being added // (this is useful if the result will be re-parsed, for example as a @@ -69,12 +83,12 @@ namespace build2 if (v->null) return string (); - untypify (*v); // Reverse to names. + untypify (*v, true /* reduce */); // Reverse to names. ostringstream os; to_stream (os, v->as<names> (), - true /* quote */, + quote_mode::normal, '@' /* pair */, escape && convert<bool> (move (*escape))); return os.str (); |