aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-02-15 11:36:47 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-02-15 11:36:47 +0000
commit7e125b4740d8bb50aa06b97d1dc070dfbce8bb3a (patch)
treea690976211d4e380d4ffbccfdf5ae53d7b0f1e38
parentae7109237069623709637fd16b0230dddcccda8d (diff)
downloadpaludis-7e125b4740d8bb50aa06b97d1dc070dfbce8bb3a.tar.gz
paludis-7e125b4740d8bb50aa06b97d1dc070dfbce8bb3a.tar.xz
Start removing the global concept of use flags: rename UseDepSpec to ConditionalDepSpec, move the descent logic into the spec.
-rw-r--r--doc/api/cplusplus/examples/example_dep_label.cc9
-rw-r--r--doc/api/cplusplus/examples/example_dep_spec_flattener.cc6
-rw-r--r--doc/api/cplusplus/examples/example_dep_tree.cc11
-rw-r--r--doc/api/cplusplus/examples/example_formatter.cc12
-rw-r--r--paludis/condition_tracker.cc4
-rw-r--r--paludis/condition_tracker.hh4
-rw-r--r--paludis/dep_list-fwd.hh5
-rw-r--r--paludis/dep_list.cc39
-rw-r--r--paludis/dep_spec-fwd.hh9
-rw-r--r--paludis/dep_spec.cc121
-rw-r--r--paludis/dep_spec.hh92
-rw-r--r--paludis/dep_spec_TEST.cc8
-rw-r--r--paludis/dep_spec_flattener.cc29
-rw-r--r--paludis/dep_spec_flattener.hh37
-rw-r--r--paludis/dep_tag.cc4
-rw-r--r--paludis/dep_tree.cc16
-rw-r--r--paludis/dep_tree.hh30
-rw-r--r--paludis/formatter.hh6
-rw-r--r--paludis/install_task.cc8
-rw-r--r--paludis/match_package.cc4
-rw-r--r--paludis/query_visitor.cc8
-rw-r--r--paludis/query_visitor.hh4
-rw-r--r--paludis/range_rewriter.cc4
-rw-r--r--paludis/range_rewriter.hh4
-rw-r--r--paludis/repositories/cran/dep_spec_pretty_printer.hh4
-rw-r--r--paludis/repositories/e/Makefile.am6
-rw-r--r--paludis/repositories/e/aa_visitor.hh2
-rw-r--r--paludis/repositories/e/aa_visitor_TEST.cc11
-rw-r--r--paludis/repositories/e/check_fetched_files_visitor.cc4
-rw-r--r--paludis/repositories/e/check_fetched_files_visitor.hh4
-rw-r--r--paludis/repositories/e/conditional_dep_spec.cc138
-rw-r--r--paludis/repositories/e/conditional_dep_spec.hh41
-rw-r--r--paludis/repositories/e/dep_parser.cc68
-rw-r--r--paludis/repositories/e/dep_parser.hh21
-rw-r--r--paludis/repositories/e/dep_parser_TEST.cc175
-rw-r--r--paludis/repositories/e/dep_spec_pretty_printer.cc15
-rw-r--r--paludis/repositories/e/dep_spec_pretty_printer.hh4
-rw-r--r--paludis/repositories/e/dep_spec_pretty_printer_TEST.cc42
-rw-r--r--paludis/repositories/e/dependencies_rewriter.cc2
-rw-r--r--paludis/repositories/e/dependencies_rewriter.hh2
-rw-r--r--paludis/repositories/e/distfiles_size_visitor.cc4
-rw-r--r--paludis/repositories/e/distfiles_size_visitor.hh2
-rw-r--r--paludis/repositories/e/e_installed_repository_id.cc2
-rw-r--r--paludis/repositories/e/e_key.cc16
-rw-r--r--paludis/repositories/e/ebuild.cc2
-rw-r--r--paludis/repositories/e/ebuild_entries.cc8
-rw-r--r--paludis/repositories/e/ebuild_flat_metadata_cache.cc5
-rw-r--r--paludis/repositories/e/ebuild_flat_metadata_cache.hh5
-rw-r--r--paludis/repositories/e/ebuild_id.cc11
-rw-r--r--paludis/repositories/e/fetch_visitor.cc6
-rw-r--r--paludis/repositories/e/fetch_visitor.hh4
-rw-r--r--paludis/repositories/e/fetch_visitor_TEST.cc7
-rw-r--r--paludis/repositories/e/qa/extractors.cc14
-rw-r--r--paludis/repositories/e/qa/fetches_key.cc4
-rw-r--r--paludis/repositories/e/qa/homepage_key.cc6
-rw-r--r--paludis/repositories/e/qa/license_key.cc6
-rw-r--r--paludis/repositories/e/qa/manifest.cc4
-rw-r--r--paludis/repositories/e/qa/restrict_key.cc6
-rw-r--r--paludis/repositories/e/qa/spec_keys.cc25
-rw-r--r--paludis/repositories/e/qa/visibility.cc12
-rw-r--r--paludis/repositories/e/vdb_repository.cc8
-rw-r--r--paludis/repositories/fake/fake_installed_repository.cc4
-rw-r--r--paludis/repositories/fake/fake_package_id.cc72
-rw-r--r--paludis/repositories/unpackaged/dep_printer.hh6
-rw-r--r--paludis/show_suggest_visitor.cc6
-rw-r--r--paludis/show_suggest_visitor.hh5
-rw-r--r--paludis/stringify_formatter-impl.hh8
-rw-r--r--paludis/stringify_formatter.cc12
-rw-r--r--paludis/stringify_formatter.hh14
-rw-r--r--paludis/stringify_formatter_TEST.cc10
-rw-r--r--paludis/uninstall_list.cc6
-rw-r--r--python/dep_spec.cc98
-rw-r--r--python/dep_spec.hh31
-rw-r--r--python/formatter.cc36
-rw-r--r--python/nice_names.nn4
-rw-r--r--ruby/dep_spec.cc61
-rw-r--r--ruby/nice_names.nn2
-rw-r--r--src/clients/adjutrix/find_reverse_deps.cc6
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/markup_formatter.cc10
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/markup_formatter.hh12
-rw-r--r--src/clients/inquisitio/key_extractor.cc6
-rw-r--r--src/output/colour_formatter.cc12
-rw-r--r--src/output/colour_formatter.hh14
-rw-r--r--src/output/console_query_task.cc6
84 files changed, 980 insertions, 631 deletions
diff --git a/doc/api/cplusplus/examples/example_dep_label.cc b/doc/api/cplusplus/examples/example_dep_label.cc
index 7429e77..3627bfc 100644
--- a/doc/api/cplusplus/examples/example_dep_label.cc
+++ b/doc/api/cplusplus/examples/example_dep_label.cc
@@ -86,7 +86,7 @@ namespace
/* This visitor class collects src_uri entries and stores the result in
* a provided map. Label statuses are handled by a stack. When we enter
- * a block (an AllDepSpec or a UseDepSpec), we duplicate the top item
+ * a block (an AllDepSpec or a ConditionalDepSpec), we duplicate the top item
* of the stack, since labels recurse into subblocks. When we encounter
* a label, we replace the top item of the stack. */
class DistfilesCollector :
@@ -115,13 +115,12 @@ namespace
_restricted.pop_back();
}
- void visit_sequence(const UseDepSpec &,
+ void visit_sequence(const ConditionalDepSpec &,
FetchableURISpecTree::ConstSequenceIterator cur,
FetchableURISpecTree::ConstSequenceIterator end)
{
- /* Always recurse over a UseDepSpec's children. In real world
- * code, we would more likely check whether the use flag is
- * accepted. */
+ /* Always recurse over a ConditionalDepSpec's children. In real world
+ * code, we would more likely check whether condition is met. */
_restricted.push_back(_restricted.back());
std::for_each(cur, end, accept_visitor(*this));
_restricted.pop_back();
diff --git a/doc/api/cplusplus/examples/example_dep_spec_flattener.cc b/doc/api/cplusplus/examples/example_dep_spec_flattener.cc
index 1974bce..2b4d3bb 100644
--- a/doc/api/cplusplus/examples/example_dep_spec_flattener.cc
+++ b/doc/api/cplusplus/examples/example_dep_spec_flattener.cc
@@ -58,7 +58,7 @@ int main(int argc, char * argv[])
if ((*i)->provide_key())
{
/* Create our flattener... */
- DepSpecFlattener<ProvideSpecTree, PackageDepSpec> provides(env.get(), **i);
+ DepSpecFlattener<ProvideSpecTree, PackageDepSpec> provides(env.get());
/* Populate it by making it visit the key's value */
(*i)->provide_key()->value()->accept(provides);
@@ -74,7 +74,7 @@ int main(int argc, char * argv[])
/* Again for homepage */
if ((*i)->homepage_key())
{
- DepSpecFlattener<SimpleURISpecTree, SimpleURIDepSpec> homepages(env.get(), **i);
+ DepSpecFlattener<SimpleURISpecTree, SimpleURIDepSpec> homepages(env.get());
(*i)->homepage_key()->value()->accept(homepages);
cout << " " << left << setw(24) << "Homepages:" << " "
@@ -91,7 +91,7 @@ int main(int argc, char * argv[])
if ((*i)->end_metadata() != (*i)->find_metadata("RESTRICT") &&
visitor_cast<const MetadataSpecTreeKey<RestrictSpecTree> >(**(*i)->find_metadata("RESTRICT")))
{
- DepSpecFlattener<RestrictSpecTree, PlainTextDepSpec> restricts(env.get(), **i);
+ DepSpecFlattener<RestrictSpecTree, PlainTextDepSpec> restricts(env.get());
visitor_cast<const MetadataSpecTreeKey<RestrictSpecTree> >(
**(*i)->find_metadata("RESTRICT"))->value()->accept(restricts);
diff --git a/doc/api/cplusplus/examples/example_dep_tree.cc b/doc/api/cplusplus/examples/example_dep_tree.cc
index 12ea68e..26717c0 100644
--- a/doc/api/cplusplus/examples/example_dep_tree.cc
+++ b/doc/api/cplusplus/examples/example_dep_tree.cc
@@ -71,13 +71,13 @@ namespace
using ConstVisitor<DependencySpecTree>::VisitConstSequence<DependenciesCollector, AllDepSpec>::visit_sequence;
using ConstVisitor<DependencySpecTree>::VisitConstSequence<DependenciesCollector, AnyDepSpec>::visit_sequence;
- void visit_sequence(const UseDepSpec & u,
+ void visit_sequence(const ConditionalDepSpec & u,
DependencySpecTree::ConstSequenceIterator cur,
DependencySpecTree::ConstSequenceIterator end)
{
/* Was this use flag enabled (or, if we're inverse, disabled)
* when we built this package? */
- if (_env->query_use(u.flag(), *_id) ^ u.inverse())
+ if (u.condition_met())
std::for_each(cur, end, accept_visitor(*this));
}
@@ -155,13 +155,12 @@ namespace
using ConstVisitor<FetchableURISpecTree>::VisitConstSequence<FileExtensionsCollector, AllDepSpec>::visit_sequence;
- void visit_sequence(const UseDepSpec & u,
+ void visit_sequence(const ConditionalDepSpec & u,
FetchableURISpecTree::ConstSequenceIterator cur,
FetchableURISpecTree::ConstSequenceIterator end)
{
- /* Was this use flag enabled (or, if we're inverse, disabled)
- * when we built this package? */
- if (_env->query_use(u.flag(), *_id) ^ u.inverse())
+ /* Was the condition met when we built this package? */
+ if (u.condition_met())
std::for_each(cur, end, accept_visitor(*this));
}
diff --git a/doc/api/cplusplus/examples/example_formatter.cc b/doc/api/cplusplus/examples/example_formatter.cc
index bc6aafb..72f7e08 100644
--- a/doc/api/cplusplus/examples/example_formatter.cc
+++ b/doc/api/cplusplus/examples/example_formatter.cc
@@ -70,7 +70,7 @@ namespace
public CanSpace,
public CanFormat<PackageDepSpec>,
public CanFormat<DependencyLabelsDepSpec>,
- public CanFormat<UseDepSpec>,
+ public CanFormat<ConditionalDepSpec>,
public CanFormat<NamedSetDepSpec>,
public CanFormat<BlockDepSpec>
{
@@ -97,27 +97,27 @@ namespace
return span_colour(escape_html(stringify(s)), "#666666");
}
- std::string format(const UseDepSpec & s, const format::Plain &) const
+ std::string format(const ConditionalDepSpec & s, const format::Plain &) const
{
return span_colour(escape_html(stringify(s)), "#666666");
}
- std::string format(const UseDepSpec & s, const format::Enabled &) const
+ std::string format(const ConditionalDepSpec & s, const format::Enabled &) const
{
return span_colour(escape_html(stringify(s)), "#66ff66");
}
- std::string format(const UseDepSpec & s, const format::Disabled &) const
+ std::string format(const ConditionalDepSpec & s, const format::Disabled &) const
{
return span_colour(escape_html(stringify(s)), "#ff6666");
}
- std::string format(const UseDepSpec & s, const format::Forced &) const
+ std::string format(const ConditionalDepSpec & s, const format::Forced &) const
{
return span_colour(escape_html("(" + stringify(s) + ")"), "#66ff66");
}
- std::string format(const UseDepSpec & s, const format::Masked &) const
+ std::string format(const ConditionalDepSpec & s, const format::Masked &) const
{
return span_colour(escape_html("(" + stringify(s) + ")"), "#ff6666");
}
diff --git a/paludis/condition_tracker.cc b/paludis/condition_tracker.cc
index 8f2dbab..6d8dc1d 100644
--- a/paludis/condition_tracker.cc
+++ b/paludis/condition_tracker.cc
@@ -66,7 +66,7 @@ ConditionTracker::add_condition(const AnyDepSpec & any)
}
tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> >
-ConditionTracker::add_condition(const UseDepSpec & use)
+ConditionTracker::add_condition(const ConditionalDepSpec & use)
{
return do_add_sequence(use);
}
@@ -111,7 +111,7 @@ ConditionTracker::visit_sequence(const AnyDepSpec & node,
}
void
-ConditionTracker::visit_sequence(const UseDepSpec & node,
+ConditionTracker::visit_sequence(const ConditionalDepSpec & node,
DependencySpecTree::ConstSequenceIterator begin,
DependencySpecTree::ConstSequenceIterator end)
{
diff --git a/paludis/condition_tracker.hh b/paludis/condition_tracker.hh
index 0f7b6e5..6d7d98c 100644
--- a/paludis/condition_tracker.hh
+++ b/paludis/condition_tracker.hh
@@ -77,7 +77,7 @@ namespace paludis
///\{
tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > add_condition(const AnyDepSpec &);
- tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > add_condition(const UseDepSpec &);
+ tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > add_condition(const ConditionalDepSpec &);
tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > add_condition(const PackageDepSpec &);
tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > add_condition(const BlockDepSpec &);
@@ -89,7 +89,7 @@ namespace paludis
using ConstVisitor<DependencySpecTree>::VisitConstSequence<ConditionTracker, AllDepSpec>::visit_sequence;
void visit_sequence(const AnyDepSpec &, DependencySpecTree::ConstSequenceIterator, DependencySpecTree::ConstSequenceIterator);
- void visit_sequence(const UseDepSpec &, DependencySpecTree::ConstSequenceIterator, DependencySpecTree::ConstSequenceIterator);
+ void visit_sequence(const ConditionalDepSpec &, DependencySpecTree::ConstSequenceIterator, DependencySpecTree::ConstSequenceIterator);
void visit_leaf(const PackageDepSpec &) PALUDIS_ATTRIBUTE((noreturn));
void visit_leaf(const BlockDepSpec &) PALUDIS_ATTRIBUTE((noreturn));
diff --git a/paludis/dep_list-fwd.hh b/paludis/dep_list-fwd.hh
index 2d826ae..9c16b5f 100644
--- a/paludis/dep_list-fwd.hh
+++ b/paludis/dep_list-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -44,8 +44,7 @@ namespace paludis
*
* \ingroup g_dep_list
*/
- bool is_viable_any_child(const Environment & env, const tr1::shared_ptr<const PackageID> &,
- const DependencySpecTree::ConstItem & i);
+ bool is_viable_any_child(const DependencySpecTree::ConstItem & i);
}
#endif
diff --git a/paludis/dep_list.cc b/paludis/dep_list.cc
index d99acf6..5a00bb3 100644
--- a/paludis/dep_list.cc
+++ b/paludis/dep_list.cc
@@ -306,7 +306,7 @@ struct DepList::AddVisitor :
DependencySpecTree::ConstSequenceIterator,
DependencySpecTree::ConstSequenceIterator);
- void visit_sequence(const UseDepSpec &,
+ void visit_sequence(const ConditionalDepSpec &,
DependencySpecTree::ConstSequenceIterator,
DependencySpecTree::ConstSequenceIterator);
@@ -606,7 +606,7 @@ DepList::AddVisitor::visit_leaf(const NamedSetDepSpec & a)
}
void
-DepList::AddVisitor::visit_sequence(const UseDepSpec & a,
+DepList::AddVisitor::visit_sequence(const ConditionalDepSpec & a,
DependencySpecTree::ConstSequenceIterator cur,
DependencySpecTree::ConstSequenceIterator end)
{
@@ -615,24 +615,13 @@ DepList::AddVisitor::visit_sequence(const UseDepSpec & a,
if (d->_imp->opts->use == dl_use_deps_standard)
{
- if ((d->_imp->current_package_id() ? d->_imp->env->query_use(a.flag(), *d->_imp->current_package_id()) : false) ^ a.inverse())
+ if (a.condition_met())
std::for_each(cur, end, accept_visitor(*this));
}
else
{
- RepositoryUseInterface * u(0);
- if ((! d->_imp->current_package_id()) || (! ((u = d->_imp->current_package_id()->repository()->use_interface))))
+ if (a.condition_meetable())
std::for_each(cur, end, accept_visitor(*this));
- else if (a.inverse())
- {
- if ((! d->_imp->current_package_id()) || (! u->query_use_force(a.flag(), *d->_imp->current_package_id())))
- std::for_each(cur, end, accept_visitor(*this));
- }
- else
- {
- if ((! d->_imp->current_package_id()) || (! u->query_use_mask(a.flag(), *d->_imp->current_package_id())))
- std::for_each(cur, end, accept_visitor(*this));
- }
}
}
@@ -644,8 +633,7 @@ DepList::AddVisitor::visit_sequence(const AnyDepSpec & a,
using namespace tr1::placeholders;
/* annoying requirement: || ( foo? ( ... ) ) resolves to empty if !foo. */
- if (end == std::find_if(cur, end,
- tr1::bind(&is_viable_any_child, tr1::cref(*d->_imp->env), d->_imp->current_package_id(), _1)))
+ if (end == std::find_if(cur, end, &is_viable_any_child))
return;
{
@@ -667,7 +655,7 @@ DepList::AddVisitor::visit_sequence(const AnyDepSpec & a,
* any upgrades kick in */
for (DependencySpecTree::ConstSequenceIterator c(cur) ; c != end ; ++c)
{
- if (! is_viable_any_child(*d->_imp->env, d->_imp->current_package_id(), *c))
+ if (! is_viable_any_child(*c))
continue;
if (d->already_installed(*c, destinations))
@@ -682,7 +670,7 @@ DepList::AddVisitor::visit_sequence(const AnyDepSpec & a,
* the b-2 bit first */
for (DependencySpecTree::ConstSequenceIterator c(cur) ; c != end ; ++c)
{
- if (! is_viable_any_child(*d->_imp->env, d->_imp->current_package_id(), *c))
+ if (! is_viable_any_child(*c))
continue;
if (! is_interesting_any_child(*d->_imp->env, *c))
continue;
@@ -706,7 +694,7 @@ DepList::AddVisitor::visit_sequence(const AnyDepSpec & a,
/* install first available viable option */
for (DependencySpecTree::ConstSequenceIterator c(cur) ; c != end ; ++c)
{
- if (! is_viable_any_child(*d->_imp->env, d->_imp->current_package_id(), *c))
+ if (! is_viable_any_child(*c))
continue;
try
@@ -731,7 +719,7 @@ DepList::AddVisitor::visit_sequence(const AnyDepSpec & a,
Context block_context("Inside || ( ) block with other options:");
for (DependencySpecTree::ConstSequenceIterator c(cur) ; c != end ; ++c)
{
- if (! is_viable_any_child(*d->_imp->env, d->_imp->current_package_id(), *c))
+ if (! is_viable_any_child(*c))
continue;
d->add_not_top_level(*c, destinations, conditions);
@@ -1026,7 +1014,7 @@ DepList::add_package(const tr1::shared_ptr<const PackageID> & p, tr1::shared_ptr
/* add provides */
if (p->provide_key())
{
- DepSpecFlattener<ProvideSpecTree, PackageDepSpec> f(_imp->env, *_imp->current_package_id());
+ DepSpecFlattener<ProvideSpecTree, PackageDepSpec> f(_imp->env);
p->provide_key()->value()->accept(f);
if (f.begin() != f.end() && ! (*DistributionData::get_instance()->distribution_from_string(
@@ -1538,12 +1526,11 @@ DepList::match_on_list(const PackageDepSpec & a) const
}
bool
-paludis::is_viable_any_child(const Environment & env, const tr1::shared_ptr<const PackageID> & id,
- const DependencySpecTree::ConstItem & i)
+paludis::is_viable_any_child(const DependencySpecTree::ConstItem & i)
{
- const UseDepSpec * const u(get_const_item(i)->as_use_dep_spec());
+ const ConditionalDepSpec * const u(get_const_item(i)->as_conditional_dep_spec());
if (0 != u)
- return (id ? env.query_use(u->flag(), *id) : false) ^ u->inverse();
+ return u->condition_met();
else
return true;
}
diff --git a/paludis/dep_spec-fwd.hh b/paludis/dep_spec-fwd.hh
index de70dd3..b8f28ce 100644
--- a/paludis/dep_spec-fwd.hh
+++ b/paludis/dep_spec-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -45,7 +45,7 @@ namespace paludis
class SimpleURIDepSpec;
class AllDepSpec;
class AnyDepSpec;
- class UseDepSpec;
+ class ConditionalDepSpec;
class BlockDepSpec;
class StringDepSpec;
class NamedSetDepSpec;
@@ -69,6 +69,7 @@ namespace paludis
class PackageDepSpecData;
class PartiallyMadePackageDepSpec;
+ class ConditionalDepSpecData;
#include <paludis/dep_spec-se.hh>
@@ -164,12 +165,12 @@ namespace paludis
std::ostream & operator<< (std::ostream &, const LicenseDepSpec &) PALUDIS_VISIBLE;
/**
- * A UseDepSpec can be written to an ostream.
+ * A ConditionalDepSpec can be written to an ostream.
*
* \ingroup g_dep_spec
* \since 0.26
*/
- std::ostream & operator<< (std::ostream &, const UseDepSpec &) PALUDIS_VISIBLE;
+ std::ostream & operator<< (std::ostream &, const ConditionalDepSpec &) PALUDIS_VISIBLE;
/**
* A NamedSetDepSpec can be written to an ostream.
diff --git a/paludis/dep_spec.cc b/paludis/dep_spec.cc
index 7295077..187eb86 100644
--- a/paludis/dep_spec.cc
+++ b/paludis/dep_spec.cc
@@ -37,6 +37,7 @@
#include <paludis/util/tr1_functional.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/visitor-impl.hh>
+#include <algorithm>
#include <list>
#include <map>
@@ -52,8 +53,8 @@ DepSpec::~DepSpec()
{
}
-const UseDepSpec *
-DepSpec::as_use_dep_spec() const
+const ConditionalDepSpec *
+DepSpec::as_conditional_dep_spec() const
{
return 0;
}
@@ -84,34 +85,106 @@ AllDepSpec::clone() const
return tr1::shared_ptr<AllDepSpec>(new AllDepSpec());
}
-UseDepSpec::UseDepSpec(const UseFlagName & our_flag, bool is_inverse) :
- _flag(our_flag),
- _inverse(is_inverse)
+namespace paludis
{
+ template <>
+ struct Implementation<ConditionalDepSpec>
+ {
+ const tr1::shared_ptr<const ConditionalDepSpecData> data;
+ Mutex mutex;
+ bool added_keys;
+
+ Implementation(const tr1::shared_ptr<const ConditionalDepSpecData> & d) :
+ data(d),
+ added_keys(false)
+ {
+ }
+ };
}
-const UseDepSpec *
-UseDepSpec::as_use_dep_spec() const
+ConditionalDepSpec::ConditionalDepSpec(const tr1::shared_ptr<const ConditionalDepSpecData> & d) :
+ PrivateImplementationPattern<ConditionalDepSpec>(new Implementation<ConditionalDepSpec>(d)),
+ _imp(PrivateImplementationPattern<ConditionalDepSpec>::_imp)
{
- return this;
}
-UseFlagName
-UseDepSpec::flag() const
+namespace
+{
+ template <void (ConditionalDepSpec::* f_) () const>
+ const ConditionalDepSpec & horrible_hack_to_force_key_copy(const ConditionalDepSpec & spec)
+ {
+ (spec.*f_)();
+ return spec;
+ }
+}
+
+ConditionalDepSpec::ConditionalDepSpec(const ConditionalDepSpec & other) :
+ Cloneable<DepSpec>(),
+ DepSpec(),
+ PrivateImplementationPattern<ConditionalDepSpec>(new Implementation<ConditionalDepSpec>(other._imp->data)),
+ MetadataKeyHolder(),
+ CloneUsingThis<DepSpec, ConditionalDepSpec>(other),
+ _imp(PrivateImplementationPattern<ConditionalDepSpec>::_imp)
+{
+}
+
+ConditionalDepSpec::~ConditionalDepSpec()
+{
+}
+
+void
+ConditionalDepSpec::need_keys_added() const
+{
+ Lock l(_imp->mutex);
+ if (! _imp->added_keys)
+ {
+ _imp->added_keys = true;
+ using namespace tr1::placeholders;
+ std::for_each(_imp->data->begin_metadata(), _imp->data->end_metadata(),
+ tr1::bind(&ConditionalDepSpec::add_metadata_key, this, _1));
+ }
+}
+
+void
+ConditionalDepSpec::clear_metadata_keys() const
{
- return _flag;
+ Lock l(_imp->mutex);
+ _imp->added_keys = false;
+ MetadataKeyHolder::clear_metadata_keys();
}
bool
-UseDepSpec::inverse() const
+ConditionalDepSpec::condition_met() const
{
- return _inverse;
+ return _imp->data->condition_met();
}
-tr1::shared_ptr<DepSpec>
-UseDepSpec::clone() const
+bool
+ConditionalDepSpec::condition_meetable() const
+{
+ return _imp->data->condition_meetable();
+}
+
+const tr1::shared_ptr<const ConditionalDepSpecData>
+ConditionalDepSpec::data() const
+{
+ return _imp->data;
+}
+
+const ConditionalDepSpec *
+ConditionalDepSpec::as_conditional_dep_spec() const
+{
+ return this;
+}
+
+std::string
+ConditionalDepSpec::_as_string() const
+{
+ return _imp->data->as_string();
+}
+
+ConditionalDepSpecData::~ConditionalDepSpecData()
{
- return tr1::shared_ptr<UseDepSpec>(new UseDepSpec(_flag, _inverse));
}
std::string
@@ -179,15 +252,6 @@ paludis::operator<< (std::ostream & s, const BlockDepSpec & a)
}
std::ostream &
-paludis::operator<< (std::ostream & s, const UseDepSpec & a)
-{
- if (a.inverse())
- s << "!";
- s << a.flag() << "?";
- return s;
-}
-
-std::ostream &
paludis::operator<< (std::ostream & s, const FetchableURIDepSpec & p)
{
if (! p.renamed_url_suffix().empty())
@@ -213,6 +277,13 @@ paludis::operator<< (std::ostream & s, const PackageDepSpec & a)
}
std::ostream &
+paludis::operator<< (std::ostream & s, const ConditionalDepSpec & a)
+{
+ s << a._as_string();
+ return s;
+}
+
+std::ostream &
paludis::operator<< (std::ostream & s, const URILabelsDepSpec & l)
{
s << join(indirect_iterator(l.begin()), indirect_iterator(l.end()), "+") << ":";
diff --git a/paludis/dep_spec.hh b/paludis/dep_spec.hh
index 3834951..c02bc59 100644
--- a/paludis/dep_spec.hh
+++ b/paludis/dep_spec.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -31,6 +31,7 @@
#include <paludis/dep_spec-fwd.hh>
#include <paludis/dep_tag-fwd.hh>
#include <paludis/name.hh>
+#include <paludis/metadata_key_holder.hh>
#include <paludis/version_operator-fwd.hh>
#include <paludis/version_requirements-fwd.hh>
#include <paludis/version_spec-fwd.hh>
@@ -76,15 +77,15 @@ namespace paludis
///\{
/**
- * Return us as a UseDepSpec, or 0 if we are not a
- * UseDepSpec.
+ * Return us as a ConditionalDepSpec, or 0 if we are not a
+ * ConditionalDepSpec.
*/
- virtual const UseDepSpec * as_use_dep_spec() const
+ virtual const ConditionalDepSpec * as_conditional_dep_spec() const
PALUDIS_ATTRIBUTE((warn_unused_result));
/**
* Return us as a PackageDepSpec, or 0 if we are not a
- * UseDepSpec.
+ * ConditionalDepSpec.
*/
virtual const PackageDepSpec * as_package_dep_spec() const
PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -134,39 +135,96 @@ namespace paludis
};
/**
- * Represents a use? ( ) dependency spec.
+ * Represents a dependency spec whose children should only be considered
+ * upon a certain condition (for example, a use dependency block).
*
* \ingroup g_dep_spec
+ * \since 0.26
* \nosubgrouping
*/
- class PALUDIS_VISIBLE UseDepSpec :
- public DepSpec
+ class PALUDIS_VISIBLE ConditionalDepSpec :
+ public DepSpec,
+ private PrivateImplementationPattern<ConditionalDepSpec>,
+ public MetadataKeyHolder,
+ public CloneUsingThis<DepSpec, ConditionalDepSpec>
{
+ friend std::ostream & operator<< (std::ostream &, const ConditionalDepSpec &);
+
private:
- const UseFlagName _flag;
- const bool _inverse;
+ PrivateImplementationPattern<ConditionalDepSpec>::ImpPtr & _imp;
+
+ std::string _as_string() const;
+
+ protected:
+ virtual void need_keys_added() const;
+ virtual void clear_metadata_keys() const;
public:
///\name Basic operations
///\{
- UseDepSpec(const UseFlagName &, bool);
+ ConditionalDepSpec(const tr1::shared_ptr<const ConditionalDepSpecData> &);
+ ConditionalDepSpec(const ConditionalDepSpec &);
+ ~ConditionalDepSpec();
///\}
+ virtual const ConditionalDepSpec * as_conditional_dep_spec() const;
+
/**
- * Fetch our use flag name.
+ * Is our condition met?
+ *
+ * This takes into account inverses etc.
*/
- UseFlagName flag() const;
+ bool condition_met() const PALUDIS_ATTRIBUTE((warn_unused_result));
/**
- * Fetch whether we are a ! flag.
+ * Is our condition meetable?
+ *
+ * This takes into account inverses, masks, forces etc.
*/
- bool inverse() const;
+ bool condition_meetable() const PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual const UseDepSpec * as_use_dep_spec() const;
+ /**
+ * Fetch our data.
+ *
+ * This shouldn't generally be used by clients, but some repositories use it
+ * to gain access to additional data stored in the ConditionalDepSpecData.
+ */
+ const tr1::shared_ptr<const ConditionalDepSpecData> data() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
- virtual tr1::shared_ptr<DepSpec> clone() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ /**
+ * Data for a ConditionalDepSpec.
+ *
+ * \since 0.26
+ * \ingroup g_dep_spec
+ */
+ class PALUDIS_VISIBLE ConditionalDepSpecData :
+ public MetadataKeyHolder
+ {
+ public:
+ ///\name Basic operations
+ ///\{
+
+ virtual ~ConditionalDepSpecData();
+
+ ///\}
+
+ /**
+ * Fetch ourself as a string.
+ */
+ virtual std::string as_string() const = 0;
+
+ /**
+ * Fetch the result for condition_met.
+ */
+ virtual bool condition_met() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ /**
+ * Fetch the result for condition_meetable.
+ */
+ virtual bool condition_meetable() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
};
/**
diff --git a/paludis/dep_spec_TEST.cc b/paludis/dep_spec_TEST.cc
index ffbb06d..26d4c3b 100644
--- a/paludis/dep_spec_TEST.cc
+++ b/paludis/dep_spec_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
@@ -43,11 +43,7 @@ namespace test_cases
void run()
{
tr1::shared_ptr<PackageDepSpec> x(new PackageDepSpec(parse_user_package_dep_spec("foo/bar", UserPackageDepSpecOptions())));
- TEST_CHECK(0 == x->as_use_dep_spec());
-
- tr1::shared_ptr<UseDepSpec> y(new UseDepSpec(UseFlagName("foo"), x));
- TEST_CHECK(0 != y->as_use_dep_spec());
- TEST_CHECK(y.get() == y->as_use_dep_spec());
+ TEST_CHECK(0 == x->as_conditional_dep_spec());
}
} test_dep_spec_as;
diff --git a/paludis/dep_spec_flattener.cc b/paludis/dep_spec_flattener.cc
index 2b152e3..7005502 100644
--- a/paludis/dep_spec_flattener.cc
+++ b/paludis/dep_spec_flattener.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007 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
@@ -40,13 +40,11 @@ namespace paludis
struct Implementation<DepSpecFlattener<Heirarchy_, Item_> >
{
const Environment * const env;
- const PackageID * const pkg;
std::list<tr1::shared_ptr<const Item_> > specs;
- Implementation(const Environment * const e, const PackageID * const p) :
- env(e),
- pkg(p)
+ Implementation(const Environment * const e) :
+ env(e)
{
}
};
@@ -54,22 +52,9 @@ namespace paludis
template <typename Heirarchy_, typename Item_>
DepSpecFlattener<Heirarchy_, Item_>::DepSpecFlattener(
- const Environment * const env,
- const PackageID & pkg) :
+ const Environment * const env) :
PrivateImplementationPattern<DepSpecFlattener<Heirarchy_, Item_> >(
- new Implementation<DepSpecFlattener<Heirarchy_, Item_> >(env, &pkg)),
- _imp(PrivateImplementationPattern<DepSpecFlattener<Heirarchy_, Item_> >::_imp)
-{
-}
-
-template <typename Heirarchy_, typename Item_>
-DepSpecFlattener<Heirarchy_, Item_>::DepSpecFlattener(
- const Environment * const e,
- const typename Select<ConstVisitor<Heirarchy_>::template
- Contains<const ConstTreeSequence<Heirarchy_, UseDepSpec> >::value,
- NoType<0u>, Empty>::Type &) :
- PrivateImplementationPattern<DepSpecFlattener<Heirarchy_, Item_> >(
- new Implementation<DepSpecFlattener<Heirarchy_, Item_> >(e, 0)),
+ new Implementation<DepSpecFlattener<Heirarchy_, Item_> >(env)),
_imp(PrivateImplementationPattern<DepSpecFlattener<Heirarchy_, Item_> >::_imp)
{
}
@@ -95,13 +80,13 @@ DepSpecFlattener<Heirarchy_, Item_>::end() const
template <typename Heirarchy_, typename Item_>
void
-dep_spec_flattener_internals::VisitUseDepSpec<Heirarchy_, Item_, true>::visit_sequence(const UseDepSpec & u,
+dep_spec_flattener_internals::VisitConditionalDepSpec<Heirarchy_, Item_, true>::visit_sequence(const ConditionalDepSpec & u,
typename Heirarchy_::ConstSequenceIterator cur,
typename Heirarchy_::ConstSequenceIterator e)
{
DepSpecFlattener<Heirarchy_, Item_> * const f(static_cast<DepSpecFlattener<Heirarchy_, Item_> *>(this));
- if (f->_imp->env->query_use(u.flag(), *f->_imp->pkg) ^ u.inverse())
+ if (u.condition_met())
std::for_each(cur, e, accept_visitor(*f));
}
diff --git a/paludis/dep_spec_flattener.hh b/paludis/dep_spec_flattener.hh
index 398af61..d172af6 100644
--- a/paludis/dep_spec_flattener.hh
+++ b/paludis/dep_spec_flattener.hh
@@ -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
@@ -90,31 +90,31 @@ namespace paludis
};
/**
- * Implement visit for UseDepSpec, if necessary.
+ * Implement visit for ConditionalDepSpec, if necessary.
*
* \ingroup g_dep_spec
* \since 0.26
* \nosubgrouping
*/
template <typename H_, typename I_, bool b_>
- struct VisitUseDepSpec
+ struct VisitConditionalDepSpec
{
void visit_sequence(const NoType<0u> &);
};
/**
- * Implement visit for UseDepSpec, if necessary.
+ * Implement visit for ConditionalDepSpec, if necessary.
*
* \ingroup g_dep_spec
* \since 0.26
* \nosubgrouping
*/
template <typename H_, typename I_>
- struct VisitUseDepSpec<H_, I_, true> :
- virtual visitor_internals::Visits<const ConstTreeSequence<H_, UseDepSpec> >
+ struct VisitConditionalDepSpec<H_, I_, true> :
+ virtual visitor_internals::Visits<const ConstTreeSequence<H_, ConditionalDepSpec> >
{
void visit_sequence(
- const UseDepSpec &,
+ const ConditionalDepSpec &,
typename H_::ConstSequenceIterator,
typename H_::ConstSequenceIterator);
};
@@ -146,13 +146,13 @@ namespace paludis
public ConstVisitor<Heirarchy_>::template VisitConstSequence<DepSpecFlattener<Heirarchy_, Item_>, AllDepSpec>,
public dep_spec_flattener_internals::VisitNamedSetDepSpec<
Heirarchy_, Item_, ConstVisitor<Heirarchy_>::template Contains<const TreeLeaf<Heirarchy_, NamedSetDepSpec> >::value>,
- public dep_spec_flattener_internals::VisitUseDepSpec<
- Heirarchy_, Item_, ConstVisitor<Heirarchy_>::template Contains<const ConstTreeSequence<Heirarchy_, UseDepSpec> >::value>
+ public dep_spec_flattener_internals::VisitConditionalDepSpec<
+ Heirarchy_, Item_, ConstVisitor<Heirarchy_>::template Contains<const ConstTreeSequence<Heirarchy_, ConditionalDepSpec> >::value>
{
friend class dep_spec_flattener_internals::VisitNamedSetDepSpec<
Heirarchy_, Item_, ConstVisitor<Heirarchy_>::template Contains<const TreeLeaf<Heirarchy_, NamedSetDepSpec> >::value>;
- friend class dep_spec_flattener_internals::VisitUseDepSpec<
- Heirarchy_, Item_, ConstVisitor<Heirarchy_>::template Contains<const ConstTreeSequence<Heirarchy_, UseDepSpec> >::value>;
+ friend class dep_spec_flattener_internals::VisitConditionalDepSpec<
+ Heirarchy_, Item_, ConstVisitor<Heirarchy_>::template Contains<const ConstTreeSequence<Heirarchy_, ConditionalDepSpec> >::value>;
private:
typename PrivateImplementationPattern<DepSpecFlattener<Heirarchy_, Item_> >::ImpPtr & _imp;
@@ -163,8 +163,8 @@ namespace paludis
using ConstVisitor<Heirarchy_>::template VisitConstSequence<DepSpecFlattener<Heirarchy_, Item_>, AllDepSpec>::visit_sequence;
- using dep_spec_flattener_internals::VisitUseDepSpec<Heirarchy_, Item_,
- ConstVisitor<Heirarchy_>::template Contains<const ConstTreeSequence<Heirarchy_, UseDepSpec> >::value>::visit_sequence;
+ using dep_spec_flattener_internals::VisitConditionalDepSpec<Heirarchy_, Item_,
+ ConstVisitor<Heirarchy_>::template Contains<const ConstTreeSequence<Heirarchy_, ConditionalDepSpec> >::value>::visit_sequence;
using dep_spec_flattener_internals::VisitNamedSetDepSpec<Heirarchy_, Item_,
ConstVisitor<Heirarchy_>::template Contains<const TreeLeaf<Heirarchy_, NamedSetDepSpec> >::value>::visit_leaf;
@@ -176,16 +176,7 @@ namespace paludis
///\name Basic operations
///\{
- /**
- * This constructor only works if we can't contain a UseDepSpec. The second
- * parameter is ignored.
- */
- DepSpecFlattener(const Environment * const,
- const typename Select<ConstVisitor<Heirarchy_>::template
- Contains<const ConstTreeSequence<Heirarchy_, UseDepSpec> >::value,
- NoType<0u>, Empty>::Type & t = Empty::instance);
-
- DepSpecFlattener(const Environment * const, const PackageID &);
+ DepSpecFlattener(const Environment * const);
~DepSpecFlattener();
diff --git a/paludis/dep_tag.cc b/paludis/dep_tag.cc
index b7f67fe..b212d73 100644
--- a/paludis/dep_tag.cc
+++ b/paludis/dep_tag.cc
@@ -185,11 +185,11 @@ namespace
}
void
- visit_sequence(const UseDepSpec & a,
+ visit_sequence(const ConditionalDepSpec & a,
DependencySpecTree::ConstSequenceIterator cur,
DependencySpecTree::ConstSequenceIterator end)
{
- s << (a.inverse() ? "!" : "") << a.flag() << "? ( ";
+ s << stringify(a) << " ( ";
std::for_each(cur, end, accept_visitor(*this));
s << ") ";
}
diff --git a/paludis/dep_tree.cc b/paludis/dep_tree.cc
index fd8d3ab..fa06ed7 100644
--- a/paludis/dep_tree.cc
+++ b/paludis/dep_tree.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -32,45 +32,45 @@ template class TreeLeaf<GenericSpecTree, FetchableURIDepSpec>;
template class TreeLeaf<GenericSpecTree, LicenseDepSpec>;
template class ConstTreeSequence<GenericSpecTree, AllDepSpec>;
template class ConstTreeSequence<GenericSpecTree, AnyDepSpec>;
-template class ConstTreeSequence<GenericSpecTree, UseDepSpec>;
+template class ConstTreeSequence<GenericSpecTree, ConditionalDepSpec>;
template class ConstVisitor<LicenseSpecTree>;
template class ConstAcceptInterface<LicenseSpecTree>;
template class TreeLeaf<LicenseSpecTree, LicenseDepSpec>;
template class ConstTreeSequence<LicenseSpecTree, AllDepSpec>;
template class ConstTreeSequence<LicenseSpecTree, AnyDepSpec>;
-template class ConstTreeSequence<LicenseSpecTree, UseDepSpec>;
+template class ConstTreeSequence<LicenseSpecTree, ConditionalDepSpec>;
template class ConstVisitor<FetchableURISpecTree>;
template class ConstAcceptInterface<FetchableURISpecTree>;
template class TreeLeaf<FetchableURISpecTree, FetchableURIDepSpec>;
template class ConstTreeSequence<FetchableURISpecTree, AllDepSpec>;
-template class ConstTreeSequence<FetchableURISpecTree, UseDepSpec>;
+template class ConstTreeSequence<FetchableURISpecTree, ConditionalDepSpec>;
template class ConstVisitor<SimpleURISpecTree>;
template class ConstAcceptInterface<SimpleURISpecTree>;
template class TreeLeaf<SimpleURISpecTree, SimpleURIDepSpec>;
template class ConstTreeSequence<SimpleURISpecTree, AllDepSpec>;
-template class ConstTreeSequence<SimpleURISpecTree, UseDepSpec>;
+template class ConstTreeSequence<SimpleURISpecTree, ConditionalDepSpec>;
template class ConstVisitor<ProvideSpecTree>;
template class ConstAcceptInterface<ProvideSpecTree>;
template class TreeLeaf<ProvideSpecTree, PackageDepSpec>;
template class ConstTreeSequence<ProvideSpecTree, AllDepSpec>;
-template class ConstTreeSequence<ProvideSpecTree, UseDepSpec>;
+template class ConstTreeSequence<ProvideSpecTree, ConditionalDepSpec>;
template class ConstVisitor<RestrictSpecTree>;
template class ConstAcceptInterface<RestrictSpecTree>;
template class TreeLeaf<RestrictSpecTree, PlainTextDepSpec>;
template class ConstTreeSequence<RestrictSpecTree, AllDepSpec>;
-template class ConstTreeSequence<RestrictSpecTree, UseDepSpec>;
+template class ConstTreeSequence<RestrictSpecTree, ConditionalDepSpec>;
template class ConstVisitor<DependencySpecTree>;
template class TreeLeaf<DependencySpecTree, PackageDepSpec>;
template class TreeLeaf<DependencySpecTree, BlockDepSpec>;
template class ConstTreeSequence<DependencySpecTree, AllDepSpec>;
template class ConstTreeSequence<DependencySpecTree, AnyDepSpec>;
-template class ConstTreeSequence<DependencySpecTree, UseDepSpec>;
+template class ConstTreeSequence<DependencySpecTree, ConditionalDepSpec>;
template class ConstAcceptInterface<DependencySpecTree>;
template class ConstVisitor<SetSpecTree>;
diff --git a/paludis/dep_tree.hh b/paludis/dep_tree.hh
index ef49c1a..c383139 100644
--- a/paludis/dep_tree.hh
+++ b/paludis/dep_tree.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -65,7 +65,7 @@ namespace paludis
TreeLeaf<GenericSpecTree, NamedSetDepSpec>,
ConstTreeSequence<GenericSpecTree, AllDepSpec>,
ConstTreeSequence<GenericSpecTree, AnyDepSpec>,
- ConstTreeSequence<GenericSpecTree, UseDepSpec>
+ ConstTreeSequence<GenericSpecTree, ConditionalDepSpec>
>
{
/**
@@ -77,7 +77,7 @@ namespace paludis
* \nosubgrouping
*/
typedef Formatter<
- UseDepSpec,
+ ConditionalDepSpec,
PlainTextDepSpec,
SimpleURIDepSpec,
FetchableURIDepSpec,
@@ -104,7 +104,7 @@ namespace paludis
TreeLeaf<LicenseSpecTree, LicenseDepSpec>,
ConstTreeSequence<LicenseSpecTree, AllDepSpec>,
ConstTreeSequence<LicenseSpecTree, AnyDepSpec>,
- ConstTreeSequence<LicenseSpecTree, UseDepSpec>
+ ConstTreeSequence<LicenseSpecTree, ConditionalDepSpec>
>
{
/**
@@ -116,7 +116,7 @@ namespace paludis
* \nosubgrouping
*/
typedef Formatter<
- UseDepSpec,
+ ConditionalDepSpec,
LicenseDepSpec
> ItemFormatter;
};
@@ -135,7 +135,7 @@ namespace paludis
TreeLeaf<FetchableURISpecTree, FetchableURIDepSpec>,
TreeLeaf<FetchableURISpecTree, LabelsDepSpec<URILabelVisitorTypes> >,
ConstTreeSequence<FetchableURISpecTree, AllDepSpec>,
- ConstTreeSequence<FetchableURISpecTree, UseDepSpec>
+ ConstTreeSequence<FetchableURISpecTree, ConditionalDepSpec>
>
{
/**
@@ -147,7 +147,7 @@ namespace paludis
* \nosubgrouping
*/
typedef Formatter<
- UseDepSpec,
+ ConditionalDepSpec,
FetchableURIDepSpec,
URILabelsDepSpec
> ItemFormatter;
@@ -166,7 +166,7 @@ namespace paludis
DepSpec,
TreeLeaf<SimpleURISpecTree, SimpleURIDepSpec>,
ConstTreeSequence<SimpleURISpecTree, AllDepSpec>,
- ConstTreeSequence<SimpleURISpecTree, UseDepSpec>
+ ConstTreeSequence<SimpleURISpecTree, ConditionalDepSpec>
>
{
/**
@@ -178,7 +178,7 @@ namespace paludis
* \nosubgrouping
*/
typedef Formatter<
- UseDepSpec,
+ ConditionalDepSpec,
SimpleURIDepSpec
> ItemFormatter;
};
@@ -196,7 +196,7 @@ namespace paludis
DepSpec,
TreeLeaf<ProvideSpecTree, PackageDepSpec>,
ConstTreeSequence<ProvideSpecTree, AllDepSpec>,
- ConstTreeSequence<ProvideSpecTree, UseDepSpec>
+ ConstTreeSequence<ProvideSpecTree, ConditionalDepSpec>
>
{
/**
@@ -208,7 +208,7 @@ namespace paludis
* \nosubgrouping
*/
typedef Formatter<
- UseDepSpec,
+ ConditionalDepSpec,
PackageDepSpec
> ItemFormatter;
};
@@ -226,7 +226,7 @@ namespace paludis
DepSpec,
TreeLeaf<RestrictSpecTree, PlainTextDepSpec>,
ConstTreeSequence<RestrictSpecTree, AllDepSpec>,
- ConstTreeSequence<RestrictSpecTree, UseDepSpec>
+ ConstTreeSequence<RestrictSpecTree, ConditionalDepSpec>
>
{
/**
@@ -238,7 +238,7 @@ namespace paludis
* \nosubgrouping
*/
typedef Formatter<
- UseDepSpec,
+ ConditionalDepSpec,
PlainTextDepSpec
> ItemFormatter;
};
@@ -260,7 +260,7 @@ namespace paludis
TreeLeaf<DependencySpecTree, NamedSetDepSpec>,
ConstTreeSequence<DependencySpecTree, AllDepSpec>,
ConstTreeSequence<DependencySpecTree, AnyDepSpec>,
- ConstTreeSequence<DependencySpecTree, UseDepSpec>
+ ConstTreeSequence<DependencySpecTree, ConditionalDepSpec>
>
{
/**
@@ -272,7 +272,7 @@ namespace paludis
* \nosubgrouping
*/
typedef Formatter<
- UseDepSpec,
+ ConditionalDepSpec,
PackageDepSpec,
BlockDepSpec,
NamedSetDepSpec,
diff --git a/paludis/formatter.hh b/paludis/formatter.hh
index b237466..470d22b 100644
--- a/paludis/formatter.hh
+++ b/paludis/formatter.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
@@ -285,14 +285,14 @@ namespace paludis
};
/**
- * UseDepSpec supports UseRoles.
+ * ConditionalDepSpec supports UseRoles.
*
* \ingroup g_formatters
* \since 0.26
* \nosubgrouping
*/
template <>
- struct CategorySelector<UseDepSpec>
+ struct CategorySelector<ConditionalDepSpec>
{
/// The roles this type supports.
typedef UseRoles Category;
diff --git a/paludis/install_task.cc b/paludis/install_task.cc
index 2244613..99120cb 100644
--- a/paludis/install_task.cc
+++ b/paludis/install_task.cc
@@ -1072,11 +1072,11 @@ namespace
failure.reset(new PackageDepSpec(a));
}
- void visit_sequence(const UseDepSpec & u,
+ void visit_sequence(const ConditionalDepSpec & u,
DependencySpecTree::ConstSequenceIterator cur,
DependencySpecTree::ConstSequenceIterator end)
{
- if (env->query_use(u.flag(), id) ^ u.inverse())
+ if (u.condition_met())
std::for_each(cur, end, accept_visitor(*this));
}
@@ -1300,11 +1300,11 @@ namespace
}
}
- void visit_sequence(const UseDepSpec & u,
+ void visit_sequence(const ConditionalDepSpec & u,
DependencySpecTree::ConstSequenceIterator cur,
DependencySpecTree::ConstSequenceIterator end)
{
- if (env->query_use(u.flag(), *id) ^ u.inverse())
+ if (u.condition_met())
std::for_each(cur, end, accept_visitor(*this));
}
diff --git a/paludis/match_package.cc b/paludis/match_package.cc
index b1e65d7..23d1a52 100644
--- a/paludis/match_package.cc
+++ b/paludis/match_package.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
@@ -103,7 +103,7 @@ paludis::match_package_in_set(
{
using namespace tr1::placeholders;
- DepSpecFlattener<SetSpecTree, PackageDepSpec> f(&env, entry);
+ DepSpecFlattener<SetSpecTree, PackageDepSpec> f(&env);
target.accept(f);
return indirect_iterator(f.end()) != std::find_if(
indirect_iterator(f.begin()), indirect_iterator(f.end()),
diff --git a/paludis/query_visitor.cc b/paludis/query_visitor.cc
index 0e8773e..b5ed42e 100644
--- a/paludis/query_visitor.cc
+++ b/paludis/query_visitor.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -128,13 +128,13 @@ QueryVisitor::visit_leaf(const NamedSetDepSpec & s)
}
void
-QueryVisitor::visit_sequence(const UseDepSpec & a,
+QueryVisitor::visit_sequence(const ConditionalDepSpec & a,
DependencySpecTree::ConstSequenceIterator cur,
DependencySpecTree::ConstSequenceIterator end)
{
/* for use? ( ) dep specs, return true if we're not enabled, so that
* weird || ( ) cases work. */
- if ((_imp->id ? _imp->environment->query_use(a.flag(), *_imp->id) : false) ^ a.inverse())
+ if (a.condition_met())
{
_imp->result = true;
for ( ; cur != end ; ++cur)
@@ -164,7 +164,7 @@ QueryVisitor::visit_sequence(const AnyDepSpec &,
else
for ( ; cur != end ; ++cur)
{
- if (! is_viable_any_child(*_imp->environment, _imp->id, *cur))
+ if (! is_viable_any_child(*cur))
continue;
cur->accept(*this);
diff --git a/paludis/query_visitor.hh b/paludis/query_visitor.hh
index 9679951..f943576 100644
--- a/paludis/query_visitor.hh
+++ b/paludis/query_visitor.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -68,7 +68,7 @@ namespace paludis
DependencySpecTree::ConstSequenceIterator,
DependencySpecTree::ConstSequenceIterator);
- void visit_sequence(const UseDepSpec &,
+ void visit_sequence(const ConditionalDepSpec &,
DependencySpecTree::ConstSequenceIterator,
DependencySpecTree::ConstSequenceIterator);
diff --git a/paludis/range_rewriter.cc b/paludis/range_rewriter.cc
index e3c57c1..2faba0b 100644
--- a/paludis/range_rewriter.cc
+++ b/paludis/range_rewriter.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
@@ -193,7 +193,7 @@ RangeRewriter::visit_sequence(const AnyDepSpec &,
}
void
-RangeRewriter::visit_sequence(const UseDepSpec &,
+RangeRewriter::visit_sequence(const ConditionalDepSpec &,
DependencySpecTree::ConstSequenceIterator,
DependencySpecTree::ConstSequenceIterator)
{
diff --git a/paludis/range_rewriter.hh b/paludis/range_rewriter.hh
index 37088c4..d8f51d4 100644
--- a/paludis/range_rewriter.hh
+++ b/paludis/range_rewriter.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
@@ -73,7 +73,7 @@ namespace paludis
DependencySpecTree::ConstSequenceIterator,
DependencySpecTree::ConstSequenceIterator);
- void visit_sequence(const UseDepSpec &,
+ void visit_sequence(const ConditionalDepSpec &,
DependencySpecTree::ConstSequenceIterator,
DependencySpecTree::ConstSequenceIterator);
diff --git a/paludis/repositories/cran/dep_spec_pretty_printer.hh b/paludis/repositories/cran/dep_spec_pretty_printer.hh
index 311d678..a343961 100644
--- a/paludis/repositories/cran/dep_spec_pretty_printer.hh
+++ b/paludis/repositories/cran/dep_spec_pretty_printer.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
@@ -40,7 +40,7 @@ namespace paludis
private PrivateImplementationPattern<DepSpecPrettyPrinter>,
public ConstVisitor<DependencySpecTree>,
public ConstVisitor<DependencySpecTree>::VisitConstSequence<DepSpecPrettyPrinter, AllDepSpec>,
- public ConstVisitor<DependencySpecTree>::VisitConstSequence<DepSpecPrettyPrinter, UseDepSpec>,
+ public ConstVisitor<DependencySpecTree>::VisitConstSequence<DepSpecPrettyPrinter, ConditionalDepSpec>,
public ConstVisitor<DependencySpecTree>::VisitConstSequence<DepSpecPrettyPrinter, AnyDepSpec>
{
friend std::ostream & operator<< (std::ostream &, const DepSpecPrettyPrinter &);
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index 87fbce7..0282a21 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -37,6 +37,7 @@ libpaludiserepository_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_
paludis_repositories_e_include_HEADERS = \
aa_visitor.hh \
check_fetched_files_visitor.hh \
+ conditional_dep_spec.hh \
dep_lexer.hh \
dep_parser.hh \
dep_parser-se.hh \
@@ -100,6 +101,7 @@ libpaludiserepository_la_SOURCES = \
aa_visitor.cc \
dep_lexer.cc \
check_fetched_files_visitor.cc \
+ conditional_dep_spec.cc \
dep_parser.cc \
dep_spec_pretty_printer.cc \
dependencies_rewriter.cc \
@@ -222,6 +224,7 @@ e_repository_sets_TEST_SOURCES = e_repository_sets_TEST.cc
e_repository_sets_TEST_LDADD = \
libpaludiserepository.la \
+ $(top_builddir)/paludis/repositories/fake/libpaludisfakerepository.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(top_builddir)/paludis/util/test_extras.o \
$(top_builddir)/paludis/libpaludis.la \
@@ -236,6 +239,7 @@ dep_spec_pretty_printer_TEST_SOURCES = dep_spec_pretty_printer_TEST.cc
dep_spec_pretty_printer_TEST_LDADD = \
libpaludiserepository.la \
+ $(top_builddir)/paludis/repositories/fake/libpaludisfakerepository.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(top_builddir)/paludis/util/test_extras.o \
$(top_builddir)/paludis/libpaludis.la \
@@ -258,6 +262,7 @@ dep_parser_TEST_SOURCES = dep_parser_TEST.cc
dep_parser_TEST_LDADD = \
libpaludiserepository.la \
+ $(top_builddir)/paludis/repositories/fake/libpaludisfakerepository.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(top_builddir)/paludis/util/test_extras.o \
$(top_builddir)/paludis/libpaludis.la \
@@ -269,6 +274,7 @@ aa_visitor_TEST_SOURCES = aa_visitor_TEST.cc
aa_visitor_TEST_LDADD = \
libpaludiserepository.la \
+ $(top_builddir)/paludis/repositories/fake/libpaludisfakerepository.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(top_builddir)/paludis/util/test_extras.o \
$(top_builddir)/paludis/libpaludis.la \
diff --git a/paludis/repositories/e/aa_visitor.hh b/paludis/repositories/e/aa_visitor.hh
index 27ef27d..4b2e71e 100644
--- a/paludis/repositories/e/aa_visitor.hh
+++ b/paludis/repositories/e/aa_visitor.hh
@@ -44,7 +44,7 @@ namespace paludis
class PALUDIS_VISIBLE AAVisitor :
public ConstVisitor<FetchableURISpecTree>,
public ConstVisitor<FetchableURISpecTree>::VisitConstSequence<AAVisitor, AllDepSpec>,
- public ConstVisitor<FetchableURISpecTree>::VisitConstSequence<AAVisitor, UseDepSpec>,
+ public ConstVisitor<FetchableURISpecTree>::VisitConstSequence<AAVisitor, ConditionalDepSpec>,
private PrivateImplementationPattern<AAVisitor>
{
public:
diff --git a/paludis/repositories/e/aa_visitor_TEST.cc b/paludis/repositories/e/aa_visitor_TEST.cc
index e1a319f..6eb0e06 100644
--- a/paludis/repositories/e/aa_visitor_TEST.cc
+++ b/paludis/repositories/e/aa_visitor_TEST.cc
@@ -22,6 +22,10 @@
#include <paludis/util/join.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/repositories/e/eapi.hh>
+#include <paludis/environments/test/test_environment.hh>
+#include <paludis/repositories/fake/fake_repository.hh>
+#include <paludis/repositories/fake/fake_package_id.hh>
+#include <paludis/package_database.hh>
#include <test/test_runner.hh>
#include <test/test_framework.hh>
@@ -37,8 +41,13 @@ namespace test_cases
void run()
{
+ TestEnvironment env;
+ tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
+ env.package_database()->add_repository(1, repo);
+ tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1"));
+
AAVisitor p1;
- parse_fetchable_uri("( a -> b c x? ( d e ) )", *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p1);
+ parse_fetchable_uri("( a -> b c x? ( d e ) )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p1);
TEST_CHECK_EQUAL(join(p1.begin(), p1.end(), " "), "b c d e");
}
} test_aa_visitor;
diff --git a/paludis/repositories/e/check_fetched_files_visitor.cc b/paludis/repositories/e/check_fetched_files_visitor.cc
index 9a7693f..89280fa 100644
--- a/paludis/repositories/e/check_fetched_files_visitor.cc
+++ b/paludis/repositories/e/check_fetched_files_visitor.cc
@@ -108,12 +108,12 @@ CheckFetchedFilesVisitor::~CheckFetchedFilesVisitor()
}
void
-CheckFetchedFilesVisitor::visit_sequence(const UseDepSpec & u,
+CheckFetchedFilesVisitor::visit_sequence(const ConditionalDepSpec & u,
FetchableURISpecTree::ConstSequenceIterator cur,
FetchableURISpecTree::ConstSequenceIterator end)
{
Save<bool> save_in_nofetch(&_imp->in_nofetch, _imp->in_nofetch);
- if ((_imp->check_unneeded) || (_imp->env->query_use(u.flag(), *_imp->id) ^ u.inverse()))
+ if ((_imp->check_unneeded) || (u.condition_met()))
std::for_each(cur, end, accept_visitor(*this));
}
diff --git a/paludis/repositories/e/check_fetched_files_visitor.hh b/paludis/repositories/e/check_fetched_files_visitor.hh
index aa06218..7e1e366 100644
--- a/paludis/repositories/e/check_fetched_files_visitor.hh
+++ b/paludis/repositories/e/check_fetched_files_visitor.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
@@ -55,7 +55,7 @@ namespace paludis
~CheckFetchedFilesVisitor();
- void visit_sequence(const UseDepSpec &,
+ void visit_sequence(const ConditionalDepSpec &,
FetchableURISpecTree::ConstSequenceIterator,
FetchableURISpecTree::ConstSequenceIterator);
diff --git a/paludis/repositories/e/conditional_dep_spec.cc b/paludis/repositories/e/conditional_dep_spec.cc
new file mode 100644
index 0000000..33dfe38
--- /dev/null
+++ b/paludis/repositories/e/conditional_dep_spec.cc
@@ -0,0 +1,138 @@
+/* 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
+ */
+
+#include <paludis/repositories/e/conditional_dep_spec.hh>
+#include <paludis/repositories/e/dep_parser.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/visitor_cast.hh>
+#include <paludis/util/destringify.hh>
+#include <paludis/environment.hh>
+#include <paludis/package_id.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/repository.hh>
+#include <paludis/literal_metadata_key.hh>
+#include <paludis/metadata_key_holder.hh>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+namespace
+{
+ struct EConditionalDepSpecData :
+ ConditionalDepSpecData
+ {
+ bool inverse;
+ UseFlagName flag;
+
+ const Environment * const env;
+ const tr1::shared_ptr<const PackageID> id;
+
+ EConditionalDepSpecData(const std::string & s, const Environment * const e, const tr1::shared_ptr<const PackageID> & i) :
+ inverse(false),
+ flag(UseFlagName("unset")),
+ env(e),
+ id(i)
+ {
+ if (! i)
+ Log::get_instance()->message(ll_warning, lc_context) << "! i";
+
+ if (s.empty())
+ throw DepStringParseError(s, "missing use flag name");
+
+ if (s.at(s.length() - 1) != '?')
+ throw DepStringParseError(s, "missing ? on use conditional");
+
+ inverse = '!' == s.at(0);
+ if (s.length() < (inverse ? 3 : 2))
+ throw DepStringParseError(s, "missing flag name on use conditional");
+
+ flag = UseFlagName(s.substr(inverse ? 1 : 0, s.length() - (inverse ? 2 : 1)));
+
+ add_metadata_key(make_shared_ptr(new LiteralMetadataStringKey("Flag", "Flag", mkt_normal, stringify(flag))));
+ add_metadata_key(make_shared_ptr(new LiteralMetadataStringKey("Inverse", "Inverse", mkt_normal, stringify(inverse))));
+ }
+
+ virtual std::string as_string() const
+ {
+ return (inverse ? "!" : "") + stringify(flag) + "?";
+ }
+
+ virtual bool condition_met() const
+ {
+ if (! id)
+ throw InternalError(PALUDIS_HERE, "! id");
+
+ return env->query_use(flag, *id) ^ inverse;
+ }
+
+ virtual bool condition_meetable() const
+ {
+ if (! id)
+ throw InternalError(PALUDIS_HERE, "! id");
+
+ RepositoryUseInterface * const u(id->repository()->use_interface);
+ if (! u)
+ return true;
+
+ if (inverse)
+ return ! u->query_use_force(flag, *id);
+ else
+ return ! u->query_use_mask(flag, *id);
+ }
+
+ virtual void need_keys_added() const
+ {
+ }
+ };
+}
+
+ConditionalDepSpec
+paludis::erepository::parse_e_conditional_dep_spec(const std::string & s,
+ const Environment * const env, const tr1::shared_ptr<const PackageID> & id, const EAPI &)
+{
+ return ConditionalDepSpec(make_shared_ptr(new EConditionalDepSpecData(s, env, id)));
+}
+
+UseFlagName
+paludis::erepository::conditional_dep_spec_flag(const ConditionalDepSpec & spec)
+{
+ ConditionalDepSpec::MetadataConstIterator i(spec.find_metadata("Flag"));
+ if (i == spec.end_metadata())
+ throw InternalError(PALUDIS_HERE, "Spec '" + stringify(spec) + "' has no Flag metadata");
+ const MetadataStringKey * key(visitor_cast<const MetadataStringKey>(**i));
+ if (! key)
+ throw InternalError(PALUDIS_HERE, "Spec '" + stringify(spec) + "' has Flag metadata which is not a string");
+ return UseFlagName(key->value());
+}
+
+bool
+paludis::erepository::conditional_dep_spec_is_inverse(const ConditionalDepSpec & spec)
+{
+ ConditionalDepSpec::MetadataConstIterator i(spec.find_metadata("Inverse"));
+ if (i == spec.end_metadata())
+ throw InternalError(PALUDIS_HERE, "Spec '" + stringify(spec) + "' has no Inverse metadata");
+ const MetadataStringKey * key(visitor_cast<const MetadataStringKey>(**i));
+ if (! key)
+ throw InternalError(PALUDIS_HERE, "Spec '" + stringify(spec) + "' has Inverse metadata which is not a string");
+ return destringify<bool>(key->value());
+}
+
diff --git a/paludis/repositories/e/conditional_dep_spec.hh b/paludis/repositories/e/conditional_dep_spec.hh
new file mode 100644
index 0000000..87e99c5
--- /dev/null
+++ b/paludis/repositories/e/conditional_dep_spec.hh
@@ -0,0 +1,41 @@
+/* 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_REPOSITORIES_E_CONDITIONAL_DEP_SPEC_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_CONDITIONAL_DEP_SPEC_HH 1
+
+#include <paludis/dep_spec-fwd.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/name-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+#include <paludis/repositories/e/eapi-fwd.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ ConditionalDepSpec parse_e_conditional_dep_spec(const std::string &,
+ const Environment * const, const tr1::shared_ptr<const PackageID> &, const EAPI &) PALUDIS_VISIBLE;
+
+ UseFlagName conditional_dep_spec_flag(const ConditionalDepSpec &) PALUDIS_VISIBLE;
+ bool conditional_dep_spec_is_inverse(const ConditionalDepSpec &) PALUDIS_VISIBLE;
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/dep_parser.cc b/paludis/repositories/e/dep_parser.cc
index 9d1aea0..7db94d9 100644
--- a/paludis/repositories/e/dep_parser.cc
+++ b/paludis/repositories/e/dep_parser.cc
@@ -22,6 +22,7 @@
#include <paludis/repositories/e/dep_lexer.hh>
#include <paludis/repositories/e/dep_parser.hh>
#include <paludis/repositories/e/package_dep_spec.hh>
+#include <paludis/repositories/e/conditional_dep_spec.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/tokeniser.hh>
@@ -222,28 +223,16 @@ namespace
template <typename H_, bool>
struct HandleUse
{
- static void handle(const std::string & s, const std::string & i,
- std::stack<std::pair<tr1::function<void (tr1::shared_ptr<ConstAcceptInterface<H_> >)>, bool> > & stack)
+ static void handle(const std::string &, const std::string & i,
+ const tr1::shared_ptr<const PackageID> & id, const Environment * const env,
+ const EAPI & eapi, std::stack<std::pair<tr1::function<void (tr1::shared_ptr<ConstAcceptInterface<H_> >)>, bool> > & stack)
{
- std::string f(i);
- bool inv(f.length() && ('!' == f.at(0)));
- if (inv)
- f.erase(0, 1);
-
- if (f.empty())
- throw DepStringParseError(s,
- "Bad use flag name '" + i + "'");
- if ('?' != f.at(f.length() - 1))
- throw DepStringParseError(s,
- "Use flag name '" + i + "' missing '?'");
-
- f.erase(f.length() - 1);
- tr1::shared_ptr<ConstTreeSequence<H_, UseDepSpec> > a(
- new ConstTreeSequence<H_, UseDepSpec>(tr1::shared_ptr<UseDepSpec>(
- new UseDepSpec(UseFlagName(f), inv))));
+ tr1::shared_ptr<ConstTreeSequence<H_, ConditionalDepSpec> > a(
+ new ConstTreeSequence<H_, ConditionalDepSpec>(tr1::shared_ptr<ConditionalDepSpec>(
+ new ConditionalDepSpec(parse_e_conditional_dep_spec(i, env, id, eapi)))));
stack.top().first(a);
stack.push(std::make_pair(tr1::function<void (tr1::shared_ptr<ConstAcceptInterface<H_> >)>(
- tr1::bind(&ConstTreeSequence<H_, UseDepSpec>::add, a.get(), _1)), false));
+ tr1::bind(&ConstTreeSequence<H_, ConditionalDepSpec>::add, a.get(), _1)), false));
}
};
@@ -251,7 +240,8 @@ namespace
struct HandleUse<H_, false>
{
static void handle(const std::string & s, const std::string &,
- std::stack<std::pair<tr1::function<void (tr1::shared_ptr<ConstAcceptInterface<H_> >)>, bool> > &)
+ const tr1::shared_ptr<const PackageID> &, const Environment * const,
+ const EAPI &, std::stack<std::pair<tr1::function<void (tr1::shared_ptr<ConstAcceptInterface<H_> >)>, bool> > &)
{
throw DepStringParseError(s, "use? group is not allowed here");
}
@@ -323,10 +313,14 @@ namespace
{
template <typename H_, typename I_, bool any_, bool use_, typename Label_>
tr1::shared_ptr<typename H_::ConstItem>
- parse(const std::string & s, bool disallow_any_use, const I_ & p, const EAPI & e, const tr1::shared_ptr<const PackageID> &)
+ parse(const std::string & s, bool disallow_any_use, const I_ & p, const Environment * const env,
+ const EAPI & e, const tr1::shared_ptr<const PackageID> & id)
{
Context context("When parsing dependency string '" + s + "':");
+ if (! id)
+ throw InternalError(PALUDIS_HERE, "! id");
+
tr1::shared_ptr<ConstTreeSequence<H_, AllDepSpec> > result(
new ConstTreeSequence<H_, AllDepSpec>(tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
std::stack<std::pair<tr1::function<void (tr1::shared_ptr<ConstAcceptInterface<H_> >)>, bool> > stack;
@@ -403,7 +397,7 @@ namespace
case dpl_use_flag:
if (use_ && disallow_any_use && stack.top().second)
throw DepStringParseError(s, "use? group is not allowed immediately under a || ( )");
- HandleUse<H_, use_>::handle(s, i->second, stack);
+ HandleUse<H_, use_>::handle(s, i->second, id, env, e, stack);
state = dps_had_use_flag;
continue;
@@ -664,7 +658,8 @@ namespace
}
tr1::shared_ptr<DependencySpecTree::ConstItem>
-paludis::erepository::parse_depend(const std::string & s, const EAPI & e, const tr1::shared_ptr<const PackageID> & id)
+paludis::erepository::parse_depend(const std::string & s, const Environment * const env,
+ const tr1::shared_ptr<const PackageID> & id, const EAPI & e)
{
Context c("When parsing dependency string '" + s + "' using EAPI '" + e.name + "':");
@@ -673,11 +668,12 @@ paludis::erepository::parse_depend(const std::string & s, const EAPI & e, const
return parse<DependencySpecTree, ParsePackageOrBlockDepSpec, true, true, LabelsAreDependency>(s,
e.supported->dependency_spec_tree_parse_options[dstpo_disallow_any_use],
- ParsePackageOrBlockDepSpec(e, id), e, id);
+ ParsePackageOrBlockDepSpec(e, id), env, e, id);
}
tr1::shared_ptr<ProvideSpecTree::ConstItem>
-paludis::erepository::parse_provide(const std::string & s, const EAPI & e)
+paludis::erepository::parse_provide(const std::string & s, const Environment * const env,
+ const tr1::shared_ptr<const PackageID> & id, const EAPI & e)
{
Context c("When parsing provide string '" + s + "' using EAPI '" + e.name + "':");
@@ -685,11 +681,12 @@ paludis::erepository::parse_provide(const std::string & s, const EAPI & e)
throw DepStringParseError(s, "Don't know how to parse EAPI '" + e.name + "' provides");
return parse<ProvideSpecTree, ParsePackageDepSpec, false, true, void>(s, false,
- ParsePackageDepSpec(e, tr1::shared_ptr<const PackageID>()), e, tr1::shared_ptr<const PackageID>());
+ ParsePackageDepSpec(e, tr1::shared_ptr<const PackageID>()), env, e, id);
}
tr1::shared_ptr<RestrictSpecTree::ConstItem>
-paludis::erepository::parse_restrict(const std::string & s, const EAPI & e)
+paludis::erepository::parse_restrict(const std::string & s, const Environment * const env,
+ const tr1::shared_ptr<const PackageID> & id, const EAPI & e)
{
Context c("When parsing restrict string '" + s + "' using EAPI '" + e.name + "':");
@@ -697,11 +694,12 @@ paludis::erepository::parse_restrict(const std::string & s, const EAPI & e)
throw DepStringParseError(s, "Don't know how to parse EAPI '" + e.name + "' restrictions");
return parse<RestrictSpecTree, ParseTextDepSpec, false, true, void>(s, false,
- ParseTextDepSpec(), e, tr1::shared_ptr<const PackageID>());
+ ParseTextDepSpec(), env, e, id);
}
tr1::shared_ptr<FetchableURISpecTree::ConstItem>
-paludis::erepository::parse_fetchable_uri(const std::string & s, const EAPI & e)
+paludis::erepository::parse_fetchable_uri(const std::string & s, const Environment * const env,
+ const tr1::shared_ptr<const PackageID> & id, const EAPI & e)
{
Context c("When parsing fetchable URI string '" + s + "' using EAPI '" + e.name + "':");
@@ -710,11 +708,12 @@ paludis::erepository::parse_fetchable_uri(const std::string & s, const EAPI & e)
return parse<FetchableURISpecTree, ParseFetchableURIDepSpec, false, true, LabelsAreURI>(s, false,
ParseFetchableURIDepSpec(e.supported->dependency_spec_tree_parse_options[dstpo_uri_supports_arrow]),
- e, tr1::shared_ptr<const PackageID>());
+ env, e, id);
}
tr1::shared_ptr<SimpleURISpecTree::ConstItem>
-paludis::erepository::parse_simple_uri(const std::string & s, const EAPI & e)
+paludis::erepository::parse_simple_uri(const std::string & s, const Environment * const env,
+ const tr1::shared_ptr<const PackageID> & id, const EAPI & e)
{
Context c("When parsing simple URI string '" + s + "' using EAPI '" + e.name + "':");
@@ -722,11 +721,12 @@ paludis::erepository::parse_simple_uri(const std::string & s, const EAPI & e)
throw DepStringParseError(s, "Don't know how to parse EAPI '" + e.name + "' URIs");
return parse<SimpleURISpecTree, ParseSimpleURIDepSpec, false, true, void>(s, false,
- ParseSimpleURIDepSpec(), e, tr1::shared_ptr<const PackageID>());
+ ParseSimpleURIDepSpec(), env, e, id);
}
tr1::shared_ptr<LicenseSpecTree::ConstItem>
-paludis::erepository::parse_license(const std::string & s, const EAPI & e)
+paludis::erepository::parse_license(const std::string & s, const Environment * const env,
+ const tr1::shared_ptr<const PackageID> & id, const EAPI & e)
{
Context c("When parsing license string '" + s + "' using EAPI '" + e.name + "':");
@@ -734,7 +734,7 @@ paludis::erepository::parse_license(const std::string & s, const EAPI & e)
throw DepStringParseError(s, "Don't know how to parse EAPI '" + e.name + "' licenses");
return parse<LicenseSpecTree, ParseLicenseDepSpec, true, true, void>(s,
- true, ParseLicenseDepSpec(), e, tr1::shared_ptr<const PackageID>());
+ true, ParseLicenseDepSpec(), env, e, id);
}
tr1::shared_ptr<URILabelsDepSpec>
diff --git a/paludis/repositories/e/dep_parser.hh b/paludis/repositories/e/dep_parser.hh
index a668360..6c6baea 100644
--- a/paludis/repositories/e/dep_parser.hh
+++ b/paludis/repositories/e/dep_parser.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -27,6 +27,7 @@
#include <paludis/repositories/e/eapi-fwd.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/instantiation_policy.hh>
+#include <paludis/environment-fwd.hh>
#include <string>
/** \file
@@ -76,49 +77,47 @@ namespace paludis
* Parse a dependency heirarchy.
*/
tr1::shared_ptr<DependencySpecTree::ConstItem> parse_depend(const std::string & s,
- const EAPI &, const tr1::shared_ptr<const PackageID> &) PALUDIS_VISIBLE;
+ const Environment * const, const tr1::shared_ptr<const PackageID> &, const EAPI &) PALUDIS_VISIBLE;
/**
* Parse a dep spec label.
*/
- tr1::shared_ptr<DependencyLabelsDepSpec> parse_dependency_label(const std::string & s,
- const EAPI &) PALUDIS_VISIBLE;
+ tr1::shared_ptr<DependencyLabelsDepSpec> parse_dependency_label(const std::string & s, const EAPI &) PALUDIS_VISIBLE;
/**
* Parse a provide heirarchy.
*/
tr1::shared_ptr<ProvideSpecTree::ConstItem> parse_provide(const std::string & s,
- const EAPI &) PALUDIS_VISIBLE;
+ const Environment * const, const tr1::shared_ptr<const PackageID> &, const EAPI &) PALUDIS_VISIBLE;
/**
* Parse a restrict.
*/
tr1::shared_ptr<RestrictSpecTree::ConstItem> parse_restrict(const std::string & s,
- const EAPI &) PALUDIS_VISIBLE;
+ const Environment * const, const tr1::shared_ptr<const PackageID> &, const EAPI &) PALUDIS_VISIBLE;
/**
* Parse a fetchable uri heirarchy.
*/
tr1::shared_ptr<FetchableURISpecTree::ConstItem> parse_fetchable_uri(const std::string & s,
- const EAPI &) PALUDIS_VISIBLE;
+ const Environment * const, const tr1::shared_ptr<const PackageID> &, const EAPI &) PALUDIS_VISIBLE;
/**
* Parse a simple uri heirarchy.
*/
tr1::shared_ptr<SimpleURISpecTree::ConstItem> parse_simple_uri(const std::string & s,
- const EAPI &) PALUDIS_VISIBLE;
+ const Environment * const, const tr1::shared_ptr<const PackageID> &, const EAPI &) PALUDIS_VISIBLE;
/**
* Parse a license heirarchy.
*/
tr1::shared_ptr<LicenseSpecTree::ConstItem> parse_license(const std::string & s,
- const EAPI &) PALUDIS_VISIBLE;
+ const Environment * const, const tr1::shared_ptr<const PackageID> &, const EAPI &) PALUDIS_VISIBLE;
/**
* Parse a URI label.
*/
- tr1::shared_ptr<URILabelsDepSpec> parse_uri_label(const std::string & s,
- const EAPI &) PALUDIS_VISIBLE;
+ tr1::shared_ptr<URILabelsDepSpec> parse_uri_label(const std::string & s, const EAPI &) PALUDIS_VISIBLE;
}
}
diff --git a/paludis/repositories/e/dep_parser_TEST.cc b/paludis/repositories/e/dep_parser_TEST.cc
index a7f7cf1..f46897c 100644
--- a/paludis/repositories/e/dep_parser_TEST.cc
+++ b/paludis/repositories/e/dep_parser_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -20,6 +20,10 @@
#include <paludis/repositories/e/dep_spec_pretty_printer.hh>
#include <paludis/repositories/e/dep_parser.hh>
#include <paludis/repositories/e/eapi.hh>
+#include <paludis/environments/test/test_environment.hh>
+#include <paludis/repositories/fake/fake_repository.hh>
+#include <paludis/repositories/fake/fake_package_id.hh>
+#include <paludis/package_database.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/stringify_formatter.hh>
#include <sstream>
@@ -47,11 +51,15 @@ namespace test_cases
void run()
{
+ TestEnvironment env;
+ tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
+ env.package_database()->add_repository(1, repo);
+ tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1"));
+
StringifyFormatter ff;
DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
parse_depend("",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "");
}
} test_dep_spec_parser_empty;
@@ -66,11 +74,15 @@ namespace test_cases
void run()
{
+ TestEnvironment env;
+ tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
+ env.package_database()->add_repository(1, repo);
+ tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1"));
+
StringifyFormatter ff;
DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
parse_depend(" \n \t",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "");
}
} test_dep_spec_parser_blank;
@@ -85,11 +97,15 @@ namespace test_cases
void run()
{
+ TestEnvironment env;
+ tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
+ env.package_database()->add_repository(1, repo);
+ tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1"));
+
StringifyFormatter ff;
DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
parse_depend("app-editors/vim",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "app-editors/vim");
}
} test_dep_spec_parser_package;
@@ -105,23 +121,24 @@ namespace test_cases
void run()
{
StringifyFormatter ff;
+ TestEnvironment env;
+ tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
+ env.package_database()->add_repository(1, repo);
+ tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1"));
DepSpecPrettyPrinter d1(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
parse_depend(">=app-editors/vim-6.4_alpha",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d1);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d1);
TEST_CHECK_EQUAL(stringify(d1), ">=app-editors/vim-6.4_alpha");
DepSpecPrettyPrinter d2(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
parse_depend("=app-editors/vim-6.4_alpha-r1",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d2);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d2);
TEST_CHECK_EQUAL(stringify(d2), "=app-editors/vim-6.4_alpha-r1");
DepSpecPrettyPrinter d3(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
parse_depend(">=app-editors/vim-6.4_alpha:one",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d3);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d3);
TEST_CHECK_EQUAL(stringify(d3), ">=app-editors/vim-6.4_alpha:one");
}
} test_dep_spec_parser_decorated_package;
@@ -137,11 +154,14 @@ namespace test_cases
void run()
{
StringifyFormatter ff;
+ TestEnvironment env;
+ tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
+ env.package_database()->add_repository(1, repo);
+ tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1"));
DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
parse_depend("app-editors/vim app-misc/hilite \nsys-apps/findutils",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "app-editors/vim app-misc/hilite sys-apps/findutils");
}
} test_dep_spec_parser_packages;
@@ -153,11 +173,14 @@ namespace test_cases
void run()
{
StringifyFormatter ff;
+ TestEnvironment env;
+ tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
+ env.package_database()->add_repository(1, repo);
+ tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1"));
DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
parse_depend("|| ( one/one two/two )",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "|| ( one/one two/two )");
}
} test_dep_spec_parser_any;
@@ -169,21 +192,22 @@ namespace test_cases
void run()
{
StringifyFormatter ff;
+ TestEnvironment env;
+ tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
+ env.package_database()->add_repository(1, repo);
+ tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1"));
DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
parse_depend("|| ( one/one foo? ( two/two ) )",
- *EAPIData::get_instance()->eapi_from_string("0"),
- tr1::shared_ptr<const PackageID>())->accept(d);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("0"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "|| ( one/one foo? ( two/two ) )");
TEST_CHECK_THROWS(parse_depend("|| ( one/one foo? ( two/two ) )",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
DepSpecPrettyPrinter e(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
parse_depend("|| ( one/one ( foo? ( two/two ) ) )",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(e);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(e);
TEST_CHECK_EQUAL(stringify(e), "|| ( one/one ( foo? ( two/two ) ) )");
}
} test_dep_spec_parser_any_use;
@@ -199,11 +223,14 @@ namespace test_cases
void run()
{
StringifyFormatter ff;
+ TestEnvironment env;
+ tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
+ env.package_database()->add_repository(1, repo);
+ tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1"));
DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
parse_depend(" ( one/one two/two ) ",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "one/one two/two");
}
} test_dep_spec_parser_all;
@@ -219,10 +246,13 @@ namespace test_cases
void run()
{
StringifyFormatter ff;
+ TestEnvironment env;
+ tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
+ env.package_database()->add_repository(1, repo);
+ tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1"));
DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
- parse_depend("foo? ( one/one )", *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d);
+ parse_depend("foo? ( one/one )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "foo? ( one/one )");
}
} test_dep_spec_parser_use;
@@ -238,10 +268,13 @@ namespace test_cases
void run()
{
StringifyFormatter ff;
+ TestEnvironment env;
+ tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
+ env.package_database()->add_repository(1, repo);
+ tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1"));
DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
- parse_depend("!foo? ( one/one )", *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d);
+ parse_depend("!foo? ( one/one )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "!foo? ( one/one )");
}
} test_dep_spec_parser_inv_use;
@@ -253,17 +286,21 @@ namespace test_cases
void run()
{
StringifyFormatter ff;
+ TestEnvironment env;
+ tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
+ env.package_database()->add_repository(1, repo);
+ tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1"));
DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, true);
- parse_fetchable_uri("a\n->\tb", *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
+ parse_fetchable_uri("a\n->\tb", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "a -> b\n");
DepSpecPrettyPrinter e(0, tr1::shared_ptr<const PackageID>(), ff, 0, true);
- parse_fetchable_uri("a-> b", *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(e);
+ parse_fetchable_uri("a-> b", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(e);
TEST_CHECK_EQUAL(stringify(e), "a->\nb\n");
TEST_CHECK_THROWS(parse_fetchable_uri("a -> b",
- *EAPIData::get_instance()->eapi_from_string("0"))->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("0"))->accept(d), DepStringError);
}
} test_dep_spec_parser_uri;
@@ -278,23 +315,22 @@ namespace test_cases
void run()
{
StringifyFormatter ff;
+ TestEnvironment env;
+ tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
+ env.package_database()->add_repository(1, repo);
+ tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1"));
DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
TEST_CHECK_THROWS(parse_depend("!foo? ( one/one",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(parse_depend("!foo? ( one/one ) )",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(parse_depend("( ( ( ) )",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(parse_depend("( ( ( ) ) ) )",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(parse_depend(")",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
}
} test_dep_spec_parser_bad_nesting;
@@ -309,48 +345,47 @@ namespace test_cases
void run()
{
StringifyFormatter ff;
+ TestEnvironment env;
+ tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
+ env.package_database()->add_repository(1, repo);
+ tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1"));
DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
TEST_CHECK_THROWS(parse_depend("||",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(parse_depend("|| ",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(parse_depend("foo?",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ TEST_CHECK_THROWS(parse_depend("!? ( )",
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(parse_depend("!foo? ||",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(parse_depend("(((",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(parse_depend(")",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(parse_depend("(foo/bar)",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(parse_license("a -> b",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(parse_fetchable_uri("( -> )",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(parse_fetchable_uri("( -> )",
- *EAPIData::get_instance()->eapi_from_string("0"))->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("0"))->accept(d), DepStringError);
TEST_CHECK_THROWS(parse_fetchable_uri("foo? -> bar",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(parse_fetchable_uri("a ->",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(parse_fetchable_uri("a -> ( )",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(parse_fetchable_uri("a -> )",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(parse_fetchable_uri("a -> || ( )",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(parse_fetchable_uri("a -> foo? ( )",
- *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
}
} test_dep_spec_parser_bad_values;
@@ -364,15 +399,17 @@ namespace test_cases
void run()
{
StringifyFormatter ff;
+ TestEnvironment env;
+ tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
+ env.package_database()->add_repository(1, repo);
+ tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1"));
DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
parse_depend("build: one/one",
- *EAPIData::get_instance()->eapi_from_string("exheres-0"),
- tr1::shared_ptr<const PackageID>())->accept(d);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("exheres-0"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "build: one/one");
TEST_CHECK_THROWS(parse_depend("build: one/one",
- *EAPIData::get_instance()->eapi_from_string("0"),
- tr1::shared_ptr<const PackageID>())->accept(d), DepStringParseError);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("0"))->accept(d), DepStringParseError);
}
} test_dep_spec_parser_labels;
}
diff --git a/paludis/repositories/e/dep_spec_pretty_printer.cc b/paludis/repositories/e/dep_spec_pretty_printer.cc
index c7132e3..34030c7 100644
--- a/paludis/repositories/e/dep_spec_pretty_printer.cc
+++ b/paludis/repositories/e/dep_spec_pretty_printer.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
@@ -168,7 +168,7 @@ DepSpecPrettyPrinter::visit_sequence(const AnyDepSpec &,
}
void
-DepSpecPrettyPrinter::visit_sequence(const UseDepSpec & a,
+DepSpecPrettyPrinter::visit_sequence(const ConditionalDepSpec & a,
GenericSpecTree::ConstSequenceIterator cur,
GenericSpecTree::ConstSequenceIterator end)
{
@@ -179,15 +179,10 @@ DepSpecPrettyPrinter::visit_sequence(const UseDepSpec & a,
else if (_imp->need_space)
_imp->s << " ";
- if (_imp->env && _imp->id)
- {
- if (_imp->env->query_use(a.flag(), *_imp->id))
- _imp->s << _imp->formatter.format(a, format::Enabled()) << " (";
- else
- _imp->s << _imp->formatter.format(a, format::Disabled()) << " (";
- }
+ if (a.condition_met())
+ _imp->s << _imp->formatter.format(a, format::Enabled()) << " (";
else
- _imp->s << _imp->formatter.format(a, format::Plain()) << " (";
+ _imp->s << _imp->formatter.format(a, format::Disabled()) << " (";
if (_imp->use_newlines)
_imp->s << _imp->formatter.newline();
diff --git a/paludis/repositories/e/dep_spec_pretty_printer.hh b/paludis/repositories/e/dep_spec_pretty_printer.hh
index fb2918a..092294c 100644
--- a/paludis/repositories/e/dep_spec_pretty_printer.hh
+++ b/paludis/repositories/e/dep_spec_pretty_printer.hh
@@ -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
@@ -92,7 +92,7 @@ namespace paludis
GenericSpecTree::ConstSequenceIterator,
GenericSpecTree::ConstSequenceIterator);
- void visit_sequence(const UseDepSpec &,
+ void visit_sequence(const ConditionalDepSpec &,
GenericSpecTree::ConstSequenceIterator,
GenericSpecTree::ConstSequenceIterator);
diff --git a/paludis/repositories/e/dep_spec_pretty_printer_TEST.cc b/paludis/repositories/e/dep_spec_pretty_printer_TEST.cc
index 0f51a5b..1afbee3 100644
--- a/paludis/repositories/e/dep_spec_pretty_printer_TEST.cc
+++ b/paludis/repositories/e/dep_spec_pretty_printer_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 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 <paludis/repositories/e/eapi.hh>
#include <paludis/stringify_formatter.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/environments/test/test_environment.hh>
+#include <paludis/repositories/fake/fake_repository.hh>
+#include <paludis/repositories/fake/fake_package_id.hh>
+#include <paludis/package_database.hh>
#include <test/test_runner.hh>
#include <test/test_framework.hh>
@@ -38,33 +42,34 @@ namespace test_cases
void run()
{
StringifyFormatter ff;
+ TestEnvironment env;
+ tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
+ env.package_database()->add_repository(1, repo);
+ tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1"));
DepSpecPrettyPrinter p1(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
- parse_depend("foo/bar bar/baz", *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(p1);
+ parse_depend("foo/bar bar/baz", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p1);
TEST_CHECK_STRINGIFY_EQUAL(p1, "foo/bar bar/baz");
DepSpecPrettyPrinter p2(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
- parse_depend("foo/bar moo? ( bar/baz )", *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(p2);
+ parse_depend("foo/bar moo? ( bar/baz )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p2);
TEST_CHECK_STRINGIFY_EQUAL(p2, "foo/bar moo? ( bar/baz )");
DepSpecPrettyPrinter p3(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
- parse_depend("|| ( a/b ( c/d e/f ) )", *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(p3);
+ parse_depend("|| ( a/b ( c/d e/f ) )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p3);
TEST_CHECK_STRINGIFY_EQUAL(p3, "|| ( a/b ( c/d e/f ) )");
DepSpecPrettyPrinter p4(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
- parse_license("( ( ( ) a ) b )", *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p4);
+ parse_license("( ( ( ) a ) b )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p4);
TEST_CHECK_STRINGIFY_EQUAL(p4, "a b");
DepSpecPrettyPrinter p5(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
- parse_fetchable_uri("( a -> b c x? ( d e ) )", *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p5);
+ parse_fetchable_uri("( a -> b c x? ( d e ) )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p5);
TEST_CHECK_STRINGIFY_EQUAL(p5, "a -> b c x? ( d e )");
DepSpecPrettyPrinter p6(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
parse_fetchable_uri("a manual: b x? ( c mirrors-first: d manual: e ) f",
- *EAPIData::get_instance()->eapi_from_string("exheres-0"))->accept(p6);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("exheres-0"))->accept(p6);
TEST_CHECK_STRINGIFY_EQUAL(p6, "a manual: b x? ( c mirrors-first: d manual: e ) f");
}
} test_pretty_printer_no_indent;
@@ -76,30 +81,31 @@ namespace test_cases
void run()
{
StringifyFormatter ff;
+ TestEnvironment env;
+ tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
+ env.package_database()->add_repository(1, repo);
+ tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1"));
DepSpecPrettyPrinter p1(0, tr1::shared_ptr<const PackageID>(), ff, 1, true);
- parse_depend("foo/bar bar/baz", *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(p1);
+ parse_depend("foo/bar bar/baz", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p1);
TEST_CHECK_STRINGIFY_EQUAL(p1, " foo/bar\n bar/baz\n");
DepSpecPrettyPrinter p2(0, tr1::shared_ptr<const PackageID>(), ff, 1, true);
- parse_depend("foo/bar moo? ( bar/baz )", *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(p2);
+ parse_depend("foo/bar moo? ( bar/baz )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p2);
TEST_CHECK_STRINGIFY_EQUAL(p2, " foo/bar\n moo? (\n bar/baz\n )\n");
DepSpecPrettyPrinter p3(0, tr1::shared_ptr<const PackageID>(), ff, 1, true);
- parse_depend("|| ( a/b ( c/d e/f ) )", *EAPIData::get_instance()->eapi_from_string("paludis-1"),
- tr1::shared_ptr<const PackageID>())->accept(p3);
+ parse_depend("|| ( a/b ( c/d e/f ) )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p3);
TEST_CHECK_STRINGIFY_EQUAL(p3, " || (\n a/b\n (\n c/d\n"
" e/f\n )\n )\n");
DepSpecPrettyPrinter p4(0, tr1::shared_ptr<const PackageID>(), ff, 1, true);
- parse_license("( ( ( ) a ) b )", *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p4);
+ parse_license("( ( ( ) a ) b )", &env, id, *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p4);
TEST_CHECK_STRINGIFY_EQUAL(p4, " a\n b\n");
DepSpecPrettyPrinter p5(0, tr1::shared_ptr<const PackageID>(), ff, 1, true);
parse_fetchable_uri("a manual: b x? ( c mirrors-first: d manual: e ) f",
- *EAPIData::get_instance()->eapi_from_string("exheres-0"))->accept(p5);
+ &env, id, *EAPIData::get_instance()->eapi_from_string("exheres-0"))->accept(p5);
TEST_CHECK_STRINGIFY_EQUAL(p5, " a\n manual:\n b\n x? (\n c\n"
" mirrors-first:\n d\n manual:\n e\n )\n f\n");
}
diff --git a/paludis/repositories/e/dependencies_rewriter.cc b/paludis/repositories/e/dependencies_rewriter.cc
index 06e9680..56659da 100644
--- a/paludis/repositories/e/dependencies_rewriter.cc
+++ b/paludis/repositories/e/dependencies_rewriter.cc
@@ -149,7 +149,7 @@ DependenciesRewriter::visit_sequence(const AnyDepSpec &,
}
void
-DependenciesRewriter::visit_sequence(const UseDepSpec & spec,
+DependenciesRewriter::visit_sequence(const ConditionalDepSpec & spec,
DependencySpecTree::ConstSequenceIterator cur,
DependencySpecTree::ConstSequenceIterator end)
{
diff --git a/paludis/repositories/e/dependencies_rewriter.hh b/paludis/repositories/e/dependencies_rewriter.hh
index 333d941..1b74b6e 100644
--- a/paludis/repositories/e/dependencies_rewriter.hh
+++ b/paludis/repositories/e/dependencies_rewriter.hh
@@ -51,7 +51,7 @@ namespace paludis
DependencySpecTree::ConstSequenceIterator,
DependencySpecTree::ConstSequenceIterator);
- void visit_sequence(const UseDepSpec &,
+ void visit_sequence(const ConditionalDepSpec &,
DependencySpecTree::ConstSequenceIterator,
DependencySpecTree::ConstSequenceIterator);
diff --git a/paludis/repositories/e/distfiles_size_visitor.cc b/paludis/repositories/e/distfiles_size_visitor.cc
index 15ced88..c0e2456 100644
--- a/paludis/repositories/e/distfiles_size_visitor.cc
+++ b/paludis/repositories/e/distfiles_size_visitor.cc
@@ -93,11 +93,11 @@ DistfilesSizeVisitor::~DistfilesSizeVisitor()
}
void
-DistfilesSizeVisitor::visit_sequence(const UseDepSpec & u,
+DistfilesSizeVisitor::visit_sequence(const ConditionalDepSpec & u,
FetchableURISpecTree::ConstSequenceIterator cur,
FetchableURISpecTree::ConstSequenceIterator end)
{
- if (_imp->env->query_use(u.flag(), *_imp->id) ^ u.inverse())
+ if (u.condition_met())
{
_imp->labels.push_front(* _imp->labels.begin());
std::for_each(cur, end, accept_visitor(*this));
diff --git a/paludis/repositories/e/distfiles_size_visitor.hh b/paludis/repositories/e/distfiles_size_visitor.hh
index 00a98b9..1b82e7f 100644
--- a/paludis/repositories/e/distfiles_size_visitor.hh
+++ b/paludis/repositories/e/distfiles_size_visitor.hh
@@ -55,7 +55,7 @@ namespace paludis
FetchableURISpecTree::ConstSequenceIterator,
FetchableURISpecTree::ConstSequenceIterator);
- void visit_sequence(const UseDepSpec &,
+ void visit_sequence(const ConditionalDepSpec &,
FetchableURISpecTree::ConstSequenceIterator,
FetchableURISpecTree::ConstSequenceIterator);
diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc
index b71edef..e154599 100644
--- a/paludis/repositories/e/e_installed_repository_id.cc
+++ b/paludis/repositories/e/e_installed_repository_id.cc
@@ -222,7 +222,7 @@ EInstalledRepositoryID::need_keys_added() const
if ((_imp->dir / vars->metadata_dependencies).exists())
{
DependenciesRewriter rewriter;
- parse_depend(file_contents(_imp->dir / vars->metadata_dependencies), *eapi(), shared_from_this())->accept(rewriter);
+ parse_depend(file_contents(_imp->dir / vars->metadata_dependencies), _imp->environment, shared_from_this(), *eapi())->accept(rewriter);
_imp->build_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_dependencies + ".DEPEND",
vars->description_dependencies + " (build)", rewriter.depend(), _imp->build_dependencies_labels, mkt_dependencies));
diff --git a/paludis/repositories/e/e_key.cc b/paludis/repositories/e/e_key.cc
index b5326ff..3deac00 100644
--- a/paludis/repositories/e/e_key.cc
+++ b/paludis/repositories/e/e_key.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 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
@@ -130,7 +130,7 @@ EDependenciesKey::value() const
}
Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
- _imp->value = parse_depend(_imp->string_value, *_imp->id->eapi(), _imp->id);
+ _imp->value = parse_depend(_imp->string_value, _imp->env, _imp->id, *_imp->id->eapi());
return _imp->value;
}
@@ -209,7 +209,7 @@ ELicenseKey::value() const
}
Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
- _imp->value = parse_license(_imp->string_value, *_imp->id->eapi());
+ _imp->value = parse_license(_imp->string_value, _imp->env, _imp->id, *_imp->id->eapi());
return _imp->value;
}
@@ -274,7 +274,7 @@ EFetchableURIKey::value() const
return _imp->value;
Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
- _imp->value = parse_fetchable_uri(_imp->string_value, *_imp->id->eapi());
+ _imp->value = parse_fetchable_uri(_imp->string_value, _imp->env, _imp->id, *_imp->id->eapi());
return _imp->value;
}
@@ -303,7 +303,7 @@ EFetchableURIKey::initial_label() const
if (! _imp->initial_label)
{
- DepSpecFlattener<RestrictSpecTree, PlainTextDepSpec> f(_imp->env, *_imp->id);
+ DepSpecFlattener<RestrictSpecTree, PlainTextDepSpec> f(_imp->env);
if (_imp->id->restrict_key())
_imp->id->restrict_key()->value()->accept(f);
for (DepSpecFlattener<RestrictSpecTree, PlainTextDepSpec>::ConstIterator i(f.begin()), i_end(f.end()) ;
@@ -374,7 +374,7 @@ ESimpleURIKey::value() const
return _imp->value;
Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
- _imp->value = parse_simple_uri(_imp->string_value, *_imp->id->eapi());
+ _imp->value = parse_simple_uri(_imp->string_value, _imp->env, _imp->id, *_imp->id->eapi());
return _imp->value;
}
@@ -438,7 +438,7 @@ ERestrictKey::value() const
return _imp->value;
Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
- _imp->value = parse_restrict(_imp->string_value, *_imp->id->eapi());
+ _imp->value = parse_restrict(_imp->string_value, _imp->env, _imp->id, *_imp->id->eapi());
return _imp->value;
}
@@ -501,7 +501,7 @@ EProvideKey::value() const
return _imp->value;
Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
- _imp->value = parse_provide(_imp->string_value, *_imp->id->eapi());
+ _imp->value = parse_provide(_imp->string_value, _imp->env, _imp->id, *_imp->id->eapi());
return _imp->value;
}
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc
index e458a9b..f68afcc 100644
--- a/paludis/repositories/e/ebuild.cc
+++ b/paludis/repositories/e/ebuild.cc
@@ -384,7 +384,7 @@ EbuildMetadataCommand::load(const tr1::shared_ptr<const EbuildID> & id)
if (! m.metadata_dependencies.empty())
{
DependenciesRewriter rewriter;
- parse_depend(get(keys, m.metadata_dependencies), *id->eapi(), id)->accept(rewriter);
+ parse_depend(get(keys, m.metadata_dependencies), params.environment, id, *id->eapi())->accept(rewriter);
id->load_build_depend(m.metadata_dependencies + ".DEPEND", m.description_dependencies + " (build)", rewriter.depend());
id->load_run_depend(m.metadata_dependencies + ".RDEPEND", m.description_dependencies + " (run)", rewriter.rdepend());
id->load_post_depend(m.metadata_dependencies + ".PDEPEND", m.description_dependencies + " (post)", rewriter.pdepend());
diff --git a/paludis/repositories/e/ebuild_entries.cc b/paludis/repositories/e/ebuild_entries.cc
index 7eccd92..1410f73 100644
--- a/paludis/repositories/e/ebuild_entries.cc
+++ b/paludis/repositories/e/ebuild_entries.cc
@@ -154,11 +154,11 @@ namespace
_labels.pop_front();
}
- void visit_sequence(const UseDepSpec & u,
+ void visit_sequence(const ConditionalDepSpec & u,
FetchableURISpecTree::ConstSequenceIterator cur,
FetchableURISpecTree::ConstSequenceIterator e)
{
- if (env->query_use(u.flag(), *id) ^ u.inverse())
+ if (u.condition_met())
{
_labels.push_front(*_labels.begin());
std::for_each(cur, e, accept_visitor(*this));
@@ -269,7 +269,7 @@ EbuildEntries::fetch(const tr1::shared_ptr<const ERepositoryID> & id,
bool fetch_restrict(false);
{
- DepSpecFlattener<RestrictSpecTree, PlainTextDepSpec> restricts(_imp->params.environment, *id);
+ DepSpecFlattener<RestrictSpecTree, PlainTextDepSpec> restricts(_imp->params.environment);
if (id->restrict_key())
id->restrict_key()->value()->accept(restricts);
@@ -431,7 +431,7 @@ EbuildEntries::install(const tr1::shared_ptr<const ERepositoryID> & id,
bool userpriv_restrict;
{
- DepSpecFlattener<RestrictSpecTree, PlainTextDepSpec> restricts(_imp->params.environment, *id);
+ DepSpecFlattener<RestrictSpecTree, PlainTextDepSpec> restricts(_imp->params.environment);
if (id->restrict_key())
id->restrict_key()->value()->accept(restricts);
diff --git a/paludis/repositories/e/ebuild_flat_metadata_cache.cc b/paludis/repositories/e/ebuild_flat_metadata_cache.cc
index ecdd026..5a6dd7d 100644
--- a/paludis/repositories/e/ebuild_flat_metadata_cache.cc
+++ b/paludis/repositories/e/ebuild_flat_metadata_cache.cc
@@ -41,8 +41,9 @@
using namespace paludis;
using namespace paludis::erepository;
-EbuildFlatMetadataCache::EbuildFlatMetadataCache(const FSEntry & f,
+EbuildFlatMetadataCache::EbuildFlatMetadataCache(const Environment * const v, const FSEntry & f,
const FSEntry & e, time_t t, tr1::shared_ptr<const EclassMtimes> m, bool s) :
+ _env(v),
_filename(f),
_ebuild(e),
_master_mtime(t),
@@ -99,7 +100,7 @@ EbuildFlatMetadataCache::load(const tr1::shared_ptr<const EbuildID> & id)
if (! m.metadata_dependencies.empty())
{
DependenciesRewriter rewriter;
- parse_depend(lines.at(m.flat_cache_dependencies), *id->eapi(), id)->accept(rewriter);
+ parse_depend(lines.at(m.flat_cache_dependencies), _env, id, *id->eapi())->accept(rewriter);
id->load_build_depend(m.metadata_dependencies + ".DEPEND", m.description_dependencies + " (build)", rewriter.depend());
id->load_run_depend(m.metadata_dependencies + ".RDEPEND", m.description_dependencies + " (run)", rewriter.rdepend());
id->load_post_depend(m.metadata_dependencies + ".PDEPEND", m.description_dependencies + " (post)", rewriter.pdepend());
diff --git a/paludis/repositories/e/ebuild_flat_metadata_cache.hh b/paludis/repositories/e/ebuild_flat_metadata_cache.hh
index 9537741..089af56 100644
--- a/paludis/repositories/e/ebuild_flat_metadata_cache.hh
+++ b/paludis/repositories/e/ebuild_flat_metadata_cache.hh
@@ -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
@@ -41,6 +41,7 @@ namespace paludis
class EbuildFlatMetadataCache
{
private:
+ const Environment * const _env;
const FSEntry & _filename;
const FSEntry & _ebuild;
time_t _master_mtime;
@@ -51,7 +52,7 @@ namespace paludis
///\name Basic operations
///\{
- EbuildFlatMetadataCache(const FSEntry & filename, const FSEntry & ebuild,
+ EbuildFlatMetadataCache(const Environment * const, const FSEntry & filename, const FSEntry & ebuild,
time_t master_mtime, tr1::shared_ptr<const EclassMtimes> eclass_mtimes, bool silent);
///\}
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index 3b745d4..ed2f641 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -170,14 +170,15 @@ EbuildID::need_keys_added() const
bool ok(false);
if (_imp->repository->params().cache.basename() != "empty")
{
- EbuildFlatMetadataCache metadata_cache(cache_file, _imp->ebuild, _imp->master_mtime, _imp->eclass_mtimes, false);
+ EbuildFlatMetadataCache metadata_cache(_imp->environment, cache_file, _imp->ebuild, _imp->master_mtime, _imp->eclass_mtimes, false);
if (metadata_cache.load(shared_from_this()))
ok = true;
}
if ((! ok) && _imp->repository->params().write_cache.basename() != "empty")
{
- EbuildFlatMetadataCache write_metadata_cache(write_cache_file, _imp->ebuild, _imp->master_mtime, _imp->eclass_mtimes, true);
+ EbuildFlatMetadataCache write_metadata_cache(_imp->environment,
+ write_cache_file, _imp->ebuild, _imp->master_mtime, _imp->eclass_mtimes, true);
if (write_metadata_cache.load(shared_from_this()))
ok = true;
else if (write_cache_file.exists())
@@ -243,7 +244,7 @@ EbuildID::need_keys_added() const
if (_imp->repository->params().write_cache.basename() != "empty" && _imp->eapi->supported)
{
- EbuildFlatMetadataCache metadata_cache(write_cache_file, _imp->ebuild, _imp->master_mtime,
+ EbuildFlatMetadataCache metadata_cache(_imp->environment, write_cache_file, _imp->ebuild, _imp->master_mtime,
_imp->eclass_mtimes, false);
metadata_cache.save(shared_from_this());
}
@@ -336,11 +337,11 @@ namespace
ok &= local_ok;
}
- void visit_sequence(const UseDepSpec & spec,
+ void visit_sequence(const ConditionalDepSpec & spec,
LicenseSpecTree::ConstSequenceIterator begin,
LicenseSpecTree::ConstSequenceIterator end)
{
- if (env->query_use(spec.flag(), *id))
+ if (spec.condition_met())
std::for_each(begin, end, accept_visitor(*this));
}
diff --git a/paludis/repositories/e/fetch_visitor.cc b/paludis/repositories/e/fetch_visitor.cc
index 25f4b45..232fd01 100644
--- a/paludis/repositories/e/fetch_visitor.cc
+++ b/paludis/repositories/e/fetch_visitor.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 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
@@ -103,11 +103,11 @@ FetchVisitor::~FetchVisitor()
}
void
-FetchVisitor::visit_sequence(const UseDepSpec & u,
+FetchVisitor::visit_sequence(const ConditionalDepSpec & u,
FetchableURISpecTree::ConstSequenceIterator cur,
FetchableURISpecTree::ConstSequenceIterator end)
{
- if ((_imp->fetch_unneeded) || (_imp->env->query_use(u.flag(), *_imp->id) ^ u.inverse()))
+ if ((_imp->fetch_unneeded) || (u.condition_met()))
{
_imp->labels.push_front(* _imp->labels.begin());
std::for_each(cur, end, accept_visitor(*this));
diff --git a/paludis/repositories/e/fetch_visitor.hh b/paludis/repositories/e/fetch_visitor.hh
index d3362df..c25e08a 100644
--- a/paludis/repositories/e/fetch_visitor.hh
+++ b/paludis/repositories/e/fetch_visitor.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
@@ -57,7 +57,7 @@ namespace paludis
FetchableURISpecTree::ConstSequenceIterator,
FetchableURISpecTree::ConstSequenceIterator);
- void visit_sequence(const UseDepSpec &,
+ void visit_sequence(const ConditionalDepSpec &,
FetchableURISpecTree::ConstSequenceIterator,
FetchableURISpecTree::ConstSequenceIterator);
diff --git a/paludis/repositories/e/fetch_visitor_TEST.cc b/paludis/repositories/e/fetch_visitor_TEST.cc
index 11bbf72..3f5125b 100644
--- a/paludis/repositories/e/fetch_visitor_TEST.cc
+++ b/paludis/repositories/e/fetch_visitor_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 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
@@ -21,6 +21,7 @@
#include <paludis/repositories/e/eapi.hh>
#include <paludis/repositories/e/dep_parser.hh>
#include <paludis/repositories/fake/fake_repository.hh>
+#include <paludis/repositories/fake/fake_package_id.hh>
#include <paludis/environments/test/test_environment.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/make_shared_ptr.hh>
@@ -47,7 +48,7 @@ namespace test_cases
TestEnvironment env;
const tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(1, repo);
- repo->add_version("cat", "pkg", "1");
+ tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1"));
TEST_CHECK(FSEntry("fetch_visitor_TEST_dir/in/input1").exists());
TEST_CHECK(! FSEntry("fetch_visitor_TEST_dir/out/input1").exists());
@@ -57,7 +58,7 @@ namespace test_cases
qo_require_exactly_one)->begin(),
*eapi, FSEntry("fetch_visitor_TEST_dir/out"),
false, false, "test", make_shared_ptr(new URIListedThenMirrorsLabel("listed-then-mirrors")), false);
- parse_fetchable_uri("file:///" + stringify(FSEntry("fetch_visitor_TEST_dir/in/input1").realpath()), *eapi)->accept(v);
+ parse_fetchable_uri("file:///" + stringify(FSEntry("fetch_visitor_TEST_dir/in/input1").realpath()), &env, id, *eapi)->accept(v);
TEST_CHECK(FSEntry("fetch_visitor_TEST_dir/out/input1").is_regular_file());
std::ifstream f(stringify(FSEntry("fetch_visitor_TEST_dir/out/input1")).c_str());
diff --git a/paludis/repositories/e/qa/extractors.cc b/paludis/repositories/e/qa/extractors.cc
index b567d4c..a606557 100644
--- a/paludis/repositories/e/qa/extractors.cc
+++ b/paludis/repositories/e/qa/extractors.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 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
@@ -32,6 +32,7 @@
#include <paludis/util/log.hh>
#include <paludis/util/instantiation_policy-impl.hh>
#include <paludis/util/tr1_functional.hh>
+#include <paludis/repositories/e/conditional_dep_spec.hh>
#include <algorithm>
#include <map>
#include <set>
@@ -107,12 +108,12 @@ namespace
{
}
- void visit_sequence(const UseDepSpec & u,
+ void visit_sequence(const ConditionalDepSpec & u,
GenericSpecTree::ConstSequenceIterator cur,
GenericSpecTree::ConstSequenceIterator end)
{
Save<std::set<UseFlagName> > save_current(&current);
- current.insert(u.flag());
+ current.insert(conditional_dep_spec_flag(u));
std::for_each(cur, end, accept_visitor(*this));
}
@@ -224,13 +225,14 @@ namespace
using ConstVisitor<GenericSpecTree>::VisitConstSequence<Requirements, AllDepSpec>::visit_sequence;
- void visit_sequence(const UseDepSpec & u,
+ void visit_sequence(const ConditionalDepSpec & u,
GenericSpecTree::ConstSequenceIterator cur,
GenericSpecTree::ConstSequenceIterator end)
{
Save<std::map<UseFlagName, bool> > save_current(&current);
- std::pair<std::map<UseFlagName, bool>::const_iterator, bool> p(current.insert(std::make_pair(u.flag(), !u.inverse())));
- if (p.second || (p.first->second == !u.inverse()))
+ std::pair<std::map<UseFlagName, bool>::const_iterator, bool> p(current.insert(std::make_pair(
+ conditional_dep_spec_flag(u), ! conditional_dep_spec_is_inverse(u))));
+ if (p.second || (p.first->second == ! conditional_dep_spec_is_inverse(u)))
std::for_each(cur, end, accept_visitor(*this));
}
diff --git a/paludis/repositories/e/qa/fetches_key.cc b/paludis/repositories/e/qa/fetches_key.cc
index f7c3dc9..eae5aa6 100644
--- a/paludis/repositories/e/qa/fetches_key.cc
+++ b/paludis/repositories/e/qa/fetches_key.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007 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
@@ -173,7 +173,7 @@ namespace
std::for_each(begin, end, accept_visitor(*this));
}
- void visit_sequence(const UseDepSpec &,
+ void visit_sequence(const ConditionalDepSpec &,
FetchableURISpecTree::ConstSequenceIterator begin,
FetchableURISpecTree::ConstSequenceIterator end)
{
diff --git a/paludis/repositories/e/qa/homepage_key.cc b/paludis/repositories/e/qa/homepage_key.cc
index a6b1f42..0f7152b 100644
--- a/paludis/repositories/e/qa/homepage_key.cc
+++ b/paludis/repositories/e/qa/homepage_key.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 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
@@ -36,9 +36,9 @@ namespace
struct HomepageChecker :
ConstVisitor<SimpleURISpecTree>,
ConstVisitor<SimpleURISpecTree>::VisitConstSequence<HomepageChecker, AllDepSpec>,
- ConstVisitor<SimpleURISpecTree>::VisitConstSequence<HomepageChecker, UseDepSpec>
+ ConstVisitor<SimpleURISpecTree>::VisitConstSequence<HomepageChecker, ConditionalDepSpec>
{
- using ConstVisitor<SimpleURISpecTree>::VisitConstSequence<HomepageChecker, UseDepSpec>::visit_sequence;
+ using ConstVisitor<SimpleURISpecTree>::VisitConstSequence<HomepageChecker, ConditionalDepSpec>::visit_sequence;
using ConstVisitor<SimpleURISpecTree>::VisitConstSequence<HomepageChecker, AllDepSpec>::visit_sequence;
const tr1::shared_ptr<const MetadataKey> & key;
diff --git a/paludis/repositories/e/qa/license_key.cc b/paludis/repositories/e/qa/license_key.cc
index 9212969..4fec298 100644
--- a/paludis/repositories/e/qa/license_key.cc
+++ b/paludis/repositories/e/qa/license_key.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007 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
@@ -39,7 +39,7 @@ namespace
ConstVisitor<LicenseSpecTree>,
ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, AllDepSpec>,
ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, AnyDepSpec>,
- ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, UseDepSpec>
+ ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, ConditionalDepSpec>
{
const FSEntry & entry;
QAReporter & reporter;
@@ -59,7 +59,7 @@ namespace
using ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, AllDepSpec>::visit_sequence;
using ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, AnyDepSpec>::visit_sequence;
- using ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, UseDepSpec>::visit_sequence;
+ using ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, ConditionalDepSpec>::visit_sequence;
void visit_leaf(const LicenseDepSpec & l)
{
diff --git a/paludis/repositories/e/qa/manifest.cc b/paludis/repositories/e/qa/manifest.cc
index 62e06cc..e569e5e 100644
--- a/paludis/repositories/e/qa/manifest.cc
+++ b/paludis/repositories/e/qa/manifest.cc
@@ -53,13 +53,13 @@ namespace
struct DistfilesCollector :
ConstVisitor<FetchableURISpecTree>,
ConstVisitor<FetchableURISpecTree>::VisitConstSequence<DistfilesCollector, AllDepSpec>,
- ConstVisitor<FetchableURISpecTree>::VisitConstSequence<DistfilesCollector, UseDepSpec>
+ ConstVisitor<FetchableURISpecTree>::VisitConstSequence<DistfilesCollector, ConditionalDepSpec>
{
tr1::shared_ptr<const PackageID> id;
std::map<std::string, tr1::shared_ptr<PackageIDSet> > & distfiles;
using ConstVisitor<FetchableURISpecTree>::VisitConstSequence<DistfilesCollector, AllDepSpec>::visit_sequence;
- using ConstVisitor<FetchableURISpecTree>::VisitConstSequence<DistfilesCollector, UseDepSpec>::visit_sequence;
+ using ConstVisitor<FetchableURISpecTree>::VisitConstSequence<DistfilesCollector, ConditionalDepSpec>::visit_sequence;
DistfilesCollector(const tr1::shared_ptr<const PackageID> & i,
std::map<std::string, tr1::shared_ptr<PackageIDSet> > & d) :
diff --git a/paludis/repositories/e/qa/restrict_key.cc b/paludis/repositories/e/qa/restrict_key.cc
index d1ee362..02e8bb5 100644
--- a/paludis/repositories/e/qa/restrict_key.cc
+++ b/paludis/repositories/e/qa/restrict_key.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007 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
@@ -56,9 +56,9 @@ namespace
struct RestrictChecker :
ConstVisitor<RestrictSpecTree>,
ConstVisitor<RestrictSpecTree>::VisitConstSequence<RestrictChecker, AllDepSpec>,
- ConstVisitor<RestrictSpecTree>::VisitConstSequence<RestrictChecker, UseDepSpec>
+ ConstVisitor<RestrictSpecTree>::VisitConstSequence<RestrictChecker, ConditionalDepSpec>
{
- using ConstVisitor<RestrictSpecTree>::VisitConstSequence<RestrictChecker, UseDepSpec>::visit_sequence;
+ using ConstVisitor<RestrictSpecTree>::VisitConstSequence<RestrictChecker, ConditionalDepSpec>::visit_sequence;
using ConstVisitor<RestrictSpecTree>::VisitConstSequence<RestrictChecker, AllDepSpec>::visit_sequence;
const std::set<std::string> & allowed_restricts;
diff --git a/paludis/repositories/e/qa/spec_keys.cc b/paludis/repositories/e/qa/spec_keys.cc
index a179604..d3e8dd7 100644
--- a/paludis/repositories/e/qa/spec_keys.cc
+++ b/paludis/repositories/e/qa/spec_keys.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 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
@@ -38,6 +38,7 @@
#include <paludis/util/log.hh>
#include <paludis/util/instantiation_policy-impl.hh>
#include <paludis/util/create_iterator-impl.hh>
+#include <paludis/repositories/e/conditional_dep_spec.hh>
#include <algorithm>
#include <map>
#include <set>
@@ -170,7 +171,7 @@ namespace
{
}
- void visit_sequence(const UseDepSpec & u,
+ void visit_sequence(const ConditionalDepSpec & u,
GenericSpecTree::ConstSequenceIterator cur,
GenericSpecTree::ConstSequenceIterator end)
{
@@ -181,34 +182,34 @@ namespace
.with_associated_id(id)
.with_associated_key(id, key));
- if (uses.count(u.flag()))
+ if (uses.count(conditional_dep_spec_flag(u)))
reporter.message(QAMessage(entry, qaml_normal, name,
- "Recursive use of flag '" + stringify(u.flag()) + "' in '"
+ "Recursive use of flag '" + stringify(conditional_dep_spec_flag(u)) + "' in '"
+ stringify(key->raw_name()) + "'")
.with_associated_id(id)
.with_associated_key(id, key));
- if (id->repository()->use_interface->arch_flags()->count(u.flag()))
+ if (id->repository()->use_interface->arch_flags()->count(conditional_dep_spec_flag(u)))
{
if (forbid_arch_flags)
reporter.message(QAMessage(entry, qaml_normal, name,
- "Arch flag '" + stringify(u.flag()) + "' in '" + stringify(key->raw_name()) + "'")
+ "Arch flag '" + stringify(conditional_dep_spec_flag(u)) + "' in '" + stringify(key->raw_name()) + "'")
.with_associated_id(id)
.with_associated_key(id, key));
- else if (u.inverse() && forbid_inverse_arch_flags)
+ else if (conditional_dep_spec_is_inverse(u) && forbid_inverse_arch_flags)
reporter.message(QAMessage(entry, qaml_maybe, name,
- "Inverse arch flag '" + stringify(u.flag()) + "' in '" + stringify(key->raw_name()) + "'")
+ "Inverse arch flag '" + stringify(conditional_dep_spec_flag(u)) + "' in '" + stringify(key->raw_name()) + "'")
.with_associated_id(id)
.with_associated_key(id, key));
}
else
{
- if (iuse_flags.end() == iuse_flags.find(u.flag()))
+ if (iuse_flags.end() == iuse_flags.find(conditional_dep_spec_flag(u)))
{
std::tr1::shared_ptr<const UseFlagNameSet> c(
id->repository()->use_interface->use_expand_hidden_prefixes());
- std::string flag(stringify(u.flag()));
+ std::string flag(stringify(conditional_dep_spec_flag(u)));
bool is_hidden(false);
for (UseFlagNameSet::ConstIterator i(c->begin()), i_end(c->end()) ;
@@ -224,7 +225,7 @@ namespace
if (! is_hidden)
reporter.message(QAMessage(entry, qaml_normal, name,
- "Conditional flag '" + stringify(u.flag()) +
+ "Conditional flag '" + stringify(conditional_dep_spec_flag(u)) +
"' in '" + stringify(key->raw_name()) + "' not in '" +
stringify(id->iuse_key()->raw_name()) + "'")
.with_associated_id(id)
@@ -236,7 +237,7 @@ namespace
Save<unsigned> save_level(&level, level + 1);
Save<bool> save_child_of_any(&child_of_any, false);
Save<std::set<UseFlagName> > save_uses(&uses, uses);
- uses.insert(u.flag());
+ uses.insert(conditional_dep_spec_flag(u));
if (cur == end)
reporter.message(QAMessage(entry, qaml_normal, name,
"Empty 'use? ( )' in '" + stringify(key->raw_name()) + "'")
diff --git a/paludis/repositories/e/qa/visibility.cc b/paludis/repositories/e/qa/visibility.cc
index 87736cc..83c2e8d 100644
--- a/paludis/repositories/e/qa/visibility.cc
+++ b/paludis/repositories/e/qa/visibility.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 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
@@ -19,6 +19,7 @@
#include <paludis/repositories/e/qa/visibility.hh>
#include <paludis/repositories/e/dep_spec_pretty_printer.hh>
+#include <paludis/repositories/e/conditional_dep_spec.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/tokeniser.hh>
@@ -40,6 +41,7 @@
#include <algorithm>
using namespace paludis;
+using namespace paludis::erepository;
namespace
{
@@ -196,13 +198,13 @@ namespace
}
}
- void visit_sequence(const UseDepSpec & u,
+ void visit_sequence(const ConditionalDepSpec & u,
DependencySpecTree::ConstSequenceIterator cur,
DependencySpecTree::ConstSequenceIterator end)
{
viable =
- ((! u.inverse()) && (! repo->query_use_mask(u.flag(), *id))) ||
- ((u.inverse()) && (! repo->query_use_force(u.flag(), *id)));
+ ((! conditional_dep_spec_is_inverse(u)) && (! repo->query_use_mask(conditional_dep_spec_flag(u), *id))) ||
+ ((conditional_dep_spec_is_inverse(u)) && (! repo->query_use_force(conditional_dep_spec_flag(u), *id)));
if (viable)
std::for_each(cur, end, accept_visitor(*this));
@@ -232,7 +234,7 @@ namespace
if (reporter)
{
StringifyFormatter ff;
- erepository::DepSpecPrettyPrinter printer(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
+ DepSpecPrettyPrinter printer(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
std::for_each(begin, end, accept_visitor(printer));
reporter->message(QAMessage(entry, qaml_normal, name, "No item in block '|| ( "
+ stringify(printer) + " )' visible for profile '"
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index 8d6aaa6..0320544 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -529,9 +529,11 @@ VDBRepository::load_provided_using_cache() const
continue;
}
- DepSpecFlattener<ProvideSpecTree, PackageDepSpec> f(_imp->params.environment, *id);
+ DepSpecFlattener<ProvideSpecTree, PackageDepSpec> f(_imp->params.environment);
tr1::shared_ptr<ProvideSpecTree::ConstItem> pp(parse_provide(
- join(next(next(tokens.begin())), tokens.end(), " "), *EAPIData::get_instance()->eapi_from_string("paludis-1")));
+ join(next(next(tokens.begin())), tokens.end(), " "),
+ _imp->params.environment, id,
+ *EAPIData::get_instance()->eapi_from_string("paludis-1")));
pp->accept(f);
for (DepSpecFlattener<ProvideSpecTree, PackageDepSpec>::ConstIterator p(f.begin()), p_end(f.end()) ; p != p_end ; ++p)
@@ -578,7 +580,7 @@ VDBRepository::load_provided_the_slow_way() const
continue;
tr1::shared_ptr<const ProvideSpecTree::ConstItem> provide((*e)->provide_key()->value());;
- DepSpecFlattener<ProvideSpecTree, PackageDepSpec> f(_imp->params.environment, **e);
+ DepSpecFlattener<ProvideSpecTree, PackageDepSpec> f(_imp->params.environment);
provide->accept(f);
for (DepSpecFlattener<ProvideSpecTree, PackageDepSpec>::ConstIterator
diff --git a/paludis/repositories/fake/fake_installed_repository.cc b/paludis/repositories/fake/fake_installed_repository.cc
index 262f4d7..43cb6b2 100644
--- a/paludis/repositories/fake/fake_installed_repository.cc
+++ b/paludis/repositories/fake/fake_installed_repository.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -106,7 +106,7 @@ FakeInstalledRepository::provided_packages() const
if (! (*v)->provide_key())
continue;
- DepSpecFlattener<ProvideSpecTree, PackageDepSpec> f(environment(), **v);
+ DepSpecFlattener<ProvideSpecTree, PackageDepSpec> f(environment());
(*v)->provide_key()->value()->accept(f);
for (DepSpecFlattener<ProvideSpecTree, PackageDepSpec>::ConstIterator q(f.begin()), q_end(f.end()) ; q != q_end ; ++q)
diff --git a/paludis/repositories/fake/fake_package_id.cc b/paludis/repositories/fake/fake_package_id.cc
index 9210212..9a985d0 100644
--- a/paludis/repositories/fake/fake_package_id.cc
+++ b/paludis/repositories/fake/fake_package_id.cc
@@ -403,18 +403,6 @@ namespace paludis
keywords(new FakeMetadataKeywordSetKey("KEYWORDS", "Keywords", "test", mkt_normal, id, env)),
iuse(new FakeMetadataIUseSetKey("IUSE", "Used USE flags", "",
erepository::EAPIData::get_instance()->eapi_from_string(eapi)->supported->iuse_flag_parse_options, mkt_normal, id, env)),
- license(new FakeMetadataSpecTreeKey<LicenseSpecTree>("LICENSE", "Licenses",
- "", tr1::bind(&erepository::parse_license, _1,
- *erepository::EAPIData::get_instance()->eapi_from_string(eapi)), mkt_normal)),
- provide(new FakeMetadataSpecTreeKey<ProvideSpecTree>("PROVIDE", "Provided packages",
- "", tr1::bind(&erepository::parse_provide, _1,
- *erepository::EAPIData::get_instance()->eapi_from_string(eapi)), mkt_normal)),
- src_uri(new FakeMetadataSpecTreeKey<FetchableURISpecTree>("SRC_URI", "Source URIs",
- "", tr1::bind(&erepository::parse_fetchable_uri, _1,
- *erepository::EAPIData::get_instance()->eapi_from_string(eapi)), mkt_dependencies)),
- homepage(new FakeMetadataSpecTreeKey<SimpleURISpecTree>("HOMEPAGE", "Homepage",
- "", tr1::bind(&erepository::parse_simple_uri, _1,
- *erepository::EAPIData::get_instance()->eapi_from_string(eapi)), mkt_dependencies)),
has_masks(false)
{
build_dependencies_labels->push_back(make_shared_ptr(new DependencyBuildLabel("DEPEND")));
@@ -433,8 +421,6 @@ FakePackageID::FakePackageID(const Environment * const e, const tr1::shared_ptr<
{
add_metadata_key(_imp->keywords);
add_metadata_key(_imp->iuse);
- add_metadata_key(_imp->license);
- add_metadata_key(_imp->provide);
}
FakePackageID::~FakePackageID()
@@ -489,30 +475,35 @@ FakePackageID::repository() const
const tr1::shared_ptr<const MetadataPackageIDKey>
FakePackageID::virtual_for_key() const
{
+ need_keys_added();
return _imp->virtual_for;
}
const tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> >
FakePackageID::keywords_key() const
{
+ need_keys_added();
return _imp->keywords;
}
const tr1::shared_ptr<const MetadataCollectionKey<IUseFlagSet> >
FakePackageID::iuse_key() const
{
+ need_keys_added();
return _imp->iuse;
}
const tr1::shared_ptr<const MetadataSpecTreeKey<LicenseSpecTree> >
FakePackageID::license_key() const
{
+ need_keys_added();
return _imp->license;
}
const tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> >
FakePackageID::provide_key() const
{
+ need_keys_added();
return _imp->provide;
}
@@ -547,18 +538,21 @@ FakePackageID::suggested_dependencies_key() const
const tr1::shared_ptr<FakeMetadataKeywordSetKey>
FakePackageID::keywords_key()
{
+ need_keys_added();
return _imp->keywords;
}
const tr1::shared_ptr<FakeMetadataIUseSetKey>
FakePackageID::iuse_key()
{
+ need_keys_added();
return _imp->iuse;
}
const tr1::shared_ptr<FakeMetadataSpecTreeKey<ProvideSpecTree> >
FakePackageID::provide_key()
{
+ need_keys_added();
return _imp->provide;
}
@@ -593,60 +587,70 @@ FakePackageID::suggested_dependencies_key()
const tr1::shared_ptr<const MetadataSpecTreeKey<FetchableURISpecTree> >
FakePackageID::fetches_key() const
{
+ need_keys_added();
return _imp->src_uri;
}
const tr1::shared_ptr<FakeMetadataSpecTreeKey<FetchableURISpecTree> >
FakePackageID::fetches_key()
{
+ need_keys_added();
return _imp->src_uri;
}
const tr1::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> >
FakePackageID::homepage_key() const
{
+ need_keys_added();
return _imp->homepage;
}
const tr1::shared_ptr<FakeMetadataSpecTreeKey<SimpleURISpecTree> >
FakePackageID::homepage_key()
{
+ need_keys_added();
return _imp->homepage;
}
const tr1::shared_ptr<const MetadataStringKey>
FakePackageID::short_description_key() const
{
+ need_keys_added();
return tr1::shared_ptr<const MetadataStringKey>();
}
const tr1::shared_ptr<const MetadataStringKey>
FakePackageID::long_description_key() const
{
+ need_keys_added();
return tr1::shared_ptr<const MetadataStringKey>();
}
const tr1::shared_ptr<const MetadataContentsKey>
FakePackageID::contents_key() const
{
+ need_keys_added();
return tr1::shared_ptr<const MetadataContentsKey>();
}
const tr1::shared_ptr<const MetadataTimeKey>
FakePackageID::installed_time_key() const
{
+ need_keys_added();
return tr1::shared_ptr<const MetadataTimeKey>();
}
const tr1::shared_ptr<const MetadataStringKey>
FakePackageID::source_origin_key() const
{
+ need_keys_added();
return tr1::shared_ptr<const MetadataStringKey>();
}
const tr1::shared_ptr<const MetadataStringKey>
FakePackageID::binary_origin_key() const
{
+ need_keys_added();
return tr1::shared_ptr<const MetadataStringKey>();
}
@@ -672,29 +676,49 @@ FakePackageID::need_keys_added() const
using namespace tr1::placeholders;
_imp->build_dependencies.reset(new FakeMetadataSpecTreeKey<DependencySpecTree>("DEPEND", "Build dependencies",
- "", tr1::bind(&erepository::parse_depend, _1,
- *erepository::EAPIData::get_instance()->eapi_from_string(_imp->eapi), shared_from_this()),
+ "", tr1::bind(&erepository::parse_depend, _1, _imp->env,
+ shared_from_this(), *erepository::EAPIData::get_instance()->eapi_from_string(_imp->eapi)),
_imp->build_dependencies_labels, mkt_dependencies));
_imp->run_dependencies.reset(new FakeMetadataSpecTreeKey<DependencySpecTree>("RDEPEND", "Run dependencies",
- "", tr1::bind(&erepository::parse_depend, _1,
- *erepository::EAPIData::get_instance()->eapi_from_string(_imp->eapi), shared_from_this()),
+ "", tr1::bind(&erepository::parse_depend, _1, _imp->env,
+ shared_from_this(), *erepository::EAPIData::get_instance()->eapi_from_string(_imp->eapi)),
_imp->run_dependencies_labels, mkt_dependencies)),
_imp->post_dependencies.reset(new FakeMetadataSpecTreeKey<DependencySpecTree>("PDEPEND", "Post dependencies",
- "", tr1::bind(&erepository::parse_depend, _1,
- *erepository::EAPIData::get_instance()->eapi_from_string(_imp->eapi), shared_from_this()),
+ "", tr1::bind(&erepository::parse_depend, _1, _imp->env,
+ shared_from_this(), *erepository::EAPIData::get_instance()->eapi_from_string(_imp->eapi)),
_imp->post_dependencies_labels, mkt_dependencies)),
_imp->suggested_dependencies.reset(new FakeMetadataSpecTreeKey<DependencySpecTree>("SDEPEND", "Suggested dependencies",
- "", tr1::bind(&erepository::parse_depend, _1,
- *erepository::EAPIData::get_instance()->eapi_from_string(_imp->eapi), shared_from_this()),
+ "", tr1::bind(&erepository::parse_depend, _1, _imp->env,
+ shared_from_this(), *erepository::EAPIData::get_instance()->eapi_from_string(_imp->eapi)),
_imp->suggested_dependencies_labels, mkt_dependencies)),
+ _imp->src_uri.reset(new FakeMetadataSpecTreeKey<FetchableURISpecTree>("SRC_URI", "Source URI",
+ "", tr1::bind(&erepository::parse_fetchable_uri, _1, _imp->env,
+ shared_from_this(), *erepository::EAPIData::get_instance()->eapi_from_string(_imp->eapi)), mkt_normal));
+
+ _imp->homepage.reset(new FakeMetadataSpecTreeKey<SimpleURISpecTree>("HOMEPAGE", "Homepage",
+ "", tr1::bind(&erepository::parse_simple_uri, _1, _imp->env,
+ shared_from_this(), *erepository::EAPIData::get_instance()->eapi_from_string(_imp->eapi)), mkt_normal));
+
+ _imp->license.reset(new FakeMetadataSpecTreeKey<LicenseSpecTree>("LICENSE", "License",
+ "", tr1::bind(&erepository::parse_license, _1, _imp->env,
+ shared_from_this(), *erepository::EAPIData::get_instance()->eapi_from_string(_imp->eapi)), mkt_normal));
+
+ _imp->provide.reset(new FakeMetadataSpecTreeKey<ProvideSpecTree>("PROVIDE", "Provide",
+ "", tr1::bind(&erepository::parse_provide, _1, _imp->env,
+ shared_from_this(), *erepository::EAPIData::get_instance()->eapi_from_string(_imp->eapi)), mkt_normal));
+
add_metadata_key(_imp->build_dependencies);
add_metadata_key(_imp->run_dependencies);
add_metadata_key(_imp->post_dependencies);
add_metadata_key(_imp->suggested_dependencies);
+ add_metadata_key(_imp->src_uri);
+ add_metadata_key(_imp->homepage);
+ add_metadata_key(_imp->provide);
+ add_metadata_key(_imp->license);
}
}
@@ -754,11 +778,11 @@ namespace
ok &= local_ok;
}
- void visit_sequence(const UseDepSpec & spec,
+ void visit_sequence(const ConditionalDepSpec & spec,
LicenseSpecTree::ConstSequenceIterator begin,
LicenseSpecTree::ConstSequenceIterator end)
{
- if (env->query_use(spec.flag(), *id))
+ if (spec.condition_met())
std::for_each(begin, end, accept_visitor(*this));
}
diff --git a/paludis/repositories/unpackaged/dep_printer.hh b/paludis/repositories/unpackaged/dep_printer.hh
index f8a75b8..1d43fd8 100644
--- a/paludis/repositories/unpackaged/dep_printer.hh
+++ b/paludis/repositories/unpackaged/dep_printer.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
@@ -34,7 +34,7 @@ namespace paludis
public ConstVisitor<DependencySpecTree>,
public ConstVisitor<DependencySpecTree>::VisitConstSequence<DepPrinter, AllDepSpec>,
public ConstVisitor<DependencySpecTree>::VisitConstSequence<DepPrinter, AnyDepSpec>,
- public ConstVisitor<DependencySpecTree>::VisitConstSequence<DepPrinter, UseDepSpec>,
+ public ConstVisitor<DependencySpecTree>::VisitConstSequence<DepPrinter, ConditionalDepSpec>,
private PrivateImplementationPattern<DepPrinter>
{
public:
@@ -50,7 +50,7 @@ namespace paludis
using ConstVisitor<DependencySpecTree>::VisitConstSequence<DepPrinter, AllDepSpec>::visit_sequence;
using ConstVisitor<DependencySpecTree>::VisitConstSequence<DepPrinter, AnyDepSpec>::visit_sequence;
- using ConstVisitor<DependencySpecTree>::VisitConstSequence<DepPrinter, UseDepSpec>::visit_sequence;
+ using ConstVisitor<DependencySpecTree>::VisitConstSequence<DepPrinter, ConditionalDepSpec>::visit_sequence;
};
}
}
diff --git a/paludis/show_suggest_visitor.cc b/paludis/show_suggest_visitor.cc
index 72681cb..42d8f36 100644
--- a/paludis/show_suggest_visitor.cc
+++ b/paludis/show_suggest_visitor.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -71,7 +71,7 @@ ShowSuggestVisitor::~ShowSuggestVisitor()
}
void
-ShowSuggestVisitor::visit_sequence(const UseDepSpec & a,
+ShowSuggestVisitor::visit_sequence(const ConditionalDepSpec & a,
DependencySpecTree::ConstSequenceIterator cur,
DependencySpecTree::ConstSequenceIterator end)
{
@@ -79,7 +79,7 @@ ShowSuggestVisitor::visit_sequence(const UseDepSpec & a,
&_imp->conditions, _imp->dependency_tags ?
ConditionTracker(_imp->conditions).add_condition(a) : _imp->conditions);
- if ((_imp->id ? _imp->environment->query_use(a.flag(), *_imp->id) : false) ^ a.inverse())
+ if (a.condition_met())
std::for_each(cur, end, accept_visitor(*this));
}
diff --git a/paludis/show_suggest_visitor.hh b/paludis/show_suggest_visitor.hh
index cd1f916..3d9ab10 100644
--- a/paludis/show_suggest_visitor.hh
+++ b/paludis/show_suggest_visitor.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -69,9 +69,10 @@ namespace paludis
void visit_leaf(const NamedSetDepSpec &);
- void visit_sequence(const UseDepSpec &,
+ void visit_sequence(const ConditionalDepSpec &,
DependencySpecTree::ConstSequenceIterator,
DependencySpecTree::ConstSequenceIterator);
+
void visit_sequence(const AnyDepSpec &,
DependencySpecTree::ConstSequenceIterator,
DependencySpecTree::ConstSequenceIterator);
diff --git a/paludis/stringify_formatter-impl.hh b/paludis/stringify_formatter-impl.hh
index 1886c00..cf82dac 100644
--- a/paludis/stringify_formatter-impl.hh
+++ b/paludis/stringify_formatter-impl.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
@@ -54,7 +54,7 @@ namespace paludis
const CanFormat<DependencyLabelsDepSpec> * const f_dep_label;
const CanFormat<URILabelsDepSpec> * const f_uri_label;
const CanFormat<PlainTextDepSpec> * const f_plain;
- const CanFormat<UseDepSpec> * const f_use_dep;
+ const CanFormat<ConditionalDepSpec> * const f_use_dep;
const CanFormat<NamedSetDepSpec> * const f_named;
const CanFormat<FSEntry> * const f_fsentry;
const CanFormat<PackageID> * const f_package_id;
@@ -73,7 +73,7 @@ namespace paludis
const CanFormat<DependencyLabelsDepSpec> * const f_dep_label_v,
const CanFormat<URILabelsDepSpec> * const f_uri_label_v,
const CanFormat<PlainTextDepSpec> * const f_plain_v,
- const CanFormat<UseDepSpec> * const f_use_dep_v,
+ const CanFormat<ConditionalDepSpec> * const f_use_dep_v,
const CanFormat<NamedSetDepSpec> * const f_named_v,
const CanFormat<FSEntry> * const f_fsentry_v,
const CanFormat<PackageID> * const f_package_id_v,
@@ -207,7 +207,7 @@ namespace paludis
StringifyFormatterGetForwarder<
tr1::is_convertible<T_ *, CanFormat<PlainTextDepSpec> *>::value,
PlainTextDepSpec>::get(&t),
- StringifyFormatterGetForwarder<tr1::is_convertible<T_ *, CanFormat<UseDepSpec> *>::value, UseDepSpec>::get(&t),
+ StringifyFormatterGetForwarder<tr1::is_convertible<T_ *, CanFormat<ConditionalDepSpec> *>::value, ConditionalDepSpec>::get(&t),
StringifyFormatterGetForwarder<tr1::is_convertible<T_ *, CanFormat<NamedSetDepSpec> *>::value, NamedSetDepSpec>::get(&t),
StringifyFormatterGetForwarder<tr1::is_convertible<T_ *, CanFormat<FSEntry> *>::value, FSEntry>::get(&t),
StringifyFormatterGetForwarder<tr1::is_convertible<T_ *, CanFormat<PackageID> *>::value, PackageID>::get(&t),
diff --git a/paludis/stringify_formatter.cc b/paludis/stringify_formatter.cc
index 6d5c3bf..6d36a6f 100644
--- a/paludis/stringify_formatter.cc
+++ b/paludis/stringify_formatter.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
@@ -285,7 +285,7 @@ StringifyFormatter::format(const PlainTextDepSpec & s, const format::Plain & k)
}
std::string
-StringifyFormatter::format(const UseDepSpec & s, const format::Enabled & k) const
+StringifyFormatter::format(const ConditionalDepSpec & s, const format::Enabled & k) const
{
if (_imp->f_use_dep)
return _imp->f_use_dep->format(s, k);
@@ -293,7 +293,7 @@ StringifyFormatter::format(const UseDepSpec & s, const format::Enabled & k) cons
}
std::string
-StringifyFormatter::format(const UseDepSpec & s, const format::Disabled & k) const
+StringifyFormatter::format(const ConditionalDepSpec & s, const format::Disabled & k) const
{
if (_imp->f_use_dep)
return _imp->f_use_dep->format(s, k);
@@ -301,7 +301,7 @@ StringifyFormatter::format(const UseDepSpec & s, const format::Disabled & k) con
}
std::string
-StringifyFormatter::format(const UseDepSpec & s, const format::Forced & k) const
+StringifyFormatter::format(const ConditionalDepSpec & s, const format::Forced & k) const
{
if (_imp->f_use_dep)
return _imp->f_use_dep->format(s, k);
@@ -309,7 +309,7 @@ StringifyFormatter::format(const UseDepSpec & s, const format::Forced & k) const
}
std::string
-StringifyFormatter::format(const UseDepSpec & s, const format::Masked & k) const
+StringifyFormatter::format(const ConditionalDepSpec & s, const format::Masked & k) const
{
if (_imp->f_use_dep)
return _imp->f_use_dep->format(s, k);
@@ -325,7 +325,7 @@ StringifyFormatter::format(const FSEntry & s, const format::Plain & k) const
}
std::string
-StringifyFormatter::format(const UseDepSpec & s, const format::Plain & k) const
+StringifyFormatter::format(const ConditionalDepSpec & s, const format::Plain & k) const
{
if (_imp->f_use_dep)
return _imp->f_use_dep->format(s, k);
diff --git a/paludis/stringify_formatter.hh b/paludis/stringify_formatter.hh
index 22649fb..3447547 100644
--- a/paludis/stringify_formatter.hh
+++ b/paludis/stringify_formatter.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
@@ -71,7 +71,7 @@ namespace paludis
public CanFormat<URILabelsDepSpec>,
public CanFormat<PlainTextDepSpec>,
public CanFormat<LicenseDepSpec>,
- public CanFormat<UseDepSpec>,
+ public CanFormat<ConditionalDepSpec>,
public CanFormat<NamedSetDepSpec>,
public CanFormat<FSEntry>,
public CanFormat<PackageID>,
@@ -138,11 +138,11 @@ namespace paludis
virtual std::string format(const LicenseDepSpec &, const format::Accepted &) const;
virtual std::string format(const LicenseDepSpec &, const format::Unaccepted &) const;
- virtual std::string format(const UseDepSpec &, const format::Enabled &) const;
- virtual std::string format(const UseDepSpec &, const format::Disabled &) const;
- virtual std::string format(const UseDepSpec &, const format::Forced &) const;
- virtual std::string format(const UseDepSpec &, const format::Masked &) const;
- virtual std::string format(const UseDepSpec &, const format::Plain &) const;
+ virtual std::string format(const ConditionalDepSpec &, const format::Enabled &) const;
+ virtual std::string format(const ConditionalDepSpec &, const format::Disabled &) const;
+ virtual std::string format(const ConditionalDepSpec &, const format::Forced &) const;
+ virtual std::string format(const ConditionalDepSpec &, const format::Masked &) const;
+ virtual std::string format(const ConditionalDepSpec &, const format::Plain &) const;
virtual std::string format(const FSEntry &, const format::Plain &) const;
diff --git a/paludis/stringify_formatter_TEST.cc b/paludis/stringify_formatter_TEST.cc
index e975ff5..c1e85f3 100644
--- a/paludis/stringify_formatter_TEST.cc
+++ b/paludis/stringify_formatter_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
@@ -38,10 +38,10 @@ namespace
return f.format(k, format::Accepted()) + " " + f.format(n, format::Enabled());
}
- std::string format_three(const PackageDepSpec & k, const BlockDepSpec & d, const UseDepSpec & u,
+ std::string format_three(const PackageDepSpec & k, const BlockDepSpec & d, const NamedSetDepSpec & u,
const GenericSpecTree::ItemFormatter & f)
{
- return f.format(k, format::Plain()) + " " + f.format(d, format::Plain()) + " " + f.format(u, format::Enabled());
+ return f.format(k, format::Plain()) + " " + f.format(d, format::Plain()) + " " + f.format(u, format::Plain());
}
class PartialFormatter :
@@ -111,12 +111,12 @@ namespace test_cases
PartialFormatter f;
StringifyFormatter ff(f);
BlockDepSpec b(make_shared_ptr(new PackageDepSpec(parse_user_package_dep_spec("cat/pkg", UserPackageDepSpecOptions()))));
- UseDepSpec u(UseFlagName("foo"), true);
+ NamedSetDepSpec u(SetName("foo"));
std::string s(format_three(
parse_user_package_dep_spec("cat/pkg", UserPackageDepSpecOptions()),
b, u,
ff));
- TEST_CHECK_EQUAL(s, "<cat/pkg> !cat/pkg !foo?");
+ TEST_CHECK_EQUAL(s, "<cat/pkg> !cat/pkg foo");
}
} test_stringify_formatter_partial;
}
diff --git a/paludis/uninstall_list.cc b/paludis/uninstall_list.cc
index f6cf46c..5539ed0 100644
--- a/paludis/uninstall_list.cc
+++ b/paludis/uninstall_list.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
@@ -293,14 +293,14 @@ namespace
std::for_each(cur, end, accept_visitor(*this));
}
- void visit_sequence(const UseDepSpec & u,
+ void visit_sequence(const ConditionalDepSpec & u,
DependencySpecTree::ConstSequenceIterator cur,
DependencySpecTree::ConstSequenceIterator end)
{
Save<tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > > save_c(
&conditions, ConditionTracker(conditions).add_condition(u));
- if (env->query_use(UseFlagName(u.flag()), *pkg) ^ u.inverse())
+ if (u.condition_met())
std::for_each(cur, end, accept_visitor(*this));
}
diff --git a/python/dep_spec.cc b/python/dep_spec.cc
index b89bbad..e58da2b 100644
--- a/python/dep_spec.cc
+++ b/python/dep_spec.cc
@@ -46,7 +46,7 @@ template class ConstAcceptInterface<PythonDepSpecVisitorTypes>;
template class ConstAcceptInterfaceVisitsThis<PythonDepSpecVisitorTypes, PythonAllDepSpec>;
template class ConstAcceptInterfaceVisitsThis<PythonDepSpecVisitorTypes, PythonAnyDepSpec>;
-template class ConstAcceptInterfaceVisitsThis<PythonDepSpecVisitorTypes, PythonUseDepSpec>;
+template class ConstAcceptInterfaceVisitsThis<PythonDepSpecVisitorTypes, PythonConditionalDepSpec>;
template class ConstAcceptInterfaceVisitsThis<PythonDepSpecVisitorTypes, PythonPackageDepSpec>;
template class ConstAcceptInterfaceVisitsThis<PythonDepSpecVisitorTypes, PythonBlockDepSpec>;
template class ConstAcceptInterfaceVisitsThis<PythonDepSpecVisitorTypes, PythonPlainTextDepSpec>;
@@ -59,7 +59,7 @@ template class ConstAcceptInterfaceVisitsThis<PythonDepSpecVisitorTypes, PythonN
template class Visits<const PythonAllDepSpec>;
template class Visits<const PythonAnyDepSpec>;
-template class Visits<const PythonUseDepSpec>;
+template class Visits<const PythonConditionalDepSpec>;
template class Visits<const PythonPackageDepSpec>;
template class Visits<const PythonBlockDepSpec>;
template class Visits<const PythonPlainTextDepSpec>;
@@ -81,8 +81,8 @@ PythonDepSpec::~PythonDepSpec()
{
}
-const PythonUseDepSpec *
-PythonDepSpec::as_use_dep_spec() const
+const PythonConditionalDepSpec *
+PythonDepSpec::as_conditional_dep_spec() const
{
return 0;
}
@@ -184,34 +184,33 @@ PythonAllDepSpec::PythonAllDepSpec(const AllDepSpec &)
{
}
-PythonUseDepSpec::PythonUseDepSpec(const UseFlagName & our_flag, bool is_inverse) :
- _flag(our_flag),
- _inverse(is_inverse)
+PythonConditionalDepSpec::PythonConditionalDepSpec(const ConditionalDepSpec & d) :
+ _data(d.data())
{
}
-PythonUseDepSpec::PythonUseDepSpec(const UseDepSpec & d) :
- _flag(d.flag()),
- _inverse(d.inverse())
+const PythonConditionalDepSpec *
+PythonConditionalDepSpec::as_conditional_dep_spec() const
{
+ return this;
}
-const PythonUseDepSpec *
-PythonUseDepSpec::as_use_dep_spec() const
+bool
+PythonConditionalDepSpec::condition_met() const
{
- return this;
+ return _data->condition_met();
}
-UseFlagName
-PythonUseDepSpec::flag() const
+bool
+PythonConditionalDepSpec::condition_meetable() const
{
- return _flag;
+ return _data->condition_meetable();
}
-bool
-PythonUseDepSpec::inverse() const
+const tr1::shared_ptr<const ConditionalDepSpecData>
+PythonConditionalDepSpec::data() const
{
- return _inverse;
+ return _data;
}
PythonStringDepSpec::PythonStringDepSpec(const std::string & s) :
@@ -572,11 +571,11 @@ SpecTreeToPython::visit_sequence(const AnyDepSpec & d,
}
void
-SpecTreeToPython::visit_sequence(const UseDepSpec & d,
+SpecTreeToPython::visit_sequence(const ConditionalDepSpec & d,
GenericSpecTree::ConstSequenceIterator cur,
GenericSpecTree::ConstSequenceIterator end)
{
- tr1::shared_ptr<PythonUseDepSpec> py_cds(new PythonUseDepSpec(d));
+ tr1::shared_ptr<PythonConditionalDepSpec> py_cds(new PythonConditionalDepSpec(d));
_current_parent->add_child(py_cds);
Save<tr1::shared_ptr<PythonCompositeDepSpec> > old_parent(&_current_parent, py_cds);
std::for_each(cur, end, accept_visitor(*this));
@@ -650,7 +649,7 @@ struct AllowedTypes<LicenseSpecTree>
{
AllowedTypes(const AllDepSpec &) {};
AllowedTypes(const AnyDepSpec &) {};
- AllowedTypes(const UseDepSpec &) {};
+ AllowedTypes(const ConditionalDepSpec &) {};
AllowedTypes(const LicenseDepSpec &) {};
};
@@ -658,7 +657,7 @@ template<>
struct AllowedTypes<FetchableURISpecTree>
{
AllowedTypes(const AllDepSpec &) {};
- AllowedTypes(const UseDepSpec &) {};
+ AllowedTypes(const ConditionalDepSpec &) {};
AllowedTypes(const FetchableURISpecTree &) {};
AllowedTypes(const URILabelsDepSpec &) {};
};
@@ -667,7 +666,7 @@ template<>
struct AllowedTypes<SimpleURISpecTree>
{
AllowedTypes(const AllDepSpec &) {};
- AllowedTypes(const UseDepSpec &) {};
+ AllowedTypes(const ConditionalDepSpec &) {};
AllowedTypes(const SimpleURIDepSpec &) {};
};
@@ -675,7 +674,7 @@ template<>
struct AllowedTypes<ProvideSpecTree>
{
AllowedTypes(const AllDepSpec &) {};
- AllowedTypes(const UseDepSpec &) {};
+ AllowedTypes(const ConditionalDepSpec &) {};
AllowedTypes(const PackageDepSpec &) {};
};
@@ -683,7 +682,7 @@ template<>
struct AllowedTypes<RestrictSpecTree>
{
AllowedTypes(const AllDepSpec &) {};
- AllowedTypes(const UseDepSpec &) {};
+ AllowedTypes(const ConditionalDepSpec &) {};
AllowedTypes(const PlainTextDepSpec &) {};
};
@@ -692,7 +691,7 @@ struct AllowedTypes<DependencySpecTree>
{
AllowedTypes(const AllDepSpec &) {};
AllowedTypes(const AnyDepSpec &) {};
- AllowedTypes(const UseDepSpec &) {};
+ AllowedTypes(const ConditionalDepSpec &) {};
AllowedTypes(const PackageDepSpec &) {};
AllowedTypes(const BlockDepSpec &) {};
AllowedTypes(const DependencyLabelsDepSpec &) {};
@@ -777,9 +776,9 @@ SpecTreeFromPython<H_>::visit(const PythonAnyDepSpec & d)
template <typename H_>
void
-SpecTreeFromPython<H_>::visit(const PythonUseDepSpec & d)
+SpecTreeFromPython<H_>::visit(const PythonConditionalDepSpec & d)
{
- dispatch<H_, UseDepSpec>(this, d);
+ dispatch<H_, ConditionalDepSpec>(this, d);
}
template <typename H_>
@@ -879,16 +878,16 @@ SpecTreeFromPython<H_>::real_visit(const PythonAnyDepSpec & d)
template <typename H_>
void
-SpecTreeFromPython<H_>::real_visit(const PythonUseDepSpec & d)
+SpecTreeFromPython<H_>::real_visit(const PythonConditionalDepSpec & d)
{
- tr1::shared_ptr<ConstTreeSequence<H_, UseDepSpec> > cds(
- new ConstTreeSequence<H_, UseDepSpec>(make_shared_ptr(
- new UseDepSpec(d.flag(), d.inverse()))));
+ tr1::shared_ptr<ConstTreeSequence<H_, ConditionalDepSpec> > cds(
+ new ConstTreeSequence<H_, ConditionalDepSpec>(make_shared_ptr(
+ new ConditionalDepSpec(d.data()))));
_add(cds);
Save<tr1::function<void (tr1::shared_ptr<ConstAcceptInterface<H_> >)> > old_add(&_add,
- tr1::bind(&ConstTreeSequence<H_, UseDepSpec>::add, cds, tr1::placeholders::_1));
+ tr1::bind(&ConstTreeSequence<H_, ConditionalDepSpec>::add, cds, tr1::placeholders::_1));
std::for_each(IndirectIterator<PythonCompositeDepSpec::ConstIterator, const PythonDepSpec>(d.begin()),
IndirectIterator<PythonCompositeDepSpec::ConstIterator, const PythonDepSpec>(d.end()),
accept_visitor(*this));
@@ -1092,10 +1091,10 @@ void expose_dep_spec()
"Base class for a dependency spec.",
bp::no_init
)
- .def("as_use_dep_spec", &PythonDepSpec::as_use_dep_spec,
+ .def("as_conditional_dep_spec", &PythonDepSpec::as_conditional_dep_spec,
bp::return_value_policy<bp::reference_existing_object>(),
- "as_use_dep_spec() -> UseDepSpec\n"
- "Return us as a UseDepSpec, or None if we are not a UseDepSpec."
+ "as_conditional_dep_spec() -> ConditionalDepSpec\n"
+ "Return us as a ConditionalDepSpec, or None if we are not a ConditionalDepSpec."
)
.def("as_package_dep_spec", &PythonDepSpec::as_package_dep_spec,
@@ -1141,23 +1140,22 @@ void expose_dep_spec()
);
/**
- * UseDepSpec
+ * ConditionalDepSpec
*/
- bp::class_<PythonUseDepSpec, bp::bases<PythonCompositeDepSpec>, boost::noncopyable>
+ bp::class_<PythonConditionalDepSpec, bp::bases<PythonCompositeDepSpec>, boost::noncopyable>
(
- "UseDepSpec",
+ "ConditionalDepSpec",
"Represents a use? ( ) dependency spec.",
- bp::init<const UseFlagName &, bool>("__init__(UseFlagName, inverse_bool)")
+ bp::no_init
)
- .add_property("flag", &UseDepSpec::flag,
- "[ro] UseFlagName\n"
- "Our use flag name."
- )
-
- .add_property("inverse", &UseDepSpec::inverse,
- "[ro] bool\n"
- "Are we a ! flag?"
- )
+ .def("condition_met", &PythonConditionalDepSpec::condition_met,
+ "condition_met() -> bool\n"
+ "Is our condition met?"
+ )
+ .def("condition_meetable", &PythonConditionalDepSpec::condition_meetable,
+ "condition_met() -> bool\n"
+ "Is our condition meetable?"
+ )
;
/**
diff --git a/python/dep_spec.hh b/python/dep_spec.hh
index 98f8638..687dad3 100644
--- a/python/dep_spec.hh
+++ b/python/dep_spec.hh
@@ -32,7 +32,7 @@ namespace paludis
class PythonCompositeDepSpec;
class PythonAllDepSpec;
class PythonAnyDepSpec;
- class PythonUseDepSpec;
+ class PythonConditionalDepSpec;
class PythonStringDepSpec;
class PythonPlainTextDepSpec;
class PythonLicenseDepSpec;
@@ -50,7 +50,7 @@ namespace paludis
PythonDepSpec,
PythonAnyDepSpec,
PythonAllDepSpec,
- PythonUseDepSpec,
+ PythonConditionalDepSpec,
PythonBlockDepSpec,
PythonPlainTextDepSpec,
PythonLicenseDepSpec,
@@ -74,7 +74,7 @@ namespace paludis
public:
virtual ~PythonDepSpec();
- virtual const PythonUseDepSpec * as_use_dep_spec() const
+ virtual const PythonConditionalDepSpec * as_conditional_dep_spec() const
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const PythonPackageDepSpec * as_package_dep_spec() const
@@ -120,21 +120,22 @@ namespace paludis
PythonAllDepSpec(const AllDepSpec &);
};
- class PALUDIS_VISIBLE PythonUseDepSpec :
+ class PALUDIS_VISIBLE PythonConditionalDepSpec :
public PythonCompositeDepSpec,
- public ConstAcceptInterfaceVisitsThis<PythonDepSpecVisitorTypes, PythonUseDepSpec>
+ public ConstAcceptInterfaceVisitsThis<PythonDepSpecVisitorTypes, PythonConditionalDepSpec>
{
private:
- const UseFlagName _flag;
- const bool _inverse;
+ const tr1::shared_ptr<const ConditionalDepSpecData> _data;
public:
- PythonUseDepSpec(const UseFlagName &, bool);
- PythonUseDepSpec(const UseDepSpec &);
+ PythonConditionalDepSpec(const ConditionalDepSpec &);
- UseFlagName flag() const;
- bool inverse() const;
- virtual const PythonUseDepSpec * as_use_dep_spec() const;
+ virtual const PythonConditionalDepSpec * as_conditional_dep_spec() const;
+
+ bool condition_met() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ bool condition_meetable() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ const tr1::shared_ptr<const ConditionalDepSpecData> data() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
class PALUDIS_VISIBLE PythonStringDepSpec :
@@ -296,7 +297,7 @@ namespace paludis
GenericSpecTree::ConstSequenceIterator,
GenericSpecTree::ConstSequenceIterator);
- void visit_sequence(const UseDepSpec &,
+ void visit_sequence(const ConditionalDepSpec &,
GenericSpecTree::ConstSequenceIterator,
GenericSpecTree::ConstSequenceIterator);
@@ -340,7 +341,7 @@ namespace paludis
void visit(const PythonAllDepSpec &);
void visit(const PythonAnyDepSpec &);
- void visit(const PythonUseDepSpec &);
+ void visit(const PythonConditionalDepSpec &);
void visit(const PythonPackageDepSpec &);
void visit(const PythonPlainTextDepSpec &);
void visit(const PythonBlockDepSpec &);
@@ -353,7 +354,7 @@ namespace paludis
void real_visit(const PythonAllDepSpec &);
void real_visit(const PythonAnyDepSpec &);
- void real_visit(const PythonUseDepSpec &);
+ void real_visit(const PythonConditionalDepSpec &);
void real_visit(const PythonPackageDepSpec &);
void real_visit(const PythonPlainTextDepSpec &);
void real_visit(const PythonBlockDepSpec &);
diff --git a/python/formatter.cc b/python/formatter.cc
index fdc1e13..f3bc389 100644
--- a/python/formatter.cc
+++ b/python/formatter.cc
@@ -355,7 +355,7 @@ class PythonFormatterWrapper :
public PythonCanFormat<URILabelsDepSpec>,
public PythonCanFormat<PlainTextDepSpec>,
public PythonCanFormat<LicenseDepSpec>,
- public PythonCanFormat<UseDepSpec>,
+ public PythonCanFormat<ConditionalDepSpec>,
public PythonCanFormat<NamedSetDepSpec>,
public PythonCanSpace,
public bp::wrapper<PythonFormatterWrapper>
@@ -531,19 +531,19 @@ void expose_formatter()
;
/**
- * CanFormatUseDepSpec
+ * CanFormatConditionalDepSpec
*/
- bp::class_<PythonCanFormatWrapper<UseDepSpec>, boost::noncopyable>
+ bp::class_<PythonCanFormatWrapper<ConditionalDepSpec>, boost::noncopyable>
(
- "CanFormatUseDepSpec",
- "Descendents of this class implement the necessary methods to format a UseDepSpec.",
+ "CanFormatConditionalDepSpec",
+ "Descendents of this class implement the necessary methods to format a ConditionalDepSpec.",
bp::init<>("__init__()")
)
- .def("format_use_dep_spec_plain", &PythonCanFormatWrapper<UseDepSpec>::format_plain)
- .def("format_use_dep_spec_enabled", &PythonCanFormatWrapper<UseDepSpec>::format_enabled)
- .def("format_use_dep_spec_disabled", &PythonCanFormatWrapper<UseDepSpec>::format_disabled)
- .def("format_use_dep_spec_forced", &PythonCanFormatWrapper<UseDepSpec>::format_forced)
- .def("format_use_dep_spec_masked", &PythonCanFormatWrapper<UseDepSpec>::format_masked)
+ .def("format_conditional_dep_spec_plain", &PythonCanFormatWrapper<ConditionalDepSpec>::format_plain)
+ .def("format_conditional_dep_spec_enabled", &PythonCanFormatWrapper<ConditionalDepSpec>::format_enabled)
+ .def("format_conditional_dep_spec_disabled", &PythonCanFormatWrapper<ConditionalDepSpec>::format_disabled)
+ .def("format_conditional_dep_spec_forced", &PythonCanFormatWrapper<ConditionalDepSpec>::format_forced)
+ .def("format_conditional_dep_spec_masked", &PythonCanFormatWrapper<ConditionalDepSpec>::format_masked)
;
/**
@@ -623,7 +623,7 @@ void expose_formatter()
*/
bp::class_<LicenseSpecTree::ItemFormatter,
bp::bases<
- CanFormat<UseDepSpec>,
+ CanFormat<ConditionalDepSpec>,
CanFormat<LicenseDepSpec> >,
boost::noncopyable>
(
@@ -638,7 +638,7 @@ void expose_formatter()
*/
bp::class_<ProvideSpecTree::ItemFormatter,
bp::bases<
- CanFormat<UseDepSpec>,
+ CanFormat<ConditionalDepSpec>,
CanFormat<PackageDepSpec> >,
boost::noncopyable>
(
@@ -653,7 +653,7 @@ void expose_formatter()
*/
bp::class_<DependencySpecTree::ItemFormatter,
bp::bases<
- CanFormat<UseDepSpec>,
+ CanFormat<ConditionalDepSpec>,
CanFormat<PackageDepSpec>,
CanFormat<NamedSetDepSpec>,
CanFormat<DependencyLabelsDepSpec> >,
@@ -670,7 +670,7 @@ void expose_formatter()
*/
bp::class_<RestrictSpecTree::ItemFormatter,
bp::bases<
- CanFormat<UseDepSpec>,
+ CanFormat<ConditionalDepSpec>,
CanFormat<PlainTextDepSpec> >,
boost::noncopyable>
(
@@ -685,7 +685,7 @@ void expose_formatter()
*/
bp::class_<SimpleURISpecTree::ItemFormatter,
bp::bases<
- CanFormat<UseDepSpec>,
+ CanFormat<ConditionalDepSpec>,
CanFormat<SimpleURIDepSpec> >,
boost::noncopyable>
(
@@ -700,7 +700,7 @@ void expose_formatter()
*/
bp::class_<FetchableURISpecTree::ItemFormatter,
bp::bases<
- CanFormat<UseDepSpec>,
+ CanFormat<ConditionalDepSpec>,
CanFormat<FetchableURIDepSpec>,
CanFormat<URILabelsDepSpec> >,
boost::noncopyable>
@@ -738,7 +738,7 @@ void expose_formatter()
CanFormat<URILabelsDepSpec>,
CanFormat<PlainTextDepSpec>,
CanFormat<LicenseDepSpec>,
- CanFormat<UseDepSpec>,
+ CanFormat<ConditionalDepSpec>,
CanFormat<NamedSetDepSpec>,
CanSpace>,
boost::noncopyable>
@@ -782,7 +782,7 @@ void expose_formatter()
CanFormat<URILabelsDepSpec>,
CanFormat<PlainTextDepSpec>,
CanFormat<LicenseDepSpec>,
- CanFormat<UseDepSpec>,
+ CanFormat<ConditionalDepSpec>,
CanFormat<NamedSetDepSpec>,
CanSpace>,
boost::noncopyable>
diff --git a/python/nice_names.nn b/python/nice_names.nn
index 36ce9b6..4d35d29 100644
--- a/python/nice_names.nn
+++ b/python/nice_names.nn
@@ -27,7 +27,7 @@ make_nn_NiceNames() {
name "SimpleURIDepSpec"
name "AllDepSpec"
name "AnyDepSpec"
- name "UseDepSpec"
+ name "ConditionalDepSpec"
name "BlockDepSpec"
name "StringDepSpec"
name "NamedSetDepSpec"
@@ -82,7 +82,7 @@ make_nn_LowercaseNiceNames() {
name "URILabelsDepSpec" "uri_labels_dep_spec"
name "PlainTextDepSpec" "plain_text_dep_spec"
name "LicenseDepSpec" "license_dep_spec"
- name "UseDepSpec" "use_dep_spec"
+ name "ConditionalDepSpec" "conditional_dep_spec"
name "NamedSetDepSpec" "named_set_dep_spec"
name "format::Plain" "plain"
diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc
index 1819d54..8d27c54 100644
--- a/ruby/dep_spec.cc
+++ b/ruby/dep_spec.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 Richard Brown
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -57,7 +57,7 @@ namespace
static VALUE c_all_dep_spec;
static VALUE c_any_dep_spec;
- static VALUE c_use_dep_spec;
+ static VALUE c_conditional_dep_spec;
static VALUE c_version_requirements_mode;
@@ -87,7 +87,7 @@ namespace
WrappedSpec<NamedSetDepSpec>,
WrappedSpec<AllDepSpec>,
WrappedSpec<AnyDepSpec>,
- WrappedSpec<UseDepSpec>
+ WrappedSpec<ConditionalDepSpec>
>
{
};
@@ -225,13 +225,13 @@ namespace
value = Data_Wrap_Struct(c_license_dep_spec, 0, &Common<tr1::shared_ptr<const WrappedSpecBase> >::free, ptr);
}
- void visit_sequence(const UseDepSpec & spec,
+ void visit_sequence(const ConditionalDepSpec & spec,
GenericSpecTree::ConstSequenceIterator cur,
GenericSpecTree::ConstSequenceIterator end)
{
ptr = new tr1::shared_ptr<const WrappedSpecBase>(
- (new WrappedSpec<UseDepSpec>(tr1::static_pointer_cast<UseDepSpec>(spec.clone())))->add_children(cur, end));
- value = Data_Wrap_Struct(c_use_dep_spec, &WrappedSpecBase::mark, &Common<tr1::shared_ptr<const WrappedSpecBase> >::free, ptr);
+ (new WrappedSpec<ConditionalDepSpec>(tr1::static_pointer_cast<ConditionalDepSpec>(spec.clone())))->add_children(cur, end));
+ value = Data_Wrap_Struct(c_conditional_dep_spec, &WrappedSpecBase::mark, &Common<tr1::shared_ptr<const WrappedSpecBase> >::free, ptr);
}
void visit_sequence(const AllDepSpec & spec,
@@ -327,7 +327,7 @@ namespace
do_visit_sequence(s);
}
- virtual void visit(const WrappedSpec<UseDepSpec> & s)
+ virtual void visit(const WrappedSpec<ConditionalDepSpec> & s)
{
do_visit_sequence(s);
}
@@ -519,31 +519,26 @@ namespace
/*
* call-seq:
- * flag -> String
+ * condition_met? -> true or false
*
- * Fetch our use flag name.
+ * Whether our condition is met.
*/
- VALUE
- use_dep_spec_flag(VALUE self)
- {
- tr1::shared_ptr<WrappedSpecBase> * p;
- Data_Get_Struct(self, tr1::shared_ptr<WrappedSpecBase>, p);
- return rb_str_new2(stringify(tr1::static_pointer_cast<const WrappedSpec<UseDepSpec> >(*p)->spec()->flag()).c_str());
- }
-
/*
* call-seq:
- * inverse? -> true or false
+ * condition_meetable? -> true or false
*
- * Fetch whether we are a ! flag.
+ * Whether our condition is meetable.
*/
- VALUE
- use_dep_spec_inverse(VALUE self)
+ template <bool (ConditionalDepSpec::* f_) () const>
+ struct ConditionalDepSpecBoolFunc
{
- tr1::shared_ptr<WrappedSpecBase> * p;
- Data_Get_Struct(self, tr1::shared_ptr<WrappedSpecBase>, p);
- return tr1::static_pointer_cast<const WrappedSpec<UseDepSpec> >(*p)->spec()->inverse() ? Qtrue : Qfalse;
- }
+ static VALUE func(VALUE self)
+ {
+ tr1::shared_ptr<WrappedSpecBase> * p;
+ Data_Get_Struct(self, tr1::shared_ptr<WrappedSpecBase>, p);
+ return ((*tr1::static_pointer_cast<const WrappedSpec<ConditionalDepSpec> >(*p)->spec().get()).*f_)() ? Qtrue : Qfalse;
+ }
+ };
/*
* call-seq:
@@ -966,17 +961,19 @@ namespace
rb_define_method(c_any_dep_spec, "each", RUBY_FUNC_CAST((&Composite<AllDepSpec>::each)), 0);
/*
- * Document-class: Paludis::UseDepSpec
+ * Document-class: Paludis::ConditionalDepSpec
*
* Represents a use? ( ) dependency spec. Includes
* Enumerable[http://www.ruby-doc.org/core/classes/Enumerable.html].
*/
- c_use_dep_spec = rb_define_class_under(paludis_module(), "UseDepSpec", c_dep_spec);
- rb_funcall(c_use_dep_spec, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_include_module(c_use_dep_spec, rb_mEnumerable);
- rb_define_method(c_use_dep_spec, "flag", RUBY_FUNC_CAST(&use_dep_spec_flag), 0);
- rb_define_method(c_use_dep_spec, "inverse?", RUBY_FUNC_CAST(&use_dep_spec_inverse), 0);
- rb_define_method(c_use_dep_spec, "each", RUBY_FUNC_CAST((&Composite<AllDepSpec>::each)), 0);
+ c_conditional_dep_spec = rb_define_class_under(paludis_module(), "ConditionalDepSpec", c_dep_spec);
+ rb_funcall(c_conditional_dep_spec, rb_intern("private_class_method"), 1, rb_str_new2("new"));
+ rb_include_module(c_conditional_dep_spec, rb_mEnumerable);
+ rb_define_method(c_conditional_dep_spec, "condition_met?", RUBY_FUNC_CAST(
+ &ConditionalDepSpecBoolFunc<&ConditionalDepSpec::condition_met>::func), 0);
+ rb_define_method(c_conditional_dep_spec, "condition_meetable?", RUBY_FUNC_CAST(
+ &ConditionalDepSpecBoolFunc<&ConditionalDepSpec::condition_meetable>::func), 0);
+ rb_define_method(c_conditional_dep_spec, "each", RUBY_FUNC_CAST((&Composite<AllDepSpec>::each)), 0);
/*
* Document-class: Paludis::StringDepSpec
diff --git a/ruby/nice_names.nn b/ruby/nice_names.nn
index 4cbd738..ee852fc 100644
--- a/ruby/nice_names.nn
+++ b/ruby/nice_names.nn
@@ -24,7 +24,7 @@ make_nn_NiceNames() {
name "SimpleURIDepSpec"
name "AllDepSpec"
name "AnyDepSpec"
- name "UseDepSpec"
+ name "ConditionalDepSpec"
name "BlockDepSpec"
name "StringDepSpec"
name "NamedSetDepSpec"
diff --git a/src/clients/adjutrix/find_reverse_deps.cc b/src/clients/adjutrix/find_reverse_deps.cc
index 91b53ee..5ab5eb1 100644
--- a/src/clients/adjutrix/find_reverse_deps.cc
+++ b/src/clients/adjutrix/find_reverse_deps.cc
@@ -96,7 +96,7 @@ namespace
DependencySpecTree::ConstSequenceIterator,
DependencySpecTree::ConstSequenceIterator);
- void visit_sequence(const UseDepSpec &,
+ void visit_sequence(const ConditionalDepSpec &,
DependencySpecTree::ConstSequenceIterator,
DependencySpecTree::ConstSequenceIterator);
@@ -144,7 +144,7 @@ namespace
}
void
- ReverseDepChecker::visit_sequence(const UseDepSpec & a,
+ ReverseDepChecker::visit_sequence(const ConditionalDepSpec & a,
DependencySpecTree::ConstSequenceIterator cur,
DependencySpecTree::ConstSequenceIterator end)
{
@@ -153,7 +153,7 @@ namespace
if (! _flags.empty())
_flags += " ";
- _flags += (a.inverse() ? "!" : "") + stringify(a.flag());
+ _flags += stringify(a);
std::for_each(cur, end, accept_visitor(*this));
}
diff --git a/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.cc b/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.cc
index b0ede92..2689bea 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.cc
+++ b/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.cc
@@ -83,31 +83,31 @@ MarkupFormatter::format(const UseFlagName & f, const format::Masked &) const
}
std::string
-MarkupFormatter::format(const UseDepSpec & f, const format::Plain &) const
+MarkupFormatter::format(const ConditionalDepSpec & f, const format::Plain &) const
{
return markup_escape(stringify(f));
}
std::string
-MarkupFormatter::format(const UseDepSpec & f, const format::Enabled &) const
+MarkupFormatter::format(const ConditionalDepSpec & f, const format::Enabled &) const
{
return markup_foreground("green", markup_escape(stringify(f)));
}
std::string
-MarkupFormatter::format(const UseDepSpec & f, const format::Disabled &) const
+MarkupFormatter::format(const ConditionalDepSpec & f, const format::Disabled &) const
{
return markup_foreground("red", markup_escape(stringify(f)));
}
std::string
-MarkupFormatter::format(const UseDepSpec & f, const format::Forced &) const
+MarkupFormatter::format(const ConditionalDepSpec & f, const format::Forced &) const
{
return markup_foreground("green", markup_escape("(" + stringify(f) + ")"));
}
std::string
-MarkupFormatter::format(const UseDepSpec & f, const format::Masked &) const
+MarkupFormatter::format(const ConditionalDepSpec & f, const format::Masked &) const
{
return markup_foreground("red", markup_escape("(" + stringify(f) + ")"));
}
diff --git a/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.hh b/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.hh
index d5e0fcc..60ce649 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.hh
+++ b/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.hh
@@ -14,7 +14,7 @@ namespace gtkpaludis
public paludis::CanFormat<paludis::UseFlagName>,
public paludis::CanFormat<paludis::IUseFlag>,
public paludis::CanFormat<paludis::KeywordName>,
- public paludis::CanFormat<paludis::UseDepSpec>,
+ public paludis::CanFormat<paludis::ConditionalDepSpec>,
public paludis::CanFormat<paludis::PackageDepSpec>,
public paludis::CanFormat<paludis::BlockDepSpec>,
public paludis::CanFormat<paludis::DependencyLabelsDepSpec>,
@@ -44,11 +44,11 @@ namespace gtkpaludis
std::string format(const paludis::UseFlagName &, const paludis::format::Forced &) const;
std::string format(const paludis::UseFlagName &, const paludis::format::Masked &) const;
- std::string format(const paludis::UseDepSpec &, const paludis::format::Plain &) const;
- std::string format(const paludis::UseDepSpec &, const paludis::format::Enabled &) const;
- std::string format(const paludis::UseDepSpec &, const paludis::format::Disabled &) const;
- std::string format(const paludis::UseDepSpec &, const paludis::format::Forced &) const;
- std::string format(const paludis::UseDepSpec &, const paludis::format::Masked &) const;
+ std::string format(const paludis::ConditionalDepSpec &, const paludis::format::Plain &) const;
+ std::string format(const paludis::ConditionalDepSpec &, const paludis::format::Enabled &) const;
+ std::string format(const paludis::ConditionalDepSpec &, const paludis::format::Disabled &) const;
+ std::string format(const paludis::ConditionalDepSpec &, const paludis::format::Forced &) const;
+ std::string format(const paludis::ConditionalDepSpec &, const paludis::format::Masked &) const;
std::string format(const paludis::PackageDepSpec &, const paludis::format::Plain &) const;
std::string format(const paludis::PackageDepSpec &, const paludis::format::Installed &) const;
diff --git a/src/clients/inquisitio/key_extractor.cc b/src/clients/inquisitio/key_extractor.cc
index 250d598..0f59345 100644
--- a/src/clients/inquisitio/key_extractor.cc
+++ b/src/clients/inquisitio/key_extractor.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
@@ -98,7 +98,7 @@ namespace
using ConstVisitor<GenericSpecTree>::VisitConstSequence<TreeVisitor, AllDepSpec>::visit_sequence;
using ConstVisitor<GenericSpecTree>::VisitConstSequence<TreeVisitor, AnyDepSpec>::visit_sequence;
- void visit_sequence(const UseDepSpec & u,
+ void visit_sequence(const ConditionalDepSpec & u,
GenericSpecTree::ConstSequenceIterator cur,
GenericSpecTree::ConstSequenceIterator end)
{
@@ -110,7 +110,7 @@ namespace
{
if (! _visible_only)
std::for_each(cur, end, accept_visitor(*this));
- else if (u.inverse() ^ _env.query_use(u.flag(), _id))
+ else if (u.condition_met())
std::for_each(cur, end, accept_visitor(*this));
}
}
diff --git a/src/output/colour_formatter.cc b/src/output/colour_formatter.cc
index 7e64d52..c7b1dcd 100644
--- a/src/output/colour_formatter.cc
+++ b/src/output/colour_formatter.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
@@ -255,31 +255,31 @@ ColourFormatter::format(const UseFlagName & f, const format::Masked &) const
}
std::string
-ColourFormatter::format(const UseDepSpec & f, const format::Plain &) const
+ColourFormatter::format(const ConditionalDepSpec & f, const format::Plain &) const
{
return stringify(f);
}
std::string
-ColourFormatter::format(const UseDepSpec & f, const format::Enabled &) const
+ColourFormatter::format(const ConditionalDepSpec & f, const format::Enabled &) const
{
return colour(cl_flag_on, f);
}
std::string
-ColourFormatter::format(const UseDepSpec & f, const format::Disabled &) const
+ColourFormatter::format(const ConditionalDepSpec & f, const format::Disabled &) const
{
return colour(cl_flag_off, f);
}
std::string
-ColourFormatter::format(const UseDepSpec & f, const format::Forced &) const
+ColourFormatter::format(const ConditionalDepSpec & f, const format::Forced &) const
{
return colour(cl_flag_on, "(" + stringify(f) + ")");
}
std::string
-ColourFormatter::format(const UseDepSpec & f, const format::Masked &) const
+ColourFormatter::format(const ConditionalDepSpec & f, const format::Masked &) const
{
return colour(cl_flag_off, "(" + stringify(f) + ")");
}
diff --git a/src/output/colour_formatter.hh b/src/output/colour_formatter.hh
index 0f9b9e5..ee6ad8e 100644
--- a/src/output/colour_formatter.hh
+++ b/src/output/colour_formatter.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
@@ -30,7 +30,7 @@ class ColourFormatter :
public paludis::CanFormat<paludis::UseFlagName>,
public paludis::CanFormat<paludis::IUseFlag>,
public paludis::CanFormat<paludis::KeywordName>,
- public paludis::CanFormat<paludis::UseDepSpec>,
+ public paludis::CanFormat<paludis::ConditionalDepSpec>,
public paludis::CanFormat<paludis::PackageDepSpec>,
public paludis::CanFormat<paludis::BlockDepSpec>,
public paludis::CanFormat<paludis::DependencyLabelsDepSpec>,
@@ -69,11 +69,11 @@ class ColourFormatter :
std::string format(const paludis::UseFlagName &, const paludis::format::Forced &) const;
std::string format(const paludis::UseFlagName &, const paludis::format::Masked &) const;
- std::string format(const paludis::UseDepSpec &, const paludis::format::Plain &) const;
- std::string format(const paludis::UseDepSpec &, const paludis::format::Enabled &) const;
- std::string format(const paludis::UseDepSpec &, const paludis::format::Disabled &) const;
- std::string format(const paludis::UseDepSpec &, const paludis::format::Forced &) const;
- std::string format(const paludis::UseDepSpec &, const paludis::format::Masked &) const;
+ std::string format(const paludis::ConditionalDepSpec &, const paludis::format::Plain &) const;
+ std::string format(const paludis::ConditionalDepSpec &, const paludis::format::Enabled &) const;
+ std::string format(const paludis::ConditionalDepSpec &, const paludis::format::Disabled &) const;
+ std::string format(const paludis::ConditionalDepSpec &, const paludis::format::Forced &) const;
+ std::string format(const paludis::ConditionalDepSpec &, const paludis::format::Masked &) const;
std::string format(const paludis::PackageDepSpec &, const paludis::format::Plain &) const;
std::string format(const paludis::PackageDepSpec &, const paludis::format::Installed &) const;
diff --git a/src/output/console_query_task.cc b/src/output/console_query_task.cc
index 6da8dcf..cb1cf53 100644
--- a/src/output/console_query_task.cc
+++ b/src/output/console_query_task.cc
@@ -222,7 +222,7 @@ namespace
_is_complex = true;
}
- void visit_sequence(const UseDepSpec &,
+ void visit_sequence(const ConditionalDepSpec &,
LicenseSpecTree::ConstSequenceIterator,
LicenseSpecTree::ConstSequenceIterator)
{
@@ -697,11 +697,11 @@ namespace
ConstVisitor<GenericSpecTree>,
ConstVisitor<GenericSpecTree>::VisitConstSequence<IsEmpty, AllDepSpec>,
ConstVisitor<GenericSpecTree>::VisitConstSequence<IsEmpty, AnyDepSpec>,
- ConstVisitor<GenericSpecTree>::VisitConstSequence<IsEmpty, UseDepSpec>
+ ConstVisitor<GenericSpecTree>::VisitConstSequence<IsEmpty, ConditionalDepSpec>
{
using ConstVisitor<GenericSpecTree>::VisitConstSequence<IsEmpty, AnyDepSpec>::visit_sequence;
using ConstVisitor<GenericSpecTree>::VisitConstSequence<IsEmpty, AllDepSpec>::visit_sequence;
- using ConstVisitor<GenericSpecTree>::VisitConstSequence<IsEmpty, UseDepSpec>::visit_sequence;
+ using ConstVisitor<GenericSpecTree>::VisitConstSequence<IsEmpty, ConditionalDepSpec>::visit_sequence;
bool empty;