aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-06-19 20:06:48 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-06-19 20:06:48 +0100
commit6735424d05fb20755b670b8be30adadb112aa6e1 (patch)
treec4c5a6df99e48d9d4fdce2071928797027d913aa
parent86ec24031e3178a56dbc381916704dc0aba5bf75 (diff)
downloadpaludis-6735424d05fb20755b670b8be30adadb112aa6e1.tar.gz
paludis-6735424d05fb20755b670b8be30adadb112aa6e1.tar.xz
Lots of bools is icky
-rw-r--r--paludis/resolver/Makefile.am11
-rw-r--r--paludis/resolver/decider.cc86
-rw-r--r--paludis/resolver/decision-fwd.hh8
-rw-r--r--paludis/resolver/decision.cc52
-rw-r--r--paludis/resolver/decision.hh10
-rw-r--r--paludis/resolver/decision.se16
-rw-r--r--paludis/resolver/get_sameness-fwd.hh4
-rw-r--r--paludis/resolver/get_sameness.cc9
-rw-r--r--src/clients/cave/cmd_resolve_dump.cc14
9 files changed, 93 insertions, 117 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index 825b68e..1e7e144 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -3,6 +3,7 @@ include $(top_srcdir)/misc/common-makefile.am
DISTCLEANFILES = \
any_child_score-se.hh any_child_score-se.cc \
change_type-se.hh change_type-se.cc \
+ decision-se.hh decision-se.cc \
destination_types-se.hh destination_types-se.cc \
job_requirements-se.hh job_requirements-se.cc \
nag-se.hh nag-se.cc \
@@ -12,6 +13,7 @@ AM_CXXFLAGS = -I$(top_srcdir) @PALUDIS_CXXFLAGS@ @PALUDIS_CXXFLAGS_VISIBILITY@
EXTRA_DIST = \
any_child_score-se.hh any_child_score-se.cc any_child_score.se \
change_type-se.hh change_type-se.cc change_type.se \
+ decision-se.hh decision-se.cc decision.se \
destination_types-se.hh destination_types-se.cc destination_types.se \
job_requirements-se.hh job_requirements-se.cc job_requirements.se \
nag-se.hh nag-se.cc nag.se \
@@ -21,6 +23,7 @@ EXTRA_DIST = \
BUILT_SOURCES = \
any_child_score-se.hh any_child_score-se.cc \
change_type-se.hh change_type-se.cc \
+ decision-se.hh decision-se.cc \
destination_types-se.hh destination_types-se.cc \
nag-se.hh nag-se.cc \
job_requirements-se.hh job_requirements-se.cc \
@@ -44,7 +47,7 @@ noinst_HEADERS = \
confirm_helper.hh confirm_helper-fwd.hh \
constraint.hh constraint-fwd.hh \
decider.hh decider-fwd.hh \
- decision.hh decision-fwd.hh \
+ decision.hh decision-fwd.hh decision-se.hh \
decision_utils.hh decision_utils-fwd.hh \
decisions.hh decisions-fwd.hh \
destination.hh destination-fwd.hh \
@@ -405,3 +408,9 @@ nag-se.hh : nag.se $(top_srcdir)/misc/make_se.bash
nag-se.cc : nag.se $(top_srcdir)/misc/make_se.bash
if ! $(top_srcdir)/misc/make_se.bash --source $(srcdir)/nag.se > $@ ; then rm -f $@ ; exit 1 ; fi
+decision-se.hh : decision.se $(top_srcdir)/misc/make_se.bash
+ if ! $(top_srcdir)/misc/make_se.bash --header $(srcdir)/decision.se > $@ ; then rm -f $@ ; exit 1 ; fi
+
+decision-se.cc : decision.se $(top_srcdir)/misc/make_se.bash
+ if ! $(top_srcdir)/misc/make_se.bash --source $(srcdir)/decision.se > $@ ; then rm -f $@ ; exit 1 ; fi
+
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index 9b916dd..758b47c 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -718,29 +718,14 @@ namespace
case ue_if_possible:
break;
- case ue_only_if_transient:
- if (! decision.is_transient())
- return false;
- break;
-
- case ue_if_same:
- if (! decision.is_same())
- return false;
- break;
-
- case ue_if_same_metadata:
- if (! decision.is_same_metadata())
- return false;
- break;
-
- case ue_if_same_version:
- if (! decision.is_same_version())
- return false;
- break;
-
case ue_never:
case last_ue:
return false;
+
+ case ue_only_if_transient: if (! decision.attributes()[epia_is_transient]) return false; break;
+ case ue_if_same: if (! decision.attributes()[epia_is_same]) return false; break;
+ case ue_if_same_metadata: if (! decision.attributes()[epia_is_same_metadata]) return false; break;
+ case ue_if_same_version: if (! decision.attributes()[epia_is_same_version]) return false; break;
}
return true;
@@ -1454,6 +1439,15 @@ Decider::_get_error_resolvents_for(
return result;
}
+namespace
+{
+ ExistingPackageIDAttributes existing_package_id_attributes_for_no_installable_id(bool is_transient)
+ {
+ return ExistingPackageIDAttributes({ epia_is_same, epia_is_same_metadata, epia_is_same_version }) |
+ (is_transient ? ExistingPackageIDAttributes({ epia_is_transient }) : ExistingPackageIDAttributes({ }));
+ }
+}
+
const std::shared_ptr<Decision>
Decider::_try_to_find_decision_for(
const std::shared_ptr<const Resolution> & resolution,
@@ -1528,10 +1522,7 @@ Decider::_try_to_find_decision_for(
return std::make_shared<ExistingNoChangeDecision>(
resolution->resolvent(),
existing_id,
- true,
- true,
- true,
- is_transient,
+ existing_package_id_attributes_for_no_installable_id(is_transient),
! resolution->constraints()->all_untaken()
);
}
@@ -1555,19 +1546,15 @@ Decider::_try_to_find_decision_for(
}
else if (existing_id && installable_id)
{
- bool is_same_version, is_same, is_same_metadata;
- std::tie(is_same_version, is_same, is_same_metadata) = get_sameness(existing_id, installable_id);
-
- bool is_transient(has_behaviour(existing_id, "transient"));
+ ExistingPackageIDAttributes existing_package_id_attributes(get_sameness(existing_id, installable_id));
+ if (has_behaviour(existing_id, "transient"))
+ existing_package_id_attributes += epia_is_transient;
/* we've got existing and installable. do we have any reason not to pick the existing id? */
const std::shared_ptr<Decision> existing(std::make_shared<ExistingNoChangeDecision>(
resolution->resolvent(),
existing_id,
- is_same_metadata,
- is_same,
- is_same_version,
- is_transient,
+ existing_package_id_attributes,
! resolution->constraints()->all_untaken()
));
const std::shared_ptr<Decision> changes_to_make(std::make_shared<ChangesToMakeDecision>(
@@ -1583,30 +1570,12 @@ Decider::_try_to_find_decision_for(
switch (resolution->constraints()->strictest_use_existing())
{
- case ue_only_if_transient:
- case ue_never:
- return changes_to_make;
-
- case ue_if_same_metadata:
- if (is_same_metadata)
- return existing;
- else
- return changes_to_make;
-
- case ue_if_same:
- if (is_same)
- return existing;
- else
- return changes_to_make;
-
- case ue_if_same_version:
- if (is_same_version)
- return existing;
- else
- return changes_to_make;
-
- case ue_if_possible:
- return existing;
+ case ue_only_if_transient: return changes_to_make;
+ case ue_never: return changes_to_make;
+ case ue_if_same_metadata: return existing_package_id_attributes[epia_is_same_metadata] ? existing : changes_to_make;
+ case ue_if_same: return existing_package_id_attributes[epia_is_same] ? existing : changes_to_make;
+ case ue_if_same_version: return existing_package_id_attributes[epia_is_same_version] ? existing : changes_to_make;
+ case ue_if_possible: return existing;
case last_ue:
break;
@@ -1849,10 +1818,7 @@ Decider::_get_unmatching_constraints(
decision = std::make_shared<ExistingNoChangeDecision>(
resolution->resolvent(),
id,
- true,
- true,
- true,
- is_transient,
+ existing_package_id_attributes_for_no_installable_id(is_transient),
! (*c)->untaken()
);
}
diff --git a/paludis/resolver/decision-fwd.hh b/paludis/resolver/decision-fwd.hh
index 3e1ce58..6ddc1d4 100644
--- a/paludis/resolver/decision-fwd.hh
+++ b/paludis/resolver/decision-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009, 2010 Ciaran McCreesh
+ * Copyright (c) 2009, 2010, 2011 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -21,6 +21,8 @@
#define PALUDIS_GUARD_PALUDIS_RESOLVER_DECISION_FWD_HH 1
#include <paludis/util/attributes.hh>
+#include <paludis/util/options-fwd.hh>
+
#include <iosfwd>
namespace paludis
@@ -37,6 +39,10 @@ namespace paludis
class ChangesToMakeDecision;
class RemoveDecision;
class BreakDecision;
+
+#include <paludis/resolver/decision-se.hh>
+
+ typedef Options<ExistingPackageIDAttribute> ExistingPackageIDAttributes;
}
}
diff --git a/paludis/resolver/decision.cc b/paludis/resolver/decision.cc
index 5dc3745..10661c0 100644
--- a/paludis/resolver/decision.cc
+++ b/paludis/resolver/decision.cc
@@ -37,6 +37,8 @@
using namespace paludis;
using namespace paludis::resolver;
+#include <paludis/resolver/decision-se.cc>
+
Decision::~Decision() = default;
const std::shared_ptr<Decision>
@@ -56,10 +58,7 @@ Decision::deserialise(Deserialisation & d)
return std::make_shared<ExistingNoChangeDecision>(
v.member<Resolvent>("resolvent"),
v.member<std::shared_ptr<const PackageID> >("existing_id"),
- v.member<bool>("is_same_metadata"),
- v.member<bool>("is_same"),
- v.member<bool>("is_same_version"),
- v.member<bool>("is_transient"),
+ v.member<ExistingPackageIDAttributes>("attributes"),
v.member<bool>("taken")
);
}
@@ -250,21 +249,15 @@ namespace paludis
{
const Resolvent resolvent;
const std::shared_ptr<const PackageID> existing_id;
- const bool is_same_metadata;
- const bool is_same;
- const bool is_same_version;
- const bool is_transient;
+ const ExistingPackageIDAttributes attributes;
const bool taken;
Imp(const Resolvent & l,
const std::shared_ptr<const PackageID> & e,
- const bool m, const bool s, const bool v, const bool r, const bool t) :
+ const ExistingPackageIDAttributes & a, const bool t) :
resolvent(l),
existing_id(e),
- is_same_metadata(m),
- is_same(s),
- is_same_version(v),
- is_transient(r),
+ attributes(a),
taken(t)
{
}
@@ -272,8 +265,8 @@ namespace paludis
}
ExistingNoChangeDecision::ExistingNoChangeDecision(const Resolvent & l, const std::shared_ptr<const PackageID> & e,
- const bool m, const bool s, const bool v, const bool r, const bool t) :
- _imp(l, e, m, s, v, r, t)
+ const ExistingPackageIDAttributes & a, const bool t) :
+ _imp(l, e, a, t)
{
}
@@ -285,28 +278,10 @@ ExistingNoChangeDecision::existing_id() const
return _imp->existing_id;
}
-bool
-ExistingNoChangeDecision::is_same_metadata() const
-{
- return _imp->is_same_metadata;
-}
-
-bool
-ExistingNoChangeDecision::is_same() const
-{
- return _imp->is_same;
-}
-
-bool
-ExistingNoChangeDecision::is_same_version() const
-{
- return _imp->is_same_version;
-}
-
-bool
-ExistingNoChangeDecision::is_transient() const
+const ExistingPackageIDAttributes
+ExistingNoChangeDecision::attributes() const
{
- return _imp->is_transient;
+ return _imp->attributes;
}
const Resolvent
@@ -327,10 +302,7 @@ ExistingNoChangeDecision::serialise(Serialiser & s) const
s.object("ExistingNoChangeDecision")
.member(SerialiserFlags<>(), "resolvent", resolvent())
.member(SerialiserFlags<serialise::might_be_null>(), "existing_id", existing_id())
- .member(SerialiserFlags<>(), "is_same_metadata", is_same_metadata())
- .member(SerialiserFlags<>(), "is_same", is_same())
- .member(SerialiserFlags<>(), "is_same_version", is_same_version())
- .member(SerialiserFlags<>(), "is_transient", is_transient())
+ .member(SerialiserFlags<>(), "attributes", attributes())
.member(SerialiserFlags<>(), "taken", taken())
;
}
diff --git a/paludis/resolver/decision.hh b/paludis/resolver/decision.hh
index b39e20b..f6be49a 100644
--- a/paludis/resolver/decision.hh
+++ b/paludis/resolver/decision.hh
@@ -85,10 +85,7 @@ namespace paludis
ExistingNoChangeDecision(
const Resolvent &,
const std::shared_ptr<const PackageID> &,
- const bool is_same_metadata,
- const bool is_same,
- const bool is_same_version,
- const bool is_transient,
+ const ExistingPackageIDAttributes &,
const bool taken
);
~ExistingNoChangeDecision();
@@ -96,10 +93,7 @@ namespace paludis
const std::shared_ptr<const PackageID> existing_id() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- bool is_same_metadata() const PALUDIS_ATTRIBUTE((warn_unused_result));
- bool is_same() const PALUDIS_ATTRIBUTE((warn_unused_result));
- bool is_same_version() const PALUDIS_ATTRIBUTE((warn_unused_result));
- bool is_transient() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const ExistingPackageIDAttributes attributes() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const Resolvent resolvent() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual bool taken() const PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/paludis/resolver/decision.se b/paludis/resolver/decision.se
new file mode 100644
index 0000000..576f5ad
--- /dev/null
+++ b/paludis/resolver/decision.se
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+# vim: set sw=4 sts=4 et ft=sh :
+
+make_enum_ExistingPackageIDAttribute()
+{
+ prefix epia
+ namespace paludis::resolver
+
+ key epia_is_same_metadata "Same, including metadata"
+ key epia_is_same "Same, including choices"
+ key epia_is_same_version "Same version"
+ key epia_is_transient "Is transient"
+
+ want_destringify
+}
+
diff --git a/paludis/resolver/get_sameness-fwd.hh b/paludis/resolver/get_sameness-fwd.hh
index c5ed22f..d5bdca8 100644
--- a/paludis/resolver/get_sameness-fwd.hh
+++ b/paludis/resolver/get_sameness-fwd.hh
@@ -21,15 +21,15 @@
#define PALUDIS_GUARD_PALUDIS_RESOLVER_GET_SAMENESS_FWD_HH 1
#include <paludis/util/attributes.hh>
+#include <paludis/resolver/decision-fwd.hh>
#include <paludis/package_id-fwd.hh>
-#include <tuple>
#include <memory>
namespace paludis
{
namespace resolver
{
- std::tuple<bool, bool, bool>
+ ExistingPackageIDAttributes
get_sameness(
const std::shared_ptr<const PackageID> & existing_id,
const std::shared_ptr<const PackageID> & installable_id) PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/paludis/resolver/get_sameness.cc b/paludis/resolver/get_sameness.cc
index 8ed6d00..dfb68f3 100644
--- a/paludis/resolver/get_sameness.cc
+++ b/paludis/resolver/get_sameness.cc
@@ -79,7 +79,7 @@ namespace
}
}
-std::tuple<bool, bool, bool>
+ExistingPackageIDAttributes
paludis::resolver::get_sameness(
const std::shared_ptr<const PackageID> & existing_id,
const std::shared_ptr<const PackageID> & installable_id)
@@ -152,6 +152,11 @@ paludis::resolver::get_sameness(
is_same_metadata = is_same_metadata && is_same_dependencies(existing_id->dependencies_key(), installable_id->dependencies_key());
}
- return std::make_tuple(is_same_version, is_same, is_same_metadata);
+ ExistingPackageIDAttributes attrs;
+ if (is_same_version) attrs += epia_is_same_version;
+ if (is_same) attrs += epia_is_same;
+ if (is_same_metadata) attrs += epia_is_same_metadata;
+
+ return attrs;
}
diff --git a/src/clients/cave/cmd_resolve_dump.cc b/src/clients/cave/cmd_resolve_dump.cc
index c77c155..ee31dde 100644
--- a/src/clients/cave/cmd_resolve_dump.cc
+++ b/src/clients/cave/cmd_resolve_dump.cc
@@ -97,9 +97,17 @@ namespace
const std::string visit(const ExistingNoChangeDecision & d) const
{
- return "ExistingNoChangeDecision(" + stringify(*d.existing_id()) + " is_same: "
- + stringify(d.is_same()) + " is_same_version: " + stringify(d.is_same_version())
- + " is_transient: " + stringify(d.is_transient()) + " taken: " + stringify(d.taken()) + ")";
+ std::string attrs;
+ for (EnumIterator<ExistingPackageIDAttribute> t, t_end(last_epia) ; t != t_end ; ++t)
+ if (d.attributes()[*t])
+ {
+ if (! attrs.empty())
+ attrs += ", ";
+ attrs += stringify(*t);
+ }
+
+ return "ExistingNoChangeDecision(" + stringify(*d.existing_id()) + " " +
+ attrs + " taken: " + stringify(d.taken()) + ")";
}
const std::string visit(const ChangesToMakeDecision & d) const