diff options
author | 2009-01-09 13:46:00 +0000 | |
---|---|---|
committer | 2009-01-09 13:46:00 +0000 | |
commit | 4231af5178d647d8ad932decfcf6a437bec63365 (patch) | |
tree | bb0d7168d1aff08b6c087bd1aca0f42f8a33e1ed /paludis | |
parent | 6cf45c1cfa4bf675095a244693b9dbfd5e08daca (diff) | |
download | paludis-4231af5178d647d8ad932decfcf6a437bec63365.tar.gz paludis-4231af5178d647d8ad932decfcf6a437bec63365.tar.xz |
New easier tree visitors
Diffstat (limited to 'paludis')
203 files changed, 2939 insertions, 6209 deletions
diff --git a/paludis/action.cc b/paludis/action.cc index d8fcf2437..dbe4e27e2 100644 --- a/paludis/action.cc +++ b/paludis/action.cc @@ -22,6 +22,7 @@ #include <paludis/util/exception.hh> #include <paludis/util/stringify.hh> #include <paludis/util/sequence-impl.hh> +#include <paludis/util/wrapped_forward_iterator-impl.hh> using namespace paludis; @@ -281,4 +282,5 @@ template class PrivateImplementationPattern<PretendFetchAction>; template class PrivateImplementationPattern<UninstallAction>; template class Sequence<FetchActionFailure>; +template class WrappedForwardIterator<Sequence<FetchActionFailure>::ConstIteratorTag, const FetchActionFailure>; diff --git a/paludis/args/args_dumper.cc b/paludis/args/args_dumper.cc index d2b6d01dd..82bc6ed20 100644 --- a/paludis/args/args_dumper.cc +++ b/paludis/args/args_dumper.cc @@ -19,7 +19,6 @@ #include <paludis/args/args_dumper.hh> #include <paludis/args/args_option.hh> -#include <paludis/util/visitor-impl.hh> #include <sstream> diff --git a/paludis/args/args_handler.cc b/paludis/args/args_handler.cc index 44dd36a1e..723e2eccd 100644 --- a/paludis/args/args_handler.cc +++ b/paludis/args/args_handler.cc @@ -22,10 +22,11 @@ #include <paludis/util/system.hh> #include <paludis/util/join.hh> #include <paludis/util/private_implementation_pattern-impl.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/wrapped_forward_iterator-impl.hh> #include <paludis/util/wrapped_output_iterator-impl.hh> #include <paludis/util/create_iterator-impl.hh> +#include <paludis/util/indirect_iterator-impl.hh> +#include <paludis/util/accept_visitor.hh> #include <algorithm> #include <sstream> #include <list> diff --git a/paludis/args/args_option.cc b/paludis/args/args_option.cc index 6935fd7e9..d1ecb3346 100644 --- a/paludis/args/args_option.cc +++ b/paludis/args/args_option.cc @@ -21,7 +21,6 @@ #include "args_error.hh" #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/wrapped_forward_iterator-impl.hh> -#include <paludis/util/visitor-impl.hh> #include <set> #include <vector> #include <algorithm> diff --git a/paludis/args/args_visitor.cc b/paludis/args/args_visitor.cc index ec28a051b..607750f29 100644 --- a/paludis/args/args_visitor.cc +++ b/paludis/args/args_visitor.cc @@ -20,8 +20,6 @@ #include "args_error.hh" #include "bad_argument.hh" -#include <paludis/util/visitor.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/destringify.hh> #include <paludis/util/system.hh> #include <paludis/util/join.hh> diff --git a/paludis/args/man.cc b/paludis/args/man.cc index 7fb1d4bd2..76a6f9df2 100644 --- a/paludis/args/man.cc +++ b/paludis/args/man.cc @@ -18,8 +18,8 @@ */ #include "man.hh" -#include <paludis/util/visitor-impl.hh> #include <paludis/util/simple_visitor_cast.hh> +#include <paludis/util/wrapped_forward_iterator-impl.hh> #include <tr1/functional> #include <ostream> #include <sstream> diff --git a/paludis/condition_tracker.cc b/paludis/condition_tracker.cc deleted file mode 100644 index 1125baa52..000000000 --- a/paludis/condition_tracker.cc +++ /dev/null @@ -1,147 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007 David Leverton - * - * 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 - * Public License version 2, as published by the Free Software Foundation. - * - * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <paludis/condition_tracker.hh> -#include <paludis/util/stringify.hh> -#include <paludis/util/visitor-impl.hh> -#include <paludis/dep_spec.hh> -#include <paludis/dep_label.hh> - -using namespace paludis; -using namespace std::tr1::placeholders; - -ConditionTracker::ConditionTracker( - std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > conditions) : - base(new ConstTreeSequence<DependencySpecTree, AllDepSpec>( - std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))), - adder(std::tr1::bind(&ConstTreeSequence<DependencySpecTree, AllDepSpec>::add, base.get(), _1)) -{ - conditions->accept(*this); -} - -ConditionTracker::~ConditionTracker() -{ -} - -template <typename T_> -std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > -ConditionTracker::do_add_sequence(const T_ & node) -{ - adder(std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, T_> >( - new ConstTreeSequence<DependencySpecTree, T_>( - std::tr1::static_pointer_cast<T_>(node.clone())))); - return base; -} - -template <typename T_> -std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > -ConditionTracker::do_add_leaf(const T_ & node) -{ - adder(std::tr1::shared_ptr<TreeLeaf<DependencySpecTree, T_> >( - new TreeLeaf<DependencySpecTree, T_>( - std::tr1::static_pointer_cast<T_>(node.clone())))); - return base; -} - -std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > -ConditionTracker::add_condition(const AnyDepSpec & any) -{ - return do_add_sequence(any); -} - -std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > -ConditionTracker::add_condition(const ConditionalDepSpec & use) -{ - return do_add_sequence(use); -} - -std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > -ConditionTracker::add_condition(const PackageDepSpec & pkg) -{ - return do_add_leaf(pkg); -} - -std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > -ConditionTracker::add_condition(const BlockDepSpec & block) -{ - return do_add_leaf(block); -} - -template <typename T_> -void -ConditionTracker::do_visit_sequence(const T_ & node, - DependencySpecTree::ConstSequenceIterator begin, - DependencySpecTree::ConstSequenceIterator end) -{ - std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, T_> > a( - new ConstTreeSequence<DependencySpecTree, T_>( - std::tr1::static_pointer_cast<T_>(node.clone()))); - adder(a); - adder = std::tr1::bind(&ConstTreeSequence<DependencySpecTree, T_>::add, a.get(), _1); - if (begin != end) - { - begin->accept(*this); - if (++begin != end) - throw InternalError(PALUDIS_HERE, "ConditionTracker saw a sequence with more than one element"); - } -} - -void -ConditionTracker::visit_sequence(const AnyDepSpec & node, - DependencySpecTree::ConstSequenceIterator begin, - DependencySpecTree::ConstSequenceIterator end) -{ - do_visit_sequence(node, begin, end); -} - -void -ConditionTracker::visit_sequence(const ConditionalDepSpec & node, - DependencySpecTree::ConstSequenceIterator begin, - DependencySpecTree::ConstSequenceIterator end) -{ - do_visit_sequence(node, begin, end); -} - -void -ConditionTracker::visit_leaf(const PackageDepSpec &) -{ - throw InternalError(PALUDIS_HERE, "ConditionTracker saw a PackageDepSpec"); -} - -void -ConditionTracker::visit_leaf(const BlockDepSpec &) -{ - throw InternalError(PALUDIS_HERE, "ConditionTracker saw a BlockDepSpec"); -} - -void -ConditionTracker::visit_leaf(const DependencyLabelsDepSpec &) -{ - throw InternalError(PALUDIS_HERE, "ConditionTracker saw a DependencyLabelsDepSpec"); -} - -void -ConditionTracker::visit_leaf(const NamedSetDepSpec &) -{ - throw InternalError(PALUDIS_HERE, "ConditionTracker saw a NamedSetDepSpec"); -} - -template class ConstVisitor<DependencySpecTree>; -template class ConstVisitor<DependencySpecTree>::VisitConstSequence<ConditionTracker, AllDepSpec>; - diff --git a/paludis/condition_tracker.hh b/paludis/condition_tracker.hh deleted file mode 100644 index 10525a76a..000000000 --- a/paludis/condition_tracker.hh +++ /dev/null @@ -1,108 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007 David Leverton - * - * 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 - * Public License version 2, as published by the Free Software Foundation. - * - * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef PALUDIS_GUARD_PALUDIS_CONDITION_TRACKER_HH -#define PALUDIS_GUARD_PALUDIS_CONDITION_TRACKER_HH 1 - -#include <paludis/util/visitor.hh> -#include <paludis/dep_tree.hh> -#include <paludis/dep_spec-fwd.hh> -#include <tr1/memory> -#include <tr1/functional> - -/** \file - * Declarations for ConditionTracker, which is used internally by DepList. - * - * \ingroup g_dep_list - * - * \section Examples - * - * - None at this time. - */ - -namespace paludis -{ - /** - * ConditionTracker is used by DepList to track the conditions under which a - * dependency was pulled in. - * - * \ingroup g_dep_list - * \nosubgrouping - */ - class ConditionTracker : - public ConstVisitor<DependencySpecTree>, - public ConstVisitor<DependencySpecTree>::VisitConstSequence<ConditionTracker, AllDepSpec> - { - private: - std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > base; - std::tr1::function<void (std::tr1::shared_ptr<ConstAcceptInterface<DependencySpecTree> >)> adder; - - template <typename T_> - void do_visit_sequence(const T_ &, - DependencySpecTree::ConstSequenceIterator, - DependencySpecTree::ConstSequenceIterator); - - template <typename T_> - std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > do_add_sequence(const T_ &); - template <typename T_> - std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > do_add_leaf(const T_ &); - - public: - ///\name Basic operations - ///\{ - - ConditionTracker(std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> >); - - virtual ~ConditionTracker(); - - ///\} - - ///\name Add a condition - ///\{ - - std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > add_condition(const AnyDepSpec &); - std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > add_condition(const ConditionalDepSpec &); - std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > add_condition(const PackageDepSpec &); - std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > add_condition(const BlockDepSpec &); - - ///\} - - ///\name Visit methods - ///\{ - - using ConstVisitor<DependencySpecTree>::VisitConstSequence<ConditionTracker, AllDepSpec>::visit_sequence; - - void visit_sequence(const AnyDepSpec &, DependencySpecTree::ConstSequenceIterator, DependencySpecTree::ConstSequenceIterator); - void visit_sequence(const ConditionalDepSpec &, DependencySpecTree::ConstSequenceIterator, DependencySpecTree::ConstSequenceIterator); - - void visit_leaf(const PackageDepSpec &) PALUDIS_ATTRIBUTE((noreturn)); - void visit_leaf(const BlockDepSpec &) PALUDIS_ATTRIBUTE((noreturn)); - void visit_leaf(const DependencyLabelsDepSpec &) PALUDIS_ATTRIBUTE((noreturn)); - void visit_leaf(const NamedSetDepSpec &) PALUDIS_ATTRIBUTE((noreturn)); - - ///\} - }; - -#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE - extern template class ConstVisitor<DependencySpecTree>; - extern template class ConstVisitor<DependencySpecTree>::VisitConstSequence<ConditionTracker, AllDepSpec>; -#endif -} - -#endif diff --git a/paludis/dep_label.cc b/paludis/dep_label.cc index 14f39635d..be7f1b989 100644 --- a/paludis/dep_label.cc +++ b/paludis/dep_label.cc @@ -19,7 +19,6 @@ #include <paludis/dep_label.hh> #include <paludis/dep_spec.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/sequence-impl.hh> #include <paludis/util/indirect_iterator-impl.hh> #include <paludis/util/stringify.hh> diff --git a/paludis/dep_label.hh b/paludis/dep_label.hh index faa0f82ec..446327325 100644 --- a/paludis/dep_label.hh +++ b/paludis/dep_label.hh @@ -22,7 +22,6 @@ #include <paludis/dep_label-fwd.hh> #include <paludis/dep_spec-fwd.hh> -#include <paludis/util/visitor.hh> #include <paludis/util/simple_visitor.hh> #include <paludis/util/instantiation_policy.hh> #include <paludis/util/private_implementation_pattern.hh> diff --git a/paludis/dep_list-fwd.hh b/paludis/dep_list-fwd.hh index 90550de52..4ed074643 100644 --- a/paludis/dep_list-fwd.hh +++ b/paludis/dep_list-fwd.hh @@ -21,7 +21,7 @@ #define PALUDIS_GUARD_PALUDIS_DEP_LIST_FWD_HH 1 #include <paludis/repository-fwd.hh> -#include <paludis/dep_tree.hh> +#include <paludis/spec_tree.hh> #include <paludis/package_id-fwd.hh> #include <paludis/environment-fwd.hh> @@ -43,7 +43,7 @@ namespace paludis * * \ingroup g_dep_list */ - bool is_viable_any_child(const DependencySpecTree::ConstItem & i); + bool is_viable_any_child(const DependencySpecTree::BasicNode & i); } #endif diff --git a/paludis/dep_list.cc b/paludis/dep_list.cc index 6ee4a20a9..dda724bd0 100644 --- a/paludis/dep_list.cc +++ b/paludis/dep_list.cc @@ -22,7 +22,6 @@ #include <paludis/query_visitor.hh> #include <paludis/range_rewriter.hh> #include <paludis/show_suggest_visitor.hh> -#include <paludis/condition_tracker.hh> #include <paludis/handled_information.hh> #include <paludis/dep_spec.hh> @@ -48,13 +47,15 @@ #include <paludis/util/save.hh> #include <paludis/util/member_iterator.hh> #include <paludis/util/set.hh> -#include <paludis/util/sequence.hh> +#include <paludis/util/sequence-impl.hh> #include <paludis/util/stringify.hh> #include <paludis/util/tokeniser.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/wrapped_forward_iterator-impl.hh> #include <paludis/util/hashes.hh> #include <paludis/util/make_named_values.hh> +#include <paludis/util/simple_visitor_cast.hh> +#include <paludis/util/indirect_iterator-impl.hh> +#include <paludis/util/accept_visitor.hh> #include <algorithm> #include <functional> @@ -69,6 +70,8 @@ using namespace paludis; typedef std::list<std::tr1::shared_ptr<ActiveDependencyLabels> > LabelsStack; template class Sequence<std::tr1::function<bool (const PackageID &, const Mask &)> >; +template class WrappedForwardIterator<DepListOverrideMasksFunctions::ConstIterator, + const std::tr1::function<bool (const PackageID &, const Mask &)> >; template class WrappedForwardIterator<DepList::IteratorTag, DepListEntry>; template class WrappedForwardIterator<DepList::ConstIteratorTag, const DepListEntry>; @@ -118,7 +121,7 @@ namespace paludis MergeListIndex merge_list_index; - SetSpecTree::ConstItem * current_top_level_target; + const SetSpecTree * current_top_level_target; bool throw_on_blocker; @@ -279,14 +282,14 @@ namespace } }; - bool is_interesting_any_child(const Environment & env, - const DependencySpecTree::ConstItem & i) + bool is_interesting_any_child(const Environment & env, const DependencySpecTree::BasicNode & i) { - const PackageDepSpec * const u(get_const_item(i)->as_package_dep_spec()); - if (0 != u && u->package_ptr()) + const DependencySpecTree::NodeType<PackageDepSpec>::Type * const u(simple_visitor_cast< + const DependencySpecTree::NodeType<PackageDepSpec>::Type>(i)); + if (u && u->spec()->package_ptr()) { return ! env[selection::SomeArbitraryVersion( - generator::Package(*u->package_ptr()) | + generator::Package(*u->spec()->package_ptr()) | filter::SupportsAction<InstalledAction>())]->empty(); } else @@ -294,46 +297,27 @@ namespace } } -struct DepList::AddVisitor : - ConstVisitor<DependencySpecTree> +struct DepList::AddVisitor { DepList * const d; std::tr1::shared_ptr<const DestinationsSet> destinations; - std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > conditions; std::set<SetName> recursing_sets; const bool only_if_not_suggested_label; - AddVisitor(DepList * const dd, bool l, std::tr1::shared_ptr<const DestinationsSet> ddd, - std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > c = - (std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> >( - new ConstTreeSequence<DependencySpecTree, AllDepSpec>( - std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))))) : + AddVisitor(DepList * const dd, bool l, std::tr1::shared_ptr<const DestinationsSet> ddd) : d(dd), destinations(ddd), - conditions(c), only_if_not_suggested_label(l) { } - void visit_sequence(const AllDepSpec &, - DependencySpecTree::ConstSequenceIterator, - DependencySpecTree::ConstSequenceIterator); - - void visit_sequence(const AnyDepSpec &, - DependencySpecTree::ConstSequenceIterator, - DependencySpecTree::ConstSequenceIterator); - - void visit_sequence(const ConditionalDepSpec &, - DependencySpecTree::ConstSequenceIterator, - DependencySpecTree::ConstSequenceIterator); - - void visit_leaf(const PackageDepSpec &); - - void visit_leaf(const BlockDepSpec &); - - void visit_leaf(const DependencyLabelsDepSpec &); - - void visit_leaf(const NamedSetDepSpec &); + void visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<DependencyLabelsDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & node); }; namespace @@ -363,9 +347,9 @@ namespace } void -DepList::AddVisitor::visit_leaf(const PackageDepSpec & a) +DepList::AddVisitor::visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node) { - Context context("When adding PackageDepSpec '" + stringify(a) + "':"); + Context context("When adding PackageDepSpec '" + stringify(*node.spec()) + "':"); if (only_if_not_suggested_label) { @@ -379,43 +363,40 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a) if (v.result) { Log::get_instance()->message("dep_list.skipping_suggested", ll_debug, lc_context) << "Skipping dep '" - << a << "' because suggested label is active"; + << *node.spec() << "' because suggested label is active"; return; } } - Save<std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > > save_c( - &conditions, d->_imp->opts->dependency_tags() ? ConditionTracker(conditions).add_condition(a) : conditions); - /* find already installed things */ // TODO: check destinations std::tr1::shared_ptr<const PackageIDSequence> already_installed((*d->_imp->env)[selection::AllVersionsSorted( - generator::Matches(a, d->_imp->opts->match_package_options()) | filter::SupportsAction<InstalledAction>())]); + generator::Matches(*node.spec(), d->_imp->opts->match_package_options()) | filter::SupportsAction<InstalledAction>())]); /* are we already on the merge list? */ std::pair<MergeListIndex::iterator, MergeListIndex::iterator> q; - if (a.package_ptr()) - q = d->_imp->merge_list_index.equal_range(*a.package_ptr()); + if (node.spec()->package_ptr()) + q = d->_imp->merge_list_index.equal_range(*node.spec()->package_ptr()); else q = std::make_pair(d->_imp->merge_list_index.begin(), d->_imp->merge_list_index.end()); MergeListIndex::iterator qq(std::find_if(q.first, q.second, - MatchDepListEntryAgainstPackageDepSpec(d->_imp->env, a, d->_imp->opts->match_package_options()))); + MatchDepListEntryAgainstPackageDepSpec(d->_imp->env, *node.spec(), d->_imp->opts->match_package_options()))); MergeList::iterator existing_merge_list_entry(qq == q.second ? d->_imp->merge_list.end() : qq->second); if (existing_merge_list_entry != d->_imp->merge_list.end()) { /* tag it */ - if (a.tag()) + if (node.spec()->tag()) existing_merge_list_entry->tags()->insert(make_named_values<DepTagEntry>( value_for<n::generation>(d->_imp->merge_list_generation), - value_for<n::tag>(a.tag()) + value_for<n::tag>(node.spec()->tag()) )); if (d->_imp->opts->dependency_tags() && d->_imp->current_package_id()) existing_merge_list_entry->tags()->insert(make_named_values<DepTagEntry>( value_for<n::generation>(d->_imp->merge_list_generation), - value_for<n::tag>(std::tr1::shared_ptr<DepTag>(new DependencyDepTag(d->_imp->current_package_id(), a, conditions))) + value_for<n::tag>(std::tr1::shared_ptr<DepTag>(new DependencyDepTag(d->_imp->current_package_id(), *node.spec()))) )); /* add an appropriate destination */ @@ -437,7 +418,7 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a) else if (d->_imp->opts->circular() == dl_circular_discard_silently) return; - throw CircularDependencyError("Atom '" + stringify(a) + "' matched by merge list entry '" + + throw CircularDependencyError("Atom '" + stringify(*node.spec()) + "' matched by merge list entry '" + stringify(*existing_merge_list_entry->package_id()) + "', which does not yet have its " "dependencies installed"); } @@ -448,7 +429,7 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a) /* find installable candidates, and find the best visible candidate */ std::tr1::shared_ptr<const PackageID> best_visible_candidate; std::tr1::shared_ptr<const PackageIDSequence> installable_candidates( - (*d->_imp->env)[selection::AllVersionsSorted(generator::Matches(a, d->_imp->opts->match_package_options()) & + (*d->_imp->env)[selection::AllVersionsSorted(generator::Matches(*node.spec(), d->_imp->opts->match_package_options()) & generator::SomeIDsMightSupportAction<InstallAction>())]); for (PackageIDSequence::ReverseConstIterator p(installable_candidates->rbegin()), @@ -464,8 +445,8 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a) (dl_target_package != d->_imp->opts->target_type() || ! d->is_top_level_target(**already_installed->last()))) { Log::get_instance()->message("dep_list.no_visible.transient", ll_debug, lc_context) << "No visible packages matching '" - << a << "', silently falling back to installed package '" << **already_installed->last() << "' as it is transient"; - d->add_already_installed_package(*already_installed->last(), a.tag(), a, conditions, destinations); + << *node.spec() << "', silently falling back to installed package '" << **already_installed->last() << "' as it is transient"; + d->add_already_installed_package(*already_installed->last(), node.spec()->tag(), *node.spec(), destinations); return; } @@ -501,7 +482,7 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a) if (success) { - d->add_error_package(*p, dlk_masked, a, conditions); + d->add_error_package(*p, dlk_masked, *node.spec()); best_visible_candidate = *p; } } @@ -544,24 +525,24 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a) if (already_installed->empty() || ! can_fall_back) { - if (! a.additional_requirements_ptr()) - throw AllMaskedError(a); + if (! node.spec()->additional_requirements_ptr()) + throw AllMaskedError(*node.spec()); std::tr1::shared_ptr<const PackageIDSequence> match_except_reqs((*d->_imp->env)[selection::AllVersionsUnsorted( - generator::Matches(*a.without_additional_requirements(), d->_imp->opts->match_package_options()))]); + generator::Matches(*node.spec()->without_additional_requirements(), d->_imp->opts->match_package_options()))]); for (PackageIDSequence::ConstIterator i(match_except_reqs->begin()), i_end(match_except_reqs->end()) ; i != i_end ; ++i) if (! (*i)->masked()) - throw AdditionalRequirementsNotMetError(a); + throw AdditionalRequirementsNotMetError(*node.spec()); - throw AllMaskedError(a); + throw AllMaskedError(*node.spec()); } else { Log::get_instance()->message("dep_list.no_visible", ll_warning, lc_context) << "No visible packages matching '" - << a << "', falling back to installed package '" << **already_installed->last() << "'"; - d->add_already_installed_package(*already_installed->last(), a.tag(), a, conditions, destinations); + << *node.spec() << "', falling back to installed package '" << **already_installed->last() << "'"; + d->add_already_installed_package(*already_installed->last(), node.spec()->tag(), *node.spec(), destinations); return; } } @@ -582,7 +563,7 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a) Log::get_instance()->message("dep_list.installed_over_best_visible", ll_debug, lc_context) << "Taking installed package '" << **already_installed_in_same_slot->last() << "' over '" << *best_visible_candidate << "'"; - d->add_already_installed_package(*already_installed_in_same_slot->last(), a.tag(), a, conditions, destinations); + d->add_already_installed_package(*already_installed_in_same_slot->last(), node.spec()->tag(), *node.spec(), destinations); return; } else @@ -599,7 +580,7 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a) Log::get_instance()->message("dep_list.installed_over_slot", ll_debug, lc_context) << "Taking installed package '" << **already_installed->last() << "' over '" << *best_visible_candidate << "' (in different slot)"; - d->add_already_installed_package(*already_installed->last(), a.tag(), a, conditions, destinations); + d->add_already_installed_package(*already_installed->last(), node.spec()->tag(), *node.spec(), destinations); return; } else @@ -648,68 +629,62 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a) ; } - d->add_package(best_visible_candidate, a.tag(), a, conditions, destinations); + d->add_package(best_visible_candidate, node.spec()->tag(), *node.spec(), destinations); } void -DepList::AddVisitor::visit_leaf(const NamedSetDepSpec & a) +DepList::AddVisitor::visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & node) { - Context context("When adding NamedSetDepSpec '" + stringify(a) + "':"); + Context context("When adding NamedSetDepSpec '" + stringify(*node.spec()) + "':"); - std::tr1::shared_ptr<const SetSpecTree::ConstItem> set(d->_imp->env->set(a.name())); + std::tr1::shared_ptr<const SetSpecTree> set(d->_imp->env->set(node.spec()->name())); if (! set) - throw NoSuchSetError(stringify(a.name())); + throw NoSuchSetError(stringify(node.spec()->name())); - if (! recursing_sets.insert(a.name()).second) + if (! recursing_sets.insert(node.spec()->name()).second) { - Log::get_instance()->message("dep_list.recursive_set", ll_warning, lc_context) << "Recursively defined set '" << a.name() << "'"; - throw RecursivelyDefinedSetError(stringify(a.name())); + Log::get_instance()->message("dep_list.recursive_set", ll_warning, lc_context) << "Recursively defined set '" << node.spec()->name() << "'"; + throw RecursivelyDefinedSetError(stringify(node.spec()->name())); } - set->accept(*this); + set->root()->accept(*this); - recursing_sets.erase(a.name()); + recursing_sets.erase(node.spec()->name()); } void -DepList::AddVisitor::visit_sequence(const AllDepSpec &, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) +DepList::AddVisitor::visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node) { d->_imp->labels.push_front(make_shared_ptr(new ActiveDependencyLabels(**d->_imp->labels.begin()))); RunOnDestruction restore_labels(std::tr1::bind(std::tr1::mem_fn(&LabelsStack::pop_front), &d->_imp->labels)); - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), + accept_visitor(*this)); } void -DepList::AddVisitor::visit_sequence(const ConditionalDepSpec & a, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) +DepList::AddVisitor::visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node) { - Save<std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > > save_c( - &conditions, d->_imp->opts->dependency_tags() ? ConditionTracker(conditions).add_condition(a) : conditions); - if (d->_imp->opts->use() == dl_use_deps_standard) { d->_imp->labels.push_front(make_shared_ptr(new ActiveDependencyLabels(**d->_imp->labels.begin()))); RunOnDestruction restore_labels(std::tr1::bind(std::tr1::mem_fn(&LabelsStack::pop_front), &d->_imp->labels)); - if (a.condition_met()) - std::for_each(cur, end, accept_visitor(*this)); + if (node.spec()->condition_met()) + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), + accept_visitor(*this)); } else { - if (a.condition_meetable()) - std::for_each(cur, end, accept_visitor(*this)); + if (node.spec()->condition_meetable()) + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), + accept_visitor(*this)); } } void -DepList::AddVisitor::visit_sequence(const AnyDepSpec & a, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) +DepList::AddVisitor::visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node) { using namespace std::tr1::placeholders; @@ -717,46 +692,45 @@ DepList::AddVisitor::visit_sequence(const AnyDepSpec & a, RunOnDestruction restore_labels(std::tr1::bind(std::tr1::mem_fn(&LabelsStack::pop_front), &d->_imp->labels)); /* annoying requirement: || ( foo? ( ... ) ) resolves to empty if !foo. */ - if (end == std::find_if(cur, end, &is_viable_any_child)) + if (indirect_iterator(node.end()) == std::find_if(indirect_iterator(node.begin()), indirect_iterator(node.end()), &is_viable_any_child)) return; { RangeRewriter r; - std::for_each(cur, end, accept_visitor(r)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(r)); std::tr1::shared_ptr<PackageDepSpec> rewritten_spec(r.spec()); if (rewritten_spec) { - TreeLeaf<DependencySpecTree, PackageDepSpec> rr(r.spec()); - d->add_not_top_level(only_if_not_suggested_label, rr, destinations, conditions); + DependencySpecTree::NodeType<PackageDepSpec>::Type rr(r.spec()); + d->add_not_top_level(only_if_not_suggested_label, rr, destinations); return; } } - Save<std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > > save_c( - &conditions, d->_imp->opts->dependency_tags() ? ConditionTracker(conditions).add_condition(a) : conditions); - /* see if any of our children is already installed. if any is, add it so that * any upgrades kick in */ - for (DependencySpecTree::ConstSequenceIterator c(cur) ; c != end ; ++c) + for (DependencySpecTree::NodeType<AnyDepSpec>::Type::ConstIterator c(node.begin()), c_end(node.end()) ; + c != c_end ; ++c) { - if (! is_viable_any_child(*c)) + if (! is_viable_any_child(**c)) continue; - if (d->already_installed(*c, destinations)) + if (d->already_installed(**c, destinations)) { Context context("When using already installed group to resolve dependencies:"); - d->add_not_top_level(only_if_not_suggested_label, *c, destinations, conditions); + d->add_not_top_level(only_if_not_suggested_label, **c, destinations); return; } } /* if we have something like || ( a >=b-2 ) and b-1 is installed, try to go for * the b-2 bit first */ - for (DependencySpecTree::ConstSequenceIterator c(cur) ; c != end ; ++c) + for (DependencySpecTree::NodeType<AnyDepSpec>::Type::ConstIterator c(node.begin()), c_end(node.end()) ; + c != c_end ; ++c) { - if (! is_viable_any_child(*c)) + if (! is_viable_any_child(**c)) continue; - if (! is_interesting_any_child(*d->_imp->env, *c)) + if (! is_interesting_any_child(*d->_imp->env, **c)) continue; try @@ -767,7 +741,7 @@ DepList::AddVisitor::visit_sequence(const AnyDepSpec & a, dl_blocks_discard_completely != d->_imp->opts->blocks()); Save<std::tr1::shared_ptr<DepListOverrideMasksFunctions> > save_o(&d->_imp->opts->override_masks(), std::tr1::shared_ptr<DepListOverrideMasksFunctions>()); - d->add_not_top_level(only_if_not_suggested_label, *c, destinations, conditions); + d->add_not_top_level(only_if_not_suggested_label, **c, destinations); return; } catch (const DepListError &) @@ -776,9 +750,10 @@ DepList::AddVisitor::visit_sequence(const AnyDepSpec & a, } /* install first available viable option */ - for (DependencySpecTree::ConstSequenceIterator c(cur) ; c != end ; ++c) + for (DependencySpecTree::NodeType<AnyDepSpec>::Type::ConstIterator c(node.begin()), c_end(node.end()) ; + c != c_end ; ++c) { - if (! is_viable_any_child(*c)) + if (! is_viable_any_child(**c)) continue; try @@ -789,7 +764,7 @@ DepList::AddVisitor::visit_sequence(const AnyDepSpec & a, dl_blocks_discard_completely != d->_imp->opts->blocks()); Save<std::tr1::shared_ptr<DepListOverrideMasksFunctions> > save_o(&d->_imp->opts->override_masks(), std::tr1::shared_ptr<DepListOverrideMasksFunctions>()); - d->add_not_top_level(only_if_not_suggested_label, *c, destinations, conditions); + d->add_not_top_level(only_if_not_suggested_label, **c, destinations); return; } catch (const DepListError &) @@ -801,44 +776,42 @@ DepList::AddVisitor::visit_sequence(const AnyDepSpec & a, << "No resolvable item in || ( ) block. Using first item for error message"; { Context block_context("Inside || ( ) block with other options:"); - for (DependencySpecTree::ConstSequenceIterator c(cur) ; c != end ; ++c) + for (DependencySpecTree::NodeType<AnyDepSpec>::Type::ConstIterator c(node.begin()), c_end(node.end()) ; + c != c_end ; ++c) { - if (! is_viable_any_child(*c)) + if (! is_viable_any_child(**c)) continue; - d->add_not_top_level(only_if_not_suggested_label, *c, destinations, conditions); + d->add_not_top_level(only_if_not_suggested_label, **c, destinations); return; } } } void -DepList::AddVisitor::visit_leaf(const BlockDepSpec & a) +DepList::AddVisitor::visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type & node) { if (dl_blocks_discard_completely == d->_imp->opts->blocks()) return; // TODO: check destinations - Context context("When checking BlockDepSpec '" + stringify(a) + "':"); - - Save<std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > > save_c( - &conditions, d->_imp->opts->dependency_tags() ? ConditionTracker(conditions).add_condition(a) : conditions); + Context context("When checking BlockDepSpec '" + stringify(*node.spec()) + "':"); bool check_whole_list(false); std::list<MergeList::const_iterator> will_be_installed; std::tr1::shared_ptr<const PackageIDSequence> already_installed; - if (a.blocked_spec()->package_ptr()) + if (node.spec()->blocked_spec()->package_ptr()) { - PackageDepSpec just_package(make_package_dep_spec().package(*a.blocked_spec()->package_ptr())); + PackageDepSpec just_package(make_package_dep_spec().package(*node.spec()->blocked_spec()->package_ptr())); already_installed = (*d->_imp->env)[selection::AllVersionsUnsorted( generator::Matches(just_package, d->_imp->opts->match_package_options()) | filter::SupportsAction<InstalledAction>())]; MatchDepListEntryAgainstPackageDepSpec m(d->_imp->env, just_package, d->_imp->opts->match_package_options()); for (std::pair<MergeListIndex::const_iterator, MergeListIndex::const_iterator> p( - d->_imp->merge_list_index.equal_range(*a.blocked_spec()->package_ptr())) ; + d->_imp->merge_list_index.equal_range(*node.spec()->blocked_spec()->package_ptr())) ; p.first != p.second ; ++p.first) { if (d->_imp->current_merge_list_entry != d->_imp->merge_list.end()) @@ -868,7 +841,7 @@ DepList::AddVisitor::visit_leaf(const BlockDepSpec & a) for (PackageIDSequence::ConstIterator aa(already_installed->begin()), aa_end(already_installed->end()) ; aa != aa_end ; ++aa) { - if (! match_package(*d->_imp->env, *a.blocked_spec(), **aa, d->_imp->opts->match_package_options())) + if (! match_package(*d->_imp->env, *node.spec()->blocked_spec(), **aa, d->_imp->opts->match_package_options())) continue; bool replaced(false); @@ -891,13 +864,13 @@ DepList::AddVisitor::visit_leaf(const BlockDepSpec & a) /* ignore if it's a virtual/blah (not <virtual/blah-1) block and it's blocking * ourself */ - if (! (a.blocked_spec()->version_requirements_ptr() || a.blocked_spec()->slot_requirement_ptr() - || a.blocked_spec()->additional_requirements_ptr() - || a.blocked_spec()->from_repository_ptr() - || a.blocked_spec()->in_repository_ptr() - || a.blocked_spec()->installed_at_path_ptr() - || a.blocked_spec()->installable_to_repository_ptr() - || a.blocked_spec()->installable_to_path_ptr()) + if (! (node.spec()->blocked_spec()->version_requirements_ptr() || node.spec()->blocked_spec()->slot_requirement_ptr() + || node.spec()->blocked_spec()->additional_requirements_ptr() + || node.spec()->blocked_spec()->from_repository_ptr() + || node.spec()->blocked_spec()->in_repository_ptr() + || node.spec()->blocked_spec()->installed_at_path_ptr() + || node.spec()->blocked_spec()->installable_to_repository_ptr() + || node.spec()->blocked_spec()->installable_to_path_ptr()) && d->_imp->current_package_id()) { if ((*aa)->name() == d->_imp->current_package_id()->name()) @@ -910,17 +883,17 @@ DepList::AddVisitor::visit_leaf(const BlockDepSpec & a) switch (d->_imp->throw_on_blocker ? dl_blocks_error : d->_imp->opts->blocks()) { case dl_blocks_error: - throw BlockError(stringify(*a.blocked_spec())); + throw BlockError(stringify(*node.spec()->blocked_spec())); case dl_blocks_discard: - Log::get_instance()->message("dep_list.discarding_block", ll_warning, lc_context) << "Discarding block '" << a << "'"; + Log::get_instance()->message("dep_list.discarding_block", ll_warning, lc_context) << "Discarding block '" << *node.spec() << "'"; break; case dl_blocks_discard_completely: break; case dl_blocks_accumulate: - d->add_error_package(*aa, dlk_block, *a.blocked_spec(), conditions); + d->add_error_package(*aa, dlk_block, *node.spec()->blocked_spec()); break; case last_dl_blocks: @@ -931,18 +904,18 @@ DepList::AddVisitor::visit_leaf(const BlockDepSpec & a) for (std::list<MergeList::const_iterator>::const_iterator r(will_be_installed.begin()), r_end(will_be_installed.end()) ; r != r_end ; ++r) { - if (! match_package(*d->_imp->env, *a.blocked_spec(), *(*r)->package_id(), d->_imp->opts->match_package_options())) + if (! match_package(*d->_imp->env, *node.spec()->blocked_spec(), *(*r)->package_id(), d->_imp->opts->match_package_options())) continue; /* ignore if it's a virtual/blah (not <virtual/blah-1) block and it's blocking * ourself */ - if (! (a.blocked_spec()->version_requirements_ptr() || a.blocked_spec()->slot_requirement_ptr() - || a.blocked_spec()->additional_requirements_ptr() - || a.blocked_spec()->in_repository_ptr() - || a.blocked_spec()->from_repository_ptr() - || a.blocked_spec()->installed_at_path_ptr() - || a.blocked_spec()->installable_to_repository_ptr() - || a.blocked_spec()->installable_to_path_ptr()) + if (! (node.spec()->blocked_spec()->version_requirements_ptr() || node.spec()->blocked_spec()->slot_requirement_ptr() + || node.spec()->blocked_spec()->additional_requirements_ptr() + || node.spec()->blocked_spec()->in_repository_ptr() + || node.spec()->blocked_spec()->from_repository_ptr() + || node.spec()->blocked_spec()->installed_at_path_ptr() + || node.spec()->blocked_spec()->installable_to_repository_ptr() + || node.spec()->blocked_spec()->installable_to_path_ptr()) && d->_imp->current_package_id()) { if ((*r)->package_id()->name() == d->_imp->current_package_id()->name()) @@ -953,7 +926,7 @@ DepList::AddVisitor::visit_leaf(const BlockDepSpec & a) continue; } - throw BlockError(stringify(*a.blocked_spec())); + throw BlockError(stringify(*node.spec()->blocked_spec())); } if (check_whole_list) @@ -961,18 +934,18 @@ DepList::AddVisitor::visit_leaf(const BlockDepSpec & a) for (MergeList::const_iterator r(d->_imp->merge_list.begin()), r_end(d->_imp->merge_list.end()) ; r != r_end ; ++r) { - if (! match_package(*d->_imp->env, *a.blocked_spec(), *r->package_id(), d->_imp->opts->match_package_options())) + if (! match_package(*d->_imp->env, *node.spec()->blocked_spec(), *r->package_id(), d->_imp->opts->match_package_options())) continue; /* ignore if it's a virtual/blah (not <virtual/blah-1) block and it's blocking * ourself */ - if (! (a.blocked_spec()->version_requirements_ptr() || a.blocked_spec()->slot_requirement_ptr() - || a.blocked_spec()->additional_requirements_ptr() - || a.blocked_spec()->in_repository_ptr() - || a.blocked_spec()->from_repository_ptr() - || a.blocked_spec()->installed_at_path_ptr() - || a.blocked_spec()->installable_to_repository_ptr() - || a.blocked_spec()->installable_to_path_ptr()) + if (! (node.spec()->blocked_spec()->version_requirements_ptr() || node.spec()->blocked_spec()->slot_requirement_ptr() + || node.spec()->blocked_spec()->additional_requirements_ptr() + || node.spec()->blocked_spec()->in_repository_ptr() + || node.spec()->blocked_spec()->from_repository_ptr() + || node.spec()->blocked_spec()->installed_at_path_ptr() + || node.spec()->blocked_spec()->installable_to_repository_ptr() + || node.spec()->blocked_spec()->installable_to_path_ptr()) && d->_imp->current_package_id()) { if (r->package_id()->name() == d->_imp->current_package_id()->name()) @@ -983,15 +956,15 @@ DepList::AddVisitor::visit_leaf(const BlockDepSpec & a) continue; } - throw BlockError(stringify(*a.blocked_spec())); + throw BlockError(stringify(*node.spec()->blocked_spec())); } } } void -DepList::AddVisitor::visit_leaf(const DependencyLabelsDepSpec & spec) +DepList::AddVisitor::visit(const DependencySpecTree::NodeType<DependencyLabelsDepSpec>::Type & node) { - d->_imp->labels.begin()->reset(new ActiveDependencyLabels(**d->_imp->labels.begin(), spec)); + d->_imp->labels.begin()->reset(new ActiveDependencyLabels(**d->_imp->labels.begin(), *node.spec())); } DepList::DepList(const Environment * const e, const DepListOptions & o) : @@ -1023,51 +996,48 @@ DepList::clear() } void -DepList::add_in_role(const bool only_if_not_suggested_label, DependencySpecTree::ConstItem & spec, const std::string & role, +DepList::add_in_role(const bool only_if_not_suggested_label, const DependencySpecTree::BasicNode & spec, const std::string & role, const std::tr1::shared_ptr<const DestinationsSet> & destinations) { Context context("When adding " + role + (only_if_not_suggested_label ? " unless under a suggested label" : "") + ":"); - add_not_top_level(only_if_not_suggested_label, spec, destinations, - std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> >( - new ConstTreeSequence<DependencySpecTree, AllDepSpec>(std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec)))); + add_not_top_level(only_if_not_suggested_label, spec, destinations); } void DepList::add_not_top_level(const bool only_if_not_suggested_label, - DependencySpecTree::ConstItem & spec, const std::tr1::shared_ptr<const DestinationsSet> & destinations, - const std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > & conditions) + const DependencySpecTree::BasicNode & spec, const std::tr1::shared_ptr<const DestinationsSet> & destinations) { DepListTransaction transaction(_imp->merge_list, _imp->merge_list_index, _imp->merge_list_generation); - AddVisitor visitor(this, only_if_not_suggested_label, destinations, conditions); + AddVisitor visitor(this, only_if_not_suggested_label, destinations); spec.accept(visitor); transaction.commit(); } void -DepList::add(SetSpecTree::ConstItem & spec, const std::tr1::shared_ptr<const DestinationsSet> & destinations) +DepList::add(const SetSpecTree & spec, const std::tr1::shared_ptr<const DestinationsSet> & destinations) { DepListTransaction transaction(_imp->merge_list, _imp->merge_list_index, _imp->merge_list_generation); - Save<SetSpecTree::ConstItem *> save_current_top_level_target(&_imp->current_top_level_target, + Save<const SetSpecTree *> save_current_top_level_target(&_imp->current_top_level_target, _imp->current_top_level_target ? _imp->current_top_level_target : &spec); AddVisitor visitor(this, false, destinations); - spec.accept(visitor); + spec.root()->accept(visitor); transaction.commit(); } void DepList::add(const PackageDepSpec & spec, const std::tr1::shared_ptr<const DestinationsSet> & destinations) { - TreeLeaf<SetSpecTree, PackageDepSpec> l(std::tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(spec))); - add(l, destinations); + SetSpecTree tree(make_shared_ptr(new AllDepSpec)); + tree.root()->append(make_shared_ptr(new PackageDepSpec(spec))); + add(tree, destinations); } void DepList::add_package(const std::tr1::shared_ptr<const PackageID> & p, const std::tr1::shared_ptr<const DepTag> & tag, - const PackageDepSpec & pds, const std::tr1::shared_ptr<DependencySpecTree::ConstItem> & conditions, - const std::tr1::shared_ptr<const DestinationsSet> & destinations) + const PackageDepSpec & pds, const std::tr1::shared_ptr<const DestinationsSet> & destinations) { Context context("When adding package '" + stringify(*p) + "':"); @@ -1103,7 +1073,7 @@ DepList::add_package(const std::tr1::shared_ptr<const PackageID> & p, const std: if (_imp->opts->dependency_tags() && _imp->current_package_id()) our_merge_entry_position->tags()->insert(make_named_values<DepTagEntry>( value_for<n::generation>(_imp->merge_list_generation), - value_for<n::tag>(std::tr1::shared_ptr<DepTag>(new DependencyDepTag(_imp->current_package_id(), pds, conditions))) + value_for<n::tag>(std::tr1::shared_ptr<DepTag>(new DependencyDepTag(_imp->current_package_id(), pds))) )); Save<MergeList::const_iterator> save_current_merge_list_entry(&_imp->current_merge_list_entry, @@ -1115,7 +1085,7 @@ DepList::add_package(const std::tr1::shared_ptr<const PackageID> & p, const std: if (p->provide_key()) { DepSpecFlattener<ProvideSpecTree, PackageDepSpec> f(_imp->env); - p->provide_key()->value()->accept(f); + p->provide_key()->value()->root()->accept(f); if (f.begin() != f.end() && ! (*DistributionData::get_instance()->distribution_from_string( _imp->env->distribution())).support_old_style_virtuals()) @@ -1167,7 +1137,7 @@ DepList::add_package(const std::tr1::shared_ptr<const PackageID> & p, const std: Save<MergeList::iterator> suggest_save_merge_list_insert_position(&_imp->merge_list_insert_position, next(our_merge_entry_position)); ShowSuggestVisitor visitor(this, destinations, _imp->env, _imp->current_package_id(), _imp->opts->dependency_tags(), false); - p->suggested_dependencies_key()->value()->accept(visitor); + p->suggested_dependencies_key()->value()->root()->accept(visitor); } /* add suggests in post depend too */ @@ -1177,41 +1147,41 @@ DepList::add_package(const std::tr1::shared_ptr<const PackageID> & p, const std: Save<MergeList::iterator> suggest_save_merge_list_insert_position(&_imp->merge_list_insert_position, next(our_merge_entry_position)); ShowSuggestVisitor visitor(this, destinations, _imp->env, _imp->current_package_id(), _imp->opts->dependency_tags(), true); - p->post_dependencies_key()->value()->accept(visitor); + p->post_dependencies_key()->value()->root()->accept(visitor); } /* add pre dependencies */ if (p->build_dependencies_key()) - add_predeps(*p->build_dependencies_key()->value(), _imp->opts->uninstalled_deps_pre(), "build", destinations, false); + add_predeps(*p->build_dependencies_key()->value()->root(), _imp->opts->uninstalled_deps_pre(), "build", destinations, false); if (p->run_dependencies_key()) - add_predeps(*p->run_dependencies_key()->value(), _imp->opts->uninstalled_deps_runtime(), "run", destinations, false); + add_predeps(*p->run_dependencies_key()->value()->root(), _imp->opts->uninstalled_deps_runtime(), "run", destinations, false); if (p->post_dependencies_key()) - add_predeps(*p->post_dependencies_key()->value(), _imp->opts->uninstalled_deps_post(), "post", destinations, + add_predeps(*p->post_dependencies_key()->value()->root(), _imp->opts->uninstalled_deps_post(), "post", destinations, (_imp->opts->suggested() == dl_suggested_install) ? false : true); if (_imp->opts->suggested() == dl_suggested_install && p->suggested_dependencies_key()) - add_predeps(*p->suggested_dependencies_key()->value(), _imp->opts->uninstalled_deps_suggested(), "suggest", destinations, false); + add_predeps(*p->suggested_dependencies_key()->value()->root(), _imp->opts->uninstalled_deps_suggested(), "suggest", destinations, false); our_merge_entry_position->state() = dle_has_pre_deps; _imp->merge_list_insert_position = next(our_merge_entry_post_position); /* add post dependencies */ if (p->build_dependencies_key()) - add_postdeps(*p->build_dependencies_key()->value(), _imp->opts->uninstalled_deps_pre(), "build", destinations, false); + add_postdeps(*p->build_dependencies_key()->value()->root(), _imp->opts->uninstalled_deps_pre(), "build", destinations, false); if (p->run_dependencies_key()) - add_postdeps(*p->run_dependencies_key()->value(), _imp->opts->uninstalled_deps_runtime(), "run", destinations, false); + add_postdeps(*p->run_dependencies_key()->value()->root(), _imp->opts->uninstalled_deps_runtime(), "run", destinations, false); if (p->post_dependencies_key()) - add_postdeps(*p->post_dependencies_key()->value(), _imp->opts->uninstalled_deps_post(), "post", destinations, + add_postdeps(*p->post_dependencies_key()->value()->root(), _imp->opts->uninstalled_deps_post(), "post", destinations, (_imp->opts->suggested() == dl_suggested_install) ? false : true); if (_imp->opts->suggested() == dl_suggested_install && p->suggested_dependencies_key()) - add_postdeps(*p->suggested_dependencies_key()->value(), _imp->opts->uninstalled_deps_suggested(), "suggest", destinations, false); + add_postdeps(*p->suggested_dependencies_key()->value()->root(), _imp->opts->uninstalled_deps_suggested(), "suggest", destinations, false); our_merge_entry_position->state() = dle_has_all_deps; } void DepList::add_error_package(const std::tr1::shared_ptr<const PackageID> & p, const DepListEntryKind kind, - const PackageDepSpec & pds, const std::tr1::shared_ptr<DependencySpecTree::ConstItem> & conditions) + const PackageDepSpec & pds) { std::pair<MergeListIndex::iterator, MergeListIndex::const_iterator> pp( _imp->merge_list_index.equal_range(p->name())); @@ -1223,7 +1193,7 @@ DepList::add_error_package(const std::tr1::shared_ptr<const PackageID> & p, cons if (_imp->current_package_id()) pp.first->second->tags()->insert(make_named_values<DepTagEntry>( value_for<n::generation>(_imp->merge_list_generation), - value_for<n::tag>(std::tr1::shared_ptr<DepTag>(new DependencyDepTag(_imp->current_package_id(), pds, conditions))) + value_for<n::tag>(std::tr1::shared_ptr<DepTag>(new DependencyDepTag(_imp->current_package_id(), pds))) )); return; } @@ -1245,7 +1215,7 @@ DepList::add_error_package(const std::tr1::shared_ptr<const PackageID> & p, cons if (_imp->current_package_id()) our_merge_entry_position->tags()->insert(make_named_values<DepTagEntry>( value_for<n::generation>(_imp->merge_list_generation), - value_for<n::tag>(std::tr1::shared_ptr<DepTag>(new DependencyDepTag(_imp->current_package_id(), pds, conditions))) + value_for<n::tag>(std::tr1::shared_ptr<DepTag>(new DependencyDepTag(_imp->current_package_id(), pds))) )); _imp->merge_list_index.insert(std::make_pair(p->name(), our_merge_entry_position)); @@ -1253,8 +1223,7 @@ DepList::add_error_package(const std::tr1::shared_ptr<const PackageID> & p, cons void DepList::add_suggested_package(const std::tr1::shared_ptr<const PackageID> & p, - const PackageDepSpec & pds, const std::tr1::shared_ptr<DependencySpecTree::ConstItem> & conditions, - const std::tr1::shared_ptr<const DestinationsSet> & destinations) + const PackageDepSpec & pds, const std::tr1::shared_ptr<const DestinationsSet> & destinations) { std::pair<MergeListIndex::iterator, MergeListIndex::const_iterator> pp( _imp->merge_list_index.equal_range(p->name())); @@ -1283,14 +1252,14 @@ DepList::add_suggested_package(const std::tr1::shared_ptr<const PackageID> & p, if (_imp->current_package_id()) our_merge_entry_position->tags()->insert(make_named_values<DepTagEntry>( value_for<n::generation>(_imp->merge_list_generation), - value_for<n::tag>(std::tr1::shared_ptr<DepTag>(new DependencyDepTag(_imp->current_package_id(), pds, conditions))) + value_for<n::tag>(std::tr1::shared_ptr<DepTag>(new DependencyDepTag(_imp->current_package_id(), pds))) )); _imp->merge_list_index.insert(std::make_pair(p->name(), our_merge_entry_position)); } void -DepList::add_predeps(DependencySpecTree::ConstItem & d, const DepListDepsOption opt, const std::string & s, +DepList::add_predeps(const DependencySpecTree::BasicNode & d, const DepListDepsOption opt, const std::string & s, const std::tr1::shared_ptr<const DestinationsSet> & destinations, const bool only_if_not_suggested_label) { if (dl_deps_pre == opt || dl_deps_pre_or_post == opt) @@ -1312,7 +1281,7 @@ DepList::add_predeps(DependencySpecTree::ConstItem & d, const DepListDepsOption } void -DepList::add_postdeps(DependencySpecTree::ConstItem & d, const DepListDepsOption opt, const std::string & s, +DepList::add_postdeps(const DependencySpecTree::BasicNode & d, const DepListDepsOption opt, const std::string & s, const std::tr1::shared_ptr<const DestinationsSet> & destinations, const bool only_if_not_suggested_label) { if (dl_deps_pre_or_post == opt || dl_deps_post == opt || dl_deps_try_post == opt) @@ -1346,8 +1315,7 @@ DepList::add_postdeps(DependencySpecTree::ConstItem & d, const DepListDepsOption void DepList::add_already_installed_package(const std::tr1::shared_ptr<const PackageID> & p, const std::tr1::shared_ptr<const DepTag> & tag, - const PackageDepSpec & pds, const std::tr1::shared_ptr<DependencySpecTree::ConstItem> & conditions, - const std::tr1::shared_ptr<const DestinationsSet> & destinations) + const PackageDepSpec & pds, const std::tr1::shared_ptr<const DestinationsSet> & destinations) { Context context("When adding installed package '" + stringify(*p) + "':"); @@ -1375,28 +1343,28 @@ DepList::add_already_installed_package(const std::tr1::shared_ptr<const PackageI if (_imp->opts->dependency_tags() && _imp->current_package_id()) our_merge_entry->tags()->insert(make_named_values<DepTagEntry>( value_for<n::generation>(_imp->merge_list_generation), - value_for<n::tag>(std::tr1::shared_ptr<DepTag>(new DependencyDepTag(_imp->current_package_id(), pds, conditions))) + value_for<n::tag>(std::tr1::shared_ptr<DepTag>(new DependencyDepTag(_imp->current_package_id(), pds))) )); Save<MergeList::const_iterator> save_current_merge_list_entry(&_imp->current_merge_list_entry, our_merge_entry); if (p->build_dependencies_key()) - add_predeps(*p->build_dependencies_key()->value(), _imp->opts->installed_deps_pre(), "build", destinations, false); + add_predeps(*p->build_dependencies_key()->value()->root(), _imp->opts->installed_deps_pre(), "build", destinations, false); if (p->run_dependencies_key()) - add_predeps(*p->run_dependencies_key()->value(), _imp->opts->installed_deps_runtime(), "run", destinations, false); + add_predeps(*p->run_dependencies_key()->value()->root(), _imp->opts->installed_deps_runtime(), "run", destinations, false); if (p->post_dependencies_key()) - add_predeps(*p->post_dependencies_key()->value(), _imp->opts->installed_deps_post(), "post", destinations, true); + add_predeps(*p->post_dependencies_key()->value()->root(), _imp->opts->installed_deps_post(), "post", destinations, true); our_merge_entry->state() = dle_has_pre_deps; _imp->merge_list_insert_position = next(our_merge_entry); if (p->build_dependencies_key()) - add_postdeps(*p->build_dependencies_key()->value(), _imp->opts->installed_deps_pre(), "build", destinations, false); + add_postdeps(*p->build_dependencies_key()->value()->root(), _imp->opts->installed_deps_pre(), "build", destinations, false); if (p->run_dependencies_key()) - add_postdeps(*p->run_dependencies_key()->value(), _imp->opts->installed_deps_runtime(), "run", destinations, false); + add_postdeps(*p->run_dependencies_key()->value()->root(), _imp->opts->installed_deps_runtime(), "run", destinations, false); if (p->post_dependencies_key()) - add_postdeps(*p->post_dependencies_key()->value(), _imp->opts->installed_deps_post(), "post", destinations, true); + add_postdeps(*p->post_dependencies_key()->value()->root(), _imp->opts->installed_deps_post(), "post", destinations, true); } namespace @@ -1554,7 +1522,7 @@ DepList::prefer_installed_over_uninstalled(const PackageID & installed, } bool -DepList::already_installed(const DependencySpecTree::ConstItem & spec, +DepList::already_installed(const DependencySpecTree::BasicNode & spec, const std::tr1::shared_ptr<const DestinationsSet> & destinations) const { QueryVisitor visitor(this, destinations, _imp->env, _imp->current_package_id()); @@ -1684,11 +1652,12 @@ DepList::push_back(const DepListEntry & e) } bool -paludis::is_viable_any_child(const DependencySpecTree::ConstItem & i) +paludis::is_viable_any_child(const DependencySpecTree::BasicNode & i) { - const ConditionalDepSpec * const u(get_const_item(i)->as_conditional_dep_spec()); + const DependencySpecTree::NodeType<ConditionalDepSpec>::Type * const u(simple_visitor_cast< + const DependencySpecTree::NodeType<ConditionalDepSpec>::Type>(i)); if (0 != u) - return u->condition_met(); + return u->spec()->condition_met(); else return true; } diff --git a/paludis/dep_list.hh b/paludis/dep_list.hh index c9fb83fa7..0f32759f9 100644 --- a/paludis/dep_list.hh +++ b/paludis/dep_list.hh @@ -164,7 +164,7 @@ namespace paludis /** * Add a DepSpec with role context. */ - void add_in_role(const bool only_if_not_suggested_label, DependencySpecTree::ConstItem &, const std::string & role, + void add_in_role(const bool only_if_not_suggested_label, const DependencySpecTree::BasicNode &, const std::string & role, const std::tr1::shared_ptr<const DestinationsSet> &); /** @@ -178,32 +178,29 @@ namespace paludis * Add a package to the list. */ void add_package(const std::tr1::shared_ptr<const PackageID> &, const std::tr1::shared_ptr<const DepTag> &, - const PackageDepSpec &, const std::tr1::shared_ptr<DependencySpecTree::ConstItem> &, - const std::tr1::shared_ptr<const DestinationsSet> & destinations); + const PackageDepSpec &, const std::tr1::shared_ptr<const DestinationsSet> & destinations); /** * Add an already installed package to the list. */ void add_already_installed_package(const std::tr1::shared_ptr<const PackageID> &, const std::tr1::shared_ptr<const DepTag> &, - const PackageDepSpec &, const std::tr1::shared_ptr<DependencySpecTree::ConstItem> &, - const std::tr1::shared_ptr<const DestinationsSet> & destinations); + const PackageDepSpec &, const std::tr1::shared_ptr<const DestinationsSet> & destinations); /** * Add an error package to the list. */ - void add_error_package(const std::tr1::shared_ptr<const PackageID> &, const DepListEntryKind, - const PackageDepSpec &, const std::tr1::shared_ptr<DependencySpecTree::ConstItem> &); + void add_error_package(const std::tr1::shared_ptr<const PackageID> &, const DepListEntryKind, const PackageDepSpec &); /** * Add predependencies. */ - void add_predeps(DependencySpecTree::ConstItem &, const DepListDepsOption, const std::string &, + void add_predeps(const DependencySpecTree::BasicNode &, const DepListDepsOption, const std::string &, const std::tr1::shared_ptr<const DestinationsSet> & destinations, const bool only_if_not_suggested_label); /** * Add postdependencies. */ - void add_postdeps(DependencySpecTree::ConstItem &, const DepListDepsOption, const std::string &, + void add_postdeps(const DependencySpecTree::BasicNode &, const DepListDepsOption, const std::string &, const std::tr1::shared_ptr<const DestinationsSet> & destinations, const bool only_if_not_suggested_label); /** @@ -214,9 +211,8 @@ namespace paludis void add_not_top_level( const bool only_if_not_suggested_label, - DependencySpecTree::ConstItem &, - const std::tr1::shared_ptr<const DestinationsSet> & target_destinations, - const std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > & conditions); + const DependencySpecTree::BasicNode &, + const std::tr1::shared_ptr<const DestinationsSet> & target_destinations); public: ///\name Basic operations @@ -259,7 +255,7 @@ namespace paludis * Add the packages required to resolve an additional dependency * spec. */ - void add(SetSpecTree::ConstItem &, + void add(const SetSpecTree &, const std::tr1::shared_ptr<const DestinationsSet> & target_destinations); /** @@ -286,7 +282,7 @@ namespace paludis /** * Return whether a spec structure is already installed. */ - bool already_installed(DependencySpecTree::ConstItem &, + bool already_installed(const DependencySpecTree::BasicNode &, const std::tr1::shared_ptr<const DestinationsSet> & target_destinations) const; /** @@ -308,8 +304,7 @@ namespace paludis * Add a suggested package to the list. */ void add_suggested_package(const std::tr1::shared_ptr<const PackageID> &, - const PackageDepSpec &, const std::tr1::shared_ptr<DependencySpecTree::ConstItem> &, - const std::tr1::shared_ptr<const DestinationsSet> & destinations); + const PackageDepSpec &, const std::tr1::shared_ptr<const DestinationsSet> & destinations); }; #ifdef PALUDIS_HAVE_EXTERN_TEMPLATE diff --git a/paludis/dep_list_TEST.cc b/paludis/dep_list_TEST.cc index fff8eeca1..0cfc0efa2 100644 --- a/paludis/dep_list_TEST.cc +++ b/paludis/dep_list_TEST.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2008, 2009 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 @@ -18,7 +18,6 @@ */ #include "dep_list_TEST.hh" -#include <paludis/util/visitor-impl.hh> #include <paludis/util/set.hh> #include <paludis/package_id.hh> #include <paludis/mask.hh> @@ -2102,25 +2101,15 @@ namespace test_cases DepList d3(&env, DepListOptions()); d3.options()->fall_back() = dl_fall_back_as_needed_except_targets; - std::tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > t3(new ConstTreeSequence<SetSpecTree, AllDepSpec>( - std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); - t3->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>( - std::tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(parse_user_package_dep_spec("cat/one", - &env, UserPackageDepSpecOptions())))))); - t3->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>( - std::tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(parse_user_package_dep_spec("cat/two", - &env, UserPackageDepSpecOptions())))))); + std::tr1::shared_ptr<SetSpecTree> t3(new SetSpecTree(make_shared_ptr(new AllDepSpec))); + t3->root()->append(make_shared_ptr(new PackageDepSpec(parse_user_package_dep_spec("cat/one", &env, UserPackageDepSpecOptions())))); + t3->root()->append(make_shared_ptr(new PackageDepSpec(parse_user_package_dep_spec("cat/two", &env, UserPackageDepSpecOptions())))); TEST_CHECK_THROWS(d3.add(*t3, env.default_destinations()), DepListError); DepList d4(&env, DepListOptions()); - std::tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > t4(new ConstTreeSequence<SetSpecTree, AllDepSpec>( - std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); - t4->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>( - std::tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(parse_user_package_dep_spec("cat/one", - &env, UserPackageDepSpecOptions())))))); - t4->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>( - std::tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(parse_user_package_dep_spec("cat/three", - &env, UserPackageDepSpecOptions())))))); + std::tr1::shared_ptr<SetSpecTree> t4(new SetSpecTree(make_shared_ptr(new AllDepSpec))); + t4->root()->append(make_shared_ptr(new PackageDepSpec(parse_user_package_dep_spec("cat/one", &env, UserPackageDepSpecOptions())))); + t4->root()->append(make_shared_ptr(new PackageDepSpec(parse_user_package_dep_spec("cat/three", &env, UserPackageDepSpecOptions())))); TEST_CHECK_THROWS(d4.add(*t4, env.default_destinations()), DepListError); } } test_dep_list_fall_back_as_needed_not_targets; @@ -2155,14 +2144,9 @@ namespace test_cases DepList d2(&env, DepListOptions()); d2.options()->upgrade() = dl_upgrade_as_needed; - std::tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > t2(new ConstTreeSequence<SetSpecTree, AllDepSpec>( - std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); - t2->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>( - std::tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(parse_user_package_dep_spec("cat/one", - &env, UserPackageDepSpecOptions())))))); - t2->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>( - std::tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(parse_user_package_dep_spec("cat/two", - &env, UserPackageDepSpecOptions())))))); + std::tr1::shared_ptr<SetSpecTree> t2(new SetSpecTree(make_shared_ptr(new AllDepSpec))); + t2->root()->append(make_shared_ptr(new PackageDepSpec(parse_user_package_dep_spec("cat/one", &env, UserPackageDepSpecOptions())))); + t2->root()->append(make_shared_ptr(new PackageDepSpec(parse_user_package_dep_spec("cat/two", &env, UserPackageDepSpecOptions())))); d2.add(*t2, env.default_destinations()); TEST_CHECK_EQUAL(join(d2.begin(), d2.end(), " "), "cat/two-2:0::repo cat/one-1:0::repo"); } @@ -2252,52 +2236,6 @@ namespace test_cases DepList::Iterator it(d1.begin()); std::tr1::shared_ptr<DepListEntryTags> tags(it->tags()); TEST_CHECK_EQUAL(tags->size(), 3U); - bool cat_three_has_tag_from_cat_one(false); - bool cat_three_has_first_tag_from_cat_two(false); - bool cat_three_has_second_tag_from_cat_two(false); - - for (DepListEntryTags::ConstIterator tag_it(tags->begin()), - tag_it_end(tags->end()); tag_it_end != tag_it; ++tag_it) - { - if ("dependency" != tag_it->tag()->category()) - continue; - std::tr1::shared_ptr<const DependencyDepTag> tag( - std::tr1::static_pointer_cast<const DependencyDepTag>(tag_it->tag())); - - if ("cat/one-1:0::repo" == tag->short_text()) - { - cat_three_has_tag_from_cat_one = true; - TEST_CHECK_STRINGIFY_EQUAL(*tag->dependency(), "cat/three"); - StringifyFormatter ff; - erepository::DepSpecPrettyPrinter pretty(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); - tag->conditions()->accept(pretty); - TEST_CHECK_STRINGIFY_EQUAL(pretty, "cat/three"); - } - - else if ("cat/two-1:0::repo" == tag->short_text()) - { - if ("<cat/three-1" == stringify(*tag->dependency())) - { - cat_three_has_first_tag_from_cat_two = true; - StringifyFormatter ff; - erepository::DepSpecPrettyPrinter pretty(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); - tag->conditions()->accept(pretty); - TEST_CHECK_STRINGIFY_EQUAL(pretty, "enabled? ( || ( <cat/three-1 ) )"); - } - else if ("cat/three:0" == stringify(*tag->dependency())) - { - cat_three_has_second_tag_from_cat_two = true; - StringifyFormatter ff; - erepository::DepSpecPrettyPrinter pretty(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); - tag->conditions()->accept(pretty); - TEST_CHECK_STRINGIFY_EQUAL(pretty, "enabled? ( || ( cat/three:0 ) )"); - } - } - } - - TEST_CHECK(cat_three_has_tag_from_cat_one); - TEST_CHECK(cat_three_has_first_tag_from_cat_two); - TEST_CHECK(cat_three_has_second_tag_from_cat_two); // tags for cat/one ++it; @@ -2314,10 +2252,6 @@ namespace test_cases std::tr1::static_pointer_cast<const DependencyDepTag>(tags->begin()->tag())); TEST_CHECK_EQUAL(deptag->short_text(), "cat/two-1:0::repo"); TEST_CHECK_STRINGIFY_EQUAL(*deptag->dependency(), "=cat/four-1"); - StringifyFormatter ff; - erepository::DepSpecPrettyPrinter pretty(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); - deptag->conditions()->accept(pretty); - TEST_CHECK_STRINGIFY_EQUAL(pretty, "enabled? ( || ( =cat/four-1 ) )"); // tags for cat/two ++it; diff --git a/paludis/dep_spec.cc b/paludis/dep_spec.cc index 76c3da135..092de8f27 100644 --- a/paludis/dep_spec.cc +++ b/paludis/dep_spec.cc @@ -35,7 +35,6 @@ #include <paludis/util/indirect_iterator-impl.hh> #include <paludis/util/options.hh> #include <paludis/util/make_shared_ptr.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/fs_entry.hh> #include <paludis/metadata_key.hh> #include <tr1/functional> @@ -1258,6 +1257,7 @@ template class LabelsDepSpec<URILabel>; template class LabelsDepSpec<DependencyLabel>; template class Sequence<std::tr1::shared_ptr<const AdditionalPackageDepSpecRequirement> >; +template class WrappedForwardIterator<AdditionalPackageDepSpecRequirements::ConstIteratorTag, const std::tr1::shared_ptr<const AdditionalPackageDepSpecRequirement> >; template class Cloneable<DepSpec>; template class PrivateImplementationPattern<ConditionalDepSpec>; diff --git a/paludis/dep_spec_TEST.cc b/paludis/dep_spec_TEST.cc index 6861fda28..3af1e98b0 100644 --- a/paludis/dep_spec_TEST.cc +++ b/paludis/dep_spec_TEST.cc @@ -24,8 +24,6 @@ #include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/util/iterator_funcs.hh> #include <paludis/util/options.hh> -#include <paludis/util/visitor_cast.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/make_shared_ptr.hh> #include <paludis/version_requirements.hh> #include <paludis/environments/test/test_environment.hh> diff --git a/paludis/dep_spec_flattener.cc b/paludis/dep_spec_flattener.cc index d235c046f..d5a5c213e 100644 --- a/paludis/dep_spec_flattener.cc +++ b/paludis/dep_spec_flattener.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh + * Copyright (c) 2006, 2007, 2008, 2009 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 @@ -19,13 +19,13 @@ #include <paludis/dep_spec_flattener.hh> #include <paludis/dep_spec.hh> -#include <paludis/dep_tree.hh> #include <paludis/environment.hh> -#include <paludis/repository.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/log.hh> #include <paludis/util/stringify.hh> +#include <paludis/util/wrapped_forward_iterator-impl.hh> +#include <paludis/util/make_shared_ptr.hh> +#include <paludis/repository.hh> #include <list> #include <algorithm> #include <set> @@ -43,6 +43,7 @@ namespace paludis const Environment * const env; std::list<std::tr1::shared_ptr<const Item_> > specs; + std::set<SetName> recursing_sets; Implementation(const Environment * const e) : env(e) @@ -79,78 +80,174 @@ DepSpecFlattener<Heirarchy_, Item_>::end() const return ConstIterator(_imp->specs.end()); } +namespace +{ + template <typename Heirarchy_, typename Item_, bool> + struct HandleNamedSet + { + inline static void handle(const typename Heirarchy_::template NodeType<NamedSetDepSpec>::Type &, DepSpecFlattener<Heirarchy_, Item_> &) + { + } + }; + + template <typename Heirarchy_, typename Item_> + struct HandleNamedSet<Heirarchy_, Item_, true> + { + inline static void handle(const typename Heirarchy_::template NodeType<NamedSetDepSpec>::Type & node, DepSpecFlattener<Heirarchy_, Item_> & f) + { + f.template handle_named_set<true>(*node.spec()); + } + }; +} + template <typename Heirarchy_, typename Item_> void -dep_spec_flattener_internals::VisitConditionalDepSpec<Heirarchy_, Item_, true>::visit_sequence(const ConditionalDepSpec & u, - typename Heirarchy_::ConstSequenceIterator cur, - typename Heirarchy_::ConstSequenceIterator e) +DepSpecFlattener<Heirarchy_, Item_>::visit(const typename Heirarchy_::template NodeType<NamedSetDepSpec>::Type & node) { - DepSpecFlattener<Heirarchy_, Item_> * const f(static_cast<DepSpecFlattener<Heirarchy_, Item_> *>(this)); - - if (u.condition_met()) - std::for_each(cur, e, accept_visitor(*f)); + HandleNamedSet<Heirarchy_, Item_, TypeListContains< + typename Heirarchy_::VisitableTypeList, typename Heirarchy_::template NodeType<NamedSetDepSpec>::Type>::value>::handle(node, *this); } -namespace paludis +namespace { -#ifndef PALUDIS_NO_DOUBLE_TEMPLATE - template <> -#endif - template <typename Heirarchy_, typename Item_> - struct Implementation<dep_spec_flattener_internals::VisitNamedSetDepSpec<Heirarchy_, Item_, true> > + template <typename Heirarchy_, typename Item_, typename MaybeItem_, bool> + struct HandleItem { - std::set<SetName> recursing_sets; + inline static void handle(const typename Heirarchy_::template NodeType<MaybeItem_>::Type &, DepSpecFlattener<Heirarchy_, Item_> &) + { + } + }; + + template <typename Heirarchy_, typename Item_, typename MaybeItem_> + struct HandleItem<Heirarchy_, Item_, MaybeItem_, true> + { + inline static void handle(const typename Heirarchy_::template NodeType<MaybeItem_>::Type & node, DepSpecFlattener<Heirarchy_, Item_> & f) + { + f.handle_item(*node.spec()); + } }; } template <typename Heirarchy_, typename Item_> -dep_spec_flattener_internals::VisitNamedSetDepSpec<Heirarchy_, Item_, true>::VisitNamedSetDepSpec() : - PrivateImplementationPattern<dep_spec_flattener_internals::VisitNamedSetDepSpec<Heirarchy_, Item_, true> >( - new Implementation<dep_spec_flattener_internals::VisitNamedSetDepSpec<Heirarchy_, Item_, true> >) +void +DepSpecFlattener<Heirarchy_, Item_>::visit(const typename Heirarchy_::template NodeType<PlainTextDepSpec>::Type & node) { + HandleItem<Heirarchy_, Item_, PlainTextDepSpec, TypeListContains< + typename Heirarchy_::VisitableTypeList, typename Heirarchy_::template NodeType<PlainTextDepSpec>::Type>::value>::handle(node, *this); } template <typename Heirarchy_, typename Item_> -dep_spec_flattener_internals::VisitNamedSetDepSpec<Heirarchy_, Item_, true>::~VisitNamedSetDepSpec() +void +DepSpecFlattener<Heirarchy_, Item_>::visit(const typename Heirarchy_::template NodeType<PackageDepSpec>::Type & node) { + HandleItem<Heirarchy_, Item_, PackageDepSpec, TypeListContains< + typename Heirarchy_::VisitableTypeList, typename Heirarchy_::template NodeType<PackageDepSpec>::Type>::value>::handle(node, *this); } template <typename Heirarchy_, typename Item_> void -dep_spec_flattener_internals::VisitNamedSetDepSpec<Heirarchy_, Item_, true>::visit_leaf(const NamedSetDepSpec & s) +DepSpecFlattener<Heirarchy_, Item_>::visit(const typename Heirarchy_::template NodeType<SimpleURIDepSpec>::Type & node) { - DepSpecFlattener<Heirarchy_, Item_> * const f(static_cast<DepSpecFlattener<Heirarchy_, Item_> *>(this)); + HandleItem<Heirarchy_, Item_, SimpleURIDepSpec, TypeListContains< + typename Heirarchy_::VisitableTypeList, typename Heirarchy_::template NodeType<SimpleURIDepSpec>::Type>::value>::handle(node, *this); +} - Context context("When expanding named set '" + stringify(s) + "':"); +template <typename Heirarchy_, typename Item_> +void +DepSpecFlattener<Heirarchy_, Item_>::visit(const typename Heirarchy_::template NodeType<PlainTextLabelDepSpec>::Type &) +{ +} - std::tr1::shared_ptr<const SetSpecTree::ConstItem> set(f->_imp->env->set(s.name())); +template <typename Heirarchy_, typename Item_> +void +DepSpecFlattener<Heirarchy_, Item_>::visit(const typename Heirarchy_::template NodeType<AllDepSpec>::Type & node) +{ + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); +} - if (! set) - throw NoSuchSetError(stringify(s.name())); +namespace +{ + template <typename Heirarchy_, typename Item_, bool> + struct HandleAny + { + inline static void handle(const typename Heirarchy_::template NodeType<AnyDepSpec>::Type &, DepSpecFlattener<Heirarchy_, Item_> &) + { + } + }; - if (! this->_imp->recursing_sets.insert(s.name()).second) - throw RecursivelyDefinedSetError(stringify(s.name())); + template <typename Heirarchy_, typename Item_> + struct HandleAny<Heirarchy_, Item_, true> + { + inline static void handle(const typename Heirarchy_::template NodeType<AnyDepSpec>::Type & node, DepSpecFlattener<Heirarchy_, Item_> & f) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(f)); + } + }; +} - set->accept(*f); +template <typename Heirarchy_, typename Item_> +void +DepSpecFlattener<Heirarchy_, Item_>::visit(const typename Heirarchy_::template NodeType<AnyDepSpec>::Type & node) +{ + HandleAny<Heirarchy_, Item_, TypeListContains< + typename Heirarchy_::VisitableTypeList, typename Heirarchy_::template NodeType<AnyDepSpec>::Type>::value>::handle(node, *this); +} - this->_imp->recursing_sets.erase(s.name()); +namespace +{ + template <typename Heirarchy_, typename Item_, bool> + struct HandleConditional + { + inline static void handle(const typename Heirarchy_::template NodeType<ConditionalDepSpec>::Type &, DepSpecFlattener<Heirarchy_, Item_> &) + { + } + }; + + template <typename Heirarchy_, typename Item_> + struct HandleConditional<Heirarchy_, Item_, true> + { + inline static void handle(const typename Heirarchy_::template NodeType<ConditionalDepSpec>::Type & node, DepSpecFlattener<Heirarchy_, Item_> & f) + { + if (node.spec()->condition_met()) + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(f)); + } + }; } template <typename Heirarchy_, typename Item_> void -DepSpecFlattener<Heirarchy_, Item_>::visit_leaf(const Item_ & p) +DepSpecFlattener<Heirarchy_, Item_>::visit(const typename Heirarchy_::template NodeType<ConditionalDepSpec>::Type & node) { - _imp->specs.push_back(std::tr1::static_pointer_cast<const Item_>(p.clone())); + HandleConditional<Heirarchy_, Item_, TypeListContains< + typename Heirarchy_::VisitableTypeList, typename Heirarchy_::template NodeType<ConditionalDepSpec>::Type>::value>::handle(node, *this); } template <typename Heirarchy_, typename Item_> +template <bool> void -dep_spec_flattener_internals::VisitPlainTextLabelDepSpec<Heirarchy_, Item_, true>::visit_leaf(const PlainTextLabelDepSpec &) +DepSpecFlattener<Heirarchy_, Item_>::handle_named_set(const NamedSetDepSpec & spec) { + if (! _imp->recursing_sets.insert(spec.name()).second) + throw RecursivelyDefinedSetError(stringify(spec.name())); + + std::tr1::shared_ptr<const SetSpecTree> set(_imp->env->set(spec.name())); + if (! set) + throw NoSuchSetError(stringify(spec.name())); + + set->root()->accept(*this); + + _imp->recursing_sets.erase(spec.name()); +} + +template <typename Heirarchy_, typename Item_> +void +DepSpecFlattener<Heirarchy_, Item_>::handle_item(const Item_ & spec) +{ + _imp->specs.push_back(std::tr1::static_pointer_cast<const Item_>(spec.clone())); } template class DepSpecFlattener<ProvideSpecTree, PackageDepSpec>; -template class DepSpecFlattener<SetSpecTree, PackageDepSpec>; template class DepSpecFlattener<PlainTextSpecTree, PlainTextDepSpec>; +template class DepSpecFlattener<SetSpecTree, PackageDepSpec>; template class DepSpecFlattener<SimpleURISpecTree, SimpleURIDepSpec>; diff --git a/paludis/dep_spec_flattener.hh b/paludis/dep_spec_flattener.hh index bbb6cc1fe..0996f073c 100644 --- a/paludis/dep_spec_flattener.hh +++ b/paludis/dep_spec_flattener.hh @@ -23,10 +23,10 @@ #include <paludis/environment-fwd.hh> #include <paludis/package_id-fwd.hh> #include <paludis/dep_spec-fwd.hh> +#include <paludis/spec_tree.hh> #include <paludis/util/attributes.hh> #include <paludis/util/instantiation_policy.hh> #include <paludis/util/private_implementation_pattern.hh> -#include <paludis/util/visitor.hh> #include <paludis/util/no_type.hh> #include <paludis/util/wrapped_forward_iterator-fwd.hh> #include <tr1/memory> @@ -43,118 +43,14 @@ namespace paludis { - /** \namespace dep_spec_flattener_internals - * - * For internal use by DepSpecFlattener. - * - * \ingroup g_dep_spec - * \since 0.26 - */ - namespace dep_spec_flattener_internals - { - /** - * Implement visit for NamedSetDepSpec, if necessary. - * - * \ingroup g_dep_spec - * \since 0.26 - * \nosubgrouping - */ - template <typename H_, typename I_, bool b_> - struct VisitNamedSetDepSpec - { - void visit_leaf(const NoType<0u> &); - }; - - /** - * Implement visit for NamedSetDepSpec, if necessary. - * - * \ingroup g_dep_spec - * \since 0.26 - * \nosubgrouping - */ - template <typename H_, typename I_> - class VisitNamedSetDepSpec<H_, I_, true> : - public virtual visitor_internals::Visits<const TreeLeaf<H_, NamedSetDepSpec> >, - private PrivateImplementationPattern<VisitNamedSetDepSpec<H_, I_, true> > - { - private: - using PrivateImplementationPattern<VisitNamedSetDepSpec<H_, I_, true> >::_imp; - - protected: - VisitNamedSetDepSpec(); - ~VisitNamedSetDepSpec(); - - public: - void visit_leaf(const NamedSetDepSpec &); - }; - - /** - * Implement visit for PlainTextLabelDepSpec, if necessary. - * - * \ingroup g_dep_spec - * \since 0.32 - * \nosubgrouping - */ - template <typename H_, typename I_, bool b_> - struct VisitPlainTextLabelDepSpec - { - void visit_leaf(const NoType<1u> &); - }; - - /** - * Implement visit for PlainTextLabelDepSpec, if necessary. - * - * \ingroup g_dep_spec - * \since 0.32 - * \nosubgrouping - */ - template <typename H_, typename I_> - class VisitPlainTextLabelDepSpec<H_, I_, true> : - public virtual visitor_internals::Visits<const TreeLeaf<H_, PlainTextLabelDepSpec> > - { - public: - void visit_leaf(const PlainTextLabelDepSpec &); - }; - - /** - * Implement visit for ConditionalDepSpec, if necessary. - * - * \ingroup g_dep_spec - * \since 0.26 - * \nosubgrouping - */ - template <typename H_, typename I_, bool b_> - struct VisitConditionalDepSpec - { - void visit_sequence(const NoType<0u> &); - }; - - /** - * Implement visit for ConditionalDepSpec, if necessary. - * - * \ingroup g_dep_spec - * \since 0.26 - * \nosubgrouping - */ - template <typename H_, typename I_> - struct VisitConditionalDepSpec<H_, I_, true> : - virtual visitor_internals::Visits<const ConstTreeSequence<H_, ConditionalDepSpec> > - { - void visit_sequence( - const ConditionalDepSpec &, - typename H_::ConstSequenceIterator, - typename H_::ConstSequenceIterator); - }; - } - /** * Extract the enabled components of a dep heirarchy for a particular * package. Sets, via NamedSetDepSpec, are automatically expanded. * * This template can be instantiated as: * - * - DepSpecFlattener<ProvideSpecTree, PlainTextDepSpec> - * - DepSpecFlattener<PlainTextDepSpec, PlainTextDepSpec> + * - DepSpecFlattener<ProvideSpecTree, PackageDepSpec> + * - DepSpecFlattener<PlainTextSpecTree, PlainTextDepSpec> * - DepSpecFlattener<SetSpecTree, PackageDepSpec> * - DepSpecFlattener<SimpleURISpecTree, SimpleURIDepSpec> * @@ -168,44 +64,33 @@ namespace paludis template <typename Heirarchy_, typename Item_> class PALUDIS_VISIBLE DepSpecFlattener : private InstantiationPolicy<DepSpecFlattener<Heirarchy_, Item_>, instantiation_method::NonCopyableTag>, - private PrivateImplementationPattern<DepSpecFlattener<Heirarchy_, Item_> >, - public ConstVisitor<Heirarchy_>, - public ConstVisitor<Heirarchy_>::template VisitConstSequence<DepSpecFlattener<Heirarchy_, Item_>, AllDepSpec>, - public dep_spec_flattener_internals::VisitNamedSetDepSpec< - Heirarchy_, Item_, ConstVisitor<Heirarchy_>::template Contains<const TreeLeaf<Heirarchy_, NamedSetDepSpec> >::value>, - public dep_spec_flattener_internals::VisitPlainTextLabelDepSpec< - Heirarchy_, Item_, ConstVisitor<Heirarchy_>::template Contains<const TreeLeaf<Heirarchy_, PlainTextLabelDepSpec> >::value>, - public dep_spec_flattener_internals::VisitConditionalDepSpec< - Heirarchy_, Item_, ConstVisitor<Heirarchy_>::template Contains<const ConstTreeSequence<Heirarchy_, ConditionalDepSpec> >::value> + private PrivateImplementationPattern<DepSpecFlattener<Heirarchy_, Item_> > { - friend class dep_spec_flattener_internals::VisitNamedSetDepSpec< - Heirarchy_, Item_, ConstVisitor<Heirarchy_>::template Contains<const TreeLeaf<Heirarchy_, NamedSetDepSpec> >::value>; - friend class dep_spec_flattener_internals::VisitPlainTextLabelDepSpec< - Heirarchy_, Item_, ConstVisitor<Heirarchy_>::template Contains<const TreeLeaf<Heirarchy_, PlainTextLabelDepSpec> >::value>; - friend class dep_spec_flattener_internals::VisitConditionalDepSpec< - Heirarchy_, Item_, ConstVisitor<Heirarchy_>::template Contains<const ConstTreeSequence<Heirarchy_, ConditionalDepSpec> >::value>; - private: typename PrivateImplementationPattern<DepSpecFlattener<Heirarchy_, Item_> >::ImpPtr & _imp; public: - ///\name Visit methods - ///{ + ///\name Visit operations + ///\{ - using ConstVisitor<Heirarchy_>::template VisitConstSequence<DepSpecFlattener<Heirarchy_, Item_>, AllDepSpec>::visit_sequence; + void visit(const typename Heirarchy_::template NodeType<NamedSetDepSpec>::Type & node); + void visit(const typename Heirarchy_::template NodeType<PlainTextDepSpec>::Type & node); + void visit(const typename Heirarchy_::template NodeType<PackageDepSpec>::Type & node); + void visit(const typename Heirarchy_::template NodeType<SimpleURIDepSpec>::Type & node); + void visit(const typename Heirarchy_::template NodeType<PlainTextLabelDepSpec>::Type & node); - using dep_spec_flattener_internals::VisitConditionalDepSpec<Heirarchy_, Item_, - ConstVisitor<Heirarchy_>::template Contains<const ConstTreeSequence<Heirarchy_, ConditionalDepSpec> >::value>::visit_sequence; + void visit(const typename Heirarchy_::template NodeType<AllDepSpec>::Type & node); + void visit(const typename Heirarchy_::template NodeType<AnyDepSpec>::Type & node); + void visit(const typename Heirarchy_::template NodeType<ConditionalDepSpec>::Type & node); - using dep_spec_flattener_internals::VisitNamedSetDepSpec<Heirarchy_, Item_, - ConstVisitor<Heirarchy_>::template Contains<const TreeLeaf<Heirarchy_, NamedSetDepSpec> >::value>::visit_leaf; + ///\} - using dep_spec_flattener_internals::VisitPlainTextLabelDepSpec<Heirarchy_, Item_, - ConstVisitor<Heirarchy_>::template Contains<const TreeLeaf<Heirarchy_, PlainTextLabelDepSpec> >::value>::visit_leaf; + ///\name Visit implementation operations - void visit_leaf(const Item_ &); + template <bool b_> void handle_named_set(const NamedSetDepSpec & spec); + void handle_item(const Item_ & spec); - ///} + ///\} ///\name Basic operations ///\{ @@ -227,6 +112,13 @@ namespace paludis ///\} }; + +#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE + extern template class DepSpecFlattener<ProvideSpecTree, PackageDepSpec>; + extern template class DepSpecFlattener<PlainTextSpecTree, PlainTextDepSpec>; + extern template class DepSpecFlattener<SetSpecTree, PackageDepSpec>; + extern template class DepSpecFlattener<SimpleURISpecTree, SimpleURIDepSpec>; +#endif } #endif diff --git a/paludis/dep_tag-fwd.hh b/paludis/dep_tag-fwd.hh index b3da5559d..a505a58f1 100644 --- a/paludis/dep_tag-fwd.hh +++ b/paludis/dep_tag-fwd.hh @@ -20,7 +20,6 @@ #ifndef PALUDIS_GUARD_PALUDIS_DEP_TAG_FWD_HH #define PALUDIS_GUARD_PALUDIS_DEP_TAG_FWD_HH 1 -#include <paludis/util/visitor-fwd.hh> #include <paludis/util/set-fwd.hh> #include <paludis/util/attributes.hh> diff --git a/paludis/dep_tag.cc b/paludis/dep_tag.cc index 8e9f15d72..4b912f8eb 100644 --- a/paludis/dep_tag.cc +++ b/paludis/dep_tag.cc @@ -20,12 +20,13 @@ #include <paludis/dep_tag.hh> #include <paludis/dep_spec.hh> #include <paludis/dep_label.hh> +#include <paludis/spec_tree.hh> #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/instantiation_policy-impl.hh> #include <paludis/util/set-impl.hh> #include <paludis/util/mutex.hh> #include <paludis/util/indirect_iterator-impl.hh> -#include <paludis/util/visitor-impl.hh> +#include <paludis/util/accept_visitor.hh> #include <algorithm> #include <sstream> @@ -140,68 +141,6 @@ DepTag::~DepTag() namespace { - struct DepSpecStringifier : - ConstVisitor<DependencySpecTree> - { - std::ostringstream s; - - void - visit_sequence(const AllDepSpec &, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) - { - s << "( "; - std::for_each(cur, end, accept_visitor(*this)); - s << ") "; - } - - void - visit_sequence(const AnyDepSpec &, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) - { - s << "|| ( "; - std::for_each(cur, end, accept_visitor(*this)); - s << ") "; - } - - void - visit_sequence(const ConditionalDepSpec & a, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) - { - s << stringify(a) << " ( "; - std::for_each(cur, end, accept_visitor(*this)); - s << ") "; - } - - void - visit_leaf(const PackageDepSpec & p) - { - s << p << " "; - } - - void - visit_leaf(const BlockDepSpec & b) - { - s << b << " "; - } - - void - visit_leaf(const DependencyLabelsDepSpec & l) - { - std::copy(indirect_iterator(l.begin()), indirect_iterator(l.end()), - std::ostream_iterator<DependencyLabel>(s, ",")); - s << ":"; - } - - void - visit_leaf(const NamedSetDepSpec & p) - { - s << p << " "; - } - }; - struct DepTagComparator { std::string value; @@ -219,9 +158,6 @@ namespace void visit(const DependencyDepTag & t) { value = stringify(*t.package_id()) + "," + stringify(*t.dependency()) + ","; - DepSpecStringifier s; - t.conditions()->accept(s); - value.append(s.s.str()); } void visit(const TargetDepTag & t) @@ -337,22 +273,18 @@ namespace paludis std::tr1::shared_ptr<const PackageID> id; const std::tr1::shared_ptr<PackageDepSpec> spec; - const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> cond; - Implementation(const std::tr1::shared_ptr<const PackageID> & i, - const PackageDepSpec & d, const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> & s) : + Implementation(const std::tr1::shared_ptr<const PackageID> & i, const PackageDepSpec & d) : id(i), - spec(std::tr1::static_pointer_cast<PackageDepSpec>(d.clone())), - cond(s) + spec(std::tr1::static_pointer_cast<PackageDepSpec>(d.clone())) { spec->set_tag(std::tr1::shared_ptr<const DepTag>()); } }; } -DependencyDepTag::DependencyDepTag(const std::tr1::shared_ptr<const PackageID> & i, const PackageDepSpec & d, - const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> & s) : - PrivateImplementationPattern<DependencyDepTag>(new Implementation<DependencyDepTag>(i, d, s)) +DependencyDepTag::DependencyDepTag(const std::tr1::shared_ptr<const PackageID> & i, const PackageDepSpec & d) : + PrivateImplementationPattern<DependencyDepTag>(new Implementation<DependencyDepTag>(i, d)) { } @@ -384,12 +316,6 @@ DependencyDepTag::dependency() const return _imp->spec; } -const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> -DependencyDepTag::conditions() const -{ - return _imp->cond; -} - TargetDepTag::TargetDepTag() { } diff --git a/paludis/dep_tag.hh b/paludis/dep_tag.hh index dbb56d09c..e5ffeadf9 100644 --- a/paludis/dep_tag.hh +++ b/paludis/dep_tag.hh @@ -30,14 +30,13 @@ * - \ref example_dep_tag.cc "example_dep_tag.cc" (for tags) * - \ref example_dep_spec.cc "example_dep_spec.cc" (for specifications) * - \ref example_dep_label.cc "example_dep_label.cc" (for labels) - * - \ref example_dep_tree.cc "example_dep_tree.cc" (for specification trees) */ #include <paludis/dep_tag-fwd.hh> #include <paludis/dep_spec-fwd.hh> -#include <paludis/dep_tree.hh> #include <paludis/name-fwd.hh> #include <paludis/package_id-fwd.hh> +#include <paludis/spec_tree-fwd.hh> #include <paludis/util/instantiation_policy.hh> #include <paludis/util/simple_visitor.hh> #include <paludis/util/exception.hh> @@ -278,8 +277,7 @@ namespace paludis ///\name Basic operations ///\{ - DependencyDepTag(const std::tr1::shared_ptr<const PackageID> &, const PackageDepSpec &, - const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> &); + DependencyDepTag(const std::tr1::shared_ptr<const PackageID> &, const PackageDepSpec &); ~DependencyDepTag(); @@ -298,12 +296,6 @@ namespace paludis * The PackageDepSpec that pulled us in. */ const std::tr1::shared_ptr<const PackageDepSpec> dependency() const; - - /** - * The AnyDepSpec instances and ConditionalDepSpec instances that our dependency - * is conditional upon. - */ - const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> conditions() const; }; /** diff --git a/paludis/dep_tree-fwd.hh b/paludis/dep_tree-fwd.hh deleted file mode 100644 index 8b5356f8d..000000000 --- a/paludis/dep_tree-fwd.hh +++ /dev/null @@ -1,42 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2005, 2006, 2007, 2008 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 - * Public License version 2, as published by the Free Software Foundation. - * - * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef PALUDIS_GUARD_PALUDIS_DEP_TREE_FWD_HH -#define PALUDIS_GUARD_PALUDIS_DEP_TREE_FWD_HH 1 - -/** \file - * Forward declarations for paludis/dep_tree.hh . - * - * \ingroup g_dep_spec - */ - -namespace paludis -{ - struct GenericSpecTree; - struct LicenseSpecTree; - struct FetchableURISpecTree; - struct SimpleURISpecTree; - struct FlattenableSpecTree; - struct ProvideSpecTree; - struct PlainTextSpecTree; - struct DependencySpecTree; - struct SetSpecTree; -} - -#endif diff --git a/paludis/dep_tree.cc b/paludis/dep_tree.cc deleted file mode 100644 index 0d8b0b29c..000000000 --- a/paludis/dep_tree.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2005, 2006, 2007, 2008 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 - * Public License version 2, as published by the Free Software Foundation. - * - * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <paludis/dep_tree.hh> -#include <paludis/util/visitor-impl.hh> - -using namespace paludis; - -template class ConstVisitor<GenericSpecTree>; -template class ConstAcceptInterface<GenericSpecTree>; -template class TreeLeaf<GenericSpecTree, PackageDepSpec>; -template class TreeLeaf<GenericSpecTree, BlockDepSpec>; -template class TreeLeaf<GenericSpecTree, PlainTextDepSpec>; -template class TreeLeaf<GenericSpecTree, SimpleURIDepSpec>; -template class TreeLeaf<GenericSpecTree, FetchableURIDepSpec>; -template class TreeLeaf<GenericSpecTree, LicenseDepSpec>; -template class ConstTreeSequence<GenericSpecTree, AllDepSpec>; -template class ConstTreeSequence<GenericSpecTree, AnyDepSpec>; -template class ConstTreeSequence<GenericSpecTree, ConditionalDepSpec>; - -template class ConstVisitor<LicenseSpecTree>; -template class ConstAcceptInterface<LicenseSpecTree>; -template class TreeLeaf<LicenseSpecTree, LicenseDepSpec>; -template class ConstTreeSequence<LicenseSpecTree, AllDepSpec>; -template class ConstTreeSequence<LicenseSpecTree, AnyDepSpec>; -template class ConstTreeSequence<LicenseSpecTree, ConditionalDepSpec>; - -template class ConstVisitor<FetchableURISpecTree>; -template class ConstAcceptInterface<FetchableURISpecTree>; -template class TreeLeaf<FetchableURISpecTree, FetchableURIDepSpec>; -template class ConstTreeSequence<FetchableURISpecTree, AllDepSpec>; -template class ConstTreeSequence<FetchableURISpecTree, ConditionalDepSpec>; - -template class ConstVisitor<SimpleURISpecTree>; -template class ConstAcceptInterface<SimpleURISpecTree>; -template class TreeLeaf<SimpleURISpecTree, SimpleURIDepSpec>; -template class ConstTreeSequence<SimpleURISpecTree, AllDepSpec>; -template class ConstTreeSequence<SimpleURISpecTree, ConditionalDepSpec>; - -template class ConstVisitor<ProvideSpecTree>; -template class ConstAcceptInterface<ProvideSpecTree>; -template class TreeLeaf<ProvideSpecTree, PackageDepSpec>; -template class ConstTreeSequence<ProvideSpecTree, AllDepSpec>; -template class ConstTreeSequence<ProvideSpecTree, ConditionalDepSpec>; - -template class ConstVisitor<PlainTextSpecTree>; -template class ConstAcceptInterface<PlainTextSpecTree>; -template class TreeLeaf<PlainTextSpecTree, PlainTextDepSpec>; -template class ConstTreeSequence<PlainTextSpecTree, AllDepSpec>; -template class ConstTreeSequence<PlainTextSpecTree, ConditionalDepSpec>; - -template class ConstVisitor<DependencySpecTree>; -template class TreeLeaf<DependencySpecTree, PackageDepSpec>; -template class TreeLeaf<DependencySpecTree, BlockDepSpec>; -template class ConstTreeSequence<DependencySpecTree, AllDepSpec>; -template class ConstTreeSequence<DependencySpecTree, AnyDepSpec>; -template class ConstTreeSequence<DependencySpecTree, ConditionalDepSpec>; -template class ConstAcceptInterface<DependencySpecTree>; - -template class ConstVisitor<SetSpecTree>; -template class ConstAcceptInterface<SetSpecTree>; -template class TreeLeaf<SetSpecTree, PackageDepSpec>; -template class ConstTreeSequence<SetSpecTree, AllDepSpec>; - diff --git a/paludis/dep_tree.hh b/paludis/dep_tree.hh deleted file mode 100644 index 2d1874be3..000000000 --- a/paludis/dep_tree.hh +++ /dev/null @@ -1,318 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2005, 2006, 2007, 2008 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 - * Public License version 2, as published by the Free Software Foundation. - * - * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef PALUDIS_GUARD_PALUDIS_DEP_TREE_HH -#define PALUDIS_GUARD_PALUDIS_DEP_TREE_HH 1 - -#include <paludis/dep_tree-fwd.hh> -#include <paludis/dep_spec-fwd.hh> -#include <paludis/util/visitor.hh> - -/** \file - * Declarations for dependency spec trees. - * - * \ingroup g_dep_spec - * - * \section Examples - * - * - \ref example_dep_tree.cc "example_dep_tree.cc" (for specification trees) - * - \ref example_dep_spec.cc "example_dep_spec.cc" (for specifications) - * - \ref example_dep_label.cc "example_dep_label.cc" (for labels) - * - \ref example_dep_tag.cc "example_dep_tag.cc" (for tags) - */ - -namespace paludis -{ - /** - * A generic dep tree heirarchy. - * - * Heirarchies conforming to this type will likely not ever be created. - * However, the heirarchy is useful for creating generic visitors that can - * handle any of the subheirarchies. - * - * \ingroup g_dep_spec - * \since 0.26 - * \nosubgrouping - */ - struct GenericSpecTree : - VisitorTypes< - GenericSpecTree, - DepSpec, - TreeLeaf<GenericSpecTree, PlainTextDepSpec>, - TreeLeaf<GenericSpecTree, PlainTextLabelDepSpec>, - TreeLeaf<GenericSpecTree, SimpleURIDepSpec>, - TreeLeaf<GenericSpecTree, FetchableURIDepSpec>, - TreeLeaf<GenericSpecTree, LicenseDepSpec>, - TreeLeaf<GenericSpecTree, PackageDepSpec>, - TreeLeaf<GenericSpecTree, BlockDepSpec>, - TreeLeaf<GenericSpecTree, URILabelsDepSpec>, - TreeLeaf<GenericSpecTree, DependencyLabelsDepSpec>, - TreeLeaf<GenericSpecTree, NamedSetDepSpec>, - ConstTreeSequence<GenericSpecTree, AllDepSpec>, - ConstTreeSequence<GenericSpecTree, AnyDepSpec>, - ConstTreeSequence<GenericSpecTree, ConditionalDepSpec> - > - { - /** - * A formatter that can handle any formattable type found in a - * GenericSpecTree. - * - * \since 0.26 - * \ingroup g_dep_spec - * \nosubgrouping - */ - typedef Formatter< - ConditionalDepSpec, - PlainTextDepSpec, - SimpleURIDepSpec, - FetchableURIDepSpec, - LicenseDepSpec, - PackageDepSpec, - BlockDepSpec, - URILabelsDepSpec, - DependencyLabelsDepSpec, - NamedSetDepSpec, - PlainTextLabelDepSpec - > ItemFormatter; - }; - - /** - * A heirarchy for licence specifications. - * - * \ingroup g_dep_spec - * \since 0.26 - * \nosubgrouping - */ - struct LicenseSpecTree : - VisitorTypes< - LicenseSpecTree, - DepSpec, - TreeLeaf<LicenseSpecTree, LicenseDepSpec>, - ConstTreeSequence<LicenseSpecTree, AllDepSpec>, - ConstTreeSequence<LicenseSpecTree, AnyDepSpec>, - ConstTreeSequence<LicenseSpecTree, ConditionalDepSpec> - > - { - /** - * A formatter that can handle any formattable type found in a - * LicenseSpecTree. - * - * \since 0.26 - * \ingroup g_dep_spec - * \nosubgrouping - */ - typedef Formatter< - ConditionalDepSpec, - LicenseDepSpec - > ItemFormatter; - }; - - /** - * A heirarchy for fetchable URI heirarchies. - * - * \ingroup g_dep_spec - * \since 0.26 - * \nosubgrouping - */ - struct FetchableURISpecTree : - VisitorTypes< - FetchableURISpecTree, - DepSpec, - TreeLeaf<FetchableURISpecTree, FetchableURIDepSpec>, - TreeLeaf<FetchableURISpecTree, URILabelsDepSpec>, - ConstTreeSequence<FetchableURISpecTree, AllDepSpec>, - ConstTreeSequence<FetchableURISpecTree, ConditionalDepSpec> - > - { - /** - * A formatter that can handle any formattable type found in a - * FetchableURISpecTree. - * - * \since 0.26 - * \ingroup g_dep_spec - * \nosubgrouping - */ - typedef Formatter< - ConditionalDepSpec, - FetchableURIDepSpec, - URILabelsDepSpec - > ItemFormatter; - }; - - /** - * A heirarchy for simple URI heirarchies. - * - * \ingroup g_dep_spec - * \since 0.26 - * \nosubgrouping - */ - struct SimpleURISpecTree : - VisitorTypes< - SimpleURISpecTree, - DepSpec, - TreeLeaf<SimpleURISpecTree, SimpleURIDepSpec>, - ConstTreeSequence<SimpleURISpecTree, AllDepSpec>, - ConstTreeSequence<SimpleURISpecTree, ConditionalDepSpec> - > - { - /** - * A formatter that can handle any formattable type found in a - * SimpleURISpecTree. - * - * \since 0.26 - * \ingroup g_dep_spec - * \nosubgrouping - */ - typedef Formatter< - ConditionalDepSpec, - SimpleURIDepSpec - > ItemFormatter; - }; - - /** - * A heirarchy of provided packages. - * - * \ingroup g_dep_spec - * \since 0.26 - * \nosubgrouping - */ - struct ProvideSpecTree : - VisitorTypes< - ProvideSpecTree, - DepSpec, - TreeLeaf<ProvideSpecTree, PackageDepSpec>, - ConstTreeSequence<ProvideSpecTree, AllDepSpec>, - ConstTreeSequence<ProvideSpecTree, ConditionalDepSpec> - > - { - /** - * A formatter that can handle any formattable type found in a - * ProvideSpecTree. - * - * \ingroup g_dep_spec - * \since 0.26 - * \nosubgrouping - */ - typedef Formatter< - ConditionalDepSpec, - PackageDepSpec - > ItemFormatter; - }; - - /** - * A heirarchy of plain text values. - * - * \ingroup g_dep_spec - * \since 0.30 - * \nosubgrouping - */ - struct PlainTextSpecTree : - VisitorTypes< - PlainTextSpecTree, - DepSpec, - TreeLeaf<PlainTextSpecTree, PlainTextDepSpec>, - TreeLeaf<PlainTextSpecTree, PlainTextLabelDepSpec>, - ConstTreeSequence<PlainTextSpecTree, AllDepSpec>, - ConstTreeSequence<PlainTextSpecTree, ConditionalDepSpec> - > - { - /** - * A formatter that can handle any formattable type found in a - * PlainTextSpecTree. - * - * \ingroup g_dep_spec - * \since 0.26 - * \nosubgrouping - */ - typedef Formatter< - ConditionalDepSpec, - PlainTextDepSpec, - PlainTextLabelDepSpec - > ItemFormatter; - }; - - /** - * A heirarchy for dependencies. - * - * \ingroup g_dep_spec - * \since 0.26 - * \nosubgrouping - */ - struct DependencySpecTree : - VisitorTypes< - DependencySpecTree, - DepSpec, - TreeLeaf<DependencySpecTree, PackageDepSpec>, - TreeLeaf<DependencySpecTree, BlockDepSpec>, - TreeLeaf<DependencySpecTree, DependencyLabelsDepSpec>, - TreeLeaf<DependencySpecTree, NamedSetDepSpec>, - ConstTreeSequence<DependencySpecTree, AllDepSpec>, - ConstTreeSequence<DependencySpecTree, AnyDepSpec>, - ConstTreeSequence<DependencySpecTree, ConditionalDepSpec> - > - { - /** - * A formatter that can handle any formattable type found in a - * DependencySpecTree. - * - * \ingroup g_dep_spec - * \since 0.26 - * \nosubgrouping - */ - typedef Formatter< - ConditionalDepSpec, - PackageDepSpec, - BlockDepSpec, - NamedSetDepSpec, - DependencyLabelsDepSpec - > ItemFormatter; - }; - - /** - * A heirarchy for things that can be found in package sets. - * - * \ingroup g_dep_spec - * \since 0.26 - * \nosubgrouping - */ - struct SetSpecTree : - VisitorTypes< - SetSpecTree, - DepSpec, - TreeLeaf<SetSpecTree, PackageDepSpec>, - TreeLeaf<SetSpecTree, NamedSetDepSpec>, - ConstTreeSequence<SetSpecTree, AllDepSpec> - > - { - /** - * A formatter that can handle any formattable type found in a - * SetSpecTree. - * - * \ingroup g_dep_spec - * \since 0.26 - * \nosubgrouping - */ - typedef Formatter< - PackageDepSpec, - NamedSetDepSpec - > ItemFormatter; - }; -} - -#endif diff --git a/paludis/environment.hh b/paludis/environment.hh index 950ce3a97..63a954548 100644 --- a/paludis/environment.hh +++ b/paludis/environment.hh @@ -29,7 +29,7 @@ #include <paludis/hook-fwd.hh> #include <paludis/repository-fwd.hh> #include <paludis/dep_spec.hh> -#include <paludis/dep_tree.hh> +#include <paludis/spec_tree-fwd.hh> #include <paludis/package_id-fwd.hh> #include <paludis/mask-fwd.hh> #include <paludis/package_database-fwd.hh> @@ -284,7 +284,7 @@ namespace paludis * * If the named set is not known, returns a zero pointer. */ - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> set(const SetName &) const + virtual const std::tr1::shared_ptr<const SetSpecTree> set(const SetName &) const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0; ///\} diff --git a/paludis/environment_implementation.cc b/paludis/environment_implementation.cc index 9b0268444..ef932fcdf 100644 --- a/paludis/environment_implementation.cc +++ b/paludis/environment_implementation.cc @@ -21,12 +21,13 @@ #include <paludis/package_id.hh> #include <paludis/metadata_key.hh> #include <paludis/package_database.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/log.hh> #include <paludis/util/save.hh> #include <paludis/util/set.hh> #include <paludis/util/make_shared_ptr.hh> #include <paludis/util/system.hh> +#include <paludis/util/sequence.hh> +#include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/hook.hh> #include <paludis/distribution.hh> #include <paludis/selection.hh> @@ -85,11 +86,11 @@ EnvironmentImplementation::default_destinations() const return result; } -std::tr1::shared_ptr<SetSpecTree::ConstItem> +const std::tr1::shared_ptr<const SetSpecTree> EnvironmentImplementation::set(const SetName & s) const { { - std::tr1::shared_ptr<SetSpecTree::ConstItem> l(local_set(s)); + const std::tr1::shared_ptr<const SetSpecTree> l(local_set(s)); if (l) { Log::get_instance()->message("environment_implementation.local_set", ll_debug, lc_context) << "Set '" << s << "' is a local set"; @@ -97,13 +98,13 @@ EnvironmentImplementation::set(const SetName & s) const } } - std::tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > result; + std::tr1::shared_ptr<SetSpecTree> result;; /* these sets always exist, even if empty */ if (s.data() == "everything" || s.data() == "system" || s.data() == "world" || s.data() == "security") { Log::get_instance()->message("environment_implementation.standard_set", ll_debug, lc_context) << "Set '" << s << "' is a standard set"; - result.reset(new ConstTreeSequence<SetSpecTree, AllDepSpec>(std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); + result.reset(new SetSpecTree(make_shared_ptr(new AllDepSpec))); } for (PackageDatabase::RepositoryConstIterator r(package_database()->begin_repositories()), @@ -113,26 +114,25 @@ EnvironmentImplementation::set(const SetName & s) const if (! (**r).sets_interface()) continue; - std::tr1::shared_ptr<SetSpecTree::ConstItem> add((**r).sets_interface()->package_set(s)); + std::tr1::shared_ptr<const SetSpecTree> add((**r).sets_interface()->package_set(s)); if (add) { Log::get_instance()->message("environment_implementation.set_found_in_repository", ll_debug, lc_context) << "Set '" << s << "' found in '" << (*r)->name() << "'"; if (! result) - result.reset(new ConstTreeSequence<SetSpecTree, AllDepSpec>(std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); - result->add(add); + result.reset(new SetSpecTree(make_shared_ptr(new AllDepSpec))); + result->root()->append_node(add->root()); } } if ("everything" == s.data() || "world" == s.data()) - result->add(make_shared_ptr(new TreeLeaf<SetSpecTree, NamedSetDepSpec>( - make_shared_ptr(new NamedSetDepSpec(SetName("system")))))); + result->root()->append(make_shared_ptr(new NamedSetDepSpec(SetName("system")))); if ("world" == s.data()) { - std::tr1::shared_ptr<SetSpecTree::ConstItem> w(world_set()); + std::tr1::shared_ptr<const SetSpecTree> w(world_set()); if (w) - result->add(w); + result->root()->append_node(w->root()); } if (! result) diff --git a/paludis/environment_implementation.hh b/paludis/environment_implementation.hh index ae45c4a76..2fc37c9bd 100644 --- a/paludis/environment_implementation.hh +++ b/paludis/environment_implementation.hh @@ -50,10 +50,10 @@ namespace paludis public Environment { protected: - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> local_set(const SetName &) const + virtual const std::tr1::shared_ptr<const SetSpecTree> local_set(const SetName &) const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0; - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> world_set() const + virtual const std::tr1::shared_ptr<const SetSpecTree> world_set() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0; public: @@ -76,7 +76,7 @@ namespace paludis virtual std::tr1::shared_ptr<const SetNameSet> set_names() const PALUDIS_ATTRIBUTE((warn_unused_result)); - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> set(const SetName &) const + virtual const std::tr1::shared_ptr<const SetSpecTree> set(const SetName &) const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual std::tr1::shared_ptr<const DestinationsSet> default_destinations() const diff --git a/paludis/environments/no_config/no_config_environment.cc b/paludis/environments/no_config/no_config_environment.cc index bfefe13aa..61bdf19db 100644 --- a/paludis/environments/no_config/no_config_environment.cc +++ b/paludis/environments/no_config/no_config_environment.cc @@ -429,16 +429,16 @@ NoConfigEnvironment::accept_keywords(const std::tr1::shared_ptr<const KeywordNam return false; } -std::tr1::shared_ptr<SetSpecTree::ConstItem> +const std::tr1::shared_ptr<const SetSpecTree> NoConfigEnvironment::local_set(const SetName &) const { - return std::tr1::shared_ptr<SetSpecTree::ConstItem>(); + return make_null_shared_ptr(); } -std::tr1::shared_ptr<SetSpecTree::ConstItem> +const std::tr1::shared_ptr<const SetSpecTree> NoConfigEnvironment::world_set() const { - return std::tr1::shared_ptr<SetSpecTree::ConstItem>(); + return make_null_shared_ptr(); } void diff --git a/paludis/environments/no_config/no_config_environment.hh b/paludis/environments/no_config/no_config_environment.hh index 7a98b7d8e..84dd67982 100644 --- a/paludis/environments/no_config/no_config_environment.hh +++ b/paludis/environments/no_config/no_config_environment.hh @@ -80,10 +80,10 @@ namespace paludis PrivateImplementationPattern<NoConfigEnvironment>::ImpPtr & _imp; protected: - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> local_set(const SetName &) const + virtual const std::tr1::shared_ptr<const SetSpecTree> local_set(const SetName &) const PALUDIS_ATTRIBUTE((warn_unused_result)); - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> world_set() const + virtual const std::tr1::shared_ptr<const SetSpecTree> world_set() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual void need_keys_added() const; diff --git a/paludis/environments/paludis/keywords_conf.cc b/paludis/environments/paludis/keywords_conf.cc index 15d2f8889..509846585 100644 --- a/paludis/environments/paludis/keywords_conf.cc +++ b/paludis/environments/paludis/keywords_conf.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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,7 @@ #include <paludis/environment.hh> #include <paludis/name.hh> #include <paludis/dep_spec.hh> +#include <paludis/spec_tree.hh> #include <paludis/user_dep_spec.hh> #include <paludis/match_package.hh> #include <paludis/util/config_file.hh> @@ -36,6 +37,7 @@ #include <paludis/util/mutex.hh> #include <paludis/util/set.hh> #include <paludis/util/hashes.hh> +#include <paludis/util/make_shared_ptr.hh> #include <tr1/unordered_map> #include <list> #include <vector> @@ -46,7 +48,7 @@ using namespace paludis::paludis_environment; typedef std::list<KeywordName> KeywordsList; typedef std::map<std::tr1::shared_ptr<const PackageDepSpec>, KeywordsList> PDSToKeywordsList; -typedef std::pair<std::tr1::shared_ptr<const SetSpecTree::ConstItem>, KeywordsList> SetNameEntry; +typedef std::pair<std::tr1::shared_ptr<const SetSpecTree>, KeywordsList> SetNameEntry; typedef std::tr1::unordered_map<QualifiedPackageName, PDSToKeywordsList, Hash<QualifiedPackageName> > SpecificMap; typedef PDSToKeywordsList UnspecificMap; @@ -121,7 +123,7 @@ KeywordsConf::add(const FSEntry & filename) catch (const GotASetNotAPackageDepSpec &) { NamedSetMap::iterator i(_imp->set.insert(std::make_pair(SetName(tokens.at(0)), std::make_pair( - std::tr1::shared_ptr<SetSpecTree::ConstItem>(), KeywordsList()))).first); + make_null_shared_ptr(), KeywordsList()))).first); for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ; t != t_end ; ++t) @@ -184,8 +186,7 @@ KeywordsConf::query(const std::tr1::shared_ptr<const KeywordNameSet> & k, const { Log::get_instance()->message("paludis_environment.keywords_conf.unknown_set", ll_warning, lc_no_context) << "Set name '" << i->first << "' does not exist"; - i->second.first.reset(new ConstTreeSequence<SetSpecTree, AllDepSpec>( - std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); + i->second.first.reset(new SetSpecTree(make_shared_ptr(new AllDepSpec))); } } diff --git a/paludis/environments/paludis/licenses_conf.cc b/paludis/environments/paludis/licenses_conf.cc index fd25e0dc5..f4433d393 100644 --- a/paludis/environments/paludis/licenses_conf.cc +++ b/paludis/environments/paludis/licenses_conf.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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,7 @@ #include <paludis/environment.hh> #include <paludis/name.hh> #include <paludis/dep_spec.hh> +#include <paludis/spec_tree.hh> #include <paludis/user_dep_spec.hh> #include <paludis/match_package.hh> #include <paludis/util/config_file.hh> @@ -35,6 +36,7 @@ #include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/util/iterator_funcs.hh> #include <paludis/util/hashes.hh> +#include <paludis/util/make_shared_ptr.hh> #include <tr1/unordered_map> #include <list> #include <vector> @@ -45,7 +47,7 @@ using namespace paludis::paludis_environment; typedef std::list<std::string> LicensesList; typedef std::map<std::tr1::shared_ptr<const PackageDepSpec>, LicensesList> PDSToLicensesList; -typedef std::pair<std::tr1::shared_ptr<const SetSpecTree::ConstItem>, LicensesList> SetNameEntry; +typedef std::pair<std::tr1::shared_ptr<const SetSpecTree>, LicensesList> SetNameEntry; typedef std::tr1::unordered_map<QualifiedPackageName, PDSToLicensesList, Hash<QualifiedPackageName> > SpecificMap; typedef PDSToLicensesList UnspecificMap; @@ -120,7 +122,7 @@ LicensesConf::add(const FSEntry & filename) catch (const GotASetNotAPackageDepSpec &) { NamedSetMap::iterator i(_imp->set.insert(std::make_pair(SetName(tokens.at(0)), std::make_pair( - std::tr1::shared_ptr<SetSpecTree::ConstItem>(), LicensesList()))).first); + make_null_shared_ptr(), LicensesList()))).first); for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ; t != t_end ; ++t) @@ -176,8 +178,7 @@ LicensesConf::query(const std::string & t, const PackageID & e) const { Log::get_instance()->message("paludis_environment.licenses_conf.unknown_set", ll_warning, lc_no_context) << "Set name '" << i->first << "' does not exist"; - i->second.first.reset(new ConstTreeSequence<SetSpecTree, AllDepSpec>( - std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); + i->second.first.reset(new SetSpecTree(make_shared_ptr(new AllDepSpec))); } } @@ -224,4 +225,3 @@ LicensesConf::query(const std::string & t, const PackageID & e) const return false; } - diff --git a/paludis/environments/paludis/package_mask_conf.cc b/paludis/environments/paludis/package_mask_conf.cc index dbbe0f6ba..dd41ee7ab 100644 --- a/paludis/environments/paludis/package_mask_conf.cc +++ b/paludis/environments/paludis/package_mask_conf.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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,7 @@ #include <paludis/environment.hh> #include <paludis/name.hh> #include <paludis/dep_spec.hh> +#include <paludis/spec_tree.hh> #include <paludis/user_dep_spec.hh> #include <paludis/match_package.hh> #include <paludis/util/config_file.hh> @@ -35,6 +36,7 @@ #include <paludis/util/indirect_iterator-impl.hh> #include <paludis/util/mutex.hh> #include <paludis/util/hashes.hh> +#include <paludis/util/make_shared_ptr.hh> #include <list> #include <algorithm> #include <tr1/functional> @@ -42,7 +44,7 @@ using namespace paludis; using namespace paludis::paludis_environment; -typedef std::list<std::pair<SetName, std::tr1::shared_ptr<const SetSpecTree::ConstItem> > > Sets; +typedef std::list<std::pair<SetName, std::tr1::shared_ptr<const SetSpecTree> > > Sets; namespace paludis { @@ -90,7 +92,7 @@ PackageMaskConf::add(const FSEntry & filename) } catch (const GotASetNotAPackageDepSpec &) { - _imp->sets.push_back(std::make_pair(SetName(*line), std::tr1::shared_ptr<const SetSpecTree::ConstItem>())); + _imp->sets.push_back(std::make_pair(SetName(*line), make_null_shared_ptr())); } } } @@ -118,8 +120,7 @@ PackageMaskConf::query(const PackageID & e) const { Log::get_instance()->message("paludis_environment.package_mask.unknown_set", ll_warning, lc_no_context) << "Set name '" << it->first << "' does not exist"; - it->second.reset(new ConstTreeSequence<SetSpecTree, AllDepSpec>( - std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); + it->second.reset(new SetSpecTree(make_shared_ptr(new AllDepSpec))); } } diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc index 6b6a9f95c..392c2d5b1 100644 --- a/paludis/environments/paludis/paludis_environment.cc +++ b/paludis/environments/paludis/paludis_environment.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2008, 2009 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 @@ -52,7 +52,6 @@ #include <paludis/util/mutex.hh> #include <paludis/util/map.hh> #include <paludis/util/wrapped_output_iterator.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/options.hh> #include <paludis/util/tribool.hh> #include <paludis/util/make_named_values.hh> @@ -82,7 +81,7 @@ namespace paludis std::tr1::shared_ptr<PackageDatabase> package_database; mutable Mutex sets_mutex; - mutable std::map<SetName, std::tr1::shared_ptr<SetSpecTree::ConstItem> > sets; + mutable std::map<SetName, std::tr1::shared_ptr<const SetSpecTree> > sets; std::tr1::shared_ptr<LiteralMetadataValueKey<std::string> > format_key; std::tr1::shared_ptr<LiteralMetadataValueKey<FSEntry> > config_location_key; @@ -272,7 +271,7 @@ PaludisEnvironment::syncers_dirs() const return result; } -std::tr1::shared_ptr<SetSpecTree::ConstItem> +const std::tr1::shared_ptr<const SetSpecTree> PaludisEnvironment::local_set(const SetName & ss) const { using namespace std::tr1::placeholders; @@ -281,7 +280,7 @@ PaludisEnvironment::local_set(const SetName & ss) const Lock l(_imp->sets_mutex); - std::map<SetName, std::tr1::shared_ptr<SetSpecTree::ConstItem> >::const_iterator i(_imp->sets.find(ss)); + std::map<SetName, std::tr1::shared_ptr<const SetSpecTree> >::const_iterator i(_imp->sets.find(ss)); if (i != _imp->sets.end()) return i->second; @@ -321,12 +320,12 @@ PaludisEnvironment::local_set(const SetName & ss) const } else { - _imp->sets.insert(std::make_pair(ss, std::tr1::shared_ptr<SetSpecTree::ConstItem>())); - return std::tr1::shared_ptr<SetSpecTree::ConstItem>(); + _imp->sets.insert(std::make_pair(ss, make_null_shared_ptr())); + return make_null_shared_ptr(); } } -std::tr1::shared_ptr<SetSpecTree::ConstItem> +const std::tr1::shared_ptr<const SetSpecTree> PaludisEnvironment::world_set() const { return _imp->config->world()->world_set(); diff --git a/paludis/environments/paludis/paludis_environment.hh b/paludis/environments/paludis/paludis_environment.hh index 79930715a..b686d74b4 100644 --- a/paludis/environments/paludis/paludis_environment.hh +++ b/paludis/environments/paludis/paludis_environment.hh @@ -56,9 +56,9 @@ namespace paludis protected: virtual void need_keys_added() const; - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> local_set(const SetName & id) const; + virtual const std::tr1::shared_ptr<const SetSpecTree> local_set(const SetName & id) const; - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> world_set() const; + virtual const std::tr1::shared_ptr<const SetSpecTree> world_set() const; public: ///\name Basic operations diff --git a/paludis/environments/paludis/use_conf.cc b/paludis/environments/paludis/use_conf.cc index ad940bc65..2ccba3dc1 100644 --- a/paludis/environments/paludis/use_conf.cc +++ b/paludis/environments/paludis/use_conf.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -38,6 +38,8 @@ #include <paludis/util/mutex.hh> #include <paludis/util/hashes.hh> #include <paludis/util/tribool.hh> +#include <paludis/util/make_shared_ptr.hh> +#include <paludis/spec_tree.hh> #include <paludis/choice.hh> #include <tr1/unordered_map> #include <algorithm> @@ -53,7 +55,7 @@ typedef std::tr1::unordered_map<FlagNamePair, Tribool, Hash<FlagNamePair> > Flag typedef std::list<ChoicePrefixName> MinusStarPrefixList; typedef std::pair<FlagNamePairWithStateMap, MinusStarPrefixList> UseInfo; typedef std::pair<std::tr1::shared_ptr<const PackageDepSpec>, UseInfo> PDSWithUseInfo; -typedef std::pair<std::tr1::shared_ptr<const SetSpecTree::ConstItem>, UseInfo> DSWithUseInfo; +typedef std::pair<std::tr1::shared_ptr<const SetSpecTree>, UseInfo> DSWithUseInfo; typedef std::list<PDSWithUseInfo> PDSWithUseInfoList; typedef std::tr1::unordered_map<QualifiedPackageName, PDSWithUseInfoList, Hash<QualifiedPackageName> > Qualified; typedef std::list<PDSWithUseInfo> Unqualified; @@ -249,8 +251,7 @@ UseConf::want_choice_enabled( { Log::get_instance()->message("paludis_environment.use_conf.unknown_set", ll_warning, lc_no_context) << "Set name '" << r->first << "' does not exist"; - r->second.first.reset(new ConstTreeSequence<SetSpecTree, AllDepSpec>( - std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); + r->second.first.reset(new SetSpecTree(make_shared_ptr(new AllDepSpec))); } } @@ -342,8 +343,7 @@ UseConf::known_choice_value_names( { Log::get_instance()->message("paludis_environment.use_conf.unknown_set", ll_warning, lc_no_context) << "Set name '" << r->first << "' does not exist"; - r->second.first.reset(new ConstTreeSequence<SetSpecTree, AllDepSpec>( - std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); + r->second.first.reset(new SetSpecTree(make_shared_ptr(new AllDepSpec))); } } diff --git a/paludis/environments/paludis/world.cc b/paludis/environments/paludis/world.cc index 86d45f407..94e5ee94f 100644 --- a/paludis/environments/paludis/world.cc +++ b/paludis/environments/paludis/world.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008 Ciaran McCreesh + * Copyright (c) 2008, 2009 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 @@ -156,7 +156,7 @@ World::_remove_string_from_world(const std::string & n) const } } -std::tr1::shared_ptr<SetSpecTree::ConstItem> +const std::tr1::shared_ptr<const SetSpecTree> World::world_set() const { using namespace std::tr1::placeholders; @@ -182,8 +182,7 @@ World::world_set() const << "World file '" << *_imp->maybe_world_file << "' doesn't exist"; } - return std::tr1::shared_ptr<SetSpecTree::ConstItem>(new ConstTreeSequence<SetSpecTree, AllDepSpec>( - std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); + return make_shared_ptr(new SetSpecTree(make_shared_ptr(new AllDepSpec))); } std::tr1::shared_ptr<const FSEntry> diff --git a/paludis/environments/paludis/world.hh b/paludis/environments/paludis/world.hh index a0a50f1c1..ba1d6204f 100644 --- a/paludis/environments/paludis/world.hh +++ b/paludis/environments/paludis/world.hh @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008 Ciaran McCreesh + * Copyright (c) 2008, 2009 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 @@ -23,7 +23,7 @@ #include <paludis/util/private_implementation_pattern.hh> #include <paludis/util/fs_entry-fwd.hh> #include <paludis/name-fwd.hh> -#include <paludis/dep_tree.hh> +#include <paludis/spec_tree.hh> #include <paludis/environment-fwd.hh> #include <tr1/memory> #include <string> @@ -43,7 +43,7 @@ namespace paludis World(const Environment * const, const std::tr1::shared_ptr<const FSEntry> &); ~World(); - std::tr1::shared_ptr<SetSpecTree::ConstItem> world_set() const PALUDIS_ATTRIBUTE((warn_unused_result)); + const std::tr1::shared_ptr<const SetSpecTree> world_set() const PALUDIS_ATTRIBUTE((warn_unused_result)); void add_to_world(const SetName &) const; void add_to_world(const QualifiedPackageName &) const; diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc index 9f0ec74ab..166612dd5 100644 --- a/paludis/environments/portage/portage_environment.cc +++ b/paludis/environments/portage/portage_environment.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -34,7 +34,6 @@ #include <paludis/util/map.hh> #include <paludis/util/options.hh> #include <paludis/util/make_shared_ptr.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/config_file.hh> #include <paludis/util/tribool.hh> #include <paludis/util/make_named_values.hh> @@ -760,10 +759,10 @@ PortageEnvironment::mirrors(const std::string & m) const return result; } -std::tr1::shared_ptr<SetSpecTree::ConstItem> +const std::tr1::shared_ptr<const SetSpecTree> PortageEnvironment::local_set(const SetName &) const { - return std::tr1::shared_ptr<SetSpecTree::ConstItem>(); + return make_null_shared_ptr(); } bool @@ -942,7 +941,7 @@ PortageEnvironment::_remove_string_from_world(const std::string & s) const } } -std::tr1::shared_ptr<SetSpecTree::ConstItem> +const std::tr1::shared_ptr<const SetSpecTree> PortageEnvironment::world_set() const { Context context("When fetching environment world set:"); @@ -970,8 +969,7 @@ PortageEnvironment::world_set() const Log::get_instance()->message("portage_environment.world_file.does_not_exist", ll_warning, lc_no_context) << "World file '" << _imp->world_file << "' doesn't exist"; - return std::tr1::shared_ptr<SetSpecTree::ConstItem>(new ConstTreeSequence<SetSpecTree, AllDepSpec>( - std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); + return make_shared_ptr(new SetSpecTree(make_shared_ptr(new AllDepSpec))); } void diff --git a/paludis/environments/portage/portage_environment.hh b/paludis/environments/portage/portage_environment.hh index b27dcdda2..98021fca1 100644 --- a/paludis/environments/portage/portage_environment.hh +++ b/paludis/environments/portage/portage_environment.hh @@ -80,10 +80,10 @@ namespace paludis void _remove_string_from_world(const std::string &) const; protected: - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> local_set(const SetName &) const + virtual const std::tr1::shared_ptr<const SetSpecTree> local_set(const SetName &) const PALUDIS_ATTRIBUTE((warn_unused_result)); - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> world_set() const + virtual const std::tr1::shared_ptr<const SetSpecTree> world_set() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual void need_keys_added() const; diff --git a/paludis/environments/test/test_environment.cc b/paludis/environments/test/test_environment.cc index 7d2aac936..8abf206f8 100644 --- a/paludis/environments/test/test_environment.cc +++ b/paludis/environments/test/test_environment.cc @@ -25,7 +25,6 @@ #include <paludis/util/make_shared_ptr.hh> #include <paludis/util/hashes.hh> #include <paludis/util/tokeniser.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/tribool.hh> #include <paludis/util/destringify.hh> #include <paludis/util/system.hh> @@ -41,7 +40,7 @@ using namespace paludis; -typedef std::tr1::unordered_map<SetName, std::tr1::shared_ptr<const SetSpecTree::ConstItem>, Hash<SetName> > Sets; +typedef std::tr1::unordered_map<SetName, std::tr1::shared_ptr<const SetSpecTree>, Hash<SetName> > Sets; namespace paludis { @@ -128,12 +127,12 @@ TestEnvironment::fetch_package_id(const QualifiedPackageName & q, throw NoSuchPackageError(stringify(q) + "-" + stringify(v) + "::" + stringify(r)); } -std::tr1::shared_ptr<SetSpecTree::ConstItem> +const std::tr1::shared_ptr<const SetSpecTree> TestEnvironment::local_set(const SetName & s) const { Sets::const_iterator i(_imp->sets.find(s)); if (_imp->sets.end() == i) - return std::tr1::shared_ptr<SetSpecTree::ConstItem>(); + return make_null_shared_ptr(); else return i->second; } @@ -200,7 +199,7 @@ TestEnvironment::unmasked_by_user(const PackageID &) const return false; } -std::tr1::shared_ptr<SetSpecTree::ConstItem> +const std::tr1::shared_ptr<const SetSpecTree> TestEnvironment::world_set() const { return local_set(SetName("world")); @@ -243,6 +242,8 @@ TestEnvironment::config_location_key() const return std::tr1::shared_ptr<const MetadataValueKey<FSEntry> >(); } +#if 0 + void TestEnvironment::add_set(const SetName & s, const std::string & members_str) { @@ -270,6 +271,8 @@ TestEnvironment::add_set(const SetName & s, const std::string & members_str) _imp->sets[s] = top; } +#endif + const Tribool TestEnvironment::want_choice_enabled( const std::tr1::shared_ptr<const PackageID> & id, diff --git a/paludis/environments/test/test_environment.hh b/paludis/environments/test/test_environment.hh index 09bafad68..b0dfe2179 100644 --- a/paludis/environments/test/test_environment.hh +++ b/paludis/environments/test/test_environment.hh @@ -47,10 +47,10 @@ namespace paludis PrivateImplementationPattern<TestEnvironment>::ImpPtr & _imp; protected: - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> local_set(const SetName &) const + virtual const std::tr1::shared_ptr<const SetSpecTree> local_set(const SetName &) const PALUDIS_ATTRIBUTE((warn_unused_result)); - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> world_set() const + virtual const std::tr1::shared_ptr<const SetSpecTree> world_set() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual void need_keys_added() const; diff --git a/paludis/files.m4 b/paludis/files.m4 index 95b50fd35..0d0c45a51 100644 --- a/paludis/files.m4 +++ b/paludis/files.m4 @@ -11,7 +11,6 @@ dnl on this file at present... add(`about', `hh', `test') add(`action', `hh', `cc', `fwd') add(`action_names', `hh', `cc', `fwd') -add(`condition_tracker', `hh', `cc') add(`choice', `hh', `cc', `fwd') add(`contents', `hh', `cc', `fwd') add(`dep_label', `hh', `cc', `fwd') @@ -20,7 +19,6 @@ add(`dep_list_exceptions', `hh', `cc') add(`dep_list_options', `hh', `cc', `se') add(`dep_spec', `hh', `cc', `test', `fwd') add(`dep_spec_flattener', `hh', `cc') -add(`dep_tree', `hh', `cc', `fwd') add(`dep_tag', `hh', `cc', `fwd') add(`distribution', `hh', `cc', `impl', `fwd') add(`elike_choices', `hh', `cc', `fwd') @@ -71,6 +69,7 @@ add(`selection_handler', `hh', `cc', `fwd') add(`set_file', `hh', `cc', `se', `test', `testscript') add(`show_suggest_visitor', `hh', `cc') add(`slot_requirement', `hh', `fwd', `cc') +add(`spec_tree', `hh', `fwd', `cc') add(`stringify_formatter', `hh', `cc', `fwd', `impl', `test') add(`stripper', `hh', `cc', `fwd', `test', `testscript') add(`syncer', `hh', `cc') diff --git a/paludis/filter.cc b/paludis/filter.cc index c365b4f34..b6c3c8ddb 100644 --- a/paludis/filter.cc +++ b/paludis/filter.cc @@ -26,7 +26,6 @@ #include <paludis/package_database.hh> #include <paludis/metadata_key.hh> #include <paludis/util/private_implementation_pattern-impl.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/set.hh> #include <paludis/util/sequence.hh> #include <paludis/util/wrapped_forward_iterator.hh> diff --git a/paludis/generator.cc b/paludis/generator.cc index e1460602d..3fd0c5ebe 100644 --- a/paludis/generator.cc +++ b/paludis/generator.cc @@ -25,7 +25,6 @@ #include <paludis/action.hh> #include <paludis/match_package.hh> #include <paludis/util/private_implementation_pattern-impl.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/make_shared_ptr.hh> #include <paludis/util/set.hh> #include <paludis/util/sequence.hh> diff --git a/paludis/handled_information.cc b/paludis/handled_information.cc index e62795f00..f8c3d170c 100644 --- a/paludis/handled_information.cc +++ b/paludis/handled_information.cc @@ -17,9 +17,8 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "handled_information.hh" +#include <paludis/handled_information.hh> #include <paludis/util/private_implementation_pattern-impl.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/dep_spec.hh> using namespace paludis; diff --git a/paludis/install_task.cc b/paludis/install_task.cc index eaedd7284..8cac0a2c7 100644 --- a/paludis/install_task.cc +++ b/paludis/install_task.cc @@ -35,7 +35,6 @@ #include <paludis/filter.hh> #include <paludis/generator.hh> #include <paludis/filtered_generator.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/tokeniser.hh> #include <paludis/util/set.hh> #include <paludis/util/log.hh> @@ -45,6 +44,9 @@ #include <paludis/util/destringify.hh> #include <paludis/util/make_shared_ptr.hh> #include <paludis/util/make_named_values.hh> +#include <paludis/util/sequence.hh> +#include <paludis/util/indirect_iterator-impl.hh> +#include <paludis/util/accept_visitor.hh> #include <paludis/handled_information.hh> #include <tr1/functional> #include <sstream> @@ -73,7 +75,7 @@ namespace paludis std::string config_protect; std::list<std::string> raw_targets; - std::tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > targets; + std::tr1::shared_ptr<SetSpecTree> targets; std::tr1::shared_ptr<std::string> add_to_world_spec; std::tr1::shared_ptr<const DestinationsSet> destinations; @@ -108,7 +110,7 @@ namespace paludis this, std::tr1::placeholders::_1)) )), config_protect(""), - targets(new ConstTreeSequence<SetSpecTree, AllDepSpec>(std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))), + targets(new SetSpecTree(make_shared_ptr(new AllDepSpec))), destinations(d), pretend(false), fetch_only(false), @@ -141,7 +143,7 @@ InstallTask::~InstallTask() void InstallTask::clear() { - _imp->targets.reset(new ConstTreeSequence<SetSpecTree, AllDepSpec>(std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); + _imp->targets.reset(new SetSpecTree(make_shared_ptr(new AllDepSpec))); _imp->had_set_targets = false; _imp->had_package_targets = false; _imp->dep_list.clear(); @@ -387,7 +389,7 @@ InstallTask::_add_target(const std::string & target) { Context context("When adding install target '" + target + "':"); - std::tr1::shared_ptr<SetSpecTree::ConstItem> s; + std::tr1::shared_ptr<SetSpecTree> s; try { @@ -405,8 +407,7 @@ InstallTask::_add_target(const std::string & target) { /* no wildcards */ spec->set_tag(std::tr1::shared_ptr<const DepTag>(new TargetDepTag)); - _imp->targets->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >( - new TreeLeaf<SetSpecTree, PackageDepSpec>(spec))); + _imp->targets->root()->append(spec); } else { @@ -417,8 +418,7 @@ InstallTask::_add_target(const std::string & target) { /* no match. we'll get an error from this later anyway. */ spec->set_tag(std::tr1::shared_ptr<const DepTag>(new TargetDepTag)); - _imp->targets->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >( - new TreeLeaf<SetSpecTree, PackageDepSpec>(spec))); + _imp->targets->root()->append(spec); } else for (PackageIDSequence::ConstIterator i(names->begin()), i_end(names->end()) ; @@ -428,8 +428,7 @@ InstallTask::_add_target(const std::string & target) p.package((*i)->name()); std::tr1::shared_ptr<PackageDepSpec> specn(new PackageDepSpec(p)); specn->set_tag(std::tr1::shared_ptr<const DepTag>(new TargetDepTag)); - _imp->targets->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >( - new TreeLeaf<SetSpecTree, PackageDepSpec>(specn))); + _imp->targets->root()->append(specn); } } @@ -443,9 +442,7 @@ InstallTask::_add_target(const std::string & target) throw HadBothPackageAndSetTargets(); _imp->had_set_targets = true; - _imp->targets->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, NamedSetDepSpec> >( - new TreeLeaf<SetSpecTree, NamedSetDepSpec>(std::tr1::shared_ptr<NamedSetDepSpec>( - new NamedSetDepSpec(SetName(target)))))); + _imp->targets->root()->append(make_shared_ptr(new NamedSetDepSpec(SetName(target)))); _imp->had_set_targets = true; if (! _imp->override_target_type) _imp->dep_list.options()->target_type() = dl_target_set; @@ -478,8 +475,7 @@ InstallTask::_add_package_id(const std::tr1::shared_ptr<const PackageID> & targe .in_repository(target->repository()->name()))); spec->set_tag(std::tr1::shared_ptr<const DepTag>(new TargetDepTag)); - _imp->targets->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >( - new TreeLeaf<SetSpecTree, PackageDepSpec>(spec))); + _imp->targets->root()->append(spec); _imp->raw_targets.push_back(stringify(*spec)); } @@ -780,8 +776,9 @@ InstallTask::_one(const DepList::Iterator dep, const int x, const int y, const i on_no_clean_needed(*dep); else { - if (0 != perform_hook(Hook("clean_all_pre")("TARGETS", join( - indirect_iterator(clean_list.begin()), indirect_iterator(clean_list.end()), " "))).max_exit_status()) + if (0 != perform_hook(Hook("clean_all_pre") + ("TARGETS", join(indirect_iterator(clean_list.begin()), indirect_iterator(clean_list.end()), " ")) + ).max_exit_status()) throw InstallActionError("Clean aborted by hook"); on_clean_all_pre(*dep, clean_list); @@ -972,8 +969,7 @@ InstallTask::_main_actions() "() \t\r\n")); } - std::tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > all(new ConstTreeSequence<SetSpecTree, AllDepSpec>( - std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); + std::tr1::shared_ptr<SetSpecTree> all(new SetSpecTree(make_shared_ptr(new AllDepSpec))); std::list<std::string> tokens; tokenise_whitespace(*_imp->add_to_world_spec, std::back_inserter(tokens)); if ((! tokens.empty()) && ("(" == *tokens.begin()) && (")" == *previous(tokens.end()))) @@ -986,14 +982,10 @@ InstallTask::_main_actions() t != t_end ; ++t) { if (s_had_package_targets) - all->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >( - new TreeLeaf<SetSpecTree, PackageDepSpec>(std::tr1::shared_ptr<PackageDepSpec>( - new PackageDepSpec(parse_user_package_dep_spec(*t, _imp->env, - UserPackageDepSpecOptions())))))); + all->root()->append(make_shared_ptr(new PackageDepSpec(parse_user_package_dep_spec(*t, _imp->env, + UserPackageDepSpecOptions())))); else - all->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, NamedSetDepSpec> >( - new TreeLeaf<SetSpecTree, NamedSetDepSpec>(std::tr1::shared_ptr<NamedSetDepSpec>( - new NamedSetDepSpec(SetName(*t)))))); + all->root()->append(make_shared_ptr(new NamedSetDepSpec(SetName(*t)))); } if (s_had_package_targets) @@ -1217,12 +1209,8 @@ InstallTask::world_update_set(const SetName & s) namespace { - struct WorldTargetFinder : - ConstVisitor<SetSpecTree>, - ConstVisitor<SetSpecTree>::VisitConstSequence<WorldTargetFinder, AllDepSpec> + struct WorldTargetFinder { - using ConstVisitor<SetSpecTree>::VisitConstSequence<WorldTargetFinder, AllDepSpec>::visit_sequence; - Environment * const env; InstallTask * const task; @@ -1232,31 +1220,37 @@ namespace { } - void visit_leaf(const PackageDepSpec & a) + void visit(const SetSpecTree::NodeType<AllDepSpec>::Type & node) { - if (a.slot_requirement_ptr()) - task->on_update_world_skip(a, "slot restrictions"); - else if (a.version_requirements_ptr() && ! a.version_requirements_ptr()->empty()) - task->on_update_world_skip(a, "version restrictions"); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), + accept_visitor(*this)); + } + + void visit(const SetSpecTree::NodeType<PackageDepSpec>::Type & node) + { + if (node.spec()->slot_requirement_ptr()) + task->on_update_world_skip(*node.spec(), "slot restrictions"); + else if (node.spec()->version_requirements_ptr() && ! node.spec()->version_requirements_ptr()->empty()) + task->on_update_world_skip(*node.spec(), "version restrictions"); else { - if (a.package_ptr()) - env->add_to_world(*a.package_ptr()); - task->on_update_world(a); + if (node.spec()->package_ptr()) + env->add_to_world(*node.spec()->package_ptr()); + task->on_update_world(*node.spec()); } } - void visit_leaf(const NamedSetDepSpec &) + void visit(const SetSpecTree::NodeType<NamedSetDepSpec>::Type &) { } }; } void -InstallTask::world_update_packages(const std::tr1::shared_ptr<const SetSpecTree::ConstItem> & a) +InstallTask::world_update_packages(const std::tr1::shared_ptr<const SetSpecTree> & a) { WorldTargetFinder w(_imp->env, this); - a->accept(w); + a->root()->accept(w); } bool @@ -1273,12 +1267,8 @@ InstallTask::set_continue_on_failure(const InstallTaskContinueOnFailure c) namespace { - struct CheckSatisfiedVisitor : - ConstVisitor<DependencySpecTree>, - ConstVisitor<DependencySpecTree>::VisitConstSequence<CheckSatisfiedVisitor, AllDepSpec> + struct CheckSatisfiedVisitor { - using ConstVisitor<DependencySpecTree>::VisitConstSequence<CheckSatisfiedVisitor, AllDepSpec>::visit_sequence; - const Environment * const env; const PackageID & id; std::tr1::shared_ptr<const PackageDepSpec> failure; @@ -1291,67 +1281,72 @@ namespace { } - void visit_leaf(const BlockDepSpec &) + void visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node) { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), + accept_visitor(*this)); } - void visit_leaf(const DependencyLabelsDepSpec &) + void visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type &) { } - void visit_leaf(const PackageDepSpec & a) + void visit(const DependencySpecTree::NodeType<DependencyLabelsDepSpec>::Type &) + { + } + + void visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node) { if (! failure) - if ((*env)[selection::SomeArbitraryVersion(generator::Matches(a, MatchPackageOptions()) + if ((*env)[selection::SomeArbitraryVersion(generator::Matches(*node.spec(), MatchPackageOptions()) | filter::SupportsAction<InstalledAction>())]->empty()) - failure.reset(new PackageDepSpec(a)); + failure = node.spec(); } - void visit_sequence(const ConditionalDepSpec & u, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) + void visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node) { - if (u.condition_met()) - std::for_each(cur, end, accept_visitor(*this)); + if (node.spec()->condition_met()) + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), + accept_visitor(*this)); } - void visit_sequence(const AnyDepSpec &, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) + void visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node) { if (failure) return; failure.reset(); - for ( ; cur != end ; ++cur) + for (DependencySpecTree::NodeType<ConditionalDepSpec>::Type::ConstIterator cur(node.begin()) ; + cur != node.end() ; ++cur) { failure.reset(); - cur->accept(*this); + (*cur)->accept(*this); if (! failure) break; } } - void visit_leaf(const NamedSetDepSpec & s) + void visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & node) { - std::tr1::shared_ptr<const SetSpecTree::ConstItem> set(env->set(s.name())); + std::tr1::shared_ptr<const SetSpecTree> set(env->set(node.spec()->name())); if (! set) { - Log::get_instance()->message("install_task.unknown_set", ll_warning, lc_context) << "Unknown set '" << s.name() << "'"; + Log::get_instance()->message("install_task.unknown_set", ll_warning, lc_context) << "Unknown set '" + << node.spec()->name() << "'"; return; } - if (! recursing_sets.insert(s.name()).second) + if (! recursing_sets.insert(node.spec()->name()).second) { Log::get_instance()->message("install_task.recursive_set", ll_warning, lc_context) - << "Recursively defined set '" << s.name() << "'"; + << "Recursively defined set '" << node.spec()->name() << "'"; return; } - set->accept(*this); + set->root()->accept(*this); - recursing_sets.erase(s.name()); + recursing_sets.erase(node.spec()->name()); } }; } @@ -1366,23 +1361,23 @@ InstallTask::_unsatisfied(const DepListEntry & e) const if (dl_deps_pre == _imp->dep_list.options()->uninstalled_deps_pre() || dl_deps_pre_or_post == _imp->dep_list.options()->uninstalled_deps_pre()) if (e.package_id()->build_dependencies_key()) - e.package_id()->build_dependencies_key()->value()->accept(v); + e.package_id()->build_dependencies_key()->value()->root()->accept(v); if (dl_deps_pre == _imp->dep_list.options()->uninstalled_deps_runtime() || dl_deps_pre_or_post == _imp->dep_list.options()->uninstalled_deps_runtime()) if (e.package_id()->run_dependencies_key()) - e.package_id()->run_dependencies_key()->value()->accept(v); + e.package_id()->run_dependencies_key()->value()->root()->accept(v); if (dl_deps_pre == _imp->dep_list.options()->uninstalled_deps_post() || dl_deps_pre_or_post == _imp->dep_list.options()->uninstalled_deps_post()) if (e.package_id()->post_dependencies_key()) - e.package_id()->post_dependencies_key()->value()->accept(v); + e.package_id()->post_dependencies_key()->value()->root()->accept(v); if ((dl_deps_pre == _imp->dep_list.options()->uninstalled_deps_suggested() || dl_deps_pre_or_post == _imp->dep_list.options()->uninstalled_deps_suggested()) && dl_suggested_install == _imp->dep_list.options()->suggested()) if (e.package_id()->suggested_dependencies_key()) - e.package_id()->suggested_dependencies_key()->value()->accept(v); + e.package_id()->suggested_dependencies_key()->value()->root()->accept(v); return v.failure; } @@ -1431,14 +1426,8 @@ namespace } }; - struct CheckIndependentVisitor : - ConstVisitor<DependencySpecTree>, - ConstVisitor<DependencySpecTree>::VisitConstSequence<CheckIndependentVisitor, AllDepSpec>, - ConstVisitor<DependencySpecTree>::VisitConstSequence<CheckIndependentVisitor, AnyDepSpec> + struct CheckIndependentVisitor { - using ConstVisitor<DependencySpecTree>::VisitConstSequence<CheckIndependentVisitor, AllDepSpec>::visit_sequence; - using ConstVisitor<DependencySpecTree>::VisitConstSequence<CheckIndependentVisitor, AnyDepSpec>::visit_sequence; - const Environment * const env; const DepList & dep_list; const std::tr1::shared_ptr<const PackageID> id; @@ -1459,15 +1448,27 @@ namespace { } - void visit_leaf(const BlockDepSpec &) + void visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), + accept_visitor(*this)); + } + + void visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), + accept_visitor(*this)); + } + + void visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type &) { } - void visit_leaf(const DependencyLabelsDepSpec &) + void visit(const DependencySpecTree::NodeType<DependencyLabelsDepSpec>::Type &) { } - void visit_leaf(const PackageDepSpec & a) + void visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node) { if (failure) return; @@ -1478,7 +1479,7 @@ namespace if (! d->handled()) continue; - if (! match_package(*env, a, *d->package_id(), MatchPackageOptions())) + if (! match_package(*env, *node.spec(), *d->package_id(), MatchPackageOptions())) continue; CheckHandledVisitor v; @@ -1493,7 +1494,7 @@ namespace /* no match on the dep list, fall back to installed packages. if * there are no matches here it's not a problem because of or-deps. */ std::tr1::shared_ptr<const PackageIDSequence> installed((*env)[selection::AllVersionsUnsorted( - generator::Matches(a, MatchPackageOptions()) | + generator::Matches(*node.spec(), MatchPackageOptions()) | filter::SupportsAction<InstalledAction>())]); for (PackageIDSequence::ConstIterator i(installed->begin()), i_end(installed->end()) ; @@ -1508,23 +1509,23 @@ namespace if (dl_deps_pre == dep_list.options()->uninstalled_deps_pre() || dl_deps_pre_or_post == dep_list.options()->uninstalled_deps_pre()) if ((*i)->build_dependencies_key()) - (*i)->build_dependencies_key()->value()->accept(v); + (*i)->build_dependencies_key()->value()->root()->accept(v); if (dl_deps_pre == dep_list.options()->uninstalled_deps_runtime() || dl_deps_pre_or_post == dep_list.options()->uninstalled_deps_runtime()) if ((*i)->run_dependencies_key()) - (*i)->run_dependencies_key()->value()->accept(v); + (*i)->run_dependencies_key()->value()->root()->accept(v); if (dl_deps_pre == dep_list.options()->uninstalled_deps_post() || dl_deps_pre_or_post == dep_list.options()->uninstalled_deps_post()) if ((*i)->post_dependencies_key()) - (*i)->post_dependencies_key()->value()->accept(v); + (*i)->post_dependencies_key()->value()->root()->accept(v); if ((dl_deps_pre == dep_list.options()->uninstalled_deps_suggested() || dl_deps_pre_or_post == dep_list.options()->uninstalled_deps_suggested()) && dl_suggested_install == dep_list.options()->suggested()) if ((*i)->suggested_dependencies_key()) - (*i)->suggested_dependencies_key()->value()->accept(v); + (*i)->suggested_dependencies_key()->value()->root()->accept(v); if (v.failure) { @@ -1534,34 +1535,33 @@ namespace } } - void visit_sequence(const ConditionalDepSpec & u, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) + void visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node) { - if (u.condition_met()) - std::for_each(cur, end, accept_visitor(*this)); + if (node.spec()->condition_met()) + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), + accept_visitor(*this)); } - void visit_leaf(const NamedSetDepSpec & s) + void visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & node) { - std::tr1::shared_ptr<const SetSpecTree::ConstItem> set(env->set(s.name())); + std::tr1::shared_ptr<const SetSpecTree> set(env->set(node.spec()->name())); if (! set) { - Log::get_instance()->message("install_task.unknown_set", ll_warning, lc_context) << "Unknown set '" << s.name() << "'"; + Log::get_instance()->message("install_task.unknown_set", ll_warning, lc_context) << "Unknown set '" << node.spec()->name() << "'"; return; } - if (! recursing_sets.insert(s.name()).second) + if (! recursing_sets.insert(node.spec()->name()).second) { Log::get_instance()->message("install_task.recursive_set", ll_warning, lc_context) - << "Recursively defined set '" << s.name() << "'"; + << "Recursively defined set '" << node.spec()->name() << "'"; return; } - set->accept(*this); + set->root()->accept(*this); - recursing_sets.erase(s.name()); + recursing_sets.erase(node.spec()->name()); } }; } @@ -1593,23 +1593,23 @@ InstallTask::_dependent(const DepListEntry & e) const if (dl_deps_pre == _imp->dep_list.options()->uninstalled_deps_pre() || dl_deps_pre_or_post == _imp->dep_list.options()->uninstalled_deps_pre()) if (e.package_id()->build_dependencies_key()) - e.package_id()->build_dependencies_key()->value()->accept(v); + e.package_id()->build_dependencies_key()->value()->root()->accept(v); if (dl_deps_pre == _imp->dep_list.options()->uninstalled_deps_runtime() || dl_deps_pre_or_post == _imp->dep_list.options()->uninstalled_deps_runtime()) if (e.package_id()->run_dependencies_key()) - e.package_id()->run_dependencies_key()->value()->accept(v); + e.package_id()->run_dependencies_key()->value()->root()->accept(v); if (dl_deps_pre == _imp->dep_list.options()->uninstalled_deps_post() || dl_deps_pre_or_post == _imp->dep_list.options()->uninstalled_deps_post()) if (e.package_id()->post_dependencies_key()) - e.package_id()->post_dependencies_key()->value()->accept(v); + e.package_id()->post_dependencies_key()->value()->root()->accept(v); if ((dl_deps_pre == _imp->dep_list.options()->uninstalled_deps_suggested() || dl_deps_pre_or_post == _imp->dep_list.options()->uninstalled_deps_suggested()) && dl_suggested_install == _imp->dep_list.options()->suggested()) if (e.package_id()->suggested_dependencies_key()) - e.package_id()->suggested_dependencies_key()->value()->accept(v); + e.package_id()->suggested_dependencies_key()->value()->root()->accept(v); return v.failure; } diff --git a/paludis/install_task.hh b/paludis/install_task.hh index f89a46717..5a3566e83 100644 --- a/paludis/install_task.hh +++ b/paludis/install_task.hh @@ -207,7 +207,7 @@ namespace paludis ///\{ virtual void world_update_set(const SetName &); - virtual void world_update_packages(const std::tr1::shared_ptr<const SetSpecTree::ConstItem> &); + virtual void world_update_packages(const std::tr1::shared_ptr<const SetSpecTree> &); ///\} diff --git a/paludis/literal_metadata_key.cc b/paludis/literal_metadata_key.cc index d7eb9504b..e1db4fd2b 100644 --- a/paludis/literal_metadata_key.cc +++ b/paludis/literal_metadata_key.cc @@ -23,7 +23,6 @@ #include <paludis/util/sequence.hh> #include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/util/join.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/formatter.hh> #include <paludis/package_id.hh> #include <paludis/action.hh> diff --git a/paludis/match_package.cc b/paludis/match_package.cc index 217af7683..d236bb63c 100644 --- a/paludis/match_package.cc +++ b/paludis/match_package.cc @@ -26,10 +26,11 @@ #include <paludis/package_id.hh> #include <paludis/slot_requirement.hh> #include <paludis/metadata_key.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/set.hh> #include <paludis/util/fs_entry.hh> #include <paludis/util/options.hh> +#include <paludis/util/wrapped_forward_iterator.hh> +#include <paludis/util/sequence.hh> #include <paludis/action.hh> #include <paludis/repository.hh> #include <paludis/metadata_key.hh> @@ -212,14 +213,14 @@ paludis::match_package( bool paludis::match_package_in_set( const Environment & env, - const SetSpecTree::ConstItem & target, + const SetSpecTree & target, const PackageID & entry, const MatchPackageOptions & options) { using namespace std::tr1::placeholders; DepSpecFlattener<SetSpecTree, PackageDepSpec> f(&env); - target.accept(f); + target.root()->accept(f); return indirect_iterator(f.end()) != std::find_if( indirect_iterator(f.begin()), indirect_iterator(f.end()), std::tr1::bind(&match_package, std::tr1::cref(env), _1, std::tr1::cref(entry), std::tr1::cref(options))); diff --git a/paludis/match_package.hh b/paludis/match_package.hh index 27172fb70..26bf127c1 100644 --- a/paludis/match_package.hh +++ b/paludis/match_package.hh @@ -33,7 +33,7 @@ #include <paludis/match_package-fwd.hh> #include <paludis/util/attributes.hh> #include <paludis/dep_spec-fwd.hh> -#include <paludis/dep_tree.hh> +#include <paludis/spec_tree-fwd.hh> #include <paludis/environment-fwd.hh> #include <paludis/package_id-fwd.hh> #include <tr1/memory> @@ -63,7 +63,7 @@ namespace paludis */ bool match_package_in_set( const Environment & env, - const SetSpecTree::ConstItem & spec, + const SetSpecTree & spec, const PackageID & target, const MatchPackageOptions & options) PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE; diff --git a/paludis/metadata_key.cc b/paludis/metadata_key.cc index fd7241daf..91898110f 100644 --- a/paludis/metadata_key.cc +++ b/paludis/metadata_key.cc @@ -18,7 +18,6 @@ */ #include <paludis/metadata_key.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/exception.hh> #include <paludis/util/stringify.hh> diff --git a/paludis/metadata_key.hh b/paludis/metadata_key.hh index 973299708..380480f0f 100644 --- a/paludis/metadata_key.hh +++ b/paludis/metadata_key.hh @@ -25,7 +25,7 @@ #include <paludis/package_id-fwd.hh> #include <paludis/name-fwd.hh> #include <paludis/dep_spec-fwd.hh> -#include <paludis/dep_tree.hh> +#include <paludis/spec_tree.hh> #include <paludis/contents-fwd.hh> #include <paludis/repository-fwd.hh> #include <paludis/formatter-fwd.hh> @@ -355,7 +355,7 @@ namespace paludis /** * Fetch our value. */ - virtual const std::tr1::shared_ptr<const typename C_::ConstItem> value() const + virtual const std::tr1::shared_ptr<const C_> value() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0; /** @@ -401,7 +401,7 @@ namespace paludis /** * Fetch our value. */ - virtual const std::tr1::shared_ptr<const FetchableURISpecTree::ConstItem> value() const + virtual const std::tr1::shared_ptr<const FetchableURISpecTree> value() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0; /** @@ -454,7 +454,7 @@ namespace paludis /** * Fetch our value. */ - virtual const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> value() const + virtual const std::tr1::shared_ptr<const DependencySpecTree> value() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0; /** diff --git a/paludis/override_functions.cc b/paludis/override_functions.cc index dd5b0d902..d58490775 100644 --- a/paludis/override_functions.cc +++ b/paludis/override_functions.cc @@ -18,10 +18,11 @@ */ #include <paludis/override_functions.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/simple_visitor_cast.hh> #include <paludis/util/set.hh> #include <paludis/util/stringify.hh> +#include <paludis/util/wrapped_forward_iterator.hh> +#include <paludis/util/sequence.hh> #include <paludis/environment.hh> #include <paludis/package_id.hh> #include <paludis/metadata_key.hh> diff --git a/paludis/package_id.hh b/paludis/package_id.hh index cee5fa925..b19693d30 100644 --- a/paludis/package_id.hh +++ b/paludis/package_id.hh @@ -30,7 +30,7 @@ #include <paludis/action-fwd.hh> #include <paludis/dep_spec-fwd.hh> -#include <paludis/dep_tree-fwd.hh> +#include <paludis/spec_tree-fwd.hh> #include <paludis/mask-fwd.hh> #include <paludis/metadata_key-fwd.hh> #include <paludis/metadata_key_holder.hh> diff --git a/paludis/query_visitor.cc b/paludis/query_visitor.cc index 298512f6e..cad62a1ce 100644 --- a/paludis/query_visitor.cc +++ b/paludis/query_visitor.cc @@ -28,7 +28,10 @@ #include <paludis/util/sequence.hh> #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/log.hh> -#include <paludis/util/visitor-impl.hh> +#include <paludis/util/wrapped_forward_iterator.hh> +#include <paludis/util/indirect_iterator-impl.hh> +#include <paludis/util/accept_visitor.hh> +#include <paludis/util/make_shared_ptr.hh> #include <tr1/functional> #include <algorithm> #include <set> @@ -76,7 +79,7 @@ QueryVisitor::result() const } void -QueryVisitor::visit_leaf(const PackageDepSpec & a) +QueryVisitor::visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node) { using namespace std::tr1::placeholders; @@ -88,7 +91,7 @@ QueryVisitor::visit_leaf(const PackageDepSpec & a) // TODO: check destinations std::tr1::shared_ptr<const PackageIDSequence> matches((*_imp->environment)[selection::AllVersionsUnsorted( - generator::Matches(a, _imp->dep_list->options()->match_package_options()) | + generator::Matches(*node.spec(), _imp->dep_list->options()->match_package_options()) | filter::InstalledAtRoot(_imp->environment->root()))]); if (indirect_iterator(matches->end()) != std::find_if(indirect_iterator(matches->begin()), indirect_iterator(matches->end()), @@ -99,7 +102,7 @@ QueryVisitor::visit_leaf(const PackageDepSpec & a) } /* check the merge list for any new packages that match */ - if (_imp->dep_list->match_on_list(a)) + if (_imp->dep_list->match_on_list(*node.spec())) { _imp->result = true; return; @@ -107,44 +110,43 @@ QueryVisitor::visit_leaf(const PackageDepSpec & a) } void -QueryVisitor::visit_leaf(const NamedSetDepSpec & s) +QueryVisitor::visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & node) { - Context context("When expanding named set '" + stringify(s) + "':"); + Context context("When expanding named set '" + stringify(*node.spec()) + "':"); - std::tr1::shared_ptr<const SetSpecTree::ConstItem> set(_imp->environment->set(s.name())); + std::tr1::shared_ptr<const SetSpecTree> set(_imp->environment->set(node.spec()->name())); if (! set) { - Log::get_instance()->message("dep_list.query_visitor.unknown_set", ll_warning, lc_context) << "Unknown set '" << s.name() << "'"; + Log::get_instance()->message("dep_list.query_visitor.unknown_set", ll_warning, lc_context) << "Unknown set '" << node.spec()->name() << "'"; _imp->result = false; return; } - if (! _imp->recursing_sets.insert(s.name()).second) + if (! _imp->recursing_sets.insert(node.spec()->name()).second) { Log::get_instance()->message("dep_list.query_visitor.recursive_set", ll_warning, lc_context) - << "Recursively defined set '" << s.name() << "'"; + << "Recursively defined set '" << node.spec()->name() << "'"; return; } - set->accept(*this); + set->root()->accept(*this); - _imp->recursing_sets.erase(s.name()); + _imp->recursing_sets.erase(node.spec()->name()); } void -QueryVisitor::visit_sequence(const ConditionalDepSpec & a, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) +QueryVisitor::visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node) { /* for use? ( ) dep specs, return true if we're not enabled, so that * weird || ( ) cases work. */ - if (a.condition_met()) + if (node.spec()->condition_met()) { _imp->result = true; - for ( ; cur != end ; ++cur) + for (DependencySpecTree::NodeType<AnyDepSpec>::Type::ConstIterator c(node.begin()), c_end(node.end()) ; + c != c_end ; ++c) { - cur->accept(*this); + (*c)->accept(*this); if (! _imp->result) return; } @@ -154,52 +156,56 @@ QueryVisitor::visit_sequence(const ConditionalDepSpec & a, } void -QueryVisitor::visit_sequence(const AnyDepSpec &, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) +QueryVisitor::visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node) { /* empty || ( ) must resolve to true */ _imp->result = true; RangeRewriter r; - std::for_each(cur, end, accept_visitor(r)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(r)); if (r.spec()) - visit_leaf(*r.spec()); + { + DependencySpecTree tree(make_shared_ptr(new AllDepSpec)); + tree.root()->append(r.spec()); + tree.root()->accept(*this); + } else - for ( ; cur != end ; ++cur) + for (DependencySpecTree::NodeType<AnyDepSpec>::Type::ConstIterator c(node.begin()), c_end(node.end()) ; + c != c_end ; ++c) { - if (! is_viable_any_child(*cur)) + if (! is_viable_any_child(**c)) continue; - cur->accept(*this); + (*c)->accept(*this); if (_imp->result) return; } } void -QueryVisitor::visit_leaf(const BlockDepSpec & a) +QueryVisitor::visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type & node) { - visit_leaf(*a.blocked_spec()); + DependencySpecTree tree(make_shared_ptr(new AllDepSpec)); + tree.root()->append(node.spec()->blocked_spec()); + tree.root()->accept(*this); _imp->result = !_imp->result; } void -QueryVisitor::visit_sequence(const AllDepSpec &, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) +QueryVisitor::visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node) { - for ( ; cur != end ; ++cur) + for (DependencySpecTree::NodeType<AnyDepSpec>::Type::ConstIterator c(node.begin()), c_end(node.end()) ; + c != c_end ; ++c) { - cur->accept(*this); + (*c)->accept(*this); if (! _imp->result) return; } } void -QueryVisitor::visit_leaf(const DependencyLabelsDepSpec &) +QueryVisitor::visit(const DependencySpecTree::NodeType<DependencyLabelsDepSpec>::Type &) { // XXX implement } diff --git a/paludis/query_visitor.hh b/paludis/query_visitor.hh index 43d627eeb..56cd38083 100644 --- a/paludis/query_visitor.hh +++ b/paludis/query_visitor.hh @@ -43,7 +43,6 @@ namespace paludis * \nosubgrouping */ class QueryVisitor : - public ConstVisitor<DependencySpecTree>, private PrivateImplementationPattern<QueryVisitor> { public: @@ -60,25 +59,13 @@ namespace paludis ///\name Visitor operations ///\{ - void visit_sequence(const AllDepSpec &, - DependencySpecTree::ConstSequenceIterator, - DependencySpecTree::ConstSequenceIterator); - - void visit_sequence(const AnyDepSpec &, - DependencySpecTree::ConstSequenceIterator, - DependencySpecTree::ConstSequenceIterator); - - void visit_sequence(const ConditionalDepSpec &, - DependencySpecTree::ConstSequenceIterator, - DependencySpecTree::ConstSequenceIterator); - - void visit_leaf(const PackageDepSpec &); - - void visit_leaf(const BlockDepSpec &); - - void visit_leaf(const DependencyLabelsDepSpec &); - - void visit_leaf(const NamedSetDepSpec &); + void visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<DependencyLabelsDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & node); ///\} diff --git a/paludis/range_rewriter.cc b/paludis/range_rewriter.cc index 84eb03021..df0065e72 100644 --- a/paludis/range_rewriter.cc +++ b/paludis/range_rewriter.cc @@ -20,10 +20,12 @@ #include <paludis/range_rewriter.hh> #include <paludis/util/sequence.hh> #include <paludis/version_requirements.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/stringify.hh> #include <paludis/util/join.hh> #include <paludis/util/make_shared_ptr.hh> +#include <paludis/util/wrapped_forward_iterator.hh> +#include <paludis/util/wrapped_output_iterator.hh> +#include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/dep_spec.hh> #include <list> #include <sstream> @@ -211,37 +213,32 @@ RangeRewriter::~RangeRewriter() } void -RangeRewriter::visit_sequence(const AllDepSpec &, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) +RangeRewriter::visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node) { - if (cur != end) + if (node.begin() != node.end()) _imp->invalid = true; } void -RangeRewriter::visit_sequence(const AnyDepSpec &, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) +RangeRewriter::visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node) { - if (cur != end) + if (node.begin() != node.end()) _imp->invalid = true; } void -RangeRewriter::visit_sequence(const ConditionalDepSpec &, - DependencySpecTree::ConstSequenceIterator, - DependencySpecTree::ConstSequenceIterator) +RangeRewriter::visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type &) { _imp->invalid = true; } void -RangeRewriter::visit_leaf(const PackageDepSpec & a) +RangeRewriter::visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node) { if (_imp->invalid) return; + const PackageDepSpec & a(*node.spec()); if (a.additional_requirements_ptr() || a.slot_requirement_ptr() || a.package_name_part_ptr() || a.category_name_part_ptr() || ! a.version_requirements_ptr() || ! a.package_ptr() || a.in_repository_ptr() @@ -279,19 +276,19 @@ RangeRewriter::visit_leaf(const PackageDepSpec & a) } void -RangeRewriter::visit_leaf(const BlockDepSpec &) +RangeRewriter::visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type &) { _imp->invalid = true; } void -RangeRewriter::visit_leaf(const DependencyLabelsDepSpec &) +RangeRewriter::visit(const DependencySpecTree::NodeType<DependencyLabelsDepSpec>::Type &) { _imp->invalid = true; } void -RangeRewriter::visit_leaf(const NamedSetDepSpec &) +RangeRewriter::visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type &) { _imp->invalid = true; } diff --git a/paludis/range_rewriter.hh b/paludis/range_rewriter.hh index 6804da671..ddebf3133 100644 --- a/paludis/range_rewriter.hh +++ b/paludis/range_rewriter.hh @@ -20,7 +20,7 @@ #ifndef PALUDIS_GUARD_PALUDIS_RANGE_REWRITER_HH #define PALUDIS_GUARD_PALUDIS_RANGE_REWRITER_HH 1 -#include <paludis/dep_tree.hh> +#include <paludis/spec_tree.hh> #include <paludis/util/private_implementation_pattern.hh> /** \file @@ -44,7 +44,6 @@ namespace paludis * \nosubgrouping */ class PALUDIS_VISIBLE RangeRewriter : - public ConstVisitor<DependencySpecTree>, private PrivateImplementationPattern<RangeRewriter> { public: @@ -65,25 +64,13 @@ namespace paludis ///\name Visit methods ///\{ - void visit_sequence(const AllDepSpec &, - DependencySpecTree::ConstSequenceIterator, - DependencySpecTree::ConstSequenceIterator); - - void visit_sequence(const AnyDepSpec &, - DependencySpecTree::ConstSequenceIterator, - DependencySpecTree::ConstSequenceIterator); - - void visit_sequence(const ConditionalDepSpec &, - DependencySpecTree::ConstSequenceIterator, - DependencySpecTree::ConstSequenceIterator); - - void visit_leaf(const PackageDepSpec &); - - void visit_leaf(const BlockDepSpec &); - - void visit_leaf(const DependencyLabelsDepSpec &); - - void visit_leaf(const NamedSetDepSpec &); + void visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<DependencyLabelsDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & node); ///\} }; diff --git a/paludis/range_rewriter_TEST.cc b/paludis/range_rewriter_TEST.cc index e6c0f1695..7dd49ce8a 100644 --- a/paludis/range_rewriter_TEST.cc +++ b/paludis/range_rewriter_TEST.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -20,7 +20,6 @@ #include <paludis/range_rewriter.hh> #include <paludis/dep_spec.hh> #include <paludis/user_dep_spec.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/options.hh> #include <paludis/environments/test/test_environment.hh> @@ -42,17 +41,15 @@ namespace test_cases void run() { TestEnvironment env; - std::tr1::shared_ptr<TreeLeaf<DependencySpecTree, PackageDepSpec> > a(new TreeLeaf<DependencySpecTree, PackageDepSpec>( - std::tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(parse_user_package_dep_spec("=a/b-1", - &env, UserPackageDepSpecOptions()))))); - std::tr1::shared_ptr<TreeLeaf<DependencySpecTree, PackageDepSpec> > b(new TreeLeaf<DependencySpecTree, PackageDepSpec>( - std::tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(parse_user_package_dep_spec("=a/b-2", - &env, UserPackageDepSpecOptions()))))); + std::tr1::shared_ptr<DependencySpecTree> a(new DependencySpecTree(make_shared_ptr(new AllDepSpec))); + a->root()->append(make_shared_ptr(new PackageDepSpec(parse_user_package_dep_spec("=a/b-1", + &env, UserPackageDepSpecOptions())))); + a->root()->append(make_shared_ptr(new PackageDepSpec(parse_user_package_dep_spec("=a/b-2", + &env, UserPackageDepSpecOptions())))); RangeRewriter r; TEST_CHECK(! r.spec()); - a->accept(r); - b->accept(r); + std::for_each(indirect_iterator(a->root()->begin()), indirect_iterator(a->root()->end()), accept_visitor(r)); TEST_CHECK(r.spec()); TEST_CHECK(r.spec()); diff --git a/paludis/report_task.cc b/paludis/report_task.cc index 52851be41..618a8f80e 100644 --- a/paludis/report_task.cc +++ b/paludis/report_task.cc @@ -29,12 +29,16 @@ #include <paludis/filter.hh> #include <paludis/filtered_generator.hh> #include <paludis/util/private_implementation_pattern-impl.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/simple_visitor_cast.hh> #include <paludis/util/set.hh> #include <paludis/util/make_named_values.hh> +#include <paludis/util/indirect_iterator-impl.hh> +#include <paludis/util/wrapped_forward_iterator.hh> +#include <paludis/util/accept_visitor.hh> +#include <paludis/util/sequence.hh> #include <paludis/package_database.hh> #include <paludis/version_requirements.hh> +#include <algorithm> #include <set> #include <map> @@ -42,9 +46,7 @@ using namespace paludis; namespace { - class VulnerableChecker : - public ConstVisitor<SetSpecTree>, - public ConstVisitor<SetSpecTree>::VisitConstSequence<VulnerableChecker, AllDepSpec> + class VulnerableChecker { private: std::multimap<std::tr1::shared_ptr<const PackageID>, std::tr1::shared_ptr<const DepTag>, PackageIDSetComparator> _found; @@ -55,36 +57,40 @@ namespace typedef std::multimap<std::tr1::shared_ptr<const PackageID>, std::tr1::shared_ptr<const DepTag>, PackageIDSetComparator>::const_iterator ConstIterator; - using ConstVisitor<SetSpecTree>::VisitConstSequence<VulnerableChecker, AllDepSpec>::visit; - VulnerableChecker(const Environment & e) : _env(e) { } - void visit_leaf(const PackageDepSpec &); + void visit(const SetSpecTree::NodeType<AllDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + + void visit(const SetSpecTree::NodeType<PackageDepSpec>::Type & node); - void visit_leaf(const NamedSetDepSpec & s) + void visit(const SetSpecTree::NodeType<NamedSetDepSpec>::Type & node) { - Context context("When expanding named set '" + stringify(s) + "':"); + Context context("When expanding named set '" + stringify(*node.spec()) + "':"); - std::tr1::shared_ptr<const SetSpecTree::ConstItem> set(_env.set(s.name())); + std::tr1::shared_ptr<const SetSpecTree> set(_env.set(node.spec()->name())); if (! set) { - Log::get_instance()->message("report_task.unknown_set", ll_warning, lc_context) << "Unknown set '" << s.name() << "'"; + Log::get_instance()->message("report_task.unknown_set", ll_warning, lc_context) + << "Unknown set '" << node.spec()->name() << "'"; return; } - if (! _recursing_sets.insert(s.name()).second) + if (! _recursing_sets.insert(node.spec()->name()).second) { Log::get_instance()->message("report_task.recursive_set", ll_warning, lc_context) - << "Recursively defined set '" << s.name() << "'"; + << "Recursively defined set '" << node.spec()->name() << "'"; return; } - set->accept(*this); + set->root()->accept(*this); - _recursing_sets.erase(s.name()); + _recursing_sets.erase(node.spec()->name()); } std::pair<ConstIterator, ConstIterator> insecure_tags(const std::tr1::shared_ptr<const PackageID> & id) const @@ -94,14 +100,14 @@ namespace }; void - VulnerableChecker::visit_leaf(const PackageDepSpec & a) + VulnerableChecker::visit(const SetSpecTree::NodeType<PackageDepSpec>::Type & node) { std::tr1::shared_ptr<const PackageIDSequence> insecure(_env[selection::AllVersionsSorted( - generator::Matches(a, MatchPackageOptions()))]); + generator::Matches(*node.spec(), MatchPackageOptions()))]); for (PackageIDSequence::ConstIterator i(insecure->begin()), i_end(insecure->end()) ; i != i_end ; ++i) - if (a.tag() && simple_visitor_cast<const GLSADepTag>(*a.tag())) - _found.insert(std::make_pair(*i, a.tag())); + if (node.spec()->tag() && simple_visitor_cast<const GLSADepTag>(*node.spec()->tag())) + _found.insert(std::make_pair(*i, node.spec()->tag())); else throw InternalError(PALUDIS_HERE, "didn't get a tag"); } @@ -150,10 +156,10 @@ ReportTask::execute() try { - std::tr1::shared_ptr<const SetSpecTree::ConstItem> insecure((*rr).sets_interface()->package_set(SetName("insecurity"))); + std::tr1::shared_ptr<const SetSpecTree> insecure((*rr).sets_interface()->package_set(SetName("insecurity"))); if (! insecure) continue; - insecure->accept(vuln); + insecure->root()->accept(vuln); } catch (const NotAvailableError &) { diff --git a/paludis/repositories/cran/cran_dep_parser.cc b/paludis/repositories/cran/cran_dep_parser.cc index e48ef79a8..4961c478d 100644 --- a/paludis/repositories/cran/cran_dep_parser.cc +++ b/paludis/repositories/cran/cran_dep_parser.cc @@ -18,26 +18,26 @@ */ #include <paludis/dep_spec.hh> +#include <paludis/spec_tree.hh> #include <paludis/repositories/cran/cran_dep_parser.hh> #include <paludis/repositories/cran/normalise.hh> #include <paludis/repositories/cran/package_dep_spec.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/strip.hh> #include <paludis/util/stringify.hh> #include <paludis/util/tokeniser.hh> +#include <paludis/util/make_shared_ptr.hh> #include <string> #include <list> using namespace paludis; -std::tr1::shared_ptr<DependencySpecTree::ConstItem> +std::tr1::shared_ptr<DependencySpecTree> cranrepository::parse_depends(const std::string & s) { Context context("When parsing CRAN 'Depends:' string: '" + s + "':"); - std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > result( - new ConstTreeSequence<DependencySpecTree, AllDepSpec>(std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); + std::tr1::shared_ptr<DependencySpecTree> result(new DependencySpecTree(make_shared_ptr(new AllDepSpec))); std::list<std::string> specs; @@ -67,11 +67,9 @@ cranrepository::parse_depends(const std::string & s) { Context local_context("When processing token '" + *a + "':"); - std::tr1::shared_ptr<TreeLeaf<DependencySpecTree, PackageDepSpec> > spec( - new TreeLeaf<DependencySpecTree, PackageDepSpec>(std::tr1::shared_ptr<PackageDepSpec>( - new PackageDepSpec(cranrepository::parse_cran_package_dep_spec( - strip_leading(strip_trailing(*a, " \r\n\t"), " \r\n\t")))))); - result->add(spec); + std::tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(cranrepository::parse_cran_package_dep_spec( + strip_leading(strip_trailing(*a, " \r\n\t"), " \r\n\t")))); + result->root()->append(spec); } return result; diff --git a/paludis/repositories/cran/cran_dep_parser.hh b/paludis/repositories/cran/cran_dep_parser.hh index eadede504..5e8a15c5e 100644 --- a/paludis/repositories/cran/cran_dep_parser.hh +++ b/paludis/repositories/cran/cran_dep_parser.hh @@ -21,14 +21,15 @@ #ifndef PALUDIS_GUARD_PALUDIS_CRAN_DEP_PARSER_HH #define PALUDIS_GUARD_PALUDIS_CRAN_DEP_PARSER_HH 1 -#include <paludis/dep_tree.hh> +#include <paludis/dep_spec.hh> +#include <paludis/spec_tree-fwd.hh> #include <string> namespace paludis { namespace cranrepository { - std::tr1::shared_ptr<DependencySpecTree::ConstItem> parse_depends(const std::string & s) PALUDIS_VISIBLE; + std::tr1::shared_ptr<DependencySpecTree> parse_depends(const std::string & s) PALUDIS_VISIBLE; } } diff --git a/paludis/repositories/cran/cran_dep_parser_TEST.cc b/paludis/repositories/cran/cran_dep_parser_TEST.cc index 777ef2ace..677859e0b 100644 --- a/paludis/repositories/cran/cran_dep_parser_TEST.cc +++ b/paludis/repositories/cran/cran_dep_parser_TEST.cc @@ -23,7 +23,6 @@ #include <paludis/repositories/cran/dep_spec_pretty_printer.hh> #include <paludis/environments/test/test_environment.hh> #include <paludis/util/system.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/stringify_formatter.hh> #include <test/test_framework.hh> #include <test/test_runner.hh> @@ -45,29 +44,29 @@ namespace test_cases // test R dependency std::string dep1("R (>= 2.0.0)"); - cranrepository::parse_depends(dep1)->accept(d1); + cranrepository::parse_depends(dep1)->root()->accept(d1); TEST_CHECK_EQUAL(stringify(d1), "R (>= 2.0.0)"); // test varying whitespaces std::string dep2("testpackage1 \t(<1.9)"); - cranrepository::parse_depends(dep2)->accept(d2); + cranrepository::parse_depends(dep2)->root()->accept(d2); TEST_CHECK_EQUAL(stringify(d2), "testpackage1 (< 1.9)"); // test for package-name and version normalisation std::string dep3("R.matlab (>= 2.3-1)"); - cranrepository::parse_depends(dep3)->accept(d3); + cranrepository::parse_depends(dep3)->root()->accept(d3); TEST_CHECK_EQUAL(stringify(d3), "R.matlab (>= 2.3.1)"); std::string dep4("foo (>= 2, <3)"); - cranrepository::parse_depends(dep4)->accept(d4); + cranrepository::parse_depends(dep4)->root()->accept(d4); TEST_CHECK_EQUAL(stringify(d4), "foo (>= 2, < 3)"); std::string dep5("foo (>= 2), bar (<=3)"); - cranrepository::parse_depends(dep5)->accept(d5); + cranrepository::parse_depends(dep5)->root()->accept(d5); TEST_CHECK_EQUAL(stringify(d5), "foo (>= 2), bar (<= 3)"); std::string dep6("foo (>= 2, <= 4), bar (<=3)"); - cranrepository::parse_depends(dep6)->accept(d6); + cranrepository::parse_depends(dep6)->root()->accept(d6); TEST_CHECK_EQUAL(stringify(d6), "foo (>= 2, <= 4), bar (<= 3)"); } } test_cran_dep_parser; diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc index 43ce5dcab..ec4c4f98f 100644 --- a/paludis/repositories/cran/cran_installed_repository.cc +++ b/paludis/repositories/cran/cran_installed_repository.cc @@ -2,7 +2,7 @@ /* * Copyright (c) 2006, 2007 Danny van Dyk - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -42,9 +42,9 @@ #include <paludis/util/stringify.hh> #include <paludis/util/strip.hh> #include <paludis/util/tokeniser.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/hashes.hh> #include <paludis/util/make_named_values.hh> +#include <paludis/util/wrapped_output_iterator.hh> #include <tr1/functional> #include <tr1/unordered_map> #include <functional> @@ -445,7 +445,7 @@ CRANInstalledRepository::do_uninstall(const QualifiedPackageName & q, const Vers } #endif -std::tr1::shared_ptr<SetSpecTree::ConstItem> +const std::tr1::shared_ptr<const SetSpecTree> CRANInstalledRepository::package_set(const SetName & s) const { Context context("When fetching package set '" + stringify(s) + "' from '" + @@ -453,24 +453,21 @@ CRANInstalledRepository::package_set(const SetName & s) const if ("everything" == s.data()) { - std::tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > result(new ConstTreeSequence<SetSpecTree, AllDepSpec>( - std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); + std::tr1::shared_ptr<SetSpecTree> result(new SetSpecTree(make_shared_ptr(new AllDepSpec))); need_ids(); for (IDMap::const_iterator p(_imp->ids.begin()), p_end(_imp->ids.end()) ; p != p_end ; ++p) { - std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> > spec( - new TreeLeaf<SetSpecTree, PackageDepSpec>(make_shared_ptr( - new PackageDepSpec(cranrepository::parse_cran_package_dep_spec(stringify(p->first.package())))))); - result->add(spec); + std::tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(cranrepository::parse_cran_package_dep_spec(stringify(p->first.package())))); + result->root()->append(spec); } return result; } else - return std::tr1::shared_ptr<SetSpecTree::ConstItem>(); + return make_null_shared_ptr(); } std::tr1::shared_ptr<const SetNameSet> diff --git a/paludis/repositories/cran/cran_installed_repository.hh b/paludis/repositories/cran/cran_installed_repository.hh index f7a63dc23..80b36273e 100644 --- a/paludis/repositories/cran/cran_installed_repository.hh +++ b/paludis/repositories/cran/cran_installed_repository.hh @@ -149,7 +149,7 @@ namespace paludis /* RepositorySetsInterface */ - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> package_set(const SetName & id) const + virtual const std::tr1::shared_ptr<const SetSpecTree> package_set(const SetName & id) const PALUDIS_ATTRIBUTE((warn_unused_result)); /* Keys */ diff --git a/paludis/repositories/cran/cran_package_id.cc b/paludis/repositories/cran/cran_package_id.cc index e2ea74cc1..60c71f777 100644 --- a/paludis/repositories/cran/cran_package_id.cc +++ b/paludis/repositories/cran/cran_package_id.cc @@ -39,7 +39,6 @@ #include <paludis/action.hh> #include <paludis/dep_label.hh> #include <paludis/util/tokeniser.hh> -#include <paludis/util/visitor-impl.hh> #include <string> #include <algorithm> #include <list> diff --git a/paludis/repositories/cran/cran_repository.cc b/paludis/repositories/cran/cran_repository.cc index 44cd46d25..553f1cfc0 100644 --- a/paludis/repositories/cran/cran_repository.cc +++ b/paludis/repositories/cran/cran_repository.cc @@ -2,7 +2,7 @@ /* * Copyright (c) 2006, 2007 Danny van Dyk - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -42,10 +42,11 @@ #include <paludis/util/system.hh> #include <paludis/util/tokeniser.hh> #include <paludis/util/is_file_with_extension.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/hashes.hh> #include <paludis/util/make_named_values.hh> #include <paludis/util/output_deviator.hh> +#include <paludis/util/wrapped_output_iterator.hh> +#include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/syncer.hh> #include <tr1/unordered_map> #include <tr1/functional> @@ -341,7 +342,7 @@ CRANRepository::do_install(const std::tr1::shared_ptr<const PackageID> & id_unca } #endif -std::tr1::shared_ptr<SetSpecTree::ConstItem> +const std::tr1::shared_ptr<const SetSpecTree> CRANRepository::package_set(const SetName & s) const { if ("base" == s.data()) @@ -350,11 +351,10 @@ CRANRepository::package_set(const SetName & s) const * \todo Implement system as all package which are installed * by dev-lang/R by default. */ - return std::tr1::shared_ptr<SetSpecTree::ConstItem>(new ConstTreeSequence<SetSpecTree, AllDepSpec>( - std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); + return make_shared_ptr(new SetSpecTree(make_shared_ptr(new AllDepSpec))); } else - return std::tr1::shared_ptr<SetSpecTree::ConstItem>(); + return make_null_shared_ptr(); } std::tr1::shared_ptr<const SetNameSet> diff --git a/paludis/repositories/cran/cran_repository.hh b/paludis/repositories/cran/cran_repository.hh index b84c1fdad..6d458af2b 100644 --- a/paludis/repositories/cran/cran_repository.hh +++ b/paludis/repositories/cran/cran_repository.hh @@ -128,7 +128,7 @@ namespace paludis /* RepositorySyncableInterface */ - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> package_set(const SetName &) const; + virtual const std::tr1::shared_ptr<const SetSpecTree> package_set(const SetName &) const; virtual std::tr1::shared_ptr<const SetNameSet> sets_list() const; diff --git a/paludis/repositories/cran/dep_spec_pretty_printer.cc b/paludis/repositories/cran/dep_spec_pretty_printer.cc index e369a1ac7..3445c35cb 100644 --- a/paludis/repositories/cran/dep_spec_pretty_printer.cc +++ b/paludis/repositories/cran/dep_spec_pretty_printer.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -20,7 +20,6 @@ #include <paludis/repositories/cran/dep_spec_pretty_printer.hh> #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/stringify.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/fs_entry.hh> #include <paludis/util/options.hh> #include <paludis/environment.hh> @@ -73,7 +72,7 @@ DepSpecPrettyPrinter::~DepSpecPrettyPrinter() } void -DepSpecPrettyPrinter::visit_leaf(const PackageDepSpec & p) +DepSpecPrettyPrinter::visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node) { if (_imp->multiline) _imp->s << _imp->formatter.indent(_imp->indent); @@ -84,34 +83,52 @@ DepSpecPrettyPrinter::visit_leaf(const PackageDepSpec & p) if (_imp->env) { - if (! (*_imp->env)[selection::SomeArbitraryVersion(generator::Matches(p, MatchPackageOptions()) | + if (! (*_imp->env)[selection::SomeArbitraryVersion(generator::Matches(*node.spec(), MatchPackageOptions()) | filter::InstalledAtRoot(_imp->env->root()))]->empty()) - _imp->s << _imp->formatter.format(p, format::Installed()); - else if (! (*_imp->env)[selection::SomeArbitraryVersion(generator::Matches(p, MatchPackageOptions()) | + _imp->s << _imp->formatter.format(*node.spec(), format::Installed()); + else if (! (*_imp->env)[selection::SomeArbitraryVersion(generator::Matches(*node.spec(), MatchPackageOptions()) | filter::SupportsAction<InstallAction>() | filter::NotMasked())]->empty()) - _imp->s << _imp->formatter.format(p, format::Installable()); + _imp->s << _imp->formatter.format(*node.spec(), format::Installable()); else - _imp->s << _imp->formatter.format(p, format::Plain()); + _imp->s << _imp->formatter.format(*node.spec(), format::Plain()); } else - _imp->s << _imp->formatter.format(p, format::Plain()); + _imp->s << _imp->formatter.format(*node.spec(), format::Plain()); if (_imp->multiline) _imp->s << _imp->formatter.newline(); } void -DepSpecPrettyPrinter::visit_leaf(const BlockDepSpec &) +DepSpecPrettyPrinter::visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node) { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } void -DepSpecPrettyPrinter::visit_leaf(const DependencyLabelsDepSpec &) +DepSpecPrettyPrinter::visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node) { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } void -DepSpecPrettyPrinter::visit_leaf(const NamedSetDepSpec & p) +DepSpecPrettyPrinter::visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node) +{ + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); +} + +void +DepSpecPrettyPrinter::visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type &) +{ +} + +void +DepSpecPrettyPrinter::visit(const DependencySpecTree::NodeType<DependencyLabelsDepSpec>::Type &) +{ +} + +void +DepSpecPrettyPrinter::visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & node) { if (_imp->multiline) _imp->s << _imp->formatter.indent(_imp->indent); @@ -120,7 +137,7 @@ DepSpecPrettyPrinter::visit_leaf(const NamedSetDepSpec & p) else _imp->need_comma = true; - _imp->s << _imp->formatter.format(p, format::Plain()); + _imp->s << _imp->formatter.format(*node.spec(), format::Plain()); if (_imp->multiline) _imp->s << _imp->formatter.newline(); diff --git a/paludis/repositories/cran/dep_spec_pretty_printer.hh b/paludis/repositories/cran/dep_spec_pretty_printer.hh index a343961a8..12a72999e 100644 --- a/paludis/repositories/cran/dep_spec_pretty_printer.hh +++ b/paludis/repositories/cran/dep_spec_pretty_printer.hh @@ -21,7 +21,7 @@ #define PALUDIS_GUARD_PALUDIS_REPOSITORIES_CRAN_DEP_SPEC_PRETTY_PRINTER_HH 1 #include <paludis/util/private_implementation_pattern.hh> -#include <paludis/dep_tree.hh> +#include <paludis/spec_tree.hh> #include <paludis/dep_spec-fwd.hh> #include <paludis/formatter.hh> #include <paludis/environment-fwd.hh> @@ -37,11 +37,7 @@ namespace paludis * \ingroup grpcranrepository */ class PALUDIS_VISIBLE DepSpecPrettyPrinter : - private PrivateImplementationPattern<DepSpecPrettyPrinter>, - public ConstVisitor<DependencySpecTree>, - public ConstVisitor<DependencySpecTree>::VisitConstSequence<DepSpecPrettyPrinter, AllDepSpec>, - public ConstVisitor<DependencySpecTree>::VisitConstSequence<DepSpecPrettyPrinter, ConditionalDepSpec>, - public ConstVisitor<DependencySpecTree>::VisitConstSequence<DepSpecPrettyPrinter, AnyDepSpec> + private PrivateImplementationPattern<DepSpecPrettyPrinter> { friend std::ostream & operator<< (std::ostream &, const DepSpecPrettyPrinter &); @@ -74,13 +70,13 @@ namespace paludis ///\} - void visit_leaf(const PackageDepSpec &); - - void visit_leaf(const BlockDepSpec &); - - void visit_leaf(const DependencyLabelsDepSpec &); - - void visit_leaf(const NamedSetDepSpec &); + void visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<DependencyLabelsDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & node); }; std::ostream & operator<< (std::ostream & s, const DepSpecPrettyPrinter & p) PALUDIS_VISIBLE; diff --git a/paludis/repositories/cran/keys.cc b/paludis/repositories/cran/keys.cc index f6a8cfc40..a8ad2bf21 100644 --- a/paludis/repositories/cran/keys.cc +++ b/paludis/repositories/cran/keys.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -27,7 +27,6 @@ #include <paludis/util/join.hh> #include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/util/indirect_iterator-impl.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/set.hh> #include <paludis/dep_spec.hh> #include <paludis/stringify_formatter-impl.hh> @@ -106,7 +105,7 @@ namespace paludis const std::string v; mutable Mutex mutex; - mutable std::tr1::shared_ptr<const DependencySpecTree::ConstItem> c; + mutable std::tr1::shared_ptr<const DependencySpecTree> c; const std::tr1::shared_ptr<const DependencyLabelSequence> labels; Implementation(const Environment * const e, const std::string & vv, @@ -131,7 +130,7 @@ DepKey::~DepKey() { } -const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> +const std::tr1::shared_ptr<const DependencySpecTree> DepKey::value() const { Lock l(_imp->mutex); @@ -148,7 +147,7 @@ DepKey::pretty_print(const DependencySpecTree::ItemFormatter & f) const { StringifyFormatter ff(f); DepSpecPrettyPrinter p(_imp->env, ff, 12, true); - value()->accept(p); + value()->root()->accept(p); return stringify(p); } @@ -157,7 +156,7 @@ DepKey::pretty_print_flat(const DependencySpecTree::ItemFormatter & f) const { StringifyFormatter ff(f); DepSpecPrettyPrinter p(_imp->env, ff, 0, false); - value()->accept(p); + value()->root()->accept(p); return stringify(p); } diff --git a/paludis/repositories/cran/keys.hh b/paludis/repositories/cran/keys.hh index dfcfd3fb3..004c5a896 100644 --- a/paludis/repositories/cran/keys.hh +++ b/paludis/repositories/cran/keys.hh @@ -81,7 +81,7 @@ namespace paludis ~DepKey(); - virtual const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> value() const + virtual const std::tr1::shared_ptr<const DependencySpecTree> value() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual std::string pretty_print(const DependencySpecTree::ItemFormatter &) const diff --git a/paludis/repositories/cran/masks.cc b/paludis/repositories/cran/masks.cc index f498ff853..6850cec58 100644 --- a/paludis/repositories/cran/masks.cc +++ b/paludis/repositories/cran/masks.cc @@ -19,7 +19,6 @@ #include "masks.hh" #include <paludis/util/private_implementation_pattern-impl.hh> -#include <paludis/util/visitor-impl.hh> using namespace paludis; using namespace paludis::cranrepository; diff --git a/paludis/repositories/e/aa_visitor.cc b/paludis/repositories/e/aa_visitor.cc index 119fbb7d9..05417e224 100644 --- a/paludis/repositories/e/aa_visitor.cc +++ b/paludis/repositories/e/aa_visitor.cc @@ -19,9 +19,12 @@ #include <paludis/dep_spec.hh> #include <paludis/repositories/e/aa_visitor.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/wrapped_forward_iterator.hh> +#include <paludis/util/indirect_iterator.hh> +#include <paludis/util/accept_visitor.hh> +#include <list> +#include <algorithm> /** \file * Implementation of aa_visitor.hh @@ -51,14 +54,21 @@ AAVisitor::~AAVisitor() } void -AAVisitor::visit_leaf(const FetchableURIDepSpec & p) +AAVisitor::visit(const FetchableURISpecTree::NodeType<FetchableURIDepSpec>::Type & node) +{ + _imp->aa.push_back(node.spec()->filename()); +} + + +void +AAVisitor::visit(const FetchableURISpecTree::NodeType<URILabelsDepSpec>::Type &) { - _imp->aa.push_back(p.filename()); } void -AAVisitor::visit_leaf(const URILabelsDepSpec &) +AAVisitor::visit(const FetchableURISpecTree::BasicInnerNode & node) { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } AAVisitor::ConstIterator diff --git a/paludis/repositories/e/aa_visitor.hh b/paludis/repositories/e/aa_visitor.hh index 4b2e71efa..b97d627b9 100644 --- a/paludis/repositories/e/aa_visitor.hh +++ b/paludis/repositories/e/aa_visitor.hh @@ -20,7 +20,7 @@ #ifndef PALUDIS_GUARD_PALUDIS_AAVISITOR_HH #define PALUDIS_GUARD_PALUDIS_AAVISITOR_HH 1 -#include <paludis/dep_tree.hh> +#include <paludis/spec_tree.hh> #include <paludis/dep_spec-fwd.hh> #include <paludis/util/private_implementation_pattern.hh> #include <paludis/util/wrapped_forward_iterator-fwd.hh> @@ -42,9 +42,6 @@ namespace paludis * \ingroup grpaavisitor */ class PALUDIS_VISIBLE AAVisitor : - public ConstVisitor<FetchableURISpecTree>, - public ConstVisitor<FetchableURISpecTree>::VisitConstSequence<AAVisitor, AllDepSpec>, - public ConstVisitor<FetchableURISpecTree>::VisitConstSequence<AAVisitor, ConditionalDepSpec>, private PrivateImplementationPattern<AAVisitor> { public: @@ -60,9 +57,9 @@ namespace paludis /// \name Visit functions ///{ - void visit_leaf(const FetchableURIDepSpec &); - - void visit_leaf(const URILabelsDepSpec &); + void visit(const FetchableURISpecTree::NodeType<FetchableURIDepSpec>::Type & node); + void visit(const FetchableURISpecTree::NodeType<URILabelsDepSpec>::Type & node); + void visit(const FetchableURISpecTree::BasicInnerNode & node); ///} diff --git a/paludis/repositories/e/aa_visitor_TEST.cc b/paludis/repositories/e/aa_visitor_TEST.cc index c21b549cb..b9b1c8755 100644 --- a/paludis/repositories/e/aa_visitor_TEST.cc +++ b/paludis/repositories/e/aa_visitor_TEST.cc @@ -20,7 +20,6 @@ #include "aa_visitor.hh" #include "dep_parser.hh" #include <paludis/util/join.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/repositories/e/eapi.hh> #include <paludis/environments/test/test_environment.hh> #include <paludis/repositories/fake/fake_repository.hh> @@ -47,7 +46,7 @@ namespace test_cases std::tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1")); AAVisitor p1; - parse_fetchable_uri("( a -> b c x? ( d e ) )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p1); + parse_fetchable_uri("( a -> b c x? ( d e ) )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(p1); TEST_CHECK_EQUAL(join(p1.begin(), p1.end(), " "), "b c d e"); } } test_aa_visitor; diff --git a/paludis/repositories/e/check_fetched_files_visitor.cc b/paludis/repositories/e/check_fetched_files_visitor.cc index b667dad32..2a78c952f 100644 --- a/paludis/repositories/e/check_fetched_files_visitor.cc +++ b/paludis/repositories/e/check_fetched_files_visitor.cc @@ -21,13 +21,13 @@ #include <paludis/repositories/e/source_uri_finder.hh> #include <paludis/repositories/e/e_repository_id.hh> #include <paludis/repositories/e/e_repository_params.hh> +#include <paludis/repositories/e/manifest2_reader.hh> #include <paludis/dep_spec.hh> #include <paludis/environment.hh> #include <paludis/package_id.hh> #include <paludis/repository.hh> #include <paludis/about.hh> #include <paludis/action.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/system.hh> #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/fs_entry.hh> @@ -41,9 +41,11 @@ #include <paludis/util/md5.hh> #include <paludis/util/make_named_values.hh> #include <paludis/util/output_deviator.hh> - -#include <paludis/repositories/e/manifest2_reader.hh> - +#include <paludis/util/sequence.hh> +#include <paludis/util/wrapped_forward_iterator.hh> +#include <paludis/util/indirect_iterator.hh> +#include <paludis/util/accept_visitor.hh> +#include <algorithm> #include <iostream> #include <fstream> #include <list> @@ -119,22 +121,18 @@ CheckFetchedFilesVisitor::~CheckFetchedFilesVisitor() } void -CheckFetchedFilesVisitor::visit_sequence(const ConditionalDepSpec & u, - FetchableURISpecTree::ConstSequenceIterator cur, - FetchableURISpecTree::ConstSequenceIterator end) +CheckFetchedFilesVisitor::visit(const FetchableURISpecTree::NodeType<ConditionalDepSpec>::Type & node) { Save<bool> save_in_nofetch(&_imp->in_nofetch, _imp->in_nofetch); - if ((_imp->check_unneeded) || (u.condition_met())) - std::for_each(cur, end, accept_visitor(*this)); + if ((_imp->check_unneeded) || (node.spec()->condition_met())) + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } void -CheckFetchedFilesVisitor::visit_sequence(const AllDepSpec &, - FetchableURISpecTree::ConstSequenceIterator cur, - FetchableURISpecTree::ConstSequenceIterator end) +CheckFetchedFilesVisitor::visit(const FetchableURISpecTree::NodeType<AllDepSpec>::Type & node) { Save<bool> save_in_nofetch(&_imp->in_nofetch, _imp->in_nofetch); - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } namespace @@ -177,10 +175,10 @@ namespace } void -CheckFetchedFilesVisitor::visit_leaf(const URILabelsDepSpec & l) +CheckFetchedFilesVisitor::visit(const FetchableURISpecTree::NodeType<URILabelsDepSpec>::Type & node) { InNoFetchVisitor v; - std::for_each(indirect_iterator(l.begin()), indirect_iterator(l.end()), accept_visitor(v)); + std::for_each(indirect_iterator(node.spec()->begin()), indirect_iterator(node.spec()->end()), accept_visitor(v)); _imp->in_nofetch = v.result; } @@ -354,70 +352,70 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile) } void -CheckFetchedFilesVisitor::visit_leaf(const FetchableURIDepSpec & u) +CheckFetchedFilesVisitor::visit(const FetchableURISpecTree::NodeType<FetchableURIDepSpec>::Type & node) { - Context context("When visiting URI dep spec '" + stringify(u.text()) + "':"); + Context context("When visiting URI dep spec '" + stringify(node.spec()->text()) + "':"); - if (_imp->done.end() != _imp->done.find(u.filename())) + if (_imp->done.end() != _imp->done.find(node.spec()->filename())) { Log::get_instance()->message("e.check_fetched_files.already_checked", ll_debug, lc_context) - << "Already checked '" << u.filename() << "'"; + << "Already checked '" << node.spec()->filename() << "'"; return; } - _imp->done.insert(u.filename()); + _imp->done.insert(node.spec()->filename()); - *_imp->out << "Checking '" << u.filename() << "'... " << std::flush; + *_imp->out << "Checking '" << node.spec()->filename() << "'... " << std::flush; - if (! (_imp->distdir / u.filename()).is_regular_file()) + if (! (_imp->distdir / node.spec()->filename()).is_regular_file()) { if (_imp->in_nofetch) { if (! _imp->exclude_unmirrorable) { Log::get_instance()->message("e.check_fetched_files.requires_manual", ll_debug, lc_context) - << "Manual fetch required for '" << u.filename() << "'"; + << "Manual fetch required for '" << node.spec()->filename() << "'"; *_imp->out << "requires manual fetch"; _imp->need_nofetch = true; _imp->failures->push_back(make_named_values<FetchActionFailure>( value_for<n::failed_automatic_fetching>(false), value_for<n::failed_integrity_checks>(""), value_for<n::requires_manual_fetching>(true), - value_for<n::target_file>(u.filename()) + value_for<n::target_file>(node.spec()->filename()) )); } } else { Log::get_instance()->message("e.check_fetched_files.does_not_exist", ll_debug, lc_context) - << "Automatic fetch failed for '" << u.filename() << "'"; + << "Automatic fetch failed for '" << node.spec()->filename() << "'"; *_imp->out << "does not exist"; _imp->failures->push_back(make_named_values<FetchActionFailure>( value_for<n::failed_automatic_fetching>(true), value_for<n::failed_integrity_checks>(""), value_for<n::requires_manual_fetching>(false), - value_for<n::target_file>(u.filename()) + value_for<n::target_file>(node.spec()->filename()) )); } } - else if (0 == (_imp->distdir / u.filename()).file_size()) + else if (0 == (_imp->distdir / node.spec()->filename()).file_size()) { - Log::get_instance()->message("e.check_fetched_files.empty", ll_debug, lc_context) << "Empty file for '" << u.filename() << "'"; + Log::get_instance()->message("e.check_fetched_files.empty", ll_debug, lc_context) << "Empty file for '" << node.spec()->filename() << "'"; *_imp->out << "empty file"; _imp->failures->push_back(make_named_values<FetchActionFailure>( value_for<n::failed_automatic_fetching>(false), value_for<n::failed_integrity_checks>("SIZE (empty file)"), value_for<n::requires_manual_fetching>(false), - value_for<n::target_file>(u.filename()) + value_for<n::target_file>(node.spec()->filename()) )); } - else if (! check_distfile_manifest(_imp->distdir / u.filename())) + else if (! check_distfile_manifest(_imp->distdir / node.spec()->filename())) { Log::get_instance()->message("e.check_fetched_files.failure", ll_debug, lc_context) - << "Manifest check failed for '" << u.filename() << "'"; + << "Manifest check failed for '" << node.spec()->filename() << "'"; } else { - Log::get_instance()->message("e.check_fetched_files.success", ll_debug, lc_context) << "Success for '" << u.filename() << "'"; + Log::get_instance()->message("e.check_fetched_files.success", ll_debug, lc_context) << "Success for '" << node.spec()->filename() << "'"; *_imp->out << "ok"; } diff --git a/paludis/repositories/e/check_fetched_files_visitor.hh b/paludis/repositories/e/check_fetched_files_visitor.hh index a27dc8fed..c2215aaf3 100644 --- a/paludis/repositories/e/check_fetched_files_visitor.hh +++ b/paludis/repositories/e/check_fetched_files_visitor.hh @@ -23,11 +23,10 @@ #include <paludis/repositories/e/e_repository_params.hh> #include <paludis/util/attributes.hh> #include <paludis/util/private_implementation_pattern.hh> -#include <paludis/util/visitor-fwd.hh> #include <paludis/util/fs_entry-fwd.hh> #include <paludis/util/output_deviator-fwd.hh> #include <paludis/dep_spec-fwd.hh> -#include <paludis/dep_tree.hh> +#include <paludis/spec_tree.hh> #include <paludis/package_id-fwd.hh> #include <paludis/environment-fwd.hh> #include <paludis/action-fwd.hh> @@ -38,8 +37,7 @@ namespace paludis namespace erepository { class PALUDIS_VISIBLE CheckFetchedFilesVisitor : - private PrivateImplementationPattern<CheckFetchedFilesVisitor>, - public ConstVisitor<FetchableURISpecTree> + private PrivateImplementationPattern<CheckFetchedFilesVisitor> { private: bool check_distfile_manifest(const FSEntry & distfile); @@ -58,17 +56,10 @@ namespace paludis ~CheckFetchedFilesVisitor(); - void visit_sequence(const ConditionalDepSpec &, - FetchableURISpecTree::ConstSequenceIterator, - FetchableURISpecTree::ConstSequenceIterator); - - void visit_sequence(const AllDepSpec &, - FetchableURISpecTree::ConstSequenceIterator, - FetchableURISpecTree::ConstSequenceIterator); - - void visit_leaf(const URILabelsDepSpec &); - - void visit_leaf(const FetchableURIDepSpec &); + void visit(const FetchableURISpecTree::NodeType<ConditionalDepSpec>::Type & node); + void visit(const FetchableURISpecTree::NodeType<AllDepSpec>::Type & node); + void visit(const FetchableURISpecTree::NodeType<URILabelsDepSpec>::Type & node); + void visit(const FetchableURISpecTree::NodeType<FetchableURIDepSpec>::Type & node); const std::tr1::shared_ptr<const Sequence<FetchActionFailure> > failures() const PALUDIS_ATTRIBUTE((warn_unused_result)); diff --git a/paludis/repositories/e/dep_parser.cc b/paludis/repositories/e/dep_parser.cc index f3fe0340d..46a46c6ce 100644 --- a/paludis/repositories/e/dep_parser.cc +++ b/paludis/repositories/e/dep_parser.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2008, 2009 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 @@ -22,7 +22,6 @@ #include <paludis/util/stringify.hh> #include <paludis/util/make_shared_ptr.hh> #include <paludis/util/options.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/tokeniser.hh> #include <paludis/util/make_named_values.hh> #include <paludis/util/map.hh> @@ -55,7 +54,6 @@ namespace paludis { namespace n { - struct add_handler; struct item; struct spec; } @@ -66,12 +64,9 @@ namespace template <typename T_> struct ParseStackTypes { - typedef std::tr1::function<void (const std::tr1::shared_ptr<const typename T_::ConstItem> &)> AddHandler; - struct Item { - NamedValue<n::add_handler, AddHandler> add_handler; - NamedValue<n::item, const std::tr1::shared_ptr<const typename T_::ConstItem> > item; + NamedValue<n::item, std::tr1::shared_ptr<typename T_::BasicInnerNode> > item; NamedValue<n::spec, std::tr1::shared_ptr<DepSpec> > spec; }; @@ -89,7 +84,7 @@ namespace { std::tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec( parse_elike_package_dep_spec(s, eapi.supported()->package_dep_spec_parse_options(), id))); - (*h.begin()).add_handler()(make_shared_ptr(new TreeLeaf<T_, PackageDepSpec>(spec))); + h.begin()->item()->append(spec); annotations_go_here(spec); } @@ -114,7 +109,7 @@ namespace std::tr1::shared_ptr<BlockDepSpec> spec(new BlockDepSpec( make_shared_ptr(new PackageDepSpec(parse_elike_package_dep_spec(s.substr(specstart), eapi.supported()->package_dep_spec_parse_options(), id))), s)); - (*h.begin()).add_handler()(make_shared_ptr(new TreeLeaf<T_, BlockDepSpec>(spec))); + h.begin()->item()->append(spec); annotations_go_here(spec); } else @@ -128,7 +123,7 @@ namespace const std::string & s) { std::tr1::shared_ptr<LicenseDepSpec> spec(new LicenseDepSpec(s)); - (*h.begin()).add_handler()(make_shared_ptr(new TreeLeaf<T_, LicenseDepSpec>(spec))); + h.begin()->item()->append(spec); annotations_go_here(spec); } @@ -139,7 +134,7 @@ namespace const std::string & s) { std::tr1::shared_ptr<PlainTextDepSpec> spec(new PlainTextDepSpec(s)); - (*h.begin()).add_handler()(make_shared_ptr(new TreeLeaf<T_, PlainTextDepSpec>(spec))); + h.begin()->item()->append(spec); annotations_go_here(spec); } @@ -150,7 +145,7 @@ namespace const std::string & s) { std::tr1::shared_ptr<SimpleURIDepSpec> spec(new SimpleURIDepSpec(s)); - (*h.begin()).add_handler()(make_shared_ptr(new TreeLeaf<T_, SimpleURIDepSpec>(spec))); + h.begin()->item()->append(spec); annotations_go_here(spec); } @@ -166,7 +161,7 @@ namespace if (t.empty() || eapi.supported()->dependency_spec_tree_parse_options()[dstpo_uri_supports_arrow]) { std::tr1::shared_ptr<FetchableURIDepSpec> spec(new FetchableURIDepSpec(t.empty() ? f : f + " -> " + t)); - (*h.begin()).add_handler()(make_shared_ptr(new TreeLeaf<T_, FetchableURIDepSpec>(spec))); + h.begin()->item()->append(spec); annotations_go_here(spec); } else @@ -209,7 +204,7 @@ namespace const EAPI & eapi) { std::tr1::shared_ptr<DependencyLabelsDepSpec> spec(parse_dependency_label(s, eapi)); - (*h.begin()).add_handler()(make_shared_ptr(new TreeLeaf<T_, DependencyLabelsDepSpec>(spec))); + h.begin()->item()->append(spec); annotations_go_here(spec); } @@ -221,7 +216,7 @@ namespace const EAPI & eapi) { std::tr1::shared_ptr<URILabelsDepSpec> spec(parse_uri_label(s, eapi)); - (*h.begin()).add_handler()(make_shared_ptr(new TreeLeaf<T_, URILabelsDepSpec>(spec))); + h.begin()->item()->append(spec); annotations_go_here(spec); } @@ -232,20 +227,16 @@ namespace const std::string & s) { std::tr1::shared_ptr<PlainTextLabelDepSpec> spec(parse_plain_text_label(s)); - (*h.begin()).add_handler()(make_shared_ptr(new TreeLeaf<T_, PlainTextLabelDepSpec>(spec))); + h.begin()->item()->append(spec); annotations_go_here(spec); } template <typename T_, typename A_> void any_all_handler(typename ParseStackTypes<T_>::Stack & stack) { - using namespace std::tr1::placeholders; std::tr1::shared_ptr<A_> spec(new A_); - std::tr1::shared_ptr<ConstTreeSequence<T_, A_> > item(new ConstTreeSequence<T_, A_>(spec)); - (*stack.begin()).add_handler()(item); stack.push_front(make_named_values<typename ParseStackTypes<T_>::Item>( - value_for<n::add_handler>(std::tr1::bind(&ConstTreeSequence<T_, A_>::add, item.get(), _1)), - value_for<n::item>(item), + value_for<n::item>(stack.begin()->item()->append(spec)), value_for<n::spec>(spec) )); } @@ -257,14 +248,10 @@ namespace const Environment * const env, const std::tr1::shared_ptr<const PackageID> & id) { - using namespace std::tr1::placeholders; std::tr1::shared_ptr<ConditionalDepSpec> spec(new ConditionalDepSpec(parse_elike_conditional_dep_spec(u, env, id, id->supports_action(SupportsActionTest<InstalledAction>())))); - std::tr1::shared_ptr<ConstTreeSequence<T_, ConditionalDepSpec> > item(new ConstTreeSequence<T_, ConditionalDepSpec>(spec)); - (*stack.begin()).add_handler()(item); stack.push_front(make_named_values<typename ParseStackTypes<T_>::Item>( - value_for<n::add_handler>(std::tr1::bind(&ConstTreeSequence<T_, ConditionalDepSpec>::add, item.get(), _1)), - value_for<n::item>(item), + value_for<n::item>(stack.begin()->item()->append(spec)), value_for<n::spec>(spec) )); } @@ -326,7 +313,7 @@ namespace } } -std::tr1::shared_ptr<DependencySpecTree::ConstItem> +std::tr1::shared_ptr<DependencySpecTree> paludis::erepository::parse_depend(const std::string & s, const Environment * const env, const std::tr1::shared_ptr<const PackageID> & id, const EAPI & eapi) { @@ -335,11 +322,9 @@ paludis::erepository::parse_depend(const std::string & s, ParseStackTypes<DependencySpecTree>::Stack stack; std::tr1::shared_ptr<AllDepSpec> spec(new AllDepSpec); std::tr1::shared_ptr<DepSpec> thing_to_annotate(spec); - std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > top( - new ConstTreeSequence<DependencySpecTree, AllDepSpec>(spec)); + std::tr1::shared_ptr<DependencySpecTree> top(make_shared_ptr(new DependencySpecTree(spec))); stack.push_front(make_named_values<ParseStackTypes<DependencySpecTree>::Item>( - value_for<n::add_handler>(std::tr1::bind(&ConstTreeSequence<DependencySpecTree, AllDepSpec>::add, top.get(), _1)), - value_for<n::item>(top), + value_for<n::item>(top->root()), value_for<n::spec>(spec) )); @@ -366,10 +351,10 @@ paludis::erepository::parse_depend(const std::string & s, parse_elike_dependencies(s, callbacks); - return (*stack.begin()).item(); + return top; } -std::tr1::shared_ptr<ProvideSpecTree::ConstItem> +std::tr1::shared_ptr<ProvideSpecTree> paludis::erepository::parse_provide(const std::string & s, const Environment * const env, const std::tr1::shared_ptr<const PackageID> & id, const EAPI & eapi) { @@ -378,11 +363,9 @@ paludis::erepository::parse_provide(const std::string & s, ParseStackTypes<ProvideSpecTree>::Stack stack; std::tr1::shared_ptr<AllDepSpec> spec(new AllDepSpec); std::tr1::shared_ptr<DepSpec> thing_to_annotate(spec); - std::tr1::shared_ptr<ConstTreeSequence<ProvideSpecTree, AllDepSpec> > top( - new ConstTreeSequence<ProvideSpecTree, AllDepSpec>(spec)); + std::tr1::shared_ptr<ProvideSpecTree> top(make_shared_ptr(new ProvideSpecTree(spec))); stack.push_front(make_named_values<ParseStackTypes<ProvideSpecTree>::Item>( - value_for<n::add_handler>(std::tr1::bind(&ConstTreeSequence<ProvideSpecTree, AllDepSpec>::add, top.get(), _1)), - value_for<n::item>(top), + value_for<n::item>(top->root()), value_for<n::spec>(spec) )); @@ -407,10 +390,10 @@ paludis::erepository::parse_provide(const std::string & s, parse_elike_dependencies(s, callbacks); - return (*stack.begin()).item(); + return top; } -std::tr1::shared_ptr<FetchableURISpecTree::ConstItem> +std::tr1::shared_ptr<FetchableURISpecTree> paludis::erepository::parse_fetchable_uri(const std::string & s, const Environment * const env, const std::tr1::shared_ptr<const PackageID> & id, const EAPI & eapi) { @@ -419,13 +402,11 @@ paludis::erepository::parse_fetchable_uri(const std::string & s, ParseStackTypes<FetchableURISpecTree>::Stack stack; std::tr1::shared_ptr<AllDepSpec> spec(new AllDepSpec); std::tr1::shared_ptr<DepSpec> thing_to_annotate(spec); - std::tr1::shared_ptr<ConstTreeSequence<FetchableURISpecTree, AllDepSpec> > top( - new ConstTreeSequence<FetchableURISpecTree, AllDepSpec>(spec)); + std::tr1::shared_ptr<FetchableURISpecTree> top(make_shared_ptr(new FetchableURISpecTree(spec))); stack.push_front(make_named_values<ParseStackTypes<FetchableURISpecTree>::Item>( - value_for<n::add_handler>(std::tr1::bind(&ConstTreeSequence<FetchableURISpecTree, AllDepSpec>::add, top.get(), _1)), - value_for<n::item>(top), + value_for<n::item>(top->root()), value_for<n::spec>(spec) - )); + )); ELikeDepParserCallbacks callbacks( make_named_values<ELikeDepParserCallbacks>( @@ -452,10 +433,10 @@ paludis::erepository::parse_fetchable_uri(const std::string & s, parse_elike_dependencies(s, callbacks); - return (*stack.begin()).item(); + return top; } -std::tr1::shared_ptr<SimpleURISpecTree::ConstItem> +std::tr1::shared_ptr<SimpleURISpecTree> paludis::erepository::parse_simple_uri(const std::string & s, const Environment * const env, const std::tr1::shared_ptr<const PackageID> & id, const EAPI &) { @@ -464,11 +445,9 @@ paludis::erepository::parse_simple_uri(const std::string & s, ParseStackTypes<SimpleURISpecTree>::Stack stack; std::tr1::shared_ptr<AllDepSpec> spec(new AllDepSpec); std::tr1::shared_ptr<DepSpec> thing_to_annotate(spec); - std::tr1::shared_ptr<ConstTreeSequence<SimpleURISpecTree, AllDepSpec> > top( - new ConstTreeSequence<SimpleURISpecTree, AllDepSpec>(spec)); + std::tr1::shared_ptr<SimpleURISpecTree> top(make_shared_ptr(new SimpleURISpecTree(spec))); stack.push_front(make_named_values<ParseStackTypes<SimpleURISpecTree>::Item>( - value_for<n::add_handler>(std::tr1::bind(&ConstTreeSequence<SimpleURISpecTree, AllDepSpec>::add, top.get(), _1)), - value_for<n::item>(top), + value_for<n::item>(top->root()), value_for<n::spec>(spec) )); @@ -493,10 +472,10 @@ paludis::erepository::parse_simple_uri(const std::string & s, parse_elike_dependencies(s, callbacks); - return (*stack.begin()).item(); + return top; } -std::tr1::shared_ptr<LicenseSpecTree::ConstItem> +std::tr1::shared_ptr<LicenseSpecTree> paludis::erepository::parse_license(const std::string & s, const Environment * const env, const std::tr1::shared_ptr<const PackageID> & id, const EAPI & eapi) { @@ -505,11 +484,9 @@ paludis::erepository::parse_license(const std::string & s, ParseStackTypes<LicenseSpecTree>::Stack stack; std::tr1::shared_ptr<AllDepSpec> spec(new AllDepSpec); std::tr1::shared_ptr<DepSpec> thing_to_annotate(spec); - std::tr1::shared_ptr<ConstTreeSequence<LicenseSpecTree, AllDepSpec> > top( - new ConstTreeSequence<LicenseSpecTree, AllDepSpec>(spec)); + std::tr1::shared_ptr<LicenseSpecTree> top(make_shared_ptr(new LicenseSpecTree(spec))); stack.push_front(make_named_values<ParseStackTypes<LicenseSpecTree>::Item>( - value_for<n::add_handler>(std::tr1::bind(&ConstTreeSequence<LicenseSpecTree, AllDepSpec>::add, top.get(), _1)), - value_for<n::item>(top), + value_for<n::item>(top->root()), value_for<n::spec>(spec) )); @@ -534,10 +511,10 @@ paludis::erepository::parse_license(const std::string & s, parse_elike_dependencies(s, callbacks); - return (*stack.begin()).item(); + return top; } -std::tr1::shared_ptr<PlainTextSpecTree::ConstItem> +std::tr1::shared_ptr<PlainTextSpecTree> paludis::erepository::parse_plain_text(const std::string & s, const Environment * const env, const std::tr1::shared_ptr<const PackageID> & id, const EAPI &) { @@ -546,11 +523,9 @@ paludis::erepository::parse_plain_text(const std::string & s, ParseStackTypes<PlainTextSpecTree>::Stack stack; std::tr1::shared_ptr<AllDepSpec> spec(new AllDepSpec); std::tr1::shared_ptr<DepSpec> thing_to_annotate(spec); - std::tr1::shared_ptr<ConstTreeSequence<PlainTextSpecTree, AllDepSpec> > top( - new ConstTreeSequence<PlainTextSpecTree, AllDepSpec>(spec)); + std::tr1::shared_ptr<PlainTextSpecTree> top(make_shared_ptr(new PlainTextSpecTree(spec))); stack.push_front(make_named_values<ParseStackTypes<PlainTextSpecTree>::Item>( - value_for<n::add_handler>(std::tr1::bind(&ConstTreeSequence<PlainTextSpecTree, AllDepSpec>::add, top.get(), _1)), - value_for<n::item>(top), + value_for<n::item>(top->root()), value_for<n::spec>(spec) )); @@ -575,10 +550,10 @@ paludis::erepository::parse_plain_text(const std::string & s, parse_elike_dependencies(s, callbacks); - return (*stack.begin()).item(); + return top; } -std::tr1::shared_ptr<PlainTextSpecTree::ConstItem> +std::tr1::shared_ptr<PlainTextSpecTree> paludis::erepository::parse_myoptions(const std::string & s, const Environment * const env, const std::tr1::shared_ptr<const PackageID> & id, const EAPI &) { @@ -587,11 +562,9 @@ paludis::erepository::parse_myoptions(const std::string & s, ParseStackTypes<PlainTextSpecTree>::Stack stack; std::tr1::shared_ptr<AllDepSpec> spec(new AllDepSpec); std::tr1::shared_ptr<DepSpec> thing_to_annotate(spec); - std::tr1::shared_ptr<ConstTreeSequence<PlainTextSpecTree, AllDepSpec> > top( - new ConstTreeSequence<PlainTextSpecTree, AllDepSpec>(spec)); + std::tr1::shared_ptr<PlainTextSpecTree> top(make_shared_ptr(new PlainTextSpecTree(spec))); stack.push_front(make_named_values<ParseStackTypes<PlainTextSpecTree>::Item>( - value_for<n::add_handler>(std::tr1::bind(&ConstTreeSequence<PlainTextSpecTree, AllDepSpec>::add, top.get(), _1)), - value_for<n::item>(top), + value_for<n::item>(top->root()), value_for<n::spec>(spec) )); @@ -618,7 +591,7 @@ paludis::erepository::parse_myoptions(const std::string & s, parse_elike_dependencies(s, callbacks); - return (*stack.begin()).item(); + return top; } std::tr1::shared_ptr<URILabelsDepSpec> diff --git a/paludis/repositories/e/dep_parser.hh b/paludis/repositories/e/dep_parser.hh index d00f95536..3cc09afc1 100644 --- a/paludis/repositories/e/dep_parser.hh +++ b/paludis/repositories/e/dep_parser.hh @@ -21,7 +21,7 @@ #define PALUDIS_GUARD_PALUDIS_E_DEP_PARSER_HH 1 #include <paludis/repositories/e/dep_parser-fwd.hh> -#include <paludis/dep_tree.hh> +#include <paludis/spec_tree.hh> #include <paludis/package_id-fwd.hh> #include <paludis/repositories/e/eapi-fwd.hh> #include <paludis/util/exception.hh> @@ -53,7 +53,7 @@ namespace paludis /** * Parse a dependency heirarchy. */ - std::tr1::shared_ptr<DependencySpecTree::ConstItem> parse_depend(const std::string & s, + std::tr1::shared_ptr<DependencySpecTree> parse_depend(const std::string & s, const Environment * const, const std::tr1::shared_ptr<const PackageID> &, const EAPI &) PALUDIS_VISIBLE; /** @@ -64,37 +64,37 @@ namespace paludis /** * Parse a provide heirarchy. */ - std::tr1::shared_ptr<ProvideSpecTree::ConstItem> parse_provide(const std::string & s, + std::tr1::shared_ptr<ProvideSpecTree> parse_provide(const std::string & s, const Environment * const, const std::tr1::shared_ptr<const PackageID> &, const EAPI &) PALUDIS_VISIBLE; /** * Parse a restrict or plain text heirarchy. */ - std::tr1::shared_ptr<PlainTextSpecTree::ConstItem> parse_plain_text(const std::string & s, + std::tr1::shared_ptr<PlainTextSpecTree> parse_plain_text(const std::string & s, const Environment * const, const std::tr1::shared_ptr<const PackageID> &, const EAPI &) PALUDIS_VISIBLE; /** * Parse a myoptions heirarchy. */ - std::tr1::shared_ptr<PlainTextSpecTree::ConstItem> parse_myoptions(const std::string & s, + std::tr1::shared_ptr<PlainTextSpecTree> parse_myoptions(const std::string & s, const Environment * const, const std::tr1::shared_ptr<const PackageID> &, const EAPI &) PALUDIS_VISIBLE; /** * Parse a fetchable uri heirarchy. */ - std::tr1::shared_ptr<FetchableURISpecTree::ConstItem> parse_fetchable_uri(const std::string & s, + std::tr1::shared_ptr<FetchableURISpecTree> parse_fetchable_uri(const std::string & s, const Environment * const, const std::tr1::shared_ptr<const PackageID> &, const EAPI &) PALUDIS_VISIBLE; /** * Parse a simple uri heirarchy. */ - std::tr1::shared_ptr<SimpleURISpecTree::ConstItem> parse_simple_uri(const std::string & s, + std::tr1::shared_ptr<SimpleURISpecTree> parse_simple_uri(const std::string & s, const Environment * const, const std::tr1::shared_ptr<const PackageID> &, const EAPI &) PALUDIS_VISIBLE; /** * Parse a license heirarchy. */ - std::tr1::shared_ptr<LicenseSpecTree::ConstItem> parse_license(const std::string & s, + std::tr1::shared_ptr<LicenseSpecTree> parse_license(const std::string & s, const Environment * const, const std::tr1::shared_ptr<const PackageID> &, const EAPI &) PALUDIS_VISIBLE; /** diff --git a/paludis/repositories/e/dep_parser_TEST.cc b/paludis/repositories/e/dep_parser_TEST.cc index c5c91f929..a90e2eeea 100644 --- a/paludis/repositories/e/dep_parser_TEST.cc +++ b/paludis/repositories/e/dep_parser_TEST.cc @@ -24,7 +24,6 @@ #include <paludis/repositories/fake/fake_repository.hh> #include <paludis/repositories/fake/fake_package_id.hh> #include <paludis/package_database.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/stringify_formatter.hh> #include <sstream> #include <test/test_framework.hh> @@ -59,7 +58,7 @@ namespace test_cases StringifyFormatter ff; DepSpecPrettyPrinter d(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); parse_depend("", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d); TEST_CHECK_EQUAL(stringify(d), ""); } } test_dep_spec_parser_empty; @@ -82,7 +81,7 @@ namespace test_cases StringifyFormatter ff; DepSpecPrettyPrinter d(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); parse_depend(" \n \t", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d); TEST_CHECK_EQUAL(stringify(d), ""); } } test_dep_spec_parser_blank; @@ -105,7 +104,7 @@ namespace test_cases StringifyFormatter ff; DepSpecPrettyPrinter d(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); parse_depend("app-editors/vim", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d); TEST_CHECK_EQUAL(stringify(d), "app-editors/vim"); } } test_dep_spec_parser_package; @@ -128,17 +127,17 @@ namespace test_cases DepSpecPrettyPrinter d1(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); parse_depend(">=app-editors/vim-6.4_alpha", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d1); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d1); TEST_CHECK_EQUAL(stringify(d1), ">=app-editors/vim-6.4_alpha"); DepSpecPrettyPrinter d2(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); parse_depend("=app-editors/vim-6.4_alpha-r1", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d2); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d2); TEST_CHECK_EQUAL(stringify(d2), "=app-editors/vim-6.4_alpha-r1"); DepSpecPrettyPrinter d3(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); parse_depend(">=app-editors/vim-6.4_alpha:one", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d3); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d3); TEST_CHECK_EQUAL(stringify(d3), ">=app-editors/vim-6.4_alpha:one"); } } test_dep_spec_parser_decorated_package; @@ -161,7 +160,7 @@ namespace test_cases DepSpecPrettyPrinter d(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); parse_depend("app-editors/vim app-misc/hilite \nsys-apps/findutils", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d); TEST_CHECK_EQUAL(stringify(d), "app-editors/vim app-misc/hilite sys-apps/findutils"); } } test_dep_spec_parser_packages; @@ -180,7 +179,7 @@ namespace test_cases DepSpecPrettyPrinter d(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); parse_depend("|| ( one/one two/two )", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d); TEST_CHECK_EQUAL(stringify(d), "|| ( one/one two/two )"); } } test_dep_spec_parser_any; @@ -199,15 +198,15 @@ namespace test_cases DepSpecPrettyPrinter d(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); parse_depend("|| ( one/one foo? ( two/two ) )", - &env, id, *EAPIData::get_instance()->eapi_from_string("0"))->accept(d); + &env, id, *EAPIData::get_instance()->eapi_from_string("0"))->root()->accept(d); TEST_CHECK_EQUAL(stringify(d), "|| ( one/one foo? ( two/two ) )"); TEST_CHECK_THROWS(parse_depend("|| ( one/one foo? ( two/two ) )", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d), Exception); DepSpecPrettyPrinter e(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); parse_depend("|| ( one/one ( foo? ( two/two ) ) )", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(e); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(e); TEST_CHECK_EQUAL(stringify(e), "|| ( one/one ( foo? ( two/two ) ) )"); } } test_dep_spec_parser_any_use; @@ -230,7 +229,7 @@ namespace test_cases DepSpecPrettyPrinter d(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); parse_depend(" ( one/one two/two ) ", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d); TEST_CHECK_EQUAL(stringify(d), "one/one two/two"); } } test_dep_spec_parser_all; @@ -252,7 +251,7 @@ namespace test_cases std::tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1")); DepSpecPrettyPrinter d(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); - parse_depend("foo? ( one/one )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d); + parse_depend("foo? ( one/one )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d); TEST_CHECK_EQUAL(stringify(d), "foo? ( one/one )"); } } test_dep_spec_parser_use; @@ -274,7 +273,7 @@ namespace test_cases std::tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1")); DepSpecPrettyPrinter d(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); - parse_depend("!foo? ( one/one )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d); + parse_depend("!foo? ( one/one )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d); TEST_CHECK_EQUAL(stringify(d), "!foo? ( one/one )"); } } test_dep_spec_parser_inv_use; @@ -292,15 +291,15 @@ namespace test_cases std::tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1")); DepSpecPrettyPrinter d(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, true, false); - parse_fetchable_uri("a\n->\tb", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d); + parse_fetchable_uri("a\n->\tb", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d); TEST_CHECK_EQUAL(stringify(d), "a -> b\n"); DepSpecPrettyPrinter e(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, true, false); - parse_fetchable_uri("a-> b", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(e); + parse_fetchable_uri("a-> b", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(e); TEST_CHECK_EQUAL(stringify(e), "a->\nb\n"); TEST_CHECK_THROWS(parse_fetchable_uri("a -> b", - &env, id, *EAPIData::get_instance()->eapi_from_string("0"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("0"))->root()->accept(d), Exception); } } test_dep_spec_parser_uri; @@ -322,15 +321,15 @@ namespace test_cases DepSpecPrettyPrinter d(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); TEST_CHECK_THROWS(parse_depend("!foo? ( one/one", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d), Exception); TEST_CHECK_THROWS(parse_depend("!foo? ( one/one ) )", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d), Exception); TEST_CHECK_THROWS(parse_depend("( ( ( ) )", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d), Exception); TEST_CHECK_THROWS(parse_depend("( ( ( ) ) ) )", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d), Exception); TEST_CHECK_THROWS(parse_depend(")", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d), Exception); } } test_dep_spec_parser_bad_nesting; @@ -352,38 +351,38 @@ namespace test_cases DepSpecPrettyPrinter d(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); TEST_CHECK_THROWS(parse_depend("||", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d), Exception); TEST_CHECK_THROWS(parse_depend("|| ", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d), Exception); TEST_CHECK_THROWS(parse_depend("foo?", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d), Exception); TEST_CHECK_THROWS(parse_depend("!? ( )", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d), Exception); TEST_CHECK_THROWS(parse_depend("!foo? ||", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d), Exception); TEST_CHECK_THROWS(parse_depend("(((", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d), Exception); TEST_CHECK_THROWS(parse_depend(")", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d), Exception); TEST_CHECK_THROWS(parse_depend("(foo/bar)", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d), Exception); TEST_CHECK_THROWS(parse_license("a -> b", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d), Exception); TEST_CHECK_THROWS(parse_fetchable_uri("( -> )", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d), Exception); TEST_CHECK_THROWS(parse_fetchable_uri("( -> )", - &env, id, *EAPIData::get_instance()->eapi_from_string("0"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("0"))->root()->accept(d), Exception); TEST_CHECK_THROWS(parse_fetchable_uri("foo? -> bar", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d), Exception); TEST_CHECK_THROWS(parse_fetchable_uri("a ->", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d), Exception); TEST_CHECK_THROWS(parse_fetchable_uri("a -> ( )", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d), Exception); TEST_CHECK_THROWS(parse_fetchable_uri("a -> )", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d), Exception); TEST_CHECK_THROWS(parse_fetchable_uri("a -> || ( )", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), Exception); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d), Exception); } } test_dep_spec_parser_bad_values; @@ -404,10 +403,10 @@ namespace test_cases DepSpecPrettyPrinter d(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); parse_depend("build: one/one", - &env, id, *EAPIData::get_instance()->eapi_from_string("exheres-0"))->accept(d); + &env, id, *EAPIData::get_instance()->eapi_from_string("exheres-0"))->root()->accept(d); TEST_CHECK_EQUAL(stringify(d), "build: one/one"); TEST_CHECK_THROWS(parse_depend("build: one/one", - &env, id, *EAPIData::get_instance()->eapi_from_string("0"))->accept(d), EDepParseError); + &env, id, *EAPIData::get_instance()->eapi_from_string("0"))->root()->accept(d), EDepParseError); } } test_dep_spec_parser_labels; @@ -425,10 +424,10 @@ namespace test_cases DepSpecPrettyPrinter d(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); parse_fetchable_uri("http://foo/bar manual: two", - &env, id, *EAPIData::get_instance()->eapi_from_string("kdebuild-1"))->accept(d); + &env, id, *EAPIData::get_instance()->eapi_from_string("kdebuild-1"))->root()->accept(d); TEST_CHECK_EQUAL(stringify(d), "http://foo/bar manual: two"); TEST_CHECK_THROWS(parse_fetchable_uri("http://foo/bar monkey: two", - &env, id, *EAPIData::get_instance()->eapi_from_string("kdebuild-1"))->accept(d), EDepParseError); + &env, id, *EAPIData::get_instance()->eapi_from_string("kdebuild-1"))->root()->accept(d), EDepParseError); } } test_dep_spec_parser_kdebuild_uri_labels; @@ -446,12 +445,12 @@ namespace test_cases StringifyFormatter ff; DepSpecPrettyPrinter d(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); parse_depend("cat/first [[ foo = bar bar = baz ]] cat/second cat/third [[ moo = oink ]]", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(d); TEST_CHECK_EQUAL(stringify(d), "cat/first [[ bar = [ baz ] foo = [ bar ] ]] cat/second cat/third [[ moo = [ oink ] ]]"); DepSpecPrettyPrinter e(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); parse_depend("bar? ( foo? ( cat/first [[ for = first ]] ) [[ for = foo ]] baz? ( ) [[ for = baz ]] ) [[ for = bar ]]", - &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(e); + &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(e); TEST_CHECK_EQUAL(stringify(e), "bar? ( foo? ( cat/first [[ for = [ first ] ]] ) " "[[ for = [ foo ] ]] baz? ( ) [[ for = [ baz ] ]] ) [[ for = [ bar ] ]]"); } diff --git a/paludis/repositories/e/dep_spec_pretty_printer.cc b/paludis/repositories/e/dep_spec_pretty_printer.cc index 04b94a3e9..c68dc7135 100644 --- a/paludis/repositories/e/dep_spec_pretty_printer.cc +++ b/paludis/repositories/e/dep_spec_pretty_printer.cc @@ -22,7 +22,6 @@ #include <paludis/metadata_key.hh> #include <paludis/formatter.hh> #include <paludis/util/save.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/simple_visitor_cast.hh> #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/stringify.hh> @@ -110,8 +109,7 @@ paludis::erepository::operator<< (std::ostream & s, const DepSpecPrettyPrinter & namespace { - struct IsLabelVisitor : - ConstVisitor<GenericSpecTree> + struct IsLabelVisitor { bool result; @@ -120,63 +118,63 @@ namespace { } - void visit_leaf(const PlainTextDepSpec &) + void visit(const GenericSpecTree::NodeType<PlainTextDepSpec>::Type &) { } - void visit_leaf(const SimpleURIDepSpec &) + void visit(const GenericSpecTree::NodeType<SimpleURIDepSpec>::Type &) { } - void visit_leaf(const FetchableURIDepSpec &) + void visit(const GenericSpecTree::NodeType<FetchableURIDepSpec>::Type &) { } - void visit_leaf(const LicenseDepSpec &) + void visit(const GenericSpecTree::NodeType<LicenseDepSpec>::Type &) { } - void visit_leaf(const PackageDepSpec &) + void visit(const GenericSpecTree::NodeType<PackageDepSpec>::Type &) { } - void visit_leaf(const BlockDepSpec &) + void visit(const GenericSpecTree::NodeType<BlockDepSpec>::Type &) { } - void visit_leaf(const PlainTextLabelDepSpec &) + void visit(const GenericSpecTree::NodeType<PlainTextLabelDepSpec>::Type &) { result = true; } - void visit_leaf(const URILabelsDepSpec &) + void visit(const GenericSpecTree::NodeType<URILabelsDepSpec>::Type &) { result = true; } - void visit_leaf(const DependencyLabelsDepSpec &) + void visit(const GenericSpecTree::NodeType<DependencyLabelsDepSpec>::Type &) { result = true; } - void visit_leaf(const NamedSetDepSpec &) + void visit(const GenericSpecTree::NodeType<NamedSetDepSpec>::Type &) { } - void visit_sequence(const AllDepSpec &, GenericSpecTree::ConstSequenceIterator, GenericSpecTree::ConstSequenceIterator) + void visit(const GenericSpecTree::NodeType<AllDepSpec>::Type &) { } - void visit_sequence(const AnyDepSpec &, GenericSpecTree::ConstSequenceIterator, GenericSpecTree::ConstSequenceIterator) + void visit(const GenericSpecTree::NodeType<AnyDepSpec>::Type &) { } - void visit_sequence(const ConditionalDepSpec &, GenericSpecTree::ConstSequenceIterator, GenericSpecTree::ConstSequenceIterator) + void visit(const GenericSpecTree::NodeType<ConditionalDepSpec>::Type &) { } }; - bool is_label(const ConstAcceptInterface<GenericSpecTree> & i) + bool is_label(const GenericSpecTree::BasicNode & i) { IsLabelVisitor v; i.accept(v); @@ -185,12 +183,12 @@ namespace } void -DepSpecPrettyPrinter::visit_sequence(const AllDepSpec & a, - GenericSpecTree::ConstSequenceIterator cur, - GenericSpecTree::ConstSequenceIterator end) +DepSpecPrettyPrinter::visit(const GenericSpecTree::NodeType<AllDepSpec>::Type & node) { - bool need_parens(_imp->all_needs_parens || a.annotations_key() || - (! _imp->outer_block && end != std::find_if(cur, end, is_label))); + bool need_parens(_imp->all_needs_parens || node.spec()->annotations_key() || + (! _imp->outer_block && indirect_iterator(node.end()) != std::find_if(indirect_iterator(node.begin()), + indirect_iterator(node.end()), + is_label))); Save<bool> old_outer(&_imp->outer_block, false); Save<bool> old_needs_parens(&_imp->all_needs_parens, false); @@ -210,7 +208,7 @@ DepSpecPrettyPrinter::visit_sequence(const AllDepSpec & a, { Save<unsigned> old_indent(&_imp->indent, need_parens ? _imp->indent +1 : _imp->indent); Save<bool> extra_label_indent(&_imp->extra_label_indent, need_parens ? false : _imp->extra_label_indent); - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } if (need_parens) @@ -221,7 +219,7 @@ DepSpecPrettyPrinter::visit_sequence(const AllDepSpec & a, _imp->s << " "; _imp->s << ")"; - do_annotations(a); + do_annotations(*node.spec()); if (_imp->use_newlines) _imp->s << _imp->formatter.newline(); @@ -231,9 +229,7 @@ DepSpecPrettyPrinter::visit_sequence(const AllDepSpec & a, } void -DepSpecPrettyPrinter::visit_sequence(const AnyDepSpec & a, - GenericSpecTree::ConstSequenceIterator cur, - GenericSpecTree::ConstSequenceIterator end) +DepSpecPrettyPrinter::visit(const GenericSpecTree::NodeType<AnyDepSpec>::Type & node) { Save<bool> old_outer(&_imp->outer_block, false); Save<bool> old_needs_parens(&_imp->all_needs_parens, true); @@ -251,7 +247,7 @@ DepSpecPrettyPrinter::visit_sequence(const AnyDepSpec & a, { Save<unsigned> old_indent(&_imp->indent, _imp->indent + 1); Save<bool> extra_label_indent(&_imp->extra_label_indent, false); - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } if (_imp->use_newlines) @@ -260,7 +256,7 @@ DepSpecPrettyPrinter::visit_sequence(const AnyDepSpec & a, _imp->s << " "; _imp->s << ")"; - do_annotations(a); + do_annotations(*node.spec()); if (_imp->use_newlines) _imp->s << _imp->formatter.newline(); @@ -269,9 +265,7 @@ DepSpecPrettyPrinter::visit_sequence(const AnyDepSpec & a, } void -DepSpecPrettyPrinter::visit_sequence(const ConditionalDepSpec & a, - GenericSpecTree::ConstSequenceIterator cur, - GenericSpecTree::ConstSequenceIterator end) +DepSpecPrettyPrinter::visit(const GenericSpecTree::NodeType<ConditionalDepSpec>::Type & node) { Save<bool> old_outer(&_imp->outer_block, false); Save<bool> old_needs_parens(&_imp->all_needs_parens, false); @@ -282,11 +276,11 @@ DepSpecPrettyPrinter::visit_sequence(const ConditionalDepSpec & a, _imp->s << " "; if (! _imp->check_conditions) - _imp->s << _imp->formatter.format(a, format::Plain()) << " ("; - else if (a.condition_met()) - _imp->s << _imp->formatter.format(a, format::Enabled()) << " ("; + _imp->s << _imp->formatter.format(*node.spec(), format::Plain()) << " ("; + else if (node.spec()->condition_met()) + _imp->s << _imp->formatter.format(*node.spec(), format::Enabled()) << " ("; else - _imp->s << _imp->formatter.format(a, format::Disabled()) << " ("; + _imp->s << _imp->formatter.format(*node.spec(), format::Disabled()) << " ("; if (_imp->use_newlines) _imp->s << _imp->formatter.newline(); @@ -296,7 +290,7 @@ DepSpecPrettyPrinter::visit_sequence(const ConditionalDepSpec & a, { Save<unsigned> old_indent(&_imp->indent, _imp->indent + 1); Save<bool> extra_label_indent(&_imp->extra_label_indent, false); - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } if (_imp->use_newlines) @@ -305,7 +299,7 @@ DepSpecPrettyPrinter::visit_sequence(const ConditionalDepSpec & a, _imp->s << " "; _imp->s << ")"; - do_annotations(a); + do_annotations(*node.spec()); if (_imp->use_newlines) _imp->s << _imp->formatter.newline(); @@ -314,7 +308,7 @@ DepSpecPrettyPrinter::visit_sequence(const ConditionalDepSpec & a, } void -DepSpecPrettyPrinter::visit_leaf(const PackageDepSpec & p) +DepSpecPrettyPrinter::visit(const GenericSpecTree::NodeType<PackageDepSpec>::Type & node) { if (_imp->use_newlines) _imp->s << _imp->formatter.indent(_imp->indent); @@ -323,19 +317,19 @@ DepSpecPrettyPrinter::visit_leaf(const PackageDepSpec & p) if (_imp->env && _imp->check_conditions) { - if (! (*_imp->env)[selection::SomeArbitraryVersion(generator::Matches(p, MatchPackageOptions()) | + if (! (*_imp->env)[selection::SomeArbitraryVersion(generator::Matches(*node.spec(), MatchPackageOptions()) | filter::InstalledAtRoot(_imp->env->root()))]->empty()) - _imp->s << _imp->formatter.format(p, format::Installed()); - else if (! (*_imp->env)[selection::SomeArbitraryVersion(generator::Matches(p, MatchPackageOptions()) | + _imp->s << _imp->formatter.format(*node.spec(), format::Installed()); + else if (! (*_imp->env)[selection::SomeArbitraryVersion(generator::Matches(*node.spec(), MatchPackageOptions()) | filter::SupportsAction<InstallAction>() | filter::NotMasked())]->empty()) - _imp->s << _imp->formatter.format(p, format::Installable()); + _imp->s << _imp->formatter.format(*node.spec(), format::Installable()); else - _imp->s << _imp->formatter.format(p, format::Plain()); + _imp->s << _imp->formatter.format(*node.spec(), format::Plain()); } else - _imp->s << _imp->formatter.format(p, format::Plain()); + _imp->s << _imp->formatter.format(*node.spec(), format::Plain()); - do_annotations(p); + do_annotations(*node.spec()); if (_imp->use_newlines) _imp->s << _imp->formatter.newline(); @@ -344,16 +338,16 @@ DepSpecPrettyPrinter::visit_leaf(const PackageDepSpec & p) } void -DepSpecPrettyPrinter::visit_leaf(const PlainTextDepSpec & p) +DepSpecPrettyPrinter::visit(const GenericSpecTree::NodeType<PlainTextDepSpec>::Type & node) { if (_imp->use_newlines) _imp->s << _imp->formatter.indent(_imp->indent); else if (_imp->need_space) _imp->s << " "; - _imp->s << _imp->formatter.format(p, format::Plain()); + _imp->s << _imp->formatter.format(*node.spec(), format::Plain()); - do_annotations(p); + do_annotations(*node.spec()); if (_imp->use_newlines) _imp->s << _imp->formatter.newline(); @@ -362,16 +356,16 @@ DepSpecPrettyPrinter::visit_leaf(const PlainTextDepSpec & p) } void -DepSpecPrettyPrinter::visit_leaf(const NamedSetDepSpec & p) +DepSpecPrettyPrinter::visit(const GenericSpecTree::NodeType<NamedSetDepSpec>::Type & node) { if (_imp->use_newlines) _imp->s << _imp->formatter.indent(_imp->indent); else if (_imp->need_space) _imp->s << " "; - _imp->s << _imp->formatter.format(p, format::Plain()); + _imp->s << _imp->formatter.format(*node.spec(), format::Plain()); - do_annotations(p); + do_annotations(*node.spec()); if (_imp->use_newlines) _imp->s << _imp->formatter.newline(); @@ -380,7 +374,7 @@ DepSpecPrettyPrinter::visit_leaf(const NamedSetDepSpec & p) } void -DepSpecPrettyPrinter::visit_leaf(const LicenseDepSpec & p) +DepSpecPrettyPrinter::visit(const GenericSpecTree::NodeType<LicenseDepSpec>::Type & node) { if (_imp->use_newlines) _imp->s << _imp->formatter.indent(_imp->indent); @@ -389,15 +383,15 @@ DepSpecPrettyPrinter::visit_leaf(const LicenseDepSpec & p) if (_imp->env && _imp->id && _imp->check_conditions) { - if (_imp->env->accept_license(p.text(), *_imp->id)) - _imp->s << _imp->formatter.format(p, format::Accepted()); + if (_imp->env->accept_license(node.spec()->text(), *_imp->id)) + _imp->s << _imp->formatter.format(*node.spec(), format::Accepted()); else - _imp->s << _imp->formatter.format(p, format::Unaccepted()); + _imp->s << _imp->formatter.format(*node.spec(), format::Unaccepted()); } else - _imp->s << _imp->formatter.format(p, format::Plain()); + _imp->s << _imp->formatter.format(*node.spec(), format::Plain()); - do_annotations(p); + do_annotations(*node.spec()); if (_imp->use_newlines) _imp->s << _imp->formatter.newline(); @@ -406,16 +400,16 @@ DepSpecPrettyPrinter::visit_leaf(const LicenseDepSpec & p) } void -DepSpecPrettyPrinter::visit_leaf(const FetchableURIDepSpec & p) +DepSpecPrettyPrinter::visit(const GenericSpecTree::NodeType<FetchableURIDepSpec>::Type & node) { if (_imp->use_newlines) _imp->s << _imp->formatter.indent(_imp->indent); else if (_imp->need_space) _imp->s << " "; - _imp->s << _imp->formatter.format(p, format::Plain()); + _imp->s << _imp->formatter.format(*node.spec(), format::Plain()); - do_annotations(p); + do_annotations(*node.spec()); if (_imp->use_newlines) _imp->s << _imp->formatter.newline(); @@ -424,16 +418,16 @@ DepSpecPrettyPrinter::visit_leaf(const FetchableURIDepSpec & p) } void -DepSpecPrettyPrinter::visit_leaf(const SimpleURIDepSpec & p) +DepSpecPrettyPrinter::visit(const GenericSpecTree::NodeType<SimpleURIDepSpec>::Type & node) { if (_imp->use_newlines) _imp->s << _imp->formatter.indent(_imp->indent); else if (_imp->need_space) _imp->s << " "; - _imp->s << _imp->formatter.format(p, format::Plain()); + _imp->s << _imp->formatter.format(*node.spec(), format::Plain()); - do_annotations(p); + do_annotations(*node.spec()); if (_imp->use_newlines) _imp->s << _imp->formatter.newline(); @@ -442,16 +436,16 @@ DepSpecPrettyPrinter::visit_leaf(const SimpleURIDepSpec & p) } void -DepSpecPrettyPrinter::visit_leaf(const BlockDepSpec & b) +DepSpecPrettyPrinter::visit(const GenericSpecTree::NodeType<BlockDepSpec>::Type & node) { if (_imp->use_newlines) _imp->s << _imp->formatter.indent(_imp->indent); else if (_imp->need_space) _imp->s << " "; - _imp->s << _imp->formatter.format(b, format::Plain()); + _imp->s << _imp->formatter.format(*node.spec(), format::Plain()); - do_annotations(b); + do_annotations(*node.spec()); if (_imp->use_newlines) _imp->s << _imp->formatter.newline(); @@ -460,7 +454,7 @@ DepSpecPrettyPrinter::visit_leaf(const BlockDepSpec & b) } void -DepSpecPrettyPrinter::visit_leaf(const URILabelsDepSpec & l) +DepSpecPrettyPrinter::visit(const GenericSpecTree::NodeType<URILabelsDepSpec>::Type & node) { if (_imp->extra_label_indent) { @@ -473,9 +467,9 @@ DepSpecPrettyPrinter::visit_leaf(const URILabelsDepSpec & l) else if (_imp->need_space) _imp->s << " "; - _imp->s << _imp->formatter.format(l, format::Plain()); + _imp->s << _imp->formatter.format(*node.spec(), format::Plain()); - do_annotations(l); + do_annotations(*node.spec()); if (_imp->use_newlines) _imp->s << _imp->formatter.newline(); @@ -490,7 +484,7 @@ DepSpecPrettyPrinter::visit_leaf(const URILabelsDepSpec & l) } void -DepSpecPrettyPrinter::visit_leaf(const PlainTextLabelDepSpec & l) +DepSpecPrettyPrinter::visit(const GenericSpecTree::NodeType<PlainTextLabelDepSpec>::Type & node) { if (_imp->extra_label_indent) { @@ -503,9 +497,9 @@ DepSpecPrettyPrinter::visit_leaf(const PlainTextLabelDepSpec & l) else if (_imp->need_space) _imp->s << " "; - _imp->s << _imp->formatter.format(l, format::Plain()); + _imp->s << _imp->formatter.format(*node.spec(), format::Plain()); - do_annotations(l); + do_annotations(*node.spec()); if (_imp->use_newlines) _imp->s << _imp->formatter.newline(); @@ -520,7 +514,7 @@ DepSpecPrettyPrinter::visit_leaf(const PlainTextLabelDepSpec & l) } void -DepSpecPrettyPrinter::visit_leaf(const DependencyLabelsDepSpec & l) +DepSpecPrettyPrinter::visit(const GenericSpecTree::NodeType<DependencyLabelsDepSpec>::Type & node) { if (_imp->extra_label_indent) { @@ -533,9 +527,9 @@ DepSpecPrettyPrinter::visit_leaf(const DependencyLabelsDepSpec & l) else if (_imp->need_space) _imp->s << " "; - _imp->s << _imp->formatter.format(l, format::Plain()); + _imp->s << _imp->formatter.format(*node.spec(), format::Plain()); - do_annotations(l); + do_annotations(*node.spec()); if (_imp->use_newlines) _imp->s << _imp->formatter.newline(); diff --git a/paludis/repositories/e/dep_spec_pretty_printer.hh b/paludis/repositories/e/dep_spec_pretty_printer.hh index 949dd9abe..6a60c5670 100644 --- a/paludis/repositories/e/dep_spec_pretty_printer.hh +++ b/paludis/repositories/e/dep_spec_pretty_printer.hh @@ -22,7 +22,7 @@ #include <iosfwd> #include <paludis/dep_spec.hh> -#include <paludis/dep_tree.hh> +#include <paludis/spec_tree.hh> #include <paludis/metadata_key-fwd.hh> #include <paludis/environment-fwd.hh> #include <paludis/package_id-fwd.hh> @@ -43,7 +43,6 @@ namespace paludis * \ingroup grperepository */ class PALUDIS_VISIBLE DepSpecPrettyPrinter : - public ConstVisitor<GenericSpecTree>, private PrivateImplementationPattern<DepSpecPrettyPrinter> { friend std::ostream & operator<< (std::ostream &, const DepSpecPrettyPrinter &); @@ -92,37 +91,19 @@ namespace paludis /// \name Visit functions ///{ - void visit_sequence(const AllDepSpec &, - GenericSpecTree::ConstSequenceIterator, - GenericSpecTree::ConstSequenceIterator); - - void visit_sequence(const AnyDepSpec &, - GenericSpecTree::ConstSequenceIterator, - GenericSpecTree::ConstSequenceIterator); - - void visit_sequence(const ConditionalDepSpec &, - GenericSpecTree::ConstSequenceIterator, - GenericSpecTree::ConstSequenceIterator); - - void visit_leaf(const PackageDepSpec &); - - void visit_leaf(const PlainTextDepSpec &); - - void visit_leaf(const BlockDepSpec &); - - void visit_leaf(const FetchableURIDepSpec &); - - void visit_leaf(const SimpleURIDepSpec &); - - void visit_leaf(const LicenseDepSpec &); - - void visit_leaf(const URILabelsDepSpec &); - - void visit_leaf(const DependencyLabelsDepSpec &); - - void visit_leaf(const NamedSetDepSpec &); - - void visit_leaf(const PlainTextLabelDepSpec &); + void visit(const GenericSpecTree::NodeType<AllDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<AnyDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<ConditionalDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<PackageDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<BlockDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<DependencyLabelsDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<NamedSetDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<SimpleURIDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<FetchableURIDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<URILabelsDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<PlainTextDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<PlainTextLabelDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<LicenseDepSpec>::Type & node); ///} }; diff --git a/paludis/repositories/e/dep_spec_pretty_printer_TEST.cc b/paludis/repositories/e/dep_spec_pretty_printer_TEST.cc index 479d7e03b..37091ef92 100644 --- a/paludis/repositories/e/dep_spec_pretty_printer_TEST.cc +++ b/paludis/repositories/e/dep_spec_pretty_printer_TEST.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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,7 +21,6 @@ #include <paludis/repositories/e/dep_parser.hh> #include <paludis/repositories/e/eapi.hh> #include <paludis/stringify_formatter.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/environments/test/test_environment.hh> #include <paludis/repositories/fake/fake_repository.hh> #include <paludis/repositories/fake/fake_package_id.hh> @@ -48,28 +47,28 @@ namespace test_cases std::tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1")); DepSpecPrettyPrinter p1(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); - parse_depend("foo/bar bar/baz", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p1); + parse_depend("foo/bar bar/baz", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(p1); TEST_CHECK_STRINGIFY_EQUAL(p1, "foo/bar bar/baz"); DepSpecPrettyPrinter p2(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); - parse_depend("foo/bar moo? ( bar/baz )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p2); + parse_depend("foo/bar moo? ( bar/baz )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(p2); TEST_CHECK_STRINGIFY_EQUAL(p2, "foo/bar moo? ( bar/baz )"); DepSpecPrettyPrinter p3(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); - parse_depend("|| ( a/b ( c/d e/f ) )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p3); + parse_depend("|| ( a/b ( c/d e/f ) )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(p3); TEST_CHECK_STRINGIFY_EQUAL(p3, "|| ( a/b ( c/d e/f ) )"); DepSpecPrettyPrinter p4(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); - parse_license("( ( ( ) a ) b )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p4); + parse_license("( ( ( ) a ) b )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(p4); TEST_CHECK_STRINGIFY_EQUAL(p4, "a b"); DepSpecPrettyPrinter p5(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); - parse_fetchable_uri("( a -> b c x? ( d e ) )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p5); + parse_fetchable_uri("( a -> b c x? ( d e ) )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(p5); TEST_CHECK_STRINGIFY_EQUAL(p5, "a -> b c x? ( d e )"); DepSpecPrettyPrinter p6(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); parse_fetchable_uri("a manual: b x? ( c mirrors-first: d manual: e ) f", - &env, id, *EAPIData::get_instance()->eapi_from_string("exheres-0"))->accept(p6); + &env, id, *EAPIData::get_instance()->eapi_from_string("exheres-0"))->root()->accept(p6); TEST_CHECK_STRINGIFY_EQUAL(p6, "a manual: b x? ( c mirrors-first: d manual: e ) f"); } } test_pretty_printer_no_indent; @@ -87,25 +86,25 @@ namespace test_cases std::tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1")); DepSpecPrettyPrinter p1(0, std::tr1::shared_ptr<const PackageID>(), ff, 1, true, false); - parse_depend("foo/bar bar/baz", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p1); + parse_depend("foo/bar bar/baz", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(p1); TEST_CHECK_STRINGIFY_EQUAL(p1, " foo/bar\n bar/baz\n"); DepSpecPrettyPrinter p2(0, std::tr1::shared_ptr<const PackageID>(), ff, 1, true, false); - parse_depend("foo/bar moo? ( bar/baz )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p2); + parse_depend("foo/bar moo? ( bar/baz )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(p2); TEST_CHECK_STRINGIFY_EQUAL(p2, " foo/bar\n moo? (\n bar/baz\n )\n"); DepSpecPrettyPrinter p3(0, std::tr1::shared_ptr<const PackageID>(), ff, 1, true, false); - parse_depend("|| ( a/b ( c/d e/f ) )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p3); + parse_depend("|| ( a/b ( c/d e/f ) )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(p3); TEST_CHECK_STRINGIFY_EQUAL(p3, " || (\n a/b\n (\n c/d\n" " e/f\n )\n )\n"); DepSpecPrettyPrinter p4(0, std::tr1::shared_ptr<const PackageID>(), ff, 1, true, false); - parse_license("( ( ( ) a ) b )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p4); + parse_license("( ( ( ) a ) b )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->root()->accept(p4); TEST_CHECK_STRINGIFY_EQUAL(p4, " a\n b\n"); DepSpecPrettyPrinter p5(0, std::tr1::shared_ptr<const PackageID>(), ff, 1, true, false); parse_fetchable_uri("a manual: b x? ( c mirrors-first: d manual: e ) f", - &env, id, *EAPIData::get_instance()->eapi_from_string("exheres-0"))->accept(p5); + &env, id, *EAPIData::get_instance()->eapi_from_string("exheres-0"))->root()->accept(p5); TEST_CHECK_STRINGIFY_EQUAL(p5, " a\n manual:\n b\n x? (\n c\n" " mirrors-first:\n d\n manual:\n e\n )\n f\n"); } diff --git a/paludis/repositories/e/dependencies_rewriter.cc b/paludis/repositories/e/dependencies_rewriter.cc index 8565878ad..65c6e823c 100644 --- a/paludis/repositories/e/dependencies_rewriter.cc +++ b/paludis/repositories/e/dependencies_rewriter.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008 Ciaran McCreesh + * Copyright (c) 2008, 2009 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 @@ -19,13 +19,14 @@ #include <paludis/repositories/e/dependencies_rewriter.hh> #include <paludis/util/private_implementation_pattern-impl.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/stringify.hh> #include <paludis/util/make_shared_ptr.hh> #include <paludis/util/save.hh> #include <paludis/util/indirect_iterator-impl.hh> #include <paludis/util/simple_visitor_cast.hh> #include <paludis/util/set.hh> +#include <paludis/util/wrapped_forward_iterator.hh> +#include <paludis/util/sequence.hh> #include <paludis/metadata_key.hh> #include <list> @@ -107,37 +108,35 @@ DependenciesRewriter::pdepend() const } void -DependenciesRewriter::visit_leaf(const PackageDepSpec & spec) +DependenciesRewriter::visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node) { - _add_where_necessary(stringify(spec), spec); + _add_where_necessary(stringify(*node.spec()), *node.spec()); } void -DependenciesRewriter::visit_leaf(const NamedSetDepSpec & spec) +DependenciesRewriter::visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & node) { - _add_where_necessary(stringify(spec), spec); + _add_where_necessary(stringify(*node.spec()), *node.spec()); } void -DependenciesRewriter::visit_leaf(const BlockDepSpec & spec) +DependenciesRewriter::visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type & node) { - _add_where_necessary(stringify(spec), spec); + _add_where_necessary(stringify(*node.spec()), *node.spec()); } void -DependenciesRewriter::visit_leaf(const DependencyLabelsDepSpec & spec) +DependenciesRewriter::visit(const DependencySpecTree::NodeType<DependencyLabelsDepSpec>::Type & node) { - _imp->depend.append(" " + stringify(spec) + get_annotations(spec)); - _imp->rdepend.append(" " + stringify(spec) + get_annotations(spec)); - _imp->pdepend.append(" " + stringify(spec) + get_annotations(spec)); + _imp->depend.append(" " + stringify(*node.spec()) + get_annotations(*node.spec())); + _imp->rdepend.append(" " + stringify(*node.spec()) + get_annotations(*node.spec())); + _imp->pdepend.append(" " + stringify(*node.spec()) + get_annotations(*node.spec())); - _imp->labels.begin()->reset(new ActiveDependencyLabels(**_imp->labels.begin(), spec)); + _imp->labels.begin()->reset(new ActiveDependencyLabels(**_imp->labels.begin(), *node.spec())); } void -DependenciesRewriter::visit_sequence(const AllDepSpec & spec, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) +DependenciesRewriter::visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node) { _imp->labels.push_front(make_shared_ptr(new ActiveDependencyLabels(**_imp->labels.begin()))); RunOnDestruction restore_labels(std::tr1::bind(std::tr1::mem_fn(&LabelsStack::pop_front), &_imp->labels)); @@ -147,17 +146,15 @@ DependenciesRewriter::visit_sequence(const AllDepSpec & spec, _imp->rdepend.clear(); _imp->pdepend.clear(); - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); - _imp->depend = d + " ( " + _imp->depend + " )" + get_annotations(spec); - _imp->rdepend = r + " ( " + _imp->rdepend + " )" + get_annotations(spec); - _imp->pdepend = p + " ( " + _imp->pdepend + " )" + get_annotations(spec); + _imp->depend = d + " ( " + _imp->depend + " )" + get_annotations(*node.spec()); + _imp->rdepend = r + " ( " + _imp->rdepend + " )" + get_annotations(*node.spec()); + _imp->pdepend = p + " ( " + _imp->pdepend + " )" + get_annotations(*node.spec()); } void -DependenciesRewriter::visit_sequence(const AnyDepSpec & spec, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) +DependenciesRewriter::visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node) { _imp->labels.push_front(make_shared_ptr(new ActiveDependencyLabels(**_imp->labels.begin()))); RunOnDestruction restore_labels(std::tr1::bind(std::tr1::mem_fn(&LabelsStack::pop_front), &_imp->labels)); @@ -167,17 +164,15 @@ DependenciesRewriter::visit_sequence(const AnyDepSpec & spec, _imp->rdepend.clear(); _imp->pdepend.clear(); - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); - _imp->depend = d + " || ( " + _imp->depend + " )" + get_annotations(spec); - _imp->rdepend = r + " || ( " + _imp->rdepend + " )" + get_annotations(spec); - _imp->pdepend = p + " || ( " + _imp->pdepend + " )" + get_annotations(spec); + _imp->depend = d + " || ( " + _imp->depend + " )" + get_annotations(*node.spec()); + _imp->rdepend = r + " || ( " + _imp->rdepend + " )" + get_annotations(*node.spec()); + _imp->pdepend = p + " || ( " + _imp->pdepend + " )" + get_annotations(*node.spec()); } void -DependenciesRewriter::visit_sequence(const ConditionalDepSpec & spec, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) +DependenciesRewriter::visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node) { _imp->labels.push_front(make_shared_ptr(new ActiveDependencyLabels(**_imp->labels.begin()))); RunOnDestruction restore_labels(std::tr1::bind(std::tr1::mem_fn(&LabelsStack::pop_front), &_imp->labels)); @@ -187,11 +182,11 @@ DependenciesRewriter::visit_sequence(const ConditionalDepSpec & spec, _imp->rdepend.clear(); _imp->pdepend.clear(); - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); - _imp->depend = d + " " + stringify(spec) + " ( " + _imp->depend + " )" + get_annotations(spec); - _imp->rdepend = r + " " + stringify(spec) + " ( " + _imp->rdepend + " )" + get_annotations(spec); - _imp->pdepend = p + " " + stringify(spec) + " ( " + _imp->pdepend + " )" + get_annotations(spec); + _imp->depend = d + " " + stringify(*node.spec()) + " ( " + _imp->depend + " )" + get_annotations(*node.spec()); + _imp->rdepend = r + " " + stringify(*node.spec()) + " ( " + _imp->rdepend + " )" + get_annotations(*node.spec()); + _imp->pdepend = p + " " + stringify(*node.spec()) + " ( " + _imp->pdepend + " )" + get_annotations(*node.spec()); } namespace diff --git a/paludis/repositories/e/dependencies_rewriter.hh b/paludis/repositories/e/dependencies_rewriter.hh index 4b91a86ba..9fb20bd3d 100644 --- a/paludis/repositories/e/dependencies_rewriter.hh +++ b/paludis/repositories/e/dependencies_rewriter.hh @@ -21,7 +21,7 @@ #define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_DEPENDENCIES_REWRITER_HH 1 #include <paludis/dep_spec.hh> -#include <paludis/dep_tree.hh> +#include <paludis/spec_tree.hh> #include <paludis/util/private_implementation_pattern.hh> namespace paludis @@ -29,7 +29,6 @@ namespace paludis namespace erepository { class DependenciesRewriter : - public ConstVisitor<DependencySpecTree>, private PrivateImplementationPattern<DependenciesRewriter> { public: @@ -38,22 +37,13 @@ namespace paludis void _add_where_necessary(const std::string &, const DepSpec &); - void visit_leaf(const PackageDepSpec &); - void visit_leaf(const NamedSetDepSpec &); - void visit_leaf(const BlockDepSpec &); - void visit_leaf(const DependencyLabelsDepSpec &); - - void visit_sequence(const AnyDepSpec &, - DependencySpecTree::ConstSequenceIterator, - DependencySpecTree::ConstSequenceIterator); - - void visit_sequence(const AllDepSpec &, - DependencySpecTree::ConstSequenceIterator, - DependencySpecTree::ConstSequenceIterator); - - void visit_sequence(const ConditionalDepSpec &, - DependencySpecTree::ConstSequenceIterator, - DependencySpecTree::ConstSequenceIterator); + void visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<DependencyLabelsDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node); const std::string depend() const; const std::string rdepend() const; diff --git a/paludis/repositories/e/e_choices_key.cc b/paludis/repositories/e/e_choices_key.cc index 4500529b2..9fba4dd64 100644 --- a/paludis/repositories/e/e_choices_key.cc +++ b/paludis/repositories/e/e_choices_key.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008 Ciaran McCreesh + * Copyright (c) 2008, 2009 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 @@ -31,18 +31,19 @@ #include <paludis/util/log.hh> #include <paludis/util/mutex.hh> #include <paludis/util/join.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/simple_visitor_cast.hh> #include <paludis/util/make_shared_ptr.hh> #include <paludis/util/tribool.hh> #include <paludis/util/member_iterator-impl.hh> #include <paludis/util/map.hh> +#include <paludis/util/sequence.hh> #include <paludis/environment.hh> #include <paludis/stringify_formatter-impl.hh> #include <paludis/choice.hh> #include <paludis/elike_choices.hh> +#include <list> #include <algorithm> #include <set> #include <map> @@ -113,8 +114,7 @@ namespace } }; - struct MyOptionsFinder : - ConstVisitor<PlainTextSpecTree> + struct MyOptionsFinder { typedef std::map<std::string, std::string> Annotations; typedef std::map<UnprefixedChoiceName, Annotations> Values; @@ -128,26 +128,26 @@ namespace current_prefix_stack.push_front(ChoicePrefixName("")); } - void visit_leaf(const PlainTextDepSpec & s) + void visit(const PlainTextSpecTree::NodeType<PlainTextDepSpec>::Type & node) { - if (s.text().empty()) + if (node.spec()->text().empty()) return; - Context context("When handling item '" + stringify(s) + "':"); + Context context("When handling item '" + stringify(*node.spec()) + "':"); Prefixes::iterator p(prefixes.find(*current_prefix_stack.begin())); if (p == prefixes.end()) p = prefixes.insert(std::make_pair(*current_prefix_stack.begin(), Values())).first; - UnprefixedChoiceName n(parse_myoption(s.text()).first); + UnprefixedChoiceName n(parse_myoption(node.spec()->text()).first); Values::iterator v(p->second.find(n)); if (v == p->second.end()) v = p->second.insert(std::make_pair(n, Annotations())).first; - if (s.annotations_key()) + if (node.spec()->annotations_key()) { - for (MetadataSectionKey::MetadataConstIterator m(s.annotations_key()->begin_metadata()), - m_end(s.annotations_key()->end_metadata()) ; + for (MetadataSectionKey::MetadataConstIterator m(node.spec()->annotations_key()->begin_metadata()), + m_end(node.spec()->annotations_key()->end_metadata()) ; m != m_end ; ++m) { const MetadataValueKey<std::string> * mm(simple_visitor_cast<const MetadataValueKey<std::string> >(**m)); @@ -164,26 +164,22 @@ namespace } } - void visit_leaf(const PlainTextLabelDepSpec & s) + void visit(const PlainTextSpecTree::NodeType<PlainTextLabelDepSpec>::Type & node) { - *current_prefix_stack.begin() = ChoicePrefixName(s.label()); + *current_prefix_stack.begin() = ChoicePrefixName(node.spec()->label()); } - void visit_sequence(const ConditionalDepSpec &, - PlainTextSpecTree::ConstSequenceIterator cur, - PlainTextSpecTree::ConstSequenceIterator end) + void visit(const PlainTextSpecTree::NodeType<ConditionalDepSpec>::Type & node) { current_prefix_stack.push_front(*current_prefix_stack.begin()); - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); current_prefix_stack.pop_front(); } - void visit_sequence(const AllDepSpec &, - PlainTextSpecTree::ConstSequenceIterator cur, - PlainTextSpecTree::ConstSequenceIterator end) + void visit(const PlainTextSpecTree::NodeType<AllDepSpec>::Type & node) { current_prefix_stack.push_front(*current_prefix_stack.begin()); - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); current_prefix_stack.pop_front(); } }; @@ -275,7 +271,7 @@ EChoicesKey::value() const /* yay. myoptions is easy. */ MyOptionsFinder myoptions; - _imp->id->raw_myoptions_key()->value()->accept(myoptions); + _imp->id->raw_myoptions_key()->value()->root()->accept(myoptions); if (_imp->id->raw_use_expand_key()) for (Set<std::string>::ConstIterator u(_imp->id->raw_use_expand_key()->value()->begin()), diff --git a/paludis/repositories/e/e_installed_repository.cc b/paludis/repositories/e/e_installed_repository.cc index 6be3b44d9..2deb15564 100644 --- a/paludis/repositories/e/e_installed_repository.cc +++ b/paludis/repositories/e/e_installed_repository.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh + * Copyright (c) 2006, 2007, 2008, 2009 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 @@ -24,7 +24,6 @@ #include <paludis/repositories/e/eapi_phase.hh> #include <paludis/repositories/e/ebuild.hh> #include <paludis/repositories/e/e_repository.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/simple_visitor_cast.hh> #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/mutex.hh> @@ -36,6 +35,8 @@ #include <paludis/util/system.hh> #include <paludis/util/map.hh> #include <paludis/util/make_named_values.hh> +#include <paludis/util/sequence.hh> +#include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/action.hh> #include <paludis/package_id.hh> #include <paludis/metadata_key.hh> @@ -157,7 +158,7 @@ EInstalledRepository::perform_hook(const Hook & hook) const return make_named_values<HookResult>(value_for<n::max_exit_status>(0), value_for<n::output>("")); } -std::tr1::shared_ptr<SetSpecTree::ConstItem> +const std::tr1::shared_ptr<const SetSpecTree> EInstalledRepository::package_set(const SetName & s) const { using namespace std::tr1::placeholders; @@ -167,8 +168,7 @@ EInstalledRepository::package_set(const SetName & s) const if ("everything" == s.data()) { - std::tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > result(new ConstTreeSequence<SetSpecTree, AllDepSpec>( - std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); + std::tr1::shared_ptr<SetSpecTree> result(new SetSpecTree(make_shared_ptr(new AllDepSpec))); std::tr1::shared_ptr<GeneralSetDepTag> tag(new GeneralSetDepTag(SetName("everything"), stringify(name()))); std::tr1::shared_ptr<const CategoryNamePartSet> cats(category_names()); @@ -181,14 +181,14 @@ EInstalledRepository::package_set(const SetName & s) const { std::tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(make_package_dep_spec().package(*e))); spec->set_tag(tag); - result->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>(spec))); + result->root()->append(spec); } } return result; } else - return std::tr1::shared_ptr<SetSpecTree::ConstItem>(); + return make_null_shared_ptr(); } std::tr1::shared_ptr<const SetNameSet> diff --git a/paludis/repositories/e/e_installed_repository.hh b/paludis/repositories/e/e_installed_repository.hh index 13bf67b1a..ab9c2390e 100644 --- a/paludis/repositories/e/e_installed_repository.hh +++ b/paludis/repositories/e/e_installed_repository.hh @@ -59,7 +59,7 @@ namespace paludis public: /* RepositorySetsInterface */ - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> package_set(const SetName & id) const + virtual const std::tr1::shared_ptr<const SetSpecTree> package_set(const SetName & id) const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual std::tr1::shared_ptr<const SetNameSet> sets_list() const diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc index 748787507..0940e4e9b 100644 --- a/paludis/repositories/e/e_installed_repository_id.cc +++ b/paludis/repositories/e/e_installed_repository_id.cc @@ -34,13 +34,13 @@ #include <paludis/environment.hh> #include <paludis/action.hh> #include <paludis/util/fs_entry.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/stringify.hh> #include <paludis/util/log.hh> #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/strip.hh> #include <paludis/util/mutex.hh> #include <paludis/util/make_shared_ptr.hh> +#include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/literal_metadata_key.hh> #include <iterator> #include <fstream> @@ -273,7 +273,7 @@ EInstalledRepositoryID::need_keys_added() const if ((_imp->dir / vars->dependencies().name()).exists()) { DependenciesRewriter rewriter; - parse_depend(file_contents(_imp->dir / vars->dependencies().name()), _imp->environment, shared_from_this(), *eapi())->accept(rewriter); + parse_depend(file_contents(_imp->dir / vars->dependencies().name()), _imp->environment, shared_from_this(), *eapi())->root()->accept(rewriter); _imp->build_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->dependencies().name() + ".DEPEND", vars->dependencies().description() + " (build)", rewriter.depend(), _imp->build_dependencies_labels, mkt_dependencies)); diff --git a/paludis/repositories/e/e_key.cc b/paludis/repositories/e/e_key.cc index 18055a3e1..6fd9877d0 100644 --- a/paludis/repositories/e/e_key.cc +++ b/paludis/repositories/e/e_key.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -35,12 +35,11 @@ #include <paludis/util/log.hh> #include <paludis/util/mutex.hh> #include <paludis/util/join.hh> -#include <paludis/util/visitor-impl.hh> -#include <paludis/util/visitor_cast.hh> #include <paludis/util/create_iterator-impl.hh> #include <paludis/util/make_shared_ptr.hh> #include <paludis/util/tribool.hh> #include <paludis/util/member_iterator-impl.hh> +#include <paludis/util/sequence.hh> #include <paludis/contents.hh> #include <paludis/repository.hh> @@ -88,7 +87,7 @@ namespace paludis const std::tr1::shared_ptr<const ERepositoryID> id; const std::string string_value; mutable Mutex value_mutex; - mutable std::tr1::shared_ptr<const DependencySpecTree::ConstItem> value; + mutable std::tr1::shared_ptr<const DependencySpecTree> value; mutable std::tr1::function<void () throw ()> value_used; const std::tr1::shared_ptr<const DependencyLabelSequence> labels; @@ -120,7 +119,7 @@ EDependenciesKey::~EDependenciesKey() { } -const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> +const std::tr1::shared_ptr<const DependencySpecTree> EDependenciesKey::value() const { Lock l(_imp->value_mutex); @@ -150,7 +149,7 @@ EDependenciesKey::pretty_print(const DependencySpecTree::ItemFormatter & f) cons { StringifyFormatter ff(f); DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, true, true); - value()->accept(p); + value()->root()->accept(p); return stringify(p); } @@ -159,7 +158,7 @@ EDependenciesKey::pretty_print_flat(const DependencySpecTree::ItemFormatter & f) { StringifyFormatter ff(f); DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, false, true); - value()->accept(p); + value()->root()->accept(p); return stringify(p); } @@ -172,7 +171,7 @@ namespace paludis const std::tr1::shared_ptr<const ERepositoryID> id; const std::string string_value; mutable Mutex value_mutex; - mutable std::tr1::shared_ptr<const LicenseSpecTree::ConstItem> value; + mutable std::tr1::shared_ptr<const LicenseSpecTree> value; mutable std::tr1::function<void () throw ()> value_used; Implementation(const Environment * const e, @@ -199,7 +198,7 @@ ELicenseKey::~ELicenseKey() { } -const std::tr1::shared_ptr<const LicenseSpecTree::ConstItem> +const std::tr1::shared_ptr<const LicenseSpecTree> ELicenseKey::value() const { Lock l(_imp->value_mutex); @@ -223,7 +222,7 @@ ELicenseKey::pretty_print(const LicenseSpecTree::ItemFormatter & f) const { StringifyFormatter ff(f); DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, true, true); - value()->accept(p); + value()->root()->accept(p); return stringify(p); } @@ -232,7 +231,7 @@ ELicenseKey::pretty_print_flat(const LicenseSpecTree::ItemFormatter & f) const { StringifyFormatter ff(f); DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, false, true); - value()->accept(p); + value()->root()->accept(p); return stringify(p); } @@ -245,7 +244,7 @@ namespace paludis const std::tr1::shared_ptr<const ERepositoryID> id; const std::string string_value; mutable Mutex value_mutex; - mutable std::tr1::shared_ptr<const FetchableURISpecTree::ConstItem> value; + mutable std::tr1::shared_ptr<const FetchableURISpecTree> value; mutable std::tr1::shared_ptr<const URILabel> initial_label; Implementation(const Environment * const e, const std::tr1::shared_ptr<const ERepositoryID> & i, const std::string & v) : @@ -270,7 +269,7 @@ EFetchableURIKey::~EFetchableURIKey() { } -const std::tr1::shared_ptr<const FetchableURISpecTree::ConstItem> +const std::tr1::shared_ptr<const FetchableURISpecTree> EFetchableURIKey::value() const { Lock l(_imp->value_mutex); @@ -288,7 +287,7 @@ EFetchableURIKey::pretty_print(const FetchableURISpecTree::ItemFormatter & f) co { StringifyFormatter ff(f); DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, true, true); - value()->accept(p); + value()->root()->accept(p); return stringify(p); } @@ -297,7 +296,7 @@ EFetchableURIKey::pretty_print_flat(const FetchableURISpecTree::ItemFormatter & { StringifyFormatter ff(f); DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, false, true); - value()->accept(p); + value()->root()->accept(p); return stringify(p); } @@ -310,7 +309,7 @@ EFetchableURIKey::initial_label() const { DepSpecFlattener<PlainTextSpecTree, PlainTextDepSpec> f(_imp->env); if (_imp->id->restrict_key()) - _imp->id->restrict_key()->value()->accept(f); + _imp->id->restrict_key()->value()->root()->accept(f); for (DepSpecFlattener<PlainTextSpecTree, PlainTextDepSpec>::ConstIterator i(f.begin()), i_end(f.end()) ; i != i_end ; ++i) { @@ -346,7 +345,7 @@ namespace paludis const std::tr1::shared_ptr<const ERepositoryID> id; const std::string string_value; mutable Mutex value_mutex; - mutable std::tr1::shared_ptr<const SimpleURISpecTree::ConstItem> value; + mutable std::tr1::shared_ptr<const SimpleURISpecTree> value; Implementation(const Environment * const e, const std::tr1::shared_ptr<const ERepositoryID> & i, const std::string & v) : env(e), @@ -370,7 +369,7 @@ ESimpleURIKey::~ESimpleURIKey() { } -const std::tr1::shared_ptr<const SimpleURISpecTree::ConstItem> +const std::tr1::shared_ptr<const SimpleURISpecTree> ESimpleURIKey::value() const { Lock l(_imp->value_mutex); @@ -388,7 +387,7 @@ ESimpleURIKey::pretty_print(const SimpleURISpecTree::ItemFormatter & f) const { StringifyFormatter ff(f); DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, true, true); - value()->accept(p); + value()->root()->accept(p); return stringify(p); } @@ -397,7 +396,7 @@ ESimpleURIKey::pretty_print_flat(const SimpleURISpecTree::ItemFormatter & f) con { StringifyFormatter ff(f); DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, false, true); - value()->accept(p); + value()->root()->accept(p); return stringify(p); } @@ -410,7 +409,7 @@ namespace paludis const std::tr1::shared_ptr<const ERepositoryID> id; const std::string string_value; mutable Mutex value_mutex; - mutable std::tr1::shared_ptr<const PlainTextSpecTree::ConstItem> value; + mutable std::tr1::shared_ptr<const PlainTextSpecTree> value; Implementation(const Environment * const e, const std::tr1::shared_ptr<const ERepositoryID> & i, const std::string & v) : env(e), @@ -434,7 +433,7 @@ EPlainTextSpecKey::~EPlainTextSpecKey() { } -const std::tr1::shared_ptr<const PlainTextSpecTree::ConstItem> +const std::tr1::shared_ptr<const PlainTextSpecTree> EPlainTextSpecKey::value() const { Lock l(_imp->value_mutex); @@ -452,7 +451,7 @@ EPlainTextSpecKey::pretty_print(const PlainTextSpecTree::ItemFormatter & f) cons { StringifyFormatter ff(f); DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, true, true); - value()->accept(p); + value()->root()->accept(p); return stringify(p); } @@ -461,7 +460,7 @@ EPlainTextSpecKey::pretty_print_flat(const PlainTextSpecTree::ItemFormatter & f) { StringifyFormatter ff(f); DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, false, true); - value()->accept(p); + value()->root()->accept(p); return stringify(p); } @@ -474,7 +473,7 @@ namespace paludis const std::tr1::shared_ptr<const ERepositoryID> id; const std::string string_value; mutable Mutex value_mutex; - mutable std::tr1::shared_ptr<const PlainTextSpecTree::ConstItem> value; + mutable std::tr1::shared_ptr<const PlainTextSpecTree> value; Implementation(const Environment * const e, const std::tr1::shared_ptr<const ERepositoryID> & i, const std::string & v) : env(e), @@ -498,7 +497,7 @@ EMyOptionsKey::~EMyOptionsKey() { } -const std::tr1::shared_ptr<const PlainTextSpecTree::ConstItem> +const std::tr1::shared_ptr<const PlainTextSpecTree> EMyOptionsKey::value() const { Lock l(_imp->value_mutex); @@ -516,7 +515,7 @@ EMyOptionsKey::pretty_print(const PlainTextSpecTree::ItemFormatter & f) const { StringifyFormatter ff(f); DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, true, true); - value()->accept(p); + value()->root()->accept(p); return stringify(p); } @@ -525,7 +524,7 @@ EMyOptionsKey::pretty_print_flat(const PlainTextSpecTree::ItemFormatter & f) con { StringifyFormatter ff(f); DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, false, true); - value()->accept(p); + value()->root()->accept(p); return stringify(p); } @@ -538,7 +537,7 @@ namespace paludis const std::tr1::shared_ptr<const ERepositoryID> id; const std::string string_value; mutable Mutex value_mutex; - mutable std::tr1::shared_ptr<const ProvideSpecTree::ConstItem> value; + mutable std::tr1::shared_ptr<const ProvideSpecTree> value; Implementation(const Environment * const e, const std::tr1::shared_ptr<const ERepositoryID> & i, const std::string & v) : env(e), @@ -561,7 +560,7 @@ EProvideKey::~EProvideKey() { } -const std::tr1::shared_ptr<const ProvideSpecTree::ConstItem> +const std::tr1::shared_ptr<const ProvideSpecTree> EProvideKey::value() const { Lock l(_imp->value_mutex); @@ -579,7 +578,7 @@ EProvideKey::pretty_print(const ProvideSpecTree::ItemFormatter & f) const { StringifyFormatter ff(f); DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, true, true); - value()->accept(p); + value()->root()->accept(p); return stringify(p); } @@ -588,7 +587,7 @@ EProvideKey::pretty_print_flat(const ProvideSpecTree::ItemFormatter & f) const { StringifyFormatter ff(f); DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, false, true); - value()->accept(p); + value()->root()->accept(p); return stringify(p); } diff --git a/paludis/repositories/e/e_key.hh b/paludis/repositories/e/e_key.hh index 9d30cd416..cd7c6299f 100644 --- a/paludis/repositories/e/e_key.hh +++ b/paludis/repositories/e/e_key.hh @@ -66,7 +66,7 @@ namespace paludis const MetadataKeyType); ~EDependenciesKey(); - virtual const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> value() const + virtual const std::tr1::shared_ptr<const DependencySpecTree> value() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual std::string pretty_print(const DependencySpecTree::ItemFormatter &) const @@ -92,7 +92,7 @@ namespace paludis const std::string &, const std::string &, const std::string &, const MetadataKeyType); ~EFetchableURIKey(); - virtual const std::tr1::shared_ptr<const FetchableURISpecTree::ConstItem> value() const + virtual const std::tr1::shared_ptr<const FetchableURISpecTree> value() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual std::string pretty_print(const FetchableURISpecTree::ItemFormatter &) const @@ -118,7 +118,7 @@ namespace paludis const std::string &, const std::string &, const std::string &, const MetadataKeyType); ~ESimpleURIKey(); - virtual const std::tr1::shared_ptr<const SimpleURISpecTree::ConstItem> value() const + virtual const std::tr1::shared_ptr<const SimpleURISpecTree> value() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual std::string pretty_print(const SimpleURISpecTree::ItemFormatter &) const @@ -141,7 +141,7 @@ namespace paludis const std::string &, const std::string &, const std::string &, const MetadataKeyType); ~EPlainTextSpecKey(); - virtual const std::tr1::shared_ptr<const PlainTextSpecTree::ConstItem> value() const + virtual const std::tr1::shared_ptr<const PlainTextSpecTree> value() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual std::string pretty_print(const PlainTextSpecTree::ItemFormatter &) const @@ -164,7 +164,7 @@ namespace paludis const std::string &, const std::string &, const std::string &, const MetadataKeyType); ~EMyOptionsKey(); - virtual const std::tr1::shared_ptr<const PlainTextSpecTree::ConstItem> value() const + virtual const std::tr1::shared_ptr<const PlainTextSpecTree> value() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual std::string pretty_print(const PlainTextSpecTree::ItemFormatter &) const @@ -187,7 +187,7 @@ namespace paludis const std::string &, const std::string &, const std::string &, const MetadataKeyType); ~EProvideKey(); - virtual const std::tr1::shared_ptr<const ProvideSpecTree::ConstItem> value() const + virtual const std::tr1::shared_ptr<const ProvideSpecTree> value() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual std::string pretty_print(const ProvideSpecTree::ItemFormatter &) const @@ -211,7 +211,7 @@ namespace paludis const std::string &, const std::string &, const std::string &, const MetadataKeyType); ~ELicenseKey(); - virtual const std::tr1::shared_ptr<const LicenseSpecTree::ConstItem> value() const + virtual const std::tr1::shared_ptr<const LicenseSpecTree> value() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual std::string pretty_print(const LicenseSpecTree::ItemFormatter &) const diff --git a/paludis/repositories/e/e_mask.cc b/paludis/repositories/e/e_mask.cc index cebad426f..5adedd993 100644 --- a/paludis/repositories/e/e_mask.cc +++ b/paludis/repositories/e/e_mask.cc @@ -18,7 +18,6 @@ */ #include <paludis/repositories/e/e_mask.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/private_implementation_pattern-impl.hh> using namespace paludis; diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc index 93db316da..7941b6488 100644 --- a/paludis/repositories/e/e_repository.cc +++ b/paludis/repositories/e/e_repository.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2008, 2009 Ciaran McCreesh * Copyright (c) 2006 Danny van Dyk * * This file is part of the Paludis package manager. Paludis is free software; @@ -72,7 +72,6 @@ #include <paludis/util/sequence.hh> #include <paludis/util/set.hh> #include <paludis/util/system.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/dir_iterator.hh> #include <paludis/util/is_file_with_extension.hh> #include <paludis/util/rmd160.hh> @@ -81,6 +80,8 @@ #include <paludis/util/hashes.hh> #include <paludis/util/make_named_values.hh> #include <paludis/util/destringify.hh> +#include <paludis/util/wrapped_forward_iterator.hh> +#include <paludis/util/wrapped_output_iterator.hh> #include <tr1/functional> #include <tr1/unordered_map> @@ -690,7 +691,7 @@ ERepository::need_mirrors() const } } -std::tr1::shared_ptr<SetSpecTree::ConstItem> +const std::tr1::shared_ptr<const SetSpecTree> ERepository::package_set(const SetName & s) const { if (s.data() == "system") @@ -1188,7 +1189,7 @@ ERepository::make_manifest(const QualifiedPackageName & qpn) if (! id->fetches_key()) continue; AAVisitor aa; - id->fetches_key()->value()->accept(aa); + id->fetches_key()->value()->root()->accept(aa); for (AAVisitor::ConstIterator d(aa.begin()) ; d != aa.end() ; ++d) diff --git a/paludis/repositories/e/e_repository.hh b/paludis/repositories/e/e_repository.hh index a301f1b51..2308664c6 100644 --- a/paludis/repositories/e/e_repository.hh +++ b/paludis/repositories/e/e_repository.hh @@ -127,7 +127,7 @@ namespace paludis /* RepositorySetsInterface */ - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> package_set(const SetName & id) const; + virtual const std::tr1::shared_ptr<const SetSpecTree> package_set(const SetName & id) const; virtual std::tr1::shared_ptr<const SetNameSet> sets_list() const; diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc index 150b50c6f..8766699ed 100644 --- a/paludis/repositories/e/e_repository_TEST.cc +++ b/paludis/repositories/e/e_repository_TEST.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh + * Copyright (c) 2006, 2007, 2008, 2009 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 @@ -27,7 +27,6 @@ #include <paludis/repositories/fake/fake_package_id.hh> #include <paludis/environments/test/test_environment.hh> #include <paludis/util/system.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/simple_visitor_cast.hh> #include <paludis/util/map.hh> #include <paludis/util/make_shared_ptr.hh> @@ -490,11 +489,11 @@ namespace test_cases StringifyFormatter ff; erepository::DepSpecPrettyPrinter pd(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); TEST_CHECK(id1->build_dependencies_key()); - id1->build_dependencies_key()->value()->accept(pd); + id1->build_dependencies_key()->value()->root()->accept(pd); TEST_CHECK_STRINGIFY_EQUAL(pd, "foo/bar"); erepository::DepSpecPrettyPrinter pr(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); TEST_CHECK(id1->run_dependencies_key()); - id1->run_dependencies_key()->value()->accept(pr); + id1->run_dependencies_key()->value()->root()->accept(pr); TEST_CHECK_STRINGIFY_EQUAL(pr, "foo/bar"); const std::tr1::shared_ptr<const PackageID> id2(*env[selection::RequireExactlyOne(generator::Matches( @@ -506,11 +505,11 @@ namespace test_cases TEST_CHECK_EQUAL(id2->short_description_key()->value(), "dquote \" squote ' backslash \\ dollar $"); erepository::DepSpecPrettyPrinter pd2(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); TEST_CHECK(id2->build_dependencies_key()); - id2->build_dependencies_key()->value()->accept(pd2); + id2->build_dependencies_key()->value()->root()->accept(pd2); TEST_CHECK_STRINGIFY_EQUAL(pd2, "foo/bar bar/baz"); erepository::DepSpecPrettyPrinter pr2(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); TEST_CHECK(id2->run_dependencies_key()); - id2->run_dependencies_key()->value()->accept(pr2); + id2->run_dependencies_key()->value()->root()->accept(pr2); TEST_CHECK_STRINGIFY_EQUAL(pr2, "foo/bar"); const std::tr1::shared_ptr<const PackageID> id3(*env[selection::RequireExactlyOne(generator::Matches( @@ -2295,17 +2294,17 @@ namespace test_cases erepository::DepSpecPrettyPrinter pd(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); TEST_CHECK(id->build_dependencies_key()); - id->build_dependencies_key()->value()->accept(pd); + id->build_dependencies_key()->value()->root()->accept(pd); TEST_CHECK_STRINGIFY_EQUAL(pd, "( cat/pkg1 build: cat/pkg2 build,run: cat/pkg3 suggested: cat/pkg4 post: )"); erepository::DepSpecPrettyPrinter pr(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); TEST_CHECK(id->run_dependencies_key()); - id->run_dependencies_key()->value()->accept(pr); + id->run_dependencies_key()->value()->root()->accept(pr); TEST_CHECK_STRINGIFY_EQUAL(pr, "( cat/pkg1 build: build,run: cat/pkg3 suggested: cat/pkg4 post: )"); erepository::DepSpecPrettyPrinter pp(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); TEST_CHECK(id->post_dependencies_key()); - id->post_dependencies_key()->value()->accept(pp); + id->post_dependencies_key()->value()->root()->accept(pp); TEST_CHECK_STRINGIFY_EQUAL(pp, "( build: build,run: suggested: post: cat/pkg5 )"); } } test_e_repository_dependencies_rewriter; diff --git a/paludis/repositories/e/e_repository_profile.cc b/paludis/repositories/e/e_repository_profile.cc index 3644bea8d..5806a3c9b 100644 --- a/paludis/repositories/e/e_repository_profile.cc +++ b/paludis/repositories/e/e_repository_profile.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2008, 2009 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 @@ -147,7 +147,7 @@ namespace paludis ///\name System package set ///\{ - std::tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > system_packages; + std::tr1::shared_ptr<SetSpecTree> system_packages; std::tr1::shared_ptr<GeneralSetDepTag> system_tag; ///\} @@ -188,8 +188,7 @@ namespace paludis package_mask_file(p), env(e), repository(p), - system_packages(new ConstTreeSequence<SetSpecTree, AllDepSpec>( - std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))), + system_packages(new SetSpecTree(make_shared_ptr(new AllDepSpec))), system_tag(new GeneralSetDepTag(SetName("system"), stringify(name))), use_expand(new Set<std::string>), use_expand_hidden(new Set<std::string>) @@ -484,7 +483,7 @@ Implementation<ERepositoryProfile>::make_vars_from_file_vars() std::tr1::shared_ptr<const PackageID>()))); spec->set_tag(system_tag); - system_packages->add(std::tr1::shared_ptr<SetSpecTree::ConstItem>(new TreeLeaf<SetSpecTree, PackageDepSpec>(spec))); + system_packages->root()->append(spec); } } catch (const InternalError &) @@ -866,7 +865,7 @@ ERepositoryProfile::environment_variable(const std::string & s) const return i->second; } -std::tr1::shared_ptr<SetSpecTree::ConstItem> +const std::tr1::shared_ptr<const SetSpecTree> ERepositoryProfile::system_packages() const { return _imp->system_packages; diff --git a/paludis/repositories/e/e_repository_profile.hh b/paludis/repositories/e/e_repository_profile.hh index 3dcded6bd..c30117fe0 100644 --- a/paludis/repositories/e/e_repository_profile.hh +++ b/paludis/repositories/e/e_repository_profile.hh @@ -21,17 +21,18 @@ #define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_E_REPOSITORY_PROFILE_HH 1 #include <paludis/dep_spec-fwd.hh> -#include <paludis/dep_tree.hh> #include <paludis/package_id-fwd.hh> #include <paludis/name-fwd.hh> #include <paludis/version_spec-fwd.hh> #include <paludis/mask-fwd.hh> #include <paludis/metadata_key-fwd.hh> #include <paludis/choice-fwd.hh> +#include <paludis/spec_tree-fwd.hh> #include <paludis/util/fs_entry-fwd.hh> #include <paludis/util/private_implementation_pattern.hh> #include <paludis/util/instantiation_policy.hh> #include <paludis/util/tribool.hh> +#include <paludis/util/wrapped_forward_iterator-fwd.hh> #include <string> /** \file @@ -129,7 +130,7 @@ namespace paludis ///\name System package set ///\{ - std::tr1::shared_ptr<SetSpecTree::ConstItem> system_packages() const; + const std::tr1::shared_ptr<const SetSpecTree> system_packages() const; ///\} diff --git a/paludis/repositories/e/e_repository_sets.cc b/paludis/repositories/e/e_repository_sets.cc index 3542f59f9..d94cca68f 100644 --- a/paludis/repositories/e/e_repository_sets.cc +++ b/paludis/repositories/e/e_repository_sets.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2008, 2009 Ciaran McCreesh * Copyright (c) 2006 Danny van Dyk * * This file is part of the Paludis package manager. Paludis is free software; @@ -94,7 +94,7 @@ ERepositorySets::~ERepositorySets() { } -std::tr1::shared_ptr<SetSpecTree::ConstItem> +const std::tr1::shared_ptr<const SetSpecTree> ERepositorySets::package_set(const SetName & ss) const { using namespace std::tr1::placeholders; @@ -127,7 +127,7 @@ ERepositorySets::package_set(const SetName & ss) const return f.contents(); } else - return std::tr1::shared_ptr<SetSpecTree::ConstItem>(); + return make_null_shared_ptr(); } std::tr1::shared_ptr<const SetNameSet> @@ -249,12 +249,12 @@ namespace } } -std::tr1::shared_ptr<SetSpecTree::ConstItem> +const std::tr1::shared_ptr<const SetSpecTree> ERepositorySets::security_set(bool insecurity) const { Context context("When building security or insecurity package set:"); - std::tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > security_packages( - new ConstTreeSequence<SetSpecTree, AllDepSpec>(std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); + + std::tr1::shared_ptr<SetSpecTree> security_packages(new SetSpecTree(make_shared_ptr(new AllDepSpec))); if (!_imp->params.securitydir().is_directory_or_symlink_to_directory()) return security_packages; @@ -305,8 +305,7 @@ ERepositorySets::security_set(bool insecurity) const value_for<n::version_spec>((*c)->version()))) .in_repository((*c)->repository()->name()))); spec->set_tag(glsa_tags.find(glsa->id())->second); - security_packages->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >( - new TreeLeaf<SetSpecTree, PackageDepSpec>(spec))); + security_packages->root()->append(spec); } else { @@ -341,8 +340,7 @@ ERepositorySets::security_set(bool insecurity) const value_for<n::version_spec>((*r)->version()))) .in_repository((*r)->repository()->name()))); spec->set_tag(glsa_tags.find(glsa->id())->second); - security_packages->add(std::tr1::shared_ptr<SetSpecTree::ConstItem>( - new TreeLeaf<SetSpecTree, PackageDepSpec>(spec))); + security_packages->root()->append(spec); ok = true; break; } diff --git a/paludis/repositories/e/e_repository_sets.hh b/paludis/repositories/e/e_repository_sets.hh index 2cafa6836..ba1bb11dc 100644 --- a/paludis/repositories/e/e_repository_sets.hh +++ b/paludis/repositories/e/e_repository_sets.hh @@ -58,12 +58,12 @@ namespace paludis /** * Fetch a package set other than system. */ - std::tr1::shared_ptr<SetSpecTree::ConstItem> package_set(const SetName & s) const; + const std::tr1::shared_ptr<const SetSpecTree> package_set(const SetName & s) const; /** * Fetch the security or insecurity set. */ - std::tr1::shared_ptr<SetSpecTree::ConstItem> security_set(bool insecure) const; + const std::tr1::shared_ptr<const SetSpecTree> security_set(bool insecure) const; /** * Give a list of all the sets in this repo. diff --git a/paludis/repositories/e/e_repository_sets_TEST.cc b/paludis/repositories/e/e_repository_sets_TEST.cc index 0924b921b..a5cc45bc5 100644 --- a/paludis/repositories/e/e_repository_sets_TEST.cc +++ b/paludis/repositories/e/e_repository_sets_TEST.cc @@ -21,7 +21,6 @@ #include <paludis/repositories/e/dep_spec_pretty_printer.hh> #include <paludis/repositories/fake/fake_installed_repository.hh> #include <paludis/repositories/fake/fake_package_id.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/environments/test/test_environment.hh> #include <paludis/util/system.hh> #include <paludis/util/map.hh> @@ -92,10 +91,10 @@ namespace test_cases installed->add_version("cat-two", "bar", "1.5"); env.package_database()->add_repository(0, installed); - std::tr1::shared_ptr<SetSpecTree::ConstItem> set1(repo->sets_interface()->package_set(SetName("set1"))); + std::tr1::shared_ptr<const SetSpecTree> set1(repo->sets_interface()->package_set(SetName("set1"))); StringifyFormatter ff; erepository::DepSpecPrettyPrinter pretty(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); - set1->accept(pretty); + set1->root()->accept(pretty); TEST_CHECK_STRINGIFY_EQUAL(pretty, "cat-one/foo >=cat-two/bar-2"); } } test_e_repository_sets_maintainer_defined_sets_list; @@ -122,10 +121,10 @@ namespace test_cases std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1))); env.package_database()->add_repository(1, repo); - std::tr1::shared_ptr<SetSpecTree::ConstItem> insecurity(repo->sets_interface()->package_set(SetName("insecurity"))); + std::tr1::shared_ptr<const SetSpecTree> insecurity(repo->sets_interface()->package_set(SetName("insecurity"))); StringifyFormatter ff; erepository::DepSpecPrettyPrinter pretty(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); - insecurity->accept(pretty); + insecurity->root()->accept(pretty); TEST_CHECK_STRINGIFY_EQUAL(pretty, "=cat-four/xyzzy-2.0.1::test-repo-1 =cat-four/xyzzy-2.0.2::test-repo-1 =cat-one/foo-1::test-repo-1 =cat-two/bar-1.5::test-repo-1 " "=cat-two/bar-1.5.1::test-repo-1 =cat-three/baz-1.0::test-repo-1 " "=cat-three/baz-1.1-r2::test-repo-1 =cat-three/baz-1.2::test-repo-1"); @@ -162,10 +161,10 @@ namespace test_cases installed->add_version("cat-four", "xyzzy", "2.0.1")->set_slot(SlotName("2")); env.package_database()->add_repository(0, installed); - std::tr1::shared_ptr<const SetSpecTree::ConstItem> security(repo->sets_interface()->package_set(SetName("security"))); + std::tr1::shared_ptr<const SetSpecTree> security(repo->sets_interface()->package_set(SetName("security"))); StringifyFormatter ff; erepository::DepSpecPrettyPrinter pretty(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); - security->accept(pretty); + security->root()->accept(pretty); TEST_CHECK_STRINGIFY_EQUAL(pretty, "=cat-four/xyzzy-2.0.3::test-repo-1 =cat-two/bar-2.0::test-repo-1 =cat-three/baz-1.3::test-repo-1"); } } test_e_repository_sets_security_set; diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc index ba5294681..7b5a38677 100644 --- a/paludis/repositories/e/ebuild.cc +++ b/paludis/repositories/e/ebuild.cc @@ -38,8 +38,6 @@ #include <paludis/util/iterator_funcs.hh> #include <paludis/util/destringify.hh> #include <paludis/util/indirect_iterator-impl.hh> -#include <paludis/util/visitor_cast.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/set.hh> #include <paludis/util/cookie.hh> #include <paludis/util/output_deviator.hh> @@ -447,7 +445,7 @@ EbuildMetadataCommand::load(const std::tr1::shared_ptr<const EbuildID> & id) if (! m.dependencies().name().empty()) { DependenciesRewriter rewriter; - parse_depend(get(keys, m.dependencies().name()), params.environment(), id, *id->eapi())->accept(rewriter); + parse_depend(get(keys, m.dependencies().name()), params.environment(), id, *id->eapi())->root()->accept(rewriter); id->load_build_depend(m.dependencies().name() + ".DEPEND", m.dependencies().description() + " (build)", rewriter.depend()); id->load_run_depend(m.dependencies().name() + ".RDEPEND", m.dependencies().description() + " (run)", rewriter.rdepend()); id->load_post_depend(m.dependencies().name() + ".PDEPEND", m.dependencies().description() + " (post)", rewriter.pdepend()); diff --git a/paludis/repositories/e/ebuild_entries.cc b/paludis/repositories/e/ebuild_entries.cc index 0740e8bde..819884b2e 100644 --- a/paludis/repositories/e/ebuild_entries.cc +++ b/paludis/repositories/e/ebuild_entries.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2008, 2009 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 @@ -51,7 +51,6 @@ #include <paludis/util/sequence.hh> #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/is_file_with_extension.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/indirect_iterator-impl.hh> #include <paludis/util/config_file.hh> #include <paludis/util/instantiation_policy-impl.hh> @@ -163,8 +162,7 @@ EbuildEntries::make_id(const QualifiedPackageName & q, const FSEntry & f) const namespace { class AFinder : - private InstantiationPolicy<AFinder, instantiation_method::NonCopyableTag>, - public ConstVisitor<FetchableURISpecTree> + private InstantiationPolicy<AFinder, instantiation_method::NonCopyableTag> { private: std::list<std::pair<const FetchableURIDepSpec *, const URILabelsDepSpec *> > _specs; @@ -181,33 +179,29 @@ namespace _labels.push_back(0); } - void visit_leaf(const FetchableURIDepSpec & a) + void visit(const FetchableURISpecTree::NodeType<FetchableURIDepSpec>::Type & node) { - _specs.push_back(std::make_pair(&a, *_labels.begin())); + _specs.push_back(std::make_pair(node.spec().get(), *_labels.begin())); } - void visit_leaf(const URILabelsDepSpec & l) + void visit(const FetchableURISpecTree::NodeType<URILabelsDepSpec>::Type & node) { - *_labels.begin() = &l; + *_labels.begin() = node.spec().get(); } - void visit_sequence(const AllDepSpec &, - FetchableURISpecTree::ConstSequenceIterator cur, - FetchableURISpecTree::ConstSequenceIterator e) + void visit(const FetchableURISpecTree::NodeType<AllDepSpec>::Type & node) { _labels.push_front(*_labels.begin()); - std::for_each(cur, e, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); _labels.pop_front(); } - void visit_sequence(const ConditionalDepSpec & u, - FetchableURISpecTree::ConstSequenceIterator cur, - FetchableURISpecTree::ConstSequenceIterator e) + void visit(const FetchableURISpecTree::NodeType<ConditionalDepSpec>::Type & node) { - if (u.condition_met()) + if (node.spec()->condition_met()) { _labels.push_front(*_labels.begin()); - std::for_each(cur, e, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); _labels.pop_front(); } } @@ -365,7 +359,7 @@ EbuildEntries::fetch(const std::tr1::shared_ptr<const ERepositoryID> & id, { DepSpecFlattener<PlainTextSpecTree, PlainTextDepSpec> restricts(_imp->params.environment()); if (id->restrict_key()) - id->restrict_key()->value()->accept(restricts); + id->restrict_key()->value()->root()->accept(restricts); for (DepSpecFlattener<PlainTextSpecTree, PlainTextDepSpec>::ConstIterator i(restricts.begin()), i_end(restricts.end()) ; i != i_end ; ++i) @@ -389,7 +383,7 @@ EbuildEntries::fetch(const std::tr1::shared_ptr<const ERepositoryID> & id, /* make A */ AFinder f(_imp->params.environment(), id); if (id->fetches_key()) - id->fetches_key()->value()->accept(f); + id->fetches_key()->value()->root()->accept(f); for (AFinder::ConstIterator i(f.begin()), i_end(f.end()) ; i != i_end ; ++i) { @@ -408,7 +402,7 @@ EbuildEntries::fetch(const std::tr1::shared_ptr<const ERepositoryID> & id, { AAVisitor g; if (id->fetches_key()) - id->fetches_key()->value()->accept(g); + id->fetches_key()->value()->root()->accept(g); std::set<std::string> already_in_all_archives; for (AAVisitor::ConstIterator gg(g.begin()), gg_end(g.end()) ; gg != gg_end ; ++gg) @@ -443,13 +437,13 @@ EbuildEntries::fetch(const std::tr1::shared_ptr<const ERepositoryID> & id, FetchVisitor f(_imp->params.environment(), id, *id->eapi(), _imp->e_repository->params().distdir(), o.fetch_unneeded(), fetch_userpriv_ok, mirrors_name, id->fetches_key()->initial_label(), o.safe_resume(), o.maybe_output_deviant()); - id->fetches_key()->value()->accept(f); + id->fetches_key()->value()->root()->accept(f); CheckFetchedFilesVisitor c(_imp->environment, id, _imp->e_repository->params().distdir(), o.fetch_unneeded(), fetch_restrict, ((_imp->e_repository->layout()->package_directory(id->name())) / "Manifest"), _imp->e_repository->params().use_manifest(), o.maybe_output_deviant(), o.exclude_unmirrorable()); - id->fetches_key()->value()->accept(c); + id->fetches_key()->value()->root()->accept(c); if (c.need_nofetch()) { @@ -520,7 +514,7 @@ EbuildEntries::pretend_fetch(const std::tr1::shared_ptr<const ERepositoryID> & i PretendFetchVisitor f(_imp->params.environment(), id, *id->eapi(), _imp->e_repository->params().distdir(), a.options.fetch_unneeded(), id->fetches_key()->initial_label(), a); - id->fetches_key()->value()->accept(f); + id->fetches_key()->value()->root()->accept(f); } } @@ -536,7 +530,7 @@ EbuildEntries::install(const std::tr1::shared_ptr<const ERepositoryID> & id, { DepSpecFlattener<PlainTextSpecTree, PlainTextDepSpec> restricts(_imp->params.environment()); if (id->restrict_key()) - id->restrict_key()->value()->accept(restricts); + id->restrict_key()->value()->root()->accept(restricts); userpriv_restrict = indirect_iterator(restricts.end()) != std::find_if(indirect_iterator(restricts.begin()), indirect_iterator(restricts.end()), @@ -562,7 +556,7 @@ EbuildEntries::install(const std::tr1::shared_ptr<const ERepositoryID> & id, /* make A */ AFinder f(_imp->params.environment(), id); if (id->fetches_key()) - id->fetches_key()->value()->accept(f); + id->fetches_key()->value()->root()->accept(f); for (AFinder::ConstIterator i(f.begin()), i_end(f.end()) ; i != i_end ; ++i) { @@ -581,7 +575,7 @@ EbuildEntries::install(const std::tr1::shared_ptr<const ERepositoryID> & id, { AAVisitor g; if (id->fetches_key()) - id->fetches_key()->value()->accept(g); + id->fetches_key()->value()->root()->accept(g); std::set<std::string> already_in_all_archives; for (AAVisitor::ConstIterator gg(g.begin()), gg_end(g.end()) ; gg != gg_end ; ++gg) @@ -757,7 +751,7 @@ EbuildEntries::info(const std::tr1::shared_ptr<const ERepositoryID> & id, { DepSpecFlattener<PlainTextSpecTree, PlainTextDepSpec> restricts(_imp->params.environment()); if (id->restrict_key()) - id->restrict_key()->value()->accept(restricts); + id->restrict_key()->value()->root()->accept(restricts); userpriv_restrict = indirect_iterator(restricts.end()) != std::find_if(indirect_iterator(restricts.begin()), indirect_iterator(restricts.end()), @@ -839,7 +833,7 @@ EbuildEntries::get_environment_variable(const std::tr1::shared_ptr<const EReposi DepSpecFlattener<PlainTextSpecTree, PlainTextDepSpec> restricts(_imp->params.environment()); if (id->restrict_key()) - id->restrict_key()->value()->accept(restricts); + id->restrict_key()->value()->root()->accept(restricts); userpriv_restrict = indirect_iterator(restricts.end()) != std::find_if(indirect_iterator(restricts.begin()), indirect_iterator(restricts.end()), @@ -964,7 +958,7 @@ EbuildEntries::pretend(const std::tr1::shared_ptr<const ERepositoryID> & id, { DepSpecFlattener<PlainTextSpecTree, PlainTextDepSpec> restricts(_imp->params.environment()); if (id->restrict_key()) - id->restrict_key()->value()->accept(restricts); + id->restrict_key()->value()->root()->accept(restricts); userpriv_restrict = indirect_iterator(restricts.end()) != std::find_if(indirect_iterator(restricts.begin()), indirect_iterator(restricts.end()), @@ -984,7 +978,7 @@ EbuildEntries::pretend(const std::tr1::shared_ptr<const ERepositoryID> & id, if (id->raw_myoptions_key()) { MyOptionsRequirementsVerifier verifier(id); - id->raw_myoptions_key()->value()->accept(verifier); + id->raw_myoptions_key()->value()->root()->accept(verifier); if (verifier.unmet_requirements() && ! verifier.unmet_requirements()->empty()) { diff --git a/paludis/repositories/e/ebuild_flat_metadata_cache.cc b/paludis/repositories/e/ebuild_flat_metadata_cache.cc index 883b0d308..4e581bae0 100644 --- a/paludis/repositories/e/ebuild_flat_metadata_cache.cc +++ b/paludis/repositories/e/ebuild_flat_metadata_cache.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh + * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh * Copyright (c) 2008 David Leverton * * This file is part of the Paludis package manager. Paludis is free software; @@ -22,9 +22,9 @@ #include <paludis/util/log.hh> #include <paludis/util/tokeniser.hh> #include <paludis/util/join.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/set.hh> #include <paludis/util/destringify.hh> +#include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/repositories/e/dep_spec_pretty_printer.hh> #include <paludis/repositories/e/dep_parser.hh> #include <paludis/repositories/e/dependencies_rewriter.hh> @@ -163,7 +163,7 @@ namespace if (-1 != m.dependencies().flat_list_index() && ! m.dependencies().name().empty()) { DependenciesRewriter rewriter; - parse_depend(lines.at(m.dependencies().flat_list_index()), _imp->env, id, *id->eapi())->accept(rewriter); + parse_depend(lines.at(m.dependencies().flat_list_index()), _imp->env, id, *id->eapi())->root()->accept(rewriter); id->load_build_depend(m.dependencies().name() + ".DEPEND", m.dependencies().description() + " (build)", rewriter.depend()); id->load_run_depend(m.dependencies().name() + ".RDEPEND", m.dependencies().description() + " (run)", rewriter.rdepend()); id->load_post_depend(m.dependencies().name() + ".PDEPEND", m.dependencies().description() + " (post)", rewriter.pdepend()); @@ -477,7 +477,7 @@ EbuildFlatMetadataCache::load(const std::tr1::shared_ptr<const EbuildID> & id) if (! m.dependencies().name().empty()) { DependenciesRewriter rewriter; - parse_depend(keys[m.dependencies().name()], _imp->env, id, *id->eapi())->accept(rewriter); + parse_depend(keys[m.dependencies().name()], _imp->env, id, *id->eapi())->root()->accept(rewriter); id->load_build_depend(m.dependencies().name() + ".DEPEND", m.dependencies().description() + " (build)", rewriter.depend()); id->load_run_depend(m.dependencies().name() + ".RDEPEND", m.dependencies().description() + " (run)", rewriter.rdepend()); id->load_post_depend(m.dependencies().name() + ".PDEPEND", m.dependencies().description() + " (post)", rewriter.pdepend()); @@ -638,7 +638,7 @@ namespace { StringifyFormatter ff; DepSpecPrettyPrinter p(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); - d->accept(p); + d->root()->accept(p); return stringify(p); } diff --git a/paludis/repositories/e/ebuild_flat_metadata_cache_TEST.cc b/paludis/repositories/e/ebuild_flat_metadata_cache_TEST.cc index f11954f49..aa60697c3 100644 --- a/paludis/repositories/e/ebuild_flat_metadata_cache_TEST.cc +++ b/paludis/repositories/e/ebuild_flat_metadata_cache_TEST.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh + * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh * Copyright (c) 2008 David Leverton * * This file is part of the Paludis package manager. Paludis is free software; @@ -30,7 +30,6 @@ #include <paludis/util/sequence.hh> #include <paludis/util/set.hh> #include <paludis/util/simple_visitor_cast.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/wrapped_forward_iterator.hh> #include <test/test_framework.hh> #include <test/test_runner.hh> diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc index b61d954fc..bc189c33e 100644 --- a/paludis/repositories/e/ebuild_id.cc +++ b/paludis/repositories/e/ebuild_id.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -45,11 +45,11 @@ #include <paludis/util/log.hh> #include <paludis/util/mutex.hh> #include <paludis/util/private_implementation_pattern-impl.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/make_shared_ptr.hh> #include <paludis/util/save.hh> #include <paludis/util/make_named_values.hh> #include <paludis/util/tribool.hh> +#include <paludis/util/wrapped_forward_iterator.hh> #include <set> #include <iterator> @@ -326,15 +326,11 @@ EbuildID::need_keys_added() const namespace { - struct LicenceChecker : - ConstVisitor<LicenseSpecTree>, - ConstVisitor<LicenseSpecTree>::VisitConstSequence<LicenceChecker, AllDepSpec> + struct LicenceChecker { - using ConstVisitor<LicenseSpecTree>::VisitConstSequence<LicenceChecker, AllDepSpec>::visit_sequence; - bool ok; const Environment * const env; - bool (Environment::* const func) (const std::string &, const PackageID &) const; + bool (Environment::* const func) (const std::string &, const PackageID &) const; const PackageID * const id; LicenceChecker(const Environment * const e, @@ -347,20 +343,24 @@ namespace { } - void visit_sequence(const AnyDepSpec &, - LicenseSpecTree::ConstSequenceIterator begin, - LicenseSpecTree::ConstSequenceIterator end) + void visit(const LicenseSpecTree::NodeType<AllDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + + void visit(const LicenseSpecTree::NodeType<AnyDepSpec>::Type & node) { bool local_ok(false); - if (begin == end) + if (node.begin() == node.end()) local_ok = true; else { - for ( ; begin != end ; ++begin) + for (LicenseSpecTree::NodeType<AnyDepSpec>::Type::ConstIterator c(node.begin()), c_end(node.end()) ; + c != c_end ; ++c) { Save<bool> save_ok(&ok, true); - begin->accept(*this); + (*c)->accept(*this); local_ok |= ok; } } @@ -368,17 +368,15 @@ namespace ok &= local_ok; } - void visit_sequence(const ConditionalDepSpec & spec, - LicenseSpecTree::ConstSequenceIterator begin, - LicenseSpecTree::ConstSequenceIterator end) + void visit(const LicenseSpecTree::NodeType<ConditionalDepSpec>::Type & node) { - if (spec.condition_met()) - std::for_each(begin, end, accept_visitor(*this)); + if (node.spec()->condition_met()) + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } - void visit_leaf(const LicenseDepSpec & spec) + void visit(const LicenseSpecTree::NodeType<LicenseDepSpec>::Type & node) { - if (! (env->*func)(spec.text(), *id)) + if (! (env->*func)(node.spec()->text(), *id)) ok = false; } }; @@ -411,7 +409,7 @@ EbuildID::need_masks_added() const if (license_key()) { LicenceChecker c(_imp->environment, &Environment::accept_license, this); - license_key()->value()->accept(c); + license_key()->value()->root()->accept(c); if (! c.ok) add_mask(make_shared_ptr(new EUnacceptedMask('L', DistributionData::get_instance()->distribution_from_string( @@ -1194,32 +1192,26 @@ EbuildID::make_choice_value( namespace { - struct UnconditionalRestrictFinder : - ConstVisitor<PlainTextSpecTree> + struct UnconditionalRestrictFinder { std::set<std::string> s; - void visit_leaf(const PlainTextDepSpec & p) + void visit(const PlainTextSpecTree::NodeType<PlainTextDepSpec>::Type & node) { - s.insert(p.text()); + s.insert(node.spec()->text()); } - void visit_leaf(const PlainTextLabelDepSpec & p) + void visit(const PlainTextSpecTree::NodeType<PlainTextLabelDepSpec>::Type &) { - s.insert(p.text()); } - void visit_sequence(const ConditionalDepSpec &, - PlainTextSpecTree::ConstSequenceIterator, - PlainTextSpecTree::ConstSequenceIterator) + void visit(const PlainTextSpecTree::NodeType<ConditionalDepSpec>::Type &) { } - void visit_sequence(const AllDepSpec &, - PlainTextSpecTree::ConstSequenceIterator cur, - PlainTextSpecTree::ConstSequenceIterator end) + void visit(const PlainTextSpecTree::NodeType<AllDepSpec>::Type & node) { - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } }; } @@ -1241,7 +1233,7 @@ EbuildID::add_build_options(const std::tr1::shared_ptr<Choices> & choices) const if (restrict_key()) { UnconditionalRestrictFinder f; - restrict_key()->value()->accept(f); + restrict_key()->value()->root()->accept(f); may_be_unrestricted_test = f.s.end() == f.s.find("test"); may_be_unrestricted_strip = f.s.end() == f.s.find("strip"); } diff --git a/paludis/repositories/e/exndbam_id.cc b/paludis/repositories/e/exndbam_id.cc index 41c88ebde..270a4a049 100644 --- a/paludis/repositories/e/exndbam_id.cc +++ b/paludis/repositories/e/exndbam_id.cc @@ -21,8 +21,8 @@ #include <paludis/util/mutex.hh> #include <paludis/util/stringify.hh> #include <paludis/util/make_shared_ptr.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/set.hh> +#include <paludis/util/sequence.hh> #include <paludis/contents.hh> #include <paludis/ndbam.hh> #include <tr1/functional> diff --git a/paludis/repositories/e/fetch_visitor.cc b/paludis/repositories/e/fetch_visitor.cc index 9426a7b3d..5c818aff8 100644 --- a/paludis/repositories/e/fetch_visitor.cc +++ b/paludis/repositories/e/fetch_visitor.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -28,7 +28,6 @@ #include <paludis/action.hh> #include <paludis/repository.hh> #include <paludis/about.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/system.hh> #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/fs_entry.hh> @@ -108,32 +107,28 @@ FetchVisitor::~FetchVisitor() } void -FetchVisitor::visit_sequence(const ConditionalDepSpec & u, - FetchableURISpecTree::ConstSequenceIterator cur, - FetchableURISpecTree::ConstSequenceIterator end) +FetchVisitor::visit(const FetchableURISpecTree::NodeType<ConditionalDepSpec>::Type & node) { - if ((_imp->fetch_unneeded) || (u.condition_met())) + if ((_imp->fetch_unneeded) || (node.spec()->condition_met())) { _imp->labels.push_front(* _imp->labels.begin()); - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); _imp->labels.pop_front(); } } void -FetchVisitor::visit_sequence(const AllDepSpec &, - FetchableURISpecTree::ConstSequenceIterator cur, - FetchableURISpecTree::ConstSequenceIterator end) +FetchVisitor::visit(const FetchableURISpecTree::NodeType<AllDepSpec>::Type & node) { _imp->labels.push_front(* _imp->labels.begin()); - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); _imp->labels.pop_front(); } void -FetchVisitor::visit_leaf(const URILabelsDepSpec & l) +FetchVisitor::visit(const FetchableURISpecTree::NodeType<URILabelsDepSpec>::Type & node) { - for (URILabelsDepSpec::ConstIterator i(l.begin()), i_end(l.end()) ; + for (URILabelsDepSpec::ConstIterator i(node.spec()->begin()), i_end(node.spec()->end()) ; i != i_end ; ++i) *_imp->labels.begin() = i->get(); } @@ -149,22 +144,22 @@ namespace } void -FetchVisitor::visit_leaf(const FetchableURIDepSpec & u) +FetchVisitor::visit(const FetchableURISpecTree::NodeType<FetchableURIDepSpec>::Type & node) { - Context context("When visiting URI dep spec '" + stringify(u.text()) + "':"); + Context context("When visiting URI dep spec '" + stringify(node.spec()->text()) + "':"); if (! *_imp->labels.begin()) throw FetchActionError("No fetch action label available"); SourceURIFinder source_uri_finder(_imp->env, _imp->id->repository().get(), - u.original_url(), u.filename(), _imp->mirrors_name); + node.spec()->original_url(), node.spec()->filename(), _imp->mirrors_name); (*_imp->labels.begin())->accept(source_uri_finder); for (SourceURIFinder::ConstIterator i(source_uri_finder.begin()), i_end(source_uri_finder.end()) ; i != i_end ; ++i) { Context local_context("When fetching URI '" + stringify(i->first) + "' to '" + stringify(i->second) + ":"); - FSEntry destination(_imp->distdir / u.filename()); + FSEntry destination(_imp->distdir / node.spec()->filename()); if (destination.exists()) { diff --git a/paludis/repositories/e/fetch_visitor.hh b/paludis/repositories/e/fetch_visitor.hh index f3917be3d..84013b2e3 100644 --- a/paludis/repositories/e/fetch_visitor.hh +++ b/paludis/repositories/e/fetch_visitor.hh @@ -23,13 +23,13 @@ #include <paludis/repositories/e/eapi-fwd.hh> #include <paludis/util/attributes.hh> #include <paludis/util/private_implementation_pattern.hh> -#include <paludis/util/visitor-fwd.hh> #include <paludis/util/fs_entry-fwd.hh> #include <paludis/util/output_deviator-fwd.hh> #include <paludis/dep_spec.hh> -#include <paludis/dep_tree.hh> +#include <paludis/spec_tree-fwd.hh> #include <paludis/package_id-fwd.hh> #include <paludis/environment-fwd.hh> +#include <paludis/spec_tree.hh> #include <tr1/memory> namespace paludis @@ -37,8 +37,7 @@ namespace paludis namespace erepository { class PALUDIS_VISIBLE FetchVisitor : - private PrivateImplementationPattern<FetchVisitor>, - public ConstVisitor<FetchableURISpecTree> + private PrivateImplementationPattern<FetchVisitor> { public: FetchVisitor( @@ -55,17 +54,10 @@ namespace paludis ~FetchVisitor(); - void visit_sequence(const AllDepSpec &, - FetchableURISpecTree::ConstSequenceIterator, - FetchableURISpecTree::ConstSequenceIterator); - - void visit_sequence(const ConditionalDepSpec &, - FetchableURISpecTree::ConstSequenceIterator, - FetchableURISpecTree::ConstSequenceIterator); - - void visit_leaf(const URILabelsDepSpec &); - - void visit_leaf(const FetchableURIDepSpec &); + void visit(const FetchableURISpecTree::NodeType<FetchableURIDepSpec>::Type & node); + void visit(const FetchableURISpecTree::NodeType<URILabelsDepSpec>::Type & node); + void visit(const FetchableURISpecTree::NodeType<AllDepSpec>::Type & node); + void visit(const FetchableURISpecTree::NodeType<ConditionalDepSpec>::Type & node); }; } } diff --git a/paludis/repositories/e/fetch_visitor_TEST.cc b/paludis/repositories/e/fetch_visitor_TEST.cc index c1156accf..b8868cf2d 100644 --- a/paludis/repositories/e/fetch_visitor_TEST.cc +++ b/paludis/repositories/e/fetch_visitor_TEST.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -25,7 +25,6 @@ #include <paludis/environments/test/test_environment.hh> #include <paludis/util/sequence.hh> #include <paludis/util/make_shared_ptr.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/package_database.hh> #include <paludis/user_dep_spec.hh> #include <paludis/generator.hh> @@ -64,7 +63,7 @@ namespace test_cases *eapi, FSEntry("fetch_visitor_TEST_dir/out"), false, false, "test", make_shared_ptr(new URIListedThenMirrorsLabel("listed-then-mirrors")), false, make_null_shared_ptr()); - parse_fetchable_uri("file:///" + stringify(FSEntry("fetch_visitor_TEST_dir/in/input1").realpath()), &env, id, *eapi)->accept(v); + parse_fetchable_uri("file:///" + stringify(FSEntry("fetch_visitor_TEST_dir/in/input1").realpath()), &env, id, *eapi)->root()->accept(v); TEST_CHECK(FSEntry("fetch_visitor_TEST_dir/out/input1").is_regular_file()); std::ifstream f(stringify(FSEntry("fetch_visitor_TEST_dir/out/input1")).c_str()); diff --git a/paludis/repositories/e/fix_locked_dependencies.cc b/paludis/repositories/e/fix_locked_dependencies.cc index ea7557c83..dcff49624 100644 --- a/paludis/repositories/e/fix_locked_dependencies.cc +++ b/paludis/repositories/e/fix_locked_dependencies.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008 Ciaran McCreesh + * Copyright (c) 2008, 2009 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 @@ -19,7 +19,6 @@ #include <paludis/repositories/e/fix_locked_dependencies.hh> #include <paludis/repositories/e/eapi.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/simple_visitor_cast.hh> #include <paludis/util/exception.hh> #include <paludis/util/stringify.hh> @@ -44,178 +43,109 @@ using namespace paludis::erepository; namespace { - void cannot_add(const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> &) PALUDIS_ATTRIBUTE((noreturn)); + void cannot_add(const std::tr1::shared_ptr<const DependencySpecTree> &) PALUDIS_ATTRIBUTE((noreturn)); - void cannot_add(const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> &) + void cannot_add(const std::tr1::shared_ptr<const DependencySpecTree> &) { throw InternalError(PALUDIS_HERE, "Got weird tree"); } - struct Fixer : - ConstVisitor<DependencySpecTree> + struct Fixer { - std::list<std::pair< - std::tr1::shared_ptr<DependencySpecTree::ConstItem>, - std::tr1::function<void (const std::tr1::shared_ptr<DependencySpecTree::ConstItem> &)> > > stack; - - std::tr1::shared_ptr<const DependencySpecTree::ConstItem> result; + std::list<std::tr1::shared_ptr<DependencySpecTree::BasicInnerNode> > stack; + std::tr1::shared_ptr<DependencySpecTree> result; const Environment * const env; const EAPI & eapi; const std::tr1::shared_ptr<const PackageID> id; Fixer(const Environment * const e, const EAPI & a, const std::tr1::shared_ptr<const PackageID> & i) : + result(new DependencySpecTree(make_shared_ptr(new AllDepSpec))), env(e), eapi(a), id(i) { + stack.push_front(result->root()); } - void visit_sequence(const AllDepSpec & s, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) + void visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node) { - std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > c( - new ConstTreeSequence<DependencySpecTree, AllDepSpec>( - std::tr1::static_pointer_cast<AllDepSpec>(s.clone()))); - - if (! stack.empty()) - stack.begin()->second(c); - else - result = c; - - using namespace std::tr1::placeholders; - stack.push_front(std::make_pair(c, std::tr1::bind(&ConstTreeSequence<DependencySpecTree, AllDepSpec>::add, c.get(), _1))); - std::for_each(cur, end, accept_visitor(*this)); + std::tr1::shared_ptr<AllDepSpec> spec(std::tr1::static_pointer_cast<AllDepSpec>(node.spec()->clone())); + stack.push_front((*stack.begin())->append(spec)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); stack.pop_front(); } - void visit_sequence(const AnyDepSpec & s, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) + void visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node) { - std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AnyDepSpec> > c( - new ConstTreeSequence<DependencySpecTree, AnyDepSpec>( - std::tr1::static_pointer_cast<AnyDepSpec>(s.clone()))); - - if (! stack.empty()) - stack.begin()->second(c); - else - result = c; - - using namespace std::tr1::placeholders; - stack.push_front(std::make_pair(c, std::tr1::bind(&ConstTreeSequence<DependencySpecTree, AnyDepSpec>::add, c.get(), _1))); - std::for_each(cur, end, accept_visitor(*this)); + std::tr1::shared_ptr<AnyDepSpec> spec(std::tr1::static_pointer_cast<AnyDepSpec>(node.spec()->clone())); + stack.push_front((*stack.begin())->append(spec)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); stack.pop_front(); } - void visit_sequence(const ConditionalDepSpec & s, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) + void visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node) { - std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, ConditionalDepSpec> > c( - new ConstTreeSequence<DependencySpecTree, ConditionalDepSpec>( - std::tr1::static_pointer_cast<ConditionalDepSpec>(s.clone()))); - - if (! stack.empty()) - stack.begin()->second(c); - else - result = c; - - using namespace std::tr1::placeholders; - stack.push_front(std::make_pair(c, std::tr1::bind(&ConstTreeSequence<DependencySpecTree, ConditionalDepSpec>::add, c.get(), _1))); - std::for_each(cur, end, accept_visitor(*this)); + std::tr1::shared_ptr<ConditionalDepSpec> spec(std::tr1::static_pointer_cast<ConditionalDepSpec>(node.spec()->clone())); + stack.push_front((*stack.begin())->append(spec)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); stack.pop_front(); } - void visit_leaf(const PackageDepSpec & s) + void visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node) { - std::tr1::shared_ptr<TreeLeaf<DependencySpecTree, PackageDepSpec> > c; + std::tr1::shared_ptr<const PackageDepSpec> c; do { - if (! s.slot_requirement_ptr()) + if (! node.spec()->slot_requirement_ptr()) break; - const SlotAnyLockedRequirement * const r(simple_visitor_cast<const SlotAnyLockedRequirement>(*s.slot_requirement_ptr())); + const SlotAnyLockedRequirement * const r(simple_visitor_cast<const SlotAnyLockedRequirement>(*node.spec()->slot_requirement_ptr())); if (! r) break; std::tr1::shared_ptr<const PackageIDSequence> matches((*env)[selection::AllVersionsSorted( - generator::Matches(s, MatchPackageOptions()) | filter::InstalledAtRoot(FSEntry("/")))]); + generator::Matches(*node.spec(), MatchPackageOptions()) | filter::InstalledAtRoot(FSEntry("/")))]); if (matches->empty()) break; - PackageDepSpec new_s(PartiallyMadePackageDepSpec(s).slot_requirement( + PackageDepSpec new_s(PartiallyMadePackageDepSpec(*node.spec()).slot_requirement( make_shared_ptr(new ELikeSlotExactRequirement((*matches->last())->slot(), true)))); - c.reset(new TreeLeaf<DependencySpecTree, PackageDepSpec>(std::tr1::static_pointer_cast<PackageDepSpec>( - new_s.clone()))); + c.reset(new PackageDepSpec(new_s)); } while (false); if (! c) - c.reset(new TreeLeaf<DependencySpecTree, PackageDepSpec>(std::tr1::static_pointer_cast<PackageDepSpec>(s.clone()))); + c = node.spec(); - if (stack.empty()) - { - stack.push_front(std::make_pair(c, &cannot_add)); - result = c; - } - else - stack.begin()->second(c); + (*stack.begin())->append(c); } - void visit_leaf(const NamedSetDepSpec & s) + void visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & node) { - std::tr1::shared_ptr<TreeLeaf<DependencySpecTree, NamedSetDepSpec> > c( - new TreeLeaf<DependencySpecTree, NamedSetDepSpec>(std::tr1::static_pointer_cast<NamedSetDepSpec>(s.clone()))); - - if (stack.empty()) - { - stack.push_front(std::make_pair(c, &cannot_add)); - result = c; - } - else - stack.begin()->second(c); + (*stack.begin())->append(node.spec()); } - void visit_leaf(const BlockDepSpec & s) + void visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type & node) { - std::tr1::shared_ptr<TreeLeaf<DependencySpecTree, BlockDepSpec> > c( - new TreeLeaf<DependencySpecTree, BlockDepSpec>(std::tr1::static_pointer_cast<BlockDepSpec>(s.clone()))); - - if (stack.empty()) - { - stack.push_front(std::make_pair(c, &cannot_add)); - result = c; - } - else - stack.begin()->second(c); + (*stack.begin())->append(node.spec()); } - void visit_leaf(const DependencyLabelsDepSpec & s) + void visit(const DependencySpecTree::NodeType<DependencyLabelsDepSpec>::Type & node) { - std::tr1::shared_ptr<TreeLeaf<DependencySpecTree, DependencyLabelsDepSpec> > c( - new TreeLeaf<DependencySpecTree, DependencyLabelsDepSpec>(std::tr1::static_pointer_cast<DependencyLabelsDepSpec>(s.clone()))); - - if (stack.empty()) - { - stack.push_front(std::make_pair(c, &cannot_add)); - result = c; - } - else - stack.begin()->second(c); + (*stack.begin())->append(node.spec()); } }; } -const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> +const std::tr1::shared_ptr<const DependencySpecTree> paludis::erepository::fix_locked_dependencies( const Environment * const env, const EAPI & e, const std::tr1::shared_ptr<const PackageID> & id, - const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> & b) + const std::tr1::shared_ptr<const DependencySpecTree> & b) { Fixer f(env, e, id); - b->accept(f); + b->root()->accept(f); return f.result; } diff --git a/paludis/repositories/e/fix_locked_dependencies.hh b/paludis/repositories/e/fix_locked_dependencies.hh index 6ccbd4e92..379b0d3a1 100644 --- a/paludis/repositories/e/fix_locked_dependencies.hh +++ b/paludis/repositories/e/fix_locked_dependencies.hh @@ -24,17 +24,17 @@ #include <paludis/util/attributes.hh> #include <paludis/package_id-fwd.hh> #include <paludis/environment-fwd.hh> -#include <paludis/dep_tree.hh> +#include <paludis/spec_tree.hh> #include <tr1/memory> namespace paludis { namespace erepository { - const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> fix_locked_dependencies( + const std::tr1::shared_ptr<const DependencySpecTree> fix_locked_dependencies( const Environment * const env, const EAPI &, const std::tr1::shared_ptr<const PackageID> &, - const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> &) PALUDIS_VISIBLE; + const std::tr1::shared_ptr<const DependencySpecTree> &) PALUDIS_VISIBLE; } } diff --git a/paludis/repositories/e/fix_locked_dependencies_TEST.cc b/paludis/repositories/e/fix_locked_dependencies_TEST.cc index 6083d55df..6f44fb0ce 100644 --- a/paludis/repositories/e/fix_locked_dependencies_TEST.cc +++ b/paludis/repositories/e/fix_locked_dependencies_TEST.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008 Ciaran McCreesh + * Copyright (c) 2008, 2009 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 @@ -24,7 +24,6 @@ #include <paludis/repositories/fake/fake_package_id.hh> #include <paludis/repositories/fake/fake_repository.hh> #include <paludis/repositories/fake/fake_installed_repository.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/environments/test/test_environment.hh> #include <paludis/stringify_formatter.hh> #include <paludis/package_database.hh> @@ -54,7 +53,7 @@ namespace test_cases std::tr1::shared_ptr<const EAPI> eapi(EAPIData::get_instance()->eapi_from_string("paludis-1")); - std::tr1::shared_ptr<DependencySpecTree::ConstItem> bb(parse_depend( + std::tr1::shared_ptr<const DependencySpecTree> bb(parse_depend( "|| ( foo/bar ( bar/baz oink/squeak ) ) blah/blah", &env, id, *eapi)), aa(fix_locked_dependencies(&env, *eapi, id, bb)); @@ -62,20 +61,20 @@ namespace test_cases DepSpecPrettyPrinter a(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false), b(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); - aa->accept(a); - bb->accept(b); + aa->root()->accept(a); + bb->root()->accept(b); TEST_CHECK_STRINGIFY_EQUAL(a, b); - std::tr1::shared_ptr<DependencySpecTree::ConstItem> cc(parse_depend( + std::tr1::shared_ptr<const DependencySpecTree> cc(parse_depend( "foo/bar:= cat/installed:= >=cat/installed-1.2:= <=cat/installed-1.2:=", &env, id, *eapi)), dd(fix_locked_dependencies(&env, *eapi, id, cc)); DepSpecPrettyPrinter c(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false), d(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); - cc->accept(c); - dd->accept(d); + cc->root()->accept(c); + dd->root()->accept(d); TEST_CHECK_STRINGIFY_EQUAL(c, "foo/bar:= cat/installed:= >=cat/installed-1.2:= <=cat/installed-1.2:="); TEST_CHECK_STRINGIFY_EQUAL(d, "foo/bar:= cat/installed:=monkey >=cat/installed-1.2:= <=cat/installed-1.2:=monkey"); diff --git a/paludis/repositories/e/info_metadata_key.cc b/paludis/repositories/e/info_metadata_key.cc index a6f5f3506..8bd84eb96 100644 --- a/paludis/repositories/e/info_metadata_key.cc +++ b/paludis/repositories/e/info_metadata_key.cc @@ -31,7 +31,6 @@ #include <paludis/util/sequence.hh> #include <paludis/util/indirect_iterator-impl.hh> #include <paludis/util/join.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/literal_metadata_key.hh> #include <paludis/selection.hh> #include <paludis/generator.hh> diff --git a/paludis/repositories/e/myoptions_requirements_verifier.cc b/paludis/repositories/e/myoptions_requirements_verifier.cc index fd6ccfac7..fc85a08fd 100644 --- a/paludis/repositories/e/myoptions_requirements_verifier.cc +++ b/paludis/repositories/e/myoptions_requirements_verifier.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008 Ciaran McCreesh + * Copyright (c) 2008, 2009 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 @@ -22,7 +22,6 @@ #include <paludis/repositories/e/eapi.hh> #include <paludis/repositories/e/myoption.hh> #include <paludis/util/private_implementation_pattern-impl.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/stringify.hh> #include <paludis/util/simple_visitor_cast.hh> #include <paludis/util/tokeniser.hh> @@ -78,9 +77,9 @@ MyOptionsRequirementsVerifier::unmet_requirements() const } void -MyOptionsRequirementsVerifier::visit_leaf(const PlainTextLabelDepSpec & s) +MyOptionsRequirementsVerifier::visit(const PlainTextSpecTree::NodeType<PlainTextLabelDepSpec>::Type & node) { - *_imp->current_prefix_stack.begin() = ChoicePrefixName(s.label()); + *_imp->current_prefix_stack.begin() = ChoicePrefixName(node.spec()->label()); } namespace @@ -223,18 +222,18 @@ MyOptionsRequirementsVerifier::verify_one(const ChoicePrefixName & spec_prefix, } void -MyOptionsRequirementsVerifier::visit_leaf(const PlainTextDepSpec & s) +MyOptionsRequirementsVerifier::visit(const PlainTextSpecTree::NodeType<PlainTextDepSpec>::Type & node) { - Context context("When verifying requirements for item '" + stringify(s) + "':"); + Context context("When verifying requirements for item '" + stringify(*node.spec()) + "':"); for (std::list<ChildrenList>::iterator l(_imp->current_children_stack.begin()), l_end(_imp->current_children_stack.end()) ; l != l_end ; ++l) - l->push_back(std::make_pair(*_imp->current_prefix_stack.begin(), s.text())); + l->push_back(std::make_pair(*_imp->current_prefix_stack.begin(), node.spec()->text())); { Context local_context("When finding associated choice:"); - std::pair<UnprefixedChoiceName, bool> active_myoption(parse_myoption(s.text())); + std::pair<UnprefixedChoiceName, bool> active_myoption(parse_myoption(node.spec()->text())); ChoiceNameWithPrefix active_flag(( ! stringify(*_imp->current_prefix_stack.begin()).empty() ? stringify(*_imp->current_prefix_stack.begin()) + stringify(_imp->id->eapi()->supported()->choices_options()->use_expand_separator()) : "") + @@ -247,24 +246,22 @@ MyOptionsRequirementsVerifier::visit_leaf(const PlainTextDepSpec & s) ++*l; } - if ((! s.annotations_key()) || (s.annotations_key()->begin_metadata() == s.annotations_key()->end_metadata())) + if ((! node.spec()->annotations_key()) || (node.spec()->annotations_key()->begin_metadata() == node.spec()->annotations_key()->end_metadata())) return; - verify_one(*_imp->current_prefix_stack.begin(), s.text(), s.annotations_key()); + verify_one(*_imp->current_prefix_stack.begin(), node.spec()->text(), node.spec()->annotations_key()); } void -MyOptionsRequirementsVerifier::visit_sequence(const ConditionalDepSpec & spec, - PlainTextSpecTree::ConstSequenceIterator cur, - PlainTextSpecTree::ConstSequenceIterator end) +MyOptionsRequirementsVerifier::visit(const PlainTextSpecTree::NodeType<ConditionalDepSpec>::Type & node) { - if (spec.condition_met()) + if (node.spec()->condition_met()) { _imp->current_prefix_stack.push_front(*_imp->current_prefix_stack.begin()); _imp->current_children_stack.push_front(ChildrenList()); _imp->number_enabled_stack.push_front(0); - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); _imp->number_enabled_stack.pop_front(); _imp->current_children_stack.pop_front(); @@ -273,23 +270,21 @@ MyOptionsRequirementsVerifier::visit_sequence(const ConditionalDepSpec & spec, } void -MyOptionsRequirementsVerifier::visit_sequence(const AllDepSpec & s, - PlainTextSpecTree::ConstSequenceIterator cur, - PlainTextSpecTree::ConstSequenceIterator end) +MyOptionsRequirementsVerifier::visit(const PlainTextSpecTree::NodeType<AllDepSpec>::Type & node) { _imp->current_prefix_stack.push_front(*_imp->current_prefix_stack.begin()); _imp->current_children_stack.push_front(ChildrenList()); _imp->number_enabled_stack.push_front(0); - std::for_each(cur, end, accept_visitor(*this)); - if (s.annotations_key() && (s.annotations_key()->begin_metadata() != s.annotations_key()->end_metadata())) + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + if (node.spec()->annotations_key() && (node.spec()->annotations_key()->begin_metadata() != node.spec()->annotations_key()->end_metadata())) { for (ChildrenList::const_iterator i(_imp->current_children_stack.begin()->begin()), i_end(_imp->current_children_stack.begin()->end()) ; i != i_end ; ++i) - verify_one(i->first, i->second, s.annotations_key()); + verify_one(i->first, i->second, node.spec()->annotations_key()); - for (MetadataSectionKey::MetadataConstIterator m(s.annotations_key()->begin_metadata()), m_end(s.annotations_key()->end_metadata()) ; + for (MetadataSectionKey::MetadataConstIterator m(node.spec()->annotations_key()->begin_metadata()), m_end(node.spec()->annotations_key()->end_metadata()) ; m != m_end ; ++m) { const MetadataValueKey<std::string> * mm(simple_visitor_cast<const MetadataValueKey<std::string> >(**m)); diff --git a/paludis/repositories/e/myoptions_requirements_verifier.hh b/paludis/repositories/e/myoptions_requirements_verifier.hh index 28172e55d..b92fb2c26 100644 --- a/paludis/repositories/e/myoptions_requirements_verifier.hh +++ b/paludis/repositories/e/myoptions_requirements_verifier.hh @@ -21,12 +21,11 @@ #define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_MYOPTIONS_REQUIREMENTS_VERIFIER_HH 1 #include <paludis/repositories/e/e_repository_id.hh> -#include <paludis/util/visitor.hh> #include <paludis/util/sequence.hh> #include <paludis/util/private_implementation_pattern.hh> #include <paludis/util/attributes.hh> #include <paludis/dep_spec.hh> -#include <paludis/dep_tree.hh> +#include <paludis/spec_tree.hh> #include <tr1/memory> namespace paludis @@ -34,8 +33,7 @@ namespace paludis namespace erepository { class PALUDIS_VISIBLE MyOptionsRequirementsVerifier : - private PrivateImplementationPattern<MyOptionsRequirementsVerifier>, - public ConstVisitor<PlainTextSpecTree> + private PrivateImplementationPattern<MyOptionsRequirementsVerifier> { private: void verify_one(const ChoicePrefixName &, const std::string &, @@ -47,19 +45,10 @@ namespace paludis const std::tr1::shared_ptr<const Sequence<std::string> > unmet_requirements() const PALUDIS_ATTRIBUTE((warn_unused_result)); - void visit_leaf(const PlainTextLabelDepSpec &); - - void visit_leaf(const PlainTextDepSpec &); - - void visit_sequence(const ConditionalDepSpec &, - PlainTextSpecTree::ConstSequenceIterator, - PlainTextSpecTree::ConstSequenceIterator - ); - - void visit_sequence(const AllDepSpec &, - PlainTextSpecTree::ConstSequenceIterator, - PlainTextSpecTree::ConstSequenceIterator - ); + void visit(const PlainTextSpecTree::NodeType<PlainTextLabelDepSpec>::Type & node); + void visit(const PlainTextSpecTree::NodeType<PlainTextDepSpec>::Type & node); + void visit(const PlainTextSpecTree::NodeType<AllDepSpec>::Type & node); + void visit(const PlainTextSpecTree::NodeType<ConditionalDepSpec>::Type & node); }; } diff --git a/paludis/repositories/e/pipe_command_handler.cc b/paludis/repositories/e/pipe_command_handler.cc index 54072e2e5..e939478ea 100644 --- a/paludis/repositories/e/pipe_command_handler.cc +++ b/paludis/repositories/e/pipe_command_handler.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -30,9 +30,9 @@ #include <paludis/util/iterator_funcs.hh> #include <paludis/util/sequence.hh> #include <paludis/util/wrapped_forward_iterator.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/simple_visitor_cast.hh> #include <paludis/util/set.hh> +#include <paludis/util/indirect_iterator.hh> #include <paludis/package_id.hh> #include <paludis/environment.hh> #include <paludis/package_database.hh> @@ -274,13 +274,13 @@ paludis::erepository::pipe_command_handler(const Environment * const environment (var == eapi->supported()->ebuild_metadata_variables()->pdepend().name()) || (var == eapi->supported()->ebuild_metadata_variables()->dependencies().name())) { - std::tr1::shared_ptr<const DependencySpecTree::ConstItem> before(parse_depend(join(tokens.begin() + 4, tokens.end(), " "), + std::tr1::shared_ptr<const DependencySpecTree> before(parse_depend(join(tokens.begin() + 4, tokens.end(), " "), environment, package_id, *eapi)); - std::tr1::shared_ptr<const DependencySpecTree::ConstItem> after(fix_locked_dependencies( + std::tr1::shared_ptr<const DependencySpecTree> after(fix_locked_dependencies( environment, *eapi, package_id, before)); StringifyFormatter ff; DepSpecPrettyPrinter p(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); - after->accept(p); + after->root()->accept(p); return "O0;" + stringify(p); } @@ -331,4 +331,3 @@ paludis::erepository::pipe_command_handler(const Environment * const environment } } - diff --git a/paludis/repositories/e/pretend_fetch_visitor.cc b/paludis/repositories/e/pretend_fetch_visitor.cc index d32a3beee..cedd99905 100644 --- a/paludis/repositories/e/pretend_fetch_visitor.cc +++ b/paludis/repositories/e/pretend_fetch_visitor.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008 Ciaran McCreesh + * Copyright (c) 2008, 2009 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 @@ -25,7 +25,6 @@ #include <paludis/package_id.hh> #include <paludis/action.hh> #include <paludis/metadata_key.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/fs_entry.hh> #include <paludis/util/log.hh> @@ -93,47 +92,43 @@ PretendFetchVisitor::~PretendFetchVisitor() } void -PretendFetchVisitor::visit_sequence(const ConditionalDepSpec & u, - FetchableURISpecTree::ConstSequenceIterator cur, - FetchableURISpecTree::ConstSequenceIterator end) +PretendFetchVisitor::visit(const FetchableURISpecTree::NodeType<ConditionalDepSpec>::Type & node) { - if ((_imp->fetch_unneeded) || (u.condition_met())) + if ((_imp->fetch_unneeded) || (node.spec()->condition_met())) { _imp->labels.push_front(* _imp->labels.begin()); - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); _imp->labels.pop_front(); } } void -PretendFetchVisitor::visit_sequence(const AllDepSpec &, - FetchableURISpecTree::ConstSequenceIterator cur, - FetchableURISpecTree::ConstSequenceIterator end) +PretendFetchVisitor::visit(const FetchableURISpecTree::NodeType<AllDepSpec>::Type & node) { _imp->labels.push_front(* _imp->labels.begin()); - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); _imp->labels.pop_front(); } void -PretendFetchVisitor::visit_leaf(const URILabelsDepSpec & l) +PretendFetchVisitor::visit(const FetchableURISpecTree::NodeType<URILabelsDepSpec>::Type & node) { - for (URILabelsDepSpec::ConstIterator i(l.begin()), i_end(l.end()) ; + for (URILabelsDepSpec::ConstIterator i(node.spec()->begin()), i_end(node.spec()->end()) ; i != i_end ; ++i) *_imp->labels.begin() = i->get(); } void -PretendFetchVisitor::visit_leaf(const FetchableURIDepSpec & u) +PretendFetchVisitor::visit(const FetchableURISpecTree::NodeType<FetchableURIDepSpec>::Type & node) { - if (! _imp->already_done.insert(u.filename()).second) + if (! _imp->already_done.insert(node.spec()->filename()).second) return; - FSEntry destination(_imp->distdir / u.filename()); + FSEntry destination(_imp->distdir / node.spec()->filename()); if (destination.exists()) return; - Manifest2Reader::ConstIterator m(_imp->manifest.find("DIST", u.filename())); + Manifest2Reader::ConstIterator m(_imp->manifest.find("DIST", node.spec()->filename())); if (_imp->manifest.end() == m) return; diff --git a/paludis/repositories/e/pretend_fetch_visitor.hh b/paludis/repositories/e/pretend_fetch_visitor.hh index 3b770e0a2..e21f7e5e8 100644 --- a/paludis/repositories/e/pretend_fetch_visitor.hh +++ b/paludis/repositories/e/pretend_fetch_visitor.hh @@ -22,7 +22,8 @@ #include <paludis/action-fwd.hh> #include <paludis/dep_label-fwd.hh> -#include <paludis/dep_tree.hh> +#include <paludis/dep_spec.hh> +#include <paludis/spec_tree.hh> #include <paludis/package_id-fwd.hh> #include <paludis/repositories/e/eapi-fwd.hh> #include <paludis/util/fs_entry-fwd.hh> @@ -33,8 +34,7 @@ namespace paludis namespace erepository { class PALUDIS_VISIBLE PretendFetchVisitor : - private PrivateImplementationPattern<PretendFetchVisitor>, - public ConstVisitor<FetchableURISpecTree> + private PrivateImplementationPattern<PretendFetchVisitor> { public: PretendFetchVisitor( @@ -48,17 +48,10 @@ namespace paludis ~PretendFetchVisitor(); - void visit_sequence(const AllDepSpec &, - FetchableURISpecTree::ConstSequenceIterator, - FetchableURISpecTree::ConstSequenceIterator); - - void visit_sequence(const ConditionalDepSpec &, - FetchableURISpecTree::ConstSequenceIterator, - FetchableURISpecTree::ConstSequenceIterator); - - void visit_leaf(const URILabelsDepSpec &); - - void visit_leaf(const FetchableURIDepSpec &); + void visit(const FetchableURISpecTree::NodeType<ConditionalDepSpec>::Type & node); + void visit(const FetchableURISpecTree::NodeType<AllDepSpec>::Type & node); + void visit(const FetchableURISpecTree::NodeType<URILabelsDepSpec>::Type & node); + void visit(const FetchableURISpecTree::NodeType<FetchableURIDepSpec>::Type & node); }; } diff --git a/paludis/repositories/e/qa/extractors.cc b/paludis/repositories/e/qa/extractors.cc index ad1e0d979..e7c9ee2ec 100644 --- a/paludis/repositories/e/qa/extractors.cc +++ b/paludis/repositories/e/qa/extractors.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -25,7 +25,6 @@ #include <paludis/util/config_file.hh> #include <paludis/util/stringify.hh> #include <paludis/util/system.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/fs_entry.hh> #include <paludis/util/mutex.hh> #include <paludis/util/options.hh> @@ -70,21 +69,28 @@ namespace } }; - struct FlagExtractor : - ConstVisitor<GenericSpecTree>, - ConstVisitor<GenericSpecTree>::VisitConstSequence<FlagExtractor, AllDepSpec>, - ConstVisitor<GenericSpecTree>::VisitConstSequence<FlagExtractor, AnyDepSpec> + struct FlagExtractor { std::map<QualifiedPackageName, std::set<ChoiceNameWithPrefix> > relevant; std::set<ChoiceNameWithPrefix> current; std::set<QualifiedPackageName> needed_packages; - void visit_leaf(const FetchableURIDepSpec & u) + void visit(const GenericSpecTree::NodeType<AllDepSpec>::Type & node) { - std::string::size_type p(u.filename().rfind('.')); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + + void visit(const GenericSpecTree::NodeType<AnyDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + + void visit(const GenericSpecTree::NodeType<FetchableURIDepSpec>::Type & node) + { + std::string::size_type p(node.spec()->filename().rfind('.')); if (std::string::npos == p) return; - std::string extension(u.filename().substr(p + 1)); + std::string extension(node.spec()->filename().substr(p + 1)); std::string needed(ExtractorsRequirements::get_instance()->file->get(extension)); if (! needed.empty()) { @@ -93,60 +99,53 @@ namespace } } - void visit_leaf(const PackageDepSpec & p) + void visit(const GenericSpecTree::NodeType<PackageDepSpec>::Type & node) { - if (p.package_ptr() && needed_packages.count(*p.package_ptr())) - relevant[*p.package_ptr()].insert(current.begin(), current.end()); + if (node.spec()->package_ptr() && needed_packages.count(*node.spec()->package_ptr())) + relevant[*node.spec()->package_ptr()].insert(current.begin(), current.end()); } - void visit_leaf(const BlockDepSpec &) + void visit(const GenericSpecTree::NodeType<BlockDepSpec>::Type &) { } - void visit_leaf(const URILabelsDepSpec &) + void visit(const GenericSpecTree::NodeType<URILabelsDepSpec>::Type &) { } - void visit_leaf(const DependencyLabelsDepSpec &) + void visit(const GenericSpecTree::NodeType<DependencyLabelsDepSpec>::Type &) { } - void visit_leaf(const PlainTextDepSpec &) + void visit(const GenericSpecTree::NodeType<PlainTextDepSpec>::Type &) { } - void visit_sequence(const ConditionalDepSpec & u, - GenericSpecTree::ConstSequenceIterator cur, - GenericSpecTree::ConstSequenceIterator end) + void visit(const GenericSpecTree::NodeType<ConditionalDepSpec>::Type & node) { Save<std::set<ChoiceNameWithPrefix> > save_current(¤t); - current.insert(elike_conditional_dep_spec_flag(u)); - std::for_each(cur, end, accept_visitor(*this)); + current.insert(elike_conditional_dep_spec_flag(*node.spec())); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } - void visit_leaf(const LicenseDepSpec &) + void visit(const GenericSpecTree::NodeType<LicenseDepSpec>::Type &) { } - void visit_leaf(const SimpleURIDepSpec &) + void visit(const GenericSpecTree::NodeType<SimpleURIDepSpec>::Type &) { } - void visit_leaf(const PlainTextLabelDepSpec &) + void visit(const GenericSpecTree::NodeType<PlainTextLabelDepSpec>::Type &) { } - void visit_leaf(const NamedSetDepSpec &) + void visit(const GenericSpecTree::NodeType<NamedSetDepSpec>::Type &) { } - - using ConstVisitor<GenericSpecTree>::VisitConstSequence<FlagExtractor, AllDepSpec>::visit_sequence; - using ConstVisitor<GenericSpecTree>::VisitConstSequence<FlagExtractor, AnyDepSpec>::visit_sequence; }; - struct Requirements : - ConstVisitor<GenericSpecTree>, - ConstVisitor<GenericSpecTree>::VisitConstSequence<Requirements, AllDepSpec> + struct Requirements { const QualifiedPackageName & name; const std::set<ChoiceNameWithPrefix> & relevant; @@ -185,12 +184,17 @@ namespace requirements.insert(new_requirements.begin(), new_requirements.end()); } - void visit_leaf(const FetchableURIDepSpec & u) + void visit(const GenericSpecTree::NodeType<AllDepSpec>::Type & node) { - std::string::size_type p(u.filename().rfind('.')); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + + void visit(const GenericSpecTree::NodeType<FetchableURIDepSpec>::Type & node) + { + std::string::size_type p(node.spec()->filename().rfind('.')); if (std::string::npos == p) return; - std::string extension(u.filename().substr(p + 1)); + std::string extension(node.spec()->filename().substr(p + 1)); std::string needed(ExtractorsRequirements::get_instance()->file->get(extension)); if (needed.empty() || QualifiedPackageName(needed) != name) return; @@ -198,62 +202,56 @@ namespace add_requirements(); } - void visit_leaf(const SimpleURIDepSpec &) + void visit(const GenericSpecTree::NodeType<SimpleURIDepSpec>::Type &) { } - void visit_leaf(const PackageDepSpec & p) + void visit(const GenericSpecTree::NodeType<PackageDepSpec>::Type & node) { - if ((! p.package_ptr()) || (name != *p.package_ptr())) + if ((! node.spec()->package_ptr()) || (name != *node.spec()->package_ptr())) return; add_requirements(); } - void visit_leaf(const PlainTextLabelDepSpec &) + void visit(const GenericSpecTree::NodeType<PlainTextLabelDepSpec>::Type &) { } - void visit_leaf(const URILabelsDepSpec &) + void visit(const GenericSpecTree::NodeType<URILabelsDepSpec>::Type &) { } - void visit_leaf(const DependencyLabelsDepSpec &) + void visit(const GenericSpecTree::NodeType<DependencyLabelsDepSpec>::Type &) { } - void visit_leaf(const BlockDepSpec &) + void visit(const GenericSpecTree::NodeType<BlockDepSpec>::Type &) { } - void visit_leaf(const PlainTextDepSpec &) + void visit(const GenericSpecTree::NodeType<PlainTextDepSpec>::Type &) { } - void visit_leaf(const LicenseDepSpec &) + void visit(const GenericSpecTree::NodeType<LicenseDepSpec>::Type &) { } - void visit_leaf(const NamedSetDepSpec &) + void visit(const GenericSpecTree::NodeType<NamedSetDepSpec>::Type &) { } - using ConstVisitor<GenericSpecTree>::VisitConstSequence<Requirements, AllDepSpec>::visit_sequence; - - void visit_sequence(const ConditionalDepSpec & u, - GenericSpecTree::ConstSequenceIterator cur, - GenericSpecTree::ConstSequenceIterator end) + void visit(const GenericSpecTree::NodeType<ConditionalDepSpec>::Type & node) { Save<std::map<ChoiceNameWithPrefix, bool> > save_current(¤t); std::pair<std::map<ChoiceNameWithPrefix, bool>::const_iterator, bool> p(current.insert(std::make_pair( - elike_conditional_dep_spec_flag(u), ! elike_conditional_dep_spec_is_inverse(u)))); - if (p.second || (p.first->second == ! elike_conditional_dep_spec_is_inverse(u))) - std::for_each(cur, end, accept_visitor(*this)); + elike_conditional_dep_spec_flag(*node.spec()), ! elike_conditional_dep_spec_is_inverse(*node.spec())))); + if (p.second || (p.first->second == ! elike_conditional_dep_spec_is_inverse(*node.spec()))) + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } - void visit_sequence(const AnyDepSpec &, - GenericSpecTree::ConstSequenceIterator, - GenericSpecTree::ConstSequenceIterator) + void visit(const GenericSpecTree::NodeType<AnyDepSpec>::Type &) { } }; @@ -278,9 +276,9 @@ paludis::erepository::extractors_check( * since it needs to work with USE_EXPAND and it's potentially * O(2^n). */ FlagExtractor f; - id->fetches_key()->value()->accept(f); + id->fetches_key()->value()->root()->accept(f); if (id->build_dependencies_key()) - id->build_dependencies_key()->value()->accept(f); + id->build_dependencies_key()->value()->root()->accept(f); for (std::map<QualifiedPackageName, std::set<ChoiceNameWithPrefix> >::const_iterator r(f.relevant.begin()), r_end(f.relevant.end()) ; @@ -297,12 +295,12 @@ paludis::erepository::extractors_check( /* Find the set of requirements. */ Requirements q(r->first, r->second); - id->fetches_key()->value()->accept(q); + id->fetches_key()->value()->root()->accept(q); /* Find the set of met requirements. */ Requirements m(r->first, r->second); if (id->build_dependencies_key()) - id->build_dependencies_key()->value()->accept(m); + id->build_dependencies_key()->value()->root()->accept(m); /* Find the set of unmet requirements */ std::set<std::map<ChoiceNameWithPrefix, bool> > unmet; diff --git a/paludis/repositories/e/qa/fetches_key.cc b/paludis/repositories/e/qa/fetches_key.cc index 2d1dd9133..926b49fab 100644 --- a/paludis/repositories/e/qa/fetches_key.cc +++ b/paludis/repositories/e/qa/fetches_key.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh + * Copyright (c) 2006, 2007, 2008, 2009 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,7 +21,6 @@ #include <paludis/qa.hh> #include <paludis/metadata_key.hh> #include <paludis/util/stringify.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/log.hh> #include <paludis/util/save.hh> #include <paludis/name.hh> @@ -75,7 +74,7 @@ namespace } }; - struct Checker : ConstVisitor<FetchableURISpecTree> + struct Checker { QAReporter & reporter; bool fetch_restrict; @@ -97,48 +96,48 @@ namespace { } - void visit_leaf(const FetchableURIDepSpec & a) + void visit(const FetchableURISpecTree::NodeType<FetchableURIDepSpec>::Type & node) { std::string::size_type p(std::string::npos); - if (std::string::npos == ((p = a.original_url().find("://"))) && ! fetch_restrict) + if (std::string::npos == ((p = node.spec()->original_url().find("://"))) && ! fetch_restrict) reporter.message(QAMessage(entry, qaml_normal, name, - "No protocol found for '" + a.original_url() + + "No protocol found for '" + node.spec()->original_url() + "' and not fetch restricted in '" + key->raw_name() + "'") .with_associated_id(id) .with_associated_key(id, key)); else if ((std::string::npos != p) && - (("http" != a.original_url().substr(0, p)) && - ("https" != a.original_url().substr(0, p)) && - ("mirror" != a.original_url().substr(0, p)) && - ("ftp" != a.original_url().substr(0, p)))) + (("http" != node.spec()->original_url().substr(0, p)) && + ("https" != node.spec()->original_url().substr(0, p)) && + ("mirror" != node.spec()->original_url().substr(0, p)) && + ("ftp" != node.spec()->original_url().substr(0, p)))) reporter.message(QAMessage(entry, qaml_normal, name, - "Unrecognised protocol for '" + a.original_url() + + "Unrecognised protocol for '" + node.spec()->original_url() + "' in '" + key->raw_name() + "'") .with_associated_id(id) .with_associated_key(id, key)); - else if ((std::string::npos != a.original_url().find("dev.gentoo.org")) || - (std::string::npos != a.original_url().find("cvs.gentoo.org")) || - (std::string::npos != a.original_url().find("toucan.gentoo.org")) || - (std::string::npos != a.original_url().find("emu.gentoo.org")) || - (std::string::npos != a.original_url().find("alpha.gnu.org")) || - (std::string::npos != a.original_url().find("geocities.com"))) + else if ((std::string::npos != node.spec()->original_url().find("dev.gentoo.org")) || + (std::string::npos != node.spec()->original_url().find("cvs.gentoo.org")) || + (std::string::npos != node.spec()->original_url().find("toucan.gentoo.org")) || + (std::string::npos != node.spec()->original_url().find("emu.gentoo.org")) || + (std::string::npos != node.spec()->original_url().find("alpha.gnu.org")) || + (std::string::npos != node.spec()->original_url().find("geocities.com"))) reporter.message(QAMessage(entry, qaml_normal, name, - "Unreliable host for '" + a.original_url() + "' in '" + + "Unreliable host for '" + node.spec()->original_url() + "' in '" + key->raw_name() + "'") .with_associated_id(id) .with_associated_key(id, key)); else { - if (0 == a.original_url().compare(0, 9, "mirror://")) + if (0 == node.spec()->original_url().compare(0, 9, "mirror://")) { - std::string mirror_host(a.original_url().substr(9)); + std::string mirror_host(node.spec()->original_url().substr(9)); std::string::size_type pos(mirror_host.find('/')); if (std::string::npos == pos) reporter.message(QAMessage(entry, qaml_normal, name, - "Malformed component '" + a.original_url() + "' in '" + + "Malformed component '" + node.spec()->original_url() + "' in '" + key->raw_name() + "'") .with_associated_id(id) .with_associated_key(id, key)); @@ -149,7 +148,7 @@ namespace if (! m->is_mirror(mirror_host)) reporter.message(QAMessage(entry, qaml_normal, name, "Unknown mirror '" + mirror_host + "' for '" + - a.original_url() + "' in '" + key->raw_name() + "'") + node.spec()->original_url() + "' in '" + key->raw_name() + "'") .with_associated_id(id) .with_associated_key(id, key)); } @@ -157,28 +156,24 @@ namespace } } - void visit_leaf(const URILabelsDepSpec & a) + void visit(const FetchableURISpecTree::NodeType<URILabelsDepSpec>::Type & node) { - if (1 != std::distance(a.begin(), a.end())) + if (1 != std::distance(node.spec()->begin(), node.spec()->end())) throw InternalError(PALUDIS_HERE, "URILabelsDepSpec contains " + - stringify(std::distance(a.begin(), a.end())) + " labels, but expected 1"); - fetch_restrict = LabelToFetchRestrict(**a.begin()).value; + stringify(std::distance(node.spec()->begin(), node.spec()->end())) + " labels, but expected 1"); + fetch_restrict = LabelToFetchRestrict(**node.spec()->begin()).value; } - void visit_sequence(const AllDepSpec &, - FetchableURISpecTree::ConstSequenceIterator begin, - FetchableURISpecTree::ConstSequenceIterator end) + void visit(const FetchableURISpecTree::NodeType<AllDepSpec>::Type & node) { Save<bool> s(&fetch_restrict); - std::for_each(begin, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } - void visit_sequence(const ConditionalDepSpec &, - FetchableURISpecTree::ConstSequenceIterator begin, - FetchableURISpecTree::ConstSequenceIterator end) + void visit(const FetchableURISpecTree::NodeType<ConditionalDepSpec>::Type & node) { Save<bool> s(&fetch_restrict); - std::for_each(begin, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } }; } @@ -200,7 +195,7 @@ paludis::erepository::fetches_key_check( { Checker c(reporter, LabelToFetchRestrict(*id->fetches_key()->initial_label()).value, id, id->fetches_key(), entry, name); - id->fetches_key()->value()->accept(c); + id->fetches_key()->value()->root()->accept(c); } catch (const InternalError &) { diff --git a/paludis/repositories/e/qa/homepage_key.cc b/paludis/repositories/e/qa/homepage_key.cc index 018a932f3..471002808 100644 --- a/paludis/repositories/e/qa/homepage_key.cc +++ b/paludis/repositories/e/qa/homepage_key.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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,7 +21,6 @@ #include <paludis/qa.hh> #include <paludis/metadata_key.hh> #include <paludis/util/stringify.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/log.hh> #include <paludis/name.hh> #include <paludis/dep_spec.hh> @@ -33,14 +32,8 @@ using namespace paludis::erepository; namespace { - struct HomepageChecker : - ConstVisitor<SimpleURISpecTree>, - ConstVisitor<SimpleURISpecTree>::VisitConstSequence<HomepageChecker, AllDepSpec>, - ConstVisitor<SimpleURISpecTree>::VisitConstSequence<HomepageChecker, ConditionalDepSpec> + struct HomepageChecker { - using ConstVisitor<SimpleURISpecTree>::VisitConstSequence<HomepageChecker, ConditionalDepSpec>::visit_sequence; - using ConstVisitor<SimpleURISpecTree>::VisitConstSequence<HomepageChecker, AllDepSpec>::visit_sequence; - const std::tr1::shared_ptr<const MetadataKey> & key; const FSEntry entry; QAReporter & reporter; @@ -71,18 +64,28 @@ namespace .with_associated_key(id, key)); } - void visit_leaf(const SimpleURIDepSpec & u) + void visit(const SimpleURISpecTree::NodeType<SimpleURIDepSpec>::Type & node) { found_one = true; - if (0 != u.text().compare(0, 7, "http://") && - 0 != u.text().compare(0, 8, "https://") && - 0 != u.text().compare(0, 6, "ftp://")) + if (0 != node.spec()->text().compare(0, 7, "http://") && + 0 != node.spec()->text().compare(0, 8, "https://") && + 0 != node.spec()->text().compare(0, 6, "ftp://")) reporter.message(QAMessage(entry, qaml_normal, name, - "Homepage uses no or unknown protocol in part '" + u.text() + "'") + "Homepage uses no or unknown protocol in part '" + node.spec()->text() + "'") .with_associated_id(id) .with_associated_key(id, key)); } + + void visit(const SimpleURISpecTree::NodeType<AllDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + + void visit(const SimpleURISpecTree::NodeType<ConditionalDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } }; } @@ -103,10 +106,9 @@ paludis::erepository::homepage_key_check( else { HomepageChecker h(id->homepage_key(), entry, reporter, id, name); - id->homepage_key()->value()->accept(h); + id->homepage_key()->value()->root()->accept(h); } return true; } - diff --git a/paludis/repositories/e/qa/inherited_key.cc b/paludis/repositories/e/qa/inherited_key.cc index 83a529a84..8bbd167f0 100644 --- a/paludis/repositories/e/qa/inherited_key.cc +++ b/paludis/repositories/e/qa/inherited_key.cc @@ -27,8 +27,6 @@ #include <paludis/util/stringify.hh> #include <paludis/util/set.hh> #include <paludis/util/sequence.hh> -#include <paludis/util/visitor-impl.hh> -#include <paludis/util/visitor_cast.hh> #include <paludis/util/log.hh> #include <paludis/util/system.hh> #include <paludis/package_id.hh> diff --git a/paludis/repositories/e/qa/keywords_key.cc b/paludis/repositories/e/qa/keywords_key.cc index d7c565e06..ddb2b0420 100644 --- a/paludis/repositories/e/qa/keywords_key.cc +++ b/paludis/repositories/e/qa/keywords_key.cc @@ -24,7 +24,6 @@ #include <paludis/util/set.hh> #include <paludis/util/sequence.hh> #include <paludis/util/log.hh> -#include <paludis/util/visitor_cast.hh> #include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/package_id.hh> #include <paludis/name.hh> diff --git a/paludis/repositories/e/qa/license_key.cc b/paludis/repositories/e/qa/license_key.cc index 30f9b02c5..b3277c0e6 100644 --- a/paludis/repositories/e/qa/license_key.cc +++ b/paludis/repositories/e/qa/license_key.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh + * Copyright (c) 2006, 2007, 2008, 2009 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 @@ -23,11 +23,9 @@ #include <paludis/util/stringify.hh> #include <paludis/util/log.hh> #include <paludis/util/sequence.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/package_id.hh> #include <paludis/name.hh> #include <paludis/dep_spec.hh> -#include <paludis/dep_tree.hh> #include <paludis/util/fs_entry.hh> using namespace paludis; @@ -35,11 +33,7 @@ using namespace paludis::erepository; namespace { - struct Checker : - ConstVisitor<LicenseSpecTree>, - ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, AllDepSpec>, - ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, AnyDepSpec>, - ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, ConditionalDepSpec> + struct Checker { const FSEntry & entry; QAReporter & reporter; @@ -57,22 +51,33 @@ namespace { } - using ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, AllDepSpec>::visit_sequence; - using ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, AnyDepSpec>::visit_sequence; - using ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, ConditionalDepSpec>::visit_sequence; - - void visit_leaf(const LicenseDepSpec & l) + void visit(const LicenseSpecTree::NodeType<LicenseDepSpec>::Type & node) { for (FSEntrySequence::ConstIterator it(dirs->begin()), it_end(dirs->end()); it_end != it; ++it) - if (((*it) / l.text()).is_regular_file_or_symlink_to_regular_file()) + if (((*it) / node.spec()->text()).is_regular_file_or_symlink_to_regular_file()) return; reporter.message(QAMessage(entry, qaml_normal, name, - "Item '" + l.text() + "' in '" + id->license_key()->raw_name() + "' is not a licence") + "Item '" + node.spec()->text() + "' in '" + id->license_key()->raw_name() + "' is not a licence") .with_associated_id(id) .with_associated_key(id, id->license_key())); } + + void visit(const LicenseSpecTree::NodeType<AnyDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + + void visit(const LicenseSpecTree::NodeType<AllDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + + void visit(const LicenseSpecTree::NodeType<ConditionalDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } }; } @@ -93,7 +98,7 @@ paludis::erepository::license_key_check( try { Checker c(entry, reporter, id, repo->layout()->licenses_dirs(), name); - id->license_key()->value()->accept(c); + id->license_key()->value()->root()->accept(c); } catch (const InternalError &) { diff --git a/paludis/repositories/e/qa/manifest.cc b/paludis/repositories/e/qa/manifest.cc index 1631478d0..ad2f96752 100644 --- a/paludis/repositories/e/qa/manifest.cc +++ b/paludis/repositories/e/qa/manifest.cc @@ -21,14 +21,13 @@ #include <iostream> #include "manifest.hh" #include <paludis/qa.hh> -#include <paludis/dep_tree.hh> +#include <paludis/spec_tree.hh> #include <paludis/metadata_key.hh> #include <paludis/util/log.hh> #include <paludis/util/system.hh> #include <paludis/util/map.hh> #include <paludis/util/member_iterator-impl.hh> #include <paludis/util/set.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/wrapped_forward_iterator-impl.hh> #include <paludis/util/sha1.hh> #include <paludis/util/sha256.hh> @@ -50,17 +49,11 @@ using namespace paludis::erepository; namespace { - struct DistfilesCollector : - ConstVisitor<FetchableURISpecTree>, - ConstVisitor<FetchableURISpecTree>::VisitConstSequence<DistfilesCollector, AllDepSpec>, - ConstVisitor<FetchableURISpecTree>::VisitConstSequence<DistfilesCollector, ConditionalDepSpec> + struct DistfilesCollector { std::tr1::shared_ptr<const PackageID> id; std::map<std::string, std::tr1::shared_ptr<PackageIDSet> > & distfiles; - using ConstVisitor<FetchableURISpecTree>::VisitConstSequence<DistfilesCollector, AllDepSpec>::visit_sequence; - using ConstVisitor<FetchableURISpecTree>::VisitConstSequence<DistfilesCollector, ConditionalDepSpec>::visit_sequence; - DistfilesCollector(const std::tr1::shared_ptr<const PackageID> & i, std::map<std::string, std::tr1::shared_ptr<PackageIDSet> > & d) : id(i), @@ -68,18 +61,27 @@ namespace { } - void visit_leaf(const URILabelsDepSpec &) + void visit(const FetchableURISpecTree::NodeType<AllDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + + void visit(const FetchableURISpecTree::NodeType<ConditionalDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + + void visit(const FetchableURISpecTree::NodeType<URILabelsDepSpec>::Type &) { } - void visit_leaf(const FetchableURIDepSpec & u) + void visit(const FetchableURISpecTree::NodeType<FetchableURIDepSpec>::Type & node) { - std::map<std::string, std::tr1::shared_ptr<PackageIDSet> >::iterator it( - distfiles.find(u.filename())); + std::map<std::string, std::tr1::shared_ptr<PackageIDSet> >::iterator it(distfiles.find(node.spec()->filename())); if (distfiles.end() == it) { std::tr1::shared_ptr<PackageIDSet> set(new PackageIDSet); - it = distfiles.insert(std::make_pair(u.filename(), set)).first; + it = distfiles.insert(std::make_pair(node.spec()->filename(), set)).first; } it->second->insert(id); } @@ -247,7 +249,7 @@ paludis::erepository::manifest_check( if ((*it)->fetches_key()) { DistfilesCollector c(*it, checker.distfiles); - (*it)->fetches_key()->value()->accept(c); + (*it)->fetches_key()->value()->root()->accept(c); } } diff --git a/paludis/repositories/e/qa/metadata_keys.cc b/paludis/repositories/e/qa/metadata_keys.cc index ae49b7db3..70806219a 100644 --- a/paludis/repositories/e/qa/metadata_keys.cc +++ b/paludis/repositories/e/qa/metadata_keys.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh * Copyright (c) 2008 David Leverton * * This file is part of the Paludis package manager. Paludis is free software; @@ -23,7 +23,6 @@ #include <paludis/metadata_key.hh> #include <paludis/qa.hh> #include <paludis/dep_spec.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/fs_entry.hh> #include <paludis/util/log.hh> #include <paludis/util/set.hh> @@ -77,32 +76,32 @@ namespace void visit(const MetadataSpecTreeKey<PlainTextSpecTree> & k) { - const std::tr1::shared_ptr<PlainTextSpecTree::ConstItem> & PALUDIS_ATTRIBUTE((unused)) t(k.value()); + const std::tr1::shared_ptr<const PlainTextSpecTree> & PALUDIS_ATTRIBUTE((unused)) t(k.value()); } void visit(const MetadataSpecTreeKey<ProvideSpecTree> & k) { - const std::tr1::shared_ptr<ProvideSpecTree::ConstItem> & PALUDIS_ATTRIBUTE((unused)) t(k.value()); + const std::tr1::shared_ptr<const ProvideSpecTree> & PALUDIS_ATTRIBUTE((unused)) t(k.value()); } void visit(const MetadataSpecTreeKey<FetchableURISpecTree> & k) { - const std::tr1::shared_ptr<FetchableURISpecTree::ConstItem> & PALUDIS_ATTRIBUTE((unused)) t(k.value()); + const std::tr1::shared_ptr<const FetchableURISpecTree> & PALUDIS_ATTRIBUTE((unused)) t(k.value()); } void visit(const MetadataSpecTreeKey<SimpleURISpecTree> & k) { - const std::tr1::shared_ptr<SimpleURISpecTree::ConstItem> & PALUDIS_ATTRIBUTE((unused)) t(k.value()); + const std::tr1::shared_ptr<const SimpleURISpecTree> & PALUDIS_ATTRIBUTE((unused)) t(k.value()); } void visit(const MetadataSpecTreeKey<LicenseSpecTree> & k) { - const std::tr1::shared_ptr<LicenseSpecTree::ConstItem> & PALUDIS_ATTRIBUTE((unused)) t(k.value()); + const std::tr1::shared_ptr<const LicenseSpecTree> & PALUDIS_ATTRIBUTE((unused)) t(k.value()); } void visit(const MetadataSpecTreeKey<DependencySpecTree> & k) { - const std::tr1::shared_ptr<DependencySpecTree::ConstItem> & PALUDIS_ATTRIBUTE((unused)) t(k.value()); + const std::tr1::shared_ptr<const DependencySpecTree> & PALUDIS_ATTRIBUTE((unused)) t(k.value()); } void visit(const MetadataCollectionKey<PackageIDSequence> & k) diff --git a/paludis/repositories/e/qa/restrict_key.cc b/paludis/repositories/e/qa/restrict_key.cc index b2ee1152f..eb006aefd 100644 --- a/paludis/repositories/e/qa/restrict_key.cc +++ b/paludis/repositories/e/qa/restrict_key.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh + * Copyright (c) 2006, 2007, 2008, 2009 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 @@ -20,7 +20,6 @@ #include "restrict_key.hh" #include <paludis/qa.hh> #include <paludis/metadata_key.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/log.hh> #include <paludis/util/instantiation_policy-impl.hh> #include <paludis/name.hh> @@ -53,14 +52,8 @@ namespace } }; - struct RestrictChecker : - ConstVisitor<PlainTextSpecTree>, - ConstVisitor<PlainTextSpecTree>::VisitConstSequence<RestrictChecker, AllDepSpec>, - ConstVisitor<PlainTextSpecTree>::VisitConstSequence<RestrictChecker, ConditionalDepSpec> + struct RestrictChecker { - using ConstVisitor<PlainTextSpecTree>::VisitConstSequence<RestrictChecker, ConditionalDepSpec>::visit_sequence; - using ConstVisitor<PlainTextSpecTree>::VisitConstSequence<RestrictChecker, AllDepSpec>::visit_sequence; - const std::set<std::string> & allowed_restricts; const std::tr1::shared_ptr<const MetadataKey> & key; @@ -84,28 +77,38 @@ namespace { } - void visit_leaf(const PlainTextLabelDepSpec & t) + void visit(const PlainTextSpecTree::NodeType<PlainTextLabelDepSpec>::Type & node) { reporter.message(QAMessage(entry, qaml_normal, name, - "Unexpected label '" + stringify(t) + "' in '" + key->raw_name() + "@") + "Unexpected label '" + stringify(node.spec()->text()) + "' in '" + key->raw_name() + "@") .with_associated_id(id) .with_associated_key(id, key)); } - void visit_leaf(const PlainTextDepSpec & t) + void visit(const PlainTextSpecTree::NodeType<PlainTextDepSpec>::Type & node) { - if (allowed_restricts.end() == allowed_restricts.find(t.text())) + if (allowed_restricts.end() == allowed_restricts.find(node.spec()->text())) reporter.message(QAMessage(entry, qaml_normal, name, - "Unrecognised value '" + t.text() + "' in '" + key->raw_name() + "'") + "Unrecognised value '" + node.spec()->text() + "' in '" + key->raw_name() + "'") .with_associated_id(id) .with_associated_key(id, key)); - else if (0 == t.text().compare(0, 2, "no")) + else if (0 == node.spec()->text().compare(0, 2, "no")) reporter.message(QAMessage(entry, qaml_minor, name, - "Deprecated value '" + t.text() + "' in '" + key->raw_name() + "' (use '" + t.text().substr(2) + "' instead)") + "Deprecated value '" + node.spec()->text() + "' in '" + key->raw_name() + "' (use '" + node.spec()->text().substr(2) + "' instead)") .with_associated_id(id) .with_associated_key(id, key)); } + + void visit(const PlainTextSpecTree::NodeType<AllDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + + void visit(const PlainTextSpecTree::NodeType<ConditionalDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } }; } @@ -123,7 +126,7 @@ paludis::erepository::restrict_key_check( if (id->restrict_key()) { RestrictChecker r(id->restrict_key(), entry, reporter, id, name); - id->restrict_key()->value()->accept(r); + id->restrict_key()->value()->root()->accept(r); } return true; diff --git a/paludis/repositories/e/qa/spec_keys.cc b/paludis/repositories/e/qa/spec_keys.cc index 05fc9fe76..717331d62 100644 --- a/paludis/repositories/e/qa/spec_keys.cc +++ b/paludis/repositories/e/qa/spec_keys.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -31,7 +31,6 @@ #include <paludis/util/save.hh> #include <paludis/util/set.hh> #include <paludis/util/system.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/fs_entry.hh> #include <paludis/util/iterator_funcs.hh> #include <paludis/util/mutex.hh> @@ -39,6 +38,8 @@ #include <paludis/util/log.hh> #include <paludis/util/instantiation_policy-impl.hh> #include <paludis/util/create_iterator-impl.hh> +#include <paludis/util/wrapped_forward_iterator.hh> +#include <paludis/util/wrapped_output_iterator.hh> #include <paludis/elike_conditional_dep_spec.hh> #include <algorithm> #include <map> @@ -85,8 +86,7 @@ namespace } }; - struct Checker : - ConstVisitor<GenericSpecTree> + struct Checker { const FSEntry entry; QAReporter & reporter; @@ -121,62 +121,60 @@ namespace { } - void visit_leaf(const PackageDepSpec & p) + void visit(const GenericSpecTree::NodeType<PackageDepSpec>::Type & node) { - if (pds_blacklist && p.package_ptr()) + if (pds_blacklist && node.spec()->package_ptr()) { - if (pds_blacklist->end() != pds_blacklist->find(*p.package_ptr())) - reporter.message(QAMessage(entry, qaml_maybe, name, "Package '" + stringify(p) + if (pds_blacklist->end() != pds_blacklist->find(*node.spec()->package_ptr())) + reporter.message(QAMessage(entry, qaml_maybe, name, "Package '" + stringify(*node.spec()) + "' blacklisted in '" + stringify(key->raw_name()) + "'") .with_associated_id(id) .with_associated_key(id, key)); } } - void visit_leaf(const BlockDepSpec & b) + void visit(const GenericSpecTree::NodeType<BlockDepSpec>::Type & node) { if (child_of_any) reporter.message(QAMessage(entry, qaml_normal, name, "'|| ( )' with block child '" - + stringify(b) + "' in '" + stringify(key->raw_name()) + "'") + + stringify(*node.spec()) + "' in '" + stringify(key->raw_name()) + "'") .with_associated_id(id) .with_associated_key(id, key)); } - void visit_leaf(const SimpleURIDepSpec &) + void visit(const GenericSpecTree::NodeType<SimpleURIDepSpec>::Type &) { } - void visit_leaf(const FetchableURIDepSpec &) + void visit(const GenericSpecTree::NodeType<FetchableURIDepSpec>::Type &) { } - void visit_leaf(const PlainTextDepSpec &) + void visit(const GenericSpecTree::NodeType<PlainTextDepSpec>::Type &) { } - void visit_leaf(const PlainTextLabelDepSpec &) + void visit(const GenericSpecTree::NodeType<PlainTextLabelDepSpec>::Type &) { } - void visit_leaf(const URILabelsDepSpec &) + void visit(const GenericSpecTree::NodeType<URILabelsDepSpec>::Type &) { } - void visit_leaf(const DependencyLabelsDepSpec &) + void visit(const GenericSpecTree::NodeType<DependencyLabelsDepSpec>::Type &) { } - void visit_leaf(const LicenseDepSpec &) + void visit(const GenericSpecTree::NodeType<LicenseDepSpec>::Type &) { } - void visit_leaf(const NamedSetDepSpec &) + void visit(const GenericSpecTree::NodeType<NamedSetDepSpec>::Type &) { } - void visit_sequence(const ConditionalDepSpec & u, - GenericSpecTree::ConstSequenceIterator cur, - GenericSpecTree::ConstSequenceIterator end) + void visit(const GenericSpecTree::NodeType<ConditionalDepSpec>::Type & node) { if (child_of_any) reporter.message(QAMessage(entry, qaml_normal, name, @@ -185,9 +183,9 @@ namespace .with_associated_id(id) .with_associated_key(id, key)); - if (uses.count(elike_conditional_dep_spec_flag(u))) + if (uses.count(elike_conditional_dep_spec_flag(*node.spec()))) reporter.message(QAMessage(entry, qaml_normal, name, - "Recursive use of flag '" + stringify(elike_conditional_dep_spec_flag(u)) + "' in '" + "Recursive use of flag '" + stringify(elike_conditional_dep_spec_flag(*node.spec())) + "' in '" + stringify(key->raw_name()) + "'") .with_associated_id(id) .with_associated_key(id, key)); @@ -195,7 +193,7 @@ namespace std::tr1::shared_ptr<const ChoiceValue> value; std::tr1::shared_ptr<const Choice> choice; { - ChoiceNameWithPrefix f(elike_conditional_dep_spec_flag(u)); + ChoiceNameWithPrefix f(elike_conditional_dep_spec_flag(*node.spec())); for (Choices::ConstIterator c(id->choices_key()->value()->begin()), c_end(id->choices_key()->value()->end()) ; c != c_end && ! value ; ++c) for (Choice::ConstIterator i((*c)->begin()), i_end((*c)->end()) ; @@ -212,7 +210,7 @@ namespace if (! choice) { reporter.message(QAMessage(entry, qaml_normal, name, - "Conditional flag '" + stringify(elike_conditional_dep_spec_flag(u)) + + "Conditional flag '" + stringify(elike_conditional_dep_spec_flag(*node.spec())) + "' in '" + stringify(key->raw_name()) + "' does not exist") .with_associated_id(id) .with_associated_key(id, key) @@ -222,12 +220,12 @@ namespace { if (forbid_arch_flags) reporter.message(QAMessage(entry, qaml_normal, name, - "Arch flag '" + stringify(elike_conditional_dep_spec_flag(u)) + "' in '" + stringify(key->raw_name()) + "'") + "Arch flag '" + stringify(elike_conditional_dep_spec_flag(*node.spec())) + "' in '" + stringify(key->raw_name()) + "'") .with_associated_id(id) .with_associated_key(id, key)); - else if (elike_conditional_dep_spec_is_inverse(u) && forbid_inverse_arch_flags) + else if (elike_conditional_dep_spec_is_inverse(*node.spec()) && forbid_inverse_arch_flags) reporter.message(QAMessage(entry, qaml_maybe, name, - "Inverse arch flag '" + stringify(elike_conditional_dep_spec_flag(u)) + "' in '" + stringify(key->raw_name()) + "'") + "Inverse arch flag '" + stringify(elike_conditional_dep_spec_flag(*node.spec())) + "' in '" + stringify(key->raw_name()) + "'") .with_associated_id(id) .with_associated_key(id, key)); } @@ -235,23 +233,21 @@ namespace Save<unsigned> save_level(&level, level + 1); Save<bool> save_child_of_any(&child_of_any, false); Save<std::set<ChoiceNameWithPrefix> > save_uses(&uses, uses); - uses.insert(elike_conditional_dep_spec_flag(u)); - if (cur == end) + uses.insert(elike_conditional_dep_spec_flag(*node.spec())); + if (node.begin() == node.end()) reporter.message(QAMessage(entry, qaml_normal, name, "Empty 'use? ( )' in '" + stringify(key->raw_name()) + "'") .with_associated_id(id) .with_associated_key(id, key)); else - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } - void visit_sequence(const AllDepSpec &, - GenericSpecTree::ConstSequenceIterator cur, - GenericSpecTree::ConstSequenceIterator end) + void visit(const GenericSpecTree::NodeType<AllDepSpec>::Type & node) { Save<unsigned> save_level(&level, level + 1); Save<bool> save_child_of_any(&child_of_any, false); - if (cur == end) + if (node.begin() == node.end()) { if (level > 1) reporter.message(QAMessage(entry, qaml_normal, name, @@ -260,30 +256,28 @@ namespace .with_associated_key(id, key)); } else - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } - void visit_sequence(const AnyDepSpec &, - GenericSpecTree::ConstSequenceIterator cur, - GenericSpecTree::ConstSequenceIterator end) + void visit(const GenericSpecTree::NodeType<AnyDepSpec>::Type & node) { Save<unsigned> save_level(&level, level + 1); Save<bool> save_child_of_any(&child_of_any, true); - if (cur == end) + if (node.begin() == node.end()) reporter.message(QAMessage(entry, qaml_normal, name, "Empty '|| ( )' in '" + stringify(key->raw_name()) + "'") .with_associated_id(id) .with_associated_key(id, key)); - else if (next(cur) == end) + else if (next(node.begin()) == node.end()) { - cur->accept(*this); + (*node.begin())->accept(*this); reporter.message(QAMessage(entry, qaml_normal, name, "'|| ( )' with only one child in '" + stringify(key->raw_name()) + "'") .with_associated_id(id) .with_associated_key(id, key)); } else - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } }; @@ -381,7 +375,7 @@ namespace { Context context("When visiting metadata key '" + k.raw_name() + "':"); Checker c(entry, reporter, id, key, name, std::tr1::shared_ptr<const QualifiedPackageNameSet>(), false, false); - k.value()->accept(c); + k.value()->root()->accept(c); } catch (const InternalError &) { @@ -402,7 +396,7 @@ namespace { Context context("When visiting metadata key '" + k.raw_name() + "':"); Checker c(entry, reporter, id, key, name, std::tr1::shared_ptr<const QualifiedPackageNameSet>(), true, true); - k.value()->accept(c); + k.value()->root()->accept(c); } catch (const InternalError &) { @@ -423,7 +417,7 @@ namespace { Context context("When visiting metadata key '" + k.raw_name() + "':"); Checker c(entry, reporter, id, key, name, std::tr1::shared_ptr<const QualifiedPackageNameSet>(), true, true); - k.value()->accept(c); + k.value()->root()->accept(c); } catch (const InternalError &) { @@ -444,7 +438,7 @@ namespace { Context context("When visiting metadata key '" + k.raw_name() + "':"); Checker c(entry, reporter, id, key, name, SpecKeysBlacklist::get_instance()->blacklist(k.raw_name()), false, true); - k.value()->accept(c); + k.value()->root()->accept(c); } catch (const InternalError &) { @@ -465,7 +459,7 @@ namespace { Context context("When visiting metadata key '" + k.raw_name() + "':"); Checker c(entry, reporter, id, key, name, SpecKeysBlacklist::get_instance()->blacklist(k.raw_name()), true, true); - k.value()->accept(c); + k.value()->root()->accept(c); } catch (const InternalError &) { @@ -486,7 +480,7 @@ namespace { Context context("When visiting metadata key '" + k.raw_name() + "':"); Checker c(entry, reporter, id, key, name, std::tr1::shared_ptr<const QualifiedPackageNameSet>(), true, true); - k.value()->accept(c); + k.value()->root()->accept(c); } catch (const InternalError &) { diff --git a/paludis/repositories/e/qa/visibility.cc b/paludis/repositories/e/qa/visibility.cc index 37e6e84bc..6a8c0919e 100644 --- a/paludis/repositories/e/qa/visibility.cc +++ b/paludis/repositories/e/qa/visibility.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -24,7 +24,6 @@ #include <paludis/util/tokeniser.hh> #include <paludis/util/log.hh> #include <paludis/util/set.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/create_iterator-impl.hh> #include <paludis/util/make_shared_ptr.hh> #include <paludis/qa.hh> @@ -49,8 +48,7 @@ using namespace paludis::erepository; namespace { - struct Checker : - ConstVisitor<DependencySpecTree> + struct Checker { const FSEntry entry; QAReporter * const reporter; @@ -92,27 +90,27 @@ namespace { } - void visit_leaf(const BlockDepSpec &) + void visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type &) { viable = true; } - void visit_leaf(const DependencyLabelsDepSpec &) + void visit(const DependencySpecTree::NodeType<DependencyLabelsDepSpec>::Type &) { } - void visit_leaf(const NamedSetDepSpec &) + void visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type &) { } - void visit_leaf(const PackageDepSpec & orig_p) + void visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node) { using namespace std::tr1::placeholders; success = false; viable = true; - const PackageDepSpec * p(&orig_p); + const PackageDepSpec * p(node.spec().get()); std::tr1::shared_ptr<PackageDepSpec> local_p; /* rewrite virtuals to avoid problems later on */ @@ -126,18 +124,18 @@ namespace if (v->second->version_requirements_ptr()) std::for_each(v->second->version_requirements_ptr()->begin(), v->second->version_requirements_ptr()->end(), std::tr1::bind(&PartiallyMadePackageDepSpec::version_requirement, &pp, _1)); - if (orig_p.version_requirements_ptr()) - std::for_each(orig_p.version_requirements_ptr()->begin(), orig_p.version_requirements_ptr()->end(), + if (node.spec()->version_requirements_ptr()) + std::for_each(node.spec()->version_requirements_ptr()->begin(), node.spec()->version_requirements_ptr()->end(), std::tr1::bind(&PartiallyMadePackageDepSpec::version_requirement, &pp, _1)); pp.package(*v->second->package_ptr()); - if (orig_p.slot_requirement_ptr()) - pp.slot_requirement(orig_p.slot_requirement_ptr()); - if (orig_p.in_repository_ptr()) - pp.in_repository(*orig_p.in_repository_ptr()); + if (node.spec()->slot_requirement_ptr()) + pp.slot_requirement(node.spec()->slot_requirement_ptr()); + if (node.spec()->in_repository_ptr()) + pp.in_repository(*node.spec()->in_repository_ptr()); local_p.reset(new PackageDepSpec(pp)); - local_p->set_tag(orig_p.tag()); + local_p->set_tag(node.spec()->tag()); p = local_p.get(); } } @@ -149,7 +147,7 @@ namespace { if (reporter) reporter->message(QAMessage(entry, qaml_normal, name, "No packages matching '" - + stringify(orig_p) + "' in dependencies key '" + stringify(key->raw_name()) + "' for profile '" + + stringify(*node.spec()) + "' in dependencies key '" + stringify(key->raw_name()) + "' for profile '" + stringify((*profile).path()) + "' (" + stringify((*profile).arch()) + "." + stringify((*profile).status()) + (unstable ? ".unstable" : ".stable") + ")") @@ -192,7 +190,7 @@ namespace { Log::get_instance()->message("e.qa.visibility_check.no_masks", ll_warning, lc_context) << "Probably a bug: don't know how to get masks for '" - << **i << "' from '" << orig_p << "' -> '" << *p << "'"; + << **i << "' from '" << *node.spec() << "' -> '" << *p << "'"; continue; } } @@ -213,7 +211,7 @@ namespace if (! success) if (reporter) reporter->message(QAMessage(entry, qaml_normal, name, "No visible packages matching '" - + stringify(orig_p) + "' in dependencies key '" + stringify(key->raw_name()) + "' for profile '" + + stringify(*node.spec()) + "' in dependencies key '" + stringify(key->raw_name()) + "' for profile '" + stringify((*profile).path()) + "' (" + stringify((*profile).arch()) + "." + stringify((*profile).status()) + (unstable ? ".unstable" : ".stable") + ")") .with_associated_id(id) @@ -221,11 +219,9 @@ namespace } } - void visit_sequence(const ConditionalDepSpec & u, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) + void visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node) { - ChoiceNameWithPrefix prefixed(elike_conditional_dep_spec_flag(u)); + ChoiceNameWithPrefix prefixed(elike_conditional_dep_spec_flag(*node.spec())); UnprefixedChoiceName value("x"); std::tr1::shared_ptr<const Choice> choice; if (id->choices_key()) @@ -263,25 +259,24 @@ namespace } else viable = - ((! elike_conditional_dep_spec_is_inverse(u)) && (! (*profile).profile()->use_masked( + ((! elike_conditional_dep_spec_is_inverse(*node.spec())) && (! (*profile).profile()->use_masked( id, choice, value, prefixed))) || - ((elike_conditional_dep_spec_is_inverse(u)) && (! (*profile).profile()->use_forced( + ((elike_conditional_dep_spec_is_inverse(*node.spec())) && (! (*profile).profile()->use_forced( id, choice, value, prefixed))); if (viable) - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } - void visit_sequence(const AnyDepSpec &, - DependencySpecTree::ConstSequenceIterator begin, - DependencySpecTree::ConstSequenceIterator end) + void visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node) { success = true; viable = true; - for (DependencySpecTree::ConstSequenceIterator cur(begin) ; cur != end ; ++cur) + for (DependencySpecTree::NodeType<AnyDepSpec>::Type::ConstIterator cur(node.begin()), cur_end(node.end()) ; + cur != cur_end ; ++cur) { Checker c(entry, 0, env, id, repo, accepted_keywords, profile, name, unstable, key); - accept_visitor(c)(*cur); + accept_visitor(c)(**cur); if (c.success) { success = true; @@ -297,7 +292,7 @@ namespace { StringifyFormatter ff; DepSpecPrettyPrinter printer(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); - std::for_each(begin, end, accept_visitor(printer)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(printer)); reporter->message(QAMessage(entry, qaml_normal, name, "No item in block '|| ( " + stringify(printer) + " )' visible for profile '" + stringify((*profile).path()) + "' (" + stringify((*profile).arch()) + "." + stringify((*profile).status()) @@ -308,12 +303,10 @@ namespace } } - void visit_sequence(const AllDepSpec &, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) + void visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node) { viable = true; - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } }; } @@ -354,25 +347,25 @@ paludis::erepository::visibility_check( if (id->build_dependencies_key()) { Checker c(entry, &reporter, env, id, repo, accepted_keywords, p, name, false, id->build_dependencies_key()); - id->build_dependencies_key()->value()->accept(c); + id->build_dependencies_key()->value()->root()->accept(c); } if (id->run_dependencies_key()) { Checker c(entry, &reporter, env, id, repo, accepted_keywords, p, name, false, id->run_dependencies_key()); - id->run_dependencies_key()->value()->accept(c); + id->run_dependencies_key()->value()->root()->accept(c); } if (id->post_dependencies_key()) { Checker c(entry, &reporter, env, id, repo, accepted_keywords, p, name, false, id->post_dependencies_key()); - id->post_dependencies_key()->value()->accept(c); + id->post_dependencies_key()->value()->root()->accept(c); } if (id->suggested_dependencies_key()) { Checker c(entry, &reporter, env, id, repo, accepted_keywords, p, name, false, id->suggested_dependencies_key()); - id->post_dependencies_key()->value()->accept(c); + id->post_dependencies_key()->value()->root()->accept(c); } } else @@ -391,25 +384,25 @@ paludis::erepository::visibility_check( if (id->build_dependencies_key()) { Checker c(entry, &reporter, env, id, repo, accepted_keywords, p, name, true, id->build_dependencies_key()); - id->build_dependencies_key()->value()->accept(c); + id->build_dependencies_key()->value()->root()->accept(c); } if (id->run_dependencies_key()) { Checker c(entry, &reporter, env, id, repo, accepted_keywords, p, name, true, id->run_dependencies_key()); - id->run_dependencies_key()->value()->accept(c); + id->run_dependencies_key()->value()->root()->accept(c); } if (id->post_dependencies_key()) { Checker c(entry, &reporter, env, id, repo, accepted_keywords, p, name, true, id->post_dependencies_key()); - id->post_dependencies_key()->value()->accept(c); + id->post_dependencies_key()->value()->root()->accept(c); } if (id->suggested_dependencies_key()) { Checker c(entry, &reporter, env, id, repo, accepted_keywords, p, name, true, id->suggested_dependencies_key()); - id->post_dependencies_key()->value()->accept(c); + id->post_dependencies_key()->value()->root()->accept(c); } } } diff --git a/paludis/repositories/e/source_uri_finder.cc b/paludis/repositories/e/source_uri_finder.cc index 47b8f5066..283171f2e 100644 --- a/paludis/repositories/e/source_uri_finder.cc +++ b/paludis/repositories/e/source_uri_finder.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -18,10 +18,12 @@ */ #include <paludis/repositories/e/source_uri_finder.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/log.hh> #include <paludis/util/stringify.hh> #include <paludis/util/strip.hh> +#include <paludis/util/wrapped_forward_iterator-impl.hh> +#include <paludis/util/sequence.hh> +#include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/repository.hh> #include <paludis/environment.hh> #include <paludis/action.hh> @@ -218,3 +220,5 @@ SourceURIFinder::add_listed() } } +template class WrappedForwardIterator<SourceURIFinder::ConstIteratorTag, const std::pair<std::string, std::string> >; + diff --git a/paludis/repositories/e/source_uri_finder.hh b/paludis/repositories/e/source_uri_finder.hh index 1e48bbf27..8b8fbd5c1 100644 --- a/paludis/repositories/e/source_uri_finder.hh +++ b/paludis/repositories/e/source_uri_finder.hh @@ -22,7 +22,6 @@ #include <paludis/util/attributes.hh> #include <paludis/util/private_implementation_pattern.hh> -#include <paludis/util/visitor.hh> #include <paludis/util/wrapped_forward_iterator-fwd.hh> #include <paludis/dep_label.hh> #include <paludis/environment-fwd.hh> diff --git a/paludis/repositories/e/source_uri_finder_TEST.cc b/paludis/repositories/e/source_uri_finder_TEST.cc index b99e135cd..592a2c357 100644 --- a/paludis/repositories/e/source_uri_finder_TEST.cc +++ b/paludis/repositories/e/source_uri_finder_TEST.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -20,8 +20,8 @@ #include <paludis/repositories/e/source_uri_finder.hh> #include <paludis/environments/test/test_environment.hh> #include <paludis/repositories/fake/fake_repository.hh> +#include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/package_database.hh> -#include <paludis/util/visitor-impl.hh> #include <test/test_runner.hh> #include <test/test_framework.hh> diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc index ef384ddea..da1fbf3a2 100644 --- a/paludis/repositories/e/vdb_repository.cc +++ b/paludis/repositories/e/vdb_repository.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh + * Copyright (c) 2006, 2007, 2008, 2009 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 @@ -61,7 +61,6 @@ #include <paludis/util/set.hh> #include <paludis/util/sequence.hh> #include <paludis/util/map.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/stringify.hh> #include <paludis/util/strip.hh> #include <paludis/util/system.hh> @@ -639,9 +638,9 @@ VDBRepository::provides_from_package_id(const PackageID & id) const if (! id.provide_key()) return; - std::tr1::shared_ptr<const ProvideSpecTree::ConstItem> provide(id.provide_key()->value()); + std::tr1::shared_ptr<const ProvideSpecTree> provide(id.provide_key()->value()); DepSpecFlattener<ProvideSpecTree, PackageDepSpec> f(_imp->params.environment()); - provide->accept(f); + provide->root()->accept(f); std::tr1::shared_ptr<Sequence<QualifiedPackageName> > qpns(new Sequence<QualifiedPackageName>); diff --git a/paludis/repositories/e/vdb_repository_TEST.cc b/paludis/repositories/e/vdb_repository_TEST.cc index 5d0e1ceaa..6a3f71db2 100644 --- a/paludis/repositories/e/vdb_repository_TEST.cc +++ b/paludis/repositories/e/vdb_repository_TEST.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh + * Copyright (c) 2006, 2007, 2008, 2009 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 @@ -24,7 +24,6 @@ #include <paludis/package_database.hh> #include <paludis/metadata_key.hh> #include <paludis/util/sequence.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/options.hh> #include <paludis/util/dir_iterator.hh> #include <paludis/util/make_named_values.hh> @@ -279,17 +278,17 @@ namespace test_cases erepository::DepSpecPrettyPrinter pd(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); TEST_CHECK(id->build_dependencies_key()); - id->build_dependencies_key()->value()->accept(pd); + id->build_dependencies_key()->value()->root()->accept(pd); TEST_CHECK_STRINGIFY_EQUAL(pd, "( cat/pkg1 build: cat/pkg2 build,run: cat/pkg3 suggested: cat/pkg4 post: )"); erepository::DepSpecPrettyPrinter pr(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); TEST_CHECK(id->run_dependencies_key()); - id->run_dependencies_key()->value()->accept(pr); + id->run_dependencies_key()->value()->root()->accept(pr); TEST_CHECK_STRINGIFY_EQUAL(pr, "( cat/pkg1 build: build,run: cat/pkg3 suggested: cat/pkg4 post: )"); erepository::DepSpecPrettyPrinter pp(0, std::tr1::shared_ptr<const PackageID>(), ff, 0, false, false); TEST_CHECK(id->post_dependencies_key()); - id->post_dependencies_key()->value()->accept(pp); + id->post_dependencies_key()->value()->root()->accept(pp); TEST_CHECK_STRINGIFY_EQUAL(pp, "( build: build,run: suggested: post: cat/pkg5 )"); } } test_vdb_repository_dependencies_rewriter; @@ -851,6 +850,11 @@ namespace test_cases { std::tr1::shared_ptr<const RepositoryProvidesInterface::ProvidesSequence> seq(vdb_repo->provides_interface()->provided_packages()); + + for (RepositoryProvidesInterface::ProvidesSequence::ConstIterator s(seq->begin()), s_end(seq->end()) ; + s != s_end ; ++s) + TestMessageSuffix x(stringify(s->virtual_name()) + " by " + stringify(*s->provided_by()), true); + TEST_CHECK_EQUAL(std::distance(seq->begin(), seq->end()), 5U); RepositoryProvidesInterface::ProvidesSequence::ConstIterator it(seq->begin()); diff --git a/paludis/repositories/fake/dep_parser.cc b/paludis/repositories/fake/dep_parser.cc index e4dfbe4d7..3a791d101 100644 --- a/paludis/repositories/fake/dep_parser.cc +++ b/paludis/repositories/fake/dep_parser.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008 Ciaran McCreesh + * Copyright (c) 2008, 2009 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,7 +21,6 @@ #include <paludis/util/make_shared_ptr.hh> #include <paludis/util/options.hh> #include <paludis/util/stringify.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/make_named_values.hh> #include <paludis/elike_dep_parser.hh> #include <paludis/elike_conditional_dep_spec.hh> @@ -40,29 +39,12 @@ FakeDepParseError::FakeDepParseError(const std::string & s, const std::string & { } -namespace paludis -{ - namespace n - { - struct add_handler; - struct item; - } -} - namespace { template <typename T_> struct ParseStackTypes { - typedef std::tr1::function<void (const std::tr1::shared_ptr<const typename T_::ConstItem> &)> AddHandler; - - struct Item - { - NamedValue<n::add_handler, AddHandler> add_handler; - NamedValue<n::item, const std::tr1::shared_ptr<const typename T_::ConstItem> > item; - }; - - typedef std::list<Item> Stack; + typedef std::list<std::tr1::shared_ptr<typename T_::BasicInnerNode> > Stack; }; template <typename T_> @@ -73,7 +55,7 @@ namespace + epdso_allow_slot_star_deps + epdso_allow_slot_equal_deps + epdso_allow_repository_deps + epdso_allow_use_deps + epdso_allow_ranged_deps + epdso_allow_tilde_greater_deps + epdso_strict_parsing, id)); - (*h.begin()).add_handler()(make_shared_ptr(new TreeLeaf<T_, PackageDepSpec>(make_shared_ptr(new PackageDepSpec(p))))); + (*h.begin())->append(make_shared_ptr(new PackageDepSpec(p))); } template <typename T_> @@ -82,13 +64,12 @@ namespace { if ((! s.empty()) && ('!' == s.at(0))) { - std::tr1::shared_ptr<BlockDepSpec> b(new BlockDepSpec( + (*h.begin())->append(make_shared_ptr(new BlockDepSpec( make_shared_ptr(new PackageDepSpec(parse_elike_package_dep_spec(s.substr(1), ELikePackageDepSpecOptions() + epdso_allow_slot_deps + epdso_allow_slot_star_deps + epdso_allow_slot_equal_deps + epdso_allow_repository_deps + epdso_allow_use_deps + epdso_allow_ranged_deps + epdso_allow_tilde_greater_deps - + epdso_strict_parsing, id))))); - (*h.begin()).add_handler()(make_shared_ptr(new TreeLeaf<T_, BlockDepSpec>(b))); + + epdso_strict_parsing, id)))))); } else package_dep_spec_string_handler<T_>(h, s, id); @@ -97,20 +78,19 @@ namespace template <typename T_> void license_handler(const typename ParseStackTypes<T_>::Stack & h, const std::string & s) { - (*h.begin()).add_handler()(make_shared_ptr(new TreeLeaf<T_, LicenseDepSpec>(make_shared_ptr(new LicenseDepSpec(s))))); + (*h.begin())->append(make_shared_ptr(new LicenseDepSpec(s))); } template <typename T_> void simple_uri_handler(const typename ParseStackTypes<T_>::Stack & h, const std::string & s) { - (*h.begin()).add_handler()(make_shared_ptr(new TreeLeaf<T_, SimpleURIDepSpec>(make_shared_ptr(new SimpleURIDepSpec(s))))); + (*h.begin())->append(make_shared_ptr(new SimpleURIDepSpec(s))); } template <typename T_> void arrow_handler(const typename ParseStackTypes<T_>::Stack & h, const std::string & s, const std::string & t) { - (*h.begin()).add_handler()(make_shared_ptr(new TreeLeaf<T_, FetchableURIDepSpec>(make_shared_ptr( - new FetchableURIDepSpec(t.empty() ? s : s + " -> " + t))))); + (*h.begin())->append(make_shared_ptr(new FetchableURIDepSpec(t.empty() ? s : s + " -> " + t))); } void any_not_allowed_handler(const std::string & s) PALUDIS_ATTRIBUTE((noreturn)); @@ -144,29 +124,15 @@ namespace template <typename T_, typename A_> void any_all_handler(typename ParseStackTypes<T_>::Stack & stack) { - using namespace std::tr1::placeholders; - std::tr1::shared_ptr<ConstTreeSequence<T_, A_> > item( - new ConstTreeSequence<T_, A_>(make_shared_ptr(new A_))); - (*stack.begin()).add_handler()(item); - stack.push_front(make_named_values<typename ParseStackTypes<T_>::Item>( - value_for<n::add_handler>(std::tr1::bind(&ConstTreeSequence<T_, A_>::add, item.get(), _1)), - value_for<n::item>(item) - )); + stack.push_front((*stack.begin())->append(make_shared_ptr(new A_))); } template <typename T_> void use_handler(typename ParseStackTypes<T_>::Stack & stack, const std::string & u, const Environment * const env, const std::tr1::shared_ptr<const PackageID> & id) { - using namespace std::tr1::placeholders; - std::tr1::shared_ptr<ConstTreeSequence<T_, ConditionalDepSpec> > item( - new ConstTreeSequence<T_, ConditionalDepSpec>(make_shared_ptr(new ConditionalDepSpec( - parse_elike_conditional_dep_spec(u, env, id, false))))); - (*stack.begin()).add_handler()(item); - stack.push_front(make_named_values<typename ParseStackTypes<T_>::Item>( - value_for<n::add_handler>(std::tr1::bind(&ConstTreeSequence<T_, ConditionalDepSpec>::add, item.get(), _1)), - value_for<n::item>(item) - )); + stack.push_front((*stack.begin())->append( + make_shared_ptr(new ConditionalDepSpec(parse_elike_conditional_dep_spec(u, env, id, false))))); } template <typename T_> @@ -193,19 +159,15 @@ namespace } } -std::tr1::shared_ptr<DependencySpecTree::ConstItem> +std::tr1::shared_ptr<DependencySpecTree> paludis::fakerepository::parse_depend(const std::string & s, const Environment * const env, const std::tr1::shared_ptr<const PackageID> & id) { using namespace std::tr1::placeholders; ParseStackTypes<DependencySpecTree>::Stack stack; - std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > top( - new ConstTreeSequence<DependencySpecTree, AllDepSpec>(make_shared_ptr(new AllDepSpec))); - stack.push_front(make_named_values<ParseStackTypes<DependencySpecTree>::Item>( - value_for<n::add_handler>(std::tr1::bind(&ConstTreeSequence<DependencySpecTree, AllDepSpec>::add, top.get(), _1)), - value_for<n::item>(top) - )); + std::tr1::shared_ptr<DependencySpecTree> top(make_shared_ptr(new DependencySpecTree(make_shared_ptr(new AllDepSpec)))); + stack.push_front(top->root()); ELikeDepParserCallbacks callbacks( make_named_values<ELikeDepParserCallbacks>( @@ -224,22 +186,18 @@ paludis::fakerepository::parse_depend(const std::string & s, parse_elike_dependencies(s, callbacks); - return (*stack.begin()).item(); + return top; } -std::tr1::shared_ptr<ProvideSpecTree::ConstItem> +std::tr1::shared_ptr<ProvideSpecTree> paludis::fakerepository::parse_provide(const std::string & s, const Environment * const env, const std::tr1::shared_ptr<const PackageID> & id) { using namespace std::tr1::placeholders; ParseStackTypes<ProvideSpecTree>::Stack stack; - std::tr1::shared_ptr<ConstTreeSequence<ProvideSpecTree, AllDepSpec> > top( - new ConstTreeSequence<ProvideSpecTree, AllDepSpec>(make_shared_ptr(new AllDepSpec))); - stack.push_front(make_named_values<ParseStackTypes<ProvideSpecTree>::Item>( - value_for<n::add_handler>(std::tr1::bind(&ConstTreeSequence<ProvideSpecTree, AllDepSpec>::add, top.get(), _1)), - value_for<n::item>(top) - )); + std::tr1::shared_ptr<ProvideSpecTree> top(make_shared_ptr(new ProvideSpecTree(make_shared_ptr(new AllDepSpec)))); + stack.push_front(top->root()); ELikeDepParserCallbacks callbacks( make_named_values<ELikeDepParserCallbacks>( @@ -258,22 +216,18 @@ paludis::fakerepository::parse_provide(const std::string & s, parse_elike_dependencies(s, callbacks); - return (*stack.begin()).item(); + return top; } -std::tr1::shared_ptr<FetchableURISpecTree::ConstItem> +std::tr1::shared_ptr<FetchableURISpecTree> paludis::fakerepository::parse_fetchable_uri(const std::string & s, const Environment * const env, const std::tr1::shared_ptr<const PackageID> & id) { using namespace std::tr1::placeholders; ParseStackTypes<FetchableURISpecTree>::Stack stack; - std::tr1::shared_ptr<ConstTreeSequence<FetchableURISpecTree, AllDepSpec> > top( - new ConstTreeSequence<FetchableURISpecTree, AllDepSpec>(make_shared_ptr(new AllDepSpec))); - stack.push_front(make_named_values<ParseStackTypes<FetchableURISpecTree>::Item>( - value_for<n::add_handler>(std::tr1::bind(&ConstTreeSequence<FetchableURISpecTree, AllDepSpec>::add, top.get(), _1)), - value_for<n::item>(top) - )); + std::tr1::shared_ptr<FetchableURISpecTree> top(make_shared_ptr(new FetchableURISpecTree(make_shared_ptr(new AllDepSpec)))); + stack.push_front(top->root()); ELikeDepParserCallbacks callbacks( make_named_values<ELikeDepParserCallbacks>( @@ -292,22 +246,18 @@ paludis::fakerepository::parse_fetchable_uri(const std::string & s, parse_elike_dependencies(s, callbacks); - return (*stack.begin()).item(); + return top; } -std::tr1::shared_ptr<SimpleURISpecTree::ConstItem> +std::tr1::shared_ptr<SimpleURISpecTree> paludis::fakerepository::parse_simple_uri(const std::string & s, const Environment * const env, const std::tr1::shared_ptr<const PackageID> & id) { using namespace std::tr1::placeholders; ParseStackTypes<SimpleURISpecTree>::Stack stack; - std::tr1::shared_ptr<ConstTreeSequence<SimpleURISpecTree, AllDepSpec> > top( - new ConstTreeSequence<SimpleURISpecTree, AllDepSpec>(make_shared_ptr(new AllDepSpec))); - stack.push_front(make_named_values<ParseStackTypes<SimpleURISpecTree>::Item>( - value_for<n::add_handler>(std::tr1::bind(&ConstTreeSequence<SimpleURISpecTree, AllDepSpec>::add, top.get(), _1)), - value_for<n::item>(top) - )); + std::tr1::shared_ptr<SimpleURISpecTree> top(make_shared_ptr(new SimpleURISpecTree(make_shared_ptr(new AllDepSpec)))); + stack.push_front(top->root()); ELikeDepParserCallbacks callbacks( make_named_values<ELikeDepParserCallbacks>( @@ -326,22 +276,18 @@ paludis::fakerepository::parse_simple_uri(const std::string & s, parse_elike_dependencies(s, callbacks); - return (*stack.begin()).item(); + return top; } -std::tr1::shared_ptr<LicenseSpecTree::ConstItem> +std::tr1::shared_ptr<LicenseSpecTree> paludis::fakerepository::parse_license(const std::string & s, const Environment * const env, const std::tr1::shared_ptr<const PackageID> & id) { using namespace std::tr1::placeholders; ParseStackTypes<LicenseSpecTree>::Stack stack; - std::tr1::shared_ptr<ConstTreeSequence<LicenseSpecTree, AllDepSpec> > top( - new ConstTreeSequence<LicenseSpecTree, AllDepSpec>(make_shared_ptr(new AllDepSpec))); - stack.push_front(make_named_values<ParseStackTypes<LicenseSpecTree>::Item>( - value_for<n::add_handler>(std::tr1::bind(&ConstTreeSequence<LicenseSpecTree, AllDepSpec>::add, top.get(), _1)), - value_for<n::item>(top) - )); + std::tr1::shared_ptr<LicenseSpecTree> top(make_shared_ptr(new LicenseSpecTree(make_shared_ptr(new AllDepSpec)))); + stack.push_front(top->root()); ELikeDepParserCallbacks callbacks( make_named_values<ELikeDepParserCallbacks>( @@ -360,6 +306,6 @@ paludis::fakerepository::parse_license(const std::string & s, parse_elike_dependencies(s, callbacks); - return (*stack.begin()).item(); + return top; } diff --git a/paludis/repositories/fake/dep_parser.hh b/paludis/repositories/fake/dep_parser.hh index 537a80dee..483be3571 100644 --- a/paludis/repositories/fake/dep_parser.hh +++ b/paludis/repositories/fake/dep_parser.hh @@ -21,7 +21,7 @@ #define PALUDIS_GUARD_PALUDIS_REPOSITORIES_FAKE_DEP_PARSER_HH 1 #include <paludis/util/exception.hh> -#include <paludis/dep_tree.hh> +#include <paludis/spec_tree.hh> #include <paludis/package_id-fwd.hh> #include <paludis/environment-fwd.hh> #include <string> @@ -45,31 +45,31 @@ namespace paludis /** * Parse a dependency heirarchy. */ - std::tr1::shared_ptr<DependencySpecTree::ConstItem> parse_depend(const std::string & s, + std::tr1::shared_ptr<DependencySpecTree> parse_depend(const std::string & s, const Environment * const, const std::tr1::shared_ptr<const PackageID> &) PALUDIS_VISIBLE; /** * Parse a provide heirarchy. */ - std::tr1::shared_ptr<ProvideSpecTree::ConstItem> parse_provide(const std::string & s, + std::tr1::shared_ptr<ProvideSpecTree> parse_provide(const std::string & s, const Environment * const, const std::tr1::shared_ptr<const PackageID> &) PALUDIS_VISIBLE; /** * Parse a fetchable uri heirarchy. */ - std::tr1::shared_ptr<FetchableURISpecTree::ConstItem> parse_fetchable_uri(const std::string & s, + std::tr1::shared_ptr<FetchableURISpecTree> parse_fetchable_uri(const std::string & s, const Environment * const, const std::tr1::shared_ptr<const PackageID> &) PALUDIS_VISIBLE; /** * Parse a simple uri heirarchy. */ - std::tr1::shared_ptr<SimpleURISpecTree::ConstItem> parse_simple_uri(const std::string & s, + std::tr1::shared_ptr<SimpleURISpecTree> parse_simple_uri(const std::string & s, const Environment * const, const std::tr1::shared_ptr<const PackageID> &) PALUDIS_VISIBLE; /** * Parse a license heirarchy. */ - std::tr1::shared_ptr<LicenseSpecTree::ConstItem> parse_license(const std::string & s, + std::tr1::shared_ptr<LicenseSpecTree> parse_license(const std::string & s, const Environment * const, const std::tr1::shared_ptr<const PackageID> &) PALUDIS_VISIBLE; } } diff --git a/paludis/repositories/fake/dep_parser_TEST.cc b/paludis/repositories/fake/dep_parser_TEST.cc index a8888cc92..85a7f0caf 100644 --- a/paludis/repositories/fake/dep_parser_TEST.cc +++ b/paludis/repositories/fake/dep_parser_TEST.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008 Ciaran McCreesh + * Copyright (c) 2008, 2009 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 @@ -19,7 +19,6 @@ #include <paludis/repositories/fake/dep_parser.hh> #include <paludis/environments/test/test_environment.hh> -#include <paludis/util/visitor-impl.hh> #include <test/test_runner.hh> #include <test/test_framework.hh> #include <sstream> @@ -30,55 +29,48 @@ using namespace test; namespace { - struct QuickPrinter : - ConstVisitor<DependencySpecTree> + struct QuickPrinter { std::stringstream str; - void visit_leaf(const PackageDepSpec & s) + void visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node) { - str << "p<" << stringify(s) << ">"; + str << "p<" << stringify(*node.spec()) << ">"; } - void visit_leaf(const NamedSetDepSpec & s) + void visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & node) { - str << "s<" << stringify(s) << ">"; + str << "s<" << stringify(*node.spec()) << ">"; } - void visit_leaf(const BlockDepSpec & s) + void visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type & node) { - str << "b<" << stringify(s) << ">"; + str << "b<" << stringify(*node.spec()) << ">"; } - void visit_leaf(const DependencyLabelsDepSpec & s) + void visit(const DependencySpecTree::NodeType<DependencyLabelsDepSpec>::Type & node) { - str << "l<" << stringify(s) << ">"; + str << "l<" << stringify(*node.spec()) << ">"; } - void visit_sequence(const AllDepSpec &, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) + void visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node) { str << "all<"; - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); str << ">"; } - void visit_sequence(const AnyDepSpec &, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) + void visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node) { str << "any<"; - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); str << ">"; } - void visit_sequence(const ConditionalDepSpec & s, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) + void visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node) { - str << "cond<" << s << ","; - std::for_each(cur, end, accept_visitor(*this)); + str << "cond<" << *node.spec() << ","; + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); str << ">"; } }; @@ -93,11 +85,11 @@ namespace test_cases void run() { TestEnvironment env; - std::tr1::shared_ptr<DependencySpecTree::ConstItem> d(fakerepository::parse_depend( + std::tr1::shared_ptr<DependencySpecTree> d(fakerepository::parse_depend( "( ( a/a b/b ) )", &env, std::tr1::shared_ptr<const PackageID>())); QuickPrinter p; - d->accept(p); + d->root()->accept(p); TEST_CHECK_EQUAL(p.str.str(), "all<all<all<p<a/a>p<b/b>>>>"); } } dep_parser_test; diff --git a/paludis/repositories/fake/fake_installed_repository.cc b/paludis/repositories/fake/fake_installed_repository.cc index 9677d4f69..05d243877 100644 --- a/paludis/repositories/fake/fake_installed_repository.cc +++ b/paludis/repositories/fake/fake_installed_repository.cc @@ -19,12 +19,11 @@ #include "fake_installed_repository.hh" #include <paludis/util/fs_entry.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/sequence.hh> #include <paludis/util/set.hh> #include <paludis/util/make_shared_ptr.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/make_named_values.hh> +#include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/package_id.hh> #include <paludis/metadata_key.hh> #include <paludis/environment.hh> @@ -106,7 +105,7 @@ FakeInstalledRepository::provided_packages() const continue; DepSpecFlattener<ProvideSpecTree, PackageDepSpec> f(environment()); - (*v)->provide_key()->value()->accept(f); + (*v)->provide_key()->value()->root()->accept(f); for (DepSpecFlattener<ProvideSpecTree, PackageDepSpec>::ConstIterator q(f.begin()), q_end(f.end()) ; q != q_end ; ++q) result->push_back(make_named_values<RepositoryProvidesEntry>( @@ -233,3 +232,4 @@ FakeInstalledRepository::repository_factory_dependencies( { return make_shared_ptr(new RepositoryNameSet); } + diff --git a/paludis/repositories/fake/fake_package_id.cc b/paludis/repositories/fake/fake_package_id.cc index 2d374df41..f8c0920f9 100644 --- a/paludis/repositories/fake/fake_package_id.cc +++ b/paludis/repositories/fake/fake_package_id.cc @@ -35,10 +35,9 @@ #include <paludis/util/set.hh> #include <paludis/util/create_iterator-impl.hh> #include <paludis/util/save.hh> -#include <paludis/util/visitor-impl.hh> -#include <paludis/util/make_shared_ptr.hh> #include <paludis/util/hashes.hh> #include <paludis/util/tribool.hh> +#include <paludis/util/wrapped_output_iterator.hh> #include <map> #include <list> #include <sstream> @@ -111,11 +110,11 @@ namespace paludis template <typename C_> struct Implementation<FakeMetadataSpecTreeKey<C_> > { - std::tr1::shared_ptr<const typename C_::ConstItem> value; + std::tr1::shared_ptr<const C_> value; std::string string_value; - const std::tr1::function<const std::tr1::shared_ptr<const typename C_::ConstItem> (const std::string &)> func; + const std::tr1::function<const std::tr1::shared_ptr<const C_> (const std::string &)> func; - Implementation(const std::tr1::function<const std::tr1::shared_ptr<const typename C_::ConstItem> (const std::string &)> & f) : + Implementation(const std::tr1::function<const std::tr1::shared_ptr<const C_> (const std::string &)> & f) : func(f) { } @@ -124,12 +123,12 @@ namespace paludis template <> struct Implementation<FakeMetadataSpecTreeKey<FetchableURISpecTree> > { - std::tr1::shared_ptr<const FetchableURISpecTree::ConstItem> value; + std::tr1::shared_ptr<const FetchableURISpecTree> value; std::string string_value; - const std::tr1::function<const std::tr1::shared_ptr<const FetchableURISpecTree::ConstItem> (const std::string &)> func; + const std::tr1::function<const std::tr1::shared_ptr<const FetchableURISpecTree> (const std::string &)> func; std::tr1::shared_ptr<const URILabel> initial_label; - Implementation(const std::tr1::function<const std::tr1::shared_ptr<const FetchableURISpecTree::ConstItem> (const std::string &)> & f) : + Implementation(const std::tr1::function<const std::tr1::shared_ptr<const FetchableURISpecTree> (const std::string &)> & f) : func(f), initial_label(new URIListedThenMirrorsLabel("listed-then-mirrors")) { @@ -139,12 +138,12 @@ namespace paludis template <> struct Implementation<FakeMetadataSpecTreeKey<DependencySpecTree> > { - std::tr1::shared_ptr<const DependencySpecTree::ConstItem> value; + std::tr1::shared_ptr<const DependencySpecTree> value; std::string string_value; - const std::tr1::function<const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> (const std::string &)> func; + const std::tr1::function<const std::tr1::shared_ptr<const DependencySpecTree> (const std::string &)> func; std::tr1::shared_ptr<const DependencyLabelSequence> labels; - Implementation(const std::tr1::function<const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> (const std::string &)> & f, + Implementation(const std::tr1::function<const std::tr1::shared_ptr<const DependencySpecTree> (const std::string &)> & f, const std::tr1::shared_ptr<const DependencyLabelSequence> & s) : func(f), labels(s) @@ -155,7 +154,7 @@ namespace paludis template <typename C_> FakeMetadataSpecTreeKey<C_>::FakeMetadataSpecTreeKey(const std::string & r, const std::string & h, const std::string & v, - const std::tr1::function<const std::tr1::shared_ptr<const typename C_::ConstItem> (const std::string &)> & f, const MetadataKeyType t) : + const std::tr1::function<const std::tr1::shared_ptr<const C_> (const std::string &)> & f, const MetadataKeyType t) : MetadataSpecTreeKey<C_>(r, h, t), PrivateImplementationPattern<FakeMetadataSpecTreeKey<C_> >(new Implementation<FakeMetadataSpecTreeKey<C_> >(f)), _imp(PrivateImplementationPattern<FakeMetadataSpecTreeKey<C_> >::_imp) @@ -177,7 +176,7 @@ FakeMetadataSpecTreeKey<C_>::set_from_string(const std::string & s) } template <typename C_> -const std::tr1::shared_ptr<const typename C_::ConstItem> +const std::tr1::shared_ptr<const C_> FakeMetadataSpecTreeKey<C_>::value() const { return _imp->value; @@ -198,7 +197,7 @@ FakeMetadataSpecTreeKey<C_>::pretty_print_flat(const typename C_::ItemFormatter } FakeMetadataSpecTreeKey<FetchableURISpecTree>::FakeMetadataSpecTreeKey(const std::string & r, const std::string & h, const std::string & v, - const std::tr1::function<const std::tr1::shared_ptr<const FetchableURISpecTree::ConstItem> (const std::string &)> & f, const MetadataKeyType t) : + const std::tr1::function<const std::tr1::shared_ptr<const FetchableURISpecTree> (const std::string &)> & f, const MetadataKeyType t) : MetadataSpecTreeKey<FetchableURISpecTree>(r, h, t), PrivateImplementationPattern<FakeMetadataSpecTreeKey<FetchableURISpecTree> >( new Implementation<FakeMetadataSpecTreeKey<FetchableURISpecTree> >(f)), @@ -218,7 +217,7 @@ FakeMetadataSpecTreeKey<FetchableURISpecTree>::set_from_string(const std::string _imp->value = _imp->func(s); } -const std::tr1::shared_ptr<const FetchableURISpecTree::ConstItem> +const std::tr1::shared_ptr<const FetchableURISpecTree> FakeMetadataSpecTreeKey<FetchableURISpecTree>::value() const { return _imp->value; @@ -243,7 +242,7 @@ FakeMetadataSpecTreeKey<FetchableURISpecTree>::initial_label() const } FakeMetadataSpecTreeKey<DependencySpecTree>::FakeMetadataSpecTreeKey(const std::string & r, const std::string & h, const std::string & v, - const std::tr1::function<const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> (const std::string &)> & f, + const std::tr1::function<const std::tr1::shared_ptr<const DependencySpecTree> (const std::string &)> & f, const std::tr1::shared_ptr<const DependencyLabelSequence> & s, const MetadataKeyType t) : MetadataSpecTreeKey<DependencySpecTree>(r, h, t), PrivateImplementationPattern<FakeMetadataSpecTreeKey<DependencySpecTree> >( @@ -264,7 +263,7 @@ FakeMetadataSpecTreeKey<DependencySpecTree>::set_from_string(const std::string & _imp->value = _imp->func(s); } -const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> +const std::tr1::shared_ptr<const DependencySpecTree> FakeMetadataSpecTreeKey<DependencySpecTree>::value() const { return _imp->value; @@ -833,15 +832,11 @@ FakePackageID::supports_action(const SupportsActionTestBase & b) const namespace { - struct LicenceChecker : - ConstVisitor<LicenseSpecTree>, - ConstVisitor<LicenseSpecTree>::VisitConstSequence<LicenceChecker, AllDepSpec> + struct LicenceChecker { - using ConstVisitor<LicenseSpecTree>::VisitConstSequence<LicenceChecker, AllDepSpec>::visit_sequence; - bool ok; const Environment * const env; - bool (Environment::* const func) (const std::string &, const PackageID &) const; + bool (Environment::* const func) (const std::string &, const PackageID &) const; const PackageID * const id; LicenceChecker(const Environment * const e, @@ -854,20 +849,19 @@ namespace { } - void visit_sequence(const AnyDepSpec &, - LicenseSpecTree::ConstSequenceIterator begin, - LicenseSpecTree::ConstSequenceIterator end) + void visit(const LicenseSpecTree::NodeType<AnyDepSpec>::Type & node) { bool local_ok(false); - if (begin == end) + if (node.begin() == node.end()) local_ok = true; else { - for ( ; begin != end ; ++begin) + for (LicenseSpecTree::NodeType<AnyDepSpec>::Type::ConstIterator c(node.begin()), c_end(node.end()) ; + c != c_end ; ++c) { Save<bool> save_ok(&ok, true); - begin->accept(*this); + (*c)->accept(*this); local_ok |= ok; } } @@ -875,17 +869,20 @@ namespace ok &= local_ok; } - void visit_sequence(const ConditionalDepSpec & spec, - LicenseSpecTree::ConstSequenceIterator begin, - LicenseSpecTree::ConstSequenceIterator end) + void visit(const LicenseSpecTree::NodeType<AllDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + + void visit(const LicenseSpecTree::NodeType<ConditionalDepSpec>::Type & node) { - if (spec.condition_met()) - std::for_each(begin, end, accept_visitor(*this)); + if (node.spec()->condition_met()) + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } - void visit_leaf(const LicenseDepSpec & spec) + void visit(const LicenseSpecTree::NodeType<LicenseDepSpec>::Type & node) { - if (! (env->*func)(spec.text(), *id)) + if (! (env->*func)(node.spec()->text(), *id)) ok = false; } }; @@ -910,7 +907,7 @@ FakePackageID::need_masks_added() const if (license_key()) { LicenceChecker c(_imp->env, &Environment::accept_license, this); - license_key()->value()->accept(c); + license_key()->value()->root()->accept(c); if (! c.ok) add_mask(make_shared_ptr(new FakeUnacceptedMask('L', "license", license_key()))); } diff --git a/paludis/repositories/fake/fake_package_id.hh b/paludis/repositories/fake/fake_package_id.hh index 368324d77..c9aef6834 100644 --- a/paludis/repositories/fake/fake_package_id.hh +++ b/paludis/repositories/fake/fake_package_id.hh @@ -70,10 +70,10 @@ namespace paludis public: FakeMetadataSpecTreeKey(const std::string &, const std::string &, const std::string &, - const std::tr1::function<const std::tr1::shared_ptr<const typename C_::ConstItem> (const std::string &)> &, const MetadataKeyType); + const std::tr1::function<const std::tr1::shared_ptr<const C_> (const std::string &)> &, const MetadataKeyType); ~FakeMetadataSpecTreeKey(); - virtual const std::tr1::shared_ptr<const typename C_::ConstItem> value() const + virtual const std::tr1::shared_ptr<const C_> value() const PALUDIS_ATTRIBUTE((warn_unused_result)); void set_from_string(const std::string &); @@ -95,11 +95,11 @@ namespace paludis public: FakeMetadataSpecTreeKey(const std::string &, const std::string &, const std::string &, - const std::tr1::function<const std::tr1::shared_ptr<const FetchableURISpecTree::ConstItem> (const std::string &)> &, + const std::tr1::function<const std::tr1::shared_ptr<const FetchableURISpecTree> (const std::string &)> &, const MetadataKeyType); ~FakeMetadataSpecTreeKey(); - virtual const std::tr1::shared_ptr<const FetchableURISpecTree::ConstItem> value() const + virtual const std::tr1::shared_ptr<const FetchableURISpecTree> value() const PALUDIS_ATTRIBUTE((warn_unused_result)); void set_from_string(const std::string &); @@ -124,12 +124,12 @@ namespace paludis public: FakeMetadataSpecTreeKey(const std::string &, const std::string &, const std::string &, - const std::tr1::function<const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> (const std::string &)> &, + const std::tr1::function<const std::tr1::shared_ptr<const DependencySpecTree> (const std::string &)> &, const std::tr1::shared_ptr<const DependencyLabelSequence> &, const MetadataKeyType); ~FakeMetadataSpecTreeKey(); - virtual const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> value() const + virtual const std::tr1::shared_ptr<const DependencySpecTree> value() const PALUDIS_ATTRIBUTE((warn_unused_result)); void set_from_string(const std::string &); diff --git a/paludis/repositories/fake/fake_repository.cc b/paludis/repositories/fake/fake_repository.cc index a9361b869..9bca8104e 100644 --- a/paludis/repositories/fake/fake_repository.cc +++ b/paludis/repositories/fake/fake_repository.cc @@ -23,8 +23,8 @@ #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/make_shared_ptr.hh> #include <paludis/util/sequence.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/make_named_values.hh> +#include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/distribution.hh> #include <paludis/environment.hh> #include <paludis/package_id.hh> diff --git a/paludis/repositories/fake/fake_repository_base.cc b/paludis/repositories/fake/fake_repository_base.cc index c438e3ae2..a4a900267 100644 --- a/paludis/repositories/fake/fake_repository_base.cc +++ b/paludis/repositories/fake/fake_repository_base.cc @@ -47,7 +47,7 @@ namespace paludis std::tr1::shared_ptr<CategoryNamePartSet> category_names; std::map<CategoryNamePart, std::tr1::shared_ptr<PackageNamePartSet> > package_names; std::map<QualifiedPackageName, std::tr1::shared_ptr<PackageIDSequence> > ids; - std::map<SetName, std::tr1::shared_ptr<SetSpecTree::ConstItem> > sets; + std::map<SetName, std::tr1::shared_ptr<const SetSpecTree> > sets; const Environment * const env; @@ -157,17 +157,17 @@ FakeRepositoryBase::invalidate_masks() } void -FakeRepositoryBase::add_package_set(const SetName & n, const std::tr1::shared_ptr<SetSpecTree::ConstItem> & s) +FakeRepositoryBase::add_package_set(const SetName & n, const std::tr1::shared_ptr<const SetSpecTree> & s) { _imp->sets.insert(std::make_pair(n, s)); } -std::tr1::shared_ptr<SetSpecTree::ConstItem> +const std::tr1::shared_ptr<const SetSpecTree> FakeRepositoryBase::package_set(const SetName & id) const { - std::map<SetName, std::tr1::shared_ptr<SetSpecTree::ConstItem> >::const_iterator i(_imp->sets.find(id)); + std::map<SetName, std::tr1::shared_ptr<const SetSpecTree> >::const_iterator i(_imp->sets.find(id)); if (_imp->sets.end() == i) - return std::tr1::shared_ptr<SetSpecTree::ConstItem>(); + return std::tr1::shared_ptr<const SetSpecTree>(); else return i->second; } @@ -177,7 +177,7 @@ FakeRepositoryBase::sets_list() const { std::tr1::shared_ptr<SetNameSet> result(new SetNameSet); std::transform(_imp->sets.begin(), _imp->sets.end(), result->inserter(), - std::tr1::mem_fn(&std::pair<const SetName, std::tr1::shared_ptr<SetSpecTree::ConstItem> >::first)); + std::tr1::mem_fn(&std::pair<const SetName, std::tr1::shared_ptr<const SetSpecTree> >::first)); return result; } diff --git a/paludis/repositories/fake/fake_repository_base.hh b/paludis/repositories/fake/fake_repository_base.hh index 6b02bb3cb..195dbacb4 100644 --- a/paludis/repositories/fake/fake_repository_base.hh +++ b/paludis/repositories/fake/fake_repository_base.hh @@ -95,7 +95,7 @@ namespace paludis /** * Add a package set. */ - void add_package_set(const SetName &, const std::tr1::shared_ptr<SetSpecTree::ConstItem> &); + void add_package_set(const SetName &, const std::tr1::shared_ptr<const SetSpecTree> &); virtual void invalidate(); @@ -108,7 +108,7 @@ namespace paludis /* RepositorySetsInterface */ - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> package_set(const SetName & id) const + virtual const std::tr1::shared_ptr<const SetSpecTree> package_set(const SetName & id) const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual std::tr1::shared_ptr<const SetNameSet> sets_list() const diff --git a/paludis/repositories/gems/gem_specification.cc b/paludis/repositories/gems/gem_specification.cc index 696a36c4a..3d0420d79 100644 --- a/paludis/repositories/gems/gem_specification.cc +++ b/paludis/repositories/gems/gem_specification.cc @@ -20,7 +20,6 @@ #include <paludis/repositories/gems/gem_specification.hh> #include <paludis/repositories/gems/yaml.hh> #include <paludis/util/private_implementation_pattern-impl.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/mutex.hh> #include <paludis/util/stringify.hh> #include <paludis/name.hh> diff --git a/paludis/repositories/gems/gem_specification_TEST.cc b/paludis/repositories/gems/gem_specification_TEST.cc index 18aa09231..bf9ae0d5b 100644 --- a/paludis/repositories/gems/gem_specification_TEST.cc +++ b/paludis/repositories/gems/gem_specification_TEST.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -22,7 +22,6 @@ #include <paludis/repositories/gems/gem_specification.hh> #include <paludis/repositories/gems/yaml.hh> #include <paludis/environments/test/test_environment.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/simple_visitor_cast.hh> #include <paludis/util/set.hh> #include <paludis/name.hh> diff --git a/paludis/repositories/gems/gem_specifications.cc b/paludis/repositories/gems/gem_specifications.cc index bc72fade0..5929f65d8 100644 --- a/paludis/repositories/gems/gem_specifications.cc +++ b/paludis/repositories/gems/gem_specifications.cc @@ -23,7 +23,6 @@ #include <paludis/name.hh> #include <paludis/version_spec.hh> #include <paludis/util/private_implementation_pattern-impl.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/log.hh> #include <paludis/util/stringify.hh> #include <paludis/util/make_shared_ptr.hh> diff --git a/paludis/repositories/gems/gems_repository.cc b/paludis/repositories/gems/gems_repository.cc index c068495ae..a272ac34d 100644 --- a/paludis/repositories/gems/gems_repository.cc +++ b/paludis/repositories/gems/gems_repository.cc @@ -31,7 +31,6 @@ #include <paludis/util/set.hh> #include <paludis/util/sequence.hh> #include <paludis/util/mutex.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/hashes.hh> #include <paludis/util/make_named_values.hh> #include <paludis/action.hh> diff --git a/paludis/repositories/gems/installed_gems_repository.cc b/paludis/repositories/gems/installed_gems_repository.cc index ca6c978ab..903f1d04f 100644 --- a/paludis/repositories/gems/installed_gems_repository.cc +++ b/paludis/repositories/gems/installed_gems_repository.cc @@ -32,7 +32,6 @@ #include <paludis/util/sequence.hh> #include <paludis/util/is_file_with_extension.hh> #include <paludis/util/make_shared_ptr.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/system.hh> #include <paludis/util/mutex.hh> #include <paludis/util/log.hh> diff --git a/paludis/repositories/gems/yaml.cc b/paludis/repositories/gems/yaml.cc index cd016425a..2c6aba088 100644 --- a/paludis/repositories/gems/yaml.cc +++ b/paludis/repositories/gems/yaml.cc @@ -20,7 +20,6 @@ #include "yaml.hh" #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/instantiation_policy-impl.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/make_shared_ptr.hh> #include <paludis/util/wrapped_forward_iterator-impl.hh> #include <tr1/functional> @@ -28,6 +27,7 @@ #include <cstring> #include <algorithm> #include <map> +#include <list> using namespace paludis; using namespace paludis::yaml; diff --git a/paludis/repositories/gems/yaml_TEST.cc b/paludis/repositories/gems/yaml_TEST.cc index 08a8b3110..25c98ce73 100644 --- a/paludis/repositories/gems/yaml_TEST.cc +++ b/paludis/repositories/gems/yaml_TEST.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -20,7 +20,6 @@ #include <test/test_runner.hh> #include <test/test_framework.hh> #include <paludis/repositories/gems/yaml.hh> -#include <paludis/util/visitor-impl.hh> #include <algorithm> #include <sstream> diff --git a/paludis/repositories/unavailable/unavailable_id.cc b/paludis/repositories/unavailable/unavailable_id.cc index 08f728e7b..dd9bc1252 100644 --- a/paludis/repositories/unavailable/unavailable_id.cc +++ b/paludis/repositories/unavailable/unavailable_id.cc @@ -21,11 +21,11 @@ #include <paludis/repositories/unavailable/unavailable_repository.hh> #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/stringify.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/simple_visitor_cast.hh> #include <paludis/util/set.hh> #include <paludis/util/make_shared_ptr.hh> #include <paludis/util/hashes.hh> +#include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/name.hh> #include <paludis/version_spec.hh> #include <paludis/metadata_key.hh> diff --git a/paludis/repositories/unavailable/unavailable_repository.cc b/paludis/repositories/unavailable/unavailable_repository.cc index 7d45460ce..37280b616 100644 --- a/paludis/repositories/unavailable/unavailable_repository.cc +++ b/paludis/repositories/unavailable/unavailable_repository.cc @@ -22,7 +22,6 @@ #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/active_object_ptr.hh> #include <paludis/util/deferred_construction_ptr.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/stringify.hh> #include <paludis/util/tokeniser.hh> #include <paludis/util/make_named_values.hh> diff --git a/paludis/repositories/unpackaged/dep_parser.cc b/paludis/repositories/unpackaged/dep_parser.cc index f30e36601..fa0f96e30 100644 --- a/paludis/repositories/unpackaged/dep_parser.cc +++ b/paludis/repositories/unpackaged/dep_parser.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -22,20 +22,21 @@ #include <paludis/util/strip.hh> #include <paludis/util/exception.hh> #include <paludis/util/options.hh> +#include <paludis/util/make_shared_ptr.hh> #include <paludis/dep_spec.hh> #include <paludis/user_dep_spec.hh> +#include <paludis/spec_tree.hh> #include <list> using namespace paludis; using namespace paludis::unpackaged_repositories; -std::tr1::shared_ptr<const DependencySpecTree::ConstItem> +std::tr1::shared_ptr<const DependencySpecTree> DepParser::parse(const Environment * const env, const std::string & s) { Context context("When parsing '" + s + "':"); - std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > result( - new ConstTreeSequence<DependencySpecTree, AllDepSpec>(std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); + std::tr1::shared_ptr<DependencySpecTree> result(new DependencySpecTree(make_shared_ptr(new AllDepSpec))); std::list<std::string> tokens; tokenise<delim_kind::AnyOfTag, delim_mode::DelimiterTag>(s, ",", "", std::back_inserter(tokens)); @@ -49,10 +50,9 @@ DepParser::parse(const Environment * const env, const std::string & s) if (a.empty()) continue; - std::tr1::shared_ptr<TreeLeaf<DependencySpecTree, PackageDepSpec> > spec( - new TreeLeaf<DependencySpecTree, PackageDepSpec>(std::tr1::shared_ptr<PackageDepSpec>( - new PackageDepSpec(parse_user_package_dep_spec(a, env, UserPackageDepSpecOptions() + updso_no_disambiguation))))); - result->add(spec); + std::tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(parse_user_package_dep_spec(a, env, + UserPackageDepSpecOptions() + updso_no_disambiguation))); + result->root()->append(spec); } return result; diff --git a/paludis/repositories/unpackaged/dep_parser.hh b/paludis/repositories/unpackaged/dep_parser.hh index c65a1f773..69482d8a0 100644 --- a/paludis/repositories/unpackaged/dep_parser.hh +++ b/paludis/repositories/unpackaged/dep_parser.hh @@ -21,7 +21,7 @@ #define PALUDIS_GUARD_PALUDIS_REPOSITORIES_UNPACKAGED_DEP_PARSER_HH 1 #include <paludis/util/instantiation_policy.hh> -#include <paludis/dep_tree.hh> +#include <paludis/spec_tree-fwd.hh> #include <paludis/environment-fwd.hh> namespace paludis @@ -32,7 +32,7 @@ namespace paludis private InstantiationPolicy<DepParser, instantiation_method::NonInstantiableTag> { public: - static std::tr1::shared_ptr<const DependencySpecTree::ConstItem> parse( + static std::tr1::shared_ptr<const DependencySpecTree> parse( const Environment * const env, const std::string &); }; } diff --git a/paludis/repositories/unpackaged/dep_parser_TEST.cc b/paludis/repositories/unpackaged/dep_parser_TEST.cc index bf7ccfe46..85e478cba 100644 --- a/paludis/repositories/unpackaged/dep_parser_TEST.cc +++ b/paludis/repositories/unpackaged/dep_parser_TEST.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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,7 +21,6 @@ #include <paludis/repositories/unpackaged/dep_printer.hh> #include <paludis/environments/test/test_environment.hh> #include <paludis/stringify_formatter.hh> -#include <paludis/util/visitor-impl.hh> #include <test/test_framework.hh> #include <test/test_runner.hh> @@ -38,11 +37,11 @@ namespace test_cases void run() { TestEnvironment env; - std::tr1::shared_ptr<const DependencySpecTree::ConstItem> spec( + std::tr1::shared_ptr<const DependencySpecTree> spec( DepParser::parse(&env, "cat/one , cat/two, cat/three\n")); StringifyFormatter f; DepPrinter p(&env, f, true); - spec->accept(p); + spec->root()->accept(p); TEST_CHECK_EQUAL(p.result(), "cat/one, cat/two, cat/three"); } } test_dep_parser; diff --git a/paludis/repositories/unpackaged/dep_printer.cc b/paludis/repositories/unpackaged/dep_printer.cc index a325a1e31..292a83b1d 100644 --- a/paludis/repositories/unpackaged/dep_printer.cc +++ b/paludis/repositories/unpackaged/dep_printer.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -18,7 +18,6 @@ */ #include <paludis/repositories/unpackaged/dep_printer.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/fs_entry.hh> #include <paludis/util/options.hh> @@ -71,7 +70,7 @@ DepPrinter::~DepPrinter() } void -DepPrinter::visit_leaf(const PackageDepSpec & p) +DepPrinter::visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node) { if (! _imp->flat) _imp->s << _imp->formatter.indent(_imp->indent); @@ -82,34 +81,52 @@ DepPrinter::visit_leaf(const PackageDepSpec & p) if (_imp->env) { - if (! (*_imp->env)[selection::SomeArbitraryVersion(generator::Matches(p, MatchPackageOptions()) | + if (! (*_imp->env)[selection::SomeArbitraryVersion(generator::Matches(*node.spec(), MatchPackageOptions()) | filter::InstalledAtRoot(_imp->env->root()))]->empty()) - _imp->s << _imp->formatter.format(p, format::Installed()); - else if (! (*_imp->env)[selection::SomeArbitraryVersion(generator::Matches(p, MatchPackageOptions()) | + _imp->s << _imp->formatter.format(*node.spec(), format::Installed()); + else if (! (*_imp->env)[selection::SomeArbitraryVersion(generator::Matches(*node.spec(), MatchPackageOptions()) | filter::SupportsAction<InstallAction>() | filter::NotMasked())]->empty()) - _imp->s << _imp->formatter.format(p, format::Installable()); + _imp->s << _imp->formatter.format(*node.spec(), format::Installable()); else - _imp->s << _imp->formatter.format(p, format::Plain()); + _imp->s << _imp->formatter.format(*node.spec(), format::Plain()); } else - _imp->s << _imp->formatter.format(p, format::Plain()); + _imp->s << _imp->formatter.format(*node.spec(), format::Plain()); if (! _imp->flat) _imp->s << _imp->formatter.newline(); } void -DepPrinter::visit_leaf(const BlockDepSpec &) +DepPrinter::visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type &) { } void -DepPrinter::visit_leaf(const DependencyLabelsDepSpec &) +DepPrinter::visit(const DependencySpecTree::NodeType<DependencyLabelsDepSpec>::Type &) { } void -DepPrinter::visit_leaf(const NamedSetDepSpec & p) +DepPrinter::visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node) +{ + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); +} + +void +DepPrinter::visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node) +{ + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); +} + +void +DepPrinter::visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node) +{ + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); +} + +void +DepPrinter::visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & node) { if (! _imp->flat) _imp->s << _imp->formatter.indent(_imp->indent); @@ -118,7 +135,7 @@ DepPrinter::visit_leaf(const NamedSetDepSpec & p) else _imp->need_comma = true; - _imp->s << _imp->formatter.format(p, format::Plain()); + _imp->s << _imp->formatter.format(*node.spec(), format::Plain()); if (! _imp->flat) _imp->s << _imp->formatter.newline(); diff --git a/paludis/repositories/unpackaged/dep_printer.hh b/paludis/repositories/unpackaged/dep_printer.hh index 1d43fd80a..56ff208bb 100644 --- a/paludis/repositories/unpackaged/dep_printer.hh +++ b/paludis/repositories/unpackaged/dep_printer.hh @@ -20,9 +20,8 @@ #ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_UNPACKAGED_DEP_PRINTER_HH #define PALUDIS_GUARD_PALUDIS_REPOSITORIES_UNPACKAGED_DEP_PRINTER_HH 1 -#include <paludis/util/visitor.hh> #include <paludis/util/private_implementation_pattern.hh> -#include <paludis/dep_tree.hh> +#include <paludis/spec_tree.hh> #include <paludis/formatter.hh> #include <paludis/environment-fwd.hh> @@ -31,10 +30,6 @@ namespace paludis namespace unpackaged_repositories { class PALUDIS_VISIBLE DepPrinter : - public ConstVisitor<DependencySpecTree>, - public ConstVisitor<DependencySpecTree>::VisitConstSequence<DepPrinter, AllDepSpec>, - public ConstVisitor<DependencySpecTree>::VisitConstSequence<DepPrinter, AnyDepSpec>, - public ConstVisitor<DependencySpecTree>::VisitConstSequence<DepPrinter, ConditionalDepSpec>, private PrivateImplementationPattern<DepPrinter> { public: @@ -43,14 +38,13 @@ namespace paludis const std::string result() const; - void visit_leaf(const BlockDepSpec &); - void visit_leaf(const PackageDepSpec &); - void visit_leaf(const NamedSetDepSpec &); - void visit_leaf(const DependencyLabelsDepSpec &); - - using ConstVisitor<DependencySpecTree>::VisitConstSequence<DepPrinter, AllDepSpec>::visit_sequence; - using ConstVisitor<DependencySpecTree>::VisitConstSequence<DepPrinter, AnyDepSpec>::visit_sequence; - using ConstVisitor<DependencySpecTree>::VisitConstSequence<DepPrinter, ConditionalDepSpec>::visit_sequence; + void visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<DependencyLabelsDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node); }; } } diff --git a/paludis/repositories/unpackaged/installed_id.cc b/paludis/repositories/unpackaged/installed_id.cc index b462085c4..f8f021534 100644 --- a/paludis/repositories/unpackaged/installed_id.cc +++ b/paludis/repositories/unpackaged/installed_id.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -28,12 +28,11 @@ #include <paludis/util/fs_entry.hh> #include <paludis/util/stringify.hh> #include <paludis/util/dir_iterator.hh> -#include <paludis/util/visitor-impl.hh> -#include <paludis/util/visitor_cast.hh> #include <paludis/util/make_shared_ptr.hh> #include <paludis/util/strip.hh> #include <paludis/util/hashes.hh> #include <paludis/util/make_named_values.hh> +#include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/name.hh> #include <paludis/version_spec.hh> #include <paludis/package_database.hh> @@ -227,7 +226,7 @@ namespace { private: const Environment * const _env; - mutable std::tr1::shared_ptr<const DependencySpecTree::ConstItem> _v; + mutable std::tr1::shared_ptr<const DependencySpecTree> _v; mutable Mutex _mutex; const FSEntry _f; const std::tr1::shared_ptr<const DependencyLabelSequence> _labels; @@ -243,7 +242,7 @@ namespace { } - const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> value() const + const std::tr1::shared_ptr<const DependencySpecTree> value() const { Lock l(_mutex); if (_v) @@ -264,7 +263,7 @@ namespace pretty_print(const DependencySpecTree::ItemFormatter & f) const { DepPrinter p(_env, f, false); - value()->accept(p); + value()->root()->accept(p); return p.result(); } @@ -272,7 +271,7 @@ namespace pretty_print_flat(const DependencySpecTree::ItemFormatter & f) const { DepPrinter p(_env, f, true); - value()->accept(p); + value()->root()->accept(p); return p.result(); } @@ -768,3 +767,4 @@ InstalledUnpackagedID::choices_key() const { return std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const Choices> > >(); } + diff --git a/paludis/repositories/unpackaged/installed_repository.cc b/paludis/repositories/unpackaged/installed_repository.cc index 691cb23fc..5f435bd13 100644 --- a/paludis/repositories/unpackaged/installed_repository.cc +++ b/paludis/repositories/unpackaged/installed_repository.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -25,7 +25,6 @@ #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/sequence.hh> #include <paludis/util/make_shared_ptr.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/stringify.hh> #include <paludis/util/set.hh> #include <paludis/util/dir_iterator.hh> @@ -33,6 +32,8 @@ #include <paludis/util/cookie.hh> #include <paludis/util/simple_visitor_cast.hh> #include <paludis/util/make_named_values.hh> +#include <paludis/util/indirect_iterator.hh> +#include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/stringify_formatter.hh> #include <paludis/action.hh> #include <paludis/environment.hh> @@ -413,7 +414,7 @@ InstalledUnpackagedRepository::deindex(const QualifiedPackageName & q) const _imp->ndbam.deindex(q); } -std::tr1::shared_ptr<SetSpecTree::ConstItem> +const std::tr1::shared_ptr<const SetSpecTree> InstalledUnpackagedRepository::package_set(const SetName & s) const { using namespace std::tr1::placeholders; @@ -423,8 +424,7 @@ InstalledUnpackagedRepository::package_set(const SetName & s) const if ("everything" == s.data()) { - std::tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > result(new ConstTreeSequence<SetSpecTree, AllDepSpec>( - make_shared_ptr(new AllDepSpec))); + std::tr1::shared_ptr<SetSpecTree> result(new SetSpecTree(make_shared_ptr(new AllDepSpec))); std::tr1::shared_ptr<GeneralSetDepTag> tag(new GeneralSetDepTag(s, stringify(name()))); std::tr1::shared_ptr<const CategoryNamePartSet> cats(category_names()); @@ -437,14 +437,14 @@ InstalledUnpackagedRepository::package_set(const SetName & s) const { std::tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(make_package_dep_spec().package(QualifiedPackageName(*e)))); spec->set_tag(tag); - result->add(make_shared_ptr(new TreeLeaf<SetSpecTree, PackageDepSpec>(spec))); + result->root()->append(spec); } } return result; } else - return std::tr1::shared_ptr<SetSpecTree::ConstItem>(); + return make_null_shared_ptr(); } std::tr1::shared_ptr<const SetNameSet> diff --git a/paludis/repositories/unpackaged/installed_repository.hh b/paludis/repositories/unpackaged/installed_repository.hh index 70dca38b3..11f7dc2f8 100644 --- a/paludis/repositories/unpackaged/installed_repository.hh +++ b/paludis/repositories/unpackaged/installed_repository.hh @@ -106,7 +106,7 @@ namespace paludis virtual bool some_ids_might_support_action(const SupportsActionTestBase &) const; - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> package_set(const SetName & id) const + virtual const std::tr1::shared_ptr<const SetSpecTree> package_set(const SetName & id) const PALUDIS_ATTRIBUTE((warn_unused_result)); /* Keys */ diff --git a/paludis/repositories/unpackaged/installed_repository_TEST.cc b/paludis/repositories/unpackaged/installed_repository_TEST.cc index c5c011d91..7fc8ff1fd 100644 --- a/paludis/repositories/unpackaged/installed_repository_TEST.cc +++ b/paludis/repositories/unpackaged/installed_repository_TEST.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -31,7 +31,6 @@ #include <paludis/selection.hh> #include <paludis/util/sequence.hh> #include <paludis/util/join.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/options.hh> #include <paludis/util/make_named_values.hh> #include <test/test_framework.hh> diff --git a/paludis/repositories/unpackaged/unpackaged_id.cc b/paludis/repositories/unpackaged/unpackaged_id.cc index 2a345b32e..d9e76a4b1 100644 --- a/paludis/repositories/unpackaged/unpackaged_id.cc +++ b/paludis/repositories/unpackaged/unpackaged_id.cc @@ -25,7 +25,6 @@ #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/fs_entry.hh> #include <paludis/util/stringify.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/simple_visitor_cast.hh> #include <paludis/util/make_shared_ptr.hh> #include <paludis/util/log.hh> diff --git a/paludis/repositories/unpackaged/unpackaged_key.cc b/paludis/repositories/unpackaged/unpackaged_key.cc index ade4af20c..8d0f5b84f 100644 --- a/paludis/repositories/unpackaged/unpackaged_key.cc +++ b/paludis/repositories/unpackaged/unpackaged_key.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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,7 +21,6 @@ #include <paludis/repositories/unpackaged/dep_printer.hh> #include <paludis/repositories/unpackaged/dep_parser.hh> #include <paludis/repositories/unpackaged/unpackaged_id.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/fs_entry.hh> #include <paludis/util/mutex.hh> @@ -41,7 +40,7 @@ namespace paludis struct Implementation<UnpackagedDependencyKey> { const Environment * const env; - const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> value; + const std::tr1::shared_ptr<const DependencySpecTree> value; const std::tr1::shared_ptr<const DependencyLabelSequence> labels; Implementation(const Environment * const e, const std::string & v, @@ -68,7 +67,7 @@ UnpackagedDependencyKey::~UnpackagedDependencyKey() { } -const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> +const std::tr1::shared_ptr<const DependencySpecTree> UnpackagedDependencyKey::value() const { return _imp->value; @@ -78,7 +77,7 @@ std::string UnpackagedDependencyKey::pretty_print(const DependencySpecTree::ItemFormatter & f) const { DepPrinter p(_imp->env, f, false); - _imp->value->accept(p); + _imp->value->root()->accept(p); return p.result(); } @@ -86,7 +85,7 @@ std::string UnpackagedDependencyKey::pretty_print_flat(const DependencySpecTree::ItemFormatter & f) const { DepPrinter p(_imp->env, f, true); - _imp->value->accept(p); + _imp->value->root()->accept(p); return p.result(); } diff --git a/paludis/repositories/unpackaged/unpackaged_key.hh b/paludis/repositories/unpackaged/unpackaged_key.hh index f06b58532..5896e0523 100644 --- a/paludis/repositories/unpackaged/unpackaged_key.hh +++ b/paludis/repositories/unpackaged/unpackaged_key.hh @@ -43,7 +43,7 @@ namespace paludis const std::string & v); ~UnpackagedDependencyKey(); - const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> value() const; + const std::tr1::shared_ptr<const DependencySpecTree> value() const; std::string pretty_print(const DependencySpecTree::ItemFormatter & f) const; diff --git a/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc b/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc index cce5e2496..9e54b619b 100644 --- a/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc +++ b/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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,7 +21,6 @@ #include <paludis/repositories/unpackaged/installed_repository.hh> #include <paludis/environments/test/test_environment.hh> #include <paludis/package_database.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/package_id.hh> #include <paludis/action.hh> #include <paludis/metadata_key.hh> diff --git a/paludis/repositories/unwritten/unwritten_id.cc b/paludis/repositories/unwritten/unwritten_id.cc index fc391bf4f..c0c7609ff 100644 --- a/paludis/repositories/unwritten/unwritten_id.cc +++ b/paludis/repositories/unwritten/unwritten_id.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008 Ciaran McCreesh + * Copyright (c) 2008, 2009 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,7 +21,6 @@ #include <paludis/repositories/unwritten/unwritten_repository.hh> #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/stringify.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/simple_visitor_cast.hh> #include <paludis/util/set.hh> #include <paludis/util/make_shared_ptr.hh> diff --git a/paludis/repositories/unwritten/unwritten_repository.cc b/paludis/repositories/unwritten/unwritten_repository.cc index 3336623a0..86a717025 100644 --- a/paludis/repositories/unwritten/unwritten_repository.cc +++ b/paludis/repositories/unwritten/unwritten_repository.cc @@ -22,7 +22,6 @@ #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/active_object_ptr.hh> #include <paludis/util/deferred_construction_ptr.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/stringify.hh> #include <paludis/util/tokeniser.hh> #include <paludis/util/make_named_values.hh> diff --git a/paludis/repositories/unwritten/unwritten_repository_file.cc b/paludis/repositories/unwritten/unwritten_repository_file.cc index 8aa7b74b6..5297a291f 100644 --- a/paludis/repositories/unwritten/unwritten_repository_file.cc +++ b/paludis/repositories/unwritten/unwritten_repository_file.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008 Ciaran McCreesh + * Copyright (c) 2008, 2009 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 @@ -28,7 +28,6 @@ #include <paludis/util/tokeniser.hh> #include <paludis/util/make_shared_ptr.hh> #include <paludis/util/join.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/name.hh> #include <paludis/version_spec.hh> #include <paludis/literal_metadata_key.hh> @@ -74,8 +73,7 @@ UnwrittenRepositoryFile::end() const namespace { - struct UnwrittenHomepagePrinter : - ConstVisitor<SimpleURISpecTree> + struct UnwrittenHomepagePrinter { std::stringstream s; const SimpleURISpecTree::ItemFormatter & formatter; @@ -85,43 +83,37 @@ namespace { } - void visit_sequence( - const AllDepSpec &, - SimpleURISpecTree::ConstSequenceIterator cur, - SimpleURISpecTree::ConstSequenceIterator end) + void visit(const SimpleURISpecTree::NodeType<AllDepSpec>::Type & node) { - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } - void visit_sequence( - const ConditionalDepSpec &, - SimpleURISpecTree::ConstSequenceIterator cur, - SimpleURISpecTree::ConstSequenceIterator end) + void visit(const SimpleURISpecTree::NodeType<ConditionalDepSpec>::Type & node) { - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } - void visit_leaf(const SimpleURIDepSpec & u) + void visit(const SimpleURISpecTree::NodeType<SimpleURIDepSpec>::Type & node) { if (! s.str().empty()) s << " "; - s << formatter.format(u, format::Plain()); + s << formatter.format(*node.spec(), format::Plain()); } }; struct UnwrittenHomepageKey : MetadataSpecTreeKey<SimpleURISpecTree> { - const std::tr1::shared_ptr<const SimpleURISpecTree::ConstItem> vv; + const std::tr1::shared_ptr<const SimpleURISpecTree> vv; UnwrittenHomepageKey(const std::string & r, const std::string & h, const MetadataKeyType t, - const std::tr1::shared_ptr<const SimpleURISpecTree::ConstItem> & v) : + const std::tr1::shared_ptr<const SimpleURISpecTree> & v) : MetadataSpecTreeKey<SimpleURISpecTree>(r, h, t), vv(v) { } - const std::tr1::shared_ptr<const SimpleURISpecTree::ConstItem> value() const + const std::tr1::shared_ptr<const SimpleURISpecTree> value() const { return vv; } @@ -129,14 +121,14 @@ namespace std::string pretty_print(const SimpleURISpecTree::ItemFormatter & f) const { UnwrittenHomepagePrinter p(f); - value()->accept(p); + value()->root()->accept(p); return p.s.str(); } std::string pretty_print_flat(const SimpleURISpecTree::ItemFormatter & f) const { UnwrittenHomepagePrinter p(f); - value()->accept(p); + value()->root()->accept(p); return p.s.str(); } }; @@ -280,14 +272,13 @@ UnwrittenRepositoryFile::_load(const FSEntry & f) else if (token == "homepage") { std::tr1::shared_ptr<AllDepSpec> all_spec(new AllDepSpec); - std::tr1::shared_ptr<ConstTreeSequence<SimpleURISpecTree, AllDepSpec> > spec( - new ConstTreeSequence<SimpleURISpecTree, AllDepSpec>(all_spec)); + std::tr1::shared_ptr<SimpleURISpecTree> tree(new SimpleURISpecTree(all_spec)); std::list<std::string> tokens; tokenise_whitespace(token2, std::back_inserter(tokens)); for (std::list<std::string>::const_iterator t(tokens.begin()), t_end(tokens.end()) ; t != t_end ; ++t) - spec->add(make_shared_ptr(new TreeLeaf<SimpleURISpecTree, SimpleURIDepSpec>(make_shared_ptr(new SimpleURIDepSpec(*t))))); - entry->homepage().reset(new UnwrittenHomepageKey("homepage", "Homepage", mkt_normal, spec)); + tree->root()->append(make_shared_ptr(new SimpleURIDepSpec(*t))); + entry->homepage().reset(new UnwrittenHomepageKey("homepage", "Homepage", mkt_normal, tree)); } else if (token == "comment") entry->comment().reset(new LiteralMetadataValueKey<std::string>("comment", "Comment", mkt_normal, token2)); @@ -330,3 +321,4 @@ template class PrivateImplementationPattern<UnwrittenRepositoryFile>; template class WrappedForwardIterator<UnwrittenRepositoryFile::ConstIteratorTag, const UnwrittenRepositoryFileEntry>; + diff --git a/paludis/repositories/unwritten/unwritten_repository_file.hh b/paludis/repositories/unwritten/unwritten_repository_file.hh index 44b9ad01d..89170c867 100644 --- a/paludis/repositories/unwritten/unwritten_repository_file.hh +++ b/paludis/repositories/unwritten/unwritten_repository_file.hh @@ -27,7 +27,7 @@ #include <paludis/metadata_key-fwd.hh> #include <paludis/name.hh> #include <paludis/version_spec.hh> -#include <paludis/dep_tree-fwd.hh> +#include <paludis/spec_tree-fwd.hh> namespace paludis { diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc index 5f32f546c..bfd3ae8dc 100644 --- a/paludis/repositories/virtuals/installed_virtuals_repository.cc +++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc @@ -30,11 +30,12 @@ #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/sequence.hh> #include <paludis/util/set.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/map.hh> #include <paludis/util/mutex.hh> #include <paludis/util/hashes.hh> #include <paludis/util/make_named_values.hh> +#include <paludis/util/wrapped_forward_iterator.hh> +#include <paludis/util/wrapped_output_iterator.hh> #include <tr1/functional> #include <tr1/unordered_map> diff --git a/paludis/repositories/virtuals/package_id.cc b/paludis/repositories/virtuals/package_id.cc index 0e7be0456..b6504023c 100644 --- a/paludis/repositories/virtuals/package_id.cc +++ b/paludis/repositories/virtuals/package_id.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -23,7 +23,6 @@ #include <paludis/util/stringify.hh> #include <paludis/util/make_shared_ptr.hh> #include <paludis/util/private_implementation_pattern-impl.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/mutex.hh> #include <paludis/util/hashes.hh> #include <paludis/util/make_named_values.hh> @@ -53,30 +52,33 @@ namespace paludis struct Implementation<VirtualsDepKey> { const Environment * const env; - const std::tr1::shared_ptr<const TreeLeaf<DependencySpecTree, PackageDepSpec> > value; + const std::tr1::shared_ptr<DependencySpecTree> value; const std::tr1::shared_ptr<const DependencyLabelSequence> labels; + const std::tr1::shared_ptr<const PackageDepSpec> spec; Implementation(const Environment * const e, const std::tr1::shared_ptr<const PackageID> & v, const std::tr1::shared_ptr<const DependencyLabelSequence> & l, bool exact) : env(e), - value(exact ? - new TreeLeaf<DependencySpecTree, PackageDepSpec>(make_shared_ptr(new PackageDepSpec( - make_package_dep_spec() - .package(v->name()) - .version_requirement(make_named_values<VersionRequirement>( - value_for<n::version_operator>(vo_equal), - value_for<n::version_spec>(v->version()))) - .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(v->slot()))) - .in_repository(v->repository()->name())))) + value(new DependencySpecTree(make_shared_ptr(new AllDepSpec))), + labels(l), + spec(exact ? + make_shared_ptr(new PackageDepSpec( + make_package_dep_spec() + .package(v->name()) + .version_requirement(make_named_values<VersionRequirement>( + value_for<n::version_operator>(vo_equal), + value_for<n::version_spec>(v->version()))) + .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(v->slot()))) + .in_repository(v->repository()->name()))) : - new TreeLeaf<DependencySpecTree, PackageDepSpec>(make_shared_ptr(new PackageDepSpec( - make_package_dep_spec() - .package(v->name()) - ))) - ), - labels(l) + make_shared_ptr(new PackageDepSpec( + make_package_dep_spec() + .package(v->name()) + )) + ) { + value->root()->append(spec); } }; } @@ -95,7 +97,7 @@ VirtualsDepKey::~VirtualsDepKey() { } -const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> +const std::tr1::shared_ptr<const DependencySpecTree> VirtualsDepKey::value() const { return _imp->value; @@ -106,17 +108,17 @@ VirtualsDepKey::pretty_print(const DependencySpecTree::ItemFormatter & f) const { if (_imp->env) { - if (! (*_imp->env)[selection::SomeArbitraryVersion(generator::Matches(*_imp->value->item(), MatchPackageOptions()) | + if (! (*_imp->env)[selection::SomeArbitraryVersion(generator::Matches(*_imp->spec, MatchPackageOptions()) | filter::InstalledAtRoot(_imp->env->root()))]->empty()) - return f.format(*_imp->value->item(), format::Installed()); - else if (! (*_imp->env)[selection::SomeArbitraryVersion(generator::Matches(*_imp->value->item(), MatchPackageOptions()) | + return f.format(*_imp->spec, format::Installed()); + else if (! (*_imp->env)[selection::SomeArbitraryVersion(generator::Matches(*_imp->spec, MatchPackageOptions()) | filter::SupportsAction<InstallAction>() | filter::NotMasked())]->empty()) - return f.format(*_imp->value->item(), format::Installable()); + return f.format(*_imp->spec, format::Installable()); else - return f.format(*_imp->value->item(), format::Plain()); + return f.format(*_imp->spec, format::Plain()); } else - return f.format(*_imp->value->item(), format::Plain()); + return f.format(*_imp->spec, format::Plain()); } std::string diff --git a/paludis/repositories/virtuals/package_id.hh b/paludis/repositories/virtuals/package_id.hh index 094e9d42b..91786a9b0 100644 --- a/paludis/repositories/virtuals/package_id.hh +++ b/paludis/repositories/virtuals/package_id.hh @@ -42,7 +42,7 @@ namespace paludis const bool); ~VirtualsDepKey(); - virtual const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> value() const + virtual const std::tr1::shared_ptr<const DependencySpecTree> value() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual std::string pretty_print(const DependencySpecTree::ItemFormatter &) const diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc index cd9629581..9dd6fca90 100644 --- a/paludis/repositories/virtuals/virtuals_repository.cc +++ b/paludis/repositories/virtuals/virtuals_repository.cc @@ -37,15 +37,17 @@ #include <paludis/util/map.hh> #include <paludis/util/set.hh> #include <paludis/util/sequence.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/mutex.hh> #include <paludis/util/hashes.hh> #include <paludis/util/make_named_values.hh> +#include <paludis/util/wrapped_forward_iterator.hh> +#include <paludis/util/wrapped_output_iterator.hh> #include <tr1/functional> #include <tr1/unordered_map> #include <vector> #include <utility> +#include <algorithm> using namespace paludis; diff --git a/paludis/repository.cc b/paludis/repository.cc index 3c765bb6d..efe41dcf2 100644 --- a/paludis/repository.cc +++ b/paludis/repository.cc @@ -29,7 +29,6 @@ #include <paludis/util/set.hh> #include <paludis/util/set-impl.hh> #include <paludis/util/wrapped_forward_iterator-impl.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/make_named_values.hh> #include <paludis/action.hh> #include <paludis/metadata_key.hh> diff --git a/paludis/repository.hh b/paludis/repository.hh index 2125c0ad4..59f21772c 100644 --- a/paludis/repository.hh +++ b/paludis/repository.hh @@ -23,7 +23,7 @@ #include <paludis/action-fwd.hh> #include <paludis/repository-fwd.hh> #include <paludis/dep_spec-fwd.hh> -#include <paludis/dep_tree.hh> +#include <paludis/spec_tree-fwd.hh> #include <paludis/name.hh> #include <paludis/package_id-fwd.hh> #include <paludis/qa-fwd.hh> @@ -397,7 +397,7 @@ namespace paludis /** * Fetch a package set. */ - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> package_set(const SetName & s) const = 0; + virtual const std::tr1::shared_ptr<const SetSpecTree> package_set(const SetName & s) const = 0; /** * Gives a list of the names of all the sets provided by this repo. diff --git a/paludis/set_file.cc b/paludis/set_file.cc index 293fa5c29..ba9dd3436 100644 --- a/paludis/set_file.cc +++ b/paludis/set_file.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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 @@ -23,7 +23,6 @@ #include <paludis/util/tokeniser.hh> #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/sequence.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/options.hh> #include <paludis/util/mutex.hh> #include <paludis/util/config_file.hh> @@ -58,7 +57,7 @@ namespace public: virtual ~SetFileHandler(); - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> contents() const = 0; + virtual std::tr1::shared_ptr<SetSpecTree> contents() const = 0; virtual void add(const std::string &) = 0; virtual void remove(const std::string &) = 0; virtual void rewrite() const = 0; @@ -72,14 +71,14 @@ namespace const SetFileParams _p; std::list<std::string> _lines; - mutable std::tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > _contents; + mutable std::tr1::shared_ptr<SetSpecTree> _contents; void _create_contents() const; public: PaludisConfHandler(const SetFileParams &); - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> contents() const; + virtual std::tr1::shared_ptr<SetSpecTree> contents() const; virtual void add(const std::string &); virtual void remove(const std::string &); virtual void rewrite() const; @@ -90,12 +89,12 @@ namespace { private: const SetFileParams _p; - std::tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > _contents; + std::tr1::shared_ptr<SetSpecTree> _contents; public: PaludisBashHandler(const SetFileParams &); - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> contents() const; + virtual std::tr1::shared_ptr<SetSpecTree> contents() const; virtual void add(const std::string &) PALUDIS_ATTRIBUTE((noreturn)); virtual void remove(const std::string &) PALUDIS_ATTRIBUTE((noreturn)); virtual void rewrite() const PALUDIS_ATTRIBUTE((noreturn)); @@ -109,14 +108,14 @@ namespace const SetFileParams _p; std::list<std::string> _lines; - mutable std::tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > _contents; + mutable std::tr1::shared_ptr<SetSpecTree> _contents; void _create_contents() const; public: SimpleHandler(const SetFileParams &); - virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> contents() const; + virtual std::tr1::shared_ptr<SetSpecTree> contents() const; virtual void add(const std::string &); virtual void remove(const std::string &); virtual void rewrite() const; @@ -164,7 +163,7 @@ namespace }; void - do_one_conf_line(const std::string & line, std::tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > result, + do_one_conf_line(const std::string & line, std::tr1::shared_ptr<SetSpecTree> result, const SetFileParams & params) { if (line.empty()) @@ -215,16 +214,14 @@ namespace if (! spec) throw InternalError(PALUDIS_HERE, "Bad params.set_name_suffix"); - result->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, NamedSetDepSpec> >( - new TreeLeaf<SetSpecTree, NamedSetDepSpec>(spec))); + result->root()->append(spec); } else { std::tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(params.parser()(tokens.at(1)))); if (params.tag()) spec->set_tag(params.tag()); - result->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >( - new TreeLeaf<SetSpecTree, PackageDepSpec>(spec))); + result->root()->append(spec); } } else if ("?" == tokens.at(0)) @@ -248,8 +245,7 @@ namespace else if (! (*params.environment())[selection::SomeArbitraryVersion( generator::Package(*spec->package_ptr()) | filter::InstalledAtRoot(params.environment()->root()))]->empty()) - result->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >( - new TreeLeaf<SetSpecTree, PackageDepSpec>(spec))); + result->root()->append(spec); } else Log::get_instance()->message("set_file.bad_operator", ll_warning, lc_context) @@ -279,8 +275,7 @@ namespace .slot_requirement(spec->slot_requirement_ptr()), MatchPackageOptions()) | filter::InstalledAtRoot(params.environment()->root()))]->empty()) - result->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >( - new TreeLeaf<SetSpecTree, PackageDepSpec>(spec))); + result->root()->append(spec); } else Log::get_instance()->message("set_file.bad_operator", ll_warning, lc_context) @@ -327,7 +322,7 @@ SimpleHandler::_create_contents() const { Context context("When parsing atoms in simple set file '" + stringify(_p.file_name()) + "':"); - _contents.reset(new ConstTreeSequence<SetSpecTree, AllDepSpec>(std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); + _contents.reset(new SetSpecTree(make_shared_ptr(new AllDepSpec))); for (std::list<std::string>::const_iterator i(_lines.begin()), i_end(_lines.end()) ; i != i_end ; ++i) { @@ -344,16 +339,14 @@ SimpleHandler::_create_contents() const if (std::string::npos == i->find('/')) { std::tr1::shared_ptr<NamedSetDepSpec> p(new NamedSetDepSpec(SetName(*i))); - _contents->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, NamedSetDepSpec> >( - new TreeLeaf<SetSpecTree, NamedSetDepSpec>(p))); + _contents->root()->append(p); } else { std::tr1::shared_ptr<PackageDepSpec> p(new PackageDepSpec(_p.parser()(stringify(*i)))); if (_p.tag()) p->set_tag(_p.tag()); - _contents->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >( - new TreeLeaf<SetSpecTree, PackageDepSpec>(p))); + _contents->root()->append(p); } } catch (const InternalError &) @@ -368,7 +361,7 @@ SimpleHandler::_create_contents() const } } -std::tr1::shared_ptr<SetSpecTree::ConstItem> +std::tr1::shared_ptr<SetSpecTree> SimpleHandler::contents() const { Lock l(_mutex); @@ -434,13 +427,13 @@ PaludisConfHandler::_create_contents() const { Context context("When parsing atoms in paludis conf set file '" + stringify(_p.file_name()) + "':"); - _contents.reset(new ConstTreeSequence<SetSpecTree, AllDepSpec>(std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); + _contents.reset(new SetSpecTree(make_shared_ptr(new AllDepSpec))); for (std::list<std::string>::const_iterator i(_lines.begin()), i_end(_lines.end()) ; i != i_end ; ++i) do_one_conf_line(*i, _contents, _p); } -std::tr1::shared_ptr<SetSpecTree::ConstItem> +std::tr1::shared_ptr<SetSpecTree> PaludisConfHandler::contents() const { Lock l(_mutex); @@ -493,7 +486,7 @@ PaludisBashHandler::PaludisBashHandler(const SetFileParams & p) : _p(p) { Context context("When loading paludis bash set file '" + stringify(_p.file_name()) + "':"); - _contents.reset(new ConstTreeSequence<SetSpecTree, AllDepSpec>(std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); + _contents.reset(new SetSpecTree(make_shared_ptr(new AllDepSpec))); std::stringstream s; Command cmd(Command("bash '" + stringify(_p.file_name()) + "'") @@ -517,11 +510,11 @@ PaludisBashHandler::PaludisBashHandler(const SetFileParams & p) : Log::get_instance()->message("set_file.script.failure", ll_warning, lc_context) << "Set file script '" << _p.file_name() << "' returned non-zero exit status '" << exit_status << "'"; - _contents.reset(new ConstTreeSequence<SetSpecTree, AllDepSpec>(std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))); + _contents.reset(new SetSpecTree(make_shared_ptr(new AllDepSpec))); } } -std::tr1::shared_ptr<SetSpecTree::ConstItem> +std::tr1::shared_ptr<SetSpecTree> PaludisBashHandler::contents() const { return _contents; @@ -570,7 +563,7 @@ SetFile::~SetFile() { } -std::tr1::shared_ptr<SetSpecTree::ConstItem> +const std::tr1::shared_ptr<const SetSpecTree> SetFile::contents() const { return _imp->handler->contents(); diff --git a/paludis/set_file.hh b/paludis/set_file.hh index 42cfc3f8e..3954df95e 100644 --- a/paludis/set_file.hh +++ b/paludis/set_file.hh @@ -27,7 +27,7 @@ #include <paludis/util/options.hh> #include <paludis/util/named_value.hh> #include <paludis/name.hh> -#include <paludis/dep_tree.hh> +#include <paludis/spec_tree.hh> #include <paludis/dep_spec-fwd.hh> #include <paludis/dep_tag-fwd.hh> #include <tr1/functional> @@ -128,7 +128,7 @@ namespace paludis /** * Fetch our contents. */ - std::tr1::shared_ptr<SetSpecTree::ConstItem> contents() const; + const std::tr1::shared_ptr<const SetSpecTree> contents() const; /** * Rewrite our contents. diff --git a/paludis/set_file_TEST.cc b/paludis/set_file_TEST.cc index 71848b948..eeea8d99b 100644 --- a/paludis/set_file_TEST.cc +++ b/paludis/set_file_TEST.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009 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,7 +21,6 @@ #include <test/test_runner.hh> #include <test/test_framework.hh> #include <paludis/util/fs_entry.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/make_named_values.hh> #include <paludis/dep_spec.hh> #include <paludis/user_dep_spec.hh> @@ -33,31 +32,25 @@ using namespace paludis; namespace { - struct SetSpecStringifier : - ConstVisitor<SetSpecTree> + struct SetSpecStringifier { std::ostringstream s; - void - visit_sequence(const AllDepSpec &, - SetSpecTree::ConstSequenceIterator cur, - SetSpecTree::ConstSequenceIterator end) + void visit(const SetSpecTree::NodeType<AllDepSpec>::Type & node) { s << "( "; - std::for_each(cur, end, accept_visitor(*this)); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); s << ") "; } - void - visit_leaf(const PackageDepSpec & p) + void visit(const SetSpecTree::NodeType<PackageDepSpec>::Type & node) { - s << p << " "; + s << *node.spec() << " "; } - void - visit_leaf(const NamedSetDepSpec & p) + void visit(const SetSpecTree::NodeType<NamedSetDepSpec>::Type & node) { - s << p << " "; + s << *node.spec() << " "; } }; } @@ -85,7 +78,7 @@ namespace test_cases { SetSpecStringifier p; - f.contents()->accept(p); + f.contents()->root()->accept(p); TEST_CHECK_STRINGIFY_EQUAL(p.s.str(), "( foo/bar >=bar/baz-1.23 ) "); } @@ -93,7 +86,7 @@ namespace test_cases f.add("moo/oink"); { SetSpecStringifier p; - f.contents()->accept(p); + f.contents()->root()->accept(p); TEST_CHECK_STRINGIFY_EQUAL(p.s.str(), "( foo/bar >=bar/baz-1.23 moo/oink ) "); } @@ -111,7 +104,7 @@ namespace test_cases { SetSpecStringifier p; - f.contents()->accept(p); + f.contents()->root()->accept(p); TEST_CHECK_STRINGIFY_EQUAL(p.s.str(), "( foo/bar moo/oink ) "); } @@ -152,7 +145,7 @@ namespace test_cases { SetSpecStringifier p; - f.contents()->accept(p); + f.contents()->root()->accept(p); TEST_CHECK_STRINGIFY_EQUAL(p.s.str(), "( >=bar/baz-1.23 set ) "); } @@ -162,7 +155,7 @@ namespace test_cases f.add("couch"); { SetSpecStringifier p; - f.contents()->accept(p); + f.contents()->root()->accept(p); TEST_CHECK_STRINGIFY_EQUAL(p.s.str(), "( >=bar/baz-1.23 set moo/oink couch ) "); } @@ -181,7 +174,7 @@ namespace test_cases { SetSpecStringifier p; - f.contents()->accept(p); + f.contents()->root()->accept(p); TEST_CHECK_STRINGIFY_EQUAL(p.s.str(), "( moo/oink couch ) "); } @@ -222,7 +215,7 @@ namespace test_cases { SetSpecStringifier p; - f.contents()->accept(p); + f.contents()->root()->accept(p); TEST_CHECK_STRINGIFY_EQUAL(p.s.str(), "( >=bar/bar-1.23 set set2* ) "); } @@ -237,7 +230,7 @@ namespace test_cases { SetSpecStringifier p; - fstar.contents()->accept(p); + fstar.contents()->root()->accept(p); TEST_CHECK_STRINGIFY_EQUAL(p.s.str(), "( foo/foo >=bar/bar-1.23 >=baz/baz-1.23 set* set2* ) "); } diff --git a/paludis/show_suggest_visitor.cc b/paludis/show_suggest_visitor.cc index b1c8734c2..5e03dfaf7 100644 --- a/paludis/show_suggest_visitor.cc +++ b/paludis/show_suggest_visitor.cc @@ -19,7 +19,6 @@ #include <paludis/show_suggest_visitor.hh> #include <paludis/dep_list.hh> -#include <paludis/condition_tracker.hh> #include <paludis/dep_spec.hh> #include <paludis/package_id.hh> #include <paludis/package_database.hh> @@ -30,7 +29,6 @@ #include <paludis/filtered_generator.hh> #include <paludis/util/log.hh> #include <paludis/util/save.hh> -#include <paludis/util/visitor-impl.hh> #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/make_shared_ptr.hh> #include <paludis/util/indirect_iterator-impl.hh> @@ -54,7 +52,6 @@ namespace paludis const std::tr1::shared_ptr<const PackageID> id; bool dependency_tags; const bool only_if_suggested_label; - std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > conditions; std::set<SetName> recursing_sets; LabelsStack labels; @@ -65,10 +62,7 @@ namespace paludis environment(e), id(p), dependency_tags(t), - only_if_suggested_label(l), - conditions(std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> >( - new ConstTreeSequence<DependencySpecTree, AllDepSpec>( - std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec)))) + only_if_suggested_label(l) { labels.push_front(make_shared_ptr(new ActiveDependencyLabels(*make_shared_ptr(new DependencyLabelSequence)))); } @@ -86,51 +80,37 @@ ShowSuggestVisitor::~ShowSuggestVisitor() } void -ShowSuggestVisitor::visit_sequence(const ConditionalDepSpec & a, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) +ShowSuggestVisitor::visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node) { - Save<std::tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > > save_c( - &_imp->conditions, _imp->dependency_tags ? - ConditionTracker(_imp->conditions).add_condition(a) : _imp->conditions); - - if (a.condition_met()) + if (node.spec()->condition_met()) { _imp->labels.push_front(make_shared_ptr(new ActiveDependencyLabels(**_imp->labels.begin()))); RunOnDestruction restore_labels(std::tr1::bind(std::tr1::mem_fn(&LabelsStack::pop_fr |