aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-10-11 09:05:00 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-10-11 17:16:34 +0100
commitc04b6e52e6fb72b7db85a329e9d752b903d103ca (patch)
tree9ca9f05f387610b70e8c5f58400105d47fc7fdbf
parent4782eea70f1dcfabb3187f465f3f2a2ea290591a (diff)
downloadpaludis-c04b6e52e6fb72b7db85a329e9d752b903d103ca.tar.gz
paludis-c04b6e52e6fb72b7db85a329e9d752b903d103ca.tar.xz
labels track whether they're enabled
-rw-r--r--paludis/dep_label.cc13
-rw-r--r--paludis/dep_label.hh8
-rw-r--r--paludis/repositories/accounts/accounts_dep_key.cc5
-rw-r--r--paludis/repositories/cran/cran_package_id.cc9
-rw-r--r--paludis/repositories/e/dep_parser.cc19
-rw-r--r--paludis/repositories/e/dependencies_rewriter.cc5
-rw-r--r--paludis/repositories/e/e_installed_repository_id.cc18
-rw-r--r--paludis/repositories/e/ebuild_id.cc18
-rw-r--r--paludis/repositories/fake/fake_package_id.cc13
-rw-r--r--paludis/repositories/unpackaged/installed_id.cc7
-rw-r--r--paludis/repositories/unpackaged/unpackaged_id.cc7
-rw-r--r--paludis/repositories/virtuals/package_id.cc7
-rw-r--r--python/dep_label.cc17
-rwxr-xr-xpython/dep_label_TEST.py16
14 files changed, 111 insertions, 51 deletions
diff --git a/paludis/dep_label.cc b/paludis/dep_label.cc
index 8e9f68a..7aace3c 100644
--- a/paludis/dep_label.cc
+++ b/paludis/dep_label.cc
@@ -70,8 +70,10 @@ DependenciesLabel::~DependenciesLabel()
}
template <typename T_>
-ConcreteDependenciesLabel<T_>::ConcreteDependenciesLabel(const std::string & t) :
- _text(t)
+ConcreteDependenciesLabel<T_>::ConcreteDependenciesLabel(const std::string & t,
+ const std::tr1::function<bool ()> & e) :
+ _text(t),
+ _enabled(e)
{
}
@@ -87,6 +89,13 @@ ConcreteDependenciesLabel<T_>::text() const
return _text;
}
+template <typename T_>
+bool
+ConcreteDependenciesLabel<T_>::enabled() const
+{
+ return _enabled();
+}
+
template class InstantiationPolicy<DependenciesLabel, instantiation_method::NonCopyableTag>;
template class InstantiationPolicy<URILabel, instantiation_method::NonCopyableTag>;
diff --git a/paludis/dep_label.hh b/paludis/dep_label.hh
index 79ce48e..1c3b0c5 100644
--- a/paludis/dep_label.hh
+++ b/paludis/dep_label.hh
@@ -27,6 +27,7 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/attributes.hh>
#include <paludis/util/type_list.hh>
+#include <tr1/functional>
/** \file
* Declarations for dependency label-related classes.
@@ -121,6 +122,9 @@ namespace paludis
/// Our text.
virtual const std::string text() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ /// Are we enabled?
+ virtual bool enabled() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
};
/**
@@ -136,17 +140,19 @@ namespace paludis
{
private:
const std::string _text;
+ const std::tr1::function<bool ()> _enabled;
public:
///\name Basic operations
///\{
- ConcreteDependenciesLabel(const std::string &);
+ ConcreteDependenciesLabel(const std::string &, const std::tr1::function<bool ()> &);
~ConcreteDependenciesLabel();
///\}
virtual const std::string text() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual bool enabled() const PALUDIS_ATTRIBUTE((warn_unused_result));
/// Convenience typedef alias to obtain our tag.
typedef T_ Tag;
diff --git a/paludis/repositories/accounts/accounts_dep_key.cc b/paludis/repositories/accounts/accounts_dep_key.cc
index f976d29..faeba26 100644
--- a/paludis/repositories/accounts/accounts_dep_key.cc
+++ b/paludis/repositories/accounts/accounts_dep_key.cc
@@ -20,6 +20,7 @@
#include <paludis/repositories/accounts/accounts_dep_key.hh>
#include <paludis/util/set.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/return_literal_function.hh>
#include <paludis/selection.hh>
#include <paludis/generator.hh>
#include <paludis/filtered_generator.hh>
@@ -57,8 +58,8 @@ namespace paludis
tree->root()->append(spec);
}
- initial_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("build")));
- initial_labels->push_back(make_shared_ptr(new DependenciesRunLabel("run")));
+ initial_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("build", return_literal_function(true))));
+ initial_labels->push_back(make_shared_ptr(new DependenciesRunLabel("run", return_literal_function(true))));
}
};
}
diff --git a/paludis/repositories/cran/cran_package_id.cc b/paludis/repositories/cran/cran_package_id.cc
index c99ff6b..762c464 100644
--- a/paludis/repositories/cran/cran_package_id.cc
+++ b/paludis/repositories/cran/cran_package_id.cc
@@ -33,6 +33,7 @@
#include <paludis/util/stringify.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/return_literal_function.hh>
#include <paludis/literal_metadata_key.hh>
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
@@ -85,8 +86,8 @@ namespace paludis
suggests_labels(new DependenciesLabelSequence),
depends_labels(new DependenciesLabelSequence)
{
- suggests_labels->push_back(make_shared_ptr(new DependenciesSuggestionLabel("Suggests")));
- depends_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("Depends")));
+ suggests_labels->push_back(make_shared_ptr(new DependenciesSuggestionLabel("Suggests", return_literal_function(true))));
+ depends_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("Depends", return_literal_function(true))));
}
Implementation(const Environment * const e,
@@ -100,8 +101,8 @@ namespace paludis
suggests_labels(new DependenciesLabelSequence),
depends_labels(new DependenciesLabelSequence)
{
- suggests_labels->push_back(make_shared_ptr(new DependenciesSuggestionLabel("Suggests")));
- depends_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("Depends")));
+ suggests_labels->push_back(make_shared_ptr(new DependenciesSuggestionLabel("Suggests", return_literal_function(true))));
+ depends_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("Depends", return_literal_function(true))));
}
};
}
diff --git a/paludis/repositories/e/dep_parser.cc b/paludis/repositories/e/dep_parser.cc
index 55bdc57..463a180 100644
--- a/paludis/repositories/e/dep_parser.cc
+++ b/paludis/repositories/e/dep_parser.cc
@@ -26,6 +26,7 @@
#include <paludis/util/make_named_values.hh>
#include <paludis/util/map.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/return_literal_function.hh>
#include <paludis/elike_dep_parser.hh>
#include <paludis/elike_conditional_dep_spec.hh>
#include <paludis/elike_package_dep_spec.hh>
@@ -688,23 +689,23 @@ paludis::erepository::parse_dependency_label(const std::string & s, const EAPI &
throw EDepParseError(s, "Unknown label '" + *it + "'");
if (c == "DependenciesBuildLabel")
- l->add_label(make_shared_ptr(new DependenciesBuildLabel(*it)));
+ l->add_label(make_shared_ptr(new DependenciesBuildLabel(*it, return_literal_function(true))));
else if (c == "DependenciesRunLabel")
- l->add_label(make_shared_ptr(new DependenciesRunLabel(*it)));
+ l->add_label(make_shared_ptr(new DependenciesRunLabel(*it, return_literal_function(true))));
else if (c == "DependenciesPostLabel")
- l->add_label(make_shared_ptr(new DependenciesPostLabel(*it)));
+ l->add_label(make_shared_ptr(new DependenciesPostLabel(*it, return_literal_function(true))));
else if (c == "DependenciesInstallLabel")
- l->add_label(make_shared_ptr(new DependenciesInstallLabel(*it)));
+ l->add_label(make_shared_ptr(new DependenciesInstallLabel(*it, return_literal_function(true))));
else if (c == "DependenciesCompileAgainstLabel")
- l->add_label(make_shared_ptr(new DependenciesCompileAgainstLabel(*it)));
+ l->add_label(make_shared_ptr(new DependenciesCompileAgainstLabel(*it, return_literal_function(true))));
else if (c == "DependenciesFetchLabel")
- l->add_label(make_shared_ptr(new DependenciesFetchLabel(*it)));
+ l->add_label(make_shared_ptr(new DependenciesFetchLabel(*it, return_literal_function(true))));
else if (c == "DependenciesSuggestionLabel")
- l->add_label(make_shared_ptr(new DependenciesSuggestionLabel(*it)));
+ l->add_label(make_shared_ptr(new DependenciesSuggestionLabel(*it, return_literal_function(true))));
else if (c == "DependenciesRecommendationLabel")
- l->add_label(make_shared_ptr(new DependenciesRecommendationLabel(*it)));
+ l->add_label(make_shared_ptr(new DependenciesRecommendationLabel(*it, return_literal_function(true))));
else if (c == "DependenciesTestLabel")
- l->add_label(make_shared_ptr(new DependenciesTestLabel(*it)));
+ l->add_label(make_shared_ptr(new DependenciesTestLabel(*it, return_literal_function(true))));
else
throw EDepParseError(s, "Label '" + *it + "' maps to unknown class '" + c + "'");
}
diff --git a/paludis/repositories/e/dependencies_rewriter.cc b/paludis/repositories/e/dependencies_rewriter.cc
index c5b34cf..32165a7 100644
--- a/paludis/repositories/e/dependencies_rewriter.cc
+++ b/paludis/repositories/e/dependencies_rewriter.cc
@@ -21,6 +21,7 @@
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/return_literal_function.hh>
#include <paludis/util/save.hh>
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/simple_visitor_cast.hh>
@@ -73,8 +74,8 @@ namespace paludis
Implementation() :
default_labels(new DependenciesLabelSequence)
{
- default_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("build")));
- default_labels->push_back(make_shared_ptr(new DependenciesRunLabel("run")));
+ default_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("build", return_literal_function(true))));
+ default_labels->push_back(make_shared_ptr(new DependenciesRunLabel("run", return_literal_function(true))));
labels.push_front(default_labels);
}
};
diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc
index 79e8470..902180f 100644
--- a/paludis/repositories/e/e_installed_repository_id.cc
+++ b/paludis/repositories/e/e_installed_repository_id.cc
@@ -43,6 +43,7 @@
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/safe_ifstream.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/util/return_literal_function.hh>
#include <paludis/output_manager.hh>
#include <paludis/literal_metadata_key.hh>
#include <paludis/user_dep_spec.hh>
@@ -139,12 +140,17 @@ namespace paludis
run_dependencies_labels(new DependenciesLabelSequence),
post_dependencies_labels(new DependenciesLabelSequence)
{
- raw_dependencies_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("build")));
- raw_dependencies_labels->push_back(make_shared_ptr(new DependenciesRunLabel("run")));
-
- build_dependencies_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("DEPEND")));
- run_dependencies_labels->push_back(make_shared_ptr(new DependenciesRunLabel("RDEPEND")));
- post_dependencies_labels->push_back(make_shared_ptr(new DependenciesPostLabel("PDEPEND")));
+ raw_dependencies_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("build",
+ return_literal_function(true))));
+ raw_dependencies_labels->push_back(make_shared_ptr(new DependenciesRunLabel("run",
+ return_literal_function(true))));
+
+ build_dependencies_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("DEPEND",
+ return_literal_function(true))));
+ run_dependencies_labels->push_back(make_shared_ptr(new DependenciesRunLabel("RDEPEND",
+ return_literal_function(true))));
+ post_dependencies_labels->push_back(make_shared_ptr(new DependenciesPostLabel("PDEPEND",
+ return_literal_function(true))));
}
};
}
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index 370249a..889b002 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -52,6 +52,7 @@
#include <paludis/util/make_named_values.hh>
#include <paludis/util/tribool.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/return_literal_function.hh>
#include <set>
#include <iterator>
@@ -135,12 +136,17 @@ namespace paludis
run_dependencies_labels(new DependenciesLabelSequence),
post_dependencies_labels(new DependenciesLabelSequence)
{
- raw_dependencies_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("build")));
- raw_dependencies_labels->push_back(make_shared_ptr(new DependenciesRunLabel("run")));
-
- build_dependencies_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("DEPEND")));
- run_dependencies_labels->push_back(make_shared_ptr(new DependenciesRunLabel("RDEPEND")));
- post_dependencies_labels->push_back(make_shared_ptr(new DependenciesPostLabel("PDEPEND")));
+ raw_dependencies_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("build",
+ return_literal_function(true))));
+ raw_dependencies_labels->push_back(make_shared_ptr(new DependenciesRunLabel("run",
+ return_literal_function(true))));
+
+ build_dependencies_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("DEPEND",
+ return_literal_function(true))));
+ run_dependencies_labels->push_back(make_shared_ptr(new DependenciesRunLabel("RDEPEND",
+ return_literal_function(true))));
+ post_dependencies_labels->push_back(make_shared_ptr(new DependenciesPostLabel("PDEPEND",
+ return_literal_function(true))));
}
};
}
diff --git a/paludis/repositories/fake/fake_package_id.cc b/paludis/repositories/fake/fake_package_id.cc
index 802ac67..34e6f9a 100644
--- a/paludis/repositories/fake/fake_package_id.cc
+++ b/paludis/repositories/fake/fake_package_id.cc
@@ -40,6 +40,7 @@
#include <paludis/util/tribool.hh>
#include <paludis/util/wrapped_output_iterator.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/util/return_literal_function.hh>
#include <map>
#include <list>
#include <sstream>
@@ -657,10 +658,14 @@ namespace paludis
keywords(new FakeMetadataKeywordSetKey("KEYWORDS", "Keywords", "test", mkt_normal, id, env)),
has_masks(false)
{
- build_dependencies_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("DEPEND")));
- run_dependencies_labels->push_back(make_shared_ptr(new DependenciesRunLabel("RDEPEND")));
- post_dependencies_labels->push_back(make_shared_ptr(new DependenciesPostLabel("PDEPEND")));
- suggested_dependencies_labels->push_back(make_shared_ptr(new DependenciesSuggestionLabel("SDEPEND")));
+ build_dependencies_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("DEPEND",
+ return_literal_function(true))));
+ run_dependencies_labels->push_back(make_shared_ptr(new DependenciesRunLabel("RDEPEND",
+ return_literal_function(true))));
+ post_dependencies_labels->push_back(make_shared_ptr(new DependenciesPostLabel("PDEPEND",
+ return_literal_function(true))));
+ suggested_dependencies_labels->push_back(make_shared_ptr(new DependenciesSuggestionLabel("SDEPEND",
+ return_literal_function(true))));
}
};
}
diff --git a/paludis/repositories/unpackaged/installed_id.cc b/paludis/repositories/unpackaged/installed_id.cc
index 1d43650..38055a0 100644
--- a/paludis/repositories/unpackaged/installed_id.cc
+++ b/paludis/repositories/unpackaged/installed_id.cc
@@ -34,6 +34,7 @@
#include <paludis/util/make_named_values.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/safe_ifstream.hh>
+#include <paludis/util/return_literal_function.hh>
#include <paludis/output_manager.hh>
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
@@ -423,8 +424,10 @@ namespace paludis
slot_key(new LiteralMetadataValueKey<SlotName> ("slot", "Slot", mkt_internal, s)),
fs_location_key(new InstalledUnpackagedFSEntryKey(l))
{
- build_dependencies_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("build_dependencies")));
- run_dependencies_labels->push_back(make_shared_ptr(new DependenciesRunLabel("run_dependencies")));
+ build_dependencies_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("build_dependencies",
+ return_literal_function(true))));
+ run_dependencies_labels->push_back(make_shared_ptr(new DependenciesRunLabel("run_dependencies",
+ return_literal_function(true))));
if ((l / "contents").exists())
{
diff --git a/paludis/repositories/unpackaged/unpackaged_id.cc b/paludis/repositories/unpackaged/unpackaged_id.cc
index 3fb970d..4c3a1ac 100644
--- a/paludis/repositories/unpackaged/unpackaged_id.cc
+++ b/paludis/repositories/unpackaged/unpackaged_id.cc
@@ -30,6 +30,7 @@
#include <paludis/util/log.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/util/return_literal_function.hh>
#include <paludis/output_manager.hh>
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
@@ -90,8 +91,10 @@ namespace paludis
description_key(new LiteralMetadataValueKey<std::string> ("description", "Description", mkt_significant, d)),
choices_key(new UnpackagedChoicesKey(env, "choices", "Choices", mkt_normal, id))
{
- build_dependencies_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("build_dependencies")));
- run_dependencies_labels->push_back(make_shared_ptr(new DependenciesRunLabel("run_dependencies")));
+ build_dependencies_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("build_dependencies",
+ return_literal_function(true))));
+ run_dependencies_labels->push_back(make_shared_ptr(new DependenciesRunLabel("run_dependencies",
+ return_literal_function(true))));
}
};
}
diff --git a/paludis/repositories/virtuals/package_id.cc b/paludis/repositories/virtuals/package_id.cc
index cd66923..ab07b79 100644
--- a/paludis/repositories/virtuals/package_id.cc
+++ b/paludis/repositories/virtuals/package_id.cc
@@ -26,6 +26,7 @@
#include <paludis/util/mutex.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/util/return_literal_function.hh>
#include <paludis/name.hh>
#include <paludis/dep_spec.hh>
#include <paludis/version_spec.hh>
@@ -190,8 +191,10 @@ namespace paludis
rdep(new virtuals::VirtualsDepKey(e, "RDEPEND", "Run dependencies", p, rdep_labels, b)),
has_masks(false)
{
- bdep_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("DEPEND")));
- rdep_labels->push_back(make_shared_ptr(new DependenciesRunLabel("RDEPEND")));
+ bdep_labels->push_back(make_shared_ptr(new DependenciesBuildLabel("DEPEND",
+ return_literal_function(true))));
+ rdep_labels->push_back(make_shared_ptr(new DependenciesRunLabel("RDEPEND",
+ return_literal_function(true))));
}
};
}
diff --git a/python/dep_label.cc b/python/dep_label.cc
index 4f5d4c9..d01a2bf 100644
--- a/python/dep_label.cc
+++ b/python/dep_label.cc
@@ -22,11 +22,21 @@
#include <python/iterable.hh>
#include <paludis/dep_label.hh>
+#include <paludis/util/return_literal_function.hh>
using namespace paludis;
using namespace paludis::python;
namespace bp = boost::python;
+namespace
+{
+ template <typename T_>
+ T_ * make_concrete_dependencies_label(const std::string & t, const bool b)
+ {
+ return new T_(t, return_literal_function(b));
+ }
+}
+
template <typename L_>
struct class_concrete_uri_label :
bp::class_<L_, std::tr1::shared_ptr<L_>, bp::bases<URILabel>, boost::noncopyable>
@@ -52,9 +62,14 @@ struct class_concrete_dependencies_label :
(
name.c_str(),
"A concrete dependencies label class.",
- bp::init<const std::string &>("__init__(string)")
+ bp::no_init
)
{
+ def("__init__",
+ bp::make_constructor(&make_concrete_dependencies_label<L_>),
+ "__init__(String, bool)"
+ );
+
bp::implicitly_convertible<std::tr1::shared_ptr<L_>, std::tr1::shared_ptr<DependenciesLabel> >();
}
};
diff --git a/python/dep_label_TEST.py b/python/dep_label_TEST.py
index eaf1837..e469256 100755
--- a/python/dep_label_TEST.py
+++ b/python/dep_label_TEST.py
@@ -49,14 +49,14 @@ class TestCase_01_URILabels(unittest.TestCase):
class TestCase_02_DependenciesLabels(unittest.TestCase):
def setUp(self):
self.list = []
- self.list.append((DependenciesBuildLabel("foo"), DependenciesLabel))
- self.list.append((DependenciesRunLabel("foo"), DependenciesLabel))
- self.list.append((DependenciesPostLabel("foo"), DependenciesLabel))
- self.list.append((DependenciesCompileAgainstLabel("foo"), DependenciesLabel))
- self.list.append((DependenciesInstallLabel("foo"), DependenciesLabel))
- self.list.append((DependenciesFetchLabel("foo"), DependenciesLabel))
- self.list.append((DependenciesSuggestionLabel("foo"), DependenciesLabel))
- self.list.append((DependenciesRecommendationLabel("foo"), DependenciesLabel))
+ self.list.append((DependenciesBuildLabel("foo", True), DependenciesLabel))
+ self.list.append((DependenciesRunLabel("foo", True), DependenciesLabel))
+ self.list.append((DependenciesPostLabel("foo", True), DependenciesLabel))
+ self.list.append((DependenciesCompileAgainstLabel("foo", True), DependenciesLabel))
+ self.list.append((DependenciesInstallLabel("foo", True), DependenciesLabel))
+ self.list.append((DependenciesFetchLabel("foo", True), DependenciesLabel))
+ self.list.append((DependenciesSuggestionLabel("foo", True), DependenciesLabel))
+ self.list.append((DependenciesRecommendationLabel("foo", True), DependenciesLabel))
def test_01_no_create(self):
self.assertRaises(Exception, DependenciesLabel)