aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-14 22:46:37 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-14 22:46:37 +0100
commit0d18bf226d035dacaacf65b396ed2e126157d600 (patch)
treee1334b812107656d51c780e1249d16ae554cae3f
parent32b30e632c1513656b74243893e8508d0ced6b8a (diff)
downloadpaludis-0d18bf226d035dacaacf65b396ed2e126157d600.tar.gz
paludis-0d18bf226d035dacaacf65b396ed2e126157d600.tar.xz
Defer choice checks
-rw-r--r--paludis/match_package.cc36
1 files changed, 26 insertions, 10 deletions
diff --git a/paludis/match_package.cc b/paludis/match_package.cc
index 74d2ded..9fe5dad 100644
--- a/paludis/match_package.cc
+++ b/paludis/match_package.cc
@@ -44,6 +44,7 @@
#include <algorithm>
#include <istream>
#include <ostream>
+#include <list>
using namespace paludis;
@@ -54,13 +55,22 @@ namespace
struct RequirementChecker
{
const Environment & env;
- const ChangedChoices * const maybe_changes_to_owner;
const std::shared_ptr<const PackageID> & id;
- const std::shared_ptr<const PackageID> & from_id;
- const ChangedChoices * const maybe_changes_to_target;
const MatchPackageOptions & options;
bool version_requirements_ok;
+ std::list<const ChoiceRequirement *> defer_choice_requirements;
+
+ RequirementChecker(
+ const Environment & e,
+ const std::shared_ptr<const PackageID> & i,
+ const MatchPackageOptions & o) :
+ env(e),
+ id(i),
+ options(o),
+ version_requirements_ok(true)
+ {
+ }
bool visit(const NameRequirement & r)
{
@@ -179,11 +189,8 @@ namespace
bool visit(const ChoiceRequirement & r)
{
- if (options[mpo_ignore_choice_requirements])
- return true;
-
- if (! r.requirement_met(&env, maybe_changes_to_owner, id, from_id, maybe_changes_to_target).first)
- return false;
+ if (! options[mpo_ignore_choice_requirements])
+ defer_choice_requirements.push_back(&r);
return true;
}
@@ -208,14 +215,23 @@ paludis::match_package_with_maybe_changes(
const ChangedChoices * const maybe_changes_to_target,
const MatchPackageOptions & options)
{
- RequirementChecker c{env, maybe_changes_to_owner, id, from_id, maybe_changes_to_target, options, true};
+ RequirementChecker c{env, id, options};
for (auto r(spec.requirements()->begin()), r_end(spec.requirements()->end()) ;
r != r_end ; ++r)
if (! (*r)->accept_returning<bool>(c))
return false;
- return c.version_requirements_ok;
+ if (! c.version_requirements_ok)
+ return false;
+
+
+ for (auto r(c.defer_choice_requirements.begin()), r_end(c.defer_choice_requirements.end()) ;
+ r != r_end ; ++r)
+ if (! (*r)->requirement_met(&env, maybe_changes_to_owner, id, from_id, maybe_changes_to_target).first)
+ return false;
+
+ return true;
}
bool