diff options
26 files changed, 716 insertions, 345 deletions
diff --git a/doc/api/cplusplus/examples/example_action.cc b/doc/api/cplusplus/examples/example_action.cc index f00c58ada..ecfc13ba4 100644 --- a/doc/api/cplusplus/examples/example_action.cc +++ b/doc/api/cplusplus/examples/example_action.cc @@ -61,9 +61,9 @@ int main(int argc, char * argv[]) * creating a FetchAction, controlling whether safe resume is used * and whether unneeded (e.g. due to disabled USE flags) source * files should still be fetched. */ - FetchAction fetch_action(FetchActionOptions::create() - .fetch_unneeded(false) - .safe_resume(true) + FetchAction fetch_action(FetchActionOptions::named_create() + (k::fetch_unneeded(), false) + (k::safe_resume(), true) ); try { @@ -80,16 +80,16 @@ int main(int argc, char * argv[]) for (Sequence<FetchActionFailure>::ConstIterator f(e.failures()->begin()), f_end(e.failures()->end()) ; f != f_end ; ++f) { - cout << " * File '" << f->target_file << "': "; + cout << " * File '" << (*f)[k::target_file()] << "': "; bool need_comma(false); - if (f->requires_manual_fetching) + if ((*f)[k::requires_manual_fetching()]) { cout << "requires manual fetching"; need_comma = true; } - if (f->failed_automatic_fetching) + if ((*f)[k::failed_automatic_fetching()]) { if (need_comma) cout << ", "; @@ -97,11 +97,11 @@ int main(int argc, char * argv[]) need_comma = true; } - if (! f->failed_integrity_checks.empty()) + if (! (*f)[k::failed_integrity_checks()].empty()) { if (need_comma) cout << ", "; - cout << "failed integrity checks: " << f->failed_integrity_checks; + cout << "failed integrity checks: " << (*f)[k::failed_integrity_checks()]; need_comma = true; } } diff --git a/paludis/action-fwd.hh b/paludis/action-fwd.hh index 8a4bd75fa..dbad67dfe 100644 --- a/paludis/action-fwd.hh +++ b/paludis/action-fwd.hh @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007 Ciaran McCreesh + * Copyright (c) 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 @@ -22,6 +22,10 @@ #include <iosfwd> #include <paludis/util/attributes.hh> +#include <paludis/util/kc-fwd.hh> +#include <paludis/util/keys.hh> +#include <paludis/util/tr1_memory.hh> +#include <paludis/repository-fwd.hh> /** \file * Forward declarations for paludis/action.hh . @@ -54,13 +58,58 @@ namespace paludis class ConfigActionError; class InfoActionError; - class FetchActionFailure; +#include <paludis/action-se.hh> - class InstallActionOptions; - class UninstallActionOptions; - class FetchActionOptions; + /** + * Options for a FetchAction. + * + * \see FetchAction + * \ingroup g_actions + * \since 0.26 + */ + typedef kc::KeyedClass< + kc::Field<k::fetch_unneeded, bool>, + kc::Field<k::safe_resume, bool> + > FetchActionOptions; -#include <paludis/action-se.hh> + /** + * Options for an InstallAction. + * + * \see InstallAction + * \ingroup g_actions + * \since 0.26 + */ + typedef kc::KeyedClass< + kc::Field<k::no_config_protect, bool>, + kc::Field<k::debug_build, InstallActionDebugOption>, + kc::Field<k::checks, InstallActionChecksOption>, + kc::Field<k::destination, tr1::shared_ptr<Repository> > + > InstallActionOptions; + + /** + * Options for an UninstallAction. + * + * \see UninstallAction + * \ingroup g_actions + * \since 0.26 + */ + typedef kc::KeyedClass< + kc::Field<k::no_config_protect, bool> + > UninstallActionOptions; + + /** + * A failed fetch action part. + * + * \see FetchActionError + * \ingroup g_actions + * \since 0.26 + */ + typedef kc::KeyedClass< + kc::Field<k::target_file, std::string>, + kc::Field<k::requires_manual_fetching, bool>, + kc::Field<k::failed_automatic_fetching, bool>, + kc::Field<k::failed_integrity_checks, std::string> + > FetchActionFailure; } diff --git a/paludis/action.cc b/paludis/action.cc index a6b955aa1..849eb39bc 100644 --- a/paludis/action.cc +++ b/paludis/action.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007 Ciaran McCreesh + * Copyright (c) 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 @@ -23,11 +23,11 @@ #include <paludis/util/exception.hh> #include <paludis/util/stringify.hh> #include <paludis/util/sequence-impl.hh> +#include <paludis/util/kc.hh> using namespace paludis; #include <paludis/action-se.cc> -#include <paludis/action-sr.cc> template class AcceptInterfaceVisitsThis<ActionVisitorTypes, InstallAction>; template class AcceptInterfaceVisitsThis<ActionVisitorTypes, ConfigAction>; @@ -182,8 +182,8 @@ namespace void visit(const InstallAction & a) { s << "install to "; - if (a.options.destination) - s << a.options.destination->name(); + if (a.options[k::destination()]) + s << a.options[k::destination()]->name(); else s << "nowhere"; } diff --git a/paludis/action.hh b/paludis/action.hh index 1ce900a6c..f090795db 100644 --- a/paludis/action.hh +++ b/paludis/action.hh @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007 Ciaran McCreesh + * Copyright (c) 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 @@ -42,9 +42,6 @@ namespace paludis { - -#include <paludis/action-sr.hh> - /** * Types for visiting an action. * diff --git a/paludis/action.sr b/paludis/action.sr deleted file mode 100644 index 435237353..000000000 --- a/paludis/action.sr +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash -# vim: set sw=4 sts=4 et : - -make_class_FetchActionOptions() -{ - visible - allow_named_args - - key fetch_unneeded bool - key safe_resume bool - - doxygen_comment << "END" - /** - * Options for FetchAction. - * - * \see FetchAction - * \ingroup g_actions - * \since 0.26 - * \nosubgrouping - */ -END -} - - -make_class_InstallActionOptions() -{ - visible - allow_named_args - - key no_config_protect bool - key debug_build InstallActionDebugOption - key checks InstallActionChecksOption - key destination "tr1::shared_ptr<Repository>" - - doxygen_comment << "END" - /** - * Options for InstallAction. - * - * \see InstallAction - * \ingroup g_actions - * \since 0.26 - * \nosubgrouping - */ -END -} - -make_class_UninstallActionOptions() -{ - visible - allow_named_args - - key no_config_protect bool - - doxygen_comment << "END" - /** - * Options for UninstallAction. - * - * \see UninstallAction - * \ingroup g_actions - * \since 0.26 - * \nosubgrouping - */ -END -} - -make_class_FetchActionFailure() -{ - visible - allow_named_args - - key target_file std::string - key requires_manual_fetching bool - key failed_automatic_fetching bool - key failed_integrity_checks std::string - - doxygen_comment << "END" - /** - * A failed fetch action part. - * - * \see FetchActionError - * \ingroup g_actions - * \ingroup g_exceptions - * \ingroup g_actions - * \nosubgrouping - */ -END -} - diff --git a/paludis/files.m4 b/paludis/files.m4 index 573c84b64..2f30b5df2 100644 --- a/paludis/files.m4 +++ b/paludis/files.m4 @@ -9,7 +9,7 @@ dnl `test', `impl', `testscript'. Note that there isn't much error checking done dnl on this file at present... add(`about', `hh', `test') -add(`action', `hh', `cc', `fwd', `se', `sr') +add(`action', `hh', `cc', `fwd', `se') add(`condition_tracker', `hh', `cc') add(`contents', `hh', `cc', `fwd') add(`dep_label', `hh', `cc', `fwd') diff --git a/paludis/install_task.cc b/paludis/install_task.cc index 2e7227b30..c6fcf8c1e 100644 --- a/paludis/install_task.cc +++ b/paludis/install_task.cc @@ -38,6 +38,7 @@ #include <paludis/util/log.hh> #include <paludis/util/iterator_funcs.hh> #include <paludis/util/wrapped_forward_iterator-impl.hh> +#include <paludis/util/kc.hh> #include <paludis/handled_information.hh> #include <functional> #include <algorithm> @@ -84,16 +85,16 @@ namespace paludis env(e), dep_list(e, o), fetch_options( - FetchActionOptions::create() - .safe_resume(false) - .fetch_unneeded(false) + FetchActionOptions::named_create() + (k::safe_resume(), false) + (k::fetch_unneeded(), false) ), install_options( - InstallActionOptions::create() - .no_config_protect(false) - .debug_build(iado_none) - .checks(iaco_default) - .destination(tr1::shared_ptr<Repository>()) + InstallActionOptions::named_create() + (k::no_config_protect(), false) + (k::debug_build(), iado_none) + (k::checks(), iaco_default) + (k::destination(), tr1::shared_ptr<Repository>()) ), uninstall_options(false), targets(new ConstTreeSequence<SetSpecTree, AllDepSpec>(tr1::shared_ptr<AllDepSpec>(new AllDepSpec))), @@ -465,7 +466,7 @@ InstallTask::_one(const DepList::Iterator dep, const int x, const int y, const i if (! _imp->fetch_only) { - _imp->install_options.destination = dep->destination; + _imp->install_options[k::destination()] = dep->destination; InstallAction install_action(_imp->install_options); dep->package_id->perform_action(install_action); } @@ -844,8 +845,8 @@ InstallTask::dep_list() const void InstallTask::set_no_config_protect(const bool value) { - _imp->install_options.no_config_protect = value; - _imp->uninstall_options.no_config_protect = value; + _imp->install_options[k::no_config_protect()] = value; + _imp->uninstall_options[k::no_config_protect()] = value; } void @@ -869,13 +870,13 @@ InstallTask::set_preserve_world(const bool value) void InstallTask::set_debug_mode(const InstallActionDebugOption value) { - _imp->install_options.debug_build = value; + _imp->install_options[k::debug_build()] = value; } void InstallTask::set_checks_mode(const InstallActionChecksOption value) { - _imp->install_options.checks = value; + _imp->install_options[k::checks()] = value; } void @@ -928,7 +929,7 @@ InstallTask::had_package_targets() const void InstallTask::set_safe_resume(const bool value) { - _imp->fetch_options.safe_resume = value; + _imp->fetch_options[k::safe_resume()] = value; } HookResult diff --git a/paludis/repositories/e/check_fetched_files_visitor.cc b/paludis/repositories/e/check_fetched_files_visitor.cc index e3fa8d575..2e6447460 100644 --- a/paludis/repositories/e/check_fetched_files_visitor.cc +++ b/paludis/repositories/e/check_fetched_files_visitor.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007 Ciaran McCreesh + * Copyright (c) 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 @@ -35,7 +35,7 @@ #include <paludis/util/join.hh> #include <paludis/util/save.hh> #include <paludis/util/stringify.hh> - +#include <paludis/util/kc.hh> #include <paludis/util/rmd160.hh> #include <paludis/util/sha256.hh> #include <paludis/util/md5.hh> @@ -187,11 +187,11 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile) case manifest_require: case last_manifest: - _imp->failures->push_back(FetchActionFailure::create() - .target_file(stringify(distfile.basename())) - .failed_integrity_checks("No Manifest available") - .requires_manual_fetching(false) - .failed_automatic_fetching(false) + _imp->failures->push_back(FetchActionFailure::named_create() + (k::target_file(), stringify(distfile.basename())) + (k::failed_integrity_checks(), "No Manifest available") + (k::requires_manual_fetching(), false) + (k::failed_automatic_fetching(), false) ); return false; @@ -218,11 +218,11 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile) Log::get_instance()->message(ll_debug, lc_context) << "Malformed Manifest: no file size found"; std::cout << "incorrect size"; - _imp->failures->push_back(FetchActionFailure::create() - .target_file(stringify(distfile.basename())) - .requires_manual_fetching(false) - .failed_integrity_checks("Incorrect file size") - .failed_automatic_fetching(false) + _imp->failures->push_back(FetchActionFailure::named_create() + (k::target_file(), stringify(distfile.basename())) + (k::requires_manual_fetching(), false) + (k::failed_integrity_checks(), "Incorrect file size") + (k::failed_automatic_fetching(), false) ); return false; } @@ -231,11 +231,11 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile) if (! file_stream) { std::cout << "unreadable file"; - _imp->failures->push_back(FetchActionFailure::create() - .target_file(stringify(distfile.basename())) - .requires_manual_fetching(false) - .failed_integrity_checks("Unreadable file") - .failed_automatic_fetching(false) + _imp->failures->push_back(FetchActionFailure::named_create() + (k::target_file(), stringify(distfile.basename())) + (k::requires_manual_fetching(), false) + (k::failed_integrity_checks(), "Unreadable file") + (k::failed_automatic_fetching(), false) ); return false; } @@ -248,11 +248,11 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile) Log::get_instance()->message(ll_debug, lc_context) << "Malformed Manifest: failed RMD160 checksum"; std::cout << "failed RMD160"; - _imp->failures->push_back(FetchActionFailure::create() - .target_file(stringify(distfile.basename())) - .requires_manual_fetching(false) - .failed_integrity_checks("Failed RMD160 checksum") - .failed_automatic_fetching(false) + _imp->failures->push_back(FetchActionFailure::named_create() + (k::target_file(), stringify(distfile.basename())) + (k::requires_manual_fetching(), false) + (k::failed_integrity_checks(), "Failed RMD160 checksum") + (k::failed_automatic_fetching(), false) ); return false; } @@ -270,11 +270,11 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile) Log::get_instance()->message(ll_debug, lc_context) << "Malformed Manifest: failed SHA256 checksum"; std::cout << "failed SHA256"; - _imp->failures->push_back(FetchActionFailure::create() - .target_file(stringify(distfile.basename())) - .requires_manual_fetching(false) - .failed_integrity_checks("Failed SHA256 checksum") - .failed_automatic_fetching(false) + _imp->failures->push_back(FetchActionFailure::named_create() + (k::target_file(), stringify(distfile.basename())) + (k::requires_manual_fetching(), false) + (k::failed_integrity_checks(), "Failed SHA256 checksum") + (k::failed_automatic_fetching(), false) ); return false; } @@ -292,11 +292,11 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile) Log::get_instance()->message(ll_debug, lc_context) << "Malformed Manifest: failed MD5 checksum"; std::cout << "failed MD5"; - _imp->failures->push_back(FetchActionFailure::create() - .target_file(stringify(distfile.basename())) - .requires_manual_fetching(false) - .failed_integrity_checks("Failed MD5 checksum") - .failed_automatic_fetching(false) + _imp->failures->push_back(FetchActionFailure::named_create() + (k::target_file(), stringify(distfile.basename())) + (k::requires_manual_fetching(), false) + (k::failed_integrity_checks(), "Failed MD5 checksum") + (k::failed_automatic_fetching(), false) ); return false; } @@ -308,11 +308,11 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile) if (! found) { std::cout << "not in Manifest"; - _imp->failures->push_back(FetchActionFailure::create() - .target_file(stringify(distfile.basename())) - .requires_manual_fetching(false) - .failed_integrity_checks("Not in Manifest") - .failed_automatic_fetching(false) + _imp->failures->push_back(FetchActionFailure::named_create() + (k::target_file(), stringify(distfile.basename())) + (k::requires_manual_fetching(), false) + (k::failed_integrity_checks(), "Not in Manifest") + (k::failed_automatic_fetching(), false) ); return false; } @@ -341,22 +341,22 @@ CheckFetchedFilesVisitor::visit_leaf(const FetchableURIDepSpec & u) Log::get_instance()->message(ll_debug, lc_context) << "Manual fetch required for '" << u.filename() << "'"; std::cout << "requires manual fetch"; _imp->need_nofetch = true; - _imp->failures->push_back(FetchActionFailure::create() - .target_file(u.filename()) - .requires_manual_fetching(true) - .failed_automatic_fetching(false) - .failed_integrity_checks("") + _imp->failures->push_back(FetchActionFailure::named_create() + (k::target_file(), u.filename()) + (k::requires_manual_fetching(), true) + (k::failed_automatic_fetching(), false) + (k::failed_integrity_checks(), "") ); } else { Log::get_instance()->message(ll_debug, lc_context) << "Automatic fetch failed for '" << u.filename() << "'"; std::cout << "does not exist"; - _imp->failures->push_back(FetchActionFailure::create() - .target_file(u.filename()) - .requires_manual_fetching(false) - .failed_automatic_fetching(true) - .failed_integrity_checks("") + _imp->failures->push_back(FetchActionFailure::named_create() + (k::target_file(), u.filename()) + (k::requires_manual_fetching(), false) + (k::failed_automatic_fetching(), true) + (k::failed_integrity_checks(), "") ); } } @@ -364,11 +364,11 @@ CheckFetchedFilesVisitor::visit_leaf(const FetchableURIDepSpec & u) { Log::get_instance()->message(ll_debug, lc_context) << "Empty file for '" << u.filename() << "'"; std::cout << "empty file"; - _imp->failures->push_back(FetchActionFailure::create() - .target_file(u.filename()) - .requires_manual_fetching(false) - .failed_integrity_checks("SIZE (empty file)") - .failed_automatic_fetching(false) + _imp->failures->push_back(FetchActionFailure::named_create() + (k::target_file(), u.filename()) + (k::requires_manual_fetching(), false) + (k::failed_integrity_checks(), "SIZE (empty file)") + (k::failed_automatic_fetching(), false) ); } else if (! check_distfile_manifest(_imp->distdir / u.filename())) diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc index 548337621..b2fa98388 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 Ciaran McCreesh + * Copyright (c) 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 @@ -33,6 +33,7 @@ #include <paludis/util/tr1_functional.hh> #include <paludis/util/map.hh> #include <paludis/util/set.hh> +#include <paludis/util/kc.hh> #include <paludis/package_id.hh> #include <paludis/metadata_key.hh> #include <paludis/query.hh> @@ -913,9 +914,9 @@ namespace test_cases tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env, keys)); env.package_database()->add_repository(1, repo); - FetchAction action(FetchActionOptions::create() - .fetch_unneeded(false) - .safe_resume(true) + FetchAction action(FetchActionOptions::named_create() + (k::fetch_unneeded(), false) + (k::safe_resume(), true) ); { @@ -1019,9 +1020,9 @@ namespace test_cases &env, keys)); env.package_database()->add_repository(1, repo); - FetchAction action(FetchActionOptions::create() - .fetch_unneeded(false) - .safe_resume(true) + FetchAction action(FetchActionOptions::named_create() + (k::fetch_unneeded(), false) + (k::safe_resume(), true) ); const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches( @@ -1071,11 +1072,11 @@ namespace test_cases env.package_database()->add_repository(-2, RepositoryMaker::get_instance()->find_maker("virtuals")(&env, tr1::shared_ptr<Map<std::string, std::string> >())); - InstallAction action(InstallActionOptions::create() - .debug_build(iado_none) - .checks(iaco_default) - .no_config_protect(false) - .destination(installed_repo) + InstallAction action(InstallActionOptions::named_create() + (k::debug_build(), iado_none) + (k::checks(), iaco_default) + (k::no_config_protect(), false) + (k::destination(), installed_repo) ); { @@ -1198,11 +1199,11 @@ namespace test_cases tr1::shared_ptr<FakeInstalledRepository> installed_repo(new FakeInstalledRepository(&env, RepositoryName("installed"))); env.package_database()->add_repository(2, installed_repo); - InstallAction action(InstallActionOptions::create() - .debug_build(iado_none) - .checks(iaco_default) - .no_config_protect(false) - .destination(installed_repo) + InstallAction action(InstallActionOptions::named_create() + (k::debug_build(), iado_none) + (k::checks(), iaco_default) + (k::no_config_protect(), false) + (k::destination(), installed_repo) ); { @@ -1254,11 +1255,11 @@ namespace test_cases env.package_database()->add_repository(-2, RepositoryMaker::get_instance()->find_maker("virtuals")(&env, tr1::shared_ptr<Map<std::string, std::string> >())); - InstallAction action(InstallActionOptions::create() - .debug_build(iado_none) - .checks(iaco_default) - .no_config_protect(false) - .destination(installed_repo) + InstallAction action(InstallActionOptions::named_create() + (k::debug_build(), iado_none) + (k::checks(), iaco_default) + (k::no_config_protect(), false) + (k::destination(), installed_repo) ); { diff --git a/paludis/repositories/e/ebuild_entries.cc b/paludis/repositories/e/ebuild_entries.cc index 4b902ba55..8364fb52a 100644 --- a/paludis/repositories/e/ebuild_entries.cc +++ b/paludis/repositories/e/ebuild_entries.cc @@ -48,6 +48,7 @@ #include <paludis/util/visitor-impl.hh> #include <paludis/util/tr1_functional.hh> #include <paludis/util/indirect_iterator-impl.hh> +#include <paludis/util/kc.hh> #include <fstream> #include <list> @@ -363,10 +364,10 @@ EbuildEntries::fetch(const tr1::shared_ptr<const ERepositoryID> & id, stringify(_imp->e_repository->params().master_repository->name()) : stringify(_imp->e_repository->name())); 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); + _imp->e_repository->params().distdir, o[k::fetch_unneeded()], fetch_userpriv_ok, mirrors_name, + id->fetches_key()->initial_label(), o[k::safe_resume()]); id->fetches_key()->value()->accept(f); - CheckFetchedFilesVisitor c(_imp->environment, id, _imp->e_repository->params().distdir, o.fetch_unneeded, fetch_restrict, + CheckFetchedFilesVisitor c(_imp->environment, id, _imp->e_repository->params().distdir, o[k::fetch_unneeded()], fetch_restrict, ((_imp->e_repository->layout()->package_directory(id->name())) / "Manifest"), _imp->e_repository->params().use_manifest); id->fetches_key()->value()->accept(c); @@ -534,12 +535,12 @@ EbuildEntries::install(const tr1::shared_ptr<const ERepositoryID> & id, { if (phase->option("merge")) { - if (! o.destination->destination_interface) + if (! o[k::destination()]->destination_interface) throw InstallActionError("Can't install '" + stringify(*id) - + "' to destination '" + stringify(o.destination->name()) + + "' to destination '" + stringify(o[k::destination()]->name()) + "' because destination does not provide destination_interface"); - o.destination->destination_interface->merge( + o[k::destination()]->destination_interface->merge( MergeOptions::create() .package_id(id) .image_dir(_imp->params.builddir / stringify(id->name().category) / (stringify(id->name().package) + "-" @@ -550,11 +551,11 @@ EbuildEntries::install(const tr1::shared_ptr<const ERepositoryID> & id, ); } else if ((! phase->option("prepost")) || - (o.destination->destination_interface && o.destination->destination_interface->want_pre_post_phases())) + (o[k::destination()]->destination_interface && o[k::destination()]->destination_interface->want_pre_post_phases())) { if (phase->option("checkphase")) { - switch (o.checks) + switch (o[k::checks()]) { case iaco_none: if (! phase->option("checks=none")) @@ -599,10 +600,10 @@ EbuildEntries::install(const tr1::shared_ptr<const ERepositoryID> & id, .aa(all_archives) .use_expand(join(p->begin_use_expand(), p->end_use_expand(), " ")) .expand_vars(expand_vars) - .root(o.destination->installed_root_key() ? stringify(o.destination->installed_root_key()->value()) : "/") + .root(o[k::destination()]->installed_root_key() ? stringify(o[k::destination()]->installed_root_key()->value()) : "/") .profiles(_imp->params.profiles) - .disable_cfgpro(o.no_config_protect) - .debug_build(o.debug_build) + .disable_cfgpro(o[k::no_config_protect()]) + .debug_build(o[k::debug_build()]) .config_protect(_imp->e_repository->profile_variable("CONFIG_PROTECT")) .config_protect_mask(_imp->e_repository->profile_variable("CONFIG_PROTECT_MASK")) .loadsaveenv_dir(_imp->params.builddir / stringify(id->name().category) / ( diff --git a/paludis/repositories/e/qa/function_keyword_TEST.cc b/paludis/repositories/e/qa/function_keyword_TEST.cc index d1ddae84c..9f7f397ac 100644 --- a/paludis/repositories/e/qa/function_keyword_TEST.cc +++ b/paludis/repositories/e/qa/function_keyword_TEST.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007 Ciaran McCreesh + * Copyright (c) 2007, 2008 Ciaran McCreesh * Copyright (c) 2007 Fernando J. Pereda * * This file is part of the Paludis package manager. Paludis is free software; @@ -43,7 +43,7 @@ namespace { } - void message(const QAMessage & m) + void message(const QAMessage &) { ++count; } diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc index 34e9de591..0fbe87beb 100644 --- a/paludis/repositories/e/vdb_repository.cc +++ b/paludis/repositories/e/vdb_repository.cc @@ -66,6 +66,7 @@ #include <paludis/util/system.hh> #include <paludis/util/tokeniser.hh> #include <paludis/util/private_implementation_pattern-impl.hh> +#include <paludis/util/kc.hh> #include <fstream> #include <functional> @@ -451,7 +452,7 @@ VDBRepository::perform_uninstall(const tr1::shared_ptr<const ERepositoryID> & id EbuildUninstallCommandParams uninstall_params(EbuildUninstallCommandParams::create() .root(stringify(_imp->params.root) + "/") - .disable_cfgpro(o.no_config_protect) + .disable_cfgpro(o[k::no_config_protect()]) .unmerge_only(false) .loadsaveenv_dir(pkg_dir) .load_environment(load_env.get())); diff --git a/paludis/repositories/unpackaged/installed_repository.cc b/paludis/repositories/unpackaged/installed_repository.cc index d4181df1f..851e8087a 100644 --- a/paludis/repositories/unpackaged/installed_repository.cc +++ b/paludis/repositories/unpackaged/installed_repository.cc @@ -30,6 +30,7 @@ #include <paludis/util/dir_iterator.hh> #include <paludis/util/system.hh> #include <paludis/util/cookie.hh> +#include <paludis/util/kc.hh> #include <paludis/stringify_formatter.hh> #include <paludis/action.hh> #include <paludis/environment.hh> @@ -318,8 +319,8 @@ InstalledUnpackagedRepository::merge(const MergeOptions & m) if (if_overwritten_id) { - tr1::static_pointer_cast<const InstalledUnpackagedID>(if_overwritten_id)->uninstall(UninstallActionOptions::create() - .no_config_protect(false), + tr1::static_pointer_cast<const InstalledUnpackagedID>(if_overwritten_id)->uninstall(UninstallActionOptions::named_create() + (k::no_config_protect(), false), true); } } diff --git a/paludis/repositories/unpackaged/installed_repository_TEST.cc b/paludis/repositories/unpackaged/installed_repository_TEST.cc index 5dbed30b5..a7b1e3241 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 Ciaran McCreesh + * Copyright (c) 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 @@ -29,6 +29,7 @@ #include <paludis/util/join.hh> #include <paludis/util/visitor-impl.hh> #include <paludis/util/options.hh> +#include <paludis/util/kc.hh> #include <test/test_framework.hh> #include <test/test_runner.hh> #include <algorithm> @@ -252,8 +253,8 @@ namespace test_cases const tr1::shared_ptr<const PackageID> id( *env.package_database()->query(query::All(), qo_require_exactly_one)->begin()); - UninstallAction action(UninstallActionOptions::create() - .no_config_protect(false) + UninstallAction action(UninstallActionOptions::named_create() + (k::no_config_protect(), false) ); id->perform_action(action); @@ -305,8 +306,8 @@ namespace test_cases *env.package_database()->query(query::Matches(parse_user_package_dep_spec("cat-one/foo:fred", UserPackageDepSpecOptions())), qo_require_exactly_one)->begin()); - UninstallAction action(UninstallActionOptions::create() - .no_config_protect(false) + UninstallAction action(UninstallActionOptions::named_create() + (k::no_config_protect(), false) ); id->perform_action(action); @@ -388,11 +389,11 @@ namespace test_cases TEST_CHECK(! FSEntry("installed_repository_TEST_dir/root4/dir").exists()); - InstallAction action(InstallActionOptions::create() - .destination(repo) - .no_config_protect(false) - .checks(iaco_default) - .debug_build(iado_none)); + InstallAction action(InstallActionOptions::named_create() + (k::destination(), repo) + (k::no_config_protect(), false) + (k::checks(), iaco_default) + (k::debug_build(), iado_none)); (*env.package_database()->query(query::Repository(RepositoryName("unpackaged")), qo_require_exactly_one)->begin())->perform_action(action); @@ -442,11 +443,11 @@ namespace test_cases "cat/pkg4a-1.0:foo::installed-unpackaged"); } - InstallAction action(InstallActionOptions::create() - .destination(repo) - .no_config_protect(false) - .checks(iaco_default) - .debug_build(iado_none)); + InstallAction action(InstallActionOptions::named_create() + (k::destination(), repo) + (k::no_config_protect(), false) + (k::checks(), iaco_default) + (k::debug_build(), iado_none)); (*env.package_database()->query(query::Repository(RepositoryName("unpackaged")), qo_require_exactly_one)->begin())->perform_action(action); @@ -499,11 +500,11 @@ namespace test_cases "cat/pkg4a-1.0:foo::installed-unpackaged cat/pkg4b-1.0:foo::installed-unpackaged"); } - InstallAction action(InstallActionOptions::create() - .destination(repo) - .no_config_protect(false) - .checks(iaco_default) - .debug_build(iado_none)); + InstallAction action(InstallActionOptions::named_create() + (k::destination(), repo) + (k::no_config_protect(), false) + (k::checks(), iaco_default) + (k::debug_build(), iado_none)); (*env.package_database()->query(query::Repository(RepositoryName("unpackaged")), qo_require_exactly_one)->begin())->perform_action(action); @@ -542,8 +543,8 @@ namespace test_cases "cat/pkg4a-1.0:foo::installed-unpackaged cat/pkg4b-1.0:foo::installed-unpackaged"); } - UninstallAction action(UninstallActionOptions::create() - .no_config_protect(false)); + UninstallAction action(UninstallActionOptions::named_create() + (k::no_config_protect(), false)); (*env.package_database()->query(query::Matches(parse_user_package_dep_spec("cat/pkg4a", UserPackageDepSpecOptions())), qo_require_exactly_one)->begin())->perform_action(action); @@ -582,8 +583,8 @@ namespace test_cases "cat/pkg4b-1.0:foo::installed-unpackaged"); } - UninstallAction action(UninstallActionOptions::create() - .no_config_protect(false)); + UninstallAction action(UninstallActionOptions::named_create() + (k::no_config_protect(), false)); (*env.package_database()->query(query::Matches(parse_user_package_dep_spec("cat/pkg4b", UserPackageDepSpecOptions())), qo_require_exactly_one)->begin())->perform_action(action); diff --git a/paludis/repositories/unpackaged/unpackaged_id.cc b/paludis/repositories/unpackaged/unpackaged_id.cc index 6dd7cbf3a..767c88112 100644 --- a/paludis/repositories/unpackaged/unpackaged_id.cc +++ b/paludis/repositories/unpackaged/unpackaged_id.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007 Ciaran McCreesh + * Copyright (c) 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 @@ -27,6 +27,7 @@ #include <paludis/util/visitor-impl.hh> #include <paludis/util/visitor_cast.hh> #include <paludis/util/make_shared_ptr.hh> +#include <paludis/util/kc.hh> #include <paludis/name.hh> #include <paludis/version_spec.hh> #include <paludis/package_database.hh> @@ -299,12 +300,12 @@ UnpackagedID::perform_action(Action & action) const if (! install_action) throw UnsupportedActionError(*this, action); - if (! install_action->options.destination->destination_interface) + if (! install_action->options[k::destination()]->destination_interface) throw InstallActionError("Can't install '" + stringify(*this) - + "' to destination '" + stringify(install_action->options.destination->name()) + + "' to destination '" + stringify(install_action->options[k::destination()]->name()) + "' because destination does not provide destination_interface"); - install_action->options.destination->destination_interface->merge( + install_action->options[k::destination()]->destination_interface->merge( MergeOptions::create() .package_id(shared_from_this()) .image_dir(fs_location_key()->value()) diff --git a/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc b/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc index 1c49c7534..a6b4dfc69 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 Ciaran McCreesh + * Copyright (c) 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 @@ -30,6 +30,7 @@ #include <paludis/util/join.hh> #include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/util/indirect_iterator-impl.hh> +#include <paludis/util/kc.hh> #include <test/test_framework.hh> #include <test/test_runner.hh> @@ -203,11 +204,11 @@ namespace test_cases const tr1::shared_ptr<const PackageID> id( *env.package_database()->query(query::All(), qo_require_exactly_one)->begin()); - InstallAction action(InstallActionOptions::create() - .no_config_protect(false) - .debug_build(iado_none) - .checks(iaco_default) - .destination(installed_repo) + InstallAction action(InstallActionOptions::named_create() + (k::no_config_protect(), false) + (k::debug_build(), iado_none) + (k::checks(), iaco_default) + (k::destination(), installed_repo) ); id->perform_action(action); diff --git a/paludis/uninstall_task.cc b/paludis/uninstall_task.cc index 8dec4b576..490da8f68 100644 --- a/paludis/uninstall_task.cc +++ b/paludis/uninstall_task.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007 Ciaran McCreesh + * Copyright (c) 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 @@ -31,6 +31,7 @@ #include <paludis/util/sequence.hh> #include <paludis/util/wrapped_forward_iterator-impl.hh> #include <paludis/util/options.hh> +#include <paludis/util/kc.hh> #include <paludis/query.hh> #include <paludis/package_database.hh> #include <paludis/hook.hh> @@ -133,7 +134,7 @@ UninstallTask::set_pretend(const bool v) void UninstallTask::set_no_config_protect(const bool v) { - _imp->uninstall_options.no_config_protect = v; + _imp->uninstall_options[k::no_config_protect()] = v; } void diff --git a/paludis/util/files.m4 b/paludis/util/files.m4 index 1ab35fb16..76f0eda06 100644 --- a/paludis/util/files.m4 +++ b/paludis/util/files.m4 @@ -29,6 +29,8 @@ add(`indirect_iterator', `hh', `fwd', `impl', `test') add(`instantiation_policy', `hh', `impl', `test') add(`is_file_with_extension', `hh', `cc', `se', `test', `testscript') add(`join', `hh', `test') +add(`kc', `hh', `fwd') +add(`keys', `hh') add(`log', `hh', `cc', `se', `test') add(`make_shared_ptr', `hh', `fwd') add(`map', `hh', `fwd', `impl', `cc') diff --git a/paludis/util/kc-fwd.hh b/paludis/util/kc-fwd.hh new file mode 100644 index 000000000..1fa9cff07 --- /dev/null +++ b/paludis/util/kc-fwd.hh @@ -0,0 +1,65 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 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_UTIL_KC_FWD_HH +#define PALUDIS_GUARD_PALUDIS_UTIL_KC_FWD_HH 1 + +namespace paludis +{ + namespace kc + { + template <typename Key_, typename Type_> + struct Field; + + template <unsigned id_> + struct NoField; + + template <unsigned id_> + struct Key; + + template <bool b_, typename T_> + struct NamedField; + + template <typename T_> + struct NamedField<false, T_>; + + template <unsigned id_, typename T_> + struct NamedField<true, Field<Key<id_>, T_> >; + + template <typename T_> + struct Part; + + template <unsigned id_> + struct Part<NoField<id_> >; + + template <unsigned id_, typename Type_> + struct Part<Field<Key<id_>, Type_> >; + + template < + typename T1_ = NoField<1>, + typename T2_ = NoField<2>, + typename T3_ = NoField<3>, + typename T4_ = NoField<4>, + typename T5_ = NoField<5> + > class KeyedClass; + + } +} + +#endif diff --git a/paludis/util/kc.hh b/paludis/util/kc.hh new file mode 100644 index 000000000..ad4f1b074 --- /dev/null +++ b/paludis/util/kc.hh @@ -0,0 +1,260 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 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_UTIL_KC_HH +#define PALUDIS_GUARD_PALUDIS_UTIL_KC_HH 1 + +#include <paludis/util/kc-fwd.hh> + +namespace paludis +{ + namespace kc + { + template <typename Key_, typename Type_> + struct Field + { + typedef Type_ ConstructorType; + typedef void DefaultConstructorValueType; + + typedef Key_ NamedKeyFirstParamType; + typedef Type_ NamedKeySecondParamType; + }; + + template <unsigned id_> + struct NoField + { + typedef NoField<id_> ConstructorType; + typedef NoField<id_> DefaultConstructorValueType; + + typedef NoField<id_> NamedKeyFirstParamType; + typedef NoField<id_> NamedKeySecondParamType; + }; + + template <unsigned id_> + struct Key + { + }; + + template <bool b_, typename T_> + struct NamedField; + + template <typename T_> + struct NamedField<false, T_> + { + }; + + template <unsigned id_, typename T_> + struct NamedField<true, Field<Key<id_>, T_> > + { + const T_ & value; + + NamedField(const T_ & v) : + value(v) + { + } + }; + + template <typename T_> + struct Part; + + template <unsigned id_> + struct Part<NoField<id_> > + { + public: + void operator[] (const NoField<id_> &); + + Part(const NoField<id_> &) + { + } + + Part(const NamedField<false, NoField<id_> > &) + { + } + }; + + template <unsigned id_, typename Type_> + class Part<Field<Key<id_>, Type_> > + { + private: + Type_ _value; + + public: + Type_ & operator[] (const Key<id_> &) + { + return _value; + } + + const Type_ & operator[] (const Key<id_> &) const + { + return _value; + } + + Part(const Type_ & v) : + _value(v) + { + } + + Part(const NamedField<true, Field<Key<id_>, Type_> > & v) : + _value(v.value) + { + } + }; + + template < + typename T1_, + typename T2_, + typename T3_, + typename T4_, + typename T5_ + > class KeyedClass : + public Part<T1_>, + public Part<T2_>, + public Part<T3_>, + public Part<T4_>, + public Part<T5_> + { + public: + typedef KeyedClass BaseType; + + KeyedClass + ( + const typename T1_::ConstructorType & v1 = typename T1_::DefaultConstructorValueType(), + const typename T2_::ConstructorType & v2 = typename T2_::DefaultConstructorValueType(), + const typename T3_::ConstructorType & v3 = typename T3_::DefaultConstructorValueType(), + const typename T4_::ConstructorType & v4 = typename T4_::DefaultConstructorValueType(), + const typename T5_::ConstructorType & v5 = typename T5_::DefaultConstructorValueType() + ) : + Part<T1_>(v1), + Part<T2_>(v2), + Part<T3_>(v3), + Part<T4_>(v4), + Part<T5_>(v5) + { + } + + KeyedClass(const KeyedClass & other) : + Part<T1_>(other), + Part<T2_>(other), + Part<T3_>(other), + Part<T4_>(other), + Part<T5_>(other) + { + } + + using Part<T1_>::operator[]; + using Part<T2_>::operator[]; + using Part<T3_>::operator[]; + using Part<T4_>::operator[]; + using Part<T5_>::operator[]; + + template < + bool b1_, + bool b2_, + bool b3_, + bool b4_, + bool b5_ + > + struct Named + { + NamedField<b1_, T1_> v1; + NamedField<b2_, T2_> v2; + NamedField<b3_, T3_> v3; + NamedField<b4_, T4_> v4; + NamedField<b5_, T5_> v5; + + Named() + { + } + + Named( + NamedField<b1_, T1_> p1, + NamedField<b2_, T2_> p2, + NamedField<b3_, T3_> p3, + NamedField<b4_, T4_> p4, + NamedField<b5_, T5_> p5 + ) : + v1(p1), + v2(p2), + v3(p3), + v4(p4), + v5(p5) + { + } + + Named<true, b2_, b3_, b4_, b5_> operator() ( + const typename T1_::NamedKeyFirstParamType &, + const typename T1_::NamedKeySecondParamType & v) + { + return Named<! b1_, b2_, b3_, b4_, b5_>(v, v2, v3, v4, v5); + } + + Named<b1_, true, b3_, b4_, b5_> operator() ( + const typename T2_::NamedKeyFirstParamType &, + const typename T2_::NamedKeySecondParamType & v) + { + return Named<b1_, ! b2_, b3_, b4_, b5_>(v1, v, v3, v4, v5); + } + + Named<b1_, b2_, true, b4_, b5_> operator() ( + const typename T3_::NamedKeyFirstParamType &, + const typename T3_::NamedKeySecondParamType & v) + { + return Named<b1_, b2_, ! b3_, b4_, b5_>(v1, v2, v, v4, v5); + } + + Named<b1_, b2_, b3_, true, b5_> operator() ( + const typename T4_::NamedKeyFirstParamType &, + const typename T4_::NamedKeySecondParamType & v) + { + return Named<b1_, b2_, b3_, ! b4_, b5_>(v1, v2, v3, v, v5); + } + + Named<b1_, b2_, b3_, b4_, true> operator() ( + const typename T5_::NamedKeyFirstParamType &, + const typename T5_::NamedKeySecondParamType & v) + { + return Named<b1_, b2_, b3_, b4_, ! b5_>(v1, v2, v3, v4, v); + } + }; + + static Named<false, false, false, false, false> named_create() + { + return Named<false, false, false, false, false>(); + } + + template < + bool b1_, + bool b2_, + bool b3_, + bool b4_, + bool b5_> + KeyedClass(const Named<b1_, b2_, b3_, b4_, b5_> & named) : + Part<T1_>(named.v1), + Part<T2_>(named.v2), + Part<T3_>(named.v3), + Part<T4_>(named.v4), + Part<T5_>(named.v5) + { + } + }; + + } +} + +#endif diff --git a/paludis/util/keys.hh b/paludis/util/keys.hh new file mode 100644 index 000000000..4879bb385 --- /dev/null +++ b/paludis/util/keys.hh @@ -0,0 +1,43 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 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_UTIL_KEYS_HH +#define PALUDIS_GUARD_PALUDIS_UTIL_KEYS_HH 1 + +#include <paludis/util/kc-fwd.hh> + +namespace paludis +{ + namespace k + { + typedef kc::Key<1> fetch_unneeded; + typedef kc::Key<2> safe_resume; + typedef kc::Key<3> no_config_protect; + typedef kc::Key<4> debug_build; + typedef kc::Key<5> checks; + typedef kc::Key<6> destination; + typedef kc::Key<7> visible; + typedef kc::Key<8> target_file; + typedef kc::Key<9> requires_manual_fetching; + typedef kc::Key<10> failed_automatic_fetching; + typedef kc::Key<11> failed_integrity_checks; + } +} + +#endif diff --git a/python/action.cc b/python/action.cc index c1e76153f..7229aa93e 100644 --- a/python/action.cc +++ b/python/action.cc @@ -23,12 +23,28 @@ #include <paludis/action.hh> #include <paludis/util/tr1_memory.hh> #include <paludis/util/visitor-impl.hh> +#include <paludis/util/kc.hh> #include <paludis/repository.hh> using namespace paludis; using namespace paludis::python; namespace bp = boost::python; +namespace +{ + template <typename C_, typename T_, typename K_> + T_ kc_getter(const C_ & c) + { + return c[K_()]; + } + + template <typename C_, typename T_, typename K_> + void kc_setter(C_ & c, const T_ & t) + { + c[K_()] = t; + } +} + template <typename A_> class class_supports_action_test : public bp::class_<SupportsActionTest<A_>, bp::bases<SupportsActionTestBase> > @@ -96,22 +112,27 @@ void expose_action() "InstallActionChecksOption, Repository)" ) ) - .def_readwrite("no_config_protect", &InstallActionOptions::no_config_protect, + .add_property("no_config_protect", + &kc_getter<InstallActionOptions, bool, k::no_config_protect>, + &kc_setter<InstallActionOptions, bool, k::no_config_protect>, "[rw] bool" ) - .def_readwrite("debug_build", &InstallActionOptions::debug_build, + .add_property("debug_build", + &kc_getter<InstallActionOptions, InstallActionDebugOption, k::debug_build>, + &kc_setter<InstallActionOptions, InstallActionDebugOption, k::debug_build>, "[rw] InstallActionDebugOption" ) - .def_readwrite("checks", &InstallActionOptions::checks, + .add_property("checks", + &kc_getter<InstallActionOptions, InstallActionChecksOption, k::checks>, + &kc_setter<InstallActionOptions, InstallActionChecksOption, k::checks>, "[rw] InstallActionChecksOption" ) .add_property("destination", - bp::make_getter(&InstallActionOptions::destination, - bp::return_value_policy<bp::return_by_value>()), - bp::make_setter(&InstallActionOptions::destination), + &kc_getter<InstallActionOptions, tr1::shared_ptr<Repository>, k::destination>, + &kc_setter<InstallActionOptions, tr1::shared_ptr<Repository>, k::destination>, "[rw] Repository" ) ; @@ -125,11 +146,15 @@ void expose_action() "Options for FetchAction.", bp::init<const bool &, const bool &>("__init__(fetch_unneeded_bool, safe_resume_bool)") ) - .def_readwrite("fetch_unneeded", &FetchActionOptions::fetch_unneeded, + .add_property("fetch_unneeded", + &kc_getter<FetchActionOptions, bool, k::fetch_unneeded>, + &kc_setter<FetchActionOptions, bool, k::fetch_unneeded>, "[rw] bool" ) - .def_readwrite("safe_resume", &FetchActionOptions::safe_resume, + .add_property("safe_resume", + &kc_getter<FetchActionOptions, bool, k::safe_resume>, + &kc_setter<FetchActionOptions, bool, k::safe_resume>, "[rw] bool" ) ; @@ -143,7 +168,9 @@ void expose_action() "Options for UninstallAction.", bp::init<const bool &>("__init__(no_config_protect_bool)") ) - .def_readwrite("no_config_protect", &UninstallActionOptions::no_config_protect, + .add_property("no_config_protect", + &kc_getter<UninstallActionOptions, bool, k::no_config_protect>, + &kc_setter<UninstallActionOptions, bool, k::no_config_protect>, "[rw] bool" ) ; diff --git a/ruby/action.cc b/ruby/action.cc index c0f16c5f8..88810f3df 100644 --- a/ruby/action.cc +++ b/ruby/action.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007 Ciaran McCreesh + * Copyright (c) 2007, 2008 Ciaran McCreesh * Copyright (c) 2007 Richard Brown * * This file is part of the Paludis package manager. Paludis is free software; @@ -21,6 +21,7 @@ #include <paludis_ruby.hh> #include <paludis/action.hh> #include <paludis/util/visitor-impl.hh> +#include <paludis/util/kc.hh> #include <ruby.h> using namespace paludis; @@ -290,9 +291,9 @@ namespace rb_raise(rb_eArgError, "FetchActionOptions expects one or two arguments, but got %d",argc); } - ptr = new FetchActionOptions(FetchActionOptions::create() - .fetch_unneeded(v_fetch_unneeded) - .safe_resume(v_safe_resume) + ptr = new FetchActionOptions(FetchActionOptions::named_create() + (k::fetch_unneeded(), v_fetch_unneeded) + (k::safe_resume(), v_safe_resume) ); VALUE tdata(Data_Wrap_Struct(self, 0, &Common<FetchActionOptions>::free, ptr)); @@ -385,11 +386,11 @@ namespace rb_raise(rb_eArgError, "FetchActionOptions expects one or four arguments, but got %d",argc); } - ptr = new FetchActionFailure(FetchActionFailure::create() - .target_file(v_target_file) - .requires_manual_fetching(v_requires_manual_fetching) - .failed_automatic_fetching(v_failed_automatic_fetching) - .failed_integrity_checks(v_failed_integrity_checks) + ptr = new FetchActionFailure(FetchActionFailure::named_create() + (k::target_file(), v_target_file) + (k::requires_manual_fetching(), v_requires_manual_fetching) + (k::failed_automatic_fetching(), v_failed_automatic_fetching) + (k::failed_integrity_checks(), v_failed_integrity_checks) ); VALUE tdata(Data_Wrap_Struct(self, 0, &Common<FetchActionFailure>::free, ptr)); @@ -417,18 +418,6 @@ namespace * * Our failed integrity checks. */ - template <std::string FetchActionFailure::* m_> - struct FailureStringFetch - { - static VALUE - fetch(VALUE self) - { - FetchActionFailure * ptr; - Data_Get_Struct(self, FetchActionFailure, ptr); - return rb_str_new2(((*ptr).*m_).c_str()); - } - }; - /* * Document-method: fetch_unneeded? * @@ -465,15 +454,59 @@ namespace * * Do we ignore config protection. */ - template <typename T_, bool T_::* m_> - struct BoolFetch + template <typename T_, typename K_, typename R_> + struct KCFetch; + + template <typename T_, typename K_> + struct KCFetch<T_, K_, bool> + { + static VALUE + fetch(VALUE self) + { + T_ * p; + Data_Get_Struct(self, T_, p); + return bool_to_value((*p)[K_()]); + } + }; + + template <typename T_, typename K_> + struct KCFetch<T_, K_, std::string> { static VALUE fetch(VALUE self) { T_ * p; Data_Get_Struct(self, T_, p); - return bool_to_value((*p).*m_); + return rb_str_new2((*p)[K_()].c_str()); + } + }; + + /* + * Document-method: debug_build + * + * call-seq: + * debug_build -> FixNum + * + * Our InstallActionDebugOption + */ + /* + * Document-method: checks + * + * call-seq: + * checks -> FixNum + * + * Our InstallActionChecksOption + * + */ + template <typename T_, typename K_> + struct KCFetchEnum + { + static VALUE + fetch(VALUE self) + { + T_ * p; + Data_Get_Struct(self, T_, p); + return INT2FIX((*p)[K_()]); } }; @@ -565,11 +598,11 @@ namespace rb_raise(rb_eArgError, "InstallActionOptions expects one or four arguments, but got %d",argc); } - ptr = new InstallActionOptions(InstallActionOptions::create() - .no_config_protect(v_no_config_protect) - .debug_build(v_debug_build) - .checks(v_checks) - .destination(v_destination) + ptr = new InstallActionOptions(InstallActionOptions::named_create() + (k::no_config_protect(), v_no_config_protect) + (k::debug_build(), v_debug_build) + (k::checks(), v_checks) + (k::destination(), v_destination) ); VALUE tdata(Data_Wrap_Struct(self, 0, &Common<InstallActionOptions>::free, ptr)); @@ -584,35 +617,6 @@ namespace } /* - * Document-method: debug_build - * - * call-seq: - * debug_build -> Fixnum - * - * Our InstallActionDebugOption - */ - /* - * Document-method: checks - * - * call-seq: - * checks -> FixNum - * - * Our InstallActionChecksOption - * - */ - template <typename T_, T_ InstallActionOptions::* m_> - struct IAOMember - { - static VALUE - fetch(VALUE self) - { - InstallActionOptions * p; - Data_Get_Struct(self, InstallActionOptions, p); - return INT2FIX((*p).*m_); - } - }; - - /* * Document-method: destination * * call-seq: @@ -625,7 +629,7 @@ namespace { InstallActionOptions * p; Data_Get_Struct(self, InstallActionOptions, p); - return repository_to_value(p->destination); + return repository_to_value((*p)[k::destination()]); } /* @@ -689,8 +693,8 @@ namespace rb_raise(rb_eArgError, "UninstallActionOptions expects one argument, but got %d",argc); } - ptr = new UninstallActionOptions(UninstallActionOptions::create() - .no_config_protect(v_no_config_protect) + ptr = new UninstallActionOptions(UninstallActionOptions::named_create() + (k::no_config_protect(), v_no_config_protect) ); VALUE tdata(Data_Wrap_Struct(self, 0, &Common<UninstallActionOptions>::free, ptr)); @@ -869,9 +873,9 @@ namespace rb_define_singleton_method(c_fetch_action_options, "new", RUBY_FUNC_CAST(&fetch_action_options_new), -1); rb_define_method(c_fetch_action_options, "initialize", RUBY_FUNC_CAST(&empty_init), -1); rb_define_method(c_fetch_action_options, "fetch_unneeded?", - RUBY_FUNC_CAST((&BoolFetch<FetchActionOptions, &FetchActionOptions::fetch_unneeded>::fetch)), 0); + RUBY_FUNC_CAST((&KCFetch<FetchActionOptions, k::fetch_unneeded, bool>::fetch)), 0); rb_define_method(c_fetch_action_options, "safe_resume?", - RUBY_FUNC_CAST((&BoolFetch<FetchActionOptions, &FetchActionOptions::safe_resume>::fetch)), 0); + RUBY_FUNC_CAST((&KCFetch<FetchActionOptions, k::safe_resume, bool>::fetch)), 0); /* * Document-class: Paludis::FetchActionFailure @@ -882,13 +886,13 @@ namespace rb_define_singleton_method(c_fetch_action_failure, "new", RUBY_FUNC_CAST(&fetch_action_failure_new), -1); rb_define_method(c_fetch_action_failure, "initialize", RUBY_FUNC_CAST(&empty_init), -1); rb_define_method(c_fetch_action_failure, "target_file", - RUBY_FUNC_CAST((&FailureStringFetch<&FetchActionFailure::target_file>::fetch)), 0); + RUBY_FUNC_CAST((&KCFetch<FetchActionFailure, k::target_file, std::string>::fetch)), 0); rb_define_method(c_fetch_action_failure, "requires_manual_fetching?", - RUBY_FUNC_CAST((&BoolFetch<FetchActionFailure, &FetchActionFailure::requires_manual_fetching>::fetch)), 0); + RUBY_FUNC_CAST((&KCFetch<FetchActionFailure, k::requires_manual_fetching, bool>::fetch)), 0); rb_define_method(c_fetch_action_failure, "failed_automatic_fetching?", - RUBY_FUNC_CAST((&BoolFetch<FetchActionFailure, &FetchActionFailure::failed_automatic_fetching>::fetch)), 0); + RUBY_FUNC_CAST((&KCFetch<FetchActionFailure, k::failed_automatic_fetching, bool>::fetch)), 0); rb_define_method(c_fetch_action_failure, "failed_integrity_checks", - RUBY_FUNC_CAST((&FailureStringFetch<&FetchActionFailure::failed_integrity_checks>::fetch)), 0); + RUBY_FUNC_CAST((&KCFetch<FetchActionFailure, k::failed_integrity_checks, std::string>::fetch)), 0); /* * Document-class: Paludis::InfoAction @@ -947,11 +951,11 @@ namespace rb_define_singleton_method(c_install_action_options, "new", RUBY_FUNC_CAST(&install_action_options_new), -1); rb_define_method(c_install_action_options, "initialize", RUBY_FUNC_CAST(&empty_init), -1); rb_define_method(c_install_action_options, "no_config_protect?", - RUBY_FUNC_CAST((&BoolFetch<InstallActionOptions, &InstallActionOptions::no_config_protect>::fetch)), 0); + RUBY_FUNC_CAST((&KCFetch<InstallActionOptions, k::no_config_protect, bool>::fetch)), 0); rb_define_method(c_install_action_options, "debug_build", - RUBY_FUNC_CAST((&IAOMember<InstallActionDebugOption, &InstallActionOptions::debug_build>::fetch)), 0); + RUBY_FUNC_CAST((&KCFetchEnum<InstallActionOptions, k::debug_build>::fetch)), 0); rb_define_method(c_install_action_options, "checks", - RUBY_FUNC_CAST((&IAOMember<InstallActionChecksOption, &InstallActionOptions::checks>::fetch)), 0); + RUBY_FUNC_CAST((&KCFetchEnum<InstallActionOptions, k::checks>::fetch)), 0); rb_define_method(c_install_action_options, "destination", RUBY_FUNC_CAST(&install_action_options_destination), 0); /* @@ -973,7 +977,7 @@ namespace rb_define_singleton_method(c_uninstall_action_options, "new", RUBY_FUNC_CAST(&uninstall_action_options_new), -1); rb_define_method(c_uninstall_action_options, "initialize", RUBY_FUNC_CAST(&empty_init), -1); rb_define_method(c_uninstall_action_options, "no_config_protect?", - RUBY_FUNC_CAST((&BoolFetch<UninstallActionOptions, &UninstallActionOptions::no_config_protect>::fetch)), 0); + RUBY_FUNC_CAST((&KCFetch<UninstallActionOptions, k::no_config_protect, bool>::fetch)), 0); /* * Document-class: Paludis::UninstallAction diff --git a/ruby/paludis_ruby.cc b/ruby/paludis_ruby.cc index 1ebe0b5ef..ff61ba020 100644 --- a/ruby/paludis_ruby.cc +++ b/ruby/paludis_ruby.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007 Ciaran McCreesh + * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh * Copyright (c) 2006, 2007, 2008 Richard Brown * * This file is part of the Paludis package manager. Paludis is free software; @@ -21,6 +21,7 @@ #include <paludis/paludis.hh> #include <paludis_ruby.hh> #include <paludis/util/config_file.hh> +#include <paludis/util/kc.hh> #include <paludis/dep_list_exceptions.hh> #include <paludis/util/private_implementation_pattern-impl.hh> #include <paludis/util/instantiation_policy-impl.hh> diff --git a/src/clients/accerso/accerso.cc b/src/clients/accerso/accerso.cc index ca245fc56..b5c15f38d 100644 --- a/src/clients/accerso/accerso.cc +++ b/src/clients/accerso/accerso.cc @@ -31,6 +31,7 @@ #include <paludis/util/map.hh> #include <paludis/util/tr1_functional.hh> #include <paludis/util/visitor-impl.hh> +#include <paludis/util/kc.hh> #include <paludis/environments/no_config/no_config_environment.hh> #include <paludis/package_database.hh> #include <paludis/query.hh> @@ -125,9 +126,9 @@ main(int argc, char *argv[]) try { - FetchAction a(FetchActionOptions::create() - .safe_resume(true) - .fetch_unneeded(true) + FetchAction a(FetchActionOptions::named_create() + (k::safe_resume(), true) + (k::fetch_unneeded(), true) ); if ((*i)->supports_action(SupportsActionTest<FetchAction>())) { @@ -142,24 +143,24 @@ main(int argc, char *argv[]) for (Sequence<FetchActionFailure>::ConstIterator f(e.failures()->begin()), f_end(e.failures()->end()) ; f != f_end ; ++f) { std::string r; - if (f->requires_manual_fetching) + if ((*f)[k::requires_manual_fetching()]) r = "manual"; - if (f->failed_automatic_fetching) + if ((*f)[k::failed_automatic_fetching()]) { if (! r.empty()) r.append(", "); r.append("could not fetch"); } - if (! f->failed_integrity_checks.empty()) + if (! (*f)[k::failed_integrity_checks()].empty()) { if (! r.empty()) r.append(", "); - r.append(f->failed_integrity_checks); + r.append((*f)[k::failed_integrity_checks()]); } - results.insert(std::make_pair(*i, f->target_file + ": " + r)); + results.insert(std::make_pair(*i, (*f)[k::target_file()] + ": " + r)); } } catch (const Exception & e) diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc index e05c3fbed..054a8562a 100644 --- a/src/output/console_install_task.cc +++ b/src/output/console_install_task.cc @@ -36,6 +36,7 @@ #include <paludis/util/system.hh> #include <paludis/util/iterator_funcs.hh> #include <paludis/util/visitor_cast.hh> +#include <paludis/util/kc.hh> #include <paludis/query.hh> #include <paludis/action.hh> #include <paludis/repository.hh> @@ -1442,16 +1443,16 @@ ConsoleInstallTask::on_fetch_action_error(const FetchActionError & e) for (Sequence<FetchActionFailure>::ConstIterator f(e.failures()->begin()), f_end(e.failures()->end()) ; f != f_end ; ++f) { - output_stream() << " * File '" << f->target_file << "': "; + output_stream() << " * File '" << (*f)[k::target_file()] << "': "; bool need_comma(false); - if (f->requires_manual_fetching) + if ((*f)[k::requires_manual_fetching()]) { output_stream() << "requires manual fetching"; need_comma = true; } - if (f->failed_automatic_fetching) + if ((*f)[k::failed_automatic_fetching()]) { if (need_comma) output_stream() << ", "; @@ -1459,11 +1460,11 @@ ConsoleInstallTask::on_fetch_action_error(const FetchActionError & e) need_comma = true; } - if (! f->failed_integrity_checks.empty()) + if (! (*f)[k::failed_integrity_checks()].empty()) { if (need_comma) output_stream() << ", "; - output_stream() << "failed integrity checks: " << f->failed_integrity_checks; + output_stream() << "failed integrity checks: " << (*f)[k::failed_integrity_checks()]; need_comma = true; } |