aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-12-06 01:15:24 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-12-06 01:15:43 +0000
commit26e9d4a80c83fa61580e54b9251713e733242365 (patch)
tree3102de73e2b211c4943feed9d7881deee77ea6d9
parenta0e6861d05b92c6eff116467adc4dd5baad95bad (diff)
downloadpaludis-26e9d4a80c83fa61580e54b9251713e733242365.tar.gz
paludis-26e9d4a80c83fa61580e54b9251713e733242365.tar.xz
Kill more sr
-rw-r--r--paludis/environments/paludis/paludis_environment.cc34
-rw-r--r--paludis/environments/paludis/world.cc49
-rw-r--r--paludis/environments/portage/portage_environment.cc50
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/repositories/e/e_repository_sets.cc16
-rw-r--r--paludis/set_file.cc93
-rw-r--r--paludis/set_file.hh28
-rw-r--r--paludis/set_file.sr25
-rw-r--r--paludis/set_file_TEST.cc65
9 files changed, 185 insertions, 177 deletions
diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc
index 9532630..6b6a9f9 100644
--- a/paludis/environments/paludis/paludis_environment.cc
+++ b/paludis/environments/paludis/paludis_environment.cc
@@ -55,6 +55,7 @@
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/options.hh>
#include <paludis/util/tribool.hh>
+#include <paludis/util/make_named_values.hh>
#include <tr1/functional>
#include <functional>
@@ -291,28 +292,29 @@ PaludisEnvironment::local_set(const SetName & ss) const
if ((dir / (stringify(s.first) + ".bash")).exists())
{
- SetFile f(SetFileParams::create()
- .file_name(dir / (stringify(s.first) + ".bash"))
- .type(sft_paludis_bash)
- .parser(std::tr1::bind(&parse_user_package_dep_spec, _1, this,
- UserPackageDepSpecOptions() + updso_allow_wildcards + updso_no_disambiguation + updso_throw_if_set, filter::All()))
- .tag(tag)
- .set_operator_mode(s.second)
- .environment(this));
+ SetFile f(make_named_values<SetFileParams>(
+ value_for<n::environment>(this),
+ value_for<n::file_name>(dir / (stringify(s.first) + ".bash")),
+ value_for<n::parser>(std::tr1::bind(&parse_user_package_dep_spec, _1, this, UserPackageDepSpecOptions() + updso_allow_wildcards + updso_no_disambiguation + updso_throw_if_set, filter::All())),
+ value_for<n::set_operator_mode>(s.second),
+ value_for<n::tag>(tag),
+ value_for<n::type>(sft_paludis_bash)
+ ));
_imp->sets.insert(std::make_pair(ss, f.contents()));
return f.contents();
}
else if ((dir / (stringify(s.first) + ".conf")).exists())
{
- SetFile f(SetFileParams::create()
- .file_name(dir / (stringify(s.first) + ".conf"))
- .type(sft_paludis_conf)
- .parser(std::tr1::bind(&parse_user_package_dep_spec, _1,
- this, UserPackageDepSpecOptions() + updso_allow_wildcards, filter::All()))
- .tag(tag)
- .set_operator_mode(s.second)
- .environment(this));
+ SetFile f(make_named_values<SetFileParams>(
+ value_for<n::environment>(this),
+ value_for<n::file_name>(dir / (stringify(s.first) + ".conf")),
+ value_for<n::parser>(std::tr1::bind(&parse_user_package_dep_spec, _1, this,
+ UserPackageDepSpecOptions() + updso_allow_wildcards, filter::All())),
+ value_for<n::set_operator_mode>(s.second),
+ value_for<n::tag>(tag),
+ value_for<n::type>(sft_paludis_conf)
+ ));
_imp->sets.insert(std::make_pair(ss, f.contents()));
return f.contents();
diff --git a/paludis/environments/paludis/world.cc b/paludis/environments/paludis/world.cc
index 50be96e..86d45f4 100644
--- a/paludis/environments/paludis/world.cc
+++ b/paludis/environments/paludis/world.cc
@@ -23,6 +23,7 @@
#include <paludis/util/mutex.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/log.hh>
+#include <paludis/util/make_named_values.hh>
#include <paludis/set_file.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/dep_tag.hh>
@@ -111,14 +112,14 @@ World::_add_string_to_world(const std::string & n) const
}
}
- SetFile world(SetFileParams::create()
- .file_name(*_imp->maybe_world_file)
- .type(sft_simple)
- .parser(std::tr1::bind(&parse_user_package_dep_spec, _1, _imp->env, UserPackageDepSpecOptions() + updso_no_disambiguation + updso_throw_if_set,
- filter::All()))
- .tag(std::tr1::shared_ptr<DepTag>())
- .set_operator_mode(sfsmo_natural)
- .environment(_imp->env));
+ SetFile world(make_named_values<SetFileParams>(
+ value_for<n::environment>(_imp->env),
+ value_for<n::file_name>(*_imp->maybe_world_file),
+ value_for<n::parser>(std::tr1::bind(&parse_user_package_dep_spec, _1, _imp->env, UserPackageDepSpecOptions() + updso_no_disambiguation + updso_throw_if_set, filter::All())),
+ value_for<n::set_operator_mode>(sfsmo_natural),
+ value_for<n::tag>(std::tr1::shared_ptr<DepTag>()),
+ value_for<n::type>(sft_simple)
+ ));
world.add(n);
world.rewrite();
}
@@ -141,14 +142,14 @@ World::_remove_string_from_world(const std::string & n) const
if (_imp->maybe_world_file->exists())
{
- SetFile world(SetFileParams::create()
- .file_name(*_imp->maybe_world_file)
- .type(sft_simple)
- .parser(std::tr1::bind(&parse_user_package_dep_spec, _1, _imp->env, UserPackageDepSpecOptions() + updso_no_disambiguation + updso_throw_if_set,
- filter::All()))
- .tag(std::tr1::shared_ptr<DepTag>())
- .set_operator_mode(sfsmo_natural)
- .environment(_imp->env));
+ SetFile world(make_named_values<SetFileParams>(
+ value_for<n::environment>(_imp->env),
+ value_for<n::file_name>(*_imp->maybe_world_file),
+ value_for<n::parser>(std::tr1::bind(&parse_user_package_dep_spec, _1, _imp->env, UserPackageDepSpecOptions() + updso_no_disambiguation + updso_throw_if_set, filter::All())),
+ value_for<n::set_operator_mode>(sfsmo_natural),
+ value_for<n::tag>(std::tr1::shared_ptr<DepTag>()),
+ value_for<n::type>(sft_simple)
+ ));
world.remove(n);
world.rewrite();
@@ -166,14 +167,14 @@ World::world_set() const
{
if (_imp->maybe_world_file->exists())
{
- SetFile world(SetFileParams::create()
- .file_name(*_imp->maybe_world_file)
- .type(sft_simple)
- .parser(std::tr1::bind(&parse_user_package_dep_spec, _1, _imp->env, UserPackageDepSpecOptions() + updso_no_disambiguation + updso_throw_if_set,
- filter::All()))
- .tag(tag)
- .set_operator_mode(sfsmo_natural)
- .environment(_imp->env));
+ SetFile world(make_named_values<SetFileParams>(
+ value_for<n::environment>(_imp->env),
+ value_for<n::file_name>(*_imp->maybe_world_file),
+ value_for<n::parser>(std::tr1::bind(&parse_user_package_dep_spec, _1, _imp->env, UserPackageDepSpecOptions() + updso_no_disambiguation + updso_throw_if_set, filter::All())),
+ value_for<n::set_operator_mode>(sfsmo_natural),
+ value_for<n::tag>(tag),
+ value_for<n::type>(sft_simple)
+ ));
return world.contents();
}
else
diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc
index cf00be0..160fca1 100644
--- a/paludis/environments/portage/portage_environment.cc
+++ b/paludis/environments/portage/portage_environment.cc
@@ -37,6 +37,7 @@
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/config_file.hh>
#include <paludis/util/tribool.hh>
+#include <paludis/util/make_named_values.hh>
#include <paludis/hooker.hh>
#include <paludis/hook.hh>
#include <paludis/mask.hh>
@@ -889,13 +890,14 @@ PortageEnvironment::_add_string_to_world(const std::string & s) const
}
}
- SetFile world(SetFileParams::create()
- .file_name(_imp->world_file)
- .type(sft_simple)
- .parser(std::tr1::bind(&parse_user_package_dep_spec, _1, this, UserPackageDepSpecOptions() + updso_no_disambiguation, filter::All()))
- .tag(std::tr1::shared_ptr<DepTag>())
- .set_operator_mode(sfsmo_natural)
- .environment(this));
+ SetFile world(make_named_values<SetFileParams>(
+ value_for<n::environment>(this),
+ value_for<n::file_name>(_imp->world_file),
+ value_for<n::parser>(std::tr1::bind(&parse_user_package_dep_spec, _1, this, UserPackageDepSpecOptions() + updso_no_disambiguation, filter::All())),
+ value_for<n::set_operator_mode>(sfsmo_natural),
+ value_for<n::tag>(std::tr1::shared_ptr<DepTag>()),
+ value_for<n::type>(sft_simple)
+ ));
world.add(s);
world.rewrite();
}
@@ -911,14 +913,15 @@ PortageEnvironment::_remove_string_from_world(const std::string & s) const
if (_imp->world_file.exists())
{
- SetFile world(SetFileParams::create()
- .file_name(_imp->world_file)
- .type(sft_simple)
- .parser(std::tr1::bind(&parse_user_package_dep_spec, _1, this, UserPackageDepSpecOptions() + updso_no_disambiguation,
- filter::All()))
- .tag(std::tr1::shared_ptr<DepTag>())
- .set_operator_mode(sfsmo_natural)
- .environment(this));
+ SetFile world(make_named_values<SetFileParams>(
+ value_for<n::environment>(this),
+ value_for<n::file_name>(_imp->world_file),
+ value_for<n::parser>(std::tr1::bind(&parse_user_package_dep_spec, _1, this,
+ UserPackageDepSpecOptions() + updso_no_disambiguation, filter::All())),
+ value_for<n::set_operator_mode>(sfsmo_natural),
+ value_for<n::tag>(std::tr1::shared_ptr<DepTag>()),
+ value_for<n::type>(sft_simple)
+ ));
world.remove(s);
world.rewrite();
@@ -938,14 +941,15 @@ PortageEnvironment::world_set() const
if (_imp->world_file.exists())
{
- SetFile world(SetFileParams::create()
- .file_name(_imp->world_file)
- .type(sft_simple)
- .parser(std::tr1::bind(&parse_user_package_dep_spec, _1, this, UserPackageDepSpecOptions() + updso_no_disambiguation,
- filter::All()))
- .tag(tag)
- .set_operator_mode(sfsmo_natural)
- .environment(this));
+ SetFile world(make_named_values<SetFileParams>(
+ value_for<n::environment>(this),
+ value_for<n::file_name>(_imp->world_file),
+ value_for<n::parser>(std::tr1::bind(&parse_user_package_dep_spec, _1, this,
+ UserPackageDepSpecOptions() + updso_no_disambiguation, filter::All())),
+ value_for<n::set_operator_mode>(sfsmo_natural),
+ value_for<n::tag>(tag),
+ value_for<n::type>(sft_simple)
+ ));
return world.contents();
}
else
diff --git a/paludis/files.m4 b/paludis/files.m4
index b386449..a1fa408 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -68,7 +68,7 @@ add(`repository_factory', `hh', `fwd', `cc')
add(`repository_name_cache', `hh', `cc', `test', `testscript')
add(`selection', `hh', `cc', `fwd', `test')
add(`selection_handler', `hh', `cc', `fwd')
-add(`set_file', `hh', `cc', `se', `sr', `test', `testscript')
+add(`set_file', `hh', `cc', `se', `test', `testscript')
add(`show_suggest_visitor', `hh', `cc')
add(`slot_requirement', `hh', `fwd', `cc')
add(`stringify_formatter', `hh', `cc', `fwd', `impl', `test')
diff --git a/paludis/repositories/e/e_repository_sets.cc b/paludis/repositories/e/e_repository_sets.cc
index a22c434..898dbc9 100644
--- a/paludis/repositories/e/e_repository_sets.cc
+++ b/paludis/repositories/e/e_repository_sets.cc
@@ -115,14 +115,14 @@ ERepositorySets::package_set(const SetName & ss) const
FSEntry ff(_imp->params.setsdir() / (stringify(s.first) + ".conf"));
Context context("When loading package set '" + stringify(s.first) + "' from '" + stringify(ff) + "':");
- SetFile f(SetFileParams::create()
- .file_name(ff)
- .environment(_imp->environment)
- .type(sft_paludis_conf)
- .parser(std::tr1::bind(&parse_user_package_dep_spec, _1,
- _imp->environment, UserPackageDepSpecOptions() + updso_no_disambiguation + updso_throw_if_set, filter::All()))
- .set_operator_mode(s.second)
- .tag(tag));
+ SetFile f(make_named_values<SetFileParams>(
+ value_for<n::environment>(_imp->environment),
+ value_for<n::file_name>(ff),
+ value_for<n::parser>(std::tr1::bind(&parse_user_package_dep_spec, _1, _imp->environment, UserPackageDepSpecOptions() + updso_no_disambiguation + updso_throw_if_set, filter::All())),
+ value_for<n::set_operator_mode>(s.second),
+ value_for<n::tag>(tag),
+ value_for<n::type>(sft_paludis_conf)
+ ));
return f.contents();
}
diff --git a/paludis/set_file.cc b/paludis/set_file.cc
index c8da529..293fa5c 100644
--- a/paludis/set_file.cc
+++ b/paludis/set_file.cc
@@ -42,7 +42,6 @@
using namespace paludis;
#include <paludis/set_file-se.cc>
-#include <paludis/set_file-sr.cc>
SetFileError::SetFileError(const FSEntry & f, const std::string & m) throw () :
ConfigurationError("In set file '" + stringify(f) + "': " + m)
@@ -126,9 +125,9 @@ namespace
std::tr1::shared_ptr<SetFileHandler>
make_handler(const SetFileParams & p)
{
- Context context("When making SetFileHandler for '" + stringify(p.file_name) + "':");
+ Context context("When making SetFileHandler for '" + stringify(p.file_name()) + "':");
- switch (p.type)
+ switch (p.type())
{
case sft_simple:
return std::tr1::shared_ptr<SetFileHandler>(new SimpleHandler(p));
@@ -191,13 +190,13 @@ namespace
tokens.insert(tokens.begin(), "*");
}
- if ("*" == tokens.at(0) || ((sfsmo_star == params.set_operator_mode) &&
+ if ("*" == tokens.at(0) || ((sfsmo_star == params.set_operator_mode()) &&
("?" == tokens.at(0) || "?:" == tokens.at(0))))
{
if (std::string::npos == tokens.at(1).find('/'))
{
std::tr1::shared_ptr<NamedSetDepSpec> spec;
- switch (params.set_operator_mode)
+ switch (params.set_operator_mode())
{
case sfsmo_natural:
spec.reset(new NamedSetDepSpec(SetName(tokens.at(1))));
@@ -221,9 +220,9 @@ namespace
}
else
{
- std::tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(params.parser(tokens.at(1))));
- if (params.tag)
- spec->set_tag(params.tag);
+ std::tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(params.parser()(tokens.at(1))));
+ if (params.tag())
+ spec->set_tag(params.tag());
result->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(
new TreeLeaf<SetSpecTree, PackageDepSpec>(spec)));
}
@@ -237,18 +236,18 @@ namespace
return;
}
- std::tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(params.parser(tokens.at(1))));
- if (params.tag)
- spec->set_tag(params.tag);
+ std::tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(params.parser()(tokens.at(1))));
+ if (params.tag())
+ spec->set_tag(params.tag());
if (spec->package_ptr())
{
- if (! params.environment)
+ if (! params.environment())
Log::get_instance()->message("set_file.bad_operator", ll_warning, lc_context)
<< "Line '" << line << "' uses ? operator but no environment is available";
- else if (! (*params.environment)[selection::SomeArbitraryVersion(
+ else if (! (*params.environment())[selection::SomeArbitraryVersion(
generator::Package(*spec->package_ptr()) |
- filter::InstalledAtRoot(params.environment->root()))]->empty())
+ filter::InstalledAtRoot(params.environment()->root()))]->empty())
result->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(
new TreeLeaf<SetSpecTree, PackageDepSpec>(spec)));
}
@@ -265,21 +264,21 @@ namespace
return;
}
- std::tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(params.parser(tokens.at(1))));
- if (params.tag)
- spec->set_tag(params.tag);
+ std::tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(params.parser()(tokens.at(1))));
+ if (params.tag())
+ spec->set_tag(params.tag());
if (spec->package_ptr())
{
- if (! params.environment)
+ if (! params.environment())
Log::get_instance()->message("set_file.bad_operator", ll_warning, lc_context)
<< "Line '" << line << "' uses ?: operator but no environment is available";
- else if (! (*params.environment)[selection::SomeArbitraryVersion(generator::Matches(
+ else if (! (*params.environment())[selection::SomeArbitraryVersion(generator::Matches(
make_package_dep_spec()
.package(*spec->package_ptr())
.slot_requirement(spec->slot_requirement_ptr()),
MatchPackageOptions()) |
- filter::InstalledAtRoot(params.environment->root()))]->empty())
+ filter::InstalledAtRoot(params.environment()->root()))]->empty())
result->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(
new TreeLeaf<SetSpecTree, PackageDepSpec>(spec)));
}
@@ -314,9 +313,9 @@ SetFileHandler::~SetFileHandler()
SimpleHandler::SimpleHandler(const SetFileParams & p) :
_p(p)
{
- Context context("When loading simple set file '" + stringify(_p.file_name) + "':");
+ Context context("When loading simple set file '" + stringify(_p.file_name()) + "':");
- LineConfigFile ff(_p.file_name, LineConfigFileOptions() + lcfo_disallow_continuations + lcfo_disallow_comments
+ LineConfigFile ff(_p.file_name(), LineConfigFileOptions() + lcfo_disallow_continuations + lcfo_disallow_comments
+ lcfo_no_skip_blank_lines);
for (LineConfigFile::ConstIterator line(ff.begin()), line_end(ff.end()) ;
line != line_end ; ++line)
@@ -326,7 +325,7 @@ SimpleHandler::SimpleHandler(const SetFileParams & p) :
void
SimpleHandler::_create_contents() const
{
- Context context("When parsing atoms in simple set file '" + stringify(_p.file_name) + "':");
+ Context context("When parsing atoms in simple set file '" + stringify(_p.file_name()) + "':");
_contents.reset(new ConstTreeSequence<SetSpecTree, AllDepSpec>(std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
for (std::list<std::string>::const_iterator i(_lines.begin()), i_end(_lines.end()) ;
@@ -350,9 +349,9 @@ SimpleHandler::_create_contents() const
}
else
{
- std::tr1::shared_ptr<PackageDepSpec> p(new PackageDepSpec(_p.parser(stringify(*i))));
- if (_p.tag)
- p->set_tag(_p.tag);
+ std::tr1::shared_ptr<PackageDepSpec> p(new PackageDepSpec(_p.parser()(stringify(*i))));
+ if (_p.tag())
+ p->set_tag(_p.tag());
_contents->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(
new TreeLeaf<SetSpecTree, PackageDepSpec>(p)));
}
@@ -396,7 +395,7 @@ SimpleHandler::remove(const std::string & p)
{
Lock l(_mutex);
- Context context("When removing '" + stringify(p) + "' from simple set file '" + stringify(_p.file_name) + "':");
+ Context context("When removing '" + stringify(p) + "' from simple set file '" + stringify(_p.file_name()) + "':");
_contents.reset();
_lines.remove(p);
@@ -407,11 +406,11 @@ SimpleHandler::rewrite() const
{
Lock l(_mutex);
- Context context("When rewriting simple set file '" + stringify(_p.file_name) + "':");
+ Context context("When rewriting simple set file '" + stringify(_p.file_name()) + "':");
- std::ofstream f(stringify(_p.file_name).c_str());
+ std::ofstream f(stringify(_p.file_name()).c_str());
if (! f)
- throw SetFileError(_p.file_name, "Cannot write to '" + stringify(_p.file_name) + "'");
+ throw SetFileError(_p.file_name(), "Cannot write to '" + stringify(_p.file_name()) + "'");
for (std::list<std::string>::const_iterator i(_lines.begin()), i_end(_lines.end()) ;
i != i_end ; ++i)
@@ -421,9 +420,9 @@ SimpleHandler::rewrite() const
PaludisConfHandler::PaludisConfHandler(const SetFileParams & p) :
_p(p)
{
- Context context("When loading paludis conf set file '" + stringify(_p.file_name) + "':");
+ Context context("When loading paludis conf set file '" + stringify(_p.file_name()) + "':");
- LineConfigFile ff(_p.file_name, LineConfigFileOptions() + lcfo_disallow_continuations + lcfo_disallow_comments
+ LineConfigFile ff(_p.file_name(), LineConfigFileOptions() + lcfo_disallow_continuations + lcfo_disallow_comments
+ lcfo_no_skip_blank_lines);
for (LineConfigFile::ConstIterator line(ff.begin()), line_end(ff.end()) ;
line != line_end ; ++line)
@@ -433,7 +432,7 @@ PaludisConfHandler::PaludisConfHandler(const SetFileParams & p) :
void
PaludisConfHandler::_create_contents() const
{
- Context context("When parsing atoms in paludis conf set file '" + stringify(_p.file_name) + "':");
+ Context context("When parsing atoms in paludis conf set file '" + stringify(_p.file_name()) + "':");
_contents.reset(new ConstTreeSequence<SetSpecTree, AllDepSpec>(std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
for (std::list<std::string>::const_iterator i(_lines.begin()), i_end(_lines.end()) ;
@@ -466,7 +465,7 @@ PaludisConfHandler::add(const std::string & p)
void
PaludisConfHandler::remove(const std::string & p)
{
- Context context("When removing '" + stringify(p) + "' from paludis conf set file '" + stringify(_p.file_name) + "':");
+ Context context("When removing '" + stringify(p) + "' from paludis conf set file '" + stringify(_p.file_name()) + "':");
Lock l(_mutex);
@@ -477,13 +476,13 @@ PaludisConfHandler::remove(const std::string & p)
void
PaludisConfHandler::rewrite() const
{
- Context context("When rewriting paludis conf set file '" + stringify(_p.file_name) + "':");
+ Context context("When rewriting paludis conf set file '" + stringify(_p.file_name()) + "':");
Lock l(_mutex);
- std::ofstream f(stringify(_p.file_name).c_str());
+ std::ofstream f(stringify(_p.file_name()).c_str());
if (! f)
- throw SetFileError(_p.file_name, "Cannot write to '" + stringify(_p.file_name) + "'");
+ throw SetFileError(_p.file_name(), "Cannot write to '" + stringify(_p.file_name()) + "'");
for (std::list<std::string>::const_iterator i(_lines.begin()), i_end(_lines.end()) ;
i != i_end ; ++i)
@@ -493,17 +492,17 @@ PaludisConfHandler::rewrite() const
PaludisBashHandler::PaludisBashHandler(const SetFileParams & p) :
_p(p)
{
- Context context("When loading paludis bash set file '" + stringify(_p.file_name) + "':");
+ Context context("When loading paludis bash set file '" + stringify(_p.file_name()) + "':");
_contents.reset(new ConstTreeSequence<SetSpecTree, AllDepSpec>(std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
std::stringstream s;
- Command cmd(Command("bash '" + stringify(_p.file_name) + "'")
- .with_setenv("ROOT", _p.environment ? stringify(_p.environment->root()) : "/")
- .with_setenv("SET", stringify(_p.file_name))
+ Command cmd(Command("bash '" + stringify(_p.file_name()) + "'")
+ .with_setenv("ROOT", _p.environment() ? stringify(_p.environment()->root()) : "/")
+ .with_setenv("SET", stringify(_p.file_name()))
.with_setenv("SET_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
.with_setenv("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis"))
- .with_setenv("PALUDIS_COMMAND", _p.environment ? _p.environment->paludis_command() : "")
- .with_stderr_prefix(_p.file_name.basename() + "> ")
+ .with_setenv("PALUDIS_COMMAND", _p.environment() ? _p.environment()->paludis_command() : "")
+ .with_stderr_prefix(_p.file_name().basename() + "> ")
.with_captured_stdout_stream(&s));
int exit_status(run_command(cmd));
@@ -516,7 +515,7 @@ PaludisBashHandler::PaludisBashHandler(const SetFileParams & p) :
if (exit_status != 0)
{
Log::get_instance()->message("set_file.script.failure", ll_warning, lc_context)
- << "Set file script '" << _p.file_name << "' returned non-zero exit status '"
+ << "Set file script '" << _p.file_name() << "' returned non-zero exit status '"
<< exit_status << "'";
_contents.reset(new ConstTreeSequence<SetSpecTree, AllDepSpec>(std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
}
@@ -531,19 +530,19 @@ PaludisBashHandler::contents() const
void
PaludisBashHandler::add(const std::string & p)
{
- throw SetFileError(_p.file_name, "Cannot add entry '" + p + "' to bash script '" + stringify(_p.file_name) + "'");
+ throw SetFileError(_p.file_name(), "Cannot add entry '" + p + "' to bash script '" + stringify(_p.file_name()) + "'");
}
void
PaludisBashHandler::remove(const std::string & p)
{
- throw SetFileError(_p.file_name, "Cannot remove entry '" + p + "' from bash script '" + stringify(_p.file_name) + "'");
+ throw SetFileError(_p.file_name(), "Cannot remove entry '" + p + "' from bash script '" + stringify(_p.file_name()) + "'");
}
void
PaludisBashHandler::rewrite() const
{
- throw SetFileError(_p.file_name, "Cannot modify bash script '" + stringify(_p.file_name) + "'");
+ throw SetFileError(_p.file_name(), "Cannot modify bash script '" + stringify(_p.file_name()) + "'");
}
namespace paludis
diff --git a/paludis/set_file.hh b/paludis/set_file.hh
index 0d87423..42cfc3f 100644
--- a/paludis/set_file.hh
+++ b/paludis/set_file.hh
@@ -25,6 +25,7 @@
#include <paludis/util/exception.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/options.hh>
+#include <paludis/util/named_value.hh>
#include <paludis/name.hh>
#include <paludis/dep_tree.hh>
#include <paludis/dep_spec-fwd.hh>
@@ -49,7 +50,32 @@ namespace paludis
class Environment;
#include <paludis/set_file-se.hh>
-#include <paludis/set_file-sr.hh>
+
+ namespace n
+ {
+ struct environment;
+ struct file_name;
+ struct parser;
+ struct set_operator_mode;
+ struct tag;
+ struct type;
+ }
+
+ /**
+ * Parameters for a SetFile.
+ *
+ * \ingroup g_environment
+ * \ingroup g_repository
+ */
+ struct SetFileParams
+ {
+ NamedValue<n::environment, const Environment *> environment;
+ NamedValue<n::file_name, FSEntry> file_name;
+ NamedValue<n::parser, std::tr1::function<PackageDepSpec (const std::string &)> > parser;
+ NamedValue<n::set_operator_mode, SetFileSetOperatorMode> set_operator_mode;
+ NamedValue<n::tag, std::tr1::shared_ptr<const DepTag> > tag;
+ NamedValue<n::type, SetFileType> type;
+ };
/**
* Thrown if there is a problem reading or writing a SetFile.
diff --git a/paludis/set_file.sr b/paludis/set_file.sr
deleted file mode 100644
index 0f5097f..0000000
--- a/paludis/set_file.sr
+++ /dev/null
@@ -1,25 +0,0 @@
-make_class_SetFileParams()
-{
- visible
-
- key file_name FSEntry
- key type SetFileType
- key parser "std::tr1::function<PackageDepSpec (const std::string &)>"
- key tag "std::tr1::shared_ptr<const DepTag>"
- key environment "const Environment *"
- key set_operator_mode SetFileSetOperatorMode
-
- allow_named_args
-
- doxygen_comment << "END"
- /**
- * Parameters for a SetFile.
- *
- * \see SetFile
- * \ingroup g_repository
- * \ingroup g_environment
- * \nosubgrouping
- */
-END
-}
-
diff --git a/paludis/set_file_TEST.cc b/paludis/set_file_TEST.cc
index 781c337..71848b9 100644
--- a/paludis/set_file_TEST.cc
+++ b/paludis/set_file_TEST.cc
@@ -22,6 +22,7 @@
#include <test/test_framework.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/make_named_values.hh>
#include <paludis/dep_spec.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/environments/test/test_environment.hh>
@@ -73,14 +74,14 @@ namespace test_cases
TestEnvironment env;
- SetFile f(SetFileParams::create()
- .file_name(FSEntry("set_file_TEST_dir/simple1"))
- .type(sft_simple)
- .parser(std::tr1::bind(&parse_user_package_dep_spec, _1, &env, UserPackageDepSpecOptions(),
- filter::All()))
- .tag(std::tr1::shared_ptr<DepTag>())
- .set_operator_mode(sfsmo_natural)
- .environment(0));
+ SetFile f(make_named_values<SetFileParams>(
+ value_for<n::environment>(static_cast<Environment *>(0)),
+ value_for<n::file_name>(FSEntry("set_file_TEST_dir/simple1")),
+ value_for<n::parser>(std::tr1::bind(&parse_user_package_dep_spec, _1, &env, UserPackageDepSpecOptions(), filter::All())),
+ value_for<n::set_operator_mode>(sfsmo_natural),
+ value_for<n::tag>(std::tr1::shared_ptr<DepTag>()),
+ value_for<n::type>(sft_simple)
+ ));
{
SetSpecStringifier p;
@@ -140,14 +141,14 @@ namespace test_cases
TestEnvironment env;
- SetFile f(SetFileParams::create()
- .file_name(FSEntry("set_file_TEST_dir/paludisconf1"))
- .type(sft_paludis_conf)
- .parser(std::tr1::bind(&parse_user_package_dep_spec, _1, &env, UserPackageDepSpecOptions(),
- filter::All()))
- .tag(std::tr1::shared_ptr<DepTag>())
- .set_operator_mode(sfsmo_natural)
- .environment(0));
+ SetFile f(make_named_values<SetFileParams>(
+ value_for<n::environment>(static_cast<Environment *>(0)),
+ value_for<n::file_name>(FSEntry("set_file_TEST_dir/paludisconf1")),
+ value_for<n::parser>(std::tr1::bind(&parse_user_package_dep_spec, _1, &env, UserPackageDepSpecOptions(), filter::All())),
+ value_for<n::set_operator_mode>(sfsmo_natural),
+ value_for<n::tag>(std::tr1::shared_ptr<DepTag>()),
+ value_for<n::type>(sft_paludis_conf)
+ ));
{
SetSpecStringifier p;
@@ -210,14 +211,14 @@ namespace test_cases
TestEnvironment env;
- SetFile f(SetFileParams::create()
- .file_name(FSEntry("set_file_TEST_dir/override"))
- .type(sft_paludis_conf)
- .parser(std::tr1::bind(&parse_user_package_dep_spec, _1, &env, UserPackageDepSpecOptions(),
- filter::All()))
- .tag(std::tr1::shared_ptr<DepTag>())
- .set_operator_mode(sfsmo_natural)
- .environment(0));
+ SetFile f(make_named_values<SetFileParams>(
+ value_for<n::environment>(static_cast<Environment *>(0)),
+ value_for<n::file_name>(FSEntry("set_file_TEST_dir/override")),
+ value_for<n::parser>(std::tr1::bind(&parse_user_package_dep_spec, _1, &env, UserPackageDepSpecOptions(), filter::All())),
+ value_for<n::set_operator_mode>(sfsmo_natural),
+ value_for<n::tag>(std::tr1::shared_ptr<DepTag>()),
+ value_for<n::type>(sft_paludis_conf)
+ ));
{
SetSpecStringifier p;
@@ -225,14 +226,14 @@ namespace test_cases
TEST_CHECK_STRINGIFY_EQUAL(p.s.str(), "( >=bar/bar-1.23 set set2* ) ");
}
- SetFile fstar(SetFileParams::create()
- .file_name(FSEntry("set_file_TEST_dir/override"))
- .type(sft_paludis_conf)
- .parser(std::tr1::bind(&parse_user_package_dep_spec, _1, &env, UserPackageDepSpecOptions(),
- filter::All()))
- .tag(std::tr1::shared_ptr<DepTag>())
- .set_operator_mode(sfsmo_star)
- .environment(0));
+ SetFile fstar(make_named_values<SetFileParams>(
+ value_for<n::environment>(static_cast<Environment *>(0)),
+ value_for<n::file_name>(FSEntry("set_file_TEST_dir/override")),
+ value_for<n::parser>(std::tr1::bind(&parse_user_package_dep_spec, _1, &env, UserPackageDepSpecOptions(), filter::All())),
+ value_for<n::set_operator_mode>(sfsmo_star),
+ value_for<n::tag>(std::tr1::shared_ptr<DepTag>()),
+ value_for<n::type>(sft_paludis_conf)
+ ));
{
SetSpecStringifier p;