aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-18 20:10:45 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-18 20:10:45 +0100
commitbb06c0f5ac5e7fe01e5ab0a957bc310179eb5bab (patch)
treec929cf1b4e92d8d0ec0b63045dd260700f170ed9 /python
parent537036d40b9142858d2cf863a5d143498e927640 (diff)
downloadpaludis-bb06c0f5ac5e7fe01e5ab0a957bc310179eb5bab.tar.gz
paludis-bb06c0f5ac5e7fe01e5ab0a957bc310179eb5bab.tar.xz
Don't hold versions, keys, choices in a sequence
Diffstat (limited to 'python')
-rw-r--r--python/dep_spec.cc27
1 files changed, 24 insertions, 3 deletions
diff --git a/python/dep_spec.cc b/python/dep_spec.cc
index 318fa9153..20e6899b4 100644
--- a/python/dep_spec.cc
+++ b/python/dep_spec.cc
@@ -40,6 +40,7 @@
#include <paludis/util/sequence-impl.hh>
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/accept_visitor.hh>
+#include <paludis/util/visitor_cast.hh>
#include <type_traits>
#include <list>
@@ -223,19 +224,39 @@ deep_copy(const std::shared_ptr<const T_> & x)
return std::shared_ptr<T_>();
}
+namespace
+{
+ template <typename T_>
+ std::shared_ptr<Sequence<std::shared_ptr<const T_> > > get_requirements(const std::shared_ptr<const PackageDepSpecRequirementSequence> & s)
+ {
+ auto result(std::make_shared<Sequence<std::shared_ptr<const T_> > >());
+ for (auto i(s->begin()), i_end(s->end()) ;
+ i != i_end ; ++i)
+ {
+ auto v(visitor_cast<const T_>(**i));
+ if (! v)
+ continue;
+
+ result->push_back(std::static_pointer_cast<const T_>(*i));
+ }
+
+ return result;
+ }
+}
+
PythonPackageDepSpec::PythonPackageDepSpec(const PackageDepSpec & p) :
PythonStringDepSpec(p.text()),
_imp(
p.package_name_requirement(),
p.category_name_part_requirement(),
p.package_name_part_requirement(),
- p.all_version_requirements(),
+ get_requirements<VersionRequirement>(p.requirements()),
p.any_slot_requirement(),
p.exact_slot_requirement(),
p.in_repository_requirement(),
p.from_repository_requirement(),
- p.all_key_requirements(),
- p.all_choice_requirements(),
+ get_requirements<KeyRequirement>(p.requirements()),
+ get_requirements<ChoiceRequirement>(p.requirements()),
stringify(p))
{
}