aboutsummaryrefslogtreecommitdiff
path: root/build2/bin
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-10-17 15:43:47 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 09:26:25 +0200
commitfc27ec48c9d63879e4b0f049060e943233cb540d (patch)
tree28e062c8674ad194268100bf48475aecaca4c056 /build2/bin
parent8b564b5b8f6d597a9fb76734e759f78c4b1c91da (diff)
Cleanup match_result mess
Diffstat (limited to 'build2/bin')
-rw-r--r--build2/bin/rule8
-rw-r--r--build2/bin/rule.cxx30
2 files changed, 23 insertions, 15 deletions
diff --git a/build2/bin/rule b/build2/bin/rule
index 9bf1379..4072e4e 100644
--- a/build2/bin/rule
+++ b/build2/bin/rule
@@ -18,20 +18,20 @@ namespace build2
{
public:
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;
};
class lib_rule: public rule
{
public:
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;
static target_state
perform (action, target&);
diff --git a/build2/bin/rule.cxx b/build2/bin/rule.cxx
index 7710a53..3f16d71 100644
--- a/build2/bin/rule.cxx
+++ b/build2/bin/rule.cxx
@@ -25,17 +25,26 @@ namespace build2
fail << diag_doing (a, t) << " target group" <<
info << "explicitly select obje{}, obja{}, or objs{} member";
- return nullptr;
+ return false;
}
recipe obj_rule::
- apply (action, target&, const match_result&) const {return empty_recipe;}
+ apply (action, target&) const {return empty_recipe;}
// lib
//
// The whole logic is pretty much as if we had our two group members as
// our prerequisites.
//
+
+ struct match_data
+ {
+ const string& type;
+ };
+
+ static_assert (sizeof (match_data) <= target::data_size,
+ "insufficient space");
+
match_result lib_rule::
match (action act, target& xt, const string&) const
{
@@ -79,7 +88,9 @@ namespace build2
match_only (act, *t.s);
}
- match_result mr (t, &type);
+ t.data (match_data {type}); // Save in the target's auxilary storage.
+
+ match_result mr (true);
// If there is an outer operation, indicate that we match
// unconditionally so that we don't override ourselves.
@@ -91,11 +102,12 @@ namespace build2
}
recipe lib_rule::
- apply (action act, target& xt, const match_result& mr) const
+ apply (action act, target& xt) const
{
lib& t (static_cast<lib&> (xt));
- const string& type (*static_cast<const string*> (mr.cpvalue));
+ const match_data& md (t.data<match_data> ());
+ const string& type (md.type);
bool a (type == "static" || type == "both");
bool s (type == "shared" || type == "both");
@@ -116,12 +128,8 @@ namespace build2
{
lib& t (static_cast<lib&> (xt));
- //@@ Not cool we have to do this again. Looks like we need
- // some kind of a cache vs resolved pointer, like in
- // prerequisite vs prerequisite_target.
- //
- //
- const string& type (cast<string> (t["bin.lib"]));
+ const match_data& md (t.data<match_data> ());
+ const string& type (md.type);
bool a (type == "static" || type == "both");
bool s (type == "shared" || type == "both");