aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-26 23:45:13 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-26 23:45:13 +0100
commit093e74cc37cd5709054144f9dd3a5aefd0f81c67 (patch)
treedb41561df51fa13f4d0b10dba3e075cf4d1d5a7c
parentf08e57966f6080bf8b0f45ef942efea2e2ae392e (diff)
downloadpaludis-093e74cc37cd5709054144f9dd3a5aefd0f81c67.tar.gz
paludis-093e74cc37cd5709054144f9dd3a5aefd0f81c67.tar.xz
Distinguish no vs unknown slot
-rw-r--r--paludis/resolver/resolvent-fwd.hh4
-rw-r--r--paludis/resolver/resolvent.cc130
-rw-r--r--paludis/resolver/resolvent.hh24
-rw-r--r--paludis/resolver/resolver.cc6
-rw-r--r--src/clients/cave/cmd_display_resolution.cc4
5 files changed, 135 insertions, 33 deletions
diff --git a/paludis/resolver/resolvent-fwd.hh b/paludis/resolver/resolvent-fwd.hh
index 5db5297..bde7db0 100644
--- a/paludis/resolver/resolvent-fwd.hh
+++ b/paludis/resolver/resolvent-fwd.hh
@@ -30,14 +30,18 @@ namespace paludis
namespace resolver
{
struct Resolvent;
+ struct SlotNameOrNull;
typedef Sequence<Resolvent> Resolvents;
std::ostream & operator<< (std::ostream &, const Resolvent &) PALUDIS_VISIBLE;
+ std::ostream & operator<< (std::ostream &, const SlotNameOrNull &) PALUDIS_VISIBLE;
bool operator< (const Resolvent &, const Resolvent &) PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
bool operator== (const Resolvent &, const Resolvent &) PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
+ bool operator== (const SlotNameOrNull &, const SlotNameOrNull &) PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
+
Filter make_slot_filter(const Resolvent &) PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
}
}
diff --git a/paludis/resolver/resolvent.cc b/paludis/resolver/resolvent.cc
index 9d30eef..7257efe 100644
--- a/paludis/resolver/resolvent.cc
+++ b/paludis/resolver/resolvent.cc
@@ -39,18 +39,22 @@ paludis::resolver::operator< (const Resolvent & a, const Resolvent & b)
if (a.package() > b.package())
return false;
- /* no slot orders before slot */
- if (a.slot_name_or_null() && b.slot_name_or_null())
+ /* unknown slot orders before no slot orders before slot */
+ if (a.slot().name_or_null() && b.slot().name_or_null())
{
- if (*a.slot_name_or_null() < *b.slot_name_or_null())
+ if (*a.slot().name_or_null() < *b.slot().name_or_null())
return true;
- if (*a.slot_name_or_null() > *b.slot_name_or_null())
+ if (*a.slot().name_or_null() > *b.slot().name_or_null())
return false;
}
- else if (a.slot_name_or_null())
+ else if (a.slot().name_or_null())
return false;
- else if (b.slot_name_or_null())
+ else if (b.slot().name_or_null())
return true;
+ else if (a.slot().null_means_unknown() && ! b.slot().null_means_unknown())
+ return true;
+ else if (! a.slot().null_means_unknown() && b.slot().null_means_unknown())
+ return false;
return a.destination_type() < b.destination_type();
}
@@ -61,13 +65,25 @@ paludis::resolver::operator== (const Resolvent & a, const Resolvent & b)
if (a.package() != b.package())
return false;
- if (a.slot_name_or_null() != b.slot_name_or_null())
+ if (! (a.slot() == b.slot()))
return false;
- if (a.slot_name_or_null() && *a.slot_name_or_null() != *b.slot_name_or_null())
+ if (a.destination_type() != b.destination_type())
return false;
- if (a.destination_type() != b.destination_type())
+ return true;
+}
+
+bool
+paludis::resolver::operator== (const SlotNameOrNull & a, const SlotNameOrNull & b)
+{
+ if (a.name_or_null() != b.name_or_null())
+ return false;
+
+ if ((a.name_or_null()) && (*a.name_or_null() != *b.name_or_null()))
+ return false;
+
+ if ((! a.name_or_null()) && (a.null_means_unknown() != b.null_means_unknown()))
return false;
return true;
@@ -90,21 +106,50 @@ Resolvent::Resolvent(const Resolvent & other) :
Resolvent::Resolvent(
const PackageDepSpec & spec,
- const std::tr1::shared_ptr<const SlotName> & s,
+ const SlotName & s,
const DestinationType t) :
destination_type(value_for<n::destination_type>(t)),
package(value_for<n::package>(*spec.package_ptr())),
- slot_name_or_null(s)
+ slot(make_named_values<SlotNameOrNull>(
+ value_for<n::name_or_null>(make_shared_ptr(new SlotName(s))),
+ value_for<n::null_means_unknown>(false)
+ ))
+{
+}
+
+Resolvent::Resolvent(
+ const PackageDepSpec & spec,
+ const bool b,
+ const DestinationType t) :
+ destination_type(value_for<n::destination_type>(t)),
+ package(value_for<n::package>(*spec.package_ptr())),
+ slot(make_named_values<SlotNameOrNull>(
+ value_for<n::name_or_null>(make_null_shared_ptr()),
+ value_for<n::null_means_unknown>(b)
+ ))
{
}
Resolvent::Resolvent(
const QualifiedPackageName & n,
- const std::tr1::shared_ptr<const SlotName> & s,
+ const SlotName & s,
const DestinationType t) :
destination_type(value_for<n::destination_type>(t)),
package(value_for<n::package>(n)),
- slot_name_or_null(s)
+ slot(make_named_values<SlotNameOrNull>(
+ value_for<n::name_or_null>(make_shared_ptr(new SlotName(s))),
+ value_for<n::null_means_unknown>(false)
+ ))
+{
+}
+
+Resolvent::Resolvent(
+ const QualifiedPackageName & n,
+ const SlotNameOrNull & s,
+ const DestinationType t) :
+ destination_type(value_for<n::destination_type>(t)),
+ package(value_for<n::package>(n)),
+ slot(s)
{
}
@@ -113,7 +158,12 @@ Resolvent::Resolvent(
const DestinationType t) :
destination_type(value_for<n::destination_type>(t)),
package(id->name()),
- slot_name_or_null(id->slot_key() ? make_shared_ptr(new SlotName(id->slot_key()->value())) : make_null_shared_ptr())
+ slot(make_named_values<SlotNameOrNull>(
+ value_for<n::name_or_null>(id->slot_key() ?
+ make_shared_ptr(new SlotName(id->slot_key()->value())) :
+ make_null_shared_ptr()),
+ value_for<n::null_means_unknown>(false)
+ ))
{
}
@@ -123,7 +173,7 @@ Resolvent::serialise(Serialiser & s) const
s.object("Resolvent")
.member(SerialiserFlags<>(), "destination_type", stringify(destination_type()))
.member(SerialiserFlags<>(), "package", stringify(package()))
- .member(SerialiserFlags<>(), "slot", slot_name_or_null() ? stringify(*slot_name_or_null()) : "")
+ .member(SerialiserFlags<>(), "slot", slot())
;
}
@@ -132,11 +182,9 @@ Resolvent::deserialise(Deserialisation & d)
{
Deserialisator v(d, "Resolvent");
- std::string s(v.member<std::string>("slot"));
-
return Resolvent(
QualifiedPackageName(v.member<std::string>("package")),
- s.empty() ? make_null_shared_ptr() : make_shared_ptr(new SlotName(s)),
+ v.member<SlotNameOrNull>("slot"),
destringify<DestinationType>(v.member<std::string>("destination_type"))
);
}
@@ -144,24 +192,56 @@ Resolvent::deserialise(Deserialisation & d)
Filter
paludis::resolver::make_slot_filter(const Resolvent & r)
{
- if (r.slot_name_or_null())
- return filter::Slot(*r.slot_name_or_null());
+ if (r.slot().name_or_null())
+ return filter::Slot(*r.slot().name_or_null());
+ else if (r.slot().null_means_unknown())
+ return filter::All();
else
return filter::NoSlot();
}
std::ostream &
-paludis::resolver::operator<< (std::ostream & s, const Resolvent & r)
+paludis::resolver::operator<< (std::ostream & s, const SlotNameOrNull & n)
{
- s << r.package();
- if (r.slot_name_or_null())
- s << ":" << *r.slot_name_or_null();
+ if (n.name_or_null())
+ s << ":" << *n.name_or_null();
+ else if (n.null_means_unknown())
+ s << ":(unknown)";
else
s << ":(no slot)";
- s << " -> " << r.destination_type();
return s;
}
+std::ostream &
+paludis::resolver::operator<< (std::ostream & s, const Resolvent & r)
+{
+ s << r.package() << r.slot() << s << " -> " << r.destination_type();
+ return s;
+}
+
+void
+SlotNameOrNull::serialise(Serialiser & s) const
+{
+ s.object("SlotNameOrNull")
+ .member(SerialiserFlags<>(), "name_or_null", name_or_null() ? stringify(*name_or_null()) : "")
+ .member(SerialiserFlags<>(), "null_means_unknown", null_means_unknown())
+ ;
+}
+
+const SlotNameOrNull
+SlotNameOrNull::deserialise(Deserialisation & d)
+{
+ Deserialisator v(d, "SlotNameOrNull");
+
+ std::string s(v.member<std::string>("name_or_null"));
+
+ return make_named_values<SlotNameOrNull>(
+ value_for<n::name_or_null>(s.empty() ? make_null_shared_ptr() : make_shared_ptr(new SlotName(s))),
+ value_for<n::null_means_unknown>(v.member<bool>("null_means_unknown"))
+ );
+}
+
+
template class Sequence<Resolvent>;
template class WrappedForwardIterator<Resolvents::ConstIteratorTag, Resolvent>;
diff --git a/paludis/resolver/resolvent.hh b/paludis/resolver/resolvent.hh
index f028c44..77c0238 100644
--- a/paludis/resolver/resolvent.hh
+++ b/paludis/resolver/resolvent.hh
@@ -34,21 +34,37 @@ namespace paludis
namespace n
{
struct destination_type;
+ struct name_or_null;
+ struct null_means_unknown;
struct package;
- struct slot_name_or_null;
+ struct slot;
}
namespace resolver
{
+ struct SlotNameOrNull
+ {
+ NamedValue<n::name_or_null, std::tr1::shared_ptr<const SlotName> > name_or_null;
+ NamedValue<n::null_means_unknown, bool> null_means_unknown;
+
+ void serialise(Serialiser &) const;
+ static const SlotNameOrNull deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
struct Resolvent
{
NamedValue<n::destination_type, DestinationType> destination_type;
NamedValue<n::package, QualifiedPackageName> package;
- NamedValue<n::slot_name_or_null, std::tr1::shared_ptr<const SlotName> > slot_name_or_null;
+ NamedValue<n::slot, SlotNameOrNull> slot;
Resolvent(const Resolvent &);
- Resolvent(const QualifiedPackageName &, const std::tr1::shared_ptr<const SlotName> &, const DestinationType);
- Resolvent(const PackageDepSpec &, const std::tr1::shared_ptr<const SlotName> &, const DestinationType);
+
+ Resolvent(const QualifiedPackageName &, const SlotName &, const DestinationType);
+ Resolvent(const QualifiedPackageName &, const SlotNameOrNull &, const DestinationType);
+
+ Resolvent(const PackageDepSpec &, const bool, const DestinationType);
+ Resolvent(const PackageDepSpec &, const SlotName &, const DestinationType);
+
Resolvent(const std::tr1::shared_ptr<const PackageID> &, const DestinationType);
void serialise(Serialiser &) const;
diff --git a/paludis/resolver/resolver.cc b/paludis/resolver/resolver.cc
index 3bfb2e8..fb4b141 100644
--- a/paludis/resolver/resolver.cc
+++ b/paludis/resolver/resolver.cc
@@ -1324,7 +1324,7 @@ Resolver::_get_resolvents_for_blocker(const BlockDepSpec & spec) const
{
for (EnumIterator<DestinationType> t, t_end(last_dt) ; t != t_end ; ++t)
if (destination_types[*t])
- result->push_back(Resolvent(spec.blocking(), exact_slot, *t));
+ result->push_back(Resolvent(spec.blocking(), *exact_slot, *t));
}
else
{
@@ -1368,7 +1368,7 @@ Resolver::_get_resolvents_for(
DestinationTypes destination_types(_get_destination_types_for(spec, reason));
for (EnumIterator<DestinationType> t, t_end(last_dt) ; t != t_end ; ++t)
if (destination_types[*t])
- result->push_back(Resolvent(spec, exact_slot, *t));
+ result->push_back(Resolvent(spec, *exact_slot, *t));
return result;
}
else
@@ -1393,7 +1393,7 @@ Resolver::_get_error_resolvents_for(
DestinationTypes destination_types(_get_destination_types_for(spec, reason));
for (EnumIterator<DestinationType> t, t_end(last_dt) ; t != t_end ; ++t)
if (destination_types[*t])
- result->push_back(Resolvent(spec, make_null_shared_ptr(), *t));
+ result->push_back(Resolvent(spec, true, *t));
return result;
}
diff --git a/src/clients/cave/cmd_display_resolution.cc b/src/clients/cave/cmd_display_resolution.cc
index ada3ac7..f60ab5f 100644
--- a/src/clients/cave/cmd_display_resolution.cc
+++ b/src/clients/cave/cmd_display_resolution.cc
@@ -299,7 +299,9 @@ namespace
const std::tr1::shared_ptr<const Resolution> & resolution,
const bool verbose)
{
- if (resolution->resolvent().slot_name_or_null())
+ if (resolution->resolvent().slot().name_or_null())
+ cout << "? " << c::bold_red() << resolution->resolvent() << c::normal();
+ else if (! resolution->resolvent().slot().null_means_unknown())
cout << "? " << c::bold_red() << resolution->resolvent() << c::normal();
else
cout << "? " << c::bold_red() << resolution->resolvent().package()