From fc27ec48c9d63879e4b0f049060e943233cb540d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 17 Oct 2016 15:43:47 +0200 Subject: Cleanup match_result mess --- build2/cc/compile | 4 ++-- build2/cc/compile.cxx | 20 ++++++++++++++++---- build2/cc/link | 4 ++-- build2/cc/link.cxx | 10 +++++----- 4 files changed, 25 insertions(+), 13 deletions(-) (limited to 'build2/cc') diff --git a/build2/cc/compile b/build2/cc/compile index 2be2e86..584da7c 100644 --- a/build2/cc/compile +++ b/build2/cc/compile @@ -27,10 +27,10 @@ namespace build2 compile (data&&); virtual match_result - match (action, target&, const string& hint) const; + match (action, target&, const string& hint) const override; virtual recipe - apply (action, target&, const match_result&) const; + apply (action, target&) const override; target_state perform_update (action, target&) const; diff --git a/build2/cc/compile.cxx b/build2/cc/compile.cxx index 6587d8c..e180798 100644 --- a/build2/cc/compile.cxx +++ b/build2/cc/compile.cxx @@ -35,6 +35,14 @@ namespace build2 { } + struct match_data + { + prerequisite_member src; + }; + + static_assert (sizeof (match_data) <= target::data_size, + "insufficient space"); + match_result compile:: match (action a, target& t, const string&) const { @@ -53,11 +61,14 @@ namespace build2 for (prerequisite_member p: reverse_group_prerequisite_members (a, t)) { if (p.is_a (x_src)) - return p; + { + t.data (match_data {p}); // Save in the target's auxilary storage. + return true; + } } l4 ([&]{trace << "no " << x_lang << " source file for target " << t;}); - return nullptr; + return false; } // Append or hash library options from a pair of *.export.* variables @@ -180,11 +191,12 @@ namespace build2 } recipe compile:: - apply (action a, target& xt, const match_result& mr) const + apply (action a, target& xt) const { tracer trace (x, "compile::apply"); file& t (static_cast (xt)); + const match_data& md (t.data ()); scope& bs (t.base_scope ()); scope& rs (*bs.root_scope ()); @@ -297,7 +309,7 @@ namespace build2 // t.prerequisite_targets since we used standard search() and match() // above. // - file& src (mr.as_target ()); + file& src (*md.src.search ().is_a ()); // Make sure the output directory exists. // diff --git a/build2/cc/link b/build2/cc/link index cd8c10e..ea30320 100644 --- a/build2/cc/link +++ b/build2/cc/link @@ -25,10 +25,10 @@ namespace build2 link (data&&); virtual match_result - match (action, target&, const string& hint) const; + match (action, target&, const string& hint) const override; virtual recipe - apply (action, target&, const match_result&) const; + apply (action, target&) const override; target_state perform_update (action, target&) const; diff --git a/build2/cc/link.cxx b/build2/cc/link.cxx index 5ab9d91..7722c4f 100644 --- a/build2/cc/link.cxx +++ b/build2/cc/link.cxx @@ -109,11 +109,11 @@ namespace build2 // it will most definitely need to be compiled but we can't do that. // else if (p.is_a ()) - return nullptr; + return false; } if (!(seen_x || seen_c || seen_obj || seen_lib)) - return nullptr; + return false; // We will only chain a C source if there is also an X source or we were // explicitly told to. @@ -121,7 +121,7 @@ namespace build2 if (seen_c && !seen_x && hint < x) { l4 ([&]{trace << "C prerequisite without " << x_lang << " or hint";}); - return nullptr; + return false; } // Set the library type. @@ -173,7 +173,7 @@ namespace build2 } } - return &t; + return true; } auto link:: @@ -316,7 +316,7 @@ namespace build2 } recipe link:: - apply (action a, target& xt, const match_result&) const + apply (action a, target& xt) const { tracer trace (x, "link::apply"); -- cgit v1.1