diff options
author | 2013-05-23 23:01:33 +0100 | |
---|---|---|
committer | 2013-05-23 23:02:02 +0100 | |
commit | 4663dbe5248be2a9ee2d0e5986c1e01f5006d02e (patch) | |
tree | e1ffa1c2d76b5f1018ab2e1eccc0d0520d7b4f45 | |
parent | 02af9159b804d6001edc548187bb260c2ad011aa (diff) | |
download | paludis-4663dbe5248be2a9ee2d0e5986c1e01f5006d02e.tar.gz paludis-4663dbe5248be2a9ee2d0e5986c1e01f5006d02e.tar.xz |
Convert to fancy new visitors
-rw-r--r-- | paludis/repositories/e/can_skip_phase.cc | 61 | ||||
-rw-r--r-- | paludis/repositories/e/e_installed_repository.cc | 52 | ||||
-rw-r--r-- | paludis/repositories/e/e_installed_repository_id.cc | 52 | ||||
-rw-r--r-- | paludis/repositories/e/e_repository.cc | 52 | ||||
-rw-r--r-- | paludis/repositories/e/ebuild_id.cc | 52 | ||||
-rw-r--r-- | paludis/repositories/e/spec_tree_pretty_printer.cc | 95 | ||||
-rw-r--r-- | paludis/repositories/e/vdb_unmerger.cc | 33 |
7 files changed, 81 insertions, 316 deletions
diff --git a/paludis/repositories/e/can_skip_phase.cc b/paludis/repositories/e/can_skip_phase.cc index e5e6828be..afd951e18 100644 --- a/paludis/repositories/e/can_skip_phase.cc +++ b/paludis/repositories/e/can_skip_phase.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2008, 2009, 2010, 2011, 2013 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,43 +31,6 @@ using namespace paludis; using namespace paludis::erepository; -namespace -{ - struct FindAnyFetchesFinder - { - const Environment * const env; - const std::shared_ptr<const PackageID> package_id; - bool result; - - FindAnyFetchesFinder(const Environment * const e, const std::shared_ptr<const PackageID> & id) : - env(e), - package_id(id), - result(true) - { - } - - 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) - { - if (node.spec()->condition_met(env, package_id)) - std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); - } - - void visit(const FetchableURISpecTree::NodeType<FetchableURIDepSpec>::Type &) - { - result = false; - } - - void visit(const FetchableURISpecTree::NodeType<URILabelsDepSpec>::Type &) - { - } - }; -} - bool paludis::erepository::can_skip_phase( const Environment * const env, @@ -92,9 +55,25 @@ paludis::erepository::can_skip_phase( { if (id->fetches_key()) { - FindAnyFetchesFinder f(env, id); - id->fetches_key()->parse_value()->top()->accept(f); - if (! f.result) + bool result = true; + id->fetches_key()->parse_value()->top()->make_accept( + [&] (const FetchableURISpecTree::NodeType<AllDepSpec>::Type & node, const Revisit<void, FetchableURISpecTree::BasicNode> & revisit) { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), revisit); + }, + + [&] (const FetchableURISpecTree::NodeType<ConditionalDepSpec>::Type & node, const Revisit<void, FetchableURISpecTree::BasicNode> & revisit) { + if (node.spec()->condition_met(env, id)) + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), revisit); + }, + + [&] (const FetchableURISpecTree::NodeType<FetchableURIDepSpec>::Type &) { + result = false; + }, + + [&] (const FetchableURISpecTree::NodeType<URILabelsDepSpec>::Type &) { + } + ); + if (! result) return false; } } diff --git a/paludis/repositories/e/e_installed_repository.cc b/paludis/repositories/e/e_installed_repository.cc index a94e1bdec..d4073af0a 100644 --- a/paludis/repositories/e/e_installed_repository.cc +++ b/paludis/repositories/e/e_installed_repository.cc @@ -84,52 +84,18 @@ EInstalledRepository::~EInstalledRepository() { } -namespace -{ - struct SomeIDsMightSupportVisitor - { - bool visit(const SupportsActionTest<UninstallAction> &) const - { - return true; - } - - bool visit(const SupportsActionTest<ConfigAction> &) const - { - return true; - } - - bool visit(const SupportsActionTest<InfoAction> &) const - { - return true; - } - - bool visit(const SupportsActionTest<PretendAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<FetchAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<PretendFetchAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<InstallAction> &) const - { - return false; - } - }; -} - bool EInstalledRepository::some_ids_might_support_action(const SupportsActionTestBase & test) const { - SomeIDsMightSupportVisitor v; - return test.accept_returning<bool>(v); + return test.make_accept_returning( + [&] (const SupportsActionTest<UninstallAction> &) { return true; }, + [&] (const SupportsActionTest<ConfigAction> &) { return true; }, + [&] (const SupportsActionTest<InfoAction> &) { return true; }, + [&] (const SupportsActionTest<PretendAction> &) { return false; }, + [&] (const SupportsActionTest<FetchAction> &) { return false; }, + [&] (const SupportsActionTest<PretendFetchAction> &) { return false; }, + [&] (const SupportsActionTest<InstallAction> &) { return false; } + ); } bool diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc index a66dcbd26..9dcf09640 100644 --- a/paludis/repositories/e/e_installed_repository_id.cc +++ b/paludis/repositories/e/e_installed_repository_id.cc @@ -905,52 +905,18 @@ EInstalledRepositoryID::extra_hash_value() const return 0; } -namespace -{ - struct SupportsActionQuery - { - bool visit(const SupportsActionTest<InstallAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<ConfigAction> &) const - { - return true; - } - - bool visit(const SupportsActionTest<FetchAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<PretendFetchAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<PretendAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<InfoAction> &) const - { - return true; - } - - bool visit(const SupportsActionTest<UninstallAction> &) const - { - return true; - } - }; -} - bool EInstalledRepositoryID::supports_action(const SupportsActionTestBase & b) const { - SupportsActionQuery q; - return b.accept_returning<bool>(q); + return b.make_accept_returning( + [&] (const SupportsActionTest<InstallAction> &) { return false; }, + [&] (const SupportsActionTest<ConfigAction> &) { return true; }, + [&] (const SupportsActionTest<FetchAction> &) { return false; }, + [&] (const SupportsActionTest<PretendFetchAction> &) { return false; }, + [&] (const SupportsActionTest<PretendAction> &) { return false; }, + [&] (const SupportsActionTest<InfoAction> &) { return true; }, + [&] (const SupportsActionTest<UninstallAction> &) { return true; } + ); } namespace diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc index 6de2a9e4f..cba25ff06 100644 --- a/paludis/repositories/e/e_repository.cc +++ b/paludis/repositories/e/e_repository.cc @@ -963,52 +963,18 @@ ERepository::is_unimportant() const return false; } -namespace -{ - struct SupportsActionQuery - { - bool visit(const SupportsActionTest<InstallAction> &) const - { - return true; - } - - bool visit(const SupportsActionTest<ConfigAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<PretendAction> &) const - { - return true; - } - - bool visit(const SupportsActionTest<FetchAction> &) const - { - return true; - } - - bool visit(const SupportsActionTest<PretendFetchAction> &) const - { - return true; - } - - bool visit(const SupportsActionTest<UninstallAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<InfoAction> &) const - { - return true; - } - }; -} - bool ERepository::some_ids_might_support_action(const SupportsActionTestBase & a) const { - SupportsActionQuery q; - return a.accept_returning<bool>(q); + return a.make_accept_returning( + [&] (const SupportsActionTest<InstallAction> &) { return true; }, + [&] (const SupportsActionTest<ConfigAction> &) { return false; }, + [&] (const SupportsActionTest<PretendAction> &) { return true; }, + [&] (const SupportsActionTest<FetchAction> &) { return true; }, + [&] (const SupportsActionTest<PretendFetchAction> &) { return true; }, + [&] (const SupportsActionTest<UninstallAction> &) { return false; }, + [&] (const SupportsActionTest<InfoAction> &) { return true; } + ); } bool diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc index d1e1fb430..d8ad37d7a 100644 --- a/paludis/repositories/e/ebuild_id.cc +++ b/paludis/repositories/e/ebuild_id.cc @@ -1274,52 +1274,18 @@ EbuildID::load_scm_revision(const std::string & r, const std::string & h, const add_metadata_key(_imp->scm_revision); } -namespace -{ - struct SupportsActionQuery - { - bool visit(const SupportsActionTest<FetchAction> &) const - { - return true; - } - - bool visit(const SupportsActionTest<PretendFetchAction> &) const - { - return true; - } - - bool visit(const SupportsActionTest<InstallAction> &) const - { - return true; - } - - bool visit(const SupportsActionTest<ConfigAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<PretendAction> &) const - { - return true; - } - - bool visit(const SupportsActionTest<InfoAction> &) const - { - return true; - } - - bool visit(const SupportsActionTest<UninstallAction> &) const - { - return false; - } - }; -} - bool EbuildID::supports_action(const SupportsActionTestBase & b) const { - SupportsActionQuery q; - return b.accept_returning<bool>(q) && eapi()->supported(); + return b.make_accept_returning( + [&] (const SupportsActionTest<FetchAction> &) { return true; }, + [&] (const SupportsActionTest<PretendFetchAction> &) { return true; }, + [&] (const SupportsActionTest<InstallAction> &) { return true; }, + [&] (const SupportsActionTest<ConfigAction> &) { return false; }, + [&] (const SupportsActionTest<PretendAction> &) { return true; }, + [&] (const SupportsActionTest<InfoAction> &) { return true; }, + [&] (const SupportsActionTest<UninstallAction> &) { return false; } + ) && eapi()->supported(); } namespace diff --git a/paludis/repositories/e/spec_tree_pretty_printer.cc b/paludis/repositories/e/spec_tree_pretty_printer.cc index f7dbd4330..8fa772f54 100644 --- a/paludis/repositories/e/spec_tree_pretty_printer.cc +++ b/paludis/repositories/e/spec_tree_pretty_printer.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2010, 2011 Ciaran McCreesh + * Copyright (c) 2010, 2011, 2013 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 @@ -78,84 +78,25 @@ paludis::erepository::operator<< (std::ostream & s, const SpecTreePrettyPrinter namespace { - struct IsLabelVisitor - { - bool result; - - IsLabelVisitor() : - result(false) - { - } - - void visit(const GenericSpecTree::NodeType<PlainTextDepSpec>::Type &) - { - } - - void visit(const GenericSpecTree::NodeType<SimpleURIDepSpec>::Type &) - { - } - - void visit(const GenericSpecTree::NodeType<FetchableURIDepSpec>::Type &) - { - } - - void visit(const GenericSpecTree::NodeType<LicenseDepSpec>::Type &) - { - } - - void visit(const GenericSpecTree::NodeType<PackageDepSpec>::Type &) - { - } - - void visit(const GenericSpecTree::NodeType<BlockDepSpec>::Type &) - { - } - - void visit(const GenericSpecTree::NodeType<PlainTextLabelDepSpec>::Type &) - { - result = true; - } - - void visit(const GenericSpecTree::NodeType<URILabelsDepSpec>::Type &) - { - result = true; - } - - void visit(const GenericSpecTree::NodeType<DependenciesLabelsDepSpec>::Type &) - { - result = true; - } - - void visit(const GenericSpecTree::NodeType<NamedSetDepSpec>::Type &) - { - } - - void visit(const GenericSpecTree::NodeType<AllDepSpec>::Type &) - { - } - - void visit(const GenericSpecTree::NodeType<ExactlyOneDepSpec>::Type &) - { - } - - void visit(const GenericSpecTree::NodeType<AtMostOneDepSpec>::Type &) - { - } - - void visit(const GenericSpecTree::NodeType<AnyDepSpec>::Type &) - { - } - - void visit(const GenericSpecTree::NodeType<ConditionalDepSpec>::Type &) - { - } - }; - bool is_label(const GenericSpecTree::BasicNode & i) { - IsLabelVisitor v; - i.accept(v); - return v.result; + return i.make_accept_returning( + [&] (const GenericSpecTree::NodeType<PlainTextDepSpec>::Type &) { return false; }, + [&] (const GenericSpecTree::NodeType<SimpleURIDepSpec>::Type &) { return false; }, + [&] (const GenericSpecTree::NodeType<FetchableURIDepSpec>::Type &) { return false; }, + [&] (const GenericSpecTree::NodeType<LicenseDepSpec>::Type &) { return false; }, + [&] (const GenericSpecTree::NodeType<PackageDepSpec>::Type &) { return false; }, + [&] (const GenericSpecTree::NodeType<BlockDepSpec>::Type &) { return false; }, + [&] (const GenericSpecTree::NodeType<PlainTextLabelDepSpec>::Type &) { return true; }, + [&] (const GenericSpecTree::NodeType<URILabelsDepSpec>::Type &) { return true; }, + [&] (const GenericSpecTree::NodeType<DependenciesLabelsDepSpec>::Type &) { return true; }, + [&] (const GenericSpecTree::NodeType<NamedSetDepSpec>::Type &) { return false; }, + [&] (const GenericSpecTree::NodeType<AllDepSpec>::Type &) { return false; }, + [&] (const GenericSpecTree::NodeType<ExactlyOneDepSpec>::Type &) { return false; }, + [&] (const GenericSpecTree::NodeType<AtMostOneDepSpec>::Type &) { return false; }, + [&] (const GenericSpecTree::NodeType<AnyDepSpec>::Type &) { return false; }, + [&] (const GenericSpecTree::NodeType<ConditionalDepSpec>::Type &) { return false; } + ); } } diff --git a/paludis/repositories/e/vdb_unmerger.cc b/paludis/repositories/e/vdb_unmerger.cc index a2bcf9664..988b16e3a 100644 --- a/paludis/repositories/e/vdb_unmerger.cc +++ b/paludis/repositories/e/vdb_unmerger.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * Copyright (c) 2007 Piotr JaroszyĆski * * This file is part of the Paludis package manager. Paludis is free software; @@ -159,33 +159,14 @@ VDBUnmerger::make_tidy(const FSPath & f) const namespace { - struct GetET - { - EntryType visit(const ContentsFileEntry &) const - { - return et_file; - } - - EntryType visit(const ContentsDirEntry &) const - { - return et_dir; - } - - EntryType visit(const ContentsSymEntry &) const - { - return et_sym; - } - - EntryType visit(const ContentsOtherEntry &) const - { - return et_misc; - } - }; - EntryType get_et(const ContentsEntry & e) { - GetET v; - return e.accept_returning<EntryType>(v); + return e.make_accept_returning( + [&] (const ContentsFileEntry &) { return et_file; }, + [&] (const ContentsDirEntry &) { return et_dir; }, + [&] (const ContentsSymEntry &) { return et_sym; }, + [&] (const ContentsOtherEntry &) { return et_misc; } + ); } } |