aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-12-06 20:56:30 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-12-06 20:56:30 +0000
commite57e0581b110f84e85e8bef47216210f12b7e211 (patch)
tree2cd0d8c79b6d85bc0d7314f178eb93a3506ba0d3
parentc83a35329debb115d0f44d6132833ec71a176b52 (diff)
downloadpaludis-e57e0581b110f84e85e8bef47216210f12b7e211.tar.gz
paludis-e57e0581b110f84e85e8bef47216210f12b7e211.tar.xz
kill more sr
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/report_task.cc10
-rw-r--r--paludis/uninstall_list.cc36
-rw-r--r--paludis/uninstall_list.hh42
-rw-r--r--paludis/uninstall_list.sr49
-rw-r--r--paludis/uninstall_list_TEST.cc72
-rw-r--r--paludis/uninstall_task.cc21
-rw-r--r--src/clients/paludis/uninstall.cc22
8 files changed, 126 insertions, 128 deletions
diff --git a/paludis/files.m4 b/paludis/files.m4
index 244136c..973c13c 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -77,7 +77,7 @@ add(`syncer', `hh', `cc')
add(`sync_task', `hh', `cc')
add(`tasks_exceptions', `hh', `cc')
add(`unchoices_key', `hh', `cc', `fwd')
-add(`uninstall_list', `hh', `cc', `se', `sr', `test')
+add(`uninstall_list', `hh', `cc', `se', `test')
add(`uninstall_task', `hh', `cc')
add(`unmerger', `hh', `cc')
add(`user_dep_spec', `hh', `cc', `se', `fwd', `test')
diff --git a/paludis/report_task.cc b/paludis/report_task.cc
index a30a316..6b8daf1 100644
--- a/paludis/report_task.cc
+++ b/paludis/report_task.cc
@@ -166,13 +166,17 @@ ReportTask::execute()
}
}
- UninstallList unused_list(e, UninstallListOptions());
+ UninstallList unused_list(e, make_named_values<UninstallListOptions>(
+ value_for<n::with_dependencies_as_errors>(false),
+ value_for<n::with_dependencies_included>(false),
+ value_for<n::with_unused_dependencies>(false)
+ ));
unused_list.add_unused();
std::set<std::tr1::shared_ptr<const PackageID>, PackageIDSetComparator> unused;
for (UninstallList::ConstIterator i(unused_list.begin()), i_end(unused_list.end());
i != i_end ; ++i)
- if (i->kind != ulk_virtual)
- unused.insert(i->package_id);
+ if (i->kind() != ulk_virtual)
+ unused.insert(i->package_id());
for (PackageDatabase::RepositoryConstIterator r(e->package_database()->begin_repositories()),
r_end(e->package_database()->end_repositories()) ; r != r_end ; ++r)
diff --git a/paludis/uninstall_list.cc b/paludis/uninstall_list.cc
index fd566e3..8d7dae3 100644
--- a/paludis/uninstall_list.cc
+++ b/paludis/uninstall_list.cc
@@ -33,6 +33,7 @@
#include <paludis/util/wrapped_forward_iterator-impl.hh>
#include <paludis/util/wrapped_output_iterator-impl.hh>
#include <paludis/util/hashes.hh>
+#include <paludis/util/make_named_values.hh>
#include <paludis/match_package.hh>
#include <paludis/package_database.hh>
#include <paludis/package_id.hh>
@@ -51,7 +52,6 @@
using namespace paludis;
#include <paludis/uninstall_list-se.cc>
-#include <paludis/uninstall_list-sr.cc>
typedef std::tr1::unordered_map<
std::tr1::shared_ptr<const PackageID>,
@@ -95,7 +95,7 @@ namespace
bool operator() (const UninstallListEntry & f) const
{
- return *f.package_id == *e;
+ return *f.package_id() == *e;
}
};
}
@@ -125,7 +125,7 @@ UninstallList::real_add(const std::tr1::shared_ptr<const PackageID> & e, const s
_imp->uninstall_list.end(), MatchUninstallListEntry(e)))))
{
if (t)
- i->tags->insert(t);
+ i->tags()->insert(t);
return;
}
@@ -138,15 +138,15 @@ UninstallList::real_add(const std::tr1::shared_ptr<const PackageID> & e, const s
if (! error)
{
/* don't recurse errors, it gets horrid */
- if (_imp->options.with_dependencies_included)
+ if (_imp->options.with_dependencies_included())
add_dependencies(*e, false);
- else if (_imp->options.with_dependencies_as_errors)
+ else if (_imp->options.with_dependencies_as_errors())
add_dependencies(*e, true);
}
move_package_to_end(e);
- if (_imp->options.with_unused_dependencies)
+ if (_imp->options.with_unused_dependencies())
add_unused_dependencies();
}
@@ -192,13 +192,6 @@ UninstallList::end() const
return ConstIterator(_imp->uninstall_list.end());
}
-UninstallListOptions::UninstallListOptions() :
- with_unused_dependencies(false),
- with_dependencies_included(false),
- with_dependencies_as_errors(false)
-{
-}
-
void
UninstallList::add_package(const std::tr1::shared_ptr<const PackageID> & e, const std::tr1::shared_ptr<DepTag> & t,
const UninstallListEntryKind k)
@@ -206,13 +199,14 @@ UninstallList::add_package(const std::tr1::shared_ptr<const PackageID> & e, cons
Context context("When adding package '" + stringify(*e) + "' to the uninstall list:");
std::list<UninstallListEntry>::iterator i(_imp->uninstall_list.insert(
- _imp->uninstall_list.end(), UninstallListEntry(UninstallListEntry::create()
- .package_id(e)
- .tags(make_shared_ptr(new Set<std::tr1::shared_ptr<DepTag> >))
- .kind(k))));
+ _imp->uninstall_list.end(), make_named_values<UninstallListEntry>(
+ value_for<n::kind>(k),
+ value_for<n::package_id>(e),
+ value_for<n::tags>(make_shared_ptr(new Set<std::tr1::shared_ptr<DepTag> >))
+ )));
if (t)
- i->tags->insert(t);
+ i->tags()->insert(t);
}
void
@@ -408,8 +402,8 @@ UninstallList::add_unused_dependencies()
std::tr1::shared_ptr<PackageIDSet> uninstall_list_targets(new PackageIDSet);
for (std::list<UninstallListEntry>::const_iterator i(_imp->uninstall_list.begin()),
i_end(_imp->uninstall_list.end()) ; i != i_end ; ++i)
- if (i->kind == ulk_package || i->kind == ulk_virtual)
- uninstall_list_targets->insert(i->package_id);
+ if (i->kind() == ulk_package || i->kind() == ulk_virtual)
+ uninstall_list_targets->insert(i->package_id());
std::tr1::shared_ptr<const PackageIDSet> depped_upon_list(collect_depped_upon(uninstall_list_targets));
@@ -530,7 +524,7 @@ namespace
{
bool operator() (const UninstallListEntry & e) const
{
- switch (e.kind)
+ switch (e.kind())
{
case ulk_virtual:
case ulk_package:
diff --git a/paludis/uninstall_list.hh b/paludis/uninstall_list.hh
index 05e10b7..9911447 100644
--- a/paludis/uninstall_list.hh
+++ b/paludis/uninstall_list.hh
@@ -22,8 +22,8 @@
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/private_implementation_pattern.hh>
-#include <paludis/util/sr.hh>
#include <paludis/util/wrapped_forward_iterator-fwd.hh>
+#include <paludis/util/named_value.hh>
#include <paludis/package_id-fwd.hh>
#include <paludis/dep_tag-fwd.hh>
@@ -39,9 +39,45 @@
namespace paludis
{
-
#include <paludis/uninstall_list-se.hh>
-#include <paludis/uninstall_list-sr.hh>
+
+ namespace n
+ {
+ struct kind;
+ struct package_id;
+ struct tags;
+ struct with_dependencies_as_errors;
+ struct with_dependencies_included;
+ struct with_unused_dependencies;
+ }
+
+ /**
+ * Parameters for an UninstallList.
+ *
+ * \see UninstallList
+ * \ingroup g_dep_list
+ * \nosubgrouping
+ */
+ struct UninstallListOptions
+ {
+ NamedValue<n::with_dependencies_as_errors, bool> with_dependencies_as_errors;
+ NamedValue<n::with_dependencies_included, bool> with_dependencies_included;
+ NamedValue<n::with_unused_dependencies, bool> with_unused_dependencies;
+ };
+
+ /**
+ * An entry in an UninstallList.
+ *
+ * \see UninstallList
+ * \ingroup g_dep_list
+ * \nosubgrouping
+ */
+ struct UninstallListEntry
+ {
+ NamedValue<n::kind, UninstallListEntryKind> kind;
+ NamedValue<n::package_id, std::tr1::shared_ptr<const PackageID> > package_id;
+ NamedValue<n::tags, std::tr1::shared_ptr<Set<std::tr1::shared_ptr<DepTag> > > > tags;
+ };
class Environment;
diff --git a/paludis/uninstall_list.sr b/paludis/uninstall_list.sr
deleted file mode 100644
index 78af011..0000000
--- a/paludis/uninstall_list.sr
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/usr/bin/env bash
-# vim: set sw=4 sts=4 et :
-
-make_class_UninstallListOptions()
-{
- visible
-
- key with_unused_dependencies bool
- key with_dependencies_included bool
- key with_dependencies_as_errors bool
-
- extra_constructors <<END
- UninstallListOptions();
-END
-
- allow_named_args
-
- doxygen_comment << "END"
- /**
- * Parameters for an UninstallList.
- *
- * \see UninstallList
- * \ingroup g_dep_list
- * \nosubgrouping
- */
-END
-}
-
-make_class_UninstallListEntry()
-{
- visible
-
- key package_id "std::tr1::shared_ptr<const PackageID>"
- key tags "std::tr1::shared_ptr<Set<std::tr1::shared_ptr<DepTag> > >"
- key kind UninstallListEntryKind
-
- allow_named_args
-
- doxygen_comment << "END"
- /**
- * An entry in an UninstallList.
- *
- * \see UninstallList
- * \ingroup g_dep_list
- * \nosubgrouping
- */
-END
-}
-
diff --git a/paludis/uninstall_list_TEST.cc b/paludis/uninstall_list_TEST.cc
index 5ee8c38..dfb065b 100644
--- a/paludis/uninstall_list_TEST.cc
+++ b/paludis/uninstall_list_TEST.cc
@@ -24,6 +24,7 @@
#include <paludis/environments/test/test_environment.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/options.hh>
+#include <paludis/util/make_named_values.hh>
#include <paludis/package_database.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/repository_factory.hh>
@@ -43,7 +44,7 @@ namespace paludis
std::ostream &
operator<< (std::ostream & s, const UninstallListEntry & e)
{
- s << *e.package_id;
+ s << *e.package_id();
return s;
}
}
@@ -163,7 +164,11 @@ namespace test_cases
virtual UninstallListOptions options()
{
- return UninstallListOptions();
+ return make_named_values<UninstallListOptions>(
+ value_for<n::with_dependencies_as_errors>(false),
+ value_for<n::with_dependencies_included>(false),
+ value_for<n::with_unused_dependencies>(false)
+ );
}
public:
@@ -247,10 +252,11 @@ namespace test_cases
UninstallListOptions options()
{
- return UninstallListOptions::create()
- .with_unused_dependencies(true)
- .with_dependencies_included(false)
- .with_dependencies_as_errors(false);
+ return make_named_values<UninstallListOptions>(
+ value_for<n::with_dependencies_as_errors>(false),
+ value_for<n::with_dependencies_included>(false),
+ value_for<n::with_unused_dependencies>(true)
+ );
}
} uninstall_list_with_unused_deps_test;
@@ -280,10 +286,11 @@ namespace test_cases
UninstallListOptions options()
{
- return UninstallListOptions::create()
- .with_unused_dependencies(true)
- .with_dependencies_included(false)
- .with_dependencies_as_errors(false);
+ return make_named_values<UninstallListOptions>(
+ value_for<n::with_dependencies_as_errors>(false),
+ value_for<n::with_dependencies_included>(false),
+ value_for<n::with_unused_dependencies>(true)
+ );
}
} uninstall_list_with_unused_deps_recursive_test;
@@ -313,10 +320,11 @@ namespace test_cases
UninstallListOptions options()
{
- return UninstallListOptions::create()
- .with_unused_dependencies(true)
- .with_dependencies_included(false)
- .with_dependencies_as_errors(false);
+ return make_named_values<UninstallListOptions>(
+ value_for<n::with_dependencies_as_errors>(false),
+ value_for<n::with_dependencies_included>(false),
+ value_for<n::with_unused_dependencies>(true)
+ );
}
} uninstall_list_with_unused_deps_with_used_test;
@@ -350,10 +358,11 @@ namespace test_cases
UninstallListOptions options()
{
- return UninstallListOptions::create()
- .with_unused_dependencies(true)
- .with_dependencies_as_errors(false)
- .with_dependencies_included(false);
+ return make_named_values<UninstallListOptions>(
+ value_for<n::with_dependencies_as_errors>(false),
+ value_for<n::with_dependencies_included>(false),
+ value_for<n::with_unused_dependencies>(true)
+ );
}
} uninstall_list_with_unused_deps_with_cross_used_test;
@@ -391,10 +400,11 @@ namespace test_cases
UninstallListOptions options()
{
- return UninstallListOptions::create()
- .with_unused_dependencies(true)
- .with_dependencies_included(false)
- .with_dependencies_as_errors(false);
+ return make_named_values<UninstallListOptions>(
+ value_for<n::with_dependencies_as_errors>(false),
+ value_for<n::with_dependencies_included>(false),
+ value_for<n::with_unused_dependencies>(true)
+ );
}
} uninstall_list_with_unused_deps_world_test;
@@ -435,10 +445,11 @@ namespace test_cases
UninstallListOptions options()
{
- return UninstallListOptions::create()
- .with_unused_dependencies(true)
- .with_dependencies_included(false)
- .with_dependencies_as_errors(false);
+ return make_named_values<UninstallListOptions>(
+ value_for<n::with_dependencies_as_errors>(false),
+ value_for<n::with_dependencies_included>(false),
+ value_for<n::with_unused_dependencies>(true)
+ );
}
} uninstall_list_with_unused_deps_world_target_test;
@@ -499,10 +510,11 @@ namespace test_cases
UninstallListOptions options()
{
- return UninstallListOptions::create()
- .with_unused_dependencies(false)
- .with_dependencies_included(false)
- .with_dependencies_as_errors(false);
+ return make_named_values<UninstallListOptions>(
+ value_for<n::with_dependencies_as_errors>(false),
+ value_for<n::with_dependencies_included>(false),
+ value_for<n::with_unused_dependencies>(false)
+ );
}
} uninstall_list_slots_test;
}
diff --git a/paludis/uninstall_task.cc b/paludis/uninstall_task.cc
index f06b402..9257245 100644
--- a/paludis/uninstall_task.cc
+++ b/paludis/uninstall_task.cc
@@ -230,10 +230,11 @@ UninstallTask::execute()
on_build_unmergelist_pre();
- UninstallList list(_imp->env, UninstallListOptions::create()
- .with_unused_dependencies(_imp->with_unused_dependencies)
- .with_dependencies_included(_imp->with_dependencies)
- .with_dependencies_as_errors(_imp->check_safety));
+ UninstallList list(_imp->env, make_named_values<UninstallListOptions>(
+ value_for<n::with_dependencies_as_errors>(_imp->check_safety),
+ value_for<n::with_dependencies_included>(_imp->with_dependencies),
+ value_for<n::with_unused_dependencies>(_imp->with_unused_dependencies)
+ ));
if (_imp->unused)
list.add_unused();
@@ -301,8 +302,8 @@ UninstallTask::execute()
std::map<QualifiedPackageName, std::set<VersionSpec> > being_removed;
for (UninstallList::ConstIterator i(list.begin()), i_end(list.end()) ; i != i_end ; ++i)
- if (i->kind != ulk_virtual)
- being_removed[i->package_id->name()].insert(i->package_id->version());
+ if (i->kind() != ulk_virtual)
+ being_removed[i->package_id()->name()].insert(i->package_id()->version());
for (std::map<QualifiedPackageName, std::set<VersionSpec> >::const_iterator
i(being_removed.begin()), i_end(being_removed.end()) ; i != i_end ; ++i)
@@ -340,16 +341,16 @@ UninstallTask::execute()
int x(0), y(0);
for (UninstallList::ConstIterator i(list.begin()), i_end(list.end()) ; i != i_end ; ++i)
- if (i->kind != ulk_virtual)
+ if (i->kind() != ulk_virtual)
++y;
for (UninstallList::ConstIterator i(list.begin()), i_end(list.end()) ; i != i_end ; ++i)
{
- if (i->kind == ulk_virtual)
+ if (i->kind() == ulk_virtual)
continue;
++x;
- std::string cpvr(stringify(*i->package_id));
+ std::string cpvr(stringify(*i->package_id()));
if (0 !=
_imp->env->perform_hook(Hook("uninstall_pre")("TARGET", cpvr)
@@ -363,7 +364,7 @@ UninstallTask::execute()
make_named_values<UninstallActionOptions>(
value_for<n::config_protect>("")
));
- i->package_id->perform_action(uninstall_action);
+ i->package_id()->perform_action(uninstall_action);
}
catch (const UninstallActionError & e)
{
diff --git a/src/clients/paludis/uninstall.cc b/src/clients/paludis/uninstall.cc
index 488d36a..923fdae 100644
--- a/src/clients/paludis/uninstall.cc
+++ b/src/clients/paludis/uninstall.cc
@@ -95,23 +95,23 @@ namespace
virtual void on_display_unmerge_list_entry(const UninstallListEntry & d)
{
- if (d.kind == ulk_virtual)
+ if (d.kind() == ulk_virtual)
if (CommandLine::get_instance()->install_args.a_show_reasons.argument() != "full")
return;
- switch (d.kind)
+ switch (d.kind())
{
case ulk_package:
- cout << "* " << colour(cl_package_name, stringify(*d.package_id));
+ cout << "* " << colour(cl_package_name, stringify(*d.package_id()));
++_count;
break;
case ulk_virtual:
- cout << "* " << colour(cl_unimportant, stringify(*d.package_id));
+ cout << "* " << colour(cl_unimportant, stringify(*d.package_id()));
break;
case ulk_required:
- cout << "* " << colour(cl_error, stringify(*d.package_id));
+ cout << "* " << colour(cl_error, stringify(*d.package_id()));
++_error_count;
break;
@@ -121,7 +121,7 @@ namespace
if ((CommandLine::get_instance()->install_args.a_show_reasons.argument() == "summary") ||
(CommandLine::get_instance()->install_args.a_show_reasons.argument() == "full") ||
- ulk_required == d.kind)
+ ulk_required == d.kind())
{
std::string deps;
unsigned count(0), max_count;
@@ -131,8 +131,8 @@ namespace
max_count = std::numeric_limits<long>::max();
for (Set<std::tr1::shared_ptr<DepTag> >::ConstIterator
- tag(d.tags->begin()),
- tag_end(d.tags->end()) ;
+ tag(d.tags()->begin()),
+ tag_end(d.tags()->end()) ;
tag != tag_end ; ++tag)
{
if ((*tag)->category() != "dependency")
@@ -150,9 +150,9 @@ namespace
deps.append(stringify(count - max_count + 1) + " more, ");
deps.erase(deps.length() - 2);
- if (d.kind == ulk_required)
+ if (d.kind() == ulk_required)
cout << " requires";
- cout << " " << colour(d.kind == ulk_virtual ? cl_unimportant : cl_tag,
+ cout << " " << colour(d.kind() == ulk_virtual ? cl_unimportant : cl_tag,
"<" + deps + ">");
}
}
@@ -167,7 +167,7 @@ namespace
virtual void on_uninstall_pre(const UninstallListEntry & d)
{
std::string msg("(" + stringify(++_current_count) + " of " +
- stringify(_count) + ") Uninstalling " + stringify(*d.package_id));
+ stringify(_count) + ") Uninstalling " + stringify(*d.package_id()));
cout << endl << colour(cl_heading, msg) << endl << endl;