From 69801c4e23f877359118e55ed291737f4fbece04 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 28 Mar 2016 09:45:20 +0200 Subject: Add variable cast from lookup --- build2/cxx/compile.cxx | 16 ++++++++-------- build2/cxx/link.cxx | 30 +++++++++++++++--------------- build2/cxx/module.cxx | 2 +- build2/cxx/utility.txx | 2 +- 4 files changed, 25 insertions(+), 25 deletions(-) (limited to 'build2/cxx') diff --git a/build2/cxx/compile.cxx b/build2/cxx/compile.cxx index a2b00de..cf0c91c 100644 --- a/build2/cxx/compile.cxx +++ b/build2/cxx/compile.cxx @@ -130,7 +130,7 @@ namespace build2 // if (a == perform_update_id) { - const string& sys (cast (*rs["cxx.target.system"])); + const string& sys (cast (rs["cxx.target.system"])); // The cached prerequisite target should be the same as what is in // t.prerequisite_targets since we used standard search() and match() @@ -165,7 +165,7 @@ namespace build2 // Then the compiler checksum. // - if (dd.expect (cast (*rs["cxx.checksum"])) != nullptr) + if (dd.expect (cast (rs["cxx.checksum"])) != nullptr) l4 ([&]{trace << "compiler mismatch forcing update of " << t;}); // Then the options checksum. @@ -237,7 +237,7 @@ namespace build2 -> const target_type* { if (auto l = s.lookup (tt, n, var)) - if (cast (*l) == e) + if (cast (l) == e) return &tt; return nullptr; @@ -283,7 +283,7 @@ namespace build2 if (auto l = t[var]) { - const auto& v (cast (*l)); + const auto& v (cast (l)); for (auto i (v.begin ()), e (v.end ()); i != e; ++i) { @@ -461,8 +461,8 @@ namespace build2 auto init_args = [&t, &s, &rs, &args, &cxx_std] () { - const string& cxx (cast (*rs["config.cxx"])); - const string& sys (cast (*rs["cxx.target.system"])); + const string& cxx (cast (rs["config.cxx"])); + const string& sys (cast (rs["cxx.target.system"])); args.push_back (cxx.c_str ()); @@ -923,8 +923,8 @@ namespace build2 path rels (relative (s->path ())); scope& rs (t.root_scope ()); - const string& cxx (cast (*rs["config.cxx"])); - const string& sys (cast (*rs["cxx.target.system"])); + const string& cxx (cast (rs["config.cxx"])); + const string& sys (cast (rs["cxx.target.system"])); cstrings args {cxx.c_str ()}; diff --git a/build2/cxx/link.cxx b/build2/cxx/link.cxx index ea20a47..c0ea6d3 100644 --- a/build2/cxx/link.cxx +++ b/build2/cxx/link.cxx @@ -42,7 +42,7 @@ namespace build2 case type::so: var = "bin.libso.lib"; break; } - const auto& v (cast (*t[var])); + const auto& v (cast (t[var])); return v[0] == "shared" ? v.size () > 1 && v[1] == "static" ? order::so_a : order::so : v.size () > 1 && v[1] == "shared" ? order::a_so : order::a; @@ -52,7 +52,7 @@ namespace build2 link_member (bin::lib& l, order lo) { bool lso (true); - const string& at (cast (*l["bin.lib"])); // Available types. + const string& at (cast (l["bin.lib"])); // Available types. switch (lo) { @@ -92,7 +92,7 @@ namespace build2 // if (auto l = bs["cxx.loptions"]) { - const auto& v (cast (*l)); + const auto& v (cast (l)); for (auto i (v.begin ()), e (v.end ()); i != e; ++i) { @@ -123,7 +123,7 @@ namespace build2 cstrings args; string std_storage; - args.push_back (cast (*rs["config.cxx"]).c_str ()); + args.push_back (cast (rs["config.cxx"]).c_str ()); append_options (args, bs, "cxx.coptions"); append_std (args, bs, std_storage); append_options (args, bs, "cxx.loptions"); @@ -218,7 +218,7 @@ namespace build2 return p.target; scope& rs (*p.scope.root_scope ()); - const string& sys (cast (*rs["cxx.target.system"])); + const string& sys (cast (rs["cxx.target.system"])); bool l (p.is_a ()); const string* ext (l ? nullptr : p.ext); // Only for liba/libso. @@ -483,7 +483,7 @@ namespace build2 path_target& t (static_cast (xt)); scope& rs (t.root_scope ()); - const string& sys (cast (*rs["cxx.target.system"])); + const string& sys (cast (rs["cxx.target.system"])); type lt (link_type (t)); bool so (lt == type::so); @@ -510,7 +510,7 @@ namespace build2 case type::so: { auto l (t["bin.libprefix"]); - const char* p (l ? cast (*l).c_str () : "lib"); + const char* p (l ? cast (l).c_str () : "lib"); const char* e; if (lt == type::a) @@ -769,7 +769,7 @@ namespace build2 bool up (execute_prerequisites (a, t, t.mtime ())); scope& rs (t.root_scope ()); - const string& sys (cast (*rs["cxx.target.system"])); + const string& sys (cast (rs["cxx.target.system"])); // Check/update the dependency database. // @@ -793,10 +793,10 @@ namespace build2 const char* rl ( ranlib - ? cast (*rs["bin.ranlib.checksum"]).c_str () + ? cast (rs["bin.ranlib.checksum"]).c_str () : "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); - if (dd.expect (cast (*rs["bin.ar.checksum"])) != nullptr) + if (dd.expect (cast (rs["bin.ar.checksum"])) != nullptr) l4 ([&]{trace << "ar mismatch forcing update of " << t;}); if (dd.expect (rl) != nullptr) @@ -804,7 +804,7 @@ namespace build2 } else { - if (dd.expect (cast (*rs["cxx.checksum"])) != nullptr) + if (dd.expect (cast (rs["cxx.checksum"])) != nullptr) l4 ([&]{trace << "compiler mismatch forcing update of " << t;}); } @@ -877,7 +877,7 @@ namespace build2 // precedence. // if (auto l = t["bin.rpath"]) - for (const string& p: cast (*l)) + for (const string& p: cast (l)) sargs.push_back ("-Wl,-rpath," + p); // Then the paths of the shared libraries we are linking to. Unless @@ -978,12 +978,12 @@ namespace build2 if (lt == type::a) { - args[0] = cast (*rs["config.bin.ar"]).c_str (); + args[0] = cast (rs["config.bin.ar"]).c_str (); args.push_back (relt.string ().c_str ()); } else { - args[0] = cast (*rs["config.cxx"]).c_str (); + args[0] = cast (rs["config.cxx"]).c_str (); args.push_back ("-o"); args.push_back (relt.string ().c_str ()); } @@ -1048,7 +1048,7 @@ namespace build2 if (ranlib) { const char* args[] = { - cast (*ranlib).c_str (), relt.string ().c_str (), nullptr}; + cast (ranlib).c_str (), relt.string ().c_str (), nullptr}; if (verb >= 2) print_process (args); diff --git a/build2/cxx/module.cxx b/build2/cxx/module.cxx index d491079..18f9e53 100644 --- a/build2/cxx/module.cxx +++ b/build2/cxx/module.cxx @@ -46,7 +46,7 @@ namespace build2 { auto l (b["bin.loaded"]); - if (!l || !cast (*l)) + if (!l || !cast (l)) load_module (false, "bin", r, b, loc); } diff --git a/build2/cxx/utility.txx b/build2/cxx/utility.txx index c20e437..4d38513 100644 --- a/build2/cxx/utility.txx +++ b/build2/cxx/utility.txx @@ -14,7 +14,7 @@ namespace build2 { if (auto l = t["cxx.std"]) { - const string& v (cast (*l)); + const string& v (cast (l)); // Translate 11 to 0x and 14 to 1y for compatibility with older // versions of the compiler. -- cgit v1.1