aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-05-19 14:20:48 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-05-19 20:52:24 +0100
commite52571861104efe6139b78b22557211f08025f11 (patch)
tree634bec98491886d12f8f5a25b24f4cacf8d69de5
parent80bf4ad14bfd8ab74a9c0d5f203ad5a370351def (diff)
downloadpaludis-e52571861104efe6139b78b22557211f08025f11.tar.gz
paludis-e52571861104efe6139b78b22557211f08025f11.tar.xz
Revert the package dep spec changes
-rw-r--r--.gitignore1
-rw-r--r--doc/api/cplusplus/examples/example_dep_spec.cc86
-rw-r--r--doc/api/cplusplus/examples/example_match_package.cc2
-rw-r--r--doc/api/cplusplus/examples/example_selection.cc8
-rw-r--r--doc/configuration/specs.html.part11
-rw-r--r--paludis/additional_package_dep_spec_requirement-fwd.hh48
-rw-r--r--paludis/additional_package_dep_spec_requirement.cc38
-rw-r--r--paludis/additional_package_dep_spec_requirement.hh119
-rw-r--r--paludis/changed_choices.cc14
-rw-r--r--paludis/changed_choices.hh4
-rw-r--r--paludis/common_sets.cc15
-rw-r--r--paludis/dep_spec-fwd.hh3
-rw-r--r--paludis/dep_spec.cc449
-rw-r--r--paludis/dep_spec.hh171
-rw-r--r--paludis/dep_spec_TEST.cc1
-rw-r--r--paludis/dep_spec_data-fwd.hh19
-rw-r--r--paludis/dep_spec_data.cc390
-rw-r--r--paludis/dep_spec_data.hh252
-rw-r--r--paludis/dep_spec_data.se19
-rw-r--r--paludis/elike_package_dep_spec-fwd.hh30
-rw-r--r--paludis/elike_package_dep_spec.cc208
-rw-r--r--paludis/elike_package_dep_spec.hh20
-rw-r--r--paludis/elike_slot_requirement-fwd.hh30
-rw-r--r--paludis/elike_slot_requirement.cc54
-rw-r--r--paludis/elike_slot_requirement.hh58
-rw-r--r--paludis/elike_use_requirement-fwd.hh4
-rw-r--r--paludis/elike_use_requirement.cc22
-rw-r--r--paludis/elike_use_requirement_TEST.cc180
-rw-r--r--paludis/environment_implementation.cc4
-rw-r--r--paludis/environments/paludis/keywords_conf.cc16
-rw-r--r--paludis/environments/paludis/licenses_conf.cc14
-rw-r--r--paludis/environments/paludis/suggestions_conf.cc20
-rw-r--r--paludis/environments/paludis/world.cc10
-rw-r--r--paludis/environments/paludis/world_TEST.cc6
-rw-r--r--paludis/environments/portage/portage_environment.cc29
-rw-r--r--paludis/environments/portage/portage_environment_TEST.cc6
-rw-r--r--paludis/files.m48
-rw-r--r--paludis/filter.cc4
-rw-r--r--paludis/fuzzy_finder.cc15
-rw-r--r--paludis/generator.cc65
-rw-r--r--paludis/match_package.cc275
-rw-r--r--paludis/match_package.se2
-rw-r--r--paludis/package_dep_spec_collection.cc5
-rw-r--r--paludis/package_dep_spec_properties.cc180
-rw-r--r--paludis/package_dep_spec_properties.hh30
-rw-r--r--paludis/package_dep_spec_requirement-fwd.hh82
-rw-r--r--paludis/package_dep_spec_requirement.cc1156
-rw-r--r--paludis/package_dep_spec_requirement.hh399
-rw-r--r--paludis/package_dep_spec_requirement.se33
-rw-r--r--paludis/paludislike_options_conf.cc31
-rw-r--r--paludis/partially_made_package_dep_spec-fwd.hh53
-rw-r--r--paludis/partially_made_package_dep_spec.cc567
-rw-r--r--paludis/partially_made_package_dep_spec.hh211
-rw-r--r--paludis/partially_made_package_dep_spec.se19
-rw-r--r--paludis/repositories/accounts/accounts_dep_key.cc12
-rw-r--r--paludis/repositories/e/Makefile.am2
-rw-r--r--paludis/repositories/e/e_repository_sets.cc24
-rw-r--r--paludis/repositories/e/exheres_mask_store.cc5
-rw-r--r--paludis/repositories/e/fix_locked_dependencies.cc18
-rw-r--r--paludis/repositories/e/split_pn_v.cc91
-rw-r--r--paludis/repositories/e/traditional_mask_store.cc7
-rw-r--r--paludis/repositories/e/traditional_profile.cc5
-rw-r--r--paludis/repositories/e/vdb_repository.cc29
-rw-r--r--paludis/repositories/gemcutter/gemcutter_dependencies_key.cc15
-rw-r--r--paludis/repositories/virtuals/package_id.cc23
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc4
-rw-r--r--paludis/resolver/collect_depped_upon.cc16
-rw-r--r--paludis/resolver/decider.cc122
-rw-r--r--paludis/resolver/find_replacing_helper.cc2
-rw-r--r--paludis/resolver/get_constraints_for_dependent_helper.cc11
-rw-r--r--paludis/resolver/get_constraints_for_purge_helper.cc11
-rw-r--r--paludis/resolver/get_constraints_for_via_binary_helper.cc8
-rw-r--r--paludis/resolver/get_destination_types_for_blocker_helper.cc2
-rw-r--r--paludis/resolver/get_destination_types_for_error_helper.cc2
-rw-r--r--paludis/resolver/get_initial_constraints_for_helper.cc7
-rw-r--r--paludis/resolver/get_resolvents_for_helper.cc8
-rw-r--r--paludis/resolver/get_use_existing_nothing_helper.cc7
-rw-r--r--paludis/resolver/interest_in_spec_helper.cc5
-rw-r--r--paludis/resolver/match_qpns.cc17
-rw-r--r--paludis/resolver/orderer.cc11
-rw-r--r--paludis/resolver/resolvent.cc7
-rw-r--r--paludis/resolver/resolver_test.cc2
-rw-r--r--paludis/resolver/sanitised_dependencies.cc5
-rw-r--r--paludis/resolver/spec_rewriter.cc25
-rw-r--r--paludis/set_file.cc26
-rw-r--r--paludis/slot_requirement-fwd.hh (renamed from paludis/repositories/e/split_pn_v.hh)25
-rw-r--r--paludis/slot_requirement.cc31
-rw-r--r--paludis/slot_requirement.hh59
-rw-r--r--paludis/user_dep_spec-fwd.hh6
-rw-r--r--paludis/user_dep_spec.cc765
-rw-r--r--paludis/user_dep_spec.hh65
-rw-r--r--paludis/user_dep_spec_TEST.cc141
-rw-r--r--paludis/version_operator.hh7
-rw-r--r--paludis/version_requirements-fwd.hh71
-rw-r--r--paludis/version_requirements.cc58
-rw-r--r--paludis/version_requirements.hh64
-rw-r--r--python/Makefile.am3
-rw-r--r--python/dep_spec.cc287
-rw-r--r--python/dep_spec.hh20
-rwxr-xr-xpython/dep_spec_TEST.py18
-rw-r--r--python/generator_TEST.py6
-rwxr-xr-xpython/mask_TEST.py2
-rw-r--r--python/package_dep_spec_constraint.cc253
-rw-r--r--python/paludis_python.hh2
-rw-r--r--python/paludis_python_so.cc2
-rw-r--r--python/version_requirements.cc85
-rwxr-xr-xpython/version_requirements_TEST.py38
-rw-r--r--ruby/Makefile.am1
-rwxr-xr-xruby/demos/find_unmanaged_files.rb8
-rw-r--r--ruby/dep_spec.cc291
-rw-r--r--ruby/dep_spec_TEST.rb114
-rw-r--r--ruby/generator_TEST.rb4
-rw-r--r--ruby/package_dep_spec_constraint.cc527
-rw-r--r--ruby/paludis_ruby.cc8
-rw-r--r--ruby/paludis_ruby.hh1
-rw-r--r--src/clients/cave/cmd_digest.cc4
-rwxr-xr-xsrc/clients/cave/cmd_display_resolution.cc31
-rw-r--r--src/clients/cave/cmd_execute_resolution.cc13
-rw-r--r--src/clients/cave/cmd_fix_linkage.cc15
-rw-r--r--src/clients/cave/cmd_graph_jobs.cc17
-rw-r--r--src/clients/cave/cmd_mirror.cc1
-rw-r--r--src/clients/cave/cmd_print_spec.cc123
-rw-r--r--src/clients/cave/cmd_report.cc12
-rw-r--r--src/clients/cave/cmd_show.cc36
-rw-r--r--src/clients/cave/resolve_common.cc19
125 files changed, 3932 insertions, 5326 deletions
diff --git a/.gitignore b/.gitignore
index 341c279..5a22b83 100644
--- a/.gitignore
+++ b/.gitignore
@@ -265,7 +265,6 @@ paludis-*.*.*.tar.bz2
/paludis/ihateautomake.cc
/paludis/name_TEST
/paludis/paludis.hh
-/paludis/partially_made_package_dep_spec_TEST
/paludis/repositories/accounts/accounts_repository_TEST
/paludis/repositories/e/aa_visitor_TEST
/paludis/repositories/e/dep_parser_TEST
diff --git a/doc/api/cplusplus/examples/example_dep_spec.cc b/doc/api/cplusplus/examples/example_dep_spec.cc
index 3a2cc54..081b201 100644
--- a/doc/api/cplusplus/examples/example_dep_spec.cc
+++ b/doc/api/cplusplus/examples/example_dep_spec.cc
@@ -59,39 +59,85 @@ int main(int argc, char * argv[])
/* Display information about the PackageDepSpec. */
cout << "Information about '" << spec << "':" << endl;
- if (spec.package_name_requirement())
- cout << " " << left << setw(24) << "Package:" << " " << spec.package_name_requirement()->name() << endl;
+ if (spec.package_ptr())
+ cout << " " << left << setw(24) << "Package:" << " " << *spec.package_ptr() << endl;
- if (spec.category_name_part_requirement())
- cout << " " << left << setw(24) << "Category part:" << " " << spec.category_name_part_requirement()->name_part() << endl;
+ if (spec.category_name_part_ptr())
+ cout << " " << left << setw(24) << "Category part:" << " " << *spec.category_name_part_ptr() << endl;
- if (spec.package_name_part_requirement())
- cout << " " << left << setw(24) << "Package part:" << " " << spec.package_name_part_requirement()->name_part() << endl;
+ if (spec.package_name_part_ptr())
+ cout << " " << left << setw(24) << "Package part:" << " " << *spec.package_name_part_ptr() << endl;
- if (spec.exact_slot_requirement())
- cout << " " << left << setw(24) << "Slot:" << " " << spec.exact_slot_requirement()->name() << endl;
+ if (spec.version_requirements_ptr() && ! spec.version_requirements_ptr()->empty())
+ {
+ cout << " " << left << setw(24) << "Version requirements:" << " ";
+ bool need_join(false);
+ for (VersionRequirements::ConstIterator r(spec.version_requirements_ptr()->begin()),
+ r_end(spec.version_requirements_ptr()->end()) ; r != r_end ; ++r)
+ {
+ if (need_join)
+ {
+ switch (spec.version_requirements_mode())
+ {
+ case vr_and:
+ cout << " and ";
+ break;
+
+ case vr_or:
+ cout << " or ";
+ break;
+
+ case last_vr:
+ throw InternalError(PALUDIS_HERE, "Bad version_requirements_mode");
+ }
+ }
+
+ cout << r->version_operator() << r->version_spec();
+ need_join = true;
+ }
+ cout << endl;
+ }
+
+ if (spec.slot_requirement_ptr())
+ cout << " " << left << setw(24) << "Slot:" << " " << *spec.slot_requirement_ptr() << endl;
- if (spec.in_repository_requirement())
+ if (spec.in_repository_ptr())
cout << " " << left << setw(24) << "In repository:" << " " <<
- spec.in_repository_requirement()->name() << endl;
+ *spec.in_repository_ptr() << endl;
- if (spec.from_repository_requirement())
+ if (spec.from_repository_ptr())
cout << " " << left << setw(24) << "From repository:" << " " <<
- spec.from_repository_requirement()->name() << endl;
+ *spec.from_repository_ptr() << endl;
- if (spec.installed_at_path_requirement())
+ if (spec.installed_at_path_ptr())
cout << " " << left << setw(24) << "Installed at path:" << " " <<
- spec.installed_at_path_requirement()->path() << endl;
+ *spec.installed_at_path_ptr() << endl;
- if (spec.installable_to_path_requirement())
+ if (spec.installable_to_path_ptr())
cout << " " << left << setw(24) << "Installable to path:" << " " <<
- spec.installable_to_path_requirement()->path() << ", " <<
- spec.installable_to_path_requirement()->include_masked() << endl;
+ spec.installable_to_path_ptr()->path() << ", " <<
+ spec.installable_to_path_ptr()->include_masked() << endl;
- if (spec.installable_to_repository_requirement())
+ if (spec.installable_to_repository_ptr())
cout << " " << left << setw(24) << "Installable to repository:" << " " <<
- spec.installable_to_repository_requirement()->name() << ", " <<
- spec.installable_to_repository_requirement()->include_masked() << endl;
+ spec.installable_to_repository_ptr()->repository() << ", " <<
+ spec.installable_to_repository_ptr()->include_masked() << endl;
+
+ if (spec.additional_requirements_ptr() && ! spec.additional_requirements_ptr()->empty())
+ {
+ cout << " " << left << setw(24) << "Additional requirements:" << " ";
+ bool need_join(false);
+ for (AdditionalPackageDepSpecRequirements::ConstIterator u(spec.additional_requirements_ptr()->begin()),
+ u_end(spec.additional_requirements_ptr()->end()) ; u != u_end ; ++u)
+ {
+ if (need_join)
+ cout << " and ";
+
+ cout << (*u)->as_raw_string() + " (meaning: " + (*u)->as_human_string(make_null_shared_ptr()) + ")";
+ need_join = true;
+ }
+ cout << endl;
+ }
/* And display packages matching that spec */
cout << " " << left << setw(24) << "Matches:" << " ";
diff --git a/doc/api/cplusplus/examples/example_match_package.cc b/doc/api/cplusplus/examples/example_match_package.cc
index 94abb4c..c308f8d 100644
--- a/doc/api/cplusplus/examples/example_match_package.cc
+++ b/doc/api/cplusplus/examples/example_match_package.cc
@@ -54,7 +54,7 @@ int main(int argc, char * argv[])
i != i_end ; ++i)
{
/* Is it paludis? */
- if (match_package(*env, MutablePackageDepSpecData({ }).require_package(
+ if (match_package(*env, make_package_dep_spec({ }).package(
QualifiedPackageName("sys-apps/paludis")), *i, make_null_shared_ptr(), { }))
cout << left << setw(50) << (stringify(**i) + ":") << " " << "paludis" << endl;
diff --git a/doc/api/cplusplus/examples/example_selection.cc b/doc/api/cplusplus/examples/example_selection.cc
index f71a6ba..ad60e36 100644
--- a/doc/api/cplusplus/examples/example_selection.cc
+++ b/doc/api/cplusplus/examples/example_selection.cc
@@ -62,13 +62,13 @@ int main(int argc, char * argv[])
* object used determines the number and ordering of results. In the
* simplest form, it takes a Generator as a parameter. */
show_selection(env, selection::AllVersionsSorted(
- generator::Matches(MutablePackageDepSpecData({ }).require_package(
+ generator::Matches(make_package_dep_spec({ }).package(
QualifiedPackageName("sys-apps/paludis")), make_null_shared_ptr(), { })));
/* Generators can be passed through a Filter. The Selection optimises
* the code internally to avoid doing excess work. */
show_selection(env, selection::AllVersionsSorted(
- generator::Matches(MutablePackageDepSpecData({ }).require_package(
+ generator::Matches(make_package_dep_spec({ }).package(
QualifiedPackageName("sys-apps/paludis")), make_null_shared_ptr(), { }) |
filter::InstalledAtSlash()));
@@ -76,7 +76,7 @@ int main(int argc, char * argv[])
* with filter::SupportsAction<InstallAction>, since installed packages
* aren't masked. */
show_selection(env, selection::AllVersionsSorted(
- generator::Matches(MutablePackageDepSpecData({ }).require_package(
+ generator::Matches(make_package_dep_spec({ }).package(
QualifiedPackageName("sys-apps/paludis")), make_null_shared_ptr(), { }) |
filter::SupportsAction<InstallAction>() |
filter::NotMasked()));
@@ -85,7 +85,7 @@ int main(int argc, char * argv[])
* is no metadata cache. Consider using other Selection objects if
* you only need the best matching or some arbitrary matching ID. */
show_selection(env, selection::BestVersionOnly(
- generator::Matches(MutablePackageDepSpecData({ }).require_package(
+ generator::Matches(make_package_dep_spec({ }).package(
QualifiedPackageName("sys-apps/paludis")), make_null_shared_ptr(), { }) |
filter::SupportsAction<InstallAction>() |
filter::NotMasked()));
diff --git a/doc/configuration/specs.html.part b/doc/configuration/specs.html.part
index 40833f3..ed37606 100644
--- a/doc/configuration/specs.html.part
+++ b/doc/configuration/specs.html.part
@@ -40,16 +40,15 @@ the following order:</p>
<li><code>[.key?]</code>: Match only if the specified metadata key exists. <code>key</code> may be a key's raw
name (e.g. <code>DESCRIPTION</code>, <code>DEPEND</code>) or a role prefixed with a dollar sign (e.g.
<code>$short_description</code>, <code>$build_dependencies</code>). If the key's name is prefixed with
- <code>::</code>, metadata from the repository rather than the package ID is checked. If the key is in
- <code>(parens)</code>, matches masks by role, token or associated key (and <code>(*)</code> matches any mask).</li>
+ <code>::</code>, metadata from the repository rather than the package ID is checked.</li>
<li><code>[.key=value]</code>: Match only if the specified metadata key has a particular exact value. Only works for
simple values, sets and sequences, not spec trees and other complex compound keys. If <code>&lt;</code> is used in
place of <code>=</code>, for numeric values a less-than comparison is used, and for sets, sequences and spec trees,
- a match occurs if any member of the set or sequence is equal to the value. If <code>&gt;</code> is used,
- for numeric values a greater-than comparison is used; it does not match for other types of values. If <code>~</code>
- is used, a substring match is performed. As above, the key may be a raw name or a dollar-prefixed role name, and
- may be prefixed with <code>::</code> for checking repository metadata.</li>
+ a match occurs if any member of the set or sequence is equal to the value. Similarly if <code>&gt;</code> is used,
+ for numeric values a greater-than comparison is used; it does not match for other types of values. As above, the key
+ may be a raw name or a dollar-prefixed role name, and may be prefixed with <code>::</code> for checking repository
+ metadata.</li>
</ul>
<p>Repository requirements are in the form <code>to</code>, <code>from-&gt;</code> or <code>::from-&gt;to</code>. The
diff --git a/paludis/additional_package_dep_spec_requirement-fwd.hh b/paludis/additional_package_dep_spec_requirement-fwd.hh
new file mode 100644
index 0000000..d45db55
--- /dev/null
+++ b/paludis/additional_package_dep_spec_requirement-fwd.hh
@@ -0,0 +1,48 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010 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_ADDITIONAL_PACKAGE_DEP_SPEC_REQUIREMENT_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_ADDITIONAL_PACKAGE_DEP_SPEC_REQUIREMENT_FWD_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <paludis/util/sequence-fwd.hh>
+#include <iosfwd>
+#include <memory>
+
+namespace paludis
+{
+ class AdditionalPackageDepSpecRequirement;
+
+ /**
+ * An AdditionalPackageDepSpecRequirement can be written to an ostream.
+ *
+ * \ingroup g_dep_spec
+ */
+ std::ostream & operator<< (std::ostream &, const AdditionalPackageDepSpecRequirement &) PALUDIS_VISIBLE;
+
+ /**
+ * A collection of additional requirements for a PackageDepSpec.
+ *
+ * \since 0.26
+ * \ingroup g_dep_spec
+ */
+ typedef Sequence<std::shared_ptr<const AdditionalPackageDepSpecRequirement> > AdditionalPackageDepSpecRequirements;
+}
+
+#endif
diff --git a/paludis/additional_package_dep_spec_requirement.cc b/paludis/additional_package_dep_spec_requirement.cc
new file mode 100644
index 0000000..e6d09a5
--- /dev/null
+++ b/paludis/additional_package_dep_spec_requirement.cc
@@ -0,0 +1,38 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010 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/additional_package_dep_spec_requirement.hh>
+#include <paludis/util/sequence-impl.hh>
+#include <paludis/util/wrapped_forward_iterator-impl.hh>
+#include <ostream>
+
+using namespace paludis;
+
+AdditionalPackageDepSpecRequirement::~AdditionalPackageDepSpecRequirement() = default;
+
+std::ostream &
+paludis::operator<< (std::ostream & s, const AdditionalPackageDepSpecRequirement & a)
+{
+ s << a.as_raw_string();
+ return s;
+}
+
+template class Sequence<std::shared_ptr<const AdditionalPackageDepSpecRequirement> >;
+template class WrappedForwardIterator<AdditionalPackageDepSpecRequirements::ConstIteratorTag, const std::shared_ptr<const AdditionalPackageDepSpecRequirement> >;
+
diff --git a/paludis/additional_package_dep_spec_requirement.hh b/paludis/additional_package_dep_spec_requirement.hh
new file mode 100644
index 0000000..318e75d
--- /dev/null
+++ b/paludis/additional_package_dep_spec_requirement.hh
@@ -0,0 +1,119 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011 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_ADDITIONAL_PACKAGE_DEP_SPEC_REQUIREMENT_HH
+#define PALUDIS_GUARD_PALUDIS_ADDITIONAL_PACKAGE_DEP_SPEC_REQUIREMENT_HH 1
+
+#include <paludis/additional_package_dep_spec_requirement-fwd.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/tribool-fwd.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/changed_choices-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+#include <utility>
+
+namespace paludis
+{
+ /**
+ * An additional requirement for a PackageDepSpec.
+ *
+ * \since 0.26
+ * \ingroup g_dep_spec
+ */
+ class PALUDIS_VISIBLE AdditionalPackageDepSpecRequirement
+ {
+ public:
+ AdditionalPackageDepSpecRequirement() = default;
+ virtual ~AdditionalPackageDepSpecRequirement();
+
+ AdditionalPackageDepSpecRequirement(const AdditionalPackageDepSpecRequirement &) = delete;
+ AdditionalPackageDepSpecRequirement & operator= (const AdditionalPackageDepSpecRequirement &) = delete;
+
+ /**
+ * Is our requirement met for a given PackageID?
+ *
+ * The string in the return type might be a description of why the
+ * requirement was not met. Sometimes better messages can be given
+ * than simply the return value of as_human_string() when the ID to
+ * be matched is known. If the bool is false, the string is
+ * meaningless.
+ *
+ * \param spec_id The PackageID the spec comes from. May be null. Used for
+ * [use=] style dependencies.
+ *
+ * \since 0.44 returns pair<bool, std::string>
+ * \since 0.51 takes optional ChangedChoices arguments
+ * \since 0.58 takes id by shared_ptr
+ * \since 0.58 takes spec_id
+ */
+ virtual const std::pair<bool, std::string> requirement_met(
+ const Environment * const,
+ const ChangedChoices * const maybe_changes_to_owner,
+ const std::shared_ptr<const PackageID> & target_id,
+ const std::shared_ptr<const PackageID> & spec_id,
+ const ChangedChoices * const maybe_changes_to_target) const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ /**
+ * If possible, indicate which choices to change to make our
+ * requirement met for a particular ID.
+ *
+ * Verifies that the ID has the appropriate choice, and that that
+ * choice isn't locked.
+ *
+ * Returns true for changes made, false for not possible,
+ * indeterminate for nothing needs changing.
+ *
+ * \param spec_id The PackageID the spec comes from. May be null. Used for
+ * [use=] style dependencies.
+ *
+ * \since 0.51
+ * \since 0.55 returns Tribool
+ * \since 0.58 takes spec_id
+ */
+ virtual Tribool accumulate_changes_to_make_met(
+ const Environment * const,
+ const ChangedChoices * const maybe_changes_to_owner,
+ const std::shared_ptr<const PackageID> &,
+ const std::shared_ptr<const PackageID> & spec_id,
+ ChangedChoices &) const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ /**
+ * Return a human readable string representation of ourself.
+ *
+ * \param spec_id The PackageID the spec comes from. May be null. Used for
+ * [use=] style dependencies.
+ *
+ * \since 0.58 takes spec_id
+ */
+ virtual const std::string as_human_string(
+ const std::shared_ptr<const PackageID> & spec_id) const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ /**
+ * Return a raw string representation of ourself.
+ */
+ virtual const std::string as_raw_string() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ };
+
+ extern template class Sequence<std::shared_ptr<const AdditionalPackageDepSpecRequirement> >;
+ extern template class WrappedForwardIterator<AdditionalPackageDepSpecRequirements::ConstIteratorTag,
+ const std::shared_ptr<const AdditionalPackageDepSpecRequirement> >;
+}
+
+#endif
diff --git a/paludis/changed_choices.cc b/paludis/changed_choices.cc
index d8a5c72..cbad868 100644
--- a/paludis/changed_choices.cc
+++ b/paludis/changed_choices.cc
@@ -18,15 +18,13 @@
*/
#include <paludis/changed_choices.hh>
+#include <paludis/util/pimp-impl.hh>
+#include <paludis/util/tribool.hh>
#include <paludis/choice.hh>
#include <paludis/serialise-impl.hh>
#include <paludis/elike_use_requirement-fwd.hh>
#include <paludis/dep_spec.hh>
-#include <paludis/dep_spec_data.hh>
-
-#include <paludis/util/pimp-impl.hh>
-#include <paludis/util/tribool.hh>
-
+#include <paludis/partially_made_package_dep_spec.hh>
#include <map>
using namespace paludis;
@@ -61,16 +59,16 @@ ChangedChoices::empty() const
}
void
-ChangedChoices::add_requirements_to(MutablePackageDepSpecData & spec) const
+ChangedChoices::add_additional_requirements_to(PartiallyMadePackageDepSpec & spec) const
{
for (auto o(_imp->overrides.begin()), o_end(_imp->overrides.end()) ;
o != o_end ; ++o)
{
if (o->second)
- spec.require_choice(parse_elike_use_requirement("" + stringify(o->first) + "(-)",
+ spec.additional_requirement(parse_elike_use_requirement("" + stringify(o->first) + "(-)",
{ euro_allow_default_values }));
else
- spec.require_choice(parse_elike_use_requirement("-" + stringify(o->first) + "(-)",
+ spec.additional_requirement(parse_elike_use_requirement("-" + stringify(o->first) + "(-)",
{ euro_allow_default_values }));
}
}
diff --git a/paludis/changed_choices.hh b/paludis/changed_choices.hh
index 8171648..59670cf 100644
--- a/paludis/changed_choices.hh
+++ b/paludis/changed_choices.hh
@@ -27,7 +27,7 @@
#include <paludis/choice-fwd.hh>
#include <paludis/serialise-fwd.hh>
#include <paludis/dep_spec-fwd.hh>
-#include <paludis/dep_spec_data-fwd.hh>
+#include <paludis/partially_made_package_dep_spec-fwd.hh>
#include <memory>
namespace paludis
@@ -47,7 +47,7 @@ namespace paludis
bool empty() const PALUDIS_ATTRIBUTE((warn_unused_result));
- void add_requirements_to(MutablePackageDepSpecData &) const;
+ void add_additional_requirements_to(PartiallyMadePackageDepSpec &) const;
void serialise(Serialiser &) const;
diff --git a/paludis/common_sets.cc b/paludis/common_sets.cc
index a46d8a8..eaefdec 100644
--- a/paludis/common_sets.cc
+++ b/paludis/common_sets.cc
@@ -27,8 +27,8 @@
#include <paludis/filtered_generator.hh>
#include <paludis/metadata_key.hh>
#include <paludis/package_id.hh>
-#include <paludis/dep_spec_data.hh>
-
+#include <paludis/elike_slot_requirement.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/stringify.hh>
@@ -57,14 +57,15 @@ namespace
i != i_end ; ++i)
if (slots && (*i)->slot_key())
result->top()->append(std::make_shared<PackageDepSpec>(
- MutablePackageDepSpecData({ })
- .require_package((*i)->name())
- .require_exact_slot((*i)->slot_key()->parse_value(), false)
+ make_package_dep_spec({ })
+ .package((*i)->name())
+ .slot_requirement(std::make_shared<ELikeSlotExactRequirement>(
+ (*i)->slot_key()->parse_value(), false))
));
else
result->top()->append(std::make_shared<PackageDepSpec>(
- MutablePackageDepSpecData({ })
- .require_package((*i)->name())
+ make_package_dep_spec({ })
+ .package((*i)->name())
));
return result;
diff --git a/paludis/dep_spec-fwd.hh b/paludis/dep_spec-fwd.hh
index a5f8552..51128b6 100644
--- a/paludis/dep_spec-fwd.hh
+++ b/paludis/dep_spec-fwd.hh
@@ -64,6 +64,9 @@ namespace paludis
*/
typedef LabelsDepSpec<DependenciesLabel> DependenciesLabelsDepSpec;
+ struct InstallableToRepository;
+ struct InstallableToPath;
+
/**
* A PlainTextDepSpec can be written to an ostream.
*
diff --git a/paludis/dep_spec.cc b/paludis/dep_spec.cc
index bc95d0c..35a7996 100644
--- a/paludis/dep_spec.cc
+++ b/paludis/dep_spec.cc
@@ -21,10 +21,7 @@
#include <paludis/environment.hh>
#include <paludis/version_operator.hh>
#include <paludis/version_spec.hh>
-#include <paludis/dep_spec_data.hh>
-#include <paludis/package_dep_spec_requirement.hh>
-#include <paludis/package_dep_spec_properties.hh>
-
+#include <paludis/version_requirements.hh>
#include <paludis/util/clone-impl.hh>
#include <paludis/util/log.hh>
#include <paludis/util/join.hh>
@@ -37,8 +34,8 @@
#include <paludis/util/iterator_funcs.hh>
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/options.hh>
-#include <paludis/util/accept_visitor.hh>
-#include <paludis/util/make_null_shared_ptr.hh>
+#include <paludis/additional_package_dep_spec_requirement.hh>
+#include <paludis/dep_spec_data.hh>
#include <functional>
#include <algorithm>
@@ -188,7 +185,14 @@ ConditionalDepSpec::_as_string() const
return _imp->data->as_string();
}
+std::string
+StringDepSpec::text() const
+{
+ return _str;
+}
+
NamedSetDepSpec::NamedSetDepSpec(const SetName & n) :
+ StringDepSpec(stringify(n)),
_name(n)
{
}
@@ -199,12 +203,6 @@ NamedSetDepSpec::name() const
return _name;
}
-const std::string
-NamedSetDepSpec::text() const
-{
- return stringify(_name);
-}
-
std::shared_ptr<DepSpec>
NamedSetDepSpec::clone() const
{
@@ -214,24 +212,18 @@ NamedSetDepSpec::clone() const
}
BlockDepSpec::BlockDepSpec(const std::string & s, const PackageDepSpec & p) :
- _text(s),
+ StringDepSpec(s),
_spec(p)
{
}
BlockDepSpec::BlockDepSpec(const BlockDepSpec & other) :
- _text(other._text),
+ StringDepSpec(other.text()),
_spec(other._spec)
{
set_annotations(other.maybe_annotations());
}
-const std::string
-BlockDepSpec::text() const
-{
- return _text;
-}
-
std::ostream &
paludis::operator<< (std::ostream & s, const PlainTextDepSpec & a)
{
@@ -281,7 +273,7 @@ paludis::operator<< (std::ostream & s, const SimpleURIDepSpec & p)
std::ostream &
paludis::operator<< (std::ostream & s, const PackageDepSpec & a)
{
- s << a.text();
+ s << a._as_string();
return s;
}
@@ -318,8 +310,18 @@ PackageDepSpecError::PackageDepSpecError(const std::string & msg) throw () :
{
}
+StringDepSpec::StringDepSpec(const std::string & s) :
+ _str(s)
+{
+}
+
+StringDepSpec::~StringDepSpec()
+{
+}
+
+
PlainTextDepSpec::PlainTextDepSpec(const std::string & s) :
- _text(s)
+ StringDepSpec(s)
{
}
@@ -331,14 +333,8 @@ PlainTextDepSpec::clone() const
return result;
}
-const std::string
-PlainTextDepSpec::text() const
-{
- return _text;
-}
-
PlainTextLabelDepSpec::PlainTextLabelDepSpec(const std::string & s) :
- _text(s)
+ StringDepSpec(s)
{
}
@@ -355,19 +351,13 @@ PlainTextLabelDepSpec::clone() const
}
const std::string
-PlainTextLabelDepSpec::text() const
-{
- return _text;
-}
-
-const std::string
PlainTextLabelDepSpec::label() const
{
return text().substr(0, text().length() - 1);
}
LicenseDepSpec::LicenseDepSpec(const std::string & s) :
- _text(s)
+ StringDepSpec(s)
{
}
@@ -379,14 +369,8 @@ LicenseDepSpec::clone() const
return result;
}
-const std::string
-LicenseDepSpec::text() const
-{
- return _text;
-}
-
SimpleURIDepSpec::SimpleURIDepSpec(const std::string & s) :
- _text(s)
+ StringDepSpec(s)
{
}
@@ -398,12 +382,6 @@ SimpleURIDepSpec::clone() const
return result;
}
-const std::string
-SimpleURIDepSpec::text() const
-{
- return _text;
-}
-
const PackageDepSpec
BlockDepSpec::blocking() const
{
@@ -419,7 +397,7 @@ BlockDepSpec::clone() const
}
FetchableURIDepSpec::FetchableURIDepSpec(const std::string & s) :
- _text(s)
+ StringDepSpec(s)
{
}
@@ -466,12 +444,6 @@ FetchableURIDepSpec::clone() const
return result;
}
-const std::string
-FetchableURIDepSpec::text() const
-{
- return _text;
-}
-
namespace paludis
{
template <typename T_>
@@ -536,32 +508,12 @@ LabelsDepSpec<T_>::add_label(const std::shared_ptr<const T_> & item)
_imp->items.push_back(item);
}
-namespace
-{
- template <typename I_, typename P_>
- I_ find_unique_if(I_ cur, I_ end, P_ pred)
- {
- I_ result(end);
- for ( ; cur != end ; ++cur)
- if (pred(*cur))
- {
- if (result != end)
- return end;
- else
- result = cur;
- }
-
- return result;
- }
-}
-
namespace paludis
{
template <>
struct Imp<PackageDepSpec>
{
const std::shared_ptr<const PackageDepSpecData> data;
- std::string text;
Imp(const std::shared_ptr<const PackageDepSpecData> & d) :
data(d)
@@ -572,216 +524,9 @@ namespace paludis
PackageDepSpec::PackageDepSpec(const std::shared_ptr<const PackageDepSpecData> & d) :
Cloneable<DepSpec>(),
+ StringDepSpec(d->as_string()),
_imp(d)
{
- std::ostringstream s;
-
- std::shared_ptr<VersionRequirementSequence> all_versions;
- std::shared_ptr<KeyRequirementSequence> all_keys;
- std::shared_ptr<ChoiceRequirementSequence> all_choices;
-
- for (auto u(_imp->data->requirements()->begin()), u_end(_imp->data->requirements()->end()) ;
- u != u_end ; ++u)
- {
- if ((*u)->accept_returning<bool>(DetectPackageDepSpecRequirement<VersionRequirement>()))
- {
- if (! all_versions)
- all_versions = std::make_shared<VersionRequirementSequence>();
- all_versions->push_back(std::static_pointer_cast<const VersionRequirement>(*u));
- }
- else if ((*u)->accept_returning<bool>(DetectPackageDepSpecRequirement<KeyRequirement>()))
- {
- if (! all_keys)
- all_keys = std::make_shared<KeyRequirementSequence>();
- all_keys->push_back(std::static_pointer_cast<const KeyRequirement>(*u));
- }
- else if ((*u)->accept_returning<bool>(DetectPackageDepSpecRequirement<ChoiceRequirement>()))
- {
- if (! all_choices)
- all_choices = std::make_shared<ChoiceRequirementSequence>();
- all_choices->push_back(std::static_pointer_cast<const ChoiceRequirement>(*u));
- }
- }
-
- if (all_versions)
- {
- if (all_versions->begin() == all_versions->end())
- {
- }
- else if (next(all_versions->begin()) == all_versions->end() &&
- ! _imp->data->options()[pdsdo_always_use_ranged_deps])
- {
- if ((*all_versions->begin())->version_operator() == vo_stupid_equal_star ||
- (*all_versions->begin())->version_operator() == vo_nice_equal_star)
- s << "=";
- else
- s << (*all_versions->begin())->version_operator();
- }
- }
-
- if (package_name_requirement())
- s << package_name_requirement()->name();
- else
- {
- if (category_name_part_requirement())
- s << category_name_part_requirement()->name_part();
- else
- s << "*";
-
- s << "/";
-
- if (package_name_part_requirement())
- s << package_name_part_requirement()->name_part();
- else
- s << "*";
- }
-
- if (all_versions)
- {
- if (all_versions->begin() == all_versions->end())
- {
- }
- else if (next(all_versions->begin()) == all_versions->end() &&
- ! _imp->data->options()[pdsdo_always_use_ranged_deps])
- {
- s << "-" << (*all_versions->begin())->version_spec();
- if ((*all_versions->begin())->version_operator() == vo_stupid_equal_star ||
- (*all_versions->begin())->version_operator() == vo_nice_equal_star)
- s << "*";
- }
- }
-
- if (exact_slot_requirement())
- {
- if (exact_slot_requirement()->locked())
- s << ":=";
- else
- s << ":";
-
- s << stringify(exact_slot_requirement()->name());
- }
-
- if (any_slot_requirement())
- {
- if (any_slot_requirement()->locking())
- s << ":=";
- else
- s << ":*";
- }
-
- std::string left, right;
- bool need_arrow(false);
-
- if (from_repository_requirement())
- left = stringify(from_repository_requirement()->name());
-
- if (in_repository_requirement())
- right = stringify(in_repository_requirement()->name());
-
- if (installed_at_path_requirement())
- {
- if (! right.empty())
- {
- need_arrow = true;
- right.append("->");
- }
- right.append(stringify(installed_at_path_requirement()->path()));
- }
-
- if (installable_to_repository_requirement())
- {
- if (! right.empty())
- {
- need_arrow = true;
- right.append("->");
- }
- if (installable_to_repository_requirement()->include_masked())
- right.append(stringify(installable_to_repository_requirement()->name()) + "??");
- else
- right.append(stringify(installable_to_repository_requirement()->name()) + "?");
- }
-
- if (installable_to_path_requirement())
- {
- if (! right.empty())
- {
- need_arrow = true;
- right.append("->");
- }
- if (installable_to_path_requirement()->include_masked())
- right.append(stringify(installable_to_path_requirement()->path()) + "??");
- else
- right.append(stringify(installable_to_path_requirement()->path()) + "?");
- }
-
- if (need_arrow || ((! left.empty()) && (! right.empty())))
- s << "::" << left << "->" << right;
- else if (! right.empty())
- s << "::" << right;
- else if (! left.empty())
- s << "::" << left << "->";
-
- if (all_versions)
- {
- if (all_versions->begin() == all_versions->end())
- {
- }
- else if (next(all_versions->begin()) == all_versions->end() &&
- ! _imp->data->options()[pdsdo_always_use_ranged_deps])
- {
- }
- else
- {
- bool need_op(false);
- s << "[";
- for (auto r(all_versions->begin()), r_end(all_versions->end()) ; r != r_end ; ++r)
- {
- if (need_op)
- {
- do
- {
- switch ((*r)->combiner())
- {
- case vrc_and:
- s << "&";
- continue;
-
- case vrc_or:
- s << "|";
- continue;
-
- case last_vrc:
- ;
- }
- throw InternalError(PALUDIS_HERE, "Bad version_requirements_mode");
- } while (false);
- }
-
- if ((*r)->version_operator() == vo_stupid_equal_star || (*r)->version_operator() == vo_nice_equal_star)
- s << "=";
- else
- s << (*r)->version_operator();
-
- s << (*r)->version_spec();
-
- if ((*r)->version_operator() == vo_stupid_equal_star || (*r)->version_operator() == vo_nice_equal_star)
- s << "*";
-
- need_op = true;
- }
- s << "]";
- }
- }
-
- if (all_choices)
- for (auto u(all_choices->begin()), u_end(all_choices->end()) ; u != u_end ; ++u)
- s << (*u)->as_raw_string();
-
- if (all_keys)
- for (auto u(all_keys->begin()), u_end(all_keys->end()) ; u != u_end ; ++u)
- s << (*u)->as_raw_string();
-
- _imp->text = s.str();
}
PackageDepSpec::~PackageDepSpec()
@@ -790,142 +535,92 @@ PackageDepSpec::~PackageDepSpec()
PackageDepSpec::PackageDepSpec(const PackageDepSpec & d) :
Cloneable<DepSpec>(d),
+ StringDepSpec(d._imp->data->as_string()),
CloneUsingThis<DepSpec, PackageDepSpec>(d),
_imp(d._imp->data)
{
set_annotations(d.maybe_annotations());
- _imp->text = d._imp->text;
}
-const std::string
-PackageDepSpec::text() const
+std::shared_ptr<const QualifiedPackageName>
+PackageDepSpec::package_ptr() const
{
- return _imp->text;
+ return _imp->data->package_ptr();
}
-const std::shared_ptr<const NameRequirement>
-PackageDepSpec::package_name_requirement() const
+std::shared_ptr<const PackageNamePart>
+PackageDepSpec::package_name_part_ptr() const
{
- return _imp->data->package_name_requirement();
+ return _imp->data->package_name_part_ptr();
}
-const std::shared_ptr<const PackageNamePartRequirement>
-PackageDepSpec::package_name_part_requirement() const
+std::shared_ptr<const CategoryNamePart>
+PackageDepSpec::category_name_part_ptr() const
{
- DetectPackageDepSpecRequirement<PackageNamePartRequirement> v;
- auto r(find_unique_if(indirect_iterator(_imp->data->requirements()->begin()),
- indirect_iterator(_imp->data->requirements()->end()), accept_visitor_returning<bool>(v)));
-
- if (r != indirect_iterator(_imp->data->requirements()->end()))
- return std::static_pointer_cast<const PackageNamePartRequirement>(*r.underlying_iterator());
- else
- return make_null_shared_ptr();
+ return _imp->data->category_name_part_ptr();
}
-const std::shared_ptr<const CategoryNamePartRequirement>
-PackageDepSpec::category_name_part_requirement() const
+std::shared_ptr<const VersionRequirements>
+PackageDepSpec::version_requirements_ptr() const
{
- DetectPackageDepSpecRequirement<CategoryNamePartRequirement> v;
- auto r(find_unique_if(indirect_iterator(_imp->data->requirements()->begin()),
- indirect_iterator(_imp->data->requirements()->end()), accept_visitor_returning<bool>(v)));
-
- if (r != indirect_iterator(_imp->data->requirements()->end()))
- return std::static_pointer_cast<const CategoryNamePartRequirement>(*r.underlying_iterator());
- else
- return make_null_shared_ptr();
+ return _imp->data->version_requirements_ptr();
}
-const std::shared_ptr<const ExactSlotRequirement>
-PackageDepSpec::exact_slot_requirement() const
+VersionRequirementsMode
+PackageDepSpec::version_requirements_mode() const
{
- return _imp->data->exact_slot_requirement();
+ return _imp->data->version_requirements_mode();
}
-const std::shared_ptr<const AnySlotRequirement>
-PackageDepSpec::any_slot_requirement() const
+std::shared_ptr<const SlotRequirement>
+PackageDepSpec::slot_requirement_ptr() const
{
- DetectPackageDepSpecRequirement<AnySlotRequirement> v;
- auto r(find_unique_if(indirect_iterator(_imp->data->requirements()->begin()),
- indirect_iterator(_imp->data->requirements()->end()), accept_visitor_returning<bool>(v)));
-
- if (r != indirect_iterator(_imp->data->requirements()->end()))
- return std::static_pointer_cast<const AnySlotRequirement>(*r.underlying_iterator());
- else
- return make_null_shared_ptr();
+ return _imp->data->slot_requirement_ptr();
}
-const std::shared_ptr<const InRepositoryRequirement>
-PackageDepSpec::in_repository_requirement() const
+std::shared_ptr<const RepositoryName>
+PackageDepSpec::in_repository_ptr() const
{
- DetectPackageDepSpecRequirement<InRepositoryRequirement> v;
- auto r(find_unique_if(indirect_iterator(_imp->data->requirements()->begin()),
- indirect_iterator(_imp->data->requirements()->end()), accept_visitor_returning<bool>(v)));
-
- if (r != indirect_iterator(_imp->data->requirements()->end()))
- return std::static_pointer_cast<const InRepositoryRequirement>(*r.underlying_iterator());
- else
- return make_null_shared_ptr();
+ return _imp->data->in_repository_ptr();
}
-const std::shared_ptr<const InstallableToRepositoryRequirement>
-PackageDepSpec::installable_to_repository_requirement() const
+std::shared_ptr<const InstallableToRepository>
+PackageDepSpec::installable_to_repository_ptr() const
{
- DetectPackageDepSpecRequirement<InstallableToRepositoryRequirement> v;
- auto r(find_unique_if(indirect_iterator(_imp->data->requirements()->begin()),
- indirect_iterator(_imp->data->requirements()->end()), accept_visitor_returning<bool>(v)));
-
- if (r != indirect_iterator(_imp->data->requirements()->end()))
- return std::static_pointer_cast<const InstallableToRepositoryRequirement>(*r.underlying_iterator());
- else
- return make_null_shared_ptr();
+ return _imp->data->installable_to_repository_ptr();
}
-const std::shared_ptr<const FromRepositoryRequirement>
-PackageDepSpec::from_repository_requirement() const
+std::shared_ptr<const RepositoryName>
+PackageDepSpec::from_repository_ptr() const
{
- DetectPackageDepSpecRequirement<FromRepositoryRequirement> v;
- auto r(find_unique_if(indirect_iterator(_imp->data->requirements()->begin()),
- indirect_iterator(_imp->data->requirements()->end()), accept_visitor_returning<bool>(v)));
-
- if (r != indirect_iterator(_imp->data->requirements()->end()))
- return std::static_pointer_cast<const FromRepositoryRequirement>(*r.underlying_iterator());
- else
- return make_null_shared_ptr();
+ return _imp->data->from_repository_ptr();
}
-const std::shared_ptr<const InstalledAtPathRequirement>
-PackageDepSpec::installed_at_path_requirement() const
+std::shared_ptr<const FSPath>
+PackageDepSpec::installed_at_path_ptr() const
{
- DetectPackageDepSpecRequirement<InstalledAtPathRequirement> v;
- auto r(find_unique_if(indirect_iterator(_imp->data->requirements()->begin()),
- indirect_iterator(_imp->data->requirements()->end()), accept_visitor_returning<bool>(v)));
-
- if (r != indirect_iterator(_imp->data->requirements()->end()))
- return std::static_pointer_cast<const InstalledAtPathRequirement>(*r.underlying_iterator());
- else
- return make_null_shared_ptr();
+ return _imp->data->installed_at_path_ptr();
}
-const std::shared_ptr<const InstallableToPathRequirement>
-PackageDepSpec::installable_to_path_requirement() const
+std::shared_ptr<const InstallableToPath>
+PackageDepSpec::installable_to_path_ptr() const
{
- DetectPackageDepSpecRequirement<InstallableToPathRequirement> v;
- auto r(find_unique_if(indirect_iterator(_imp->data->requirements()->begin()),
- indirect_iterator(_imp->data->requirements()->end()), accept_visitor_returning<bool>(v)));
+ return _imp->data->installable_to_path_ptr();
+}
- if (r != indirect_iterator(_imp->data->requirements()->end()))
- return std::static_pointer_cast<const InstallableToPathRequirement>(*r.underlying_iterator());
- else
- return make_null_shared_ptr();
+std::shared_ptr<const AdditionalPackageDepSpecRequirements>
+PackageDepSpec::additional_requirements_ptr() const
+{
+ return _imp->data->additional_requirements_ptr();
}
-const std::shared_ptr<const PackageDepSpecRequirementSequence>
-PackageDepSpec::requirements() const
+std::string
+PackageDepSpec::_as_string() const
{
- return _imp->data->requirements();
+ return _imp->data->as_string();
}
-const std::shared_ptr<const PackageDepSpecData>
+std::shared_ptr<const PackageDepSpecData>
PackageDepSpec::data() const
{
return _imp->data;
diff --git a/paludis/dep_spec.hh b/paludis/dep_spec.hh
index d2307cb..68b5c70 100644
--- a/paludis/dep_spec.hh
+++ b/paludis/dep_spec.hh
@@ -32,12 +32,15 @@
#include <paludis/dep_spec-fwd.hh>
#include <paludis/name.hh>
#include <paludis/version_operator-fwd.hh>
+#include <paludis/version_requirements-fwd.hh>
#include <paludis/version_spec-fwd.hh>
+#include <paludis/slot_requirement-fwd.hh>
#include <paludis/package_id-fwd.hh>
#include <paludis/environment-fwd.hh>
+#include <paludis/additional_package_dep_spec_requirement-fwd.hh>
+#include <paludis/partially_made_package_dep_spec-fwd.hh>
#include <paludis/dep_spec_data-fwd.hh>
#include <paludis/dep_spec_annotations-fwd.hh>
-#include <paludis/package_dep_spec_requirement-fwd.hh>
#include <memory>
@@ -236,11 +239,60 @@ namespace paludis
class PALUDIS_VISIBLE StringDepSpec :
public DepSpec
{
+ private:
+ std::string _str;
+
+ protected:
+ ///\name Basic operations
+ ///\{
+
+ StringDepSpec(const std::string &);
+
+ ~StringDepSpec();
+
+ ///\}
+
+ /**
+ * Change our text.
+ */
+ void set_text(const std::string &);
+
public:
/**
* Fetch our text.
*/
- virtual const std::string text() const = 0;
+ std::string text() const;
+ };
+
+ namespace n
+ {
+ typedef Name<struct name_include_masked> include_masked;
+ typedef Name<struct name_path> path;
+ typedef Name<struct name_repository> repository;
+ }
+
+ /**
+ * Data for PackageDepSpec.installable_to_repository_ptr() etc.
+ *
+ * \ingroup g_dep_spec
+ * \since 0.32
+ */
+ struct InstallableToRepository
+ {
+ NamedValue<n::include_masked, bool> include_masked;
+ NamedValue<n::repository, RepositoryName> repository;
+ };
+
+ /**
+ * Data for PackageDepSpec.installable_to_path_ptr() etc.
+ *
+ * \ingroup g_dep_spec
+ * \since 0.32
+ */
+ struct InstallableToPath
+ {
+ NamedValue<n::include_masked, bool> include_masked;
+ NamedValue<n::path, FSPath> path;
};
/**
@@ -268,6 +320,7 @@ namespace paludis
private:
const PackageDepSpec & operator= (const PackageDepSpec &);
+ std::string _as_string() const;
Pimp<PackageDepSpec> _imp;
@@ -293,100 +346,76 @@ namespace paludis
///\}
- virtual const std::string text() const;
+ /**
+ * Fetch the package name (may be a zero pointer).
+ */
+ std::shared_ptr<const QualifiedPackageName> package_ptr() const;
/**
- * Fetch our NameRequirement, if we have one, or a null pointer otherwise.
- *
- * If we have multiple NameRequirement requirements, returns one such
- * requirement.
- *
- * \since 0.61
+ * Fetch the package name part, if wildcarded, or a zero pointer otherwise.
*/
- const std::shared_ptr<const NameRequirement> package_name_requirement() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ std::shared_ptr<const PackageNamePart> package_name_part_ptr() const;
/**
- * Fetch the single PackageNamePartRequirement, if we have one, or
- * a null pointer otherwise.
- *
- * \since 0.61
+ * Fetch the category name part, if wildcarded, or a zero pointer otherwise.
*/
- const std::shared_ptr<const PackageNamePartRequirement> package_name_part_requirement() const;
+ std::shared_ptr<const CategoryNamePart> category_name_part_ptr() const;
/**
- * Fetch the single CategoryNamePartRequirement, if we have one, or
- * a null pointer otherwise.
- *
- * \since 0.61
+ * Fetch the version requirements (may be a zero pointer).
*/
- const std::shared_ptr<const CategoryNamePartRequirement> category_name_part_requirement() const;
+ std::shared_ptr<const VersionRequirements> version_requirements_ptr() const;
/**
- * Fetch our ExactSlotRequirement, if we have one, or a null pointer otherwise.
- *
- * If we have multiple ExactSlotRequirement requirements, returns one such
- * requirement.
- *
- * \since 0.61
+ * Fetch the version requirements mode.
*/
- const std::shared_ptr<const ExactSlotRequirement> exact_slot_requirement() const;
+ VersionRequirementsMode version_requirements_mode() const;
/**
- * Fetch the single AnySlotRequirement, if we have one, or
- * a null pointer otherwise.
- *
- * \since 0.61
+ * Fetch the slot requirement (may be a zero pointer).
*/
- const std::shared_ptr<const AnySlotRequirement> any_slot_requirement() const;
+ std::shared_ptr<const SlotRequirement> slot_requirement_ptr() const;
/**
- * Fetch the single InRepositoryRequirement, if we have one, or
- * a null pointer otherwise.
- *
- * \since 0.61
+ * Fetch the in-repository requirement (may be a zero pointer).
*/
- const std::shared_ptr<const InRepositoryRequirement> in_repository_requirement() const;
+ std::shared_ptr<const RepositoryName> in_repository_ptr() const;
/**
- * Fetch the single InstallableToRepositoryRequirement, if we have one, or
+ * Fetch the installable-to-repository requirement (may be a zero pointer).
*
- * \since 0.61
+ * \since 0.32
*/
- const std::shared_ptr<const InstallableToRepositoryRequirement> installable_to_repository_requirement() const;
+ std::shared_ptr<const InstallableToRepository> installable_to_repository_ptr() const;
/**
- * Fetch the single FromRepositoryRequirement, if we have one, or
- * a null pointer otherwise.
+ * Fetch the from-repository requirement (may be a zero pointer).
*/
- const std::shared_ptr<const FromRepositoryRequirement> from_repository_requirement() const;
+ std::shared_ptr<const RepositoryName> from_repository_ptr() const;
/**
- * Fetch the single InstalledAtPathRequirement, if we have one, or
- * a null pointer otherwise.
+ * Fetch the installed-at-path requirement (may be a zero pointer).
*
- * \since 0.61
+ * \since 0.32
*/
- const std::shared_ptr<const InstalledAtPathRequirement> installed_at_path_requirement() const;
+ std::shared_ptr<const FSPath> installed_at_path_ptr() const;
/**
- * Fetch the single InstallableToPathRequirement, if we have one, or
- * a null pointer otherwise.
+ * Fetch the installable-to-path requirement (may be a zero pointer).
*
- * \since 0.61
+ * \since 0.32
*/
- const std::shared_ptr<const InstallableToPathRequirement> installable_to_path_requirement() const;
+ std::shared_ptr<const InstallableToPath> installable_to_path_ptr() const;
/**
- * Fetch all our requirements.
- *
- * \since 0.61
+ * Fetch any additional requirements (may be a zero pointer).
*/
- const std::shared_ptr<const PackageDepSpecRequirementSequence> requirements() const;
+ std::shared_ptr<const AdditionalPackageDepSpecRequirements> additional_requirements_ptr() const;
/**
* Access to our data.
*/
- const std::shared_ptr<const PackageDepSpecData> data() const;
+ std::shared_ptr<const PackageDepSpecData> data() const;
};
/**
@@ -398,9 +427,6 @@ namespace paludis
class PALUDIS_VISIBLE PlainTextDepSpec :
public StringDepSpec
{
- private:
- std::string _text;
-
public:
///\name Basic operations
///\{
@@ -409,8 +435,6 @@ namespace paludis
///\}
- virtual const std::string text() const;
-
virtual std::shared_ptr<DepSpec> clone() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
@@ -434,8 +458,6 @@ namespace paludis
///\}
- virtual const std::string text() const;
-
/// Fetch the name of our set.
const SetName name() const PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -452,9 +474,6 @@ namespace paludis
class PALUDIS_VISIBLE LicenseDepSpec :
public StringDepSpec
{
- private:
- std::string _text;
-
public:
///\name Basic operations
///\{
@@ -463,8 +482,6 @@ namespace paludis
///\}
- virtual const std::string text() const;
-
virtual std::shared_ptr<DepSpec> clone() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
@@ -482,9 +499,6 @@ namespace paludis
class PALUDIS_VISIBLE FetchableURIDepSpec :
public StringDepSpec
{
- private:
- std::string _text;
-
public:
///\name Basic operations
///\{
@@ -493,8 +507,6 @@ namespace paludis
///\}
- virtual const std::string text() const;
-
/**
* The original URL (that is, the text to the left of the arrow, if present,
* or the entire text otherwise).
@@ -528,9 +540,6 @@ namespace paludis
class PALUDIS_VISIBLE SimpleURIDepSpec :
public StringDepSpec
{
- private:
- std::string _text;
-
public:
///\name Basic operations
///\{
@@ -539,8 +548,6 @@ namespace paludis
///\}
- virtual const std::string text() const;
-
virtual std::shared_ptr<DepSpec> clone() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
@@ -575,7 +582,6 @@ namespace paludis
public StringDepSpec
{
private:
- std::string _text;
PackageDepSpec _spec;
public:
@@ -588,8 +594,6 @@ namespace paludis
///\}
- virtual const std::string text() const;
-
/**
* Fetch the spec we're blocking.
*
@@ -646,9 +650,6 @@ namespace paludis
class PALUDIS_VISIBLE PlainTextLabelDepSpec :
public StringDepSpec
{
- private:
- std::string _text;
-
public:
///\name Basic operations
///\{
@@ -658,8 +659,6 @@ namespace paludis
///\}
- virtual const std::string text() const;
-
virtual std::shared_ptr<DepSpec> clone() const PALUDIS_ATTRIBUTE((warn_unused_result));
const std::string label() const PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/paludis/dep_spec_TEST.cc b/paludis/dep_spec_TEST.cc
index 07779a2..816e054 100644
--- a/paludis/dep_spec_TEST.cc
+++ b/paludis/dep_spec_TEST.cc
@@ -19,6 +19,7 @@
#include <paludis/dep_spec.hh>
#include <paludis/user_dep_spec.hh>
+#include <paludis/version_requirements.hh>
#include <paludis/environments/test/test_environment.hh>
#include <paludis/util/clone-impl.hh>
diff --git a/paludis/dep_spec_data-fwd.hh b/paludis/dep_spec_data-fwd.hh
index 90934e8..1bbf447 100644
--- a/paludis/dep_spec_data-fwd.hh
+++ b/paludis/dep_spec_data-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010 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,27 +20,10 @@
#ifndef PALUDIS_GUARD_PALUDIS_DEP_SPEC_DATA_FWD_HH
#define PALUDIS_GUARD_PALUDIS_DEP_SPEC_DATA_FWD_HH 1
-#include <paludis/util/attributes.hh>
-#include <paludis/util/options-fwd.hh>
-
-#include <iosfwd>
-
namespace paludis
{
class PackageDepSpecData;
class ConditionalDepSpecData;
-
-#include <paludis/dep_spec_data-se.hh>
-
- class MutablePackageDepSpecData;
-
- /**
- * Options for PackageDepSpecData.
- *
- * \ingroup g_dep_spec
- * \since 0.61
- */
- typedef Options<PackageDepSpecDataOption> PackageDepSpecDataOptions;
}
#endif
diff --git a/paludis/dep_spec_data.cc b/paludis/dep_spec_data.cc
index 4df8f6a..6a7a2da 100644
--- a/paludis/dep_spec_data.cc
+++ b/paludis/dep_spec_data.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010 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
@@ -18,398 +18,10 @@
*/
#include <paludis/dep_spec_data.hh>
-#include <paludis/package_dep_spec_requirement.hh>
-#include <paludis/dep_spec.hh>
-#include <paludis/version_operator.hh>
-#include <paludis/version_spec.hh>
-#include <paludis/package_dep_spec_properties.hh>
-
-#include <paludis/util/stringify.hh>
-#include <paludis/util/exception.hh>
-#include <paludis/util/pimp-impl.hh>
-#include <paludis/util/options.hh>
-#include <paludis/util/sequence.hh>
-#include <paludis/util/wrapped_forward_iterator.hh>
-#include <paludis/util/wrapped_output_iterator.hh>
-#include <paludis/util/indirect_iterator-impl.hh>
-#include <paludis/util/make_null_shared_ptr.hh>
-#include <paludis/util/accept_visitor.hh>
-
-#include <istream>
-#include <ostream>
using namespace paludis;
-#include <paludis/dep_spec_data-se.cc>
-
ConditionalDepSpecData::~ConditionalDepSpecData() = default;
-namespace paludis
-{
- template <>
- struct Imp<PackageDepSpecData>
- {
- std::shared_ptr<const NameRequirement> package_name_requirement;
- std::shared_ptr<const ExactSlotRequirement> exact_slot_requirement;
- std::shared_ptr<PackageDepSpecRequirementSequence> requirements;
- PackageDepSpecDataOptions options;
-
- Imp(const PackageDepSpecDataOptions & o) :
- requirements(std::make_shared<PackageDepSpecRequirementSequence>()),
- options(o)
- {
- }
-
- Imp(const PackageDepSpecData & other) :
- package_name_requirement(other.package_name_requirement()),
- exact_slot_requirement(other.exact_slot_requirement()),
- requirements(std::make_shared<PackageDepSpecRequirementSequence>()),
- options(other.options())
- {
- std::copy(other.requirements()->begin(), other.requirements()->end(), requirements->back_inserter());
- }
- };
-}
-
-PackageDepSpecData::PackageDepSpecData(const PackageDepSpecDataOptions & o) :
- _imp(o)
-{
-}
-
-PackageDepSpecData::PackageDepSpecData(const PackageDepSpecData & o) :
- _imp(o)
-{
-}
-
PackageDepSpecData::~PackageDepSpecData() = default;
-const std::shared_ptr<const PackageDepSpecRequirementSequence>
-PackageDepSpecData::requirements() const
-{
- return _imp->requirements;
-}
-
-const PackageDepSpecDataOptions
-PackageDepSpecData::options() const
-{
- return _imp->options;
-}
-
-const std::shared_ptr<const NameRequirement>
-PackageDepSpecData::package_name_requirement() const
-{
- return _imp->package_name_requirement;
-}
-
-const std::shared_ptr<const ExactSlotRequirement>
-PackageDepSpecData::exact_slot_requirement() const
-{
- return _imp->exact_slot_requirement;
-}
-
-MutablePackageDepSpecData::MutablePackageDepSpecData(const PackageDepSpecDataOptions & o) :
- PackageDepSpecData(o)
-{
-}
-
-MutablePackageDepSpecData::MutablePackageDepSpecData(const PackageDepSpecData & o) :
- PackageDepSpecData(o)
-{
-}
-
-MutablePackageDepSpecData::MutablePackageDepSpecData(const MutablePackageDepSpecData & o) :
- PackageDepSpecData(o)
-{
-}
-
-MutablePackageDepSpecData::~MutablePackageDepSpecData() = default;
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::require_package(const QualifiedPackageName & name)
-{
- auto r(NameRequirementPool::get_instance()->create(name));
- _imp->package_name_requirement = r;
- _imp->requirements->push_front(r);
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::unrequire_package()
-{
- if (_imp->package_name_requirement)
- {
- _imp->package_name_requirement.reset();
-
- auto r(std::make_shared<PackageDepSpecRequirementSequence>());
- for (auto u(_imp->requirements->begin()), u_end(_imp->requirements->end()) ;
- u != u_end ; ++u)
- if (! (*u)->accept_returning<bool>(DetectPackageDepSpecRequirement<NameRequirement>()))
- r->push_back(*u);
-
- _imp->requirements = r;
- }
-
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::require_package_name_part(const PackageNamePart & part)
-{
- _imp->requirements->push_front(PackageNamePartRequirementPool::get_instance()->create(part));
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::unrequire_package_name_part()
-{
- auto r(std::make_shared<PackageDepSpecRequirementSequence>());
- for (auto u(_imp->requirements->begin()), u_end(_imp->requirements->end()) ;
- u != u_end ; ++u)
- if (! (*u)->accept_returning<bool>(DetectPackageDepSpecRequirement<PackageNamePartRequirement>()))
- r->push_back(*u);
-
- _imp->requirements = r;
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::require_category_name_part(const CategoryNamePart & part)
-{
- _imp->requirements->push_front(CategoryNamePartRequirementPool::get_instance()->create(part));
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::unrequire_category_name_part()
-{
- auto r(std::make_shared<PackageDepSpecRequirementSequence>());
- for (auto u(_imp->requirements->begin()), u_end(_imp->requirements->end()) ;
- u != u_end ; ++u)
- if (! (*u)->accept_returning<bool>(DetectPackageDepSpecRequirement<CategoryNamePartRequirement>()))
- r->push_back(*u);
-
- _imp->requirements = r;
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::require_version(const VersionRequirementCombiner vc, const VersionOperator & vo, const VersionSpec & vs)
-{
- auto r(std::make_shared<VersionRequirement>(vs, vo, vc));
- _imp->requirements->push_back(r);
-
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::unrequire_versions()
-{
- auto r(std::make_shared<PackageDepSpecRequirementSequence>());
- for (auto u(_imp->requirements->begin()), u_end(_imp->requirements->end()) ;
- u != u_end ; ++u)
- if (! (*u)->accept_returning<bool>(DetectPackageDepSpecRequirement<VersionRequirement>()))
- r->push_back(*u);
-
- _imp->requirements = r;
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::require_exact_slot(const SlotName & n, const bool s)
-{
- auto r(ExactSlotRequirementPool::get_instance()->create(n, s));
- _imp->exact_slot_requirement = r;
- _imp->requirements->push_back(r);
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::unrequire_exact_slot()
-{
- if (_imp->exact_slot_requirement)
- {
- _imp->exact_slot_requirement.reset();
-
- auto r(std::make_shared<PackageDepSpecRequirementSequence>());
- for (auto u(_imp->requirements->begin()), u_end(_imp->requirements->end()) ;
- u != u_end ; ++u)
- if (! (*u)->accept_returning<bool>(DetectPackageDepSpecRequirement<ExactSlotRequirement>()))
- r->push_back(*u);
-
- _imp->requirements = r;
- }
-
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::require_in_repository(const RepositoryName & s)
-{
- _imp->requirements->push_back(InRepositoryRequirementPool::get_instance()->create(s));
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::unrequire_in_repository()
-{
- auto r(std::make_shared<PackageDepSpecRequirementSequence>());
- for (auto u(_imp->requirements->begin()), u_end(_imp->requirements->end()) ;
- u != u_end ; ++u)
- if (! (*u)->accept_returning<bool>(DetectPackageDepSpecRequirement<InRepositoryRequirement>()))
- r->push_back(*u);
-
- _imp->requirements = r;
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::require_installable_to_path(const FSPath & s, const bool i)
-{
- _imp->requirements->push_back(InstallableToPathRequirementPool::get_instance()->create(s, i));
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::unrequire_installable_to_path()
-{
- auto r(std::make_shared<PackageDepSpecRequirementSequence>());
- for (auto u(_imp->requirements->begin()), u_end(_imp->requirements->end()) ;
- u != u_end ; ++u)
- if (! (*u)->accept_returning<bool>(DetectPackageDepSpecRequirement<InstallableToPathRequirement>()))
- r->push_back(*u);
-
- _imp->requirements = r;
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::require_installable_to_repository(const RepositoryName & n, const bool i)
-{
- _imp->requirements->push_back(InstallableToRepositoryRequirementPool::get_instance()->create(n, i));
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::unrequire_installable_to_repository()
-{
- auto r(std::make_shared<PackageDepSpecRequirementSequence>());
- for (auto u(_imp->requirements->begin()), u_end(_imp->requirements->end()) ;
- u != u_end ; ++u)
- if (! (*u)->accept_returning<bool>(DetectPackageDepSpecRequirement<InstallableToRepositoryRequirement>()))
- r->push_back(*u);
-
- _imp->requirements = r;
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::require_from_repository(const RepositoryName & n)
-{
- _imp->requirements->push_back(FromRepositoryRequirementPool::get_instance()->create(n));
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::unrequire_from_repository()
-{
- auto r(std::make_shared<PackageDepSpecRequirementSequence>());
- for (auto u(_imp->requirements->begin()), u_end(_imp->requirements->end()) ;
- u != u_end ; ++u)
- if (! (*u)->accept_returning<bool>(DetectPackageDepSpecRequirement<FromRepositoryRequirement>()))
- r->push_back(*u);
-
- _imp->requirements = r;
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::require_installed_at_path(const FSPath & s)
-{
- _imp->requirements->push_back(InstalledAtPathRequirementPool::get_instance()->create(s));
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::unrequire_installed_at_path()
-{
- auto r(std::make_shared<PackageDepSpecRequirementSequence>());
- for (auto u(_imp->requirements->begin()), u_end(_imp->requirements->end()) ;
- u != u_end ; ++u)
- if (! (*u)->accept_returning<bool>(DetectPackageDepSpecRequirement<InstalledAtPathRequirement>()))
- r->push_back(*u);
-
- _imp->requirements = r;
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::require_any_slot(const bool s)
-{
- _imp->requirements->push_back(AnySlotRequirementPool::get_instance()->create(s));
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::unrequire_any_slot()
-{
- auto r(std::make_shared<PackageDepSpecRequirementSequence>());
- for (auto u(_imp->requirements->begin()), u_end(_imp->requirements->end()) ;
- u != u_end ; ++u)
- if (! (*u)->accept_returning<bool>(DetectPackageDepSpecRequirement<AnySlotRequirement>()))
- r->push_back(*u);
-
- _imp->requirements = r;
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::require_choice(const std::shared_ptr<const ChoiceRequirement> & c)
-{
- _imp->requirements->push_back(c);
-
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::unrequire_choices()
-{
- auto r(std::make_shared<PackageDepSpecRequirementSequence>());
- for (auto u(_imp->requirements->begin()), u_end(_imp->requirements->end()) ;
- u != u_end ; ++u)
- if (! (*u)->accept_returning<bool>(DetectPackageDepSpecRequirement<ChoiceRequirement>()))
- r->push_back(*u);
-
- _imp->requirements = r;
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::require_key(const KeyRequirementKeyType t, const std::string & k, const KeyRequirementOperation o, const std::string & p)
-{
- auto r(KeyRequirementPool::get_instance()->create(t, k, o, p));
-
- _imp->requirements->push_back(r);
-
- return *this;
-}
-
-MutablePackageDepSpecData &
-MutablePackageDepSpecData::unrequire_keys()
-{
- auto r(std::make_shared<PackageDepSpecRequirementSequence>());
- for (auto u(_imp->requirements->begin()), u_end(_imp->requirements->end()) ;
- u != u_end ; ++u)
- if (! (*u)->accept_returning<bool>(DetectPackageDepSpecRequirement<KeyRequirement>()))
- r->push_back(*u);
-
- _imp->requirements = r;
- return *this;
-}
-
-MutablePackageDepSpecData::operator PackageDepSpec() const
-{
- /* convoluted because it's private... */
- PackageDepSpecData * data(new MutablePackageDepSpecData(*this));
- return PackageDepSpec(std::shared_ptr<PackageDepSpecData>(data));
-}
-
diff --git a/paludis/dep_spec_data.hh b/paludis/dep_spec_data.hh
index 6a7b67a..cae1276 100644
--- a/paludis/dep_spec_data.hh
+++ b/paludis/dep_spec_data.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010 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,19 +21,18 @@
#define PALUDIS_GUARD_PALUDIS_DEP_SPEC_DATA_HH 1
#include <paludis/dep_spec_data-fwd.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/fs_path-fwd.hh>
#include <paludis/changed_choices-fwd.hh>
#include <paludis/name-fwd.hh>
#include <paludis/version_operator-fwd.hh>
+#include <paludis/version_requirements-fwd.hh>
+#include <paludis/slot_requirement-fwd.hh>
+#include <paludis/additional_package_dep_spec_requirement-fwd.hh>
#include <paludis/dep_spec-fwd.hh>
+#include <paludis/partially_made_package_dep_spec-fwd.hh>
#include <paludis/environment-fwd.hh>
#include <paludis/package_id-fwd.hh>
-#include <paludis/package_dep_spec_requirement-fwd.hh>
-#include <paludis/version_spec-fwd.hh>
-
-#include <paludis/util/attributes.hh>
-#include <paludis/util/fs_path-fwd.hh>
-#include <paludis/util/pimp.hh>
-
#include <string>
#include <memory>
@@ -93,268 +92,95 @@ namespace paludis
* Data for a PackageDepSpec.
*
* \since 0.26
- * \since 0.61 is not abstract
* \ingroup g_dep_spec
*/
class PALUDIS_VISIBLE PackageDepSpecData
{
- protected:
- Pimp<PackageDepSpecData> _imp;
-
- PackageDepSpecData(const PackageDepSpecData &);
-
public:
///\name Basic operations
///\{
- explicit PackageDepSpecData(const PackageDepSpecDataOptions &);
-
virtual ~PackageDepSpecData();
///\}
/**
- * All our requirements.
- *
- * \since 0.61
- */
- const std::shared_ptr<const PackageDepSpecRequirementSequence> requirements() const;
-
- /**
- * Our options.
- *
- * \since 0.61
- */
- const PackageDepSpecDataOptions options() const;
-
- /**
- * Fetch one of our NameRequirement requirements, if we have any, or
- * a null pointer otherwise.
- *
- * \since 0.61
- */
- const std::shared_ptr<const NameRequirement> package_name_requirement() const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- /**
- * Fetch our ExactSlotRequirement, if we have one, or a null pointer otherwise.
- *
- * If we have multiple ExactSlotRequirement requirements, returns one such
- * requirement.
- *
- * \since 0.61
- */
- const std::shared_ptr<const ExactSlotRequirement> exact_slot_requirement() const;
- };
-
- /**
- * Partially constructed PackageDepSpecData, which can be used to build up a
- * PackageDepSpec.
- *
- * \since 0.61
- * \ingroup g_dep_spec
- */
- class PALUDIS_VISIBLE MutablePackageDepSpecData :
- private PackageDepSpecData
- {
- public:
- explicit MutablePackageDepSpecData(const PackageDepSpecDataOptions &);
-
- MutablePackageDepSpecData(const PackageDepSpecData &);
-
- MutablePackageDepSpecData(const MutablePackageDepSpecData &);
-
- ~MutablePackageDepSpecData();
-
- /**
- * Add a package requirement.
- *
- * \return *this
- */
- MutablePackageDepSpecData & require_package(const QualifiedPackageName &);
-
- /**
- * Clear any package requirements.
- *
- * \return *this
- */
- MutablePackageDepSpecData & unrequire_package();
-
- /**
- * Add a package name part requirement.
- *
- * \return *this
- */
- MutablePackageDepSpecData & require_package_name_part(const PackageNamePart &);
-
- /**
- * Clear any package name part requirements.
- *
- * \return *this
- */
- MutablePackageDepSpecData & unrequire_package_name_part();
-
- /**
- * Add a category name part requirement.
- *
- * \return *this
- */
- MutablePackageDepSpecData & require_category_name_part(const CategoryNamePart &);
-
- /**
- * Clear any category name part requirements.
- *
- * \return *this
- */
- MutablePackageDepSpecData & unrequire_category_name_part();
-
- /**
- * Add a version requirement.
- *
- * The combiner must be vcc_and if this is the first version
- * requirement.
- *
- * \return *this
- */
- MutablePackageDepSpecData & require_version(const VersionRequirementCombiner, const VersionOperator &, const VersionSpec &);
-
- /**
- * Clear any version requirements.
- *
- * \return *this
- */
- MutablePackageDepSpecData & unrequire_versions();
-
- /**
- * Add an exact slot requirement.
- *
- * \return *this
- */
- MutablePackageDepSpecData & require_exact_slot(const SlotName &, const bool locked);
-
- /**
- * Clear any exact slot requirements.
- *
- * \return *this
- */
- MutablePackageDepSpecData & unrequire_exact_slot();
-
- /**
- * Add an in repository requirement.
- *
- * \return *this
+ * Fetch ourself as a string.
*/
- MutablePackageDepSpecData & require_in_repository(const RepositoryName &);
+ virtual std::string as_string() const = 0;
/**
- * Clear any in repository requirement.
- *
- * \return *this
+ * Fetch the package name (may be a zero pointer).
*/
- MutablePackageDepSpecData & unrequire_in_repository();
+ virtual std::shared_ptr<const QualifiedPackageName> package_ptr() const = 0;
/**
- * Add an installable to path requirement.
- *
- * \return *this
+ * Fetch the package name part, if wildcarded, or a zero pointer otherwise.
*/
- MutablePackageDepSpecData & require_installable_to_path(const FSPath &, const bool);
+ virtual std::shared_ptr<const PackageNamePart> package_name_part_ptr() const = 0;
/**
- * Clear any installable to path requirement.
- *
- * \return *this
+ * Fetch the category name part, if wildcarded, or a zero pointer otherwise.
*/
- MutablePackageDepSpecData & unrequire_installable_to_path();
+ virtual std::shared_ptr<const CategoryNamePart> category_name_part_ptr() const = 0;
/**
- * Add an installable to repository requirement.
- *
- * \return *this
+ * Fetch the version requirements (may be a zero pointer).
*/
- MutablePackageDepSpecData & require_installable_to_repository(const RepositoryName &, const bool);
+ virtual std::shared_ptr<const VersionRequirements> version_requirements_ptr() const = 0;
/**
- * Clear any installable to repository requirement.
- *
- * \return *this
+ * Fetch the version requirements mode.
*/
- MutablePackageDepSpecData & unrequire_installable_to_repository();
+ virtual VersionRequirementsMode version_requirements_mode() const = 0;
/**
- * Add a from repository requirement.
- *
- * \return *this
+ * Fetch the slot name (may be a zero pointer).
*/
- MutablePackageDepSpecData & require_from_repository(const RepositoryName &);
+ virtual std::shared_ptr<const SlotRequirement> slot_requirement_ptr() const = 0;
/**
- * Clear any from repository requirement.
- *
- * \return *this
+ * Fetch the from-repository requirement (may be a zero pointer).
*/
- MutablePackageDepSpecData & unrequire_from_repository();
+ virtual std::shared_ptr<const RepositoryName> in_repository_ptr() const = 0;
/**
- * Add an installed at path requirement.
+ * Fetch the installable-to-repository requirement (may be a zero pointer).
*
- * \return *this
+ * \since 0.32
*/
- MutablePackageDepSpecData & require_installed_at_path(const FSPath &);
+ virtual std::shared_ptr<const InstallableToRepository> installable_to_repository_ptr() const = 0;
/**
- * Clear any installed at path requirement.
- *
- * \return *this
+ * Fetch the from-repository requirement (may be a zero pointer).
*/
- MutablePackageDepSpecData & unrequire_installed_at_path();
+ virtual std::shared_ptr<const RepositoryName> from_repository_ptr() const = 0;
/**
- * Add an any slot requirement.
+ * Fetch the installed-at-path requirement (may be a zero pointer).
*
- * \return *this
+ * \since 0.32
*/
- MutablePackageDepSpecData & require_any_slot(const bool);
+ virtual std::shared_ptr<const FSPath> installed_at_path_ptr() const = 0;
/**
- * Clear our AnySlotRequirement, if we have one.
+ * Fetch the installable-to-path requirement (may be a zero pointer).
*
- * \return *this
+ * \since 0.32
*/
- MutablePackageDepSpecData & unrequire_any_slot();
+ virtual std::shared_ptr<const InstallableToPath> installable_to_path_ptr() const = 0;
/**
- * Add a choice requirement.
- *
- * \return *this
- */
- MutablePackageDepSpecData & require_choice(const std::shared_ptr<const ChoiceRequirement> &);
-
- /**
- * Clear any choice requirements.
- *
- * \return *this
- */
- MutablePackageDepSpecData & unrequire_choices();
-
- /**
- * Add a key requirement.
- *
- * \return *this
+ * Fetch the additional requirements (may be a zero pointer).
*/
- MutablePackageDepSpecData & require_key(
- const KeyRequirementKeyType, const std::string &, const KeyRequirementOperation, const std::string &);
+ virtual std::shared_ptr<const AdditionalPackageDepSpecRequirements> additional_requirements_ptr() const = 0;
/**
- * Clear any key requirements.
+ * Fetch options if we're being used to construct a new PartiallyMadePackageDepSpec.
*
- * \return *this
- */
- MutablePackageDepSpecData & unrequire_keys();
-
- /**
- * Convert ourself to a PackageDepSpec.
+ * \since 0.38
*/
- operator PackageDepSpec() const;
+ virtual const PartiallyMadePackageDepSpecOptions options_for_partially_made_package_dep_spec() const = 0;
};
}
diff --git a/paludis/dep_spec_data.se b/paludis/dep_spec_data.se
deleted file mode 100644
index 1fffbe8..0000000
--- a/paludis/dep_spec_data.se
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/env bash
-# vim: set sw=4 sts=4 et ft=sh :
-
-make_enum_PackageDepSpecDataOption()
-{
- prefix pdsdo
-
- key pdsdo_always_use_ranged_deps "Always write [>=1] style dependencies"
-
- doxygen_comment << "END"
- /**
- * Options for PackageDepSpecData.
- *
- * \ingroup g_dep_spec
- * \since 0.61
- */
-END
-}
-
diff --git a/paludis/elike_package_dep_spec-fwd.hh b/paludis/elike_package_dep_spec-fwd.hh
index ac5b48f..c1d2226 100644
--- a/paludis/elike_package_dep_spec-fwd.hh
+++ b/paludis/elike_package_dep_spec-fwd.hh
@@ -22,14 +22,11 @@
#include <paludis/util/attributes.hh>
#include <paludis/util/options-fwd.hh>
-
#include <paludis/dep_spec-fwd.hh>
#include <paludis/package_id-fwd.hh>
#include <paludis/version_operator-fwd.hh>
#include <paludis/version_spec-fwd.hh>
-#include <paludis/package_dep_spec_requirement-fwd.hh>
-#include <paludis/dep_spec_data-fwd.hh>
-
+#include <paludis/partially_made_package_dep_spec-fwd.hh>
#include <functional>
#include <iosfwd>
@@ -45,7 +42,7 @@ namespace paludis
PackageDepSpec parse_generic_elike_package_dep_spec(const std::string & ss, const GenericELikePackageDepSpecParseFunctions & fns)
PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
- MutablePackageDepSpecData partial_parse_generic_elike_package_dep_spec(const std::string & ss,
+ PartiallyMadePackageDepSpec partial_parse_generic_elike_package_dep_spec(const std::string & ss,
const GenericELikePackageDepSpecParseFunctions & fns)
PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
@@ -53,23 +50,23 @@ namespace paludis
const VersionSpecOptions &)
PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
- MutablePackageDepSpecData partial_parse_elike_package_dep_spec(const std::string & ss,
+ PartiallyMadePackageDepSpec partial_parse_elike_package_dep_spec(const std::string & ss,
const ELikePackageDepSpecOptions &,
const VersionSpecOptions &)
PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
void elike_check_sanity(const std::string & s) PALUDIS_VISIBLE;
- bool elike_remove_trailing_square_bracket_if_exists(std::string & s, MutablePackageDepSpecData & result,
+ bool elike_remove_trailing_square_bracket_if_exists(std::string & s, PartiallyMadePackageDepSpec & result,
const ELikePackageDepSpecOptions & options,
const VersionSpecOptions & version_options,
bool & had_bracket_version_requirements,
bool & had_use_requirements) PALUDIS_VISIBLE;
- void elike_remove_trailing_repo_if_exists(std::string & s, MutablePackageDepSpecData & result,
+ void elike_remove_trailing_repo_if_exists(std::string & s, PartiallyMadePackageDepSpec & result,
const ELikePackageDepSpecOptions & options) PALUDIS_VISIBLE;
- void elike_remove_trailing_slot_if_exists(std::string & s, MutablePackageDepSpecData & result,
+ void elike_remove_trailing_slot_if_exists(std::string & s, PartiallyMadePackageDepSpec & result,
const ELikePackageDepSpecOptions & options) PALUDIS_VISIBLE;
bool elike_has_version_operator(const std::string & s, const bool had_bracket_version_requirements,
@@ -81,21 +78,10 @@ namespace paludis
VersionSpec elike_get_remove_trailing_version(std::string & s,
const VersionSpecOptions &) PALUDIS_VISIBLE;
- void elike_add_version_requirement(
- const VersionSpec & spec,
- const VersionOperator & op,
- const VersionRequirementCombiner,
- MutablePackageDepSpecData & result)
+ void elike_add_version_requirement(const VersionOperator & op, const VersionSpec & spec, PartiallyMadePackageDepSpec & result)
PALUDIS_VISIBLE;
- void parse_elike_version_range(
- const std::string &,
- MutablePackageDepSpecData &,
- const ELikePackageDepSpecOptions & options,
- const VersionSpecOptions & version_options,
- bool & had_bracket_version_requirements) PALUDIS_VISIBLE;
-
- void elike_add_package_requirement(const std::string & s, MutablePackageDepSpecData & result) PALUDIS_VISIBLE;
+ void elike_add_package_requirement(const std::string & s, PartiallyMadePackageDepSpec & result) PALUDIS_VISIBLE;
}
#endif
diff --git a/paludis/elike_package_dep_spec.cc b/paludis/elike_package_dep_spec.cc
index aa72130..91433ef 100644
--- a/paludis/elike_package_dep_spec.cc
+++ b/paludis/elike_package_dep_spec.cc
@@ -19,25 +19,23 @@
#include <paludis/elike_package_dep_spec.hh>
#include <paludis/elike_use_requirement.hh>
+#include <paludis/elike_slot_requirement.hh>
+#include <paludis/util/options.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/make_named_values.hh>
#include <paludis/dep_spec.hh>
#include <paludis/version_operator.hh>
#include <paludis/version_spec.hh>
+#include <paludis/version_requirements.hh>
#include <paludis/user_dep_spec.hh>
-#include <paludis/dep_spec_data.hh>
-
-#include <paludis/util/options.hh>
-#include <paludis/util/log.hh>
-#include <paludis/util/make_named_values.hh>
-#include <paludis/util/options.hh>
-#include <paludis/util/return_literal_function.hh>
-
+#include <paludis/partially_made_package_dep_spec.hh>
#include <strings.h>
using namespace paludis;
#include <paludis/elike_package_dep_spec-se.cc>
-MutablePackageDepSpecData
+PartiallyMadePackageDepSpec
paludis::partial_parse_generic_elike_package_dep_spec(const std::string & ss, const GenericELikePackageDepSpecParseFunctions & fns)
{
Context context("When parsing generic package dep spec '" + ss + "':");
@@ -46,7 +44,7 @@ paludis::partial_parse_generic_elike_package_dep_spec(const std::string & ss, co
fns.check_sanity()(ss);
std::string s(ss);
- MutablePackageDepSpecData result(fns.options_for_partially_made_package_dep_spec()());
+ PartiallyMadePackageDepSpec result(fns.options_for_partially_made_package_dep_spec()());
/* Remove trailing [use], [version] etc parts. */
while (fns.remove_trailing_square_bracket_if_exists()(s, result))
@@ -62,7 +60,7 @@ paludis::partial_parse_generic_elike_package_dep_spec(const std::string & ss, co
/* Leading (or maybe =*) operator, so trailing version. */
VersionOperator op(fns.get_remove_version_operator()(s));
VersionSpec spec(fns.get_remove_trailing_version()(s));
- fns.add_version_requirement()(spec, op, vrc_and, result);
+ fns.add_version_requirement()(op, spec, result);
fns.add_package_requirement()(s, result);
}
else
@@ -88,7 +86,7 @@ paludis::elike_check_sanity(const std::string & s)
}
bool
-paludis::elike_remove_trailing_square_bracket_if_exists(std::string & s, MutablePackageDepSpecData & result,
+paludis::elike_remove_trailing_square_bracket_if_exists(std::string & s, PartiallyMadePackageDepSpec & result,
const ELikePackageDepSpecOptions & options,
const VersionSpecOptions & version_options,
bool & had_bracket_version_requirements,
@@ -125,7 +123,68 @@ paludis::elike_remove_trailing_square_bracket_if_exists(std::string & s, Mutable
<< "Version range dependencies not safe for use here";
}
- parse_elike_version_range(flag, result, options, version_options, had_bracket_version_requirements);
+ {
+ char needed_mode(0);
+
+ while (! flag.empty())
+ {
+ Context cc("When parsing [] segment '" + flag + "':");
+
+ std::string op;
+ std::string::size_type opos(0);
+ while (opos < flag.length())
+ if (std::string::npos == std::string("><=~").find(flag.at(opos)))
+ break;
+ else
+ ++opos;
+
+ op = flag.substr(0, opos);
+ flag.erase(0, opos);
+
+ if (op.empty())
+ throw PackageDepSpecError("Missing operator inside []");
+
+ VersionOperator vop(op);
+
+ std::string ver;
+ opos = flag.find_first_of("|&");
+ if (std::string::npos == opos)
+ {
+
+ ver = flag;
+ flag.clear();
+ }
+ else
+ {
+ if (0 == needed_mode)
+ needed_mode = flag.at(opos);
+ else if (needed_mode != flag.at(opos))
+ throw PackageDepSpecError("Mixed & and | inside []");
+
+ result.version_requirements_mode((flag.at(opos) == '|' ? vr_or : vr_and));
+ ver = flag.substr(0, opos++);
+ flag.erase(0, opos);
+ }
+
+ if (ver.empty())
+ throw PackageDepSpecError("Missing version after operator '" + stringify(vop) + " inside []");
+
+ if ('*' == ver.at(ver.length() - 1))
+ {
+ ver.erase(ver.length() - 1);
+ if (vop == vo_equal)
+ vop = options[epdso_nice_equal_star] ? vo_nice_equal_star : vo_stupid_equal_star;
+ else
+ throw PackageDepSpecError("Invalid use of * with operator '" + stringify(vop) + " inside []");
+ }
+
+ VersionSpec vs(ver, version_options);
+ result.version_requirement(make_named_values<VersionRequirement>(
+ n::version_operator() = vop,
+ n::version_spec() = vs));
+ had_bracket_version_requirements = true;
+ }
+ }
break;
case '.':
@@ -138,9 +197,8 @@ paludis::elike_remove_trailing_square_bracket_if_exists(std::string & s, Mutable
Log::get_instance()->message("e.package_dep_spec.key_not_allowed", ll_warning, lc_context)
<< "Key requirements not safe for use here";
}
-
- auto k(parse_user_key_requirement(flag.substr(1)));
- result.require_key(std::get<0>(k), std::get<1>(k), std::get<2>(k), std::get<3>(k));
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req(std::make_shared<UserKeyRequirement>(flag.substr(1)));
+ result.additional_requirement(req);
}
break;
@@ -180,7 +238,8 @@ paludis::elike_remove_trailing_square_bracket_if_exists(std::string & s, Mutable
if (options[epdso_strict_parsing])
euro += euro_strict_parsing;
- result.require_choice(parse_elike_use_requirement(flag, euro));
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req(parse_elike_use_requirement(flag, euro));
+ result.additional_requirement(req);
break;
};
@@ -191,7 +250,7 @@ paludis::elike_remove_trailing_square_bracket_if_exists(std::string & s, Mutable
}
void
-paludis::elike_remove_trailing_repo_if_exists(std::string & s, MutablePackageDepSpecData & result,
+paludis::elike_remove_trailing_repo_if_exists(std::string & s, PartiallyMadePackageDepSpec & result,
const ELikePackageDepSpecOptions & options)
{
std::string::size_type repo_p;
@@ -207,12 +266,12 @@ paludis::elike_remove_trailing_repo_if_exists(std::string & s, MutablePackageDep
<< "Repository dependencies not safe for use here";
}
- result.require_in_repository(RepositoryName(s.substr(repo_p + 2)));
+ result.in_repository(RepositoryName(s.substr(repo_p + 2)));
s.erase(repo_p);
}
void
-paludis::elike_remove_trailing_slot_if_exists(std::string & s, MutablePackageDepSpecData & result,
+paludis::elike_remove_trailing_slot_if_exists(std::string & s, PartiallyMadePackageDepSpec & result,
const ELikePackageDepSpecOptions & options)
{
std::string::size_type slot_p;
@@ -233,7 +292,7 @@ paludis::elike_remove_trailing_slot_if_exists(std::string & s, MutablePackageDep
Log::get_instance()->message("e.package_dep_spec.slot_star_not_allowed", ll_warning, lc_context)
<< "Slot '*' dependencies not safe for use here";
}
- result.require_any_slot(false);
+ result.slot_requirement(std::make_shared<ELikeSlotAnyUnlockedRequirement>());
}
else if ('=' == match.at(0))
{
@@ -247,9 +306,9 @@ paludis::elike_remove_trailing_slot_if_exists(std::string & s, MutablePackageDep
}
if (1 == match.length())
- result.require_any_slot(true);
+ result.slot_requirement(std::make_shared<ELikeSlotAnyLockedRequirement>());
else
- result.require_exact_slot(SlotName(s.substr(slot_p + 2)), true);
+ result.slot_requirement(std::make_shared<ELikeSlotExactRequirement>(SlotName(s.substr(slot_p + 2)), true));
}
else
{
@@ -261,7 +320,7 @@ paludis::elike_remove_trailing_slot_if_exists(std::string & s, MutablePackageDep
Log::get_instance()->message("e.package_dep_spec.slot_not_allowed", ll_warning, lc_context)
<< "Slot dependencies not safe for use here";
}
- result.require_exact_slot(SlotName(s.substr(slot_p + 1)), false);
+ result.slot_requirement(std::make_shared<ELikeSlotExactRequirement>(SlotName(s.substr(slot_p + 1)), false));
}
s.erase(slot_p);
}
@@ -370,17 +429,15 @@ paludis::elike_get_remove_trailing_version(std::string & s, const VersionSpecOpt
}
void
-paludis::elike_add_version_requirement(
- const VersionSpec & ver,
- const VersionOperator & op,
- const VersionRequirementCombiner vrc,
- MutablePackageDepSpecData & result)
+paludis::elike_add_version_requirement(const VersionOperator & op, const VersionSpec & spec, PartiallyMadePackageDepSpec & result)
{
- result.require_version(vrc, op, ver);
+ result.version_requirement(make_named_values<VersionRequirement>(
+ n::version_operator() = op,
+ n::version_spec() = spec));
}
void
-paludis::elike_add_package_requirement(const std::string & s, MutablePackageDepSpecData & result)
+paludis::elike_add_package_requirement(const std::string & s, PartiallyMadePackageDepSpec & result)
{
if (std::string::npos == s.find('/'))
throw PackageDepSpecError("No category/ found in '" + s + "' (cat/pkg is required, a simple pkg is not allowed here)");
@@ -390,19 +447,27 @@ paludis::elike_add_package_requirement(const std::string & s, MutablePackageDepS
throw PackageDepSpecError("Wildcard '*' not allowed here");
if (0 != s.compare(s.length() - 2, 2, "/*"))
- result.require_package_name_part(PackageNamePart(s.substr(2)));
+ result.package_name_part(PackageNamePart(s.substr(2)));
}
else if (s.length() >= 3 && (0 == s.compare(s.length() - 2, 2, "/*")))
{
throw PackageDepSpecError("Wildcard '*' not allowed here");
- result.require_category_name_part(CategoryNamePart(s.substr(0, s.length() - 2)));
+ result.category_name_part(CategoryNamePart(s.substr(0, s.length() - 2)));
}
else
- result.require_package(QualifiedPackageName(s));
+ result.package(QualifiedPackageName(s));
+}
+
+namespace
+{
+ const PartiallyMadePackageDepSpecOptions fixed_options_for_partially_made_package_dep_spec(PartiallyMadePackageDepSpecOptions o)
+ {
+ return o;
+ }
}
-MutablePackageDepSpecData
+PartiallyMadePackageDepSpec
paludis::partial_parse_elike_package_dep_spec(
const std::string & ss, const ELikePackageDepSpecOptions & options,
const VersionSpecOptions & version_options)
@@ -413,19 +478,19 @@ paludis::partial_parse_elike_package_dep_spec(
bool had_bracket_version_requirements(false), had_use_requirements(false);
- PackageDepSpecDataOptions o;
+ PartiallyMadePackageDepSpecOptions o;
if (options[epdso_disallow_nonranged_deps])
- o += pdsdo_always_use_ranged_deps;
+ o += pmpdso_always_use_ranged_deps;
return partial_parse_generic_elike_package_dep_spec(ss, make_named_values<GenericELikePackageDepSpecParseFunctions>(
n::add_package_requirement() = std::bind(&elike_add_package_requirement, _1, _2),
- n::add_version_requirement() = std::bind(&elike_add_version_requirement, _1, _2, _3, _4),
+ n::add_version_requirement() = std::bind(&elike_add_version_requirement, _1, _2, _3),
n::check_sanity() = &elike_check_sanity,
n::get_remove_trailing_version() = std::bind(&elike_get_remove_trailing_version, _1, version_options),
n::get_remove_version_operator() = std::bind(&elike_get_remove_version_operator, _1, options),
n::has_version_operator() = std::bind(&elike_has_version_operator, _1,
std::cref(had_bracket_version_requirements), options),
- n::options_for_partially_made_package_dep_spec() = return_literal_function(o),
+ n::options_for_partially_made_package_dep_spec() = std::bind(&fixed_options_for_partially_made_package_dep_spec, std::cref(o)),
n::remove_trailing_repo_if_exists() = std::bind(&elike_remove_trailing_repo_if_exists, _1, _2, options),
n::remove_trailing_slot_if_exists() = std::bind(&elike_remove_trailing_slot_if_exists, _1, _2, options),
n::remove_trailing_square_bracket_if_exists() = std::bind(&elike_remove_trailing_square_bracket_if_exists,
@@ -440,68 +505,3 @@ paludis::parse_elike_package_dep_spec(const std::string & ss, const ELikePackage
return partial_parse_elike_package_dep_spec(ss, options, version_options);
}
-void
-paludis::parse_elike_version_range(
- const std::string & s,
- MutablePackageDepSpecData & result,
- const ELikePackageDepSpecOptions & options,
- const VersionSpecOptions & version_options,
- bool & had_bracket_version_requirements)
-{
- std::string flag(s);
- VersionRequirementCombiner vrc(vrc_and);
-
- while (! flag.empty())
- {
- Context cc("When parsing [] segment '" + flag + "':");
- VersionRequirementCombiner next_vrc(vrc);
-
- std::string op;
- std::string::size_type opos(0);
- while (opos < flag.length())
- if (std::string::npos == std::string("><=~").find(flag.at(opos)))
- break;
- else
- ++opos;
-
- op = flag.substr(0, opos);
- flag.erase(0, opos);
-
- if (op.empty())
- throw PackageDepSpecError("Missing operator inside []");
-
- VersionOperator vop(op);
-
- std::string ver;
- opos = flag.find_first_of("|&");
- if (std::string::npos == opos)
- {
- ver = flag;
- flag.clear();
- }
- else
- {
- next_vrc = (flag.at(opos) == '|' ? vrc_or : vrc_and);
- ver = flag.substr(0, opos++);
- flag.erase(0, opos);
- }
-
- if (ver.empty())
- throw PackageDepSpecError("Missing version after operator '" + stringify(vop) + " inside []");
-
- if ('*' == ver.at(ver.length() - 1))
- {
- ver.erase(ver.length() - 1);
- if (vop == vo_equal)
- vop = options[epdso_nice_equal_star] ? vo_nice_equal_star : vo_stupid_equal_star;
- else
- throw PackageDepSpecError("Invalid use of * with operator '" + stringify(vop) + " inside []");
- }
-
- VersionSpec vs(ver, version_options);
- result.require_version(vrc, vop, vs);
- had_bracket_version_requirements = true;
- vrc = next_vrc;
- }
-}
-
diff --git a/paludis/elike_package_dep_spec.hh b/paludis/elike_package_dep_spec.hh
index 7f35f73..25e9041 100644
--- a/paludis/elike_package_dep_spec.hh
+++ b/paludis/elike_package_dep_spec.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2009, 2010, 2011 Ciaran McCreesh
+ * Copyright (c) 2008, 2009, 2010 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,8 +21,6 @@
#define PALUDIS_GUARD_PALUDIS_ELIKE_PACKAGE_DEP_SPEC_HH 1
#include <paludis/elike_package_dep_spec-fwd.hh>
-#include <paludis/dep_spec_data-fwd.hh>
-
#include <paludis/util/named_value.hh>
namespace paludis
@@ -43,20 +41,16 @@ namespace paludis
struct GenericELikePackageDepSpecParseFunctions
{
- NamedValue<n::add_package_requirement, std::function<void (const std::string &, MutablePackageDepSpecData &)> > add_package_requirement;
- NamedValue<n::add_version_requirement, std::function<void (
- const VersionSpec &,
- const VersionOperator &,
- const VersionRequirementCombiner,
- MutablePackageDepSpecData &)> > add_version_requirement;
+ NamedValue<n::add_package_requirement, std::function<void (const std::string &, PartiallyMadePackageDepSpec &)> > add_package_requirement;
+ NamedValue<n::add_version_requirement, std::function<void (const VersionOperator &, const VersionSpec &, PartiallyMadePackageDepSpec &)> > add_version_requirement;
NamedValue<n::check_sanity, std::function<void (const std::string &)> > check_sanity;
NamedValue<n::get_remove_trailing_version, std::function<VersionSpec (std::string &)> > get_remove_trailing_version;
NamedValue<n::get_remove_version_operator, std::function<VersionOperator (std::string &)> > get_remove_version_operator;
NamedValue<n::has_version_operator, std::function<bool (const std::string &)> > has_version_operator;
- NamedValue<n::options_for_partially_made_package_dep_spec, std::function<const PackageDepSpecDataOptions ()> > options_for_partially_made_package_dep_spec;
- NamedValue<n::remove_trailing_repo_if_exists, std::function<void (std::string &, MutablePackageDepSpecData &)> > remove_trailing_repo_if_exists;
- NamedValue<n::remove_trailing_slot_if_exists, std::function<void (std::string &, MutablePackageDepSpecData &)> > remove_trailing_slot_if_exists;
- NamedValue<n::remove_trailing_square_bracket_if_exists, std::function<bool (std::string &, MutablePackageDepSpecData &)> > remove_trailing_square_bracket_if_exists;
+ NamedValue<n::options_for_partially_made_package_dep_spec, std::function<const PartiallyMadePackageDepSpecOptions ()> > options_for_partially_made_package_dep_spec;
+ NamedValue<n::remove_trailing_repo_if_exists, std::function<void (std::string &, PartiallyMadePackageDepSpec &)> > remove_trailing_repo_if_exists;
+ NamedValue<n::remove_trailing_slot_if_exists, std::function<void (std::string &, PartiallyMadePackageDepSpec &)> > remove_trailing_slot_if_exists;
+ NamedValue<n::remove_trailing_square_bracket_if_exists, std::function<bool (std::string &, PartiallyMadePackageDepSpec &)> > remove_trailing_square_bracket_if_exists;
};
}
diff --git a/paludis/elike_slot_requirement-fwd.hh b/paludis/elike_slot_requirement-fwd.hh
new file mode 100644
index 0000000..9ec1513
--- /dev/null
+++ b/paludis/elike_slot_requirement-fwd.hh
@@ -0,0 +1,30 @@
+/* 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_ELIKE_SLOT_REQUIREMENT_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_ELIKE_SLOT_REQUIREMENT_FWD_HH 1
+
+namespace paludis
+{
+ class ELikeSlotExactRequirement;
+ class ELikeSlotAnyLockedRequirement;
+ class ELikeSlotAnyUnlockedRequirement;
+}
+
+#endif
diff --git a/paludis/elike_slot_requirement.cc b/paludis/elike_slot_requirement.cc
new file mode 100644
index 0000000..ea52fe4
--- /dev/null
+++ b/paludis/elike_slot_requirement.cc
@@ -0,0 +1,54 @@
+/* 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/elike_slot_requirement.hh>
+#include <paludis/util/stringify.hh>
+
+using namespace paludis;
+
+ELikeSlotExactRequirement::ELikeSlotExactRequirement(const SlotName & s, const bool e) :
+ _s(s),
+ _e(e)
+{
+}
+
+const std::string
+ELikeSlotExactRequirement::as_string() const
+{
+ return ":" + std::string(_e ? "=" : "") + stringify(_s);
+}
+
+const SlotName
+ELikeSlotExactRequirement::slot() const
+{
+ return _s;
+}
+
+const std::string
+ELikeSlotAnyUnlockedRequirement::as_string() const
+{
+ return ":*";
+}
+
+const std::string
+ELikeSlotAnyLockedRequirement::as_string() const
+{
+ return ":=";
+}
+
diff --git a/paludis/elike_slot_requirement.hh b/paludis/elike_slot_requirement.hh
new file mode 100644
index 0000000..ad33609
--- /dev/null
+++ b/paludis/elike_slot_requirement.hh
@@ -0,0 +1,58 @@
+/* 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_ELIKE_SLOT_REQUIREMENT_HH
+#define PALUDIS_GUARD_PALUDIS_ELIKE_SLOT_REQUIREMENT_HH 1
+
+#include <paludis/elike_slot_requirement-fwd.hh>
+#include <paludis/slot_requirement.hh>
+#include <paludis/name.hh>
+
+namespace paludis
+{
+ class PALUDIS_VISIBLE ELikeSlotExactRequirement :
+ public SlotExactRequirement
+ {
+ private:
+ const SlotName _s;
+ const bool _e;
+
+ public:
+ ELikeSlotExactRequirement(const SlotName &, const bool equals);
+
+ virtual const std::string as_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const SlotName slot() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class PALUDIS_VISIBLE ELikeSlotAnyUnlockedRequirement :
+ public SlotAnyUnlockedRequirement
+ {
+ public:
+ virtual const std::string as_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class PALUDIS_VISIBLE ELikeSlotAnyLockedRequirement :
+ public SlotAnyLockedRequirement
+ {
+ public:
+ virtual const std::string as_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+}
+
+#endif
diff --git a/paludis/elike_use_requirement-fwd.hh b/paludis/elike_use_requirement-fwd.hh
index 52b9645..abc7f7a 100644
--- a/paludis/elike_use_requirement-fwd.hh
+++ b/paludis/elike_use_requirement-fwd.hh
@@ -24,7 +24,7 @@
#include <paludis/util/options-fwd.hh>
#include <paludis/package_id-fwd.hh>
#include <paludis/dep_spec-fwd.hh>
-#include <paludis/package_dep_spec_requirement-fwd.hh>
+#include <paludis/additional_package_dep_spec_requirement-fwd.hh>
#include <iosfwd>
#include <string>
#include <memory>
@@ -37,7 +37,7 @@ namespace paludis
typedef Options<ELikeUseRequirementOption> ELikeUseRequirementOptions;
- std::shared_ptr<const ChoiceRequirement> parse_elike_use_requirement(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> parse_elike_use_requirement(
const std::string &, const ELikeUseRequirementOptions &)
PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
}
diff --git a/paludis/elike_use_requirement.cc b/paludis/elike_use_requirement.cc
index dd56233..82b242e 100644
--- a/paludis/elike_use_requirement.cc
+++ b/paludis/elike_use_requirement.cc
@@ -18,15 +18,6 @@
*/
#include <paludis/elike_use_requirement.hh>
-#include <paludis/dep_spec.hh>
-#include <paludis/name.hh>
-#include <paludis/environment.hh>
-#include <paludis/package_id.hh>
-#include <paludis/metadata_key.hh>
-#include <paludis/choice.hh>
-#include <paludis/changed_choices.hh>
-#include <paludis/package_dep_spec_requirement.hh>
-
#include <paludis/util/options.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/join.hh>
@@ -34,7 +25,14 @@
#include <paludis/util/log.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/tribool.hh>
-
+#include <paludis/dep_spec.hh>
+#include <paludis/name.hh>
+#include <paludis/environment.hh>
+#include <paludis/package_id.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/choice.hh>
+#include <paludis/changed_choices.hh>
+#include <paludis/additional_package_dep_spec_requirement.hh>
#include <vector>
#include <functional>
#include <algorithm>
@@ -503,7 +501,7 @@ namespace
};
class UseRequirements :
- public ChoiceRequirement
+ public AdditionalPackageDepSpecRequirement
{
private:
typedef std::vector<std::shared_ptr<const UseRequirement> > Reqs;
@@ -814,7 +812,7 @@ ELikeUseRequirementError::ELikeUseRequirementError(const std::string & s, const
{
}
-std::shared_ptr<const ChoiceRequirement>
+std::shared_ptr<const AdditionalPackageDepSpecRequirement>
paludis::parse_elike_use_requirement(const std::string & s,
const ELikeUseRequirementOptions & options)
{
diff --git a/paludis/elike_use_requirement_TEST.cc b/paludis/elike_use_requirement_TEST.cc
index 184b819..f0872dd 100644
--- a/paludis/elike_use_requirement_TEST.cc
+++ b/paludis/elike_use_requirement_TEST.cc
@@ -21,7 +21,7 @@
#include <paludis/dep_spec.hh>
#include <paludis/elike_use_requirement.hh>
#include <paludis/choice.hh>
-#include <paludis/package_dep_spec_requirement.hh>
+#include <paludis/additional_package_dep_spec_requirement.hh>
#include <paludis/environments/test/test_environment.hh>
@@ -68,25 +68,25 @@ TEST(ELikeUseRequirements, Simple)
std::shared_ptr<FakePackageID> id(fake->add_version("cat", "pkg1", "1"));
set_conditionals(id, "enabled disabled");
- std::shared_ptr<const ChoiceRequirement> req1(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
parse_elike_use_requirement("enabled", { euro_strict_parsing }));
EXPECT_EQ("[enabled]", req1->as_raw_string());
EXPECT_EQ("Flag 'enabled' enabled", req1->as_human_string(make_null_shared_ptr()));
EXPECT_TRUE(req1->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
- std::shared_ptr<const ChoiceRequirement> req2(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
parse_elike_use_requirement("disabled", { euro_strict_parsing }));
EXPECT_EQ("[disabled]", req2->as_raw_string());
EXPECT_EQ("Flag 'disabled' enabled", req2->as_human_string(make_null_shared_ptr()));
EXPECT_TRUE(! req2->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
- std::shared_ptr<const ChoiceRequirement> req3(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req3(
parse_elike_use_requirement("-enabled", { euro_strict_parsing }));
EXPECT_EQ("[-enabled]", req3->as_raw_string());
EXPECT_EQ("Flag 'enabled' disabled", req3->as_human_string(make_null_shared_ptr()));
EXPECT_TRUE(! req3->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
- std::shared_ptr<const ChoiceRequirement> req4(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req4(
parse_elike_use_requirement("-disabled", { euro_strict_parsing }));
EXPECT_EQ("[-disabled]", req4->as_raw_string());
EXPECT_EQ("Flag 'disabled' disabled", req4->as_human_string(make_null_shared_ptr()));
@@ -104,25 +104,25 @@ TEST(ELikeUseRequirements, Portage)
std::shared_ptr<FakePackageID> id(fake->add_version("cat", "pkg1", "1"));
set_conditionals(id, "enabled disabled");
- std::shared_ptr<const ChoiceRequirement> req1(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
parse_elike_use_requirement("enabled", { euro_portage_syntax, euro_strict_parsing }));
EXPECT_EQ("[enabled]", req1->as_raw_string());
EXPECT_EQ("Flag 'enabled' enabled", req1->as_human_string(make_null_shared_ptr()));
EXPECT_TRUE(req1->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
- std::shared_ptr<const ChoiceRequirement> req2(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
parse_elike_use_requirement("disabled", { euro_portage_syntax, euro_strict_parsing }));
EXPECT_EQ("[disabled]", req2->as_raw_string());
EXPECT_EQ("Flag 'disabled' enabled", req2->as_human_string(make_null_shared_ptr()));
EXPECT_TRUE(! req2->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
- std::shared_ptr<const ChoiceRequirement> req3(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req3(
parse_elike_use_requirement("-enabled", { euro_portage_syntax, euro_strict_parsing }));
EXPECT_EQ("[-enabled]", req3->as_raw_string());
EXPECT_EQ("Flag 'enabled' disabled", req3->as_human_string(make_null_shared_ptr()));
EXPECT_TRUE(! req3->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
- std::shared_ptr<const ChoiceRequirement> req4(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req4(
parse_elike_use_requirement("-disabled", { euro_portage_syntax, euro_strict_parsing }));
EXPECT_EQ("[-disabled]", req4->as_raw_string());
EXPECT_EQ("Flag 'disabled' disabled", req4->as_human_string(make_null_shared_ptr()));
@@ -140,31 +140,31 @@ TEST(ELikeUseRequirements, Multiple)
std::shared_ptr<FakePackageID> id(fake->add_version("cat", "pkg1", "1"));
set_conditionals(id, "enabled disabled");
- std::shared_ptr<const ChoiceRequirement> req1(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
parse_elike_use_requirement("enabled,-disabled", { euro_portage_syntax, euro_strict_parsing }));
EXPECT_EQ("[enabled,-disabled]", req1->as_raw_string());
EXPECT_EQ("Flag 'enabled' enabled; Flag 'disabled' disabled", req1->as_human_string(make_null_shared_ptr()));
EXPECT_TRUE(req1->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
- std::shared_ptr<const ChoiceRequirement> req2(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
parse_elike_use_requirement("enabled,disabled", { euro_portage_syntax, euro_strict_parsing }));
EXPECT_EQ("[enabled,disabled]", req2->as_raw_string());
EXPECT_EQ("Flag 'enabled' enabled; Flag 'disabled' enabled", req2->as_human_string(make_null_shared_ptr()));
EXPECT_TRUE(! req2->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
- std::shared_ptr<const ChoiceRequirement> req3(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req3(
parse_elike_use_requirement("-enabled,-disabled", { euro_portage_syntax, euro_strict_parsing }));
EXPECT_EQ("[-enabled,-disabled]", req3->as_raw_string());
EXPECT_EQ("Flag 'enabled' disabled; Flag 'disabled' disabled", req3->as_human_string(make_null_shared_ptr()));
EXPECT_TRUE(! req3->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
- std::shared_ptr<const ChoiceRequirement> req4(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req4(
parse_elike_use_requirement("enabled,-disabled,-enabled", { euro_portage_syntax, euro_strict_parsing }));
EXPECT_EQ("[enabled,-disabled,-enabled]", req4->as_raw_string());
EXPECT_EQ("Flag 'enabled' enabled; Flag 'disabled' disabled; Flag 'enabled' disabled", req4->as_human_string(make_null_shared_ptr()));
EXPECT_TRUE(! req4->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
- std::shared_ptr<const ChoiceRequirement> req5(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req5(
parse_elike_use_requirement("enabled,-disabled,enabled", { euro_portage_syntax, euro_strict_parsing }));
EXPECT_EQ("[enabled,-disabled,enabled]", req5->as_raw_string());
EXPECT_EQ("Flag 'enabled' enabled; Flag 'disabled' disabled; Flag 'enabled' enabled", req5->as_human_string(make_null_shared_ptr()));
@@ -184,84 +184,84 @@ TEST(ELikeUseRequirements, Complex)
std::shared_ptr<FakePackageID> id2(fake->add_version("cat", "disabled", "1"));
set_conditionals(id2, "pkgname");
- std::shared_ptr<const ChoiceRequirement> req1(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_strict_parsing }));
EXPECT_EQ("[pkgname?]", req1->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled if it is enabled for 'cat/enabled-1:0::fake'", req1->as_human_string(id));
EXPECT_TRUE(req1->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(! req1->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req2(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_strict_parsing }));
EXPECT_EQ("[pkgname?]", req2->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled if it is enabled for 'cat/disabled-1:0::fake'", req2->as_human_string(id2));
EXPECT_TRUE(req2->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req2->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req3(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req3(
parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps, euro_strict_parsing }));
EXPECT_EQ("[-pkgname?]", req3->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is enabled for 'cat/enabled-1:0::fake'", req3->as_human_string(id));
EXPECT_TRUE(! req3->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req3->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req4(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req4(
parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps, euro_strict_parsing }));
EXPECT_EQ("[-pkgname?]", req4->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is enabled for 'cat/disabled-1:0::fake'", req4->as_human_string(id2));
EXPECT_TRUE(req4->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req4->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req5(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req5(
parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps, euro_strict_parsing }));
EXPECT_EQ("[pkgname!?]", req5->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled if it is disabled for 'cat/enabled-1:0::fake'", req5->as_human_string(id));
EXPECT_TRUE(req5->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req5->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req6(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req6(
parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps, euro_strict_parsing }));
EXPECT_EQ("[pkgname!?]", req6->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled if it is disabled for 'cat/disabled-1:0::fake'", req6->as_human_string(id2));
EXPECT_TRUE(req6->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(! req6->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req7(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req7(
parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps, euro_strict_parsing }));
EXPECT_EQ("[-pkgname!?]", req7->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'", req7->as_human_string(id));
EXPECT_TRUE(req7->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req7->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req8(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req8(
parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps, euro_strict_parsing }));
EXPECT_EQ("[-pkgname!?]", req8->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'", req8->as_human_string(id2));
EXPECT_TRUE(! req8->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req8->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req9(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req9(
parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_strict_parsing }));
EXPECT_EQ("[pkgname=]", req9->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled like it is for 'cat/enabled-1:0::fake'", req9->as_human_string(id));
EXPECT_TRUE(req9->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(! req9->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req10(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req10(
parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_strict_parsing }));
EXPECT_EQ("[pkgname=]", req10->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled like it is for 'cat/disabled-1:0::fake'", req10->as_human_string(id2));
EXPECT_TRUE(! req10->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req10->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req11(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req11(
parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps, euro_strict_parsing }));
EXPECT_EQ("[pkgname!=]", req11->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'", req11->as_human_string(id));
EXPECT_TRUE(! req11->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req11->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req12(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req12(
parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps, euro_strict_parsing }));
EXPECT_EQ("[pkgname!=]", req12->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'", req12->as_human_string(id2));
@@ -282,56 +282,56 @@ TEST(ELikeUseRequirements, ComplexPortage)
std::shared_ptr<FakePackageID> id2(fake->add_version("cat", "disabled", "1"));
set_conditionals(id2, "pkgname");
- std::shared_ptr<const ChoiceRequirement> req1(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
EXPECT_EQ("[pkgname?]", req1->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled if it is enabled for 'cat/enabled-1:0::fake'", req1->as_human_string(id));
EXPECT_TRUE(req1->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(! req1->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req2(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
EXPECT_EQ("[pkgname?]", req2->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled if it is enabled for 'cat/disabled-1:0::fake'", req2->as_human_string(id2));
EXPECT_TRUE(req2->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req2->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req7(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req7(
parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
EXPECT_EQ("[!pkgname?]", req7->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'", req7->as_human_string(id));
EXPECT_TRUE(req7->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req7->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req8(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req8(
parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
EXPECT_EQ("[!pkgname?]", req8->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'", req8->as_human_string(id2));
EXPECT_TRUE(! req8->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req8->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req9(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req9(
parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
EXPECT_EQ("[pkgname=]", req9->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled like it is for 'cat/enabled-1:0::fake'", req9->as_human_string(id));
EXPECT_TRUE(req9->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(! req9->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req10(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req10(
parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
EXPECT_EQ("[pkgname=]", req10->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled like it is for 'cat/disabled-1:0::fake'", req10->as_human_string(id2));
EXPECT_TRUE(! req10->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req10->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req11(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req11(
parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
EXPECT_EQ("[!pkgname=]", req11->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'", req11->as_human_string(id));
EXPECT_TRUE(! req11->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req11->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req12(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req12(
parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
EXPECT_EQ("[!pkgname=]", req12->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'", req12->as_human_string(id2));
@@ -352,112 +352,112 @@ TEST(ELikeUseRequirements, Both)
std::shared_ptr<FakePackageID> id2(fake->add_version("cat", "disabled", "1"));
set_conditionals(id2, "pkgname");
- std::shared_ptr<const ChoiceRequirement> req1(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
EXPECT_EQ("[pkgname?]", req1->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled if it is enabled for 'cat/enabled-1:0::fake'", req1->as_human_string(id));
EXPECT_TRUE(req1->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(! req1->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req2(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
EXPECT_EQ("[pkgname?]", req2->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled if it is enabled for 'cat/disabled-1:0::fake'", req2->as_human_string(id2));
EXPECT_TRUE(req2->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req2->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req7(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req7(
parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
EXPECT_EQ("[!pkgname?]", req7->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'", req7->as_human_string(id));
EXPECT_TRUE(req7->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req7->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req8(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req8(
parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
EXPECT_EQ("[!pkgname?]", req8->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'", req8->as_human_string(id2));
EXPECT_TRUE(! req8->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req8->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req9(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req9(
parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
EXPECT_EQ("[pkgname=]", req9->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled like it is for 'cat/enabled-1:0::fake'", req9->as_human_string(id));
EXPECT_TRUE(req9->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(! req9->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req10(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req10(
parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
EXPECT_EQ("[pkgname=]", req10->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled like it is for 'cat/disabled-1:0::fake'", req10->as_human_string(id2));
EXPECT_TRUE(! req10->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req10->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req11(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req11(
parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
EXPECT_EQ("[!pkgname=]", req11->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'", req11->as_human_string(id));
EXPECT_TRUE(! req11->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req11->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req12(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req12(
parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
EXPECT_EQ("[!pkgname=]", req12->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'", req12->as_human_string(id2));
EXPECT_TRUE(req12->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(! req12->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req13(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req13(
parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
EXPECT_EQ("[-pkgname?]", req13->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is enabled for 'cat/enabled-1:0::fake'", req13->as_human_string(id));
EXPECT_TRUE(! req13->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req13->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req14(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req14(
parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
EXPECT_EQ("[-pkgname?]", req14->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is enabled for 'cat/disabled-1:0::fake'", req14->as_human_string(id2));
EXPECT_TRUE(req14->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req14->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req15(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req15(
parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
EXPECT_EQ("[pkgname!?]", req15->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled if it is disabled for 'cat/enabled-1:0::fake'", req15->as_human_string(id));
EXPECT_TRUE(req15->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req15->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req16(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req16(
parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
EXPECT_EQ("[pkgname!?]", req16->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled if it is disabled for 'cat/disabled-1:0::fake'", req16->as_human_string(id2));
EXPECT_TRUE(req16->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(! req16->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req17(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req17(
parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
EXPECT_EQ("[-pkgname!?]", req17->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'", req17->as_human_string(id));
EXPECT_TRUE(req17->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req17->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req18(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req18(
parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
EXPECT_EQ("[-pkgname!?]", req18->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'", req18->as_human_string(id2));
EXPECT_TRUE(! req18->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req18->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req19(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req19(
parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
EXPECT_EQ("[pkgname!=]", req19->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'", req19->as_human_string(id));
EXPECT_TRUE(! req19->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req19->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req20(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req20(
parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
EXPECT_EQ("[pkgname!=]", req20->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'", req20->as_human_string(id2));
@@ -556,112 +556,112 @@ TEST(ELikeUseRequirements, ComplexNonStrict)
std::shared_ptr<FakePackageID> id2(fake->add_version("cat", "disabled", "1"));
set_conditionals(id2, "pkgname");
- std::shared_ptr<const ChoiceRequirement> req1(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
parse_elike_use_requirement("pkgname?", { euro_allow_self_deps }));
EXPECT_EQ("[pkgname?]", req1->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled if it is enabled for 'cat/enabled-1:0::fake'", req1->as_human_string(id));
EXPECT_TRUE(req1->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(! req1->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req2(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
parse_elike_use_requirement("pkgname?", { euro_allow_self_deps }));
EXPECT_EQ("[pkgname?]", req2->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled if it is enabled for 'cat/disabled-1:0::fake'", req2->as_human_string(id2));
EXPECT_TRUE(req2->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req2->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req7(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req7(
parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps }));
EXPECT_EQ("[!pkgname?]", req7->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'", req7->as_human_string(id));
EXPECT_TRUE(req7->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req7->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req8(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req8(
parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps }));
EXPECT_EQ("[!pkgname?]", req8->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'", req8->as_human_string(id2));
EXPECT_TRUE(! req8->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req8->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req9(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req9(
parse_elike_use_requirement("pkgname=", { euro_allow_self_deps }));
EXPECT_EQ("[pkgname=]", req9->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled like it is for 'cat/enabled-1:0::fake'", req9->as_human_string(id));
EXPECT_TRUE(req9->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(! req9->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req10(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req10(
parse_elike_use_requirement("pkgname=", { euro_allow_self_deps }));
EXPECT_EQ("[pkgname=]", req10->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled like it is for 'cat/disabled-1:0::fake'", req10->as_human_string(id2));
EXPECT_TRUE(! req10->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req10->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req11(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req11(
parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps }));
EXPECT_EQ("[!pkgname=]", req11->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'", req11->as_human_string(id));
EXPECT_TRUE(! req11->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req11->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req12(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req12(
parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps }));
EXPECT_EQ("[!pkgname=]", req12->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'", req12->as_human_string(id2));
EXPECT_TRUE(req12->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(! req12->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req13(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req13(
parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps }));
EXPECT_EQ("[-pkgname?]", req13->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is enabled for 'cat/enabled-1:0::fake'", req13->as_human_string(id));
EXPECT_TRUE(! req13->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req13->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req14(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req14(
parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps }));
EXPECT_EQ("[-pkgname?]", req14->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is enabled for 'cat/disabled-1:0::fake'", req14->as_human_string(id2));
EXPECT_TRUE(req14->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req14->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req15(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req15(
parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps }));
EXPECT_EQ("[pkgname!?]", req15->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled if it is disabled for 'cat/enabled-1:0::fake'", req15->as_human_string(id));
EXPECT_TRUE(req15->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req15->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req16(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req16(
parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps }));
EXPECT_EQ("[pkgname!?]", req16->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled if it is disabled for 'cat/disabled-1:0::fake'", req16->as_human_string(id2));
EXPECT_TRUE(req16->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(! req16->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req17(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req17(
parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps }));
EXPECT_EQ("[-pkgname!?]", req17->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'", req17->as_human_string(id));
EXPECT_TRUE(req17->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req17->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req18(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req18(
parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps }));
EXPECT_EQ("[-pkgname!?]", req18->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'", req18->as_human_string(id2));
EXPECT_TRUE(! req18->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req18->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req19(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req19(
parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps }));
EXPECT_EQ("[pkgname!=]", req19->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'", req19->as_human_string(id));
EXPECT_TRUE(! req19->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req19->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req20(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req20(
parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps }));
EXPECT_EQ("[pkgname!=]", req20->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'", req20->as_human_string(id2));
@@ -682,112 +682,112 @@ TEST(ELikeUseRequirements, PortageNonStrict)
std::shared_ptr<FakePackageID> id2(fake->add_version("cat", "disabled", "1"));
set_conditionals(id2, "pkgname");
- std::shared_ptr<const ChoiceRequirement> req1(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_portage_syntax }));
EXPECT_EQ("[pkgname?]", req1->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled if it is enabled for 'cat/enabled-1:0::fake'", req1->as_human_string(id));
EXPECT_TRUE(req1->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(! req1->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req2(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_portage_syntax }));
EXPECT_EQ("[pkgname?]", req2->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled if it is enabled for 'cat/disabled-1:0::fake'", req2->as_human_string(id2));
EXPECT_TRUE(req2->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req2->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req7(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req7(
parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps, euro_portage_syntax }));
EXPECT_EQ("[!pkgname?]", req7->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'", req7->as_human_string(id));
EXPECT_TRUE(req7->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req7->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req8(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req8(
parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps, euro_portage_syntax }));
EXPECT_EQ("[!pkgname?]", req8->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'", req8->as_human_string(id2));
EXPECT_TRUE(! req8->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req8->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req9(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req9(
parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_portage_syntax }));
EXPECT_EQ("[pkgname=]", req9->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled like it is for 'cat/enabled-1:0::fake'", req9->as_human_string(id));
EXPECT_TRUE(req9->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(! req9->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req10(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req10(
parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_portage_syntax }));
EXPECT_EQ("[pkgname=]", req10->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled like it is for 'cat/disabled-1:0::fake'", req10->as_human_string(id2));
EXPECT_TRUE(! req10->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req10->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req11(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req11(
parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps, euro_portage_syntax }));
EXPECT_EQ("[!pkgname=]", req11->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'", req11->as_human_string(id));
EXPECT_TRUE(! req11->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req11->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req12(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req12(
parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps, euro_portage_syntax }));
EXPECT_EQ("[!pkgname=]", req12->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'", req12->as_human_string(id2));
EXPECT_TRUE(req12->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(! req12->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req13(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req13(
parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps, euro_portage_syntax }));
EXPECT_EQ("[-pkgname?]", req13->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is enabled for 'cat/enabled-1:0::fake'", req13->as_human_string(id));
EXPECT_TRUE(! req13->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req13->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req14(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req14(
parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps, euro_portage_syntax }));
EXPECT_EQ("[-pkgname?]", req14->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is enabled for 'cat/disabled-1:0::fake'", req14->as_human_string(id2));
EXPECT_TRUE(req14->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req14->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req15(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req15(
parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps, euro_portage_syntax }));
EXPECT_EQ("[pkgname!?]", req15->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled if it is disabled for 'cat/enabled-1:0::fake'", req15->as_human_string(id));
EXPECT_TRUE(req15->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req15->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req16(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req16(
parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps, euro_portage_syntax }));
EXPECT_EQ("[pkgname!?]", req16->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled if it is disabled for 'cat/disabled-1:0::fake'", req16->as_human_string(id2));
EXPECT_TRUE(req16->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(! req16->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req17(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req17(
parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps, euro_portage_syntax }));
EXPECT_EQ("[-pkgname!?]", req17->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'", req17->as_human_string(id));
EXPECT_TRUE(req17->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req17->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req18(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req18(
parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps, euro_portage_syntax }));
EXPECT_EQ("[-pkgname!?]", req18->as_raw_string());
EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'", req18->as_human_string(id2));
EXPECT_TRUE(! req18->requirement_met(&env, 0, id, id2, 0).first);
EXPECT_TRUE(req18->requirement_met(&env, 0, id2, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req19(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req19(
parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps, euro_portage_syntax }));
EXPECT_EQ("[pkgname!=]", req19->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'", req19->as_human_string(id));
EXPECT_TRUE(! req19->requirement_met(&env, 0, id, id, 0).first);
EXPECT_TRUE(req19->requirement_met(&env, 0, id2, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req20(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req20(
parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps, euro_portage_syntax }));
EXPECT_EQ("[pkgname!=]", req20->as_raw_string());
EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'", req20->as_human_string(id2));
@@ -806,25 +806,25 @@ TEST(ELikeUseRequirements, Defaults)
std::shared_ptr<FakePackageID> id(fake->add_version("cat", "pkg1", "1"));
set_conditionals(id, "enabled disabled");
- std::shared_ptr<const ChoiceRequirement> req1(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
parse_elike_use_requirement("missing(+)", { euro_allow_default_values, euro_strict_parsing }));
EXPECT_EQ("[missing(+)]", req1->as_raw_string());
EXPECT_EQ("Flag 'missing' enabled, assuming enabled if missing", req1->as_human_string(make_null_shared_ptr()));
EXPECT_TRUE(req1->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
- std::shared_ptr<const ChoiceRequirement> req2(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
parse_elike_use_requirement("missing(-)", { euro_allow_default_values, euro_strict_parsing }));
EXPECT_EQ("[missing(-)]", req2->as_raw_string());
EXPECT_EQ("Flag 'missing' enabled, assuming disabled if missing", req2->as_human_string(make_null_shared_ptr()));
EXPECT_TRUE(! req2->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
- std::shared_ptr<const ChoiceRequirement> req3(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req3(
parse_elike_use_requirement("-missing(+)", { euro_allow_default_values, euro_strict_parsing }));
EXPECT_EQ("[-missing(+)]", req3->as_raw_string());
EXPECT_EQ("Flag 'missing' disabled, assuming enabled if missing", req3->as_human_string(make_null_shared_ptr()));
EXPECT_TRUE(! req3->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
- std::shared_ptr<const ChoiceRequirement> req4(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req4(
parse_elike_use_requirement("-missing(-)", { euro_allow_default_values, euro_strict_parsing }));
EXPECT_EQ("[-missing(-)]", req4->as_raw_string());
EXPECT_EQ("Flag 'missing' disabled, assuming disabled if missing", req4->as_human_string(make_null_shared_ptr()));
@@ -842,12 +842,12 @@ TEST(ELikeUseRequirements, PrefixStar)
std::shared_ptr<FakePackageID> id(fake->add_version("cat", "pkg1", "1"));
set_conditionals(id, "foo:enabled foo:disabled");
- std::shared_ptr<const ChoiceRequirement> req1(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
parse_elike_use_requirement("foo:*", { euro_allow_default_values, euro_allow_self_deps }));
EXPECT_EQ("[foo:*]", req1->as_raw_string());
EXPECT_TRUE(! req1->requirement_met(&env, 0, id, id, 0).first);
- std::shared_ptr<const ChoiceRequirement> req2(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
parse_elike_use_requirement("foo:*=", { euro_allow_default_values, euro_allow_self_deps }));
EXPECT_EQ("[foo:*=]", req2->as_raw_string());
EXPECT_TRUE(req2->requirement_met(&env, 0, id, id, 0).first);
@@ -868,13 +868,13 @@ TEST(ELikeUseRequirements, QuestionDefaults)
std::shared_ptr<FakePackageID> id2(fake->add_version("cat", "pkg2", "1"));
set_conditionals(id2, "foo:enabled foo:disabled bar:enabled bar:disabled");
- std::shared_ptr<const ChoiceRequirement> req1(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
parse_elike_use_requirement("foo:*(?)=", { euro_allow_default_values, euro_allow_self_deps, euro_allow_default_question_values }));
EXPECT_EQ("[foo:*(?)=]", req1->as_raw_string());
EXPECT_TRUE(req1->requirement_met(&env, 0, id2, id2, 0).first);
EXPECT_TRUE(req1->requirement_met(&env, 0, id1, id2, 0).first);
- std::shared_ptr<const ChoiceRequirement> req2(
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
parse_elike_use_requirement("bar:*(?)=", { euro_allow_default_values, euro_allow_self_deps, euro_allow_default_question_values }));
EXPECT_EQ("[bar:*(?)=]", req2->as_raw_string());
EXPECT_TRUE(req2->requirement_met(&env, 0, id2, id2, 0).first);
diff --git a/paludis/environment_implementation.cc b/paludis/environment_implementation.cc
index 0aa5b84..c6b4718 100644
--- a/paludis/environment_implementation.cc
+++ b/paludis/environment_implementation.cc
@@ -27,7 +27,7 @@
#include <paludis/generator.hh>
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
-#include <paludis/dep_spec_data.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <paludis/util/log.hh>
#include <paludis/util/save.hh>
@@ -499,7 +499,7 @@ EnvironmentImplementation::fetch_unique_qualified_package_name(const PackageName
std::set<std::pair<CategoryNamePart, RepositoryName>, CategoryRepositoryNamePairComparator> checked;
std::shared_ptr<const PackageIDSequence> pkgs((*this)[selection::AllVersionsUnsorted(
- generator::Matches(MutablePackageDepSpecData({ }).require_package_name_part(p), make_null_shared_ptr(), { }) | f)]);
+ generator::Matches(make_package_dep_spec({ }).package_name_part(p), make_null_shared_ptr(), { }) | f)]);
for (IndirectIterator<PackageIDSequence::ConstIterator> it(pkgs->begin()),
it_end(pkgs->end()); it_end != it; ++it)
diff --git a/paludis/environments/paludis/keywords_conf.cc b/paludis/environments/paludis/keywords_conf.cc
index 4618078..4837cfb 100644
--- a/paludis/environments/paludis/keywords_conf.cc
+++ b/paludis/environments/paludis/keywords_conf.cc
@@ -17,21 +17,18 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/environments/paludis/keywords_conf.hh>
-#include <paludis/environments/paludis/paludis_environment.hh>
-#include <paludis/environments/paludis/bashable_conf.hh>
-
+#include "keywords_conf.hh"
#include <paludis/environment.hh>
#include <paludis/name.hh>
#include <paludis/dep_spec.hh>
#include <paludis/spec_tree.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/match_package.hh>
-#include <paludis/package_id.hh>
-#include <paludis/package_dep_spec_requirement.hh>
-
#include <paludis/util/config_file.hh>
#include <paludis/util/options.hh>
+#include <paludis/package_id.hh>
+#include <paludis/environments/paludis/paludis_environment.hh>
+#include <paludis/environments/paludis/bashable_conf.hh>
#include <paludis/util/log.hh>
#include <paludis/util/pimp-impl.hh>
#include <paludis/util/tokeniser.hh>
@@ -41,7 +38,6 @@
#include <paludis/util/set.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/make_null_shared_ptr.hh>
-
#include <unordered_map>
#include <list>
#include <vector>
@@ -108,9 +104,9 @@ KeywordsConf::add(const FSPath & filename)
{
std::shared_ptr<PackageDepSpec> d(std::make_shared<PackageDepSpec>(parse_user_package_dep_spec(
tokens.at(0), _imp->env, { updso_allow_wildcards, updso_no_disambiguation, updso_throw_if_set })));
- if (d->package_name_requirement())
+ if (d->package_ptr())
{
- KeywordsList & k(_imp->qualified[d->package_name_requirement()->name()][d]);
+ KeywordsList & k(_imp->qualified[*d->package_ptr()][d]);
for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
t != t_end ; ++t)
k.push_back(KeywordName(*t));
diff --git a/paludis/environments/paludis/licenses_conf.cc b/paludis/environments/paludis/licenses_conf.cc
index 6c4a15c..7e58292 100644
--- a/paludis/environments/paludis/licenses_conf.cc
+++ b/paludis/environments/paludis/licenses_conf.cc
@@ -17,10 +17,7 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/environments/paludis/licenses_conf.hh>
-#include <paludis/environments/paludis/paludis_environment.hh>
-#include <paludis/environments/paludis/bashable_conf.hh>
-
+#include "licenses_conf.hh"
#include <paludis/environment.hh>
#include <paludis/name.hh>
#include <paludis/dep_spec.hh>
@@ -29,9 +26,9 @@
#include <paludis/match_package.hh>
#include <paludis/util/config_file.hh>
#include <paludis/package_id.hh>
-#include <paludis/package_dep_spec_requirement.hh>
-
#include <paludis/util/options.hh>
+#include <paludis/environments/paludis/paludis_environment.hh>
+#include <paludis/environments/paludis/bashable_conf.hh>
#include <paludis/util/log.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/util/pimp-impl.hh>
@@ -40,7 +37,6 @@
#include <paludis/util/iterator_funcs.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/make_null_shared_ptr.hh>
-
#include <unordered_map>
#include <list>
#include <vector>
@@ -108,9 +104,9 @@ LicensesConf::add(const FSPath & filename)
std::shared_ptr<PackageDepSpec> d(std::make_shared<PackageDepSpec>(parse_user_package_dep_spec(
tokens.at(0), _imp->env,
{ updso_allow_wildcards, updso_no_disambiguation, updso_throw_if_set })));
- if (d->package_name_requirement())
+ if (d->package_ptr())
{
- LicensesList & k(_imp->qualified[d->package_name_requirement()->name()][d]);
+ LicensesList & k(_imp->qualified[*d->package_ptr()][d]);
for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
t != t_end ; ++t)
k.push_back(*t);
diff --git a/paludis/environments/paludis/suggestions_conf.cc b/paludis/environments/paludis/suggestions_conf.cc
index 4289dc6..fa9c313 100644
--- a/paludis/environments/paludis/suggestions_conf.cc
+++ b/paludis/environments/paludis/suggestions_conf.cc
@@ -21,7 +21,6 @@
#include <paludis/environments/paludis/paludis_environment.hh>
#include <paludis/environments/paludis/paludis_config.hh>
#include <paludis/environments/paludis/bashable_conf.hh>
-
#include <paludis/util/config_file.hh>
#include <paludis/util/options.hh>
#include <paludis/util/log.hh>
@@ -32,7 +31,6 @@
#include <paludis/util/iterator_funcs.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/make_null_shared_ptr.hh>
-
#include <paludis/environment.hh>
#include <paludis/name.hh>
#include <paludis/dep_spec.hh>
@@ -41,8 +39,6 @@
#include <paludis/match_package.hh>
#include <paludis/package_id.hh>
#include <paludis/dep_spec_annotations.hh>
-#include <paludis/package_dep_spec_requirement.hh>
-
#include <unordered_map>
#include <list>
#include <vector>
@@ -150,9 +146,9 @@ SuggestionsConf::add(const FSPath & filename)
std::shared_ptr<PackageDepSpec> d(std::make_shared<PackageDepSpec>(parse_user_package_dep_spec(
tokens.at(0), _imp->env,
{ updso_allow_wildcards, updso_no_disambiguation, updso_throw_if_set })));
- if (d->package_name_requirement())
+ if (d->package_ptr())
{
- ValuesList & k(_imp->qualified[d->package_name_requirement()->name()][d]);
+ ValuesList & k(_imp->qualified[*d->package_ptr()][d]);
for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
t != t_end ; ++t)
k.push_back(ValueFlag(*t));
@@ -212,10 +208,10 @@ SuggestionsConf::interest_in_suggestion(
else
{
if (! l->pkg_requirement.empty())
- if (stringify(spec.package_name_requirement()->name().package()) != l->pkg_requirement)
+ if (stringify(spec.package_ptr()->package()) != l->pkg_requirement)
continue;
if (! l->cat_requirement.empty())
- if (stringify(spec.package_name_requirement()->name().category()) != l->cat_requirement)
+ if (stringify(spec.package_ptr()->category()) != l->cat_requirement)
continue;
return l->negated ? false : true;
@@ -256,10 +252,10 @@ SuggestionsConf::interest_in_suggestion(
else
{
if (! l->pkg_requirement.empty())
- if (stringify(spec.package_name_requirement()->name().package()) != l->pkg_requirement)
+ if (stringify(spec.package_ptr()->package()) != l->pkg_requirement)
continue;
if (! l->cat_requirement.empty())
- if (stringify(spec.package_name_requirement()->name().category()) != l->cat_requirement)
+ if (stringify(spec.package_ptr()->category()) != l->cat_requirement)
continue;
return l->negated ? false : true;
@@ -287,10 +283,10 @@ SuggestionsConf::interest_in_suggestion(
else
{
if (! l->pkg_requirement.empty())
- if (stringify(spec.package_name_requirement()->name().package()) != l->pkg_requirement)
+ if (stringify(spec.package_ptr()->package()) != l->pkg_requirement)
continue;
if (! l->cat_requirement.empty())
- if (stringify(spec.package_name_requirement()->name().category()) != l->cat_requirement)
+ if (stringify(spec.package_ptr()->category()) != l->cat_requirement)
continue;
return l->negated ? false : true;
diff --git a/paludis/environments/paludis/world.cc b/paludis/environments/paludis/world.cc
index 3256925..b546d4f 100644
--- a/paludis/environments/paludis/world.cc
+++ b/paludis/environments/paludis/world.cc
@@ -18,7 +18,6 @@
*/
#include <paludis/environments/paludis/world.hh>
-
#include <paludis/util/pimp-impl.hh>
#include <paludis/util/mutex.hh>
#include <paludis/util/stringify.hh>
@@ -26,11 +25,9 @@
#include <paludis/util/make_named_values.hh>
#include <paludis/util/safe_ofstream.hh>
#include <paludis/util/fs_stat.hh>
-
#include <paludis/set_file.hh>
#include <paludis/user_dep_spec.hh>
-#include <paludis/dep_spec_data.hh>
-
+#include <paludis/partially_made_package_dep_spec.hh>
#include <functional>
using namespace paludis;
@@ -169,10 +166,7 @@ void
World::update_config_files_for_package_move(const PackageDepSpec & s, const QualifiedPackageName & n) const
{
if (_remove_string_from_world(stringify(s)))
- _add_string_to_world(stringify(
- MutablePackageDepSpecData(*s.data())
- .unrequire_package()
- .require_package(n)));
+ _add_string_to_world(stringify(PartiallyMadePackageDepSpec(s).package(n)));
}
const std::shared_ptr<const SetSpecTree>
diff --git a/paludis/environments/paludis/world_TEST.cc b/paludis/environments/paludis/world_TEST.cc
index d3b572f..cbb2f7f 100644
--- a/paludis/environments/paludis/world_TEST.cc
+++ b/paludis/environments/paludis/world_TEST.cc
@@ -23,7 +23,7 @@
#include <paludis/util/safe_ifstream.hh>
#include <paludis/util/options.hh>
-#include <paludis/dep_spec_data.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <iterator>
#include <cstdlib>
@@ -39,8 +39,8 @@ TEST(World, Updates)
{
TestEnvironment env;
paludis_environment::World world(&env, w);
- world.update_config_files_for_package_move(MutablePackageDepSpecData({ })
- .require_package(QualifiedPackageName("cat/before")),
+ world.update_config_files_for_package_move(make_package_dep_spec({ })
+ .package(QualifiedPackageName("cat/before")),
QualifiedPackageName("cat/after"));
}
diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc
index dfdef86..c6a58c2 100644
--- a/paludis/environments/portage/portage_environment.cc
+++ b/paludis/environments/portage/portage_environment.cc
@@ -56,8 +56,7 @@
#include <paludis/literal_metadata_key.hh>
#include <paludis/repository_factory.hh>
#include <paludis/choice.hh>
-#include <paludis/dep_spec_data.hh>
-#include <paludis/package_dep_spec_properties.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <functional>
#include <algorithm>
@@ -361,7 +360,7 @@ PortageEnvironment::PortageEnvironment(const std::string & s) :
template<typename I_>
void
-PortageEnvironment::_load_atom_file(const FSPath & f, I_ i, const std::string & def_value, const bool reject_choices)
+PortageEnvironment::_load_atom_file(const FSPath & f, I_ i, const std::string & def_value, const bool reject_additional)
{
using namespace std::placeholders;
@@ -373,7 +372,7 @@ PortageEnvironment::_load_atom_file(const FSPath & f, I_ i, const std::string &
if (f.stat().is_directory())
{
std::for_each(FSIterator(f, { }), FSIterator(), std::bind(
- &PortageEnvironment::_load_atom_file<I_>, this, _1, i, def_value, reject_choices));
+ &PortageEnvironment::_load_atom_file<I_>, this, _1, i, def_value, reject_additional));
}
else
{
@@ -389,22 +388,7 @@ PortageEnvironment::_load_atom_file(const FSPath & f, I_ i, const std::string &
std::shared_ptr<PackageDepSpec> p(std::make_shared<PackageDepSpec>(parse_user_package_dep_spec(
tokens.at(0), this, UserPackageDepSpecOptions() + updso_no_disambiguation)));
- if (reject_choices && package_dep_spec_has_properties(*p, make_named_values<PackageDepSpecProperties>(
- n::has_any_slot_requirement() = indeterminate,
- n::has_category_name_part() = indeterminate,
- n::has_choice_requirements() = true,
- n::has_exact_slot_requirement() = indeterminate,
- n::has_from_repository() = indeterminate,
- n::has_in_repository() = indeterminate,
- n::has_installable_to_path() = indeterminate,
- n::has_installable_to_repository() = indeterminate,
- n::has_installed_at_path() = indeterminate,
- n::has_key_requirements() = indeterminate,
- n::has_package() = indeterminate,
- n::has_package_name_part() = indeterminate,
- n::has_tag() = indeterminate,
- n::has_version_requirements() = indeterminate
- )))
+ if (reject_additional && p->additional_requirements_ptr())
{
Log::get_instance()->message("portage_environment.bad_spec", ll_warning, lc_context)
<< "Dependency specification '" << stringify(*p)
@@ -955,10 +939,7 @@ void
PortageEnvironment::update_config_files_for_package_move(const PackageDepSpec & s, const QualifiedPackageName & n) const
{
if (_remove_string_from_world(stringify(s)))
- _add_string_to_world(stringify(
- MutablePackageDepSpecData(*s.data())
- .unrequire_package()
- .require_package(n)));
+ _add_string_to_world(stringify(PartiallyMadePackageDepSpec(s).package(n)));
}
void
diff --git a/paludis/environments/portage/portage_environment_TEST.cc b/paludis/environments/portage/portage_environment_TEST.cc
index a1d8b70..03db3e8 100644
--- a/paludis/environments/portage/portage_environment_TEST.cc
+++ b/paludis/environments/portage/portage_environment_TEST.cc
@@ -37,7 +37,7 @@
#include <paludis/selection.hh>
#include <paludis/metadata_key.hh>
#include <paludis/choice.hh>
-#include <paludis/dep_spec_data.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <gtest/gtest.h>
@@ -178,8 +178,8 @@ TEST(PortageEnvironment, World)
TestPortageEnvironment env("portage_environment_TEST_dir/world");
FSPath w(FSPath::cwd() / "portage_environment_TEST_dir" / "world" / "var" / "lib" / "portage" / "world");
- env.update_config_files_for_package_move(MutablePackageDepSpecData({ })
- .require_package(QualifiedPackageName("cat/before")),
+ env.update_config_files_for_package_move(make_package_dep_spec({ })
+ .package(QualifiedPackageName("cat/before")),
QualifiedPackageName("cat/after"));
SafeIFStream f(w);
diff --git a/paludis/files.m4 b/paludis/files.m4
index 97cd33b..d7b398f 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -12,6 +12,7 @@ add(`about', `hh', `gtest')
add(`about_metadata', `hh', `cc', `fwd')
add(`action', `hh', `cc', `fwd', `se')
add(`action_names', `hh', `cc', `fwd')
+add(`additional_package_dep_spec_requirement', `hh', `cc', `fwd')
add(`always_enabled_dependency_label', `hh', `cc', `fwd')
add(`broken_linkage_configuration', `hh', `cc', `gtest', `testscript')
add(`broken_linkage_finder', `hh', `cc')
@@ -28,7 +29,7 @@ add(`create_output_manager_info', `hh', `cc', `fwd', `se')
add(`dep_label', `hh', `cc', `fwd')
add(`dep_spec', `hh', `cc', `gtest', `fwd')
add(`dep_spec_annotations', `hh', `cc', `fwd', `se')
-add(`dep_spec_data', `hh', `cc', `fwd', `se')
+add(`dep_spec_data', `hh', `cc', `fwd')
add(`dep_spec_flattener', `hh', `cc')
add(`distribution', `hh', `cc', `impl', `fwd')
add(`elf_linkage_checker', `hh', `cc')
@@ -37,6 +38,7 @@ add(`elike_choices', `hh', `cc', `fwd', `se')
add(`elike_dep_parser', `hh', `cc', `fwd', `gtest', `se')
add(`elike_conditional_dep_spec', `hh', `cc', `fwd')
add(`elike_package_dep_spec', `hh', `cc', `fwd', `se')
+add(`elike_slot_requirement', `hh', `cc', `fwd')
add(`elike_use_requirement', `hh', `cc', `fwd', `se', `gtest')
add(`environment', `hh', `fwd', `cc')
add(`environment_factory', `hh', `fwd', `cc')
@@ -75,10 +77,10 @@ add(`output_manager_factory', `hh', `fwd', `cc')
add(`output_manager_from_environment', `hh', `fwd', `cc')
add(`package_dep_spec_collection', `hh', `cc', `fwd')
add(`package_dep_spec_properties', `hh', `cc', `fwd')
-add(`package_dep_spec_requirement', `hh', `cc', `fwd', `se')
add(`package_id', `hh', `cc', `fwd', `se')
add(`paludis', `hh')
add(`paludislike_options_conf', `hh', `cc', `fwd')
+add(`partially_made_package_dep_spec', `hh', `cc', `fwd', `se')
add(`permitted_choice_value_parameter_values', `hh', `cc', `fwd')
add(`pretty_print_options', `hh', `cc', `fwd', `se')
add(`pretty_printer', `hh', `cc', `fwd')
@@ -89,6 +91,7 @@ add(`selection', `hh', `cc', `fwd', `gtest')
add(`selection_handler', `hh', `cc', `fwd')
add(`serialise', `hh', `cc', `fwd', `impl')
add(`set_file', `hh', `cc', `se', `gtest', `testscript')
+add(`slot_requirement', `hh', `fwd', `cc')
add(`spec_tree', `hh', `fwd', `cc')
add(`standard_output_manager', `hh', `cc', `fwd')
add(`stripper', `hh', `cc', `fwd', `gtest', `testscript')
@@ -100,5 +103,6 @@ add(`unformatted_pretty_printer', `hh', `cc', `fwd')
add(`unmerger', `hh', `cc')
add(`user_dep_spec', `hh', `cc', `se', `fwd', `gtest')
add(`version_operator', `hh', `cc', `fwd', `se', `gtest')
+add(`version_requirements', `hh', `cc', `fwd')
add(`version_spec', `hh', `cc', `se', `fwd', `gtest')
diff --git a/paludis/filter.cc b/paludis/filter.cc
index 664478c..2ce5d2f 100644
--- a/paludis/filter.cc
+++ b/paludis/filter.cc
@@ -467,8 +467,8 @@ namespace
virtual std::string as_string() const
{
std::string suffix;
- if (options[mpo_ignore_choice_requirements])
- suffix = " (ignoring choice requirements)";
+ if (options[mpo_ignore_additional_requirements])
+ suffix = " (ignoring additional requirements)";
return "packages matching " + stringify(spec) + suffix;
}
};
diff --git a/paludis/fuzzy_finder.cc b/paludis/fuzzy_finder.cc
index efcd8ae..3846609 100644
--- a/paludis/fuzzy_finder.cc
+++ b/paludis/fuzzy_finder.cc
@@ -28,7 +28,6 @@
#include <paludis/filter_handler.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/selection.hh>
-#include <paludis/package_dep_spec_requirement.hh>
#include <paludis/util/pimp-impl.hh>
#include <paludis/util/wrapped_forward_iterator-impl.hh>
@@ -144,17 +143,17 @@ FuzzyCandidatesFinder::FuzzyCandidatesFinder(const Environment & e, const std::s
{
PackageDepSpec pds(parse_user_package_dep_spec(name, &e, { }));
- if (pds.package_name_requirement())
+ if (pds.package_ptr())
{
- g = g & generator::Category(pds.package_name_requirement()->name().category());
- package = stringify(pds.package_name_requirement()->name().package());
+ g = g & generator::Category(pds.package_ptr()->category());
+ package = stringify(pds.package_ptr()->package());
}
- if (pds.in_repository_requirement())
- g = g & generator::InRepository(pds.in_repository_requirement()->name());
+ if (pds.in_repository_ptr())
+ g = g & generator::InRepository(*pds.in_repository_ptr());
- if (pds.from_repository_requirement())
- g = g & generator::FromRepository(pds.from_repository_requirement()->name());
+ if (pds.from_repository_ptr())
+ g = g & generator::FromRepository(*pds.from_repository_ptr());
}
std::shared_ptr<const PackageIDSequence> ids(e[selection::BestVersionOnly(g | FuzzyPackageName(package) | filter)]);
diff --git a/paludis/generator.cc b/paludis/generator.cc
index f60adce..a6e1111 100644
--- a/paludis/generator.cc
+++ b/paludis/generator.cc
@@ -29,7 +29,6 @@
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
#include <paludis/repository.hh>
-#include <paludis/package_dep_spec_requirement.hh>
#include <paludis/util/pimp-impl.hh>
#include <paludis/util/set.hh>
@@ -308,18 +307,16 @@ namespace
const RepositoryContentMayExcludes & x) const
{
if (package_dep_spec_has_properties(spec, make_named_values<PackageDepSpecProperties>(
- n::has_any_slot_requirement() = indeterminate,
+ n::has_additional_requirements() = indeterminate,
n::has_category_name_part() = indeterminate,
- n::has_choice_requirements() = indeterminate,
- n::has_exact_slot_requirement() = indeterminate,
n::has_from_repository() = indeterminate,
n::has_in_repository() = false,
n::has_installable_to_path() = indeterminate,
n::has_installable_to_repository() = indeterminate,
n::has_installed_at_path() = false,
- n::has_key_requirements() = indeterminate,
n::has_package() = indeterminate,
n::has_package_name_part() = indeterminate,
+ n::has_slot_requirement() = indeterminate,
n::has_tag() = indeterminate,
n::has_version_requirements() = indeterminate
)))
@@ -327,25 +324,26 @@ namespace
std::shared_ptr<RepositoryNameSet> result(std::make_shared<RepositoryNameSet>());
- if (spec.in_repository_requirement())
+ if (spec.in_repository_ptr())
{
- if (env->has_repository_named(spec.in_repository_requirement()->name()))
+ if (env->has_repository_named(*spec.in_repository_ptr()))
{
- if (spec.installed_at_path_requirement())
+ if (spec.installed_at_path_ptr())
{
- std::shared_ptr<const Repository> repo(env->fetch_repository(spec.in_repository_requirement()->name()));
+ std::shared_ptr<const Repository> repo(env->fetch_repository(
+ *spec.in_repository_ptr()));
if (! repo->installed_root_key())
return result;
- if (repo->installed_root_key()->parse_value() != spec.installed_at_path_requirement()->path())
+ if (repo->installed_root_key()->parse_value() != *spec.installed_at_path_ptr())
return result;
}
- result->insert(spec.in_repository_requirement()->name());
+ result->insert(*spec.in_repository_ptr());
}
}
else
{
- if (spec.installed_at_path_requirement())
+ if (spec.installed_at_path_ptr())
{
for (auto i(env->begin_repositories()),
i_end(env->end_repositories()) ; i != i_end ; ++i)
@@ -353,7 +351,7 @@ namespace
if (! (*i)->installed_root_key())
continue;
- if ((*i)->installed_root_key()->parse_value() != spec.installed_at_path_requirement()->path())
+ if ((*i)->installed_root_key()->parse_value() != *spec.installed_at_path_ptr())
continue;
result->insert((*i)->name());
@@ -371,45 +369,41 @@ namespace
const std::shared_ptr<const RepositoryNameSet> & repos,
const RepositoryContentMayExcludes & x) const
{
- auto category_name_part_requirement(spec.category_name_part_requirement());
- if (category_name_part_requirement)
+ if (spec.category_name_part_ptr())
{
std::shared_ptr<CategoryNamePartSet> result(std::make_shared<CategoryNamePartSet>());
for (RepositoryNameSet::ConstIterator r(repos->begin()), r_end(repos->end()) ;
r != r_end ; ++r)
- if (env->fetch_repository(*r)->has_category_named(category_name_part_requirement->name_part(), x))
+ if (env->fetch_repository(*r)->has_category_named(*spec.category_name_part_ptr(), x))
{
- result->insert(category_name_part_requirement->name_part());
+ result->insert(*spec.category_name_part_ptr());
break;
}
return result;
}
-
- auto package_name_part_requirement(spec.package_name_part_requirement());
- if (package_name_part_requirement)
+ else if (spec.package_name_part_ptr())
{
std::shared_ptr<CategoryNamePartSet> result(std::make_shared<CategoryNamePartSet>());
for (RepositoryNameSet::ConstIterator r(repos->begin()), r_end(repos->end()) ;
r != r_end ; ++r)
{
std::shared_ptr<const CategoryNamePartSet> cats(
- env->fetch_repository(*r)->category_names_containing_package(package_name_part_requirement->name_part(), x));
+ env->fetch_repository(*r)
+ ->category_names_containing_package(*spec.package_name_part_ptr(), x));
std::copy(cats->begin(), cats->end(), result->inserter());
}
return result;
}
-
- auto package_name_requirement(spec.package_name_requirement());
- if (package_name_requirement)
+ else if (spec.package_ptr())
{
std::shared_ptr<CategoryNamePartSet> result(std::make_shared<CategoryNamePartSet>());
for (RepositoryNameSet::ConstIterator r(repos->begin()), r_end(repos->end()) ;
r != r_end ; ++r)
- if (env->fetch_repository(*r)->has_category_named(package_name_requirement->name().category(), x))
+ if (env->fetch_repository(*r)->has_category_named(spec.package_ptr()->category(), x))
{
- result->insert(package_name_requirement->name().category());
+ result->insert(spec.package_ptr()->category());
break;
}
@@ -425,29 +419,26 @@ namespace
const std::shared_ptr<const CategoryNamePartSet> & cats,
const RepositoryContentMayExcludes & x) const
{
- auto package_name_part_requirement(spec.package_name_part_requirement());
- if (package_name_part_requirement)
+ if (spec.package_name_part_ptr())
{
std::shared_ptr<QualifiedPackageNameSet> result(std::make_shared<QualifiedPackageNameSet>());
for (RepositoryNameSet::ConstIterator r(repos->begin()), r_end(repos->end()) ;
r != r_end ; ++r)
for (CategoryNamePartSet::ConstIterator c(cats->begin()), c_end(cats->end()) ;
c != c_end ; ++c)
- if (env->fetch_repository(*r)->has_package_named(*c + package_name_part_requirement->name_part(), x))
- result->insert(*c + package_name_part_requirement->name_part());
+ if (env->fetch_repository(*r)->has_package_named(*c + *spec.package_name_part_ptr(), x))
+ result->insert(*c + *spec.package_name_part_ptr());
return result;
}
-
- auto package_name_requirement(spec.package_name_requirement());
- if (package_name_requirement)
+ else if (spec.package_ptr())
{
std::shared_ptr<QualifiedPackageNameSet> result(std::make_shared<QualifiedPackageNameSet>());
for (RepositoryNameSet::ConstIterator r(repos->begin()), r_end(repos->end()) ;
r != r_end ; ++r)
- if (env->fetch_repository(*r)->has_package_named(package_name_requirement->name(), x))
+ if (env->fetch_repository(*r)->has_package_named(*spec.package_ptr(), x))
{
- result->insert(package_name_requirement->name());
+ result->insert(*spec.package_ptr());
break;
}
@@ -486,8 +477,8 @@ namespace
virtual std::string as_string() const
{
std::string suffix;
- if (options[mpo_ignore_choice_requirements])
- suffix = " (ignoring choice requirements)";
+ if (options[mpo_ignore_additional_requirements])
+ suffix = " (ignoring additional requirements)";
return "packages matching " + stringify(spec) + suffix;
}
};
diff --git a/paludis/match_package.cc b/paludis/match_package.cc
index c5bebdd..a72f679 100644
--- a/paludis/match_package.cc
+++ b/paludis/match_package.cc
@@ -21,13 +21,13 @@
#include <paludis/dep_spec.hh>
#include <paludis/dep_spec_flattener.hh>
#include <paludis/environment.hh>
+#include <paludis/version_requirements.hh>
#include <paludis/package_id.hh>
+#include <paludis/slot_requirement.hh>
#include <paludis/metadata_key.hh>
#include <paludis/action.hh>
#include <paludis/repository.hh>
-#include <paludis/package_dep_spec_requirement.hh>
-#include <paludis/contents.hh>
-#include <paludis/version_operator.hh>
+#include <paludis/additional_package_dep_spec_requirement.hh>
#include <paludis/util/set.hh>
#include <paludis/util/options.hh>
@@ -36,15 +36,11 @@
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/util/stringify.hh>
-#include <paludis/util/accept_visitor.hh>
-#include <paludis/util/destringify.hh>
-#include <paludis/util/join.hh>
#include <functional>
#include <algorithm>
#include <istream>
#include <ostream>
-#include <list>
using namespace paludis;
@@ -52,184 +48,169 @@ using namespace paludis;
namespace
{
- struct RequirementChecker
+ struct SlotRequirementChecker
{
- const Environment & env;
- const std::shared_ptr<const PackageID> & id;
- const MatchPackageOptions & options;
-
- bool version_requirements_ok;
- std::list<const ChoiceRequirement *> defer_choice_requirements;
-
- RequirementChecker(
- const Environment & e,
- const std::shared_ptr<const PackageID> & i,
- const MatchPackageOptions & o) :
- env(e),
+ const std::shared_ptr<const PackageID> id;
+ bool result;
+
+ SlotRequirementChecker(const std::shared_ptr<const PackageID> & i) :
id(i),
- options(o),
- version_requirements_ok(true)
+ result(true)
{
}
- bool visit(const NameRequirement & r)
+ void visit(const SlotExactRequirement & s)
{
- return r.name() == id->name();
+ result = id->slot_key() && id->slot_key()->parse_value() == s.slot();
}
- bool visit(const PackageNamePartRequirement & r)
+ void visit(const SlotAnyLockedRequirement &)
{
- return r.name_part() == id->name().package();
+ result = true;
}
- bool visit(const CategoryNamePartRequirement & r)
+ void visit(const SlotAnyUnlockedRequirement &)
{
- return r.name_part() == id->name().category();
+ result = true;
}
+ };
+}
- bool visit(const VersionRequirement & r)
- {
- bool one(r.version_operator().as_version_spec_comparator()(id->version(), r.version_spec()));
-
- switch (r.combiner())
- {
- case vrc_and: version_requirements_ok &= one; break;
- case vrc_or: version_requirements_ok |= one; break;
- case last_vrc: throw InternalError(PALUDIS_HERE, "Bad vrc");
- }
+bool
+paludis::match_package_with_maybe_changes(
+ const Environment & env,
+ const PackageDepSpec & spec,
+ const ChangedChoices * const maybe_changes_to_owner,
+ const std::shared_ptr<const PackageID> & id,
+ const std::shared_ptr<const PackageID> & from_id,
+ const ChangedChoices * const maybe_changes_to_target,
+ const MatchPackageOptions & options)
+{
+ if (spec.package_ptr() && *spec.package_ptr() != id->name())
+ return false;
- return true;
- }
+ if (spec.package_name_part_ptr() && *spec.package_name_part_ptr() != id->name().package())
+ return false;
- bool visit(const InRepositoryRequirement & r)
- {
- return r.name() == id->repository_name();
- }
+ if (spec.category_name_part_ptr() && *spec.category_name_part_ptr() != id->name().category())
+ return false;
- bool visit(const FromRepositoryRequirement & r)
+ if (spec.version_requirements_ptr())
+ switch (spec.version_requirements_mode())
{
- if (! id->from_repositories_key())
- return false;
+ case vr_and:
+ for (VersionRequirements::ConstIterator r(spec.version_requirements_ptr()->begin()),
+ r_end(spec.version_requirements_ptr()->end()) ; r != r_end ; ++r)
+ if (! r->version_operator().as_version_spec_comparator()(id->version(), r->version_spec()))
+ return false;
+ break;
- auto v(id->from_repositories_key()->parse_value());
- return v->end() != v->find(stringify(r.name()));
- }
+ case vr_or:
+ {
+ bool matched(false);
+ for (VersionRequirements::ConstIterator r(spec.version_requirements_ptr()->begin()),
+ r_end(spec.version_requirements_ptr()->end()) ; r != r_end ; ++r)
+ if (r->version_operator().as_version_spec_comparator()(id->version(), r->version_spec()))
+ {
+ matched = true;
+ break;
+ }
+
+ if (! matched)
+ return false;
+ }
+ break;
- bool visit(const InstalledAtPathRequirement & r)
- {
- auto repo(env.fetch_repository(id->repository_name()));
- if (! repo->installed_root_key())
- return false;
- if (repo->installed_root_key()->parse_value() != r.path())
- return false;
- return true;
+ case last_vr:
+ ;
}
- bool visit(const InstallableToRepositoryRequirement & r)
- {
- if (! id->supports_action(SupportsActionTest<InstallAction>()))
- return false;
- if (! r.include_masked())
- if (id->masked())
- return false;
-
- const std::shared_ptr<const Repository> dest(env.fetch_repository(r.name()));
- if (! dest->destination_interface())
- return false;
- if (! dest->destination_interface()->is_suitable_destination_for(id))
- return false;
+ if (spec.in_repository_ptr())
+ if (*spec.in_repository_ptr() != id->repository_name())
+ return false;
- return true;
- }
+ if (spec.from_repository_ptr())
+ {
+ if (! id->from_repositories_key())
+ return false;
- bool visit(const InstallableToPathRequirement & r)
- {
- if (! id->supports_action(SupportsActionTest<InstallAction>()))
- return false;
- if (! r.include_masked())
- if (id->masked())
- return false;
+ auto v(id->from_repositories_key()->parse_value());
+ if (v->end() == v->find(stringify(*spec.from_repository_ptr())))
+ return false;
+ }
- bool ok(false);
- for (auto d(env.begin_repositories()), d_end(env.end_repositories()) ;
- d != d_end ; ++d)
- {
- if (! (*d)->destination_interface())
- continue;
- if (! (*d)->installed_root_key())
- continue;
- if ((*d)->installed_root_key()->parse_value() != r.path())
- continue;
- if (! (*d)->destination_interface()->is_suitable_destination_for(id))
- continue;
-
- ok = true;
- break;
- }
+ if (spec.installed_at_path_ptr())
+ {
+ auto repo(env.fetch_repository(id->repository_name()));
+ if (! repo->installed_root_key())
+ return false;
+ if (repo->installed_root_key()->parse_value() != *spec.installed_at_path_ptr())
+ return false;
+ }
- if (! ok)
+ if (spec.installable_to_repository_ptr())
+ {
+ if (! id->supports_action(SupportsActionTest<InstallAction>()))
+ return false;
+ if (! spec.installable_to_repository_ptr()->include_masked())
+ if (id->masked())
return false;
- return true;
- }
+ const std::shared_ptr<const Repository> dest(env.fetch_repository(
+ spec.installable_to_repository_ptr()->repository()));
+ if (! dest->destination_interface())
+ return false;
+ if (! dest->destination_interface()->is_suitable_destination_for(id))
+ return false;
+ }
- bool visit(const ExactSlotRequirement & r)
- {
- if ((! id->slot_key()) || (id->slot_key()->parse_value() != r.name()))
+ if (spec.installable_to_path_ptr())
+ {
+ if (! id->supports_action(SupportsActionTest<InstallAction>()))
+ return false;
+ if (! spec.installable_to_path_ptr()->include_masked())
+ if (id->masked())
return false;
- return true;
- }
-
- bool visit(const AnySlotRequirement &)
+ bool ok(false);
+ for (auto d(env.begin_repositories()), d_end(env.end_repositories()) ;
+ d != d_end ; ++d)
{
- /* don't care */
- return true;
+ if (! (*d)->destination_interface())
+ continue;
+ if (! (*d)->installed_root_key())
+ continue;
+ if ((*d)->installed_root_key()->parse_value() != spec.installable_to_path_ptr()->path())
+ continue;
+ if (! (*d)->destination_interface()->is_suitable_destination_for(id))
+ continue;
+
+ ok = true;
+ break;
}
- bool visit(const ChoiceRequirement & r)
- {
- if (! options[mpo_ignore_choice_requirements])
- defer_choice_requirements.push_back(&r);
+ if (! ok)
+ return false;
+ }
- return true;
- }
+ if (spec.slot_requirement_ptr())
+ {
+ SlotRequirementChecker v(id);
+ spec.slot_requirement_ptr()->accept(v);
+ if (! v.result)
+ return false;
+ }
- bool visit(const KeyRequirement & r)
+ if (! options[mpo_ignore_additional_requirements])
+ {
+ if (spec.additional_requirements_ptr())
{
- if (! r.matches(&env, id))
- return false;
-
- return true;
+ for (AdditionalPackageDepSpecRequirements::ConstIterator u(spec.additional_requirements_ptr()->begin()),
+ u_end(spec.additional_requirements_ptr()->end()) ; u != u_end ; ++u)
+ if (! (*u)->requirement_met(&env, maybe_changes_to_owner, id, from_id, maybe_changes_to_target).first)
+ return false;
}
- };
-}
-
-bool
-paludis::match_package_with_maybe_changes(
- const Environment & env,
- const PackageDepSpec & spec,
- const ChangedChoices * const maybe_changes_to_owner,
- const std::shared_ptr<const PackageID> & id,
- const std::shared_ptr<const PackageID> & from_id,
- const ChangedChoices * const maybe_changes_to_target,
- const MatchPackageOptions & options)
-{
- RequirementChecker c{env, id, options};
-
- for (auto r(spec.requirements()->begin()), r_end(spec.requirements()->end()) ;
- r != r_end ; ++r)
- if (! (*r)->accept_returning<bool>(c))
- return false;
-
- if (! c.version_requirements_ok)
- return false;
-
-
- for (auto r(c.defer_choice_requirements.begin()), r_end(c.defer_choice_requirements.end()) ;
- r != r_end ; ++r)
- if (! (*r)->requirement_met(&env, maybe_changes_to_owner, id, from_id, maybe_changes_to_target).first)
- return false;
+ }
return true;
}
diff --git a/paludis/match_package.se b/paludis/match_package.se
index 5c449ff..bd6b7e5 100644
--- a/paludis/match_package.se
+++ b/paludis/match_package.se
@@ -6,7 +6,7 @@ make_enum_MatchPackageOption()
prefix mpo
want_destringify
- key mpo_ignore_choice_requirements "Ignore choice requirements"
+ key mpo_ignore_additional_requirements "Ignore additional requirements"
doxygen_comment << "END"
/**
diff --git a/paludis/package_dep_spec_collection.cc b/paludis/package_dep_spec_collection.cc
index c46dc21..280921c 100644
--- a/paludis/package_dep_spec_collection.cc
+++ b/paludis/package_dep_spec_collection.cc
@@ -22,7 +22,6 @@
#include <paludis/package_id.hh>
#include <paludis/dep_spec.hh>
#include <paludis/match_package.hh>
-#include <paludis/package_dep_spec_requirement.hh>
#include <list>
#include <map>
@@ -54,8 +53,8 @@ PackageDepSpecCollection::~PackageDepSpecCollection() = default;
void
PackageDepSpecCollection::insert(const PackageDepSpec & spec)
{
- if (spec.package_name_requirement())
- _imp->by_name.insert(std::make_pair(spec.package_name_requirement()->name(), spec));
+ if (spec.package_ptr())
+ _imp->by_name.insert(std::make_pair(*spec.package_ptr(), spec));
else
_imp->unnamed.push_back(spec);
}
diff --git a/paludis/package_dep_spec_properties.cc b/paludis/package_dep_spec_properties.cc
index 8fb4670..75a1efc 100644
--- a/paludis/package_dep_spec_properties.cc
+++ b/paludis/package_dep_spec_properties.cc
@@ -19,174 +19,40 @@
#include <paludis/package_dep_spec_properties.hh>
#include <paludis/dep_spec.hh>
-#include <paludis/package_dep_spec_requirement.hh>
-
#include <paludis/util/sequence.hh>
using namespace paludis;
namespace
{
- struct Finder
+ inline bool check(const bool c, const Tribool w)
{
- bool has_any_slot_requirement;
- bool has_category_name_part;
- bool has_choice_requirements;
- bool has_from_repository;
- bool has_in_repository;
- bool has_installable_to_path;
- bool has_installable_to_repository;
- bool has_installed_at_path;
- bool has_key_requirements;
- bool has_package_name_part;
- bool has_tag;
- bool has_version_requirements;
-
- Finder() :
- has_any_slot_requirement(false),
- has_category_name_part(false),
- has_choice_requirements(false),
- has_from_repository(false),
- has_in_repository(false),
- has_installable_to_path(false),
- has_installable_to_repository(false),
- has_installed_at_path(false),
- has_key_requirements(false),
- has_package_name_part(false),
- has_tag(false),
- has_version_requirements(false)
- {
- }
-
- void visit(const NameRequirement &)
- {
- }
-
- void visit(const PackageNamePartRequirement &)
- {
- has_package_name_part = true;
- }
-
- void visit(const CategoryNamePartRequirement &)
- {
- has_category_name_part = true;
- }
-
- void visit(const VersionRequirement &)
- {
- has_version_requirements = true;
- }
-
- void visit(const InRepositoryRequirement &)
- {
- has_in_repository = true;
- }
-
- void visit(const FromRepositoryRequirement &)
- {
- has_from_repository = true;
- }
-
- void visit(const InstalledAtPathRequirement &)
- {
- has_installed_at_path = true;
- }
-
- void visit(const InstallableToRepositoryRequirement &)
- {
- has_installable_to_repository = true;
- }
-
- void visit(const InstallableToPathRequirement &)
- {
- has_installable_to_path = true;
- }
-
- void visit(const ExactSlotRequirement &)
- {
- }
-
- void visit(const AnySlotRequirement &)
- {
- has_any_slot_requirement = true;
- }
-
- void visit(const ChoiceRequirement &)
- {
- has_choice_requirements = true;
- }
-
- void visit(const KeyRequirement &)
- {
- has_key_requirements = true;
- }
- };
+ if (w.is_true())
+ return c;
+ else if (w.is_false())
+ return ! c;
+ else
+ return true;
+ }
}
bool
paludis::package_dep_spec_has_properties(const PackageDepSpec & spec, const PackageDepSpecProperties & properties)
{
- if (! properties.has_package().is_indeterminate())
- if (properties.has_package().is_true() != bool(spec.package_name_requirement()))
- return false;
-
- if (! properties.has_exact_slot_requirement().is_indeterminate())
- if (properties.has_exact_slot_requirement().is_true() != bool(spec.exact_slot_requirement()))
- return false;
-
- Finder f;
- for (auto r(spec.requirements()->begin()), r_end(spec.requirements()->end()) ;
- r != r_end ; ++r)
- (*r)->accept(f);
-
- if (! properties.has_any_slot_requirement().is_indeterminate())
- if (properties.has_any_slot_requirement().is_true() != f.has_any_slot_requirement)
- return false;
-
- if (! properties.has_category_name_part().is_indeterminate())
- if (properties.has_category_name_part().is_true() != f.has_category_name_part)
- return false;
-
- if (! properties.has_choice_requirements().is_indeterminate())
- if (properties.has_choice_requirements().is_true() != f.has_choice_requirements)
- return false;
-
- if (! properties.has_from_repository().is_indeterminate())
- if (properties.has_from_repository().is_true() != f.has_from_repository)
- return false;
-
- if (! properties.has_in_repository().is_indeterminate())
- if (properties.has_in_repository().is_true() != f.has_in_repository)
- return false;
-
- if (! properties.has_installable_to_path().is_indeterminate())
- if (properties.has_installable_to_path().is_true() != f.has_installable_to_path)
- return false;
-
- if (! properties.has_installable_to_repository().is_indeterminate())
- if (properties.has_installable_to_repository().is_true() != f.has_installable_to_repository)
- return false;
-
- if (! properties.has_installed_at_path().is_indeterminate())
- if (properties.has_installed_at_path().is_true() != f.has_installed_at_path)
- return false;
-
- if (! properties.has_key_requirements().is_indeterminate())
- if (properties.has_key_requirements().is_true() != f.has_key_requirements)
- return false;
-
- if (! properties.has_package_name_part().is_indeterminate())
- if (properties.has_package_name_part().is_true() != f.has_package_name_part)
- return false;
-
- if (! properties.has_tag().is_indeterminate())
- if (properties.has_tag().is_true() != f.has_tag)
- return false;
-
- if (! properties.has_version_requirements().is_indeterminate())
- if (properties.has_version_requirements().is_true() != f.has_version_requirements)
- return false;
-
- return true;
+ bool result(true);
+
+ result = result && check(bool(spec.additional_requirements_ptr()) && ! spec.additional_requirements_ptr()->empty(), properties.has_additional_requirements());
+ result = result && check(bool(spec.category_name_part_ptr()), properties.has_category_name_part());
+ result = result && check(bool(spec.from_repository_ptr()), properties.has_from_repository());
+ result = result && check(bool(spec.in_repository_ptr()), properties.has_in_repository());
+ result = result && check(bool(spec.installable_to_path_ptr()), properties.has_installable_to_path());
+ result = result && check(bool(spec.installable_to_repository_ptr()), properties.has_installable_to_repository());
+ result = result && check(bool(spec.installed_at_path_ptr()), properties.has_installed_at_path());
+ result = result && check(bool(spec.package_ptr()), properties.has_package());
+ result = result && check(bool(spec.package_name_part_ptr()), properties.has_package_name_part());
+ result = result && check(bool(spec.slot_requirement_ptr()), properties.has_slot_requirement());
+ result = result && check(spec.version_requirements_ptr() && ! spec.version_requirements_ptr()->empty(), properties.has_version_requirements());
+
+ return result;
}
diff --git a/paludis/package_dep_spec_properties.hh b/paludis/package_dep_spec_properties.hh
index bb0991d..45ed0fa 100644
--- a/paludis/package_dep_spec_properties.hh
+++ b/paludis/package_dep_spec_properties.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009, 2010, 2011 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 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,8 +21,6 @@
#define PALUDIS_GUARD_PALUDIS_PACKAGE_DEP_SPEC_PROPERTIES_HH 1
#include <paludis/package_dep_spec_properties-fwd.hh>
-#include <paludis/package_dep_spec_requirement-fwd.hh>
-
#include <paludis/util/named_value.hh>
#include <paludis/util/tribool.hh>
@@ -30,18 +28,16 @@ namespace paludis
{
namespace n
{
- typedef Name<struct name_has_any_slot_requirement> has_any_slot_requirement;
+ typedef Name<struct name_has_additional_requirements> has_additional_requirements;
typedef Name<struct name_has_category_name_part> has_category_name_part;
- typedef Name<struct name_has_choice_requirements> has_choice_requirements;
- typedef Name<struct name_has_exact_slot_requirement> has_exact_slot_requirement;
typedef Name<struct name_has_from_repository> has_from_repository;
typedef Name<struct name_has_in_repository> has_in_repository;
typedef Name<struct name_has_installable_to_path> has_installable_to_path;
typedef Name<struct name_has_installable_to_repository> has_installable_to_repository;
typedef Name<struct name_has_installed_at_path> has_installed_at_path;
- typedef Name<struct name_has_key_requirements> has_key_requirements;
typedef Name<struct name_has_package> has_package;
typedef Name<struct name_has_package_name_part> has_package_name_part;
+ typedef Name<struct name_has_slot_requirement> has_slot_requirement;
typedef Name<struct name_has_tag> has_tag;
typedef Name<struct name_has_version_requirements> has_version_requirements;
}
@@ -54,35 +50,19 @@ namespace paludis
*/
struct PackageDepSpecProperties
{
- NamedValue<n::has_any_slot_requirement, Tribool> has_any_slot_requirement;
+ NamedValue<n::has_additional_requirements, Tribool> has_additional_requirements;
NamedValue<n::has_category_name_part, Tribool> has_category_name_part;
- NamedValue<n::has_choice_requirements, Tribool> has_choice_requirements;
- NamedValue<n::has_exact_slot_requirement, Tribool> has_exact_slot_requirement;
NamedValue<n::has_from_repository, Tribool> has_from_repository;
NamedValue<n::has_in_repository, Tribool> has_in_repository;
NamedValue<n::has_installable_to_path, Tribool> has_installable_to_path;
NamedValue<n::has_installable_to_repository, Tribool> has_installable_to_repository;
NamedValue<n::has_installed_at_path, Tribool> has_installed_at_path;
- NamedValue<n::has_key_requirements, Tribool> has_key_requirements;
NamedValue<n::has_package, Tribool> has_package;
NamedValue<n::has_package_name_part, Tribool> has_package_name_part;
+ NamedValue<n::has_slot_requirement, Tribool> has_slot_requirement;
NamedValue<n::has_tag, Tribool> has_tag;
NamedValue<n::has_version_requirements, Tribool> has_version_requirements;
};
-
- template <typename T_>
- struct DetectPackageDepSpecRequirement
- {
- bool visit(const T_ &) const
- {
- return true;
- }
-
- bool visit(const PackageDepSpecRequirement &) const
- {
- return false;
- }
- };
}
#endif
diff --git a/paludis/package_dep_spec_requirement-fwd.hh b/paludis/package_dep_spec_requirement-fwd.hh
deleted file mode 100644
index 4442d2f..0000000
--- a/paludis/package_dep_spec_requirement-fwd.hh
+++ /dev/null
@@ -1,82 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2011 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_PACKAGE_DEP_SPEC_REQUIREMENT_FWD_HH
-#define PALUDIS_GUARD_PALUDIS_PACKAGE_DEP_SPEC_REQUIREMENT_FWD_HH 1
-
-#include <paludis/util/pool-fwd.hh>
-#include <paludis/util/attributes.hh>
-#include <paludis/util/sequence-fwd.hh>
-#include <iosfwd>
-#include <memory>
-
-namespace paludis
-{
- class PackageDepSpecRequirement;
-
- typedef Sequence<std::shared_ptr<const PackageDepSpecRequirement> > PackageDepSpecRequirementSequence;
-
- class NameRequirement;
- typedef Pool<NameRequirement> NameRequirementPool;
-
- class PackageNamePartRequirement;
- typedef Pool<PackageNamePartRequirement> PackageNamePartRequirementPool;
-
- class CategoryNamePartRequirement;
- typedef Pool<CategoryNamePartRequirement> CategoryNamePartRequirementPool;
-
- class VersionRequirement;
-
- typedef Sequence<std::shared_ptr<const VersionRequirement> > VersionRequirementSequence;
-
- class InRepositoryRequirement;
- typedef Pool<InRepositoryRequirement> InRepositoryRequirementPool;
-
- class FromRepositoryRequirement;
- typedef Pool<FromRepositoryRequirement> FromRepositoryRequirementPool;
-
- class InstalledAtPathRequirement;
- typedef Pool<InstalledAtPathRequirement> InstalledAtPathRequirementPool;
-
- class InstallableToPathRequirement;
- typedef Pool<InstallableToPathRequirement> InstallableToPathRequirementPool;
-
- class InstallableToRepositoryRequirement;
- typedef Pool<InstallableToRepositoryRequirement> InstallableToRepositoryRequirementPool;
-
- class ExactSlotRequirement;
- typedef Pool<ExactSlotRequirement> ExactSlotRequirementPool;
-
- class AnySlotRequirement;
- typedef Pool<AnySlotRequirement> AnySlotRequirementPool;
-
- class KeyRequirement;
- typedef Pool<KeyRequirement> KeyRequirementPool;
-
- typedef Sequence<std::shared_ptr<const KeyRequirement> > KeyRequirementSequence;
-
- class ChoiceRequirement;
-
- typedef Sequence<std::shared_ptr<const ChoiceRequirement> > ChoiceRequirementSequence;
-
-#include <paludis/package_dep_spec_requirement-se.hh>
-
-}
-
-#endif
diff --git a/paludis/package_dep_spec_requirement.cc b/paludis/package_dep_spec_requirement.cc
deleted file mode 100644
index cdf2b7a..0000000
--- a/paludis/package_dep_spec_requirement.cc
+++ /dev/null
@@ -1,1156 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2011 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/package_dep_spec_requirement.hh>
-#include <paludis/version_spec.hh>
-#include <paludis/version_operator.hh>
-#include <paludis/contents.hh>
-#include <paludis/metadata_key.hh>
-#include <paludis/package_id.hh>
-#include <paludis/dep_spec.hh>
-#include <paludis/environment.hh>
-#include <paludis/repository.hh>
-#include <paludis/mask.hh>
-
-#include <paludis/util/pool-impl.hh>
-#include <paludis/util/pimp-impl.hh>
-#include <paludis/util/singleton-impl.hh>
-#include <paludis/util/stringify.hh>
-#include <paludis/util/exception.hh>
-#include <paludis/util/sequence-impl.hh>
-#include <paludis/util/set-impl.hh>
-#include <paludis/util/wrapped_forward_iterator-impl.hh>
-#include <paludis/util/wrapped_output_iterator-impl.hh>
-#include <paludis/util/pimp-impl.hh>
-#include <paludis/util/indirect_iterator-impl.hh>
-#include <paludis/util/accept_visitor.hh>
-#include <paludis/util/timestamp.hh>
-#include <paludis/util/destringify.hh>
-#include <paludis/util/join.hh>
-
-#include <istream>
-#include <ostream>
-#include <algorithm>
-
-using namespace paludis;
-
-#include <paludis/package_dep_spec_requirement-se.cc>
-
-PackageDepSpecRequirement::~PackageDepSpecRequirement() = default;
-
-template class Sequence<std::shared_ptr<const PackageDepSpecRequirement> >;
-template class WrappedForwardIterator<Sequence<std::shared_ptr<const PackageDepSpecRequirement> >::ConstIteratorTag, const std::shared_ptr<const PackageDepSpecRequirement> >;
-template class WrappedOutputIterator<Sequence<std::shared_ptr<const PackageDepSpecRequirement> >::InserterTag, std::shared_ptr<const PackageDepSpecRequirement> >;
-
-NameRequirement::NameRequirement(const QualifiedPackageName & n) :
- _name(n)
-{
-}
-
-NameRequirement::~NameRequirement() = default;
-
-const QualifiedPackageName
-NameRequirement::name() const
-{
- return _name;
-}
-
-template class Pool<NameRequirement>;
-template class Singleton<Pool<NameRequirement> >;
-template const std::shared_ptr<const NameRequirement> Pool<NameRequirement>::create(
- const QualifiedPackageName &) const;
-
-CategoryNamePartRequirement::CategoryNamePartRequirement(const CategoryNamePart & n) :
- _name_part(n)
-{
-}
-
-CategoryNamePartRequirement::~CategoryNamePartRequirement() = default;
-
-const CategoryNamePart
-CategoryNamePartRequirement::name_part() const
-{
- return _name_part;
-}
-
-template class Pool<CategoryNamePartRequirement>;
-template class Singleton<Pool<CategoryNamePartRequirement> >;
-template const std::shared_ptr<const CategoryNamePartRequirement> Pool<CategoryNamePartRequirement>::create(
- const CategoryNamePart &) const;
-
-PackageNamePartRequirement::PackageNamePartRequirement(const PackageNamePart & n) :
- _name_part(n)
-{
-}
-
-PackageNamePartRequirement::~PackageNamePartRequirement() = default;
-
-const PackageNamePart
-PackageNamePartRequirement::name_part() const
-{
- return _name_part;
-}
-
-template class Pool<PackageNamePartRequirement>;
-template class Singleton<Pool<PackageNamePartRequirement> >;
-template const std::shared_ptr<const PackageNamePartRequirement> Pool<PackageNamePartRequirement>::create(
- const PackageNamePart &) const;
-
-namespace paludis
-{
- template <>
- struct Imp<VersionRequirement>
- {
- VersionSpec spec;
- VersionOperator op;
- VersionRequirementCombiner combiner;
-
- Imp(const VersionSpec & s, const VersionOperator & o, const VersionRequirementCombiner c) :
- spec(s),
- op(o),
- combiner(c)
- {
- }
- };
-}
-
-VersionRequirement::VersionRequirement(const VersionSpec & s, const VersionOperator & o, const VersionRequirementCombiner c) :
- _imp(s, o, c)
-{
-}
-
-VersionRequirement::~VersionRequirement() = default;
-
-const VersionSpec
-VersionRequirement::version_spec() const
-{
- return _imp->spec;
-}
-
-const VersionOperator
-VersionRequirement::version_operator() const
-{
- return _imp->op;
-}
-
-VersionRequirementCombiner
-VersionRequirement::combiner() const
-{
- return _imp->combiner;
-}
-
-template class Sequence<std::shared_ptr<const VersionRequirement> >;
-template class WrappedForwardIterator<Sequence<std::shared_ptr<const VersionRequirement> >::ConstIteratorTag, const std::shared_ptr<const VersionRequirement> >;
-template class WrappedOutputIterator<Sequence<std::shared_ptr<const VersionRequirement> >::InserterTag, std::shared_ptr<const VersionRequirement> >;
-template class Pimp<VersionRequirement>;
-
-InRepositoryRequirement::InRepositoryRequirement(const RepositoryName & n) :
- _name(n)
-{
-}
-
-InRepositoryRequirement::~InRepositoryRequirement() = default;
-
-const RepositoryName
-InRepositoryRequirement::name() const
-{
- return _name;
-}
-
-template class Pool<InRepositoryRequirement>;
-template class Singleton<Pool<InRepositoryRequirement> >;
-template const std::shared_ptr<const InRepositoryRequirement> Pool<InRepositoryRequirement>::create(
- const RepositoryName &) const;
-
-FromRepositoryRequirement::FromRepositoryRequirement(const RepositoryName & n) :
- _name(n)
-{
-}
-
-FromRepositoryRequirement::~FromRepositoryRequirement() = default;
-
-const RepositoryName
-FromRepositoryRequirement::name() const
-{
- return _name;
-}
-
-template class Pool<FromRepositoryRequirement>;
-template class Singleton<Pool<FromRepositoryRequirement> >;
-template const std::shared_ptr<const FromRepositoryRequirement> Pool<FromRepositoryRequirement>::create(
- const RepositoryName &) const;
-
-InstalledAtPathRequirement::InstalledAtPathRequirement(const FSPath & n) :
- _path(n)
-{
-}
-
-InstalledAtPathRequirement::~InstalledAtPathRequirement() = default;
-
-const FSPath
-InstalledAtPathRequirement::path() const
-{
- return _path;
-}
-
-template class Pool<InstalledAtPathRequirement>;
-template class Singleton<Pool<InstalledAtPathRequirement> >;
-template const std::shared_ptr<const InstalledAtPathRequirement> Pool<InstalledAtPathRequirement>::create(
- const FSPath &) const;
-
-InstallableToPathRequirement::InstallableToPathRequirement(const FSPath & n, const bool i) :
- _path(n),
- _include_masked(i)
-{
-}
-
-InstallableToPathRequirement::~InstallableToPathRequirement() = default;
-
-const FSPath
-InstallableToPathRequirement::path() const
-{
- return _path;
-}
-
-bool
-InstallableToPathRequirement::include_masked() const
-{
- return _include_masked;
-}
-
-template class Pool<InstallableToPathRequirement>;
-template class Singleton<Pool<InstallableToPathRequirement> >;
-template const std::shared_ptr<const InstallableToPathRequirement> Pool<InstallableToPathRequirement>::create(
- const FSPath &, const bool &) const;
-
-InstallableToRepositoryRequirement::InstallableToRepositoryRequirement(const RepositoryName & n, const bool i) :
- _name(n),
- _include_masked(i)
-{
-}
-
-InstallableToRepositoryRequirement::~InstallableToRepositoryRequirement() = default;
-
-const RepositoryName
-InstallableToRepositoryRequirement::name() const
-{
- return _name;
-}
-
-bool
-InstallableToRepositoryRequirement::include_masked() const
-{
- return _include_masked;
-}
-
-template class Pool<InstallableToRepositoryRequirement>;
-template class Singleton<Pool<InstallableToRepositoryRequirement> >;
-template const std::shared_ptr<const InstallableToRepositoryRequirement> Pool<InstallableToRepositoryRequirement>::create(
- const RepositoryName &, const bool &) const;
-
-ExactSlotRequirement::ExactSlotRequirement(const SlotName & n, const bool i) :
- _name(n),
- _locked(i)
-{
-}
-
-ExactSlotRequirement::~ExactSlotRequirement() = default;
-
-const SlotName
-ExactSlotRequirement::name() const
-{
- return _name;
-}
-
-bool
-ExactSlotRequirement::locked() const
-{
- return _locked;
-}
-
-template class Pool<ExactSlotRequirement>;
-template class Singleton<Pool<ExactSlotRequirement> >;
-template const std::shared_ptr<const ExactSlotRequirement> Pool<ExactSlotRequirement>::create(const SlotName &, const bool &) const;
-
-AnySlotRequirement::AnySlotRequirement(const bool i) :
- _locking(i)
-{
-}
-
-AnySlotRequirement::~AnySlotRequirement() = default;
-
-bool
-AnySlotRequirement::locking() const
-{
- return _locking;
-}
-
-template class Pool<AnySlotRequirement>;
-template class Singleton<Pool<AnySlotRequirement> >;
-template const std::shared_ptr<const AnySlotRequirement> Pool<AnySlotRequirement>::create(const bool &) const;
-
-KeyRequirement::KeyRequirement(const KeyRequirementKeyType t, const std::string & k, const KeyRequirementOperation o, const std::string & p) :
- _key_type(t),
- _key(k),
- _operation(o),
- _pattern(p)
-{
-}
-
-KeyRequirement::~KeyRequirement() = default;
-
-KeyRequirementKeyType
-KeyRequirement::key_type() const
-{
- return _key_type;
-}
-
-const std::string
-KeyRequirement::key() const
-{
- return _key;
-}
-
-KeyRequirementOperation
-KeyRequirement::operation() const
-{
- return _operation;
-}
-
-const std::string
-KeyRequirement::pattern() const
-{
- return _pattern;
-}
-
-namespace
-{
- std::string stringify_contents_entry(const ContentsEntry & e)
- {
- return stringify(e.location_key()->parse_value());
- }
-
- struct StringifyEqual
- {
- const std::string pattern;
-
- StringifyEqual(const std::string & p) :
- pattern(p)
- {
- }
-
- template <typename T_>
- bool operator() (const T_ & t) const
- {
- return stringify(t) == pattern;
- }
-
- bool operator() (const ContentsEntry & e) const
- {
- return stringify_contents_entry(e) == pattern;
- }
- };
-
- struct SpecTreeSearcher
- {
- const Environment * const env;
- const std::shared_ptr<const PackageID> id;
- const std::string pattern;
-
- SpecTreeSearcher(const Environment * const e, const std::shared_ptr<const PackageID> & i, const std::string & p) :
- env(e),
- id(i),
- pattern(p)
- {
- }
-
- bool visit(const GenericSpecTree::NodeType<AllDepSpec>::Type & n) const
- {
- return indirect_iterator(n.end()) != std::find_if(indirect_iterator(n.begin()), indirect_iterator(n.end()),
- accept_visitor_returning<bool>(*this));
- }
-
- bool visit(const GenericSpecTree::NodeType<AnyDepSpec>::Type & n) const
- {
- return indirect_iterator(n.end()) != std::find_if(indirect_iterator(n.begin()), indirect_iterator(n.end()),
- accept_visitor_returning<bool>(*this));
- }
-
- bool visit(const GenericSpecTree::NodeType<ExactlyOneDepSpec>::Type & n) const
- {
- return indirect_iterator(n.end()) != std::find_if(indirect_iterator(n.begin()), indirect_iterator(n.end()),
- accept_visitor_returning<bool>(*this));
- }
-
- bool visit(const GenericSpecTree::NodeType<ConditionalDepSpec>::Type & n) const
- {
- if (n.spec()->condition_met(env, id))
- return indirect_iterator(n.end()) != std::find_if(indirect_iterator(n.begin()), indirect_iterator(n.end()),
- accept_visitor_returning<bool>(*this));
- else
- return false;
- }
-
- bool visit(const GenericSpecTree::NodeType<NamedSetDepSpec>::Type & n) const
- {
- return stringify(*n.spec()) == pattern;
- }
-
- bool visit(const GenericSpecTree::NodeType<PlainTextDepSpec>::Type & n) const
- {
- return stringify(*n.spec()) == pattern;
- }
-
- bool visit(const GenericSpecTree::NodeType<PackageDepSpec>::Type & n) const
- {
- return stringify(*n.spec()) == pattern;
- }
-
- bool visit(const GenericSpecTree::NodeType<BlockDepSpec>::Type & n) const
- {
- return stringify(*n.spec()) == pattern;
- }
-
- bool visit(const GenericSpecTree::NodeType<LicenseDepSpec>::Type & n) const
- {
- return stringify(*n.spec()) == pattern;
- }
-
- bool visit(const GenericSpecTree::NodeType<SimpleURIDepSpec>::Type & n) const
- {
- return stringify(*n.spec()) == pattern;
- }
-
- bool visit(const GenericSpecTree::NodeType<FetchableURIDepSpec>::Type & n) const
- {
- return stringify(*n.spec()) == pattern;
- }
-
- bool visit(const GenericSpecTree::NodeType<DependenciesLabelsDepSpec>::Type & n) const
- {
- return indirect_iterator(n.spec()->end()) != std::find_if(indirect_iterator(n.spec()->begin()),
- indirect_iterator(n.spec()->end()), StringifyEqual(pattern));
- }
-
- bool visit(const GenericSpecTree::NodeType<URILabelsDepSpec>::Type & n) const
- {
- return indirect_iterator(n.spec()->end()) != std::find_if(indirect_iterator(n.spec()->begin()),
- indirect_iterator(n.spec()->end()), StringifyEqual(pattern));
- }
-
- bool visit(const GenericSpecTree::NodeType<PlainTextLabelDepSpec>::Type & n) const
- {
- return stringify(*n.spec()) == pattern;
- }
- };
-
- struct KeyComparator
- {
- const Environment * const env;
- const std::shared_ptr<const PackageID> id;
- const std::string pattern;
- const KeyRequirementOperation op;
-
- KeyComparator(const Environment * const e, const std::shared_ptr<const PackageID> & i,
- const std::string & p, const KeyRequirementOperation o) :
- env(e),
- id(i),
- pattern(p),
- op(o)
- {
- }
-
- bool visit(const MetadataSectionKey &) const
- {
- return false;
- }
-
- bool visit(const MetadataTimeKey & k) const
- {
- switch (op)
- {
- case kro_equals:
- return pattern == stringify(k.parse_value().seconds());
- case kro_tilde:
- return std::string::npos != stringify(k.parse_value().seconds()).find(pattern);
- case kro_less_than:
- return k.parse_value().seconds() < destringify<time_t>(pattern);
- case kro_greater_than:
- return k.parse_value().seconds() > destringify<time_t>(pattern);
- case kro_question:
- case last_kro:
- break;
- }
-
- return false;
- }
-
- bool visit(const MetadataValueKey<std::string> & k) const
- {
- switch (op)
- {
- case kro_equals:
- return pattern == stringify(k.parse_value());
- case kro_tilde:
- return std::string::npos != stringify(k.parse_value()).find(pattern);
- case kro_less_than:
- case kro_greater_than:
- case kro_question:
- case last_kro:
- break;
- }
-
- return false;
- }
-
- bool visit(const MetadataValueKey<SlotName> & k) const
- {
- switch (op)
- {
- case kro_equals:
- return pattern == stringify(k.parse_value());
- case kro_tilde:
- return std::string::npos != stringify(k.parse_value()).find(pattern);
- case kro_less_than:
- case kro_greater_than:
- case kro_question:
- case last_kro:
- break;
- }
-
- return false;
- }
-
- bool visit(const MetadataValueKey<FSPath> & k) const
- {
- switch (op)
- {
- case kro_equals:
- return pattern == stringify(k.parse_value());
- case kro_tilde:
- return std::string::npos != stringify(k.parse_value()).find(pattern);
- case kro_less_than:
- case kro_greater_than:
- case kro_question:
- case last_kro:
- break;
- }
-
- return false;
- }
-
- bool visit(const MetadataValueKey<bool> & k) const
- {
- switch (op)
- {
- case kro_equals:
- return pattern == stringify(k.parse_value());
- case kro_tilde:
- return std::string::npos != stringify(k.parse_value()).find(pattern);
- case kro_less_than:
- case kro_greater_than:
- case kro_question:
- case last_kro:
- break;
- }
-
- return false;
- }
-
- bool visit(const MetadataValueKey<long> & k) const
- {
- switch (op)
- {
- case kro_equals:
- return pattern == stringify(k.parse_value());
- case kro_tilde:
- return std::string::npos != stringify(k.parse_value()).find(pattern);
- case kro_less_than:
- return k.parse_value() < destringify<long>(pattern);
- case kro_greater_than:
- return k.parse_value() > destringify<long>(pattern);
- case kro_question:
- case last_kro:
- break;
- }
-
- return false;
- }
-
- bool visit(const MetadataValueKey<std::shared_ptr<const Choices> > &) const
- {
- return false;
- }
-
- bool visit(const MetadataValueKey<std::shared_ptr<const Contents> > & s) const
- {
- auto v(s.parse_value());
- switch (op)
- {
- case kro_equals:
- return pattern == join(indirect_iterator(v->begin()), indirect_iterator(v->end()), " ",
- stringify_contents_entry);
- case kro_less_than:
- return indirect_iterator(v->end()) != std::find_if(
- indirect_iterator(v->begin()),
- indirect_iterator(v->end()),
- StringifyEqual(pattern));
-
- case kro_greater_than:
- case kro_question:
- case kro_tilde:
- case last_kro:
- break;
- }
-
- return false;
- }
-
- bool visit(const MetadataValueKey<std::shared_ptr<const PackageID> > & k) const
- {
- switch (op)
- {
- case kro_equals:
- return pattern == stringify(*k.parse_value());
- case kro_tilde:
- return std::string::npos != stringify(*k.parse_value()).find(pattern);
- case kro_less_than:
- case kro_greater_than:
- case kro_question:
- case last_kro:
- break;
- }
-
- return false;
- }
-
- bool visit(const MetadataSpecTreeKey<DependencySpecTree> & s) const
- {
- switch (op)
- {
- case kro_equals:
- return false;
- case kro_less_than:
- return s.parse_value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
-
- case kro_tilde:
- case kro_greater_than:
- case kro_question:
- case last_kro:
- break;
- }
-
- return false;
- }
-
- bool visit(const MetadataSpecTreeKey<SetSpecTree> & s) const
- {
- switch (op)
- {
- case kro_equals:
- return false;
- case kro_less_than:
- return s.parse_value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
-
- case kro_tilde:
- case kro_greater_than:
- case kro_question:
- case last_kro:
- break;
- }
-
- return false;
- }
-
- bool visit(const MetadataSpecTreeKey<PlainTextSpecTree> & s) const
- {
- switch (op)
- {
- case kro_equals:
- return false;
- case kro_less_than:
- return s.parse_value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
-
- case kro_tilde:
- case kro_greater_than:
- case kro_question:
- case last_kro:
- break;
- }
-
- return false;
- }
-
- bool visit(const MetadataSpecTreeKey<RequiredUseSpecTree> & s) const
- {
- switch (op)
- {
- case kro_equals:
- return false;
- case kro_less_than:
- return s.parse_value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
-
- case kro_tilde:
- case kro_greater_than:
- case kro_question:
- case last_kro:
- break;
- }
-
- return false;
- }
-
- bool visit(const MetadataSpecTreeKey<ProvideSpecTree> & s) const
- {
- switch (op)
- {
- case kro_equals:
- return false;
- case kro_less_than:
- return s.parse_value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
-
- case kro_tilde:
- case kro_greater_than:
- case kro_question:
- case last_kro:
- break;
- }
-
- return false;
- }
-
- bool visit(const MetadataSpecTreeKey<SimpleURISpecTree> & s) const
- {
- switch (op)
- {
- case kro_equals:
- return false;
- case kro_less_than:
- return s.parse_value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
-
- case kro_tilde:
- case kro_greater_than:
- case kro_question:
- case last_kro:
- break;
- }
-
- return false;
- }
-
- bool visit(const MetadataSpecTreeKey<FetchableURISpecTree> & s) const
- {
- switch (op)
- {
- case kro_equals:
- return false;
- case kro_less_than:
- return s.parse_value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
-
- case kro_tilde:
- case kro_greater_than:
- case kro_question:
- case last_kro:
- break;
- }
-
- return false;
- }
-
- bool visit(const MetadataSpecTreeKey<LicenseSpecTree> & s) const
- {
- switch (op)
- {
- case kro_equals:
- return false;
- case kro_less_than:
- return s.parse_value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
-
- case kro_tilde:
- case kro_greater_than:
- case kro_question:
- case last_kro:
- break;
- }
-
- return false;
- }
-
- bool visit(const MetadataCollectionKey<FSPathSequence> & s) const
- {
- auto v(s.parse_value());
- switch (op)
- {
- case kro_equals:
- return pattern == join(v->begin(), v->end(), " ");
- case kro_less_than:
- return v->end() != std::find_if(v->begin(), v->end(), StringifyEqual(pattern));
-
- case kro_tilde:
- case kro_greater_than:
- case kro_question:
- case last_kro:
- break;
- }
-
- return false;
- }
-
- bool visit(const MetadataCollectionKey<PackageIDSequence> & s) const
- {
- auto v(s.parse_value());
- switch (op)
- {
- case kro_equals:
- return pattern == join(indirect_iterator(v->begin()), indirect_iterator(v->end()), " ");
- case kro_less_than:
- return indirect_iterator(v->end()) != std::find_if(
- indirect_iterator(v->begin()),
- indirect_iterator(v->end()),
- StringifyEqual(pattern));
-
- case kro_tilde:
- case kro_greater_than:
- case kro_question:
- case last_kro:
- break;
- }
-
- return false;
- }
-
- bool visit(const MetadataCollectionKey<Sequence<std::string> > & s) const
- {
- auto v(s.parse_value());
- switch (op)
- {
- case kro_equals:
- return pattern == join(v->begin(), v->end(), " ");
- case kro_less_than:
- return v->end() != std::find_if(v->begin(), v->end(), StringifyEqual(pattern));
-
- case kro_tilde:
- case kro_greater_than:
- case kro_question:
- case last_kro:
- break;
- }
-
- return false;
- }
-
- bool visit(const MetadataCollectionKey<Set<std::string> > & s) const
- {
- auto v(s.parse_value());
- switch (op)
- {
- case kro_equals:
- return pattern == join(v->begin(), v->end(), " ");
- case kro_less_than:
- return v->end() != std::find_if(v->begin(), v->end(), StringifyEqual(pattern));
-
- case kro_tilde:
- case kro_greater_than:
- case kro_question:
- case last_kro:
- break;
- }
-
- return false;
- }
-
- bool visit(const MetadataCollectionKey<Map<std::string, std::string> > &) const
- {
- return false;
- }
-
- bool visit(const MetadataCollectionKey<KeywordNameSet> & s) const
- {
- auto v(s.parse_value());
- switch (op)
- {
- case kro_equals:
- return pattern == join(v->begin(), v->end(), " ");
- case kro_less_than:
- return v->end() != std::find_if(v->begin(), v->end(), StringifyEqual(pattern));
-
- case kro_tilde:
- case kro_greater_than:
- case kro_question:
- case last_kro:
- break;
- }
-
- return false;
- }
- };
-
- struct AssociatedKeyFinder
- {
- const Environment * const env;
- const std::shared_ptr<const PackageID> id;
-
- const MetadataKey * const visit(const UserMask &) const
- {
- return 0;
- }
-
- const MetadataKey * const visit(const UnacceptedMask & m) const
- {
- auto k(id->find_metadata(m.unaccepted_key_name()));
- if (k != id->end_metadata())
- return &**k;
- else
- return 0;
- }
-
- const MetadataKey * const visit(const RepositoryMask &) const
- {
- return 0;
- }
-
- const MetadataKey * const visit(const UnsupportedMask &) const
- {
- return 0;
- }
-
- const MetadataKey * const visit(const AssociationMask &) const
- {
- return 0;
- }
- };
-
- struct MaskChecker
- {
- const std::string key;
-
- bool visit(const UserMask & m) const
- {
- return key == "*" || key == "user" || m.token() == key;
- }
-
- bool visit(const UnacceptedMask & m) const
- {
- return key == "*" || key == "unaccepted" || m.unaccepted_key_name() == key;
- }
-
- bool visit(const RepositoryMask & m) const
- {
- return key == "*" || key == "repository" || m.token() == key;
- }
-
- bool visit(const UnsupportedMask &) const
- {
- return key == "*" || key == "unsupported";
- }
-
- bool visit(const AssociationMask &) const
- {
- return key == "*" || key == "association";
- }
- };
-}
-
-bool
-KeyRequirement::matches(
- const Environment * const env,
- const std::shared_ptr<const PackageID> & id) const
-{
- const MetadataKey * k(0);
- const Mask * m(0);
-
- switch (key_type())
- {
- case krkt_repo_role:
- {
- auto repo(env->fetch_repository(id->repository_name()));
- if (key() == "format")
- k = repo->format_key().get();
- else if (key() == "location")
- k = repo->location_key().get();
- else if (key() == "installed_root")
- k = repo->installed_root_key().get();
- else if (key() == "accept_keywords")
- k = repo->accept_keywords_key().get();
- else if (key() == "sync_host")
- k = repo->sync_host_key().get();
- }
- break;
-
- case krkt_id_role:
- {
- if (key() == "behaviours")
- k = id->behaviours_key().get();
- else if (key() == "build_dependencies")
- k = id->build_dependencies_key().get();
- else if (key() == "choices")
- k = id->choices_key().get();
- else if (key() == "contained_in")
- k = id->contained_in_key().get();
- else if (key() == "contains")
- k = id->contains_key().get();
- else if (key() == "contents")
- k = id->contents_key().get();
- else if (key() == "dependencies")
- k = id->dependencies_key().get();
- else if (key() == "fetches")
- k = id->fetches_key().get();
- else if (key() == "from_repositories")
- k = id->from_repositories_key().get();
- else if (key() == "fs_location")
- k = id->fs_location_key().get();
- else if (key() == "homepage")
- k = id->homepage_key().get();
- else if (key() == "installed_time")
- k = id->installed_time_key().get();
- else if (key() == "keywords")
- k = id->keywords_key().get();
- else if (key() == "long_description")
- k = id->long_description_key().get();
- else if (key() == "post_dependencies")
- k = id->post_dependencies_key().get();
- else if (key() == "provide")
- k = id->provide_key().get();
- else if (key() == "run_dependencies")
- k = id->run_dependencies_key().get();
- else if (key() == "short_description")
- k = id->short_description_key().get();
- else if (key() == "slot")
- k = id->slot_key().get();
- else if (key() == "suggested_dependencies")
- k = id->suggested_dependencies_key().get();
- else if (key() == "virtual_for")
- k = id->virtual_for_key().get();
- }
- break;
-
- case krkt_repo:
- {
- auto repo(env->fetch_repository(id->repository_name()));
- Repository::MetadataConstIterator mm(repo->find_metadata(key()));
- if (mm != repo->end_metadata())
- k = mm->get();
- }
- break;
-
- case krkt_id:
- {
- PackageID::MetadataConstIterator mm(id->find_metadata(key()));
- if (mm != id->end_metadata())
- k = mm->get();
- }
- break;
-
- case krkt_id_mask:
- {
- for (auto mm(id->begin_masks()), mm_end(id->end_masks()) ;
- mm != mm_end ; ++mm)
- if ((*mm)->accept_returning<bool>(MaskChecker{key()}))
- {
- m = &**mm;
- break;
- }
- }
- break;
-
- case last_krkt:
- break;
- }
-
- if ((! k) && (! m))
- return false;
-
- if (operation() == kro_question)
- return true;
- else
- {
- if (m)
- k = m->accept_returning<const MetadataKey *>(AssociatedKeyFinder{env, id});
-
- if (k)
- {
- KeyComparator c(env, id, pattern(), operation());
- return k->accept_returning<bool>(c);
- }
-
- return false;
- }
-}
-
-const std::string
-KeyRequirement::as_raw_string() const
-{
- std::stringstream s;
- s << "[.";
-
- switch (key_type())
- {
- case krkt_id: break;
- case krkt_id_role: s << "$"; break;
- case krkt_id_mask: s << "("; break;
- case krkt_repo: s << "::"; break;
- case krkt_repo_role: s << "::$"; break;
- case last_krkt:
- break;
- }
-
- s << key();
-
- switch (operation())
- {
- case kro_equals: s << "=" << pattern(); break;
- case kro_tilde: s << "~" << pattern(); break;
- case kro_less_than: s << "<" << pattern(); break;
- case kro_greater_than: s << ">" << pattern(); break;
- case kro_question: s << "?"; break;
-
- case last_kro:
- throw InternalError(PALUDIS_HERE, "Bad KeyRequirementOperation");
- }
-
- switch (key_type())
- {
- case krkt_id: break;
- case krkt_id_role: break;
- case krkt_id_mask: s << ")"; break;
- case krkt_repo: break;
- case krkt_repo_role: break;
- case last_krkt:
- break;
- }
-
- s << "]";
-
- return s.str();
-}
-
-template class Pool<KeyRequirement>;
-template class Singleton<Pool<KeyRequirement> >;
-template const std::shared_ptr<const KeyRequirement> Pool<KeyRequirement>::create(
- const KeyRequirementKeyType &, const std::string &, const KeyRequirementOperation &, const std::string &) const;
-template class Sequence<std::shared_ptr<const KeyRequirement> >;
-template class WrappedOutputIterator<Sequence<std::shared_ptr<const KeyRequirement> >::InserterTag, std::shared_ptr<const KeyRequirement> >;
-template class WrappedForwardIterator<Sequence<std::shared_ptr<const KeyRequirement> >::ConstIteratorTag, const std::shared_ptr<const KeyRequirement> >;
-
-ChoiceRequirement::ChoiceRequirement() = default;
-
-template class Sequence<std::shared_ptr<const ChoiceRequirement> >;
-template class WrappedForwardIterator<Sequence<std::shared_ptr<const ChoiceRequirement> >::ConstIteratorTag, const std::shared_ptr<const ChoiceRequirement> >;
-template class WrappedOutputIterator<Sequence<std::shared_ptr<const ChoiceRequirement> >::InserterTag, std::shared_ptr<const ChoiceRequirement> >;
-
diff --git a/paludis/package_dep_spec_requirement.hh b/paludis/package_dep_spec_requirement.hh
deleted file mode 100644
index 4a3e930..0000000
--- a/paludis/package_dep_spec_requirement.hh
+++ /dev/null
@@ -1,399 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2011 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_PACKAGE_DEP_SPEC_REQUIREMENT_HH
-#define PALUDIS_GUARD_PALUDIS_PACKAGE_DEP_SPEC_REQUIREMENT_HH 1
-
-#include <paludis/package_dep_spec_requirement-fwd.hh>
-#include <paludis/name.hh>
-#include <paludis/version_operator-fwd.hh>
-#include <paludis/version_spec-fwd.hh>
-#include <paludis/environment-fwd.hh>
-#include <paludis/package_id-fwd.hh>
-#include <paludis/changed_choices-fwd.hh>
-
-#include <paludis/util/attributes.hh>
-#include <paludis/util/pool.hh>
-#include <paludis/util/visitor.hh>
-#include <paludis/util/type_list.hh>
-#include <paludis/util/fs_path.hh>
-#include <paludis/util/pimp.hh>
-#include <paludis/util/tribool-fwd.hh>
-
-namespace paludis
-{
- class PALUDIS_VISIBLE PackageDepSpecRequirement :
- public virtual DeclareAbstractAcceptMethods<PackageDepSpecRequirement, MakeTypeList<
- NameRequirement,
- PackageNamePartRequirement,
- CategoryNamePartRequirement,
- VersionRequirement,
- InRepositoryRequirement,
- FromRepositoryRequirement,
- InstalledAtPathRequirement,
- InstallableToPathRequirement,
- InstallableToRepositoryRequirement,
- AnySlotRequirement,
- ExactSlotRequirement,
- KeyRequirement,
- ChoiceRequirement
- >::Type>
- {
- public:
- virtual ~PackageDepSpecRequirement() = 0;
- };
-
- class PALUDIS_VISIBLE NameRequirement :
- public PackageDepSpecRequirement,
- public ImplementAcceptMethods<PackageDepSpecRequirement, NameRequirement>
- {
- friend class Pool<NameRequirement>;
-
- private:
- QualifiedPackageName _name;
-
- NameRequirement(const QualifiedPackageName &);
-
- NameRequirement(const NameRequirement &) = delete;
-
- public:
- ~NameRequirement();
-
- const QualifiedPackageName name() const PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
- class PALUDIS_VISIBLE CategoryNamePartRequirement :
- public PackageDepSpecRequirement,
- public ImplementAcceptMethods<PackageDepSpecRequirement, CategoryNamePartRequirement>
- {
- friend class Pool<CategoryNamePartRequirement>;
-
- private:
- CategoryNamePart _name_part;
-
- CategoryNamePartRequirement(const CategoryNamePart &);
-
- CategoryNamePartRequirement(const CategoryNamePartRequirement &) = delete;
-
- public:
- ~CategoryNamePartRequirement();
-
- const CategoryNamePart name_part() const PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
- class PALUDIS_VISIBLE PackageNamePartRequirement :
- public PackageDepSpecRequirement,
- public ImplementAcceptMethods<PackageDepSpecRequirement, PackageNamePartRequirement>
- {
- friend class Pool<PackageNamePartRequirement>;
-
- private:
- PackageNamePart _name_part;
-
- PackageNamePartRequirement(const PackageNamePart &);
-
- PackageNamePartRequirement(const PackageNamePartRequirement &) = delete;
-
- public:
- ~PackageNamePartRequirement();
-
- const PackageNamePart name_part() const PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
- class PALUDIS_VISIBLE VersionRequirement :
- public PackageDepSpecRequirement,
- public ImplementAcceptMethods<PackageDepSpecRequirement, VersionRequirement>
- {
- private:
- Pimp<VersionRequirement> _imp;
-
- VersionRequirement(const VersionRequirement &) = delete;
-
- public:
- /* not pooled for now, since VersionSpec gives equality for 1 and 1-r0 */
- VersionRequirement(const VersionSpec &, const VersionOperator &, const VersionRequirementCombiner);
-
- ~VersionRequirement();
-
- const VersionSpec version_spec() const PALUDIS_ATTRIBUTE((warn_unused_result));
- const VersionOperator version_operator() const PALUDIS_ATTRIBUTE((warn_unused_result));
- VersionRequirementCombiner combiner() const PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
- class PALUDIS_VISIBLE InRepositoryRequirement :
- public PackageDepSpecRequirement,
- public ImplementAcceptMethods<PackageDepSpecRequirement, InRepositoryRequirement>
- {
- friend class Pool<InRepositoryRequirement>;
-
- private:
- RepositoryName _name;
-
- InRepositoryRequirement(const RepositoryName &);
-
- InRepositoryRequirement(const InRepositoryRequirement &) = delete;
-
- public:
- ~InRepositoryRequirement();
-
- const RepositoryName name() const PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
- class PALUDIS_VISIBLE FromRepositoryRequirement :
- public PackageDepSpecRequirement,
- public ImplementAcceptMethods<PackageDepSpecRequirement, FromRepositoryRequirement>
- {
- friend class Pool<FromRepositoryRequirement>;
-
- private:
- RepositoryName _name;
-
- FromRepositoryRequirement(const RepositoryName &);
-
- FromRepositoryRequirement(const FromRepositoryRequirement &) = delete;
-
- public:
- ~FromRepositoryRequirement();
-
- const RepositoryName name() const PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
- class PALUDIS_VISIBLE InstalledAtPathRequirement :
- public PackageDepSpecRequirement,
- public ImplementAcceptMethods<PackageDepSpecRequirement, InstalledAtPathRequirement>
- {
- friend class Pool<InstalledAtPathRequirement>;
-
- private:
- FSPath _path;
-
- InstalledAtPathRequirement(const FSPath &);
-
- InstalledAtPathRequirement(const InstalledAtPathRequirement &) = delete;
-
- public:
- ~InstalledAtPathRequirement();
-
- const FSPath path() const PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
- class PALUDIS_VISIBLE InstallableToPathRequirement :
- public PackageDepSpecRequirement,
- public ImplementAcceptMethods<PackageDepSpecRequirement, InstallableToPathRequirement>
- {
- friend class Pool<InstallableToPathRequirement>;
-
- private:
- FSPath _path;
- bool _include_masked;
-
- InstallableToPathRequirement(const FSPath &, const bool);
-
- InstallableToPathRequirement(const InstallableToPathRequirement &) = delete;
-
- public:
- ~InstallableToPathRequirement();
-
- const FSPath path() const PALUDIS_ATTRIBUTE((warn_unused_result));
- bool include_masked() const PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
- class PALUDIS_VISIBLE InstallableToRepositoryRequirement :
- public PackageDepSpecRequirement,
- public ImplementAcceptMethods<PackageDepSpecRequirement, InstallableToRepositoryRequirement>
- {
- friend class Pool<InstallableToRepositoryRequirement>;
-
- private:
- RepositoryName _name;
- bool _include_masked;
-
- InstallableToRepositoryRequirement(const RepositoryName &, const bool);
-
- InstallableToRepositoryRequirement(const InstallableToRepositoryRequirement &) = delete;
-
- public:
- ~InstallableToRepositoryRequirement();
-
- const RepositoryName name() const PALUDIS_ATTRIBUTE((warn_unused_result));
- bool include_masked() const PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
- class PALUDIS_VISIBLE ExactSlotRequirement :
- public PackageDepSpecRequirement,
- public ImplementAcceptMethods<PackageDepSpecRequirement, ExactSlotRequirement>
- {
- friend class Pool<ExactSlotRequirement>;
-
- private:
- SlotName _name;
- bool _locked;
-
- ExactSlotRequirement(const SlotName &, const bool);
-
- ExactSlotRequirement(const ExactSlotRequirement &) = delete;
-
- public:
- ~ExactSlotRequirement();
-
- const SlotName name() const PALUDIS_ATTRIBUTE((warn_unused_result));
- bool locked() const PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
- class PALUDIS_VISIBLE AnySlotRequirement :
- public PackageDepSpecRequirement,
- public ImplementAcceptMethods<PackageDepSpecRequirement, AnySlotRequirement>
- {
- friend class Pool<AnySlotRequirement>;
-
- private:
- bool _locking;
-
- AnySlotRequirement(const bool);
-
- AnySlotRequirement(const AnySlotRequirement &) = delete;
-
- public:
- ~AnySlotRequirement();
-
- bool locking() const PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
- class PALUDIS_VISIBLE KeyRequirement :
- public PackageDepSpecRequirement,
- public ImplementAcceptMethods<PackageDepSpecRequirement, KeyRequirement>
- {
- friend class Pool<KeyRequirement>;
-
- private:
- KeyRequirementKeyType _key_type;
- std::string _key;
- KeyRequirementOperation _operation;
- std::string _pattern;
-
- KeyRequirement(const KeyRequirementKeyType, const std::string &, const KeyRequirementOperation, const std::string &);
-
- KeyRequirement(const KeyRequirement &) = delete;
-
- public:
- ~KeyRequirement();
-
- KeyRequirementKeyType key_type() const PALUDIS_ATTRIBUTE((warn_unused_result));
- const std::string key() const PALUDIS_ATTRIBUTE((warn_unused_result));
- KeyRequirementOperation operation() const PALUDIS_ATTRIBUTE((warn_unused_result));
- const std::string pattern() const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- bool matches(
- const Environment * const env,
- const std::shared_ptr<const PackageID> & id) const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- /**
- * Return a raw string representation of ourself.
- */
- const std::string as_raw_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
- class PALUDIS_VISIBLE ChoiceRequirement :
- public PackageDepSpecRequirement,
- public ImplementAcceptMethods<PackageDepSpecRequirement, ChoiceRequirement>
- {
- private:
- ChoiceRequirement(const ChoiceRequirement &) = delete;
-
- protected:
- ChoiceRequirement();
-
- public:
- /**
- * Is our requirement met for a given PackageID?
- *
- * The string in the return type might be a description of why the
- * requirement was not met. Sometimes better messages can be given
- * than simply the return value of as_human_string() when the ID to
- * be matched is known. If the bool is false, the string is
- * meaningless.
- *
- * \param spec_id The PackageID the spec comes from. May be null. Used for
- * [use=] style dependencies.
- *
- * \since 0.61 is in ChoiceRequirement
- */
- virtual const std::pair<bool, std::string> requirement_met(
- const Environment * const,
- const ChangedChoices * const maybe_changes_to_owner,
- const std::shared_ptr<const PackageID> & target_id,
- const std::shared_ptr<const PackageID> & spec_id,
- const ChangedChoices * const maybe_changes_to_target) const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
-
- /**
- * If possible, indicate which choices to change to make our
- * requirement met for a particular ID.
- *
- * Verifies that the ID has the appropriate choice, and that that
- * choice isn't locked.
- *
- * Returns true for changes made, false for not possible,
- * indeterminate for nothing needs changing.
- *
- * \param spec_id The PackageID the spec comes from. May be null. Used for
- * [use=] style dependencies.
- *
- * \since 0.61 is in ChoiceRequirement
- */
- virtual Tribool accumulate_changes_to_make_met(
- const Environment * const,
- const ChangedChoices * const maybe_changes_to_owner,
- const std::shared_ptr<const PackageID> &,
- const std::shared_ptr<const PackageID> & spec_id,
- ChangedChoices &) const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
-
- /**
- * Return a human readable string representation of ourself.
- *
- * \param spec_id The PackageID the spec comes from. May be null. Used for
- * [use=] style dependencies.
- *
- * \since 0.61 is in ChoiceRequirement
- */
- virtual const std::string as_human_string(
- const std::shared_ptr<const PackageID> & spec_id) const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
-
- /**
- * Return a raw string representation of ourself.
- */
- virtual const std::string as_raw_string() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
- };
-
- extern template class Pool<NameRequirement>;
- extern template class Pool<PackageNamePartRequirement>;
- extern template class Pool<CategoryNamePartRequirement>;
- extern template class Pool<VersionRequirement>;
- extern template class Pool<InRepositoryRequirement>;
- extern template class Pool<FromRepositoryRequirement>;
- extern template class Pool<InstalledAtPathRequirement>;
- extern template class Pool<InstallableToPathRequirement>;
- extern template class Pool<InstallableToRepositoryRequirement>;
- extern template class Pool<ExactSlotRequirement>;
- extern template class Pool<AnySlotRequirement>;
- extern template class Pool<KeyRequirement>;
-
- extern template class Pimp<VersionRequirement>;
-}
-
-#endif
diff --git a/paludis/package_dep_spec_requirement.se b/paludis/package_dep_spec_requirement.se
deleted file mode 100644
index b3fc7ff..0000000
--- a/paludis/package_dep_spec_requirement.se
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env bash
-# vim: set sw=4 sts=4 et ft=sh :
-
-make_enum_KeyRequirementOperation()
-{
- prefix kro
-
- key kro_equals "An = requirement"
- key kro_tilde "A ~ requirement"
- key kro_less_than "A less than requirement"
- key kro_greater_than "A greater than requirement"
- key kro_question "A question requirement"
-}
-
-make_enum_KeyRequirementKeyType()
-{
- prefix krkt
-
- key krkt_id "A regular [.key] requirement"
- key krkt_id_role "A role [.\$key] requirement"
- key krkt_id_mask "A role [.(mask)] requirement"
- key krkt_repo "A [.::repo] requirement"
- key krkt_repo_role "A [.::\$repo] requirement"
-}
-
-make_enum_VersionRequirementCombiner()
-{
- prefix vrc
-
- key vrc_and "And with previous value"
- key vrc_or "Or with previons value"
-}
-
diff --git a/paludis/paludislike_options_conf.cc b/paludis/paludislike_options_conf.cc
index c493de2..7e54947 100644
--- a/paludis/paludislike_options_conf.cc
+++ b/paludis/paludislike_options_conf.cc
@@ -18,7 +18,6 @@
*/
#include <paludis/paludislike_options_conf.hh>
-
#include <paludis/util/pimp-impl.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/named_value.hh>
@@ -34,7 +33,6 @@
#include <paludis/util/active_object_ptr.hh>
#include <paludis/util/deferred_construction_ptr.hh>
#include <paludis/util/make_null_shared_ptr.hh>
-
#include <paludis/choice.hh>
#include <paludis/dep_spec.hh>
#include <paludis/name.hh>
@@ -44,8 +42,6 @@
#include <paludis/environment.hh>
#include <paludis/spec_tree.hh>
#include <paludis/package_dep_spec_properties.hh>
-#include <paludis/package_dep_spec_requirement.hh>
-
#include <unordered_map>
#include <unordered_set>
#include <list>
@@ -204,22 +200,7 @@ PaludisLikeOptionsConf::add_file(const FSPath & f)
tokens.at(0), _imp->params.environment(),
{ updso_allow_wildcards, updso_no_disambiguation, updso_throw_if_set })));
- if (package_dep_spec_has_properties(*d, make_named_values<PackageDepSpecProperties>(
- n::has_any_slot_requirement() = indeterminate,
- n::has_category_name_part() = indeterminate,
- n::has_choice_requirements() = true,
- n::has_exact_slot_requirement() = indeterminate,
- n::has_from_repository() = indeterminate,
- n::has_in_repository() = indeterminate,
- n::has_installable_to_path() = indeterminate,
- n::has_installable_to_repository() = indeterminate,
- n::has_installed_at_path() = indeterminate,
- n::has_key_requirements() = indeterminate,
- n::has_package() = indeterminate,
- n::has_package_name_part() = indeterminate,
- n::has_tag() = indeterminate,
- n::has_version_requirements() = indeterminate
- )))
+ if (d->additional_requirements_ptr())
{
Log::get_instance()->message("paludislike_options_conf.bad_spec", ll_warning, lc_context)
<< "Dependency specification '" << stringify(*d)
@@ -227,10 +208,10 @@ PaludisLikeOptionsConf::add_file(const FSPath & f)
continue;
}
- if (d->package_name_requirement())
+ if (d->package_ptr())
{
SpecificSpecs::iterator i(_imp->specific_specs.insert(std::make_pair(
- d->package_name_requirement()->name(),
+ *d->package_ptr(),
SpecsWithValuesGroups())).first);
values_groups = &i->second.insert(i->second.end(),
make_named_values<SpecWithValuesGroups>(
@@ -356,18 +337,16 @@ namespace
bool match_anything(const PackageDepSpec & spec)
{
return package_dep_spec_has_properties(spec, make_named_values<PackageDepSpecProperties>(
- n::has_any_slot_requirement() = indeterminate,
+ n::has_additional_requirements() = false,
n::has_category_name_part() = false,
- n::has_choice_requirements() = false,
- n::has_exact_slot_requirement() = false,
n::has_from_repository() = false,
n::has_in_repository() = false,
n::has_installable_to_path() = false,
n::has_installable_to_repository() = false,
n::has_installed_at_path() = false,
- n::has_key_requirements() = false,
n::has_package() = false,
n::has_package_name_part() = false,
+ n::has_slot_requirement() = false,
n::has_tag() = false,
n::has_version_requirements() = false
));
diff --git a/paludis/partially_made_package_dep_spec-fwd.hh b/paludis/partially_made_package_dep_spec-fwd.hh
new file mode 100644
index 0000000..7a2a465
--- /dev/null
+++ b/paludis/partially_made_package_dep_spec-fwd.hh
@@ -0,0 +1,53 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010 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_PARTIALLY_MADE_PACKAGE_DEP_SPEC_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_PARTIALLY_MADE_PACKAGE_DEP_SPEC_FWD_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <paludis/util/options-fwd.hh>
+#include <iosfwd>
+
+namespace paludis
+{
+
+#include <paludis/partially_made_package_dep_spec-se.hh>
+
+ /**
+ * Options for PartiallyMadePackageDepSpec.
+ *
+ * \ingroup g_dep_spec
+ * \since 0.38
+ */
+ typedef Options<PartiallyMadePackageDepSpecOption> PartiallyMadePackageDepSpecOptions;
+
+ class PartiallyMadePackageDepSpec;
+
+ /**
+ * Create a PackageDepSpec from various rules.
+ *
+ * Note the return type is a PartiallyMadePackageDepSpec, which is implicitly convertible to
+ * a PackageDepSpec.
+ *
+ * \ingroup g_dep_spec
+ * \since 0.26
+ */
+ PartiallyMadePackageDepSpec make_package_dep_spec(const PartiallyMadePackageDepSpecOptions &) PALUDIS_VISIBLE;
+}
+
+#endif
diff --git a/paludis/partially_made_package_dep_spec.cc b/paludis/partially_made_package_dep_spec.cc
new file mode 100644
index 0000000..e94883a
--- /dev/null
+++ b/paludis/partially_made_package_dep_spec.cc
@@ -0,0 +1,567 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011 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/partially_made_package_dep_spec.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/exception.hh>
+#include <paludis/util/options.hh>
+#include <paludis/util/wrapped_output_iterator-impl.hh>
+#include <paludis/util/iterator_funcs.hh>
+#include <paludis/util/pimp-impl.hh>
+#include <paludis/util/sequence-impl.hh>
+#include <paludis/version_requirements.hh>
+#include <paludis/additional_package_dep_spec_requirement.hh>
+#include <paludis/dep_spec_data.hh>
+#include <iterator>
+#include <algorithm>
+#include <ostream>
+
+using namespace paludis;
+
+#include <paludis/partially_made_package_dep_spec-se.cc>
+
+PartiallyMadePackageDepSpec
+paludis::make_package_dep_spec(const PartiallyMadePackageDepSpecOptions & o)
+{
+ return PartiallyMadePackageDepSpec(o);
+}
+
+namespace
+{
+ struct PartiallyMadePackageDepSpecData :
+ PackageDepSpecData
+ {
+ std::shared_ptr<const QualifiedPackageName> package;
+ std::shared_ptr<const PackageNamePart> package_name_part;
+ std::shared_ptr<const CategoryNamePart> category_name_part;
+ std::shared_ptr<VersionRequirements> version_requirements;
+ VersionRequirementsMode version_requirements_mode_v;
+ std::shared_ptr<const SlotRequirement> slot;
+ std::shared_ptr<const RepositoryName> in_repository;
+ std::shared_ptr<const RepositoryName> from_repository;
+ std::shared_ptr<const InstallableToRepository> installable_to_repository;
+ std::shared_ptr<const FSPath> installed_at_path;
+ std::shared_ptr<const InstallableToPath> installable_to_path;
+ std::shared_ptr<AdditionalPackageDepSpecRequirements> additional_requirements;
+ PartiallyMadePackageDepSpecOptions options_for_partially_made_package_dep_spec_v;
+
+ PartiallyMadePackageDepSpecData(const PartiallyMadePackageDepSpecOptions & o) :
+ PackageDepSpecData(),
+ version_requirements_mode_v(vr_and),
+ options_for_partially_made_package_dep_spec_v(o)
+ {
+ }
+
+ PartiallyMadePackageDepSpecData(const PackageDepSpecData & other) :
+ PackageDepSpecData(other),
+ package(other.package_ptr()),
+ package_name_part(other.package_name_part_ptr()),
+ category_name_part(other.category_name_part_ptr()),
+ version_requirements(other.version_requirements_ptr() ? new VersionRequirements : 0),
+ version_requirements_mode_v(other.version_requirements_mode()),
+ slot(other.slot_requirement_ptr()),
+ in_repository(other.in_repository_ptr()),
+ from_repository(other.from_repository_ptr()),
+ installable_to_repository(other.installable_to_repository_ptr()),
+ installed_at_path(other.installed_at_path_ptr()),
+ installable_to_path(other.installable_to_path_ptr()),
+ additional_requirements(other.additional_requirements_ptr() ? new AdditionalPackageDepSpecRequirements : 0),
+ options_for_partially_made_package_dep_spec_v(other.options_for_partially_made_package_dep_spec())
+ {
+ if (version_requirements)
+ std::copy(other.version_requirements_ptr()->begin(), other.version_requirements_ptr()->end(),
+ version_requirements->back_inserter());
+
+ if (additional_requirements)
+ std::copy(other.additional_requirements_ptr()->begin(), other.additional_requirements_ptr()->end(),
+ additional_requirements->back_inserter());
+ }
+
+ PartiallyMadePackageDepSpecData(const PartiallyMadePackageDepSpecData & other) :
+ PackageDepSpecData(other),
+ package(other.package),
+ package_name_part(other.package_name_part),
+ category_name_part(other.category_name_part),
+ version_requirements(other.version_requirements),
+ version_requirements_mode_v(other.version_requirements_mode_v),
+ slot(other.slot),
+ in_repository(other.in_repository),
+ from_repository(other.from_repository),
+ installable_to_repository(other.installable_to_repository),
+ installed_at_path(other.installed_at_path),
+ installable_to_path(other.installable_to_path),
+ additional_requirements(other.additional_requirements),
+ options_for_partially_made_package_dep_spec_v(other.options_for_partially_made_package_dep_spec_v)
+ {
+ }
+
+ virtual std::string as_string() const
+ {
+ std::ostringstream s;
+
+ if (version_requirements_ptr())
+ {
+ if (version_requirements_ptr()->begin() == version_requirements_ptr()->end())
+ {
+ }
+ else if (next(version_requirements_ptr()->begin()) == version_requirements_ptr()->end() &&
+ ! options_for_partially_made_package_dep_spec_v[pmpdso_always_use_ranged_deps])
+ {
+ if (version_requirements_ptr()->begin()->version_operator() == vo_stupid_equal_star || version_requirements_ptr()->begin()->version_operator() == vo_nice_equal_star)
+ s << "=";
+ else
+ s << version_requirements_ptr()->begin()->version_operator();
+ }
+ }
+
+ if (package_ptr())
+ s << *package_ptr();
+ else
+ {
+ if (category_name_part_ptr())
+ s << *category_name_part_ptr();
+ else
+ s << "*";
+
+ s << "/";
+
+ if (package_name_part_ptr())
+ s << *package_name_part_ptr();
+ else
+ s << "*";
+ }
+
+ if (version_requirements_ptr())
+ {
+ if (version_requirements_ptr()->begin() == version_requirements_ptr()->end())
+ {
+ }
+ else if (next(version_requirements_ptr()->begin()) == version_requirements_ptr()->end() &&
+ ! options_for_partially_made_package_dep_spec_v[pmpdso_always_use_ranged_deps])
+ {
+ s << "-" << version_requirements_ptr()->begin()->version_spec();
+ if (version_requirements_ptr()->begin()->version_operator() == vo_stupid_equal_star || version_requirements_ptr()->begin()->version_operator() == vo_nice_equal_star)
+ s << "*";
+ }
+ }
+
+ if (slot_requirement_ptr())
+ s << stringify(*slot_requirement_ptr());
+
+ std::string left, right;
+ bool need_arrow(false);
+
+ if (from_repository_ptr())
+ left = stringify(*from_repository_ptr());
+
+ if (in_repository_ptr())
+ right = stringify(*in_repository_ptr());
+
+ if (installed_at_path_ptr())
+ {
+ if (! right.empty())
+ {
+ need_arrow = true;
+ right.append("->");
+ }
+ right.append(stringify(*installed_at_path_ptr()));
+ }
+
+ if (installable_to_repository_ptr())
+ {
+ if (! right.empty())
+ {
+ need_arrow = true;
+ right.append("->");
+ }
+ if (installable_to_repository_ptr()->include_masked())
+ right.append(stringify(installable_to_repository_ptr()->repository()) + "??");
+ else
+ right.append(stringify(installable_to_repository_ptr()->repository()) + "?");
+ }
+
+ if (installable_to_path_ptr())
+ {
+ if (! right.empty())
+ {
+ need_arrow = true;
+ right.append("->");
+ }
+ if (installable_to_path_ptr()->include_masked())
+ right.append(stringify(installable_to_path_ptr()->path()) + "??");
+ else
+ right.append(stringify(installable_to_path_ptr()->path()) + "?");
+ }
+
+ if (need_arrow || ((! left.empty()) && (! right.empty())))
+ s << "::" << left << "->" << right;
+ else if (! right.empty())
+ s << "::" << right;
+ else if (! left.empty())
+ s << "::" << left << "->";
+
+ if (version_requirements_ptr())
+ {
+ if (version_requirements_ptr()->begin() == version_requirements_ptr()->end())
+ {
+ }
+ else if (next(version_requirements_ptr()->begin()) == version_requirements_ptr()->end() &&
+ ! options_for_partially_made_package_dep_spec_v[pmpdso_always_use_ranged_deps])
+ {
+ }
+ else
+ {
+ bool need_op(false);
+ s << "[";
+ for (VersionRequirements::ConstIterator r(version_requirements_ptr()->begin()),
+ r_end(version_requirements_ptr()->end()) ; r != r_end ; ++r)
+ {
+ if (need_op)
+ {
+ do
+ {
+ switch (version_requirements_mode())
+ {
+ case vr_and:
+ s << "&";
+ continue;
+
+ case vr_or:
+ s << "|";
+ continue;
+
+ case last_vr:
+ ;
+ }
+ throw InternalError(PALUDIS_HERE, "Bad version_requirements_mode");
+ } while (false);
+ }
+
+ if (r->version_operator() == vo_stupid_equal_star || r->version_operator() == vo_nice_equal_star)
+ s << "=";
+ else
+ s << r->version_operator();
+
+ s << r->version_spec();
+
+ if (r->version_operator() == vo_stupid_equal_star || r->version_operator() == vo_nice_equal_star)
+ s << "*";
+
+ need_op = true;
+ }
+ s << "]";
+ }
+ }
+
+ if (additional_requirements_ptr())
+ for (AdditionalPackageDepSpecRequirements::ConstIterator u(additional_requirements_ptr()->begin()),
+ u_end(additional_requirements_ptr()->end()) ; u != u_end ; ++u)
+ s << (*u)->as_raw_string();
+
+ return s.str();
+ }
+
+ virtual std::shared_ptr<const QualifiedPackageName> package_ptr() const
+ {
+ return package;
+ }
+
+ virtual std::shared_ptr<const PackageNamePart> package_name_part_ptr() const
+ {
+ return package_name_part;
+ }
+
+ virtual std::shared_ptr<const CategoryNamePart> category_name_part_ptr() const
+ {
+ return category_name_part;
+ }
+
+ virtual std::shared_ptr<const VersionRequirements> version_requirements_ptr() const
+ {
+ return version_requirements;
+ }
+
+ virtual VersionRequirementsMode version_requirements_mode() const
+ {
+ return version_requirements_mode_v;
+ }
+
+ virtual std::shared_ptr<const SlotRequirement> slot_requirement_ptr() const
+ {
+ return slot;
+ }
+
+ virtual std::shared_ptr<const RepositoryName> in_repository_ptr() const
+ {
+ return in_repository;
+ }
+
+ virtual std::shared_ptr<const InstallableToRepository> installable_to_repository_ptr() const
+ {
+ return installable_to_repository;
+ }
+
+ virtual std::shared_ptr<const RepositoryName> from_repository_ptr() const
+ {
+ return from_repository;
+ }
+
+ virtual std::shared_ptr<const FSPath> installed_at_path_ptr() const
+ {
+ return installed_at_path;
+ }
+
+ virtual std::shared_ptr<const InstallableToPath> installable_to_path_ptr() const
+ {
+ return installable_to_path;
+ }
+
+ virtual std::shared_ptr<const AdditionalPackageDepSpecRequirements> additional_requirements_ptr() const
+ {
+ return additional_requirements;
+ }
+
+ virtual const PartiallyMadePackageDepSpecOptions options_for_partially_made_package_dep_spec() const
+ {
+ return options_for_partially_made_package_dep_spec_v;
+ }
+ };
+}
+
+namespace paludis
+{
+ template <>
+ struct Imp<PartiallyMadePackageDepSpec>
+ {
+ std::shared_ptr<PartiallyMadePackageDepSpecData> data;
+
+ Imp(const PartiallyMadePackageDepSpecOptions & o) :
+ data(std::make_shared<PartiallyMadePackageDepSpecData>(o))
+ {
+ }
+
+ Imp(const Imp & other) :
+ data(std::make_shared<PartiallyMadePackageDepSpecData>(*other.data))
+ {
+ }
+
+ Imp(const PackageDepSpec & other) :
+ data(std::make_shared<PartiallyMadePackageDepSpecData>(*other.data()))
+ {
+ }
+ };
+}
+
+PartiallyMadePackageDepSpec::PartiallyMadePackageDepSpec(const PartiallyMadePackageDepSpecOptions & o) :
+ _imp(o)
+{
+}
+
+PartiallyMadePackageDepSpec::PartiallyMadePackageDepSpec(const PartiallyMadePackageDepSpec & other) :
+ _imp(*other._imp.get())
+{
+}
+
+PartiallyMadePackageDepSpec::PartiallyMadePackageDepSpec(const PackageDepSpec & other) :
+ _imp(other)
+{
+}
+
+PartiallyMadePackageDepSpec::~PartiallyMadePackageDepSpec()
+{
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::package(const QualifiedPackageName & name)
+{
+ _imp->data->package = std::make_shared<QualifiedPackageName>(name);
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::clear_package()
+{
+ _imp->data->package.reset();
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::slot_requirement(const std::shared_ptr<const SlotRequirement> & s)
+{
+ _imp->data->slot = s;
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::clear_slot_requirement()
+{
+ _imp->data->slot.reset();
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::in_repository(const RepositoryName & s)
+{
+ _imp->data->in_repository = std::make_shared<RepositoryName>(s);
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::clear_in_repository()
+{
+ _imp->data->in_repository.reset();
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::from_repository(const RepositoryName & s)
+{
+ _imp->data->from_repository = std::make_shared<RepositoryName>(s);
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::clear_from_repository()
+{
+ _imp->data->from_repository.reset();
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::installable_to_repository(const InstallableToRepository & s)
+{
+ _imp->data->installable_to_repository = std::make_shared<InstallableToRepository>(s);
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::clear_installable_to_repository()
+{
+ _imp->data->installable_to_repository.reset();
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::installed_at_path(const FSPath & s)
+{
+ _imp->data->installed_at_path = std::make_shared<FSPath>(s);
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::clear_installed_at_path()
+{
+ _imp->data->installed_at_path.reset();
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::installable_to_path(const InstallableToPath & s)
+{
+ _imp->data->installable_to_path = std::make_shared<InstallableToPath>(s);
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::clear_installable_to_path()
+{
+ _imp->data->installable_to_path.reset();
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::package_name_part(const PackageNamePart & part)
+{
+ _imp->data->package_name_part = std::make_shared<PackageNamePart>(part);
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::clear_package_name_part()
+{
+ _imp->data->package_name_part.reset();
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::category_name_part(const CategoryNamePart & part)
+{
+ _imp->data->category_name_part = std::make_shared<CategoryNamePart>(part);
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::clear_category_name_part()
+{
+ _imp->data->category_name_part.reset();
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::version_requirement(const VersionRequirement & req)
+{
+ if (! _imp->data->version_requirements)
+ _imp->data->version_requirements = std::make_shared<VersionRequirements>();
+ _imp->data->version_requirements->push_back(req);
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::clear_version_requirements()
+{
+ _imp->data->version_requirements.reset();
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::version_requirements_mode(const VersionRequirementsMode & mode)
+{
+ _imp->data->version_requirements_mode_v = mode;
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::additional_requirement(const std::shared_ptr<const AdditionalPackageDepSpecRequirement> & req)
+{
+ if (! _imp->data->additional_requirements)
+ _imp->data->additional_requirements = std::make_shared<AdditionalPackageDepSpecRequirements>();
+ _imp->data->additional_requirements->push_back(req);
+ return *this;
+}
+
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::clear_additional_requirements()
+{
+ _imp->data->additional_requirements.reset();
+ return *this;
+}
+
+PartiallyMadePackageDepSpec::operator const PackageDepSpec() const
+{
+ return PackageDepSpec(_imp->data);
+}
+
+const PackageDepSpec
+PartiallyMadePackageDepSpec::to_package_dep_spec() const
+{
+ return operator const PackageDepSpec();
+}
+
+template class Pimp<PartiallyMadePackageDepSpec>;
+
diff --git a/paludis/partially_made_package_dep_spec.hh b/paludis/partially_made_package_dep_spec.hh
new file mode 100644
index 0000000..4f08730
--- /dev/null
+++ b/paludis/partially_made_package_dep_spec.hh
@@ -0,0 +1,211 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011 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_PARTIALLY_MADE_PACKAGE_DEP_SPEC_HH
+#define PALUDIS_GUARD_PALUDIS_PARTIALLY_MADE_PACKAGE_DEP_SPEC_HH 1
+
+#include <paludis/partially_made_package_dep_spec-fwd.hh>
+#include <paludis/util/pimp.hh>
+#include <paludis/name-fwd.hh>
+#include <paludis/dep_spec.hh>
+
+namespace paludis
+{
+ /**
+ * A PartiallyMadePackageDepSpec is returned by make_package_dep_spec()
+ * and is used to incrementally build a PackageDepSpec.
+ *
+ * \ingroup g_dep_spec
+ * \since 0.26
+ */
+ class PALUDIS_VISIBLE PartiallyMadePackageDepSpec
+ {
+ private:
+ Pimp<PartiallyMadePackageDepSpec> _imp;
+
+ public:
+ ///\name Basic operations
+ ///\{
+
+ PartiallyMadePackageDepSpec(const PartiallyMadePackageDepSpecOptions &);
+ ~PartiallyMadePackageDepSpec();
+ PartiallyMadePackageDepSpec(const PackageDepSpec &);
+ PartiallyMadePackageDepSpec(const PartiallyMadePackageDepSpec &);
+
+ ///\}
+
+ /**
+ * Set our package requirements, return ourself.
+ */
+ PartiallyMadePackageDepSpec & package(const QualifiedPackageName &);
+
+ /**
+ * Clear our package requirements, return ourself.
+ *
+ * \since 0.55
+ */
+ PartiallyMadePackageDepSpec & clear_package();
+
+ /**
+ * Set our slot requirements, return ourself.
+ */
+ PartiallyMadePackageDepSpec & slot_requirement(const std::shared_ptr<const SlotRequirement> &);
+
+ /**
+ * Clear our slot requirements, return ourself.
+ *
+ * \since 0.55
+ */
+ PartiallyMadePackageDepSpec & clear_slot_requirement();
+
+ /**
+ * Set our in-repository requirement, return ourself.
+ */
+ PartiallyMadePackageDepSpec & in_repository(const RepositoryName &);
+
+ /**
+ * Clear our in-repository requirement, return ourself.
+ *
+ * \since 0.55
+ */
+ PartiallyMadePackageDepSpec & clear_in_repository();
+
+ /**
+ * Set our from-repository requirement, return ourself.
+ */
+ PartiallyMadePackageDepSpec & from_repository(const RepositoryName &);
+
+ /**
+ * Clear our from-repository requirement, return ourself.
+ *
+ * \since 0.55
+ */
+ PartiallyMadePackageDepSpec & clear_from_repository();
+
+ /**
+ * Set our installable-to-repository requirement, return ourself.
+ *
+ * \since 0.32
+ */
+ PartiallyMadePackageDepSpec & installable_to_repository(const InstallableToRepository &);
+
+ /**
+ * Clear our installable-to-repository requirement, return ourself.
+ *
+ * \since 0.55
+ */
+ PartiallyMadePackageDepSpec & clear_installable_to_repository();
+
+ /**
+ * Set our installed-at-path requirement, return ourself.
+ *
+ * \since 0.32
+ */
+ PartiallyMadePackageDepSpec & installed_at_path(const FSPath &);
+
+ /**
+ * Clear our installed-at-path requirement, return ourself.
+ *
+ * \since 0.55
+ */
+ PartiallyMadePackageDepSpec & clear_installed_at_path();
+
+ /**
+ * Set our installable-to-path requirement, return ourself.
+ *
+ * \since 0.32
+ */
+ PartiallyMadePackageDepSpec & installable_to_path(const InstallableToPath &);
+
+ /**
+ * Clear our installable-to-path requirement, return ourself.
+ *
+ * \since 0.55
+ */
+ PartiallyMadePackageDepSpec & clear_installable_to_path();
+
+ /**
+ * Set our package name part requirements, return ourself.
+ */
+ PartiallyMadePackageDepSpec & package_name_part(const PackageNamePart &);
+
+ /**
+ * Clear our package name part requirements, return ourself.
+ *
+ * \since 0.55
+ */
+ PartiallyMadePackageDepSpec & clear_package_name_part();
+
+ /**
+ * Set our category name part requirements, return ourself.
+ */
+ PartiallyMadePackageDepSpec & category_name_part(const CategoryNamePart &);
+
+ /**
+ * Clear our category name part requirements, return ourself.
+ *
+ * \since 0.55
+ */
+ PartiallyMadePackageDepSpec & clear_category_name_part();
+
+ /**
+ * Add a version requirement, return ourself.
+ */
+ PartiallyMadePackageDepSpec & version_requirement(const VersionRequirement &);
+
+ /**
+ * Clear all version requirement, return ourself.
+ *
+ * \since 0.55
+ */
+ PartiallyMadePackageDepSpec & clear_version_requirements();
+
+ /**
+ * Set our version requirements mode, return ourself.
+ */
+ PartiallyMadePackageDepSpec & version_requirements_mode(const VersionRequirementsMode &);
+
+ /**
+ * Add an additional requirement, return ourself.
+ */
+ PartiallyMadePackageDepSpec & additional_requirement(
+ const std::shared_ptr<const AdditionalPackageDepSpecRequirement> &);
+
+ /**
+ * Clear additional requirements, return ourself.
+ *
+ * \since 0.41
+ */
+ PartiallyMadePackageDepSpec & clear_additional_requirements();
+
+ /**
+ * Turn ourselves into a PackageDepSpec.
+ */
+ operator const PackageDepSpec() const;
+
+ /**
+ * Explicitly turn ourselves into a PackageDepSpec.
+ */
+ const PackageDepSpec to_package_dep_spec() const;
+ };
+
+ extern template class Pimp<PartiallyMadePackageDepSpec>;
+}
+
+#endif
diff --git a/paludis/partially_made_package_dep_spec.se b/paludis/partially_made_package_dep_spec.se
new file mode 100644
index 0000000..ed3550a
--- /dev/null
+++ b/paludis/partially_made_package_dep_spec.se
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+# vim: set sw=4 sts=4 et ft=sh :
+
+make_enum_PartiallyMadePackageDepSpecOption()
+{
+ prefix pmpdso
+
+ key pmpdso_always_use_ranged_deps "Always write [>=1] style dependencies"
+
+ doxygen_comment << "END"
+ /**
+ * Options for PartiallyMadePackageDepSpec.
+ *
+ * \ingroup g_dep_spec
+ * \since 0.38
+ */
+END
+}
+
diff --git a/paludis/repositories/accounts/accounts_dep_key.cc b/paludis/repositories/accounts/accounts_dep_key.cc
index 0bc9bd5..6fe6f96 100644
--- a/paludis/repositories/accounts/accounts_dep_key.cc
+++ b/paludis/repositories/accounts/accounts_dep_key.cc
@@ -18,23 +18,20 @@
*/
#include <paludis/repositories/accounts/accounts_dep_key.hh>
-
#include <paludis/util/set-impl.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/return_literal_function.hh>
#include <paludis/util/singleton-impl.hh>
-#include <paludis/util/pimp-impl.hh>
-
#include <paludis/selection.hh>
#include <paludis/generator.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/filter.hh>
#include <paludis/dep_spec.hh>
#include <paludis/environment.hh>
+#include <paludis/util/pimp-impl.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <paludis/always_enabled_dependency_label.hh>
#include <paludis/pretty_printer.hh>
-#include <paludis/dep_spec_data.hh>
-
#include <sstream>
#include <list>
@@ -74,9 +71,8 @@ namespace paludis
for (Set<std::string>::ConstIterator i(s->begin()), i_end(s->end()) ;
i != i_end ; ++i)
{
- std::shared_ptr<PackageDepSpec> spec(std::make_shared<PackageDepSpec>(
- MutablePackageDepSpecData({ })
- .require_package(CategoryNamePart("group") + PackageNamePart(*i))));
+ std::shared_ptr<PackageDepSpec> spec(std::make_shared<PackageDepSpec>(make_package_dep_spec({ })
+ .package(CategoryNamePart("group") + PackageNamePart(*i))));
specs->push_back(spec);
tree->top()->append(spec);
}
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index a0d68e8..28dc795 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -90,7 +90,6 @@ noinst_HEADERS = \
required_use_verifier.hh \
source_uri_finder.hh \
spec_tree_pretty_printer.hh \
- split_pn_v.hh \
traditional_layout.hh \
traditional_mask_file.hh \
traditional_mask_store.hh \
@@ -171,7 +170,6 @@ libpaludiserepository_la_SOURCES = \
required_use_verifier.cc \
source_uri_finder.cc \
spec_tree_pretty_printer.cc \
- split_pn_v.cc \
traditional_layout.cc \
traditional_mask_file.cc \
traditional_mask_store.cc \
diff --git a/paludis/repositories/e/e_repository_sets.cc b/paludis/repositories/e/e_repository_sets.cc
index 23fe2df..a855880 100644
--- a/paludis/repositories/e/e_repository_sets.cc
+++ b/paludis/repositories/e/e_repository_sets.cc
@@ -26,17 +26,19 @@
#include <paludis/action-fwd.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/elike_slot_requirement.hh>
#include <paludis/environment.hh>
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/generator.hh>
#include <paludis/metadata_key.hh>
#include <paludis/package_id.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <paludis/selection.hh>
#include <paludis/set_file.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/version_operator.hh>
-#include <paludis/dep_spec_data.hh>
+#include <paludis/version_requirements.hh>
#include <paludis/util/config_file.hh>
#include <paludis/util/is_file_with_extension.hh>
@@ -293,10 +295,12 @@ ERepositorySets::security_set(bool insecurity) const
if (insecurity)
{
std::shared_ptr<PackageDepSpec> spec(std::make_shared<PackageDepSpec>(
- MutablePackageDepSpecData({ })
- .require_package((*c)->name())
- .require_version(vrc_and, vo_equal, (*c)->version())
- .require_in_repository((*c)->repository_name())));
+ make_package_dep_spec({ })
+ .package((*c)->name())
+ .version_requirement(make_named_values<VersionRequirement>(
+ n::version_operator() = vo_equal,
+ n::version_spec() = (*c)->version()))
+ .in_repository((*c)->repository_name())));
security_packages->top()->append(spec);
}
else
@@ -323,10 +327,12 @@ ERepositorySets::security_set(bool insecurity) const
continue;
}
- std::shared_ptr<PackageDepSpec> spec(std::make_shared<PackageDepSpec>(MutablePackageDepSpecData({ })
- .require_package((*r)->name())
- .require_version(vrc_and, vo_equal, (*r)->version())
- .require_in_repository((*r)->repository_name())));
+ std::shared_ptr<PackageDepSpec> spec(std::make_shared<PackageDepSpec>(make_package_dep_spec({ })
+ .package((*r)->name())
+ .version_requirement(make_named_values<VersionRequirement>(
+ n::version_operator() = vo_equal,
+ n::version_spec() = (*r)->version()))
+ .in_repository((*r)->repository_name())));
security_packages->top()->append(spec);
ok = true;
break;
diff --git a/paludis/repositories/e/exheres_mask_store.cc b/paludis/repositories/e/exheres_mask_store.cc
index b3f1fbb..6b8eea4 100644
--- a/paludis/repositories/e/exheres_mask_store.cc
+++ b/paludis/repositories/e/exheres_mask_store.cc
@@ -36,7 +36,6 @@
#include <paludis/match_package.hh>
#include <paludis/dep_spec_flattener.hh>
#include <paludis/dep_spec_annotations.hh>
-#include <paludis/package_dep_spec_requirement.hh>
#include <algorithm>
#include <unordered_map>
@@ -164,8 +163,8 @@ ExheresMaskStore::_populate()
for (auto s(flat_specs.begin()), s_end(flat_specs.end()) ;
s != s_end ; ++s)
{
- if ((*s)->package_name_requirement())
- _imp->repo_mask[(*s)->package_name_requirement()->name()].push_back(std::make_pair(**s, make_mask_info(**s, *f)));
+ if ((*s)->package_ptr())
+ _imp->repo_mask[*(*s)->package_ptr()].push_back(std::make_pair(**s, make_mask_info(**s, *f)));
else
Log::get_instance()->message("e.package_mask.bad_spec", ll_warning, lc_context)
<< "Loading package mask spec '" << **s << "' failed because specification does not restrict to a "
diff --git a/paludis/repositories/e/fix_locked_dependencies.cc b/paludis/repositories/e/fix_locked_dependencies.cc
index f674d98..df899c8 100644
--- a/paludis/repositories/e/fix_locked_dependencies.cc
+++ b/paludis/repositories/e/fix_locked_dependencies.cc
@@ -19,25 +19,22 @@
#include <paludis/repositories/e/fix_locked_dependencies.hh>
#include <paludis/repositories/e/eapi.hh>
-
#include <paludis/util/visitor_cast.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/options.hh>
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/accept_visitor.hh>
-
#include <paludis/dep_spec.hh>
#include <paludis/environment.hh>
#include <paludis/package_id.hh>
+#include <paludis/elike_slot_requirement.hh>
#include <paludis/selection.hh>
#include <paludis/generator.hh>
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/metadata_key.hh>
-#include <paludis/package_dep_spec_requirement.hh>
-#include <paludis/dep_spec_data.hh>
-
+#include <paludis/partially_made_package_dep_spec.hh>
#include <functional>
#include <algorithm>
#include <list>
@@ -102,7 +99,11 @@ namespace
do
{
- if ((! node.spec()->any_slot_requirement()) || (! node.spec()->any_slot_requirement()->locking()))
+ if (! node.spec()->slot_requirement_ptr())
+ break;
+
+ const SlotAnyLockedRequirement * const r(visitor_cast<const SlotAnyLockedRequirement>(*node.spec()->slot_requirement_ptr()));
+ if (! r)
break;
std::shared_ptr<const PackageIDSequence> matches((*env)[selection::AllVersionsSorted(
@@ -112,9 +113,8 @@ namespace
if ((*matches->last())->slot_key())
{
- PackageDepSpec new_s(MutablePackageDepSpecData(*node.spec()->data())
- .unrequire_any_slot()
- .require_exact_slot((*matches->last())->slot_key()->parse_value(), true));
+ PackageDepSpec new_s(PartiallyMadePackageDepSpec(*node.spec()).slot_requirement(
+ std::make_shared<ELikeSlotExactRequirement>((*matches->last())->slot_key()->parse_value(), true)));
c = std::make_shared<PackageDepSpec>(new_s);
}
} while (false);
diff --git a/paludis/repositories/e/split_pn_v.cc b/paludis/repositories/e/split_pn_v.cc
deleted file mode 100644
index c9d6d55..0000000
--- a/paludis/repositories/e/split_pn_v.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2011 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/split_pn_v.hh>
-
-#include <paludis/util/accept_visitor.hh>
-#include <paludis/util/indirect_iterator-impl.hh>
-#include <paludis/util/options.hh>
-#include <paludis/util/stringify.hh>
-#include <paludis/util/exception.hh>
-
-#include <paludis/user_dep_spec.hh>
-#include <paludis/package_dep_spec_requirement.hh>
-
-#include <algorithm>
-
-using namespace paludis;
-using namespace paludis::erepository;
-
-namespace
-{
- struct BitsFinder
- {
- std::pair<PackageNamePart, VersionSpec> result;
- bool had_package, had_version;
-
- BitsFinder() :
- result(PackageNamePart("x"), VersionSpec("0", { })),
- had_package(false),
- had_version(false)
- {
- }
-
- void visit(const PackageNamePartRequirement & r)
- {
- if (had_package)
- throw InternalError(PALUDIS_HERE, "got multiple /p parts");
- had_package = true;
- result.first = r.name_part();
- }
-
- void visit(const VersionRequirement & r)
- {
- if (had_version)
- throw InternalError(PALUDIS_HERE, "got multiple v parts");
- had_version = true;
- result.second = r.version_spec();
- }
-
- void visit(const CategoryNamePartRequirement &)
- {
- }
-
- void visit(const PackageDepSpecRequirement &)
- {
- throw InternalError(PALUDIS_HERE, "got unexpected requirement");
- }
- };
-}
-
-std::pair<PackageNamePart, VersionSpec>
-paludis::erepository::split_pn_v(const Environment * const env, const std::string & s)
-{
- PackageDepSpec spec(parse_user_package_dep_spec("=*/" + s, env, { updso_allow_wildcards }));
- BitsFinder f;
- std::for_each(indirect_iterator(spec.requirements()->begin()),
- indirect_iterator(spec.requirements()->end()),
- accept_visitor(f));
-
- if (! (f.had_package && f.had_version))
- throw InternalError(PALUDIS_HERE, "didn't get p/v");
-
- return f.result;
-}
-
diff --git a/paludis/repositories/e/traditional_mask_store.cc b/paludis/repositories/e/traditional_mask_store.cc
index 4cd5dcb..28d5292 100644
--- a/paludis/repositories/e/traditional_mask_store.cc
+++ b/paludis/repositories/e/traditional_mask_store.cc
@@ -21,18 +21,15 @@
#include <paludis/repositories/e/traditional_profile_file.hh>
#include <paludis/repositories/e/traditional_mask_file.hh>
#include <paludis/repositories/e/eapi.hh>
-
#include <paludis/util/pimp-impl.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/log.hh>
#include <paludis/util/make_null_shared_ptr.hh>
-
#include <paludis/dep_spec.hh>
#include <paludis/package_id.hh>
#include <paludis/match_package.hh>
-#include <paludis/package_dep_spec_requirement.hh>
#include <algorithm>
#include <unordered_map>
@@ -101,8 +98,8 @@ TraditionalMaskStore::_populate()
auto a(parse_elike_package_dep_spec(
line->second.first, line->first->supported()->package_dep_spec_parse_options(),
line->first->supported()->version_spec_options()));
- if (a.package_name_requirement())
- _imp->repo_mask[a.package_name_requirement()->name()].push_back(std::make_pair(a, line->second.second));
+ if (a.package_ptr())
+ _imp->repo_mask[*a.package_ptr()].push_back(std::make_pair(a, line->second.second));
else
Log::get_instance()->message("e.package_mask.bad_spec", ll_warning, lc_context)
<< "Loading package mask spec '" << line->second.first << "' failed because specification does not restrict to a "
diff --git a/paludis/repositories/e/traditional_profile.cc b/paludis/repositories/e/traditional_profile.cc
index 5f02e31..d3940f4 100644
--- a/paludis/repositories/e/traditional_profile.cc
+++ b/paludis/repositories/e/traditional_profile.cc
@@ -51,7 +51,6 @@
#include <paludis/distribution.hh>
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
-#include <paludis/package_dep_spec_requirement.hh>
#include <unordered_map>
#include <unordered_set>
@@ -361,8 +360,8 @@ namespace
line->first->supported()->package_dep_spec_parse_options(),
line->first->supported()->version_spec_options())));
- if (a->package_name_requirement())
- _imp->package_mask[a->package_name_requirement()->name()].push_back(std::make_pair(a, line->second.second));
+ if (a->package_ptr())
+ _imp->package_mask[*a->package_ptr()].push_back(std::make_pair(a, line->second.second));
else
Log::get_instance()->message("e.profile.package_mask.bad_spec", ll_warning, lc_context)
<< "Loading package.mask spec '" << line->second.first << "' failed because specification does not restrict to a "
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index 20f7275..5aca13e 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -28,7 +28,6 @@
#include <paludis/repositories/e/e_repository.hh>
#include <paludis/repositories/e/extra_distribution_data.hh>
#include <paludis/repositories/e/can_skip_phase.hh>
-#include <paludis/repositories/e/split_pn_v.hh>
#include <paludis/action.hh>
#include <paludis/util/config_file.hh>
@@ -46,15 +45,15 @@
#include <paludis/repository_name_cache.hh>
#include <paludis/set_file.hh>
#include <paludis/version_operator.hh>
+#include <paludis/version_requirements.hh>
#include <paludis/selection.hh>
#include <paludis/generator.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/filter.hh>
#include <paludis/output_manager.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <paludis/dep_spec_annotations.hh>
#include <paludis/unformatted_pretty_printer.hh>
-#include <paludis/package_dep_spec_requirement.hh>
-#include <paludis/dep_spec_data.hh>
#include <paludis/util/accept_visitor.hh>
#include <paludis/util/mutex.hh>
@@ -1111,14 +1110,13 @@ VDBRepository::need_package_ids(const CategoryNamePart & c) const
if (std::string::npos == s.rfind('-'))
continue;
- auto pn_v(split_pn_v(_imp->params.environment(), s));
- auto qpn(c + pn_v.first);
- q->insert(qpn);
- IDMap::iterator i(_imp->ids.find(qpn));
+ PackageDepSpec p(parse_user_package_dep_spec("=" + stringify(c) + "/" + s,
+ _imp->params.environment(), { }));
+ q->insert(*p.package_ptr());
+ IDMap::iterator i(_imp->ids.find(*p.package_ptr()));
if (_imp->ids.end() == i)
- i = _imp->ids.insert(std::make_pair(qpn, std::make_shared<PackageIDSequence>())).first;
-
- i->second->push_back(make_id(qpn, pn_v.second, *d));
+ i = _imp->ids.insert(std::make_pair(*p.package_ptr(), std::make_shared<PackageIDSequence>())).first;
+ i->second->push_back(make_id(*p.package_ptr(), p.version_requirements_ptr()->begin()->version_spec(), *d));
}
catch (const InternalError &)
{
@@ -1276,12 +1274,11 @@ namespace
void visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node)
{
- if (node.spec()->package_name_requirement() && rewrites.end() != rewrites.find(node.spec()->package_name_requirement()->name()))
+ if (node.spec()->package_ptr() && rewrites.end() != rewrites.find(*node.spec()->package_ptr()))
{
changed = true;
- str << f.prettify(MutablePackageDepSpecData(*node.spec()->data())
- .unrequire_package()
- .require_package(rewrites.find(node.spec()->package_name_requirement()->name())->second)) << " ";
+ str << f.prettify(PartiallyMadePackageDepSpec(*node.spec())
+ .package(rewrites.find(*node.spec()->package_ptr())->second)) << " ";
}
else
str << f.prettify(*node.spec()) << " ";
@@ -1618,9 +1615,7 @@ VDBRepository::perform_updates()
for (DepRewrites::const_iterator i(dep_rewrites.begin()), i_end(dep_rewrites.end()) ;
i != i_end ; ++i)
_imp->params.environment()->update_config_files_for_package_move(
- MutablePackageDepSpecData({ })
- .unrequire_package()
- .require_package(i->first),
+ make_package_dep_spec({ }).package(i->first),
i->second
);
}
diff --git a/paludis/repositories/gemcutter/gemcutter_dependencies_key.cc b/paludis/repositories/gemcutter/gemcutter_dependencies_key.cc
index a8e4bd5..5cf02c8 100644
--- a/paludis/repositories/gemcutter/gemcutter_dependencies_key.cc
+++ b/paludis/repositories/gemcutter/gemcutter_dependencies_key.cc
@@ -18,7 +18,6 @@
*/
#include <paludis/repositories/gemcutter/gemcutter_dependencies_key.hh>
-
#include <paludis/util/accept_visitor.hh>
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/pimp-impl.hh>
@@ -28,20 +27,19 @@
#include <paludis/util/make_shared_copy.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/util/make_named_values.hh>
-
#include <paludis/always_enabled_dependency_label.hh>
#include <paludis/spec_tree.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <paludis/environment.hh>
#include <paludis/selection.hh>
#include <paludis/generator.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/filter.hh>
+#include <paludis/version_requirements.hh>
#include <paludis/version_operator.hh>
#include <paludis/version_spec.hh>
#include <paludis/pretty_printer.hh>
-#include <paludis/dep_spec_data.hh>
-
#include <sstream>
#include <algorithm>
#include <vector>
@@ -175,9 +173,12 @@ namespace
VersionSpec ver(tokens[1], { });
- return make_shared_copy(PackageDepSpec(MutablePackageDepSpecData({ pdsdo_always_use_ranged_deps })
- .require_package(QualifiedPackageName("gem/" + dep.name()))
- .require_version(vrc_and, op, ver)
+ return make_shared_copy(PackageDepSpec(make_package_dep_spec({ pmpdso_always_use_ranged_deps })
+ .package(QualifiedPackageName("gem/" + dep.name()))
+ .version_requirement(make_named_values<VersionRequirement>(
+ n::version_operator() = op,
+ n::version_spec() = ver
+ ))
));
}
diff --git a/paludis/repositories/virtuals/package_id.cc b/paludis/repositories/virtuals/package_id.cc
index 419c7bf..9647925 100644
--- a/paludis/repositories/virtuals/package_id.cc
+++ b/paludis/repositories/virtuals/package_id.cc
@@ -20,7 +20,6 @@
#include <paludis/repositories/virtuals/package_id.hh>
#include <paludis/repositories/virtuals/installed_virtuals_repository.hh>
#include <paludis/repositories/virtuals/virtuals_repository.hh>
-
#include <paludis/util/stringify.hh>
#include <paludis/util/pimp-impl.hh>
#include <paludis/util/mutex.hh>
@@ -29,12 +28,11 @@
#include <paludis/util/return_literal_function.hh>
#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/util/singleton-impl.hh>
-
#include <paludis/name.hh>
#include <paludis/dep_spec.hh>
#include <paludis/version_spec.hh>
-#include <paludis/version_operator.hh>
#include <paludis/environment.hh>
+#include <paludis/version_requirements.hh>
#include <paludis/metadata_key.hh>
#include <paludis/action.hh>
#include <paludis/mask.hh>
@@ -44,9 +42,9 @@
#include <paludis/generator.hh>
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <paludis/always_enabled_dependency_label.hh>
#include <paludis/pretty_printer.hh>
-#include <paludis/dep_spec_data.hh>
using namespace paludis;
using namespace paludis::virtuals;
@@ -72,15 +70,18 @@ namespace paludis
labels(l),
spec(exact ?
std::make_shared<PackageDepSpec>(
- MutablePackageDepSpecData({ })
- .require_package(v->name())
- .require_version(vrc_and, vo_equal, v->version())
- .require_exact_slot(v->slot_key() ? v->slot_key()->parse_value() : SlotName("UNKNOWN"), false)
- .require_in_repository(v->repository_name()))
+ make_package_dep_spec(PartiallyMadePackageDepSpecOptions())
+ .package(v->name())
+ .version_requirement(make_named_values<VersionRequirement>(
+ n::version_operator() = vo_equal,
+ n::version_spec() = v->version()))
+ .slot_requirement(std::make_shared<UserSlotExactRequirement>(
+ v->slot_key() ? v->slot_key()->parse_value() : SlotName("UNKNOWN")))
+ .in_repository(v->repository_name()))
:
std::make_shared<PackageDepSpec>(
- MutablePackageDepSpecData({ })
- .require_package(v->name())
+ make_package_dep_spec(PartiallyMadePackageDepSpecOptions())
+ .package(v->name())
)
),
raw_name(r),
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index 6448be6..1aa80cc 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -29,7 +29,7 @@
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/hook.hh>
-#include <paludis/dep_spec_data.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <paludis/util/log.hh>
#include <paludis/util/operators.hh>
@@ -160,7 +160,7 @@ VirtualsRepository::need_names() const
for (RepositoryProvidesInterface::ProvidesSequence::ConstIterator p(provides->begin()),
p_end(provides->end()) ; p != p_end ; ++p)
_imp->names.push_back(std::make_pair((*p).virtual_name(), std::shared_ptr<const PackageDepSpec>(
- std::make_shared<PackageDepSpec>(MutablePackageDepSpecData({ }).require_package((*p).provided_by()->name())))));
+ std::make_shared<PackageDepSpec>(make_package_dep_spec(PartiallyMadePackageDepSpecOptions()).package((*p).provided_by()->name())))));
}
std::sort(_imp->names.begin(), _imp->names.end(), NamesSortComparator());
diff --git a/paludis/resolver/collect_depped_upon.cc b/paludis/resolver/collect_depped_upon.cc
index 04a5580..e6f281f 100644
--- a/paludis/resolver/collect_depped_upon.cc
+++ b/paludis/resolver/collect_depped_upon.cc
@@ -19,23 +19,20 @@
#include <paludis/resolver/collect_depped_upon.hh>
#include <paludis/resolver/change_by_resolvent.hh>
-
#include <paludis/util/visitor_cast.hh>
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/wrapped_output_iterator.hh>
#include <paludis/util/accept_visitor.hh>
#include <paludis/util/make_null_shared_ptr.hh>
-
#include <paludis/spec_tree.hh>
#include <paludis/dep_spec.hh>
#include <paludis/environment.hh>
#include <paludis/package_id.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
+#include <paludis/elike_slot_requirement.hh>
#include <paludis/metadata_key.hh>
#include <paludis/match_package.hh>
#include <paludis/version_spec.hh>
-#include <paludis/package_dep_spec_requirement.hh>
-#include <paludis/dep_spec_data.hh>
-
#include <algorithm>
using namespace paludis;
@@ -111,17 +108,16 @@ namespace
{
auto spec(s.spec());
- if (s.spec()->any_slot_requirement() && ! s.spec()->any_slot_requirement()->locking())
+ if (s.spec()->slot_requirement_ptr() && visitor_cast<const SlotAnyUnlockedRequirement>(
+ *s.spec()->slot_requirement_ptr()))
{
auto best_eventual_id(best_eventual(env, *s.spec(), id_for_specs, newly_available));
if (! best_eventual_id)
best_eventual_id = best_eventual(env, *s.spec(), id_for_specs, not_changing_slots);
if (best_eventual_id && best_eventual_id->slot_key())
{
- MutablePackageDepSpecData part_spec(*s.spec()->data());
- part_spec
- .unrequire_exact_slot()
- .require_exact_slot(best_eventual_id->slot_key()->parse_value(), false);
+ PartiallyMadePackageDepSpec part_spec(*s.spec());
+ part_spec.slot_requirement(std::make_shared<ELikeSlotExactRequirement>(best_eventual_id->slot_key()->parse_value(), false));
spec = std::make_shared<PackageDepSpec>(part_spec);
}
}
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index 3cdd4bf..dd594bd 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -41,7 +41,6 @@
#include <paludis/resolver/reason_utils.hh>
#include <paludis/resolver/make_uninstall_blocker.hh>
#include <paludis/resolver/has_behaviour-fwd.hh>
-
#include <paludis/util/exception.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/make_named_values.hh>
@@ -55,7 +54,6 @@
#include <paludis/util/visitor_cast.hh>
#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/util/accept_visitor.hh>
-
#include <paludis/environment.hh>
#include <paludis/notifier_callback.hh>
#include <paludis/repository.hh>
@@ -65,15 +63,16 @@
#include <paludis/selection.hh>
#include <paludis/filter.hh>
#include <paludis/match_package.hh>
+#include <paludis/version_requirements.hh>
+#include <paludis/slot_requirement.hh>
#include <paludis/choice.hh>
#include <paludis/action.hh>
+#include <paludis/elike_slot_requirement.hh>
#include <paludis/package_id.hh>
#include <paludis/changed_choices.hh>
+#include <paludis/additional_package_dep_spec_requirement.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <paludis/dep_spec_annotations.hh>
-#include <paludis/package_dep_spec_requirement.hh>
-#include <paludis/version_operator.hh>
-#include <paludis/dep_spec_data.hh>
-#include <paludis/package_dep_spec_properties.hh>
#include <paludis/util/pimp-impl.hh>
@@ -998,15 +997,15 @@ const PackageDepSpec
Decider::_make_spec_for_preloading(const PackageDepSpec & spec,
const std::shared_ptr<const ChangedChoices> & changed_choices) const
{
- MutablePackageDepSpecData result(*spec.data());
+ PartiallyMadePackageDepSpec result(spec);
/* we don't want to copy use deps from the constraint, since things like
* [foo?] start to get weird when there's no longer an associated ID. */
- result.unrequire_choices();
+ result.clear_additional_requirements();
/* but we do want to impose our own ChangedChoices if necessary. */
if (changed_choices)
- changed_choices->add_requirements_to(result);
+ changed_choices->add_additional_requirements_to(result);
return result;
}
@@ -1186,21 +1185,16 @@ Decider::find_any_score(
// AnyDepSpecChildHandler::commit in satitised_dependencies.cc
// matches this logic
OperatorScore operator_bias(os_worse_than_worst);
- bool any_version_requirements(false);
-
+ if (spec.version_requirements_ptr() && ! spec.version_requirements_ptr()->empty())
{
OperatorScore score(os_worse_than_worst);
- for (auto v(spec.requirements()->begin()), v_end(spec.requirements()->end()) ;
+ for (VersionRequirements::ConstIterator v(spec.version_requirements_ptr()->begin()),
+ v_end(spec.version_requirements_ptr()->end()) ;
v != v_end ; ++v)
{
- auto v_ver(visitor_cast<const VersionRequirement>(**v));
- if (! v_ver)
- continue;
- any_version_requirements = true;
-
OperatorScore local_score(os_worse_than_worst);
- switch (v_ver->version_operator().value())
+ switch (v->version_operator().value())
{
case vo_greater:
case vo_greater_equal:
@@ -1228,24 +1222,23 @@ Decider::find_any_score(
if (score == os_worse_than_worst)
score = local_score;
else
- switch (v_ver->combiner())
+ switch (spec.version_requirements_mode())
{
- case vrc_and:
+ case vr_and:
score = is_block ? std::max(score, local_score) : std::min(score, local_score);
break;
- case vrc_or:
+ case vr_or:
score = is_block ? std::min(score, local_score) : std::max(score, local_score);
break;
- case last_vrc:
+ case last_vr:
break;
}
}
operator_bias = score;
}
-
- if (! any_version_requirements)
+ else
{
/* don't bias no operator over a >= operator, so || ( >=foo-2 bar )
* still likes foo. */
@@ -1253,9 +1246,9 @@ Decider::find_any_score(
}
/* explicit preferences come first */
- if (spec.package_name_requirement())
+ if (spec.package_ptr())
{
- Tribool prefer_or_avoid(_imp->fns.prefer_or_avoid_fn()(spec.package_name_requirement()->name()));
+ Tribool prefer_or_avoid(_imp->fns.prefer_or_avoid_fn()(*spec.package_ptr()));
if (prefer_or_avoid.is_true())
return std::make_pair(is_block ? acs_avoid : acs_prefer, operator_bias);
else if (prefer_or_avoid.is_false())
@@ -1268,7 +1261,7 @@ Decider::find_any_score(
Context sub_context("When working out whether it's acs_vacuous_blocker:");
const std::shared_ptr<const PackageIDSequence> ids((*_imp->env)[selection::BestVersionOnly(
- generator::Matches(spec, our_id, { mpo_ignore_choice_requirements })
+ generator::Matches(spec, our_id, { mpo_ignore_additional_requirements })
| filter::SupportsAction<InstallAction>() | filter::NotMasked()
)]);
if (ids->empty())
@@ -1353,6 +1346,27 @@ Decider::find_any_score(
return std::make_pair(acs_not_installable, operator_bias);
}
+namespace
+{
+ struct SlotNameFinder
+ {
+ std::shared_ptr<SlotName> visit(const SlotExactRequirement & s)
+ {
+ return std::make_shared<SlotName>(s.slot());
+ }
+
+ std::shared_ptr<SlotName> visit(const SlotAnyUnlockedRequirement &)
+ {
+ return make_null_shared_ptr();
+ }
+
+ std::shared_ptr<SlotName> visit(const SlotAnyLockedRequirement &)
+ {
+ return make_null_shared_ptr();
+ }
+ };
+}
+
const std::shared_ptr<const Resolvents>
Decider::_get_resolvents_for_blocker(const BlockDepSpec & spec,
const std::shared_ptr<const Reason> & reason) const
@@ -1360,8 +1374,11 @@ Decider::_get_resolvents_for_blocker(const BlockDepSpec & spec,
Context context("When finding slots for '" + stringify(spec) + "':");
std::shared_ptr<SlotName> exact_slot;
- if (spec.blocking().exact_slot_requirement())
- exact_slot = make_shared_copy(spec.blocking().exact_slot_requirement()->name());
+ if (spec.blocking().slot_requirement_ptr())
+ {
+ SlotNameFinder f;
+ exact_slot = spec.blocking().slot_requirement_ptr()->accept_returning<std::shared_ptr<SlotName> >(f);
+ }
DestinationTypes destination_types(_imp->fns.get_destination_types_for_blocker_fn()(spec, reason));
std::shared_ptr<Resolvents> result(std::make_shared<Resolvents>());
@@ -1374,7 +1391,7 @@ Decider::_get_resolvents_for_blocker(const BlockDepSpec & spec,
else
{
const std::shared_ptr<const PackageIDSequence> ids((*_imp->env)[selection::BestVersionInEachSlot(
- generator::Package(spec.blocking().package_name_requirement()->name())
+ generator::Package(*spec.blocking().package_ptr())
)]);
for (PackageIDSequence::ConstIterator i(ids->begin()), i_end(ids->end()) ;
i != i_end ; ++i)
@@ -1395,8 +1412,11 @@ Decider::_get_resolvents_for(
std::shared_ptr<SlotName> exact_slot;
- if (spec.exact_slot_requirement())
- exact_slot = make_shared_copy(spec.exact_slot_requirement()->name());
+ if (spec.slot_requirement_ptr())
+ {
+ SlotNameFinder f;
+ exact_slot = spec.slot_requirement_ptr()->accept_returning<std::shared_ptr<SlotName> >(f);
+ }
return _imp->fns.get_resolvents_for_fn()(spec, maybe_from_package_id_from_reason(reason), exact_slot, reason);
}
@@ -1419,7 +1439,7 @@ Decider::_get_error_resolvents_for(
),
*t);
- auto ids(_find_installable_id_candidates_for(spec.package_name_requirement()->name(), filter::All(), true, true));
+ auto ids(_find_installable_id_candidates_for(*spec.package_ptr(), filter::All(), true, true));
if (! ids->empty())
resolvent.slot() = make_named_values<SlotNameOrNull>(
n::name_or_null() = (*ids->rbegin())->slot_key() ?
@@ -1750,7 +1770,7 @@ Decider::_find_id_for_from(
{
MatchPackageOptions opts;
if (trying_changing_choices)
- opts += mpo_ignore_choice_requirements;
+ opts += mpo_ignore_additional_requirements;
std::shared_ptr<const PackageID> best_version;
for (PackageIDSequence::ReverseConstIterator i(ids->rbegin()), i_end(ids->rend()) ;
@@ -1790,22 +1810,8 @@ Decider::_find_id_for_from(
if (! (*c)->spec().if_package())
{
- if (package_dep_spec_has_properties((*c)->spec().if_block()->blocking(), make_named_values<PackageDepSpecProperties>(
- n::has_any_slot_requirement() = indeterminate,
- n::has_category_name_part() = indeterminate,
- n::has_choice_requirements() = true,
- n::has_exact_slot_requirement() = indeterminate,
- n::has_from_repository() = indeterminate,
- n::has_in_repository() = indeterminate,
- n::has_installable_to_path() = indeterminate,
- n::has_installable_to_repository() = indeterminate,
- n::has_installed_at_path() = indeterminate,
- n::has_key_requirements() = indeterminate,
- n::has_package() = indeterminate,
- n::has_package_name_part() = indeterminate,
- n::has_tag() = indeterminate,
- n::has_version_requirements() = indeterminate
- )))
+ if ((*c)->spec().if_block()->blocking().additional_requirements_ptr() &&
+ ! (*c)->spec().if_block()->blocking().additional_requirements_ptr()->empty())
{
/* too complicated for now */
ok = false;
@@ -1813,15 +1819,17 @@ Decider::_find_id_for_from(
break;
}
- for (auto a((*c)->spec().if_package()->requirements()->begin()),
- a_end((*c)->spec().if_package()->requirements()->end()) ;
- a != a_end ; ++a)
+ if (! (*c)->spec().if_package()->additional_requirements_ptr())
{
- auto a_choice(visitor_cast<const ChoiceRequirement>(**a));
- if (! a_choice)
- continue;
+ /* no additional requirements, so no tinkering required */
+ continue;
+ }
- auto b(a_choice->accumulate_changes_to_make_met(_imp->env,
+ for (auto a((*c)->spec().if_package()->additional_requirements_ptr()->begin()),
+ a_end((*c)->spec().if_package()->additional_requirements_ptr()->end()) ;
+ a != a_end ; ++a)
+ {
+ auto b((*a)->accumulate_changes_to_make_met(_imp->env,
get_changed_choices_for(*c).get(), *i, (*c)->from_id(),
*why_changed_choices->changed_choices()));
if (b.is_false())
diff --git a/paludis/resolver/find_replacing_helper.cc b/paludis/resolver/find_replacing_helper.cc
index d9c7700..0dd0fd0 100644
--- a/paludis/resolver/find_replacing_helper.cc
+++ b/paludis/resolver/find_replacing_helper.cc
@@ -24,6 +24,8 @@
#include <paludis/util/make_named_values.hh>
#include <paludis/util/stringify.hh>
#include <paludis/package_id.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
+#include <paludis/elike_slot_requirement.hh>
#include <paludis/metadata_key.hh>
#include <paludis/repository.hh>
#include <paludis/environment.hh>
diff --git a/paludis/resolver/get_constraints_for_dependent_helper.cc b/paludis/resolver/get_constraints_for_dependent_helper.cc
index cf3b441..7264eed 100644
--- a/paludis/resolver/get_constraints_for_dependent_helper.cc
+++ b/paludis/resolver/get_constraints_for_dependent_helper.cc
@@ -24,19 +24,18 @@
#include <paludis/resolver/resolution.hh>
#include <paludis/resolver/decision.hh>
#include <paludis/resolver/make_uninstall_blocker.hh>
-
#include <paludis/util/pimp-impl.hh>
#include <paludis/util/visitor_cast.hh>
#include <paludis/util/make_shared_copy.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/util/stringify.hh>
-
#include <paludis/dep_spec.hh>
#include <paludis/package_id.hh>
#include <paludis/package_dep_spec_collection.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
+#include <paludis/elike_slot_requirement.hh>
#include <paludis/metadata_key.hh>
-#include <paludis/dep_spec_data.hh>
using namespace paludis;
using namespace paludis::resolver;
@@ -83,10 +82,10 @@ GetConstraintsForDependentHelper::operator() (
spec = make_shared_copy(id->uniquely_identifying_spec());
else
{
- MutablePackageDepSpecData partial_spec({ });
- partial_spec.require_package(id->name());
+ PartiallyMadePackageDepSpec partial_spec({ });
+ partial_spec.package(id->name());
if (id->slot_key())
- partial_spec.require_exact_slot(id->slot_key()->parse_value(), false);
+ partial_spec.slot_requirement(std::make_shared<ELikeSlotExactRequirement>(id->slot_key()->parse_value(), false));
spec = std::make_shared<PackageDepSpec>(partial_spec);
}
diff --git a/paludis/resolver/get_constraints_for_purge_helper.cc b/paludis/resolver/get_constraints_for_purge_helper.cc
index af0bb93..0cdedc1 100644
--- a/paludis/resolver/get_constraints_for_purge_helper.cc
+++ b/paludis/resolver/get_constraints_for_purge_helper.cc
@@ -24,19 +24,18 @@
#include <paludis/resolver/resolution.hh>
#include <paludis/resolver/decision.hh>
#include <paludis/resolver/make_uninstall_blocker.hh>
-
#include <paludis/util/pimp-impl.hh>
#include <paludis/util/visitor_cast.hh>
#include <paludis/util/make_shared_copy.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/util/stringify.hh>
-
#include <paludis/dep_spec.hh>
#include <paludis/package_id.hh>
#include <paludis/package_dep_spec_collection.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
+#include <paludis/elike_slot_requirement.hh>
#include <paludis/metadata_key.hh>
-#include <paludis/dep_spec_data.hh>
using namespace paludis;
using namespace paludis::resolver;
@@ -78,10 +77,10 @@ GetConstraintsForPurgeHelper::operator() (
{
const std::shared_ptr<ConstraintSequence> result(std::make_shared<ConstraintSequence>());
- MutablePackageDepSpecData partial_spec({ });
- partial_spec.require_package(id->name());
+ PartiallyMadePackageDepSpec partial_spec({ });
+ partial_spec.package(id->name());
if (id->slot_key())
- partial_spec.require_exact_slot(id->slot_key()->parse_value(), false);
+ partial_spec.slot_requirement(std::make_shared<ELikeSlotExactRequirement>(id->slot_key()->parse_value(), false));
PackageDepSpec spec(partial_spec);
const std::shared_ptr<WasUsedByReason> reason(std::make_shared<WasUsedByReason>(was_used_by_ids));
diff --git a/paludis/resolver/get_constraints_for_via_binary_helper.cc b/paludis/resolver/get_constraints_for_via_binary_helper.cc
index 7cf8e29..f2d8983 100644
--- a/paludis/resolver/get_constraints_for_via_binary_helper.cc
+++ b/paludis/resolver/get_constraints_for_via_binary_helper.cc
@@ -23,16 +23,14 @@
#include <paludis/resolver/resolvent.hh>
#include <paludis/resolver/resolution.hh>
#include <paludis/resolver/decision.hh>
-
#include <paludis/util/pimp-impl.hh>
#include <paludis/util/visitor_cast.hh>
#include <paludis/util/make_shared_copy.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/make_null_shared_ptr.hh>
-
#include <paludis/dep_spec.hh>
-#include <paludis/dep_spec_data.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
using namespace paludis;
using namespace paludis::resolver;
@@ -65,8 +63,8 @@ GetConstraintsForViaBinaryHelper::operator() (
{
auto result(std::make_shared<ConstraintSequence>());
- MutablePackageDepSpecData partial_spec({ });
- partial_spec.require_package(resolution->resolvent().package());
+ PartiallyMadePackageDepSpec partial_spec({ });
+ partial_spec.package(resolution->resolvent().package());
PackageDepSpec spec(partial_spec);
auto reason(std::make_shared<ViaBinaryReason>(other_resolution->resolvent()));
diff --git a/paludis/resolver/get_destination_types_for_blocker_helper.cc b/paludis/resolver/get_destination_types_for_blocker_helper.cc
index 899ec22..6a8c80d 100644
--- a/paludis/resolver/get_destination_types_for_blocker_helper.cc
+++ b/paludis/resolver/get_destination_types_for_blocker_helper.cc
@@ -31,6 +31,8 @@
#include <paludis/dep_spec.hh>
#include <paludis/package_id.hh>
#include <paludis/package_dep_spec_collection.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
+#include <paludis/elike_slot_requirement.hh>
#include <paludis/metadata_key.hh>
using namespace paludis;
diff --git a/paludis/resolver/get_destination_types_for_error_helper.cc b/paludis/resolver/get_destination_types_for_error_helper.cc
index 6e1d7ce..efd29b1 100644
--- a/paludis/resolver/get_destination_types_for_error_helper.cc
+++ b/paludis/resolver/get_destination_types_for_error_helper.cc
@@ -31,6 +31,8 @@
#include <paludis/dep_spec.hh>
#include <paludis/package_id.hh>
#include <paludis/package_dep_spec_collection.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
+#include <paludis/elike_slot_requirement.hh>
#include <paludis/metadata_key.hh>
using namespace paludis;
diff --git a/paludis/resolver/get_initial_constraints_for_helper.cc b/paludis/resolver/get_initial_constraints_for_helper.cc
index 1360a1e..e03e795 100644
--- a/paludis/resolver/get_initial_constraints_for_helper.cc
+++ b/paludis/resolver/get_initial_constraints_for_helper.cc
@@ -26,7 +26,6 @@
#include <paludis/resolver/destination_utils.hh>
#include <paludis/resolver/match_qpns.hh>
#include <paludis/resolver/suggest_restart.hh>
-
#include <paludis/util/pimp-impl.hh>
#include <paludis/util/visitor_cast.hh>
#include <paludis/util/make_shared_copy.hh>
@@ -36,7 +35,6 @@
#include <paludis/util/timestamp.hh>
#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/util/enum_iterator.hh>
-
#include <paludis/dep_spec.hh>
#include <paludis/package_id.hh>
#include <paludis/selection.hh>
@@ -46,8 +44,7 @@
#include <paludis/environment.hh>
#include <paludis/metadata_key.hh>
#include <paludis/version_spec.hh>
-#include <paludis/dep_spec_data.hh>
-
+#include <paludis/partially_made_package_dep_spec.hh>
#include <list>
#include <unordered_map>
@@ -243,7 +240,7 @@ GetInitialConstraintsForHelper::_make_initial_constraints_for(
n::from_id() = make_null_shared_ptr(),
n::nothing_is_fine_too() = true,
n::reason() = std::make_shared<PresetReason>("is scm", make_null_shared_ptr()),
- n::spec() = MutablePackageDepSpecData({ }).require_package(resolvent.package()),
+ n::spec() = make_package_dep_spec({ }).package(resolvent.package()),
n::untaken() = false,
n::use_existing() = ue_only_if_transient
)));
diff --git a/paludis/resolver/get_resolvents_for_helper.cc b/paludis/resolver/get_resolvents_for_helper.cc
index 9eb4353..d3e89a9 100644
--- a/paludis/resolver/get_resolvents_for_helper.cc
+++ b/paludis/resolver/get_resolvents_for_helper.cc
@@ -283,18 +283,16 @@ namespace
bool can_use_cache(const PackageDepSpec & spec)
{
return package_dep_spec_has_properties(spec, make_named_values<PackageDepSpecProperties>(
- n::has_any_slot_requirement() = indeterminate,
+ n::has_additional_requirements() = false,
n::has_category_name_part() = indeterminate,
- n::has_choice_requirements() = false,
- n::has_exact_slot_requirement() = indeterminate,
n::has_from_repository() = indeterminate,
n::has_in_repository() = indeterminate,
n::has_installable_to_path() = indeterminate,
n::has_installable_to_repository() = indeterminate,
n::has_installed_at_path() = indeterminate,
- n::has_key_requirements() = indeterminate,
n::has_package() = indeterminate,
n::has_package_name_part() = indeterminate,
+ n::has_slot_requirement() = indeterminate,
n::has_tag() = indeterminate,
n::has_version_requirements() = indeterminate
));
@@ -330,7 +328,7 @@ GetResolventsForHelper::operator() (
std::shared_ptr<const PackageID> best;
auto ids((*_imp->env)[selection::BestVersionOnly(
- generator::Matches(spec, from_id, { mpo_ignore_choice_requirements }) |
+ generator::Matches(spec, from_id, { mpo_ignore_additional_requirements }) |
filter::SupportsAction<InstallAction>() |
filter::NotMasked() |
(maybe_slot ? Filter(filter::Slot(*maybe_slot)) : Filter(filter::All())))]);
diff --git a/paludis/resolver/get_use_existing_nothing_helper.cc b/paludis/resolver/get_use_existing_nothing_helper.cc
index 6644e88..ed45432 100644
--- a/paludis/resolver/get_use_existing_nothing_helper.cc
+++ b/paludis/resolver/get_use_existing_nothing_helper.cc
@@ -34,7 +34,6 @@
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/environment.hh>
-#include <paludis/package_dep_spec_requirement.hh>
#include <list>
using namespace paludis;
@@ -217,11 +216,11 @@ GetUseExistingNothingHelper::operator() (
{
Context context("When determining use existing for '" + stringify(spec) + "':");
- if (spec.package_name_requirement())
+ if (spec.package_ptr())
{
- if (use_existing_from_withish(_imp->env, spec.package_name_requirement()->name(), _imp->without_specs))
+ if (use_existing_from_withish(_imp->env, *spec.package_ptr(), _imp->without_specs))
return std::make_pair(ue_if_possible, true);
- if (use_existing_from_withish(_imp->env, spec.package_name_requirement()->name(), _imp->with_specs))
+ if (use_existing_from_withish(_imp->env, *spec.package_ptr(), _imp->with_specs))
return std::make_pair(ue_never, false);
}
diff --git a/paludis/resolver/interest_in_spec_helper.cc b/paludis/resolver/interest_in_spec_helper.cc
index fc56b37..7eb8d5c 100644
--- a/paludis/resolver/interest_in_spec_helper.cc
+++ b/paludis/resolver/interest_in_spec_helper.cc
@@ -39,7 +39,6 @@
#include <paludis/metadata_key.hh>
#include <paludis/match_package.hh>
#include <paludis/dep_spec_annotations.hh>
-#include <paludis/package_dep_spec_requirement.hh>
#include <list>
#include <set>
@@ -270,7 +269,7 @@ InterestInSpecHelper::operator() (
{
for (auto l(_imp->take_specs.begin()), l_end(_imp->take_specs.end()) ;
l != l_end ; ++l)
- if (match_qpns(*_imp->env, *l, dep.spec().if_package()->package_name_requirement()->name()))
+ if (match_qpns(*_imp->env, *l, *dep.spec().if_package()->package_ptr()))
return si_take;
}
@@ -299,7 +298,7 @@ InterestInSpecHelper::operator() (
{
for (auto l(_imp->ignore_specs.begin()), l_end(_imp->ignore_specs.end()) ;
l != l_end ; ++l)
- if (match_qpns(*_imp->env, *l, dep.spec().if_package()->package_name_requirement()->name()))
+ if (match_qpns(*_imp->env, *l, *dep.spec().if_package()->package_ptr()))
return si_ignore;
}
diff --git a/paludis/resolver/match_qpns.cc b/paludis/resolver/match_qpns.cc
index 5366e29..6ad2892 100644
--- a/paludis/resolver/match_qpns.cc
+++ b/paludis/resolver/match_qpns.cc
@@ -18,14 +18,11 @@
*/
#include <paludis/resolver/match_qpns.hh>
-
-#include <paludis/util/make_named_values.hh>
-
#include <paludis/dep_spec.hh>
#include <paludis/environment.hh>
#include <paludis/package_dep_spec_properties.hh>
#include <paludis/name.hh>
-#include <paludis/package_dep_spec_requirement.hh>
+#include <paludis/util/make_named_values.hh>
using namespace paludis;
using namespace paludis::resolver;
@@ -41,28 +38,26 @@ paludis::resolver::match_qpns(
* either can be wildcards (we could work for :slot too,
* but we're lazy) */
if (! package_dep_spec_has_properties(spec, make_named_values<PackageDepSpecProperties>(
- n::has_any_slot_requirement() = false,
+ n::has_additional_requirements() = false,
n::has_category_name_part() = indeterminate,
- n::has_choice_requirements() = false,
- n::has_exact_slot_requirement() = false,
n::has_from_repository() = false,
n::has_in_repository() = false,
n::has_installable_to_path() = false,
n::has_installable_to_repository() = false,
n::has_installed_at_path() = false,
- n::has_key_requirements() = false,
n::has_package() = indeterminate,
n::has_package_name_part() = indeterminate,
+ n::has_slot_requirement() = false,
n::has_tag() = false,
n::has_version_requirements() = false
)))
return false;
- if (spec.package_name_requirement() && spec.package_name_requirement()->name() != package)
+ if (spec.package_ptr() && *spec.package_ptr() != package)
return false;
- if (spec.package_name_part_requirement() && spec.package_name_part_requirement()->name_part() != package.package())
+ if (spec.package_name_part_ptr() && *spec.package_name_part_ptr() != package.package())
return false;
- if (spec.category_name_part_requirement() && spec.category_name_part_requirement()->name_part() != package.category())
+ if (spec.category_name_part_ptr() && *spec.category_name_part_ptr() != package.category())
return false;
return true;
diff --git a/paludis/resolver/orderer.cc b/paludis/resolver/orderer.cc
index 7c600e7..59ef7b8 100644
--- a/paludis/resolver/orderer.cc
+++ b/paludis/resolver/orderer.cc
@@ -35,7 +35,6 @@
#include <paludis/resolver/orderer_notes.hh>
#include <paludis/resolver/change_by_resolvent.hh>
#include <paludis/resolver/labels_classifier.hh>
-
#include <paludis/util/pimp-impl.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/stringify.hh>
@@ -46,12 +45,10 @@
#include <paludis/util/visitor_cast.hh>
#include <paludis/util/tribool.hh>
#include <paludis/util/enum_iterator.hh>
-
+#include <paludis/partially_made_package_dep_spec.hh>
#include <paludis/environment.hh>
#include <paludis/notifier_callback.hh>
#include <paludis/package_id.hh>
-#include <paludis/dep_spec_data.hh>
-
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
@@ -819,12 +816,10 @@ namespace
{
PackageDepSpec make_origin_spec(const ChangesToMakeDecision & changes_to_make_decision)
{
- MutablePackageDepSpecData result(*changes_to_make_decision.origin_id()->uniquely_identifying_spec().data());
+ PartiallyMadePackageDepSpec result(changes_to_make_decision.origin_id()->uniquely_identifying_spec());
if (changes_to_make_decision.if_via_new_binary_in())
- result
- .unrequire_in_repository()
- .require_in_repository(*changes_to_make_decision.if_via_new_binary_in());
+ result.in_repository(*changes_to_make_decision.if_via_new_binary_in());
return result;
}
diff --git a/paludis/resolver/resolvent.cc b/paludis/resolver/resolvent.cc
index 1b06174..718c2ab 100644
--- a/paludis/resolver/resolvent.cc
+++ b/paludis/resolver/resolvent.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009, 2010, 2011 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -29,7 +29,6 @@
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
#include <paludis/serialise-impl.hh>
-#include <paludis/package_dep_spec_requirement.hh>
using namespace paludis;
using namespace paludis::resolver;
@@ -84,7 +83,7 @@ Resolvent::Resolvent(
const SlotName & s,
const DestinationType t) :
destination_type(n::destination_type() = t),
- package(n::package() = spec.package_name_requirement()->name()),
+ package(n::package() = *spec.package_ptr()),
slot(make_named_values<SlotNameOrNull>(
n::name_or_null() = std::make_shared<SlotName>(s),
n::null_means_unknown() = false
@@ -97,7 +96,7 @@ Resolvent::Resolvent(
const SlotNameOrNull & s,
const DestinationType t) :
destination_type(n::destination_type() = t),
- package(n::package() = spec.package_name_requirement()->name()),
+ package(n::package() = *spec.package_ptr()),
slot(s)
{
}
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 3ef4d25..4078fb6 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -52,6 +52,8 @@
#include <paludis/filtered_generator.hh>
#include <paludis/generator.hh>
#include <paludis/selection.hh>
+#include <paludis/elike_slot_requirement.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <paludis/repositories/fake/fake_installed_repository.hh>
diff --git a/paludis/resolver/sanitised_dependencies.cc b/paludis/resolver/sanitised_dependencies.cc
index e0e682e..890c4e0 100644
--- a/paludis/resolver/sanitised_dependencies.cc
+++ b/paludis/resolver/sanitised_dependencies.cc
@@ -36,6 +36,7 @@
#include <paludis/util/map.hh>
#include <paludis/util/accept_visitor.hh>
#include <paludis/spec_tree.hh>
+#include <paludis/slot_requirement.hh>
#include <paludis/metadata_key.hh>
#include <paludis/package_id.hh>
#include <paludis/elike_package_dep_spec.hh>
@@ -168,7 +169,7 @@ namespace
void visit_package_spec(const PackageDepSpec & spec)
{
- if (spec.package_name_requirement())
+ if (spec.package_ptr())
visit_package_or_block_spec(PackageOrBlockDepSpec(spec));
else
super_complicated = true;
@@ -176,7 +177,7 @@ namespace
void visit_block_spec(const BlockDepSpec & spec)
{
- if (spec.blocking().package_name_requirement())
+ if (spec.blocking().package_ptr())
visit_package_or_block_spec(PackageOrBlockDepSpec(spec));
else
super_complicated = true;
diff --git a/paludis/resolver/spec_rewriter.cc b/paludis/resolver/spec_rewriter.cc
index 1e0f1af..2a7a9db 100644
--- a/paludis/resolver/spec_rewriter.cc
+++ b/paludis/resolver/spec_rewriter.cc
@@ -27,7 +27,6 @@
#include <paludis/util/stringify.hh>
#include <paludis/util/pimp-impl.hh>
#include <paludis/util/make_null_shared_ptr.hh>
-
#include <paludis/spec_tree.hh>
#include <paludis/dep_spec.hh>
#include <paludis/environment.hh>
@@ -37,10 +36,8 @@
#include <paludis/filter.hh>
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <paludis/elike_blocker.hh>
-#include <paludis/package_dep_spec_requirement.hh>
-#include <paludis/dep_spec_data.hh>
-
#include <map>
#include <set>
@@ -95,13 +92,13 @@ SpecRewriter::~SpecRewriter() = default;
const std::shared_ptr<const RewrittenSpec>
SpecRewriter::rewrite_if_special(const PackageOrBlockDepSpec & s, const std::shared_ptr<const Resolvent> & maybe_our_resolvent) const
{
- if (s.if_package() && s.if_package()->package_name_requirement())
+ if (s.if_package() && s.if_package()->package_ptr())
{
- if (s.if_package()->package_name_requirement()->name().category() != CategoryNamePart("virtual"))
+ if (s.if_package()->package_ptr()->category() != CategoryNamePart("virtual"))
return make_null_shared_ptr();
_need_rewrites();
- Rewrites::const_iterator r(_imp->rewrites.find(s.if_package()->package_name_requirement()->name()));
+ Rewrites::const_iterator r(_imp->rewrites.find(*s.if_package()->package_ptr()));
if (r == _imp->rewrites.end())
return make_null_shared_ptr();
@@ -111,19 +108,17 @@ SpecRewriter::rewrite_if_special(const PackageOrBlockDepSpec & s, const std::sha
for (std::set<QualifiedPackageName>::const_iterator n(r->second.begin()), n_end(r->second.end()) ;
n != n_end ; ++n)
- result->specs()->push_back(PackageOrBlockDepSpec(MutablePackageDepSpecData(*s.if_package()->data())
- .unrequire_package()
- .require_package(*n)));
+ result->specs()->push_back(PackageOrBlockDepSpec(PartiallyMadePackageDepSpec(*s.if_package()).package(*n)));
return result;
}
- else if (s.if_block() && s.if_block()->blocking().package_name_requirement())
+ else if (s.if_block() && s.if_block()->blocking().package_ptr())
{
- if (s.if_block()->blocking().package_name_requirement()->name().category() != CategoryNamePart("virtual"))
+ if (s.if_block()->blocking().package_ptr()->category() != CategoryNamePart("virtual"))
return make_null_shared_ptr();
_need_rewrites();
- Rewrites::const_iterator r(_imp->rewrites.find(s.if_block()->blocking().package_name_requirement()->name()));
+ Rewrites::const_iterator r(_imp->rewrites.find(*s.if_block()->blocking().package_ptr()));
if (r == _imp->rewrites.end())
return make_null_shared_ptr();
@@ -137,9 +132,7 @@ SpecRewriter::rewrite_if_special(const PackageOrBlockDepSpec & s, const std::sha
if (maybe_our_resolvent && (*n == maybe_our_resolvent->package()))
continue;
- PackageDepSpec spec(MutablePackageDepSpecData(*s.if_block()->blocking().data())
- .unrequire_package()
- .require_package(*n));
+ PackageDepSpec spec(PartiallyMadePackageDepSpec(s.if_block()->blocking()).package(*n));
auto p(split_elike_blocker(s.if_block()->text()));
BlockDepSpec b(std::get<1>(p) + stringify(spec), spec);
b.set_annotations(s.if_block()->maybe_annotations());
diff --git a/paludis/set_file.cc b/paludis/set_file.cc
index 4fa3db5..646ccf4 100644
--- a/paludis/set_file.cc
+++ b/paludis/set_file.cc
@@ -37,9 +37,8 @@
#include <paludis/generator.hh>
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <paludis/metadata_key.hh>
-#include <paludis/package_dep_spec_requirement.hh>
-#include <paludis/dep_spec_data.hh>
#include <list>
#include <vector>
@@ -169,18 +168,6 @@ namespace
}
};
- PackageDepSpec name_and_slot(const PackageDepSpec & spec)
- {
- if (spec.exact_slot_requirement())
- return MutablePackageDepSpecData({ })
- .require_package(spec.package_name_requirement()->name())
- .require_exact_slot(spec.exact_slot_requirement()->name(), spec.exact_slot_requirement()->locked())
- ;
- else
- return MutablePackageDepSpecData({ })
- .require_package(spec.package_name_requirement()->name());
- }
-
void
do_one_conf_line(const std::string & line, std::shared_ptr<SetSpecTree> result,
const SetFileParams & params)
@@ -251,13 +238,13 @@ namespace
}
std::shared_ptr<PackageDepSpec> spec(std::make_shared<PackageDepSpec>(params.parser()(tokens.at(1))));
- if (spec->package_name_requirement())
+ if (spec->package_ptr())
{
if (! params.environment())
Log::get_instance()->message("set_file.bad_operator", ll_warning, lc_context)
<< "Line '" << line << "' uses ? operator but no environment is available";
else if (! (*params.environment())[selection::SomeArbitraryVersion(
- generator::Package(spec->package_name_requirement()->name()) |
+ generator::Package(*spec->package_ptr()) |
filter::InstalledAtRoot(params.environment()->preferred_root_key()->parse_value()))]->empty())
result->top()->append(spec);
}
@@ -275,13 +262,16 @@ namespace
}
std::shared_ptr<PackageDepSpec> spec(std::make_shared<PackageDepSpec>(params.parser()(tokens.at(1))));
- if (spec->package_name_requirement())
+ if (spec->package_ptr())
{
if (! params.environment())
Log::get_instance()->message("set_file.bad_operator", ll_warning, lc_context)
<< "Line '" << line << "' uses ?: operator but no environment is available";
else if (! (*params.environment())[selection::SomeArbitraryVersion(generator::Matches(
- name_and_slot(*spec), make_null_shared_ptr(), { }) |
+ make_package_dep_spec({ })
+ .package(*spec->package_ptr())
+ .slot_requirement(spec->slot_requirement_ptr()),
+ make_null_shared_ptr(), { }) |
filter::InstalledAtRoot(params.environment()->preferred_root_key()->parse_value()))]->empty())
result->top()->append(spec);
}
diff --git a/paludis/repositories/e/split_pn_v.hh b/paludis/slot_requirement-fwd.hh
index 87bbb84..09852be 100644
--- a/paludis/repositories/e/split_pn_v.hh
+++ b/paludis/slot_requirement-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2011 Ciaran McCreesh
+ * 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
@@ -17,23 +17,20 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_SPLIT_PN_V_HH
-#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_SPLIT_PN_V_HH 1
+#ifndef PALUDIS_GUARD_PALUDIS_SLOT_REQUIREMENT_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_SLOT_REQUIREMENT_FWD_HH 1
-#include <paludis/name.hh>
-#include <paludis/version_spec.hh>
-#include <paludis/environment-fwd.hh>
-
-#include <string>
-#include <utility>
+#include <iosfwd>
+#include <paludis/util/attributes.hh>
namespace paludis
{
- namespace erepository
- {
- std::pair<PackageNamePart, VersionSpec> split_pn_v(
- const Environment * const, const std::string &);
- }
+ struct SlotRequirement;
+ struct SlotExactRequirement;
+ struct SlotAnyLockedRequirement;
+ struct SlotAnyUnlockedRequirement;
+
+ std::ostream & operator<< (std::ostream &, const SlotRequirement &) PALUDIS_VISIBLE;
}
#endif
diff --git a/paludis/slot_requirement.cc b/paludis/slot_requirement.cc
new file mode 100644
index 0000000..97690e7
--- /dev/null
+++ b/paludis/slot_requirement.cc
@@ -0,0 +1,31 @@
+/* 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/slot_requirement.hh>
+#include <ostream>
+
+using namespace paludis;
+
+std::ostream &
+paludis::operator<< (std::ostream & s, const SlotRequirement & r)
+{
+ s << r.as_string();
+ return s;
+}
+
diff --git a/paludis/slot_requirement.hh b/paludis/slot_requirement.hh
new file mode 100644
index 0000000..d1c3293
--- /dev/null
+++ b/paludis/slot_requirement.hh
@@ -0,0 +1,59 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008, 2011 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_SLOT_REQUIREMENT_HH
+#define PALUDIS_GUARD_PALUDIS_SLOT_REQUIREMENT_HH 1
+
+#include <paludis/slot_requirement-fwd.hh>
+#include <paludis/name-fwd.hh>
+#include <paludis/util/visitor.hh>
+#include <paludis/util/type_list.hh>
+
+namespace paludis
+{
+ class PALUDIS_VISIBLE SlotRequirement :
+ public virtual DeclareAbstractAcceptMethods<SlotRequirement, MakeTypeList<
+ SlotExactRequirement, SlotAnyLockedRequirement, SlotAnyUnlockedRequirement>::Type>
+ {
+ public:
+ virtual const std::string as_string() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ };
+
+ class PALUDIS_VISIBLE SlotExactRequirement :
+ public SlotRequirement,
+ public ImplementAcceptMethods<SlotRequirement, SlotExactRequirement>
+ {
+ public:
+ virtual const SlotName slot() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ };
+
+ class PALUDIS_VISIBLE SlotAnyLockedRequirement :
+ public SlotRequirement,
+ public ImplementAcceptMethods<SlotRequirement, SlotAnyLockedRequirement>
+ {
+ };
+
+ class PALUDIS_VISIBLE SlotAnyUnlockedRequirement :
+ public SlotRequirement,
+ public ImplementAcceptMethods<SlotRequirement, SlotAnyUnlockedRequirement>
+ {
+ };
+}
+
+#endif
diff --git a/paludis/user_dep_spec-fwd.hh b/paludis/user_dep_spec-fwd.hh
index 5c10ea9..4a8a66d 100644
--- a/paludis/user_dep_spec-fwd.hh
+++ b/paludis/user_dep_spec-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2011 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009 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
@@ -63,6 +63,10 @@ namespace paludis
///\}
};
+ struct UserSlotExactRequirement;
+
+ struct UserKeyRequirement;
+
/**
* The VersionSpecOptions to use for parsing a user spec.
*
diff --git a/paludis/user_dep_spec.cc b/paludis/user_dep_spec.cc
index 0cbd015..d456b10 100644
--- a/paludis/user_dep_spec.cc
+++ b/paludis/user_dep_spec.cc
@@ -23,17 +23,19 @@
#include <paludis/elike_use_requirement.hh>
#include <paludis/version_operator.hh>
#include <paludis/version_spec.hh>
+#include <paludis/version_requirements.hh>
#include <paludis/filter.hh>
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
#include <paludis/dep_label.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <paludis/contents.hh>
#include <paludis/repository.hh>
-#include <paludis/dep_spec_data.hh>
#include <paludis/util/options.hh>
#include <paludis/util/log.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/util/pimp-impl.hh>
#include <paludis/util/set.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/indirect_iterator-impl.hh>
@@ -43,7 +45,6 @@
#include <paludis/util/tribool.hh>
#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/util/join.hh>
-#include <paludis/util/return_literal_function.hh>
#include <algorithm>
@@ -53,7 +54,7 @@ using namespace paludis;
namespace
{
- void user_add_package_requirement(const std::string & s, MutablePackageDepSpecData & result,
+ void user_add_package_requirement(const std::string & s, PartiallyMadePackageDepSpec & result,
const Environment * const env, const UserPackageDepSpecOptions & options,
const Filter & filter)
{
@@ -63,43 +64,43 @@ namespace
throw PackageDepSpecError("Wildcard '*' not allowed");
if (0 != s.compare(s.length() - 2, 2, "/*"))
- result.require_package_name_part(PackageNamePart(s.substr(2)));
+ result.package_name_part(PackageNamePart(s.substr(2)));
}
else if (s.length() >= 3 && (0 == s.compare(s.length() - 2, 2, "/*")))
{
if (! options[updso_allow_wildcards])
throw PackageDepSpecError("Wildcard '*' not allowed in '" + stringify(s) + "'");
- result.require_category_name_part(CategoryNamePart(s.substr(0, s.length() - 2)));
+ result.category_name_part(CategoryNamePart(s.substr(0, s.length() - 2)));
}
else if (s == "*")
throw PackageDepSpecError("Use '*/*' not '*' to match everything");
else if (std::string::npos != s.find('/'))
- result.require_package(QualifiedPackageName(s));
+ result.package(QualifiedPackageName(s));
else
{
if (options[updso_no_disambiguation])
throw PackageDepSpecError("Need an explicit category specified");
- result.require_package(env->fetch_unique_qualified_package_name(PackageNamePart(s),
+ result.package(env->fetch_unique_qualified_package_name(PackageNamePart(s),
filter::And(filter, filter::Matches(result, make_null_shared_ptr(), { }))));
}
}
- void envless_add_package_requirement(const std::string & s, MutablePackageDepSpecData & result)
+ void envless_add_package_requirement(const std::string & s, PartiallyMadePackageDepSpec & result)
{
if (s.length() >= 3 && (0 == s.compare(0, 2, "*/")))
{
if (0 != s.compare(s.length() - 2, 2, "/*"))
- result.require_package_name_part(PackageNamePart(s.substr(2)));
+ result.package_name_part(PackageNamePart(s.substr(2)));
}
else if (s.length() >= 3 && (0 == s.compare(s.length() - 2, 2, "/*")))
{
- result.require_category_name_part(CategoryNamePart(s.substr(0, s.length() - 2)));
+ result.category_name_part(CategoryNamePart(s.substr(0, s.length() - 2)));
}
else if (s == "*")
throw PackageDepSpecError("Use '*/*' not '*' to match everything");
else if (std::string::npos != s.find('/'))
- result.require_package(QualifiedPackageName(s));
+ result.package(QualifiedPackageName(s));
else
{
throw PackageDepSpecError("Need an explicit category specified");
@@ -130,7 +131,7 @@ namespace
throw PackageDepSpecError("Got empty dep spec");
}
- bool user_remove_trailing_square_bracket_if_exists(std::string & s, MutablePackageDepSpecData & result,
+ bool user_remove_trailing_square_bracket_if_exists(std::string & s, PartiallyMadePackageDepSpec & result,
bool & had_bracket_version_requirements)
{
std::string::size_type use_group_p;
@@ -155,18 +156,81 @@ namespace
case '>':
case '=':
case '~':
- parse_elike_version_range(flag, result, { epdso_nice_equal_star }, user_version_spec_options(), had_bracket_version_requirements);
+ {
+ char needed_mode(0);
+
+ while (! flag.empty())
+ {
+ Context cc("When parsing [] segment '" + flag + "':");
+
+ std::string op;
+ std::string::size_type opos(0);
+ while (opos < flag.length())
+ if (std::string::npos == std::string("><=~").find(flag.at(opos)))
+ break;
+ else
+ ++opos;
+
+ op = flag.substr(0, opos);
+ flag.erase(0, opos);
+
+ if (op.empty())
+ throw PackageDepSpecError("Missing operator inside []");
+
+ VersionOperator vop(op);
+
+ std::string ver;
+ opos = flag.find_first_of("|&");
+ if (std::string::npos == opos)
+ {
+ ver = flag;
+ flag.clear();
+ }
+ else
+ {
+ if (0 == needed_mode)
+ needed_mode = flag.at(opos);
+ else if (needed_mode != flag.at(opos))
+ throw PackageDepSpecError("Mixed & and | inside []");
+
+ result.version_requirements_mode((flag.at(opos) == '|' ? vr_or : vr_and));
+ ver = flag.substr(0, opos++);
+ flag.erase(0, opos);
+ }
+
+ if (ver.empty())
+ throw PackageDepSpecError("Missing version after operator '" + stringify(vop) + " inside []");
+
+ if ('*' == ver.at(ver.length() - 1))
+ {
+ ver.erase(ver.length() - 1);
+ if (vop == vo_equal)
+ vop = vo_nice_equal_star;
+ else
+ throw PackageDepSpecError("Invalid use of * with operator '" + stringify(vop) + " inside []");
+ }
+
+ VersionSpec vs(ver, user_version_spec_options());
+ result.version_requirement(make_named_values<VersionRequirement>(
+ n::version_operator() = vop,
+ n::version_spec() = vs));
+ had_bracket_version_requirements = true;
+ }
+ }
break;
case '.':
{
- auto k(parse_user_key_requirement(flag.substr(1)));
- result.require_key(std::get<0>(k), std::get<1>(k), std::get<2>(k), std::get<3>(k));
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req(std::make_shared<UserKeyRequirement>(flag.substr(1)));
+ result.additional_requirement(req);
}
break;
default:
- result.require_choice(parse_elike_use_requirement(flag, { }));
+ {
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req(parse_elike_use_requirement(flag, { }));
+ result.additional_requirement(req);
+ }
break;
};
@@ -176,18 +240,18 @@ namespace
}
void
- user_remove_trailing_slot_if_exists(std::string & s, MutablePackageDepSpecData & result)
+ user_remove_trailing_slot_if_exists(std::string & s, PartiallyMadePackageDepSpec & result)
{
std::string::size_type slot_p(s.rfind(':'));
if (std::string::npos != slot_p)
{
- result.require_exact_slot(SlotName(s.substr(slot_p + 1)), false);
+ result.slot_requirement(std::make_shared<UserSlotExactRequirement>(SlotName(s.substr(slot_p + 1))));
s.erase(slot_p);
}
}
void
- parse_rhs(MutablePackageDepSpecData & reqs, const std::string & req)
+ parse_rhs(PartiallyMadePackageDepSpec & reqs, const std::string & req)
{
if (req.empty())
throw PackageDepSpecError("Invalid empty :: requirement");
@@ -197,29 +261,37 @@ namespace
if ('?' == req.at(req.length() - 1))
{
if (req.length() >= 2 && '?' == req.at(req.length() - 2))
- reqs.require_installable_to_path(FSPath(req.substr(0, req.length() - 2)), true);
+ reqs.installable_to_path(make_named_values<InstallableToPath>(
+ n::include_masked() = true,
+ n::path() = FSPath(req.substr(0, req.length() - 2))));
else
- reqs.require_installable_to_path(FSPath(req.substr(0, req.length() - 1)), false);
+ reqs.installable_to_path(make_named_values<InstallableToPath>(
+ n::include_masked() = false,
+ n::path() = FSPath(req.substr(0, req.length() - 1))));
}
else
- reqs.require_installed_at_path(FSPath(req));
+ reqs.installed_at_path(FSPath(req));
}
else
{
if ('?' == req.at(req.length() - 1))
{
if (req.length() >= 3 && '?' == req.at(req.length() - 2))
- reqs.require_installable_to_repository(RepositoryName(req.substr(0, req.length() - 2)), true);
+ reqs.installable_to_repository(make_named_values<InstallableToRepository>(
+ n::include_masked() = true,
+ n::repository() = RepositoryName(req.substr(0, req.length() - 2))));
else
- reqs.require_installable_to_repository(RepositoryName(req.substr(0, req.length() - 1)), false);
+ reqs.installable_to_repository(make_named_values<InstallableToRepository>(
+ n::include_masked() = false,
+ n::repository() = RepositoryName(req.substr(0, req.length() - 1))));
}
else
- reqs.require_in_repository(RepositoryName(req));
+ reqs.in_repository(RepositoryName(req));
}
}
void
- user_remove_trailing_repo_if_exists(std::string & s, MutablePackageDepSpecData & result)
+ user_remove_trailing_repo_if_exists(std::string & s, PartiallyMadePackageDepSpec & result)
{
std::string::size_type repo_p;
if (std::string::npos == ((repo_p = s.rfind("::"))))
@@ -245,9 +317,14 @@ namespace
parse_rhs(result, right);
if (! left.empty())
- result.require_from_repository(RepositoryName(left));
+ result.from_repository(RepositoryName(left));
}
}
+
+ const PartiallyMadePackageDepSpecOptions fixed_options_for_partially_made_package_dep_spec(PartiallyMadePackageDepSpecOptions o)
+ {
+ return o;
+ }
}
PackageDepSpec
@@ -259,10 +336,11 @@ paludis::parse_user_package_dep_spec(const std::string & ss, const Environment *
Context context("When parsing user package dep spec '" + ss + "':");
bool had_bracket_version_requirements(false);
+ PartiallyMadePackageDepSpecOptions o;
return partial_parse_generic_elike_package_dep_spec(ss, make_named_values<GenericELikePackageDepSpecParseFunctions>(
n::add_package_requirement() = std::bind(&user_add_package_requirement, _1, _2, env, options, filter),
- n::add_version_requirement() = std::bind(&elike_add_version_requirement, _1, _2, _3, _4),
+ n::add_version_requirement() = std::bind(&elike_add_version_requirement, _1, _2, _3),
n::check_sanity() = std::bind(&user_check_sanity, _1, options, env),
n::get_remove_trailing_version() = std::bind(&elike_get_remove_trailing_version, _1,
user_version_spec_options()),
@@ -270,7 +348,7 @@ paludis::parse_user_package_dep_spec(const std::string & ss, const Environment *
ELikePackageDepSpecOptions() + epdso_allow_tilde_greater_deps + epdso_nice_equal_star),
n::has_version_operator() = std::bind(&elike_has_version_operator, _1,
std::cref(had_bracket_version_requirements), ELikePackageDepSpecOptions()),
- n::options_for_partially_made_package_dep_spec() = return_literal_function(PackageDepSpecDataOptions()),
+ n::options_for_partially_made_package_dep_spec() = std::bind(&fixed_options_for_partially_made_package_dep_spec, std::cref(o)),
n::remove_trailing_repo_if_exists() = std::bind(&user_remove_trailing_repo_if_exists, _1, _2),
n::remove_trailing_slot_if_exists() = std::bind(&user_remove_trailing_slot_if_exists, _1, _2),
n::remove_trailing_square_bracket_if_exists() = std::bind(&user_remove_trailing_square_bracket_if_exists,
@@ -286,10 +364,11 @@ paludis::envless_parse_package_dep_spec_for_tests(const std::string & ss)
Context context("When parsing test package dep spec '" + ss + "':");
bool had_bracket_version_requirements(false);
+ PartiallyMadePackageDepSpecOptions o;
return partial_parse_generic_elike_package_dep_spec(ss, make_named_values<GenericELikePackageDepSpecParseFunctions>(
n::add_package_requirement() = std::bind(&envless_add_package_requirement, _1, _2),
- n::add_version_requirement() = std::bind(&elike_add_version_requirement, _1, _2, _3, _4),
+ n::add_version_requirement() = std::bind(&elike_add_version_requirement, _1, _2, _3),
n::check_sanity() = std::bind(&test_check_sanity, _1),
n::get_remove_trailing_version() = std::bind(&elike_get_remove_trailing_version, _1,
user_version_spec_options()),
@@ -297,7 +376,7 @@ paludis::envless_parse_package_dep_spec_for_tests(const std::string & ss)
ELikePackageDepSpecOptions() + epdso_allow_tilde_greater_deps + epdso_nice_equal_star),
n::has_version_operator() = std::bind(&elike_has_version_operator, _1,
std::cref(had_bracket_version_requirements), ELikePackageDepSpecOptions()),
- n::options_for_partially_made_package_dep_spec() = return_literal_function(PackageDepSpecDataOptions()),
+ n::options_for_partially_made_package_dep_spec() = std::bind(&fixed_options_for_partially_made_package_dep_spec, std::cref(o)),
n::remove_trailing_repo_if_exists() = std::bind(&user_remove_trailing_repo_if_exists, _1, _2),
n::remove_trailing_slot_if_exists() = std::bind(&user_remove_trailing_slot_if_exists, _1, _2),
n::remove_trailing_square_bracket_if_exists() = std::bind(&user_remove_trailing_square_bracket_if_exists,
@@ -305,76 +384,612 @@ paludis::envless_parse_package_dep_spec_for_tests(const std::string & ss)
));
}
+UserSlotExactRequirement::UserSlotExactRequirement(const SlotName & s) :
+ _s(s)
+{
+}
+const SlotName
+UserSlotExactRequirement::slot() const
+{
+ return _s;
+}
+
+const std::string
+UserSlotExactRequirement::as_string() const
+{
+ return ":" + stringify(_s);
+}
+
GotASetNotAPackageDepSpec::GotASetNotAPackageDepSpec(const std::string & s) throw () :
Exception("'" + s + "' is a set, not a package")
{
}
-VersionSpecOptions
-paludis::user_version_spec_options()
+namespace paludis
{
- return { vso_flexible_dashes, vso_flexible_dots,
- vso_ignore_case, vso_letters_anywhere, vso_dotted_suffixes };
+ template <>
+ struct Imp<UserKeyRequirement>
+ {
+ std::string key;
+ std::string value;
+ char op;
+
+ Imp(const std::string & s)
+ {
+ std::string::size_type p(s.find_first_of("=<>?"));
+ if (std::string::npos == p)
+ throw PackageDepSpecError("Expected an =, a <, a > or a ? inside '[." + s + "]'");
+
+ key = s.substr(0, p);
+ value = s.substr(p + 1);
+ op = s.at(p);
+
+ if (op == '?' && ! value.empty())
+ throw PackageDepSpecError("Operator '?' takes no value inside '[." + s + "]'");
+ }
+ };
}
-std::tuple<KeyRequirementKeyType, std::string, KeyRequirementOperation, std::string>
-paludis::parse_user_key_requirement(const std::string & s)
+UserKeyRequirement::UserKeyRequirement(const std::string & s) :
+ _imp(s)
{
- std::string::size_type p(s.find_first_of("=<>?~"));
- if (std::string::npos == p)
- throw PackageDepSpecError("[." + s + "] contains no operator");
+}
- std::string key, value;
- KeyRequirementOperation op(last_kro);
+UserKeyRequirement::~UserKeyRequirement()
+{
+}
- if (s.at(p) == '?')
+namespace
+{
+ std::string stringify_contents_entry(const ContentsEntry & e)
{
- if (s.length() - 1 != p)
- throw PackageDepSpecError("[." + s + "] uses a key with operator '?'");
- else
+ return stringify(e.location_key()->parse_value());
+ }
+
+ struct StringifyEqual
+ {
+ const std::string pattern;
+
+ StringifyEqual(const std::string & p) :
+ pattern(p)
{
- key = s.substr(0, p);
- op = kro_question;
}
- }
- else
+
+ template <typename T_>
+ bool operator() (const T_ & t) const
+ {
+ return stringify(t) == pattern;
+ }
+
+ bool operator() (const ContentsEntry & e) const
+ {
+ return stringify_contents_entry(e) == pattern;
+ }
+ };
+
+ struct SpecTreeSearcher
{
- switch (s.at(p))
+ const Environment * const env;
+ const std::shared_ptr<const PackageID> id;
+ const std::string pattern;
+
+ SpecTreeSearcher(const Environment * const e, const std::shared_ptr<const PackageID> & i, const std::string & p) :
+ env(e),
+ id(i),
+ pattern(p)
{
- case '=': op = kro_equals; break;
- case '~': op = kro_tilde; break;
- case '<': op = kro_less_than; break;
- case '>': op = kro_greater_than; break;
- default:
- throw PackageDepSpecError("[." + s + "] unknown operator");
}
- key = s.substr(0, p);
- value = s.substr(p + 1);
- }
- KeyRequirementKeyType type(krkt_id);
- if (0 == key.compare(0, 3, "::$", 0, 3))
+ bool visit(const GenericSpecTree::NodeType<AllDepSpec>::Type & n) const
+ {
+ return indirect_iterator(n.end()) != std::find_if(indirect_iterator(n.begin()), indirect_iterator(n.end()),
+ accept_visitor_returning<bool>(*this));
+ }
+
+ bool visit(const GenericSpecTree::NodeType<AnyDepSpec>::Type & n) const
+ {
+ return indirect_iterator(n.end()) != std::find_if(indirect_iterator(n.begin()), indirect_iterator(n.end()),
+ accept_visitor_returning<bool>(*this));
+ }
+
+ bool visit(const GenericSpecTree::NodeType<ExactlyOneDepSpec>::Type & n) const
+ {
+ return indirect_iterator(n.end()) != std::find_if(indirect_iterator(n.begin()), indirect_iterator(n.end()),
+ accept_visitor_returning<bool>(*this));
+ }
+
+ bool visit(const GenericSpecTree::NodeType<ConditionalDepSpec>::Type & n) const
+ {
+ if (n.spec()->condition_met(env, id))
+ return indirect_iterator(n.end()) != std::find_if(indirect_iterator(n.begin()), indirect_iterator(n.end()),
+ accept_visitor_returning<bool>(*this));
+ else
+ return false;
+ }
+
+ bool visit(const GenericSpecTree::NodeType<NamedSetDepSpec>::Type & n) const
+ {
+ return stringify(*n.spec()) == pattern;
+ }
+
+ bool visit(const GenericSpecTree::NodeType<PlainTextDepSpec>::Type & n) const
+ {
+ return stringify(*n.spec()) == pattern;
+ }
+
+ bool visit(const GenericSpecTree::NodeType<PackageDepSpec>::Type & n) const
+ {
+ return stringify(*n.spec()) == pattern;
+ }
+
+ bool visit(const GenericSpecTree::NodeType<BlockDepSpec>::Type & n) const
+ {
+ return stringify(*n.spec()) == pattern;
+ }
+
+ bool visit(const GenericSpecTree::NodeType<LicenseDepSpec>::Type & n) const
+ {
+ return stringify(*n.spec()) == pattern;
+ }
+
+ bool visit(const GenericSpecTree::NodeType<SimpleURIDepSpec>::Type & n) const
+ {
+ return stringify(*n.spec()) == pattern;
+ }
+
+ bool visit(const GenericSpecTree::NodeType<FetchableURIDepSpec>::Type & n) const
+ {
+ return stringify(*n.spec()) == pattern;
+ }
+
+ bool visit(const GenericSpecTree::NodeType<DependenciesLabelsDepSpec>::Type & n) const
+ {
+ return indirect_iterator(n.spec()->end()) != std::find_if(indirect_iterator(n.spec()->begin()),
+ indirect_iterator(n.spec()->end()), StringifyEqual(pattern));
+ }
+
+ bool visit(const GenericSpecTree::NodeType<URILabelsDepSpec>::Type & n) const
+ {
+ return indirect_iterator(n.spec()->end()) != std::find_if(indirect_iterator(n.spec()->begin()),
+ indirect_iterator(n.spec()->end()), StringifyEqual(pattern));
+ }
+
+ bool visit(const GenericSpecTree::NodeType<PlainTextLabelDepSpec>::Type & n) const
+ {
+ return stringify(*n.spec()) == pattern;
+ }
+ };
+
+ struct KeyComparator
{
- type = krkt_repo_role;
- key.erase(0, 3);
+ const Environment * const env;
+ const std::shared_ptr<const PackageID> id;
+ const std::string pattern;
+ const char op;
+
+ KeyComparator(const Environment * const e, const std::shared_ptr<const PackageID> & i,
+ const std::string & p, const char o) :
+ env(e),
+ id(i),
+ pattern(p),
+ op(o)
+ {
+ }
+
+ bool visit(const MetadataSectionKey &) const
+ {
+ return false;
+ }
+
+ bool visit(const MetadataTimeKey & k) const
+ {
+ switch (op)
+ {
+ case '=':
+ return pattern == stringify(k.parse_value().seconds());
+ case '<':
+ return k.parse_value().seconds() < destringify<time_t>(pattern);
+ case '>':
+ return k.parse_value().seconds() > destringify<time_t>(pattern);
+ }
+
+ return false;
+ }
+
+ bool visit(const MetadataValueKey<std::string> & k) const
+ {
+ return pattern == stringify(k.parse_value());
+ }
+
+ bool visit(const MetadataValueKey<SlotName> & k) const
+ {
+ return pattern == stringify(k.parse_value());
+ }
+
+ bool visit(const MetadataValueKey<FSPath> & k) const
+ {
+ return pattern == stringify(k.parse_value());
+ }
+
+ bool visit(const MetadataValueKey<bool> & k) const
+ {
+ return pattern == stringify(k.parse_value());
+ }
+
+ bool visit(const MetadataValueKey<long> & k) const
+ {
+ switch (op)
+ {
+ case '=':
+ return pattern == stringify(k.parse_value());
+ case '<':
+ return k.parse_value() < destringify<long>(pattern);
+ case '>':
+ return k.parse_value() > destringify<long>(pattern);
+ }
+
+ return false;
+ }
+
+ bool visit(const MetadataValueKey<std::shared_ptr<const Choices> > &) const
+ {
+ return false;
+ }
+
+ bool visit(const MetadataValueKey<std::shared_ptr<const Contents> > & s) const
+ {
+ auto v(s.parse_value());
+ switch (op)
+ {
+ case '=':
+ return pattern == join(indirect_iterator(v->begin()), indirect_iterator(v->end()), " ",
+ stringify_contents_entry);
+ case '<':
+ return indirect_iterator(v->end()) != std::find_if(
+ indirect_iterator(v->begin()),
+ indirect_iterator(v->end()),
+ StringifyEqual(pattern));
+ }
+
+ return false;
+ }
+
+ bool visit(const MetadataValueKey<std::shared_ptr<const PackageID> > & k) const
+ {
+ return pattern == stringify(*k.parse_value());
+ }
+
+ bool visit(const MetadataSpecTreeKey<DependencySpecTree> & s) const
+ {
+ switch (op)
+ {
+ case '=':
+ return false;
+ case '<':
+ return s.parse_value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
+ }
+
+ return false;
+ }
+
+ bool visit(const MetadataSpecTreeKey<SetSpecTree> & s) const
+ {
+ switch (op)
+ {
+ case '=':
+ return false;
+ case '<':
+ return s.parse_value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
+ }
+
+ return false;
+ }
+
+ bool visit(const MetadataSpecTreeKey<PlainTextSpecTree> & s) const
+ {
+ switch (op)
+ {
+ case '=':
+ return false;
+ case '<':
+ return s.parse_value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
+ }
+
+ return false;
+ }
+
+ bool visit(const MetadataSpecTreeKey<RequiredUseSpecTree> & s) const
+ {
+ switch (op)
+ {
+ case '=':
+ return false;
+ case '<':
+ return s.parse_value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
+ }
+
+ return false;
+ }
+
+ bool visit(const MetadataSpecTreeKey<ProvideSpecTree> & s) const
+ {
+ switch (op)
+ {
+ case '=':
+ return false;
+ case '<':
+ return s.parse_value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
+ }
+
+ return false;
+ }
+
+ bool visit(const MetadataSpecTreeKey<SimpleURISpecTree> & s) const
+ {
+ switch (op)
+ {
+ case '=':
+ return false;
+ case '<':
+ return s.parse_value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
+ }
+
+ return false;
+ }
+
+ bool visit(const MetadataSpecTreeKey<FetchableURISpecTree> & s) const
+ {
+ switch (op)
+ {
+ case '=':
+ return false;
+ case '<':
+ return s.parse_value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
+ }
+
+ return false;
+ }
+
+ bool visit(const MetadataSpecTreeKey<LicenseSpecTree> & s) const
+ {
+ switch (op)
+ {
+ case '=':
+ return false;
+ case '<':
+ return s.parse_value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
+ }
+
+ return false;
+ }
+
+ bool visit(const MetadataCollectionKey<FSPathSequence> & s) const
+ {
+ auto v(s.parse_value());
+ switch (op)
+ {
+ case '=':
+ return pattern == join(v->begin(), v->end(), " ");
+ case '<':
+ return v->end() != std::find_if(v->begin(), v->end(),
+ StringifyEqual(pattern));
+ }
+
+ return false;
+ }
+
+ bool visit(const MetadataCollectionKey<PackageIDSequence> & s) const
+ {
+ auto v(s.parse_value());
+ switch (op)
+ {
+ case '=':
+ return pattern == join(indirect_iterator(v->begin()), indirect_iterator(v->end()), " ");
+ case '<':
+ return indirect_iterator(v->end()) != std::find_if(
+ indirect_iterator(v->begin()),
+ indirect_iterator(v->end()),
+ StringifyEqual(pattern));
+ }
+
+ return false;
+ }
+
+ bool visit(const MetadataCollectionKey<Sequence<std::string> > & s) const
+ {
+ auto v(s.parse_value());
+ switch (op)
+ {
+ case '=':
+ return pattern == join(v->begin(), v->end(), " ");
+ case '<':
+ return v->end() != std::find_if(v->begin(), v->end(),
+ StringifyEqual(pattern));
+ }
+
+ return false;
+ }
+
+ bool visit(const MetadataCollectionKey<Set<std::string> > & s) const
+ {
+ auto v(s.parse_value());
+ switch (op)
+ {
+ case '=':
+ return pattern == join(v->begin(), v->end(), " ");
+ case '<':
+ return v->end() != std::find_if(v->begin(), v->end(),
+ StringifyEqual(pattern));
+ }
+
+ return false;
+ }
+
+ bool visit(const MetadataCollectionKey<Map<std::string, std::string> > &) const
+ {
+ return false;
+ }
+
+ bool visit(const MetadataCollectionKey<KeywordNameSet> & s) const
+ {
+ auto v(s.parse_value());
+ switch (op)
+ {
+ case '=':
+ return pattern == join(v->begin(), v->end(), " ");
+ case '<':
+ return v->end() != std::find_if(v->begin(), v->end(),
+ StringifyEqual(pattern));
+ }
+
+ return false;
+ }
+ };
+}
+
+const std::pair<bool, std::string>
+UserKeyRequirement::requirement_met(
+ const Environment * const env,
+ const ChangedChoices * const,
+ const std::shared_ptr<const PackageID> & id,
+ const std::shared_ptr<const PackageID> & from_id,
+ const ChangedChoices * const) const
+{
+ Context context("When working out whether '" + stringify(*id) + "' matches " + as_raw_string() + ":");
+
+ const MetadataKey * key(0);
+
+ auto repo(env->fetch_repository(id->repository_name()));
+ if (0 == _imp->key.compare(0, 3, "::$"))
+ {
+ if (_imp->key == "::$format")
+ key = repo->format_key().get();
+ else if (_imp->key == "::$location")
+ key = repo->location_key().get();
+ else if (_imp->key == "::$installed_root")
+ key = repo->installed_root_key().get();
+ else if (_imp->key == "::$accept_keywords")
+ key = repo->accept_keywords_key().get();
+ else if (_imp->key == "::$sync_host")
+ key = repo->sync_host_key().get();
}
- else if (0 == key.compare(0, 2, "::2", 0, 2))
+ else if (0 == _imp->key.compare(0, 1, "$"))
{
- type = krkt_repo;
- key.erase(0, 2);
+ if (_imp->key == "$behaviours")
+ key = id->behaviours_key().get();
+ else if (_imp->key == "$build_dependencies")
+ key = id->build_dependencies_key().get();
+ else if (_imp->key == "$choices")
+ key = id->choices_key().get();
+ else if (_imp->key == "$contained_in")
+ key = id->contained_in_key().get();
+ else if (_imp->key == "$contains")
+ key = id->contains_key().get();
+ else if (_imp->key == "$contents")
+ key = id->contents_key().get();
+ else if (_imp->key == "$dependencies")
+ key = id->dependencies_key().get();
+ else if (_imp->key == "$fetches")
+ key = id->fetches_key().get();
+ else if (_imp->key == "$from_repositories")
+ key = id->from_repositories_key().get();
+ else if (_imp->key == "$fs_location")
+ key = id->fs_location_key().get();
+ else if (_imp->key == "$homepage")
+ key = id->homepage_key().get();
+ else if (_imp->key == "$installed_time")
+ key = id->installed_time_key().get();
+ else if (_imp->key == "$keywords")
+ key = id->keywords_key().get();
+ else if (_imp->key == "$long_description")
+ key = id->long_description_key().get();
+ else if (_imp->key == "$post_dependencies")
+ key = id->post_dependencies_key().get();
+ else if (_imp->key == "$provide")
+ key = id->provide_key().get();
+ else if (_imp->key == "$run_dependencies")
+ key = id->run_dependencies_key().get();
+ else if (_imp->key == "$short_description")
+ key = id->short_description_key().get();
+ else if (_imp->key == "$slot")
+ key = id->slot_key().get();
+ else if (_imp->key == "$suggested_dependencies")
+ key = id->suggested_dependencies_key().get();
+ else if (_imp->key == "$virtual_for")
+ key = id->virtual_for_key().get();
}
- else if (0 == key.compare(0, 1, "$", 0, 1))
+ else if (0 == _imp->key.compare(0, 2, "::"))
{
- type = krkt_id_role;
- key.erase(0, 1);
+ Repository::MetadataConstIterator m(repo->find_metadata(_imp->key.substr(2)));
+ if (m != repo->end_metadata())
+ key = m->get();
}
- else if (0 == key.compare(0, 1, "(", 0, 1) && ')' == key.at(key.length() - 1))
+ else
{
- type = krkt_id_mask;
- key.erase(0, 1);
- key.erase(key.length() - 1);
+ PackageID::MetadataConstIterator m(id->find_metadata(_imp->key));
+ if (m != id->end_metadata())
+ key = m->get();
}
- return std::make_tuple(type, key, op, value);
+ if (! key)
+ return std::make_pair(false, as_human_string(from_id));
+
+ if (_imp->op == '?')
+ return std::make_pair(true, as_human_string(from_id));
+ else
+ {
+ KeyComparator c(env, id, _imp->value, _imp->op);
+ return std::make_pair(key->accept_returning<bool>(c), as_human_string(from_id));
+ }
}
+const std::string
+UserKeyRequirement::as_human_string(const std::shared_ptr<const PackageID> &) const
+{
+ std::string key_str;
+ if ((! _imp->key.empty()) && (_imp->key.at(0) == '$'))
+ key_str = "with role '" + _imp->key.substr(1) + "'";
+ else
+ key_str = "'" + _imp->key + "'";
+
+ switch (_imp->op)
+ {
+ case '=':
+ return "Key " + key_str + " has simple string value '" + _imp->value + "'";
+ case '<':
+ return "Key " + key_str + " contains or is less than '" + _imp->value + "'";
+ case '>':
+ return "Key " + key_str + " is greater than '" + _imp->value + "'";
+ case '?':
+ return "Key " + key_str + " exists";
+ }
+
+ throw InternalError(PALUDIS_HERE, "unknown op");
+}
+
+const std::string
+UserKeyRequirement::as_raw_string() const
+{
+ return "[." + _imp->key + std::string(1, _imp->op) + _imp->value + "]";
+}
+
+Tribool
+UserKeyRequirement::accumulate_changes_to_make_met(
+ const Environment * const,
+ const ChangedChoices * const,
+ const std::shared_ptr<const PackageID> &,
+ const std::shared_ptr<const PackageID> &,
+ ChangedChoices &) const
+{
+ return false;
+}
+
+VersionSpecOptions
+paludis::user_version_spec_options()
+{
+ return { vso_flexible_dashes, vso_flexible_dots,
+ vso_ignore_case, vso_letters_anywhere, vso_dotted_suffixes };
+}
+
+template class Pimp<UserKeyRequirement>;
+
diff --git a/paludis/user_dep_spec.hh b/paludis/user_dep_spec.hh
index aacacdd..d426845 100644
--- a/paludis/user_dep_spec.hh
+++ b/paludis/user_dep_spec.hh
@@ -22,13 +22,11 @@
#include <paludis/user_dep_spec-fwd.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/slot_requirement.hh>
#include <paludis/filter.hh>
-#include <paludis/package_dep_spec_requirement-fwd.hh>
-
+#include <paludis/additional_package_dep_spec_requirement.hh>
#include <paludis/util/pimp.hh>
-#include <tuple>
-
namespace paludis
{
/**
@@ -55,14 +53,65 @@ namespace paludis
PackageDepSpec envless_parse_package_dep_spec_for_tests(
const std::string &) PALUDIS_VISIBLE;
+ class PALUDIS_VISIBLE UserSlotExactRequirement :
+ public SlotExactRequirement
+ {
+ private:
+ const SlotName _s;
+
+ public:
+ ///\name Basic operations
+ ///\{
+
+ UserSlotExactRequirement(const SlotName &);
+
+ ///\}
+
+ virtual const SlotName slot() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::string as_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
/**
- * Split up a [.key=value] into its component parts.
+ * A key requirement for a user PackageDepSpec.
*
+ * \since 0.36
* \ingroup g_dep_spec
- * \since 0.61
*/
- std::tuple<KeyRequirementKeyType, std::string, KeyRequirementOperation, std::string> parse_user_key_requirement(
- const std::string &) PALUDIS_VISIBLE PALUDIS_ATTRIBUTE((warn_unused_result));
+ class PALUDIS_VISIBLE UserKeyRequirement :
+ public AdditionalPackageDepSpecRequirement
+ {
+ private:
+ Pimp<UserKeyRequirement> _imp;
+
+ public:
+ ///\name Basic operations
+ ///\{
+
+ UserKeyRequirement(const std::string &);
+ ~UserKeyRequirement();
+
+ ///\}
+
+ virtual const std::pair<bool, std::string> requirement_met(
+ const Environment * const, const ChangedChoices *,
+ const std::shared_ptr<const PackageID> &,
+ const std::shared_ptr<const PackageID> &,
+ const ChangedChoices * const) const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::string as_human_string(
+ const std::shared_ptr<const PackageID> &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::string as_raw_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual Tribool accumulate_changes_to_make_met(
+ const Environment * const,
+ const ChangedChoices * const,
+ const std::shared_ptr<const PackageID> &,
+ const std::shared_ptr<const PackageID> &,
+ ChangedChoices &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ extern template class Pimp<UserKeyRequirement>;
}
#endif
diff --git a/paludis/user_dep_spec_TEST.cc b/paludis/user_dep_spec_TEST.cc
index 8f265e1..a5fbf9e 100644
--- a/paludis/user_dep_spec_TEST.cc
+++ b/paludis/user_dep_spec_TEST.cc
@@ -20,8 +20,7 @@
#include <paludis/dep_spec.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/match_package.hh>
-#include <paludis/package_dep_spec_requirement.hh>
-#include <paludis/version_operator.hh>
+#include <paludis/version_requirements.hh>
#include <paludis/util/clone-impl.hh>
#include <paludis/util/sequence.hh>
@@ -33,7 +32,6 @@
#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/join.hh>
-#include <paludis/util/visitor_cast.hh>
#include <paludis/environments/test/test_environment.hh>
@@ -52,16 +50,6 @@ namespace
return stringify(v.version_operator()) + stringify(v.version_spec());
}
- std::string stringify_key_requirement(const KeyRequirement & k)
- {
- return k.as_raw_string();
- }
-
- std::string stringify_choice_requirement(const ChoiceRequirement & k)
- {
- return k.as_raw_string();
- }
-
class UserDepSpecTest :
public testing::Test
{
@@ -102,136 +90,90 @@ UserDepSpecTest::check_spec(
{
if (package.empty())
- EXPECT_TRUE(! spec.package_name_requirement());
+ EXPECT_TRUE(! spec.package_ptr());
else
{
- ASSERT_TRUE(bool(spec.package_name_requirement()));
- EXPECT_EQ(package, stringify(spec.package_name_requirement()->name()));
+ EXPECT_TRUE(bool(spec.package_ptr()));
+ EXPECT_EQ(package, stringify(*spec.package_ptr()));
}
if (category_name_part.empty())
- EXPECT_TRUE(! spec.category_name_part_requirement());
+ EXPECT_TRUE(! spec.category_name_part_ptr());
else
{
- ASSERT_TRUE(bool(spec.category_name_part_requirement()));
- EXPECT_EQ(category_name_part, stringify(spec.category_name_part_requirement()->name_part()));
+ EXPECT_TRUE(bool(spec.category_name_part_ptr()));
+ EXPECT_EQ(category_name_part, stringify(*spec.category_name_part_ptr()));
}
if (package_name_part.empty())
- EXPECT_TRUE(! spec.package_name_part_requirement());
+ EXPECT_TRUE(! spec.package_name_part_ptr());
else
{
- ASSERT_TRUE(bool(spec.package_name_part_requirement()));
- EXPECT_EQ(package_name_part, stringify(spec.package_name_part_requirement()->name_part()));
+ EXPECT_TRUE(bool(spec.package_name_part_ptr()));
+ EXPECT_EQ(package_name_part, stringify(*spec.package_name_part_ptr()));
}
if (! version_requirement_mode.empty())
- {
- int n(0);
- for (auto v(spec.requirements()->begin()), v_end(spec.requirements()->end()) ;
- v != v_end ; ++v)
- {
- auto v_ver(visitor_cast<const VersionRequirement>(**v));
- if (! v_ver)
- continue;
- ++n;
-
- if (1 != n)
- EXPECT_EQ(version_requirement_mode, stringify(v_ver->combiner()));
- }
-
- EXPECT_GT(n, 0);
- }
+ EXPECT_EQ(version_requirement_mode, stringify(spec.version_requirements_mode()));
+ if (version_requirements.empty())
+ EXPECT_TRUE((! spec.version_requirements_ptr()) || spec.version_requirements_ptr()->empty());
+ else
{
- std::string v_str;
-
- for (auto v(spec.requirements()->begin()), v_end(spec.requirements()->end()) ;
- v != v_end ; ++v)
- {
- auto v_ver(visitor_cast<const VersionRequirement>(**v));
- if (! v_ver)
- continue;
-
- if (! v_str.empty())
- v_str.append(", ");
- v_str.append(dump_version_requirement(*v_ver));
- }
-
- if (version_requirements.empty())
- EXPECT_TRUE(v_str.empty());
- else
- EXPECT_EQ(version_requirements, v_str);
+ EXPECT_TRUE(bool(spec.version_requirements_ptr()));
+ EXPECT_EQ(version_requirements, stringify(join(
+ spec.version_requirements_ptr()->begin(), spec.version_requirements_ptr()->end(), ", ", &dump_version_requirement)));
}
if (slot_requirement.empty())
- EXPECT_TRUE(! spec.exact_slot_requirement());
+ EXPECT_TRUE(! spec.slot_requirement_ptr());
else
{
- ASSERT_TRUE(bool(spec.exact_slot_requirement()));
- EXPECT_EQ(slot_requirement, ":" + stringify(spec.exact_slot_requirement()->name()));
+ EXPECT_TRUE(bool(spec.slot_requirement_ptr()));
+ EXPECT_EQ(slot_requirement, stringify(*spec.slot_requirement_ptr()));
}
if (from_repository.empty())
- EXPECT_TRUE(! spec.from_repository_requirement());
+ EXPECT_TRUE(! spec.from_repository_ptr());
else
{
- ASSERT_TRUE(bool(spec.from_repository_requirement()));
- EXPECT_EQ(from_repository, stringify(spec.from_repository_requirement()->name()));
+ EXPECT_TRUE(bool(spec.from_repository_ptr()));
+ EXPECT_EQ(from_repository, stringify(*spec.from_repository_ptr()));
}
if (in_repository.empty())
- EXPECT_TRUE(! spec.in_repository_requirement());
+ EXPECT_TRUE(! spec.in_repository_ptr());
else
{
- ASSERT_TRUE(bool(spec.in_repository_requirement()));
- EXPECT_EQ(in_repository, stringify(spec.in_repository_requirement()->name()));
+ EXPECT_TRUE(bool(spec.in_repository_ptr()));
+ EXPECT_EQ(in_repository, stringify(*spec.in_repository_ptr()));
}
+ if (additional_requirement.empty())
+ EXPECT_TRUE((! spec.additional_requirements_ptr()) || spec.additional_requirements_ptr()->empty());
+ else
{
- std::string c_str;
-
- for (auto v(spec.requirements()->begin()), v_end(spec.requirements()->end()) ;
- v != v_end ; ++v)
- {
- auto v_choice(visitor_cast<const ChoiceRequirement>(**v));
- if (v_choice)
- {
- if (! c_str.empty())
- c_str.append(", ");
- c_str.append(stringify_choice_requirement(*v_choice));
- }
-
- auto v_key(visitor_cast<const KeyRequirement>(**v));
- if (v_key)
- {
- if (! c_str.empty())
- c_str.append(", ");
- c_str.append(stringify_key_requirement(*v_key));
- }
- }
-
- if (additional_requirement.empty())
- EXPECT_TRUE(c_str.empty());
- else
- EXPECT_EQ(additional_requirement, c_str);
+ EXPECT_TRUE(bool(spec.additional_requirements_ptr()));
+ EXPECT_EQ(additional_requirement, stringify(join(
+ indirect_iterator(spec.additional_requirements_ptr()->begin()),
+ indirect_iterator(spec.additional_requirements_ptr()->end()), ", ")));
}
if (installed_at_path.empty())
- EXPECT_TRUE(! spec.installed_at_path_requirement());
+ EXPECT_TRUE(! spec.installed_at_path_ptr());
else
{
- ASSERT_TRUE(bool(spec.installed_at_path_requirement()));
- EXPECT_EQ(installed_at_path, stringify(spec.installed_at_path_requirement()->path()));
+ EXPECT_TRUE(bool(spec.installed_at_path_ptr()));
+ EXPECT_EQ(installed_at_path, stringify(*spec.installed_at_path_ptr()));
}
if (installable_to_path_f.empty())
- EXPECT_TRUE(! spec.installable_to_path_requirement());
+ EXPECT_TRUE(! spec.installable_to_path_ptr());
else
{
- ASSERT_TRUE(bool(spec.installable_to_path_requirement()));
- EXPECT_EQ(installable_to_path_f, stringify(spec.installable_to_path_requirement()->path()));
- EXPECT_EQ(installable_to_path_s, spec.installable_to_path_requirement()->include_masked());
+ EXPECT_TRUE(bool(spec.installable_to_path_ptr()));
+ EXPECT_EQ(installable_to_path_f, stringify(spec.installable_to_path_ptr()->path()));
+ EXPECT_EQ(installable_to_path_s, spec.installable_to_path_ptr()->include_masked());
}
}
@@ -302,9 +244,6 @@ TEST_F(UserDepSpecTest, Parsing)
PackageDepSpec r(parse_user_package_dep_spec("foo/bar[.$short_description=value]", &env, { }));
check_spec(r, "foo/bar", "", "", "", "", "", "", "", "[.$short_description=value]");
-
- PackageDepSpec s(parse_user_package_dep_spec("=foo/bar-1-r0", &env, { }));
- check_spec(s, "foo/bar", "", "", "=1-r0", "", "", "", "", "");
}
TEST_F(UserDepSpecTest, Unspecified)
diff --git a/paludis/version_operator.hh b/paludis/version_operator.hh
index cf05390..a548c60 100644
--- a/paludis/version_operator.hh
+++ b/paludis/version_operator.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2010, 2011 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2010 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
@@ -119,11 +119,6 @@ namespace paludis
return _v == other._v;
}
- std::size_t hash() const
- {
- return static_cast<std::size_t>(_v);
- }
-
///\}
};
diff --git a/paludis/version_requirements-fwd.hh b/paludis/version_requirements-fwd.hh
new file mode 100644
index 0000000..2528b85
--- /dev/null
+++ b/paludis/version_requirements-fwd.hh
@@ -0,0 +1,71 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * 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
+ * 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_VERSION_REQUIREMENTS_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_VERSION_REQUIREMENTS_FWD_HH 1
+
+#include <paludis/util/sequence-fwd.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/version_spec-fwd.hh>
+#include <memory>
+#include <iosfwd>
+
+/** \file
+ * Forward declarations for paludis/version_requirements.hh .
+ *
+ * \ingroup g_dep_spec
+ */
+
+namespace paludis
+{
+ class VersionRequirement;
+
+ /**
+ * A collection of VersionRequirement instances, usually for a
+ * PackageDepSpec.
+ *
+ * \see PackageDepSpec
+ * \ingroup g_dep_spec
+ */
+ typedef Sequence<VersionRequirement> VersionRequirements;
+
+ /**
+ * Whether our version requirements are an 'and' or an 'or' set.
+ *
+ * \see PackageDepSpec
+ * \ingroup g_dep_spec
+ */
+ enum VersionRequirementsMode
+ {
+ vr_or, ///\< Must match one
+ vr_and, ///\< Must match all
+ last_vr
+ };
+
+ /**
+ * Write a VersionRequirementsMode to a stream.
+ *
+ * \ingroup g_dep_spec
+ */
+ std::ostream &
+ operator<< (std::ostream &, const VersionRequirementsMode &) PALUDIS_VISIBLE;
+
+}
+
+#endif
diff --git a/paludis/version_requirements.cc b/paludis/version_requirements.cc
new file mode 100644
index 0000000..ece662c
--- /dev/null
+++ b/paludis/version_requirements.cc
@@ -0,0 +1,58 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * 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
+ * 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/version_requirements.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/sequence-impl.hh>
+#include <paludis/util/wrapped_forward_iterator-impl.hh>
+#include <paludis/util/wrapped_output_iterator-impl.hh>
+#include <paludis/util/make_named_values.hh>
+
+using namespace paludis;
+
+template class Sequence<VersionRequirement>;
+template class WrappedForwardIterator<Sequence<VersionRequirement>::ConstIteratorTag, const VersionRequirement>;
+template class WrappedOutputIterator<Sequence<VersionRequirement>::InserterTag, VersionRequirement>;
+
+std::ostream &
+paludis::operator<< (std::ostream & o, const VersionRequirementsMode & s)
+{
+ do
+ {
+ switch (s)
+ {
+ case vr_and:
+ o << "and";
+ continue;
+
+ case vr_or:
+ o << "or";
+ continue;
+
+ case last_vr:
+ ;
+ }
+
+ throw InternalError(PALUDIS_HERE, "Bad VersionRequirementsMode");
+ } while (false);
+
+ return o;
+}
+
diff --git a/paludis/version_requirements.hh b/paludis/version_requirements.hh
new file mode 100644
index 0000000..380adc0
--- /dev/null
+++ b/paludis/version_requirements.hh
@@ -0,0 +1,64 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006, 2007, 2008, 2010 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_VERSION_REQUIREMENTS_HH
+#define PALUDIS_GUARD_PALUDIS_VERSION_REQUIREMENTS_HH 1
+
+#include <paludis/version_requirements-fwd.hh>
+#include <paludis/version_operator.hh>
+#include <paludis/version_spec.hh>
+#include <paludis/util/named_value.hh>
+
+/** \file
+ * Declarations for version requirements classes.
+ *
+ * \ingroup g_dep_spec
+ *
+ * \section Examples
+ *
+ * - \ref example_dep_spec.cc "example_dep_spec.cc" (for specifications)
+ */
+
+namespace paludis
+{
+ namespace n
+ {
+ typedef Name<struct name_version_operator> version_operator;
+ typedef Name<struct name_version_spec> version_spec;
+ }
+
+ /**
+ * A requirement for a version, consisting of a VersionOperator and an associated
+ * VersionSpec.
+ *
+ * \ingroup g_dep_spec
+ * \see PackageDepSpec
+ * \see VersionSpec
+ * \see VersionOperator
+ * \see VersionRequirements
+ * \nosubgrouping
+ */
+ struct VersionRequirement
+ {
+ NamedValue<n::version_operator, VersionOperator> version_operator;
+ NamedValue<n::version_spec, VersionSpec> version_spec;
+ };
+}
+
+#endif
diff --git a/python/Makefile.am b/python/Makefile.am
index e0cf4f0..4a27595 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -42,6 +42,7 @@ IF_PYTHON_TESTS = \
repository_TEST.py \
selection_TEST.py \
version_operator_TEST.py \
+ version_requirements_TEST.py \
version_spec_TEST.py
IF_PYTHON_SOURCES = \
@@ -69,10 +70,10 @@ IF_PYTHON_SOURCES = \
nice_names-nn.hh nice_names-nn.cc \
log.cc \
package_id.cc \
- package_dep_spec_constraint.cc \
repository.cc \
selection.cc \
version_operator.cc \
+ version_requirements.cc \
version_spec.cc
BUILT_SOURCES = \
diff --git a/python/dep_spec.cc b/python/dep_spec.cc
index 20e6899..b53d3a7 100644
--- a/python/dep_spec.cc
+++ b/python/dep_spec.cc
@@ -26,10 +26,9 @@
#include <paludis/dep_spec.hh>
#include <paludis/environment.hh>
#include <paludis/user_dep_spec.hh>
+#include <paludis/version_requirements.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <paludis/dep_spec_data.hh>
-#include <paludis/package_dep_spec_requirement.hh>
-#include <paludis/version_spec.hh>
-#include <paludis/version_operator.hh>
#include <paludis/util/save.hh>
#include <paludis/util/stringify.hh>
@@ -40,7 +39,6 @@
#include <paludis/util/sequence-impl.hh>
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/accept_visitor.hh>
-#include <paludis/util/visitor_cast.hh>
#include <type_traits>
#include <list>
@@ -74,40 +72,37 @@ namespace paludis
template<>
struct Imp<PythonPackageDepSpec>
{
- std::shared_ptr<const NameRequirement> package_name_requirement;
- std::shared_ptr<const CategoryNamePartRequirement> category_name_part_requirement;
- std::shared_ptr<const PackageNamePartRequirement> package_name_part_requirement;
- std::shared_ptr<const VersionRequirementSequence> all_versions;
- std::shared_ptr<const AnySlotRequirement> any_slot;
- std::shared_ptr<const ExactSlotRequirement> exact_slot;
- std::shared_ptr<const InRepositoryRequirement> in_repository;
- std::shared_ptr<const FromRepositoryRequirement> from_repository;
- std::shared_ptr<const KeyRequirementSequence> all_keys;
- std::shared_ptr<const ChoiceRequirementSequence> all_choices;
+ std::shared_ptr<const QualifiedPackageName> package_ptr;
+ std::shared_ptr<const CategoryNamePart> category_name_part_ptr;
+ std::shared_ptr<const PackageNamePart> package_name_part_ptr;
+ std::shared_ptr<VersionRequirements> version_requirements;
+ VersionRequirementsMode version_requirements_mode;
+ std::shared_ptr<const SlotRequirement> slot;
+ std::shared_ptr<const RepositoryName> in_repository;
+ std::shared_ptr<const RepositoryName> from_repository;
+ std::shared_ptr<const AdditionalPackageDepSpecRequirements> additional_requirements;
const std::string str;
Imp(
- const std::shared_ptr<const NameRequirement> & q,
- const std::shared_ptr<const CategoryNamePartRequirement> & c,
- const std::shared_ptr<const PackageNamePartRequirement> & p,
- const std::shared_ptr<const VersionRequirementSequence> & v,
- const std::shared_ptr<const AnySlotRequirement> & s,
- const std::shared_ptr<const ExactSlotRequirement> & xs,
- const std::shared_ptr<const InRepositoryRequirement> & ri,
- const std::shared_ptr<const FromRepositoryRequirement> & rf,
- const std::shared_ptr<const KeyRequirementSequence> & k,
- const std::shared_ptr<const ChoiceRequirementSequence> & a,
+ const std::shared_ptr<const QualifiedPackageName> & q,
+ const std::shared_ptr<const CategoryNamePart> & c,
+ const std::shared_ptr<const PackageNamePart> & p,
+ const std::shared_ptr<VersionRequirements> & v,
+ const VersionRequirementsMode m,
+ const std::shared_ptr<const SlotRequirement> & s,
+ const std::shared_ptr<const RepositoryName> & ri,
+ const std::shared_ptr<const RepositoryName> & rf,
+ const std::shared_ptr<const AdditionalPackageDepSpecRequirements> & u,
const std::string & st) :
- package_name_requirement(q),
- category_name_part_requirement(c),
- package_name_part_requirement(p),
- all_versions(v),
- any_slot(s),
- exact_slot(xs),
+ package_ptr(q),
+ category_name_part_ptr(c),
+ package_name_part_ptr(p),
+ version_requirements(v),
+ version_requirements_mode(m),
+ slot(s),
in_repository(ri),
from_repository(rf),
- all_keys(k),
- all_choices(a),
+ additional_requirements(u),
str(st)
{
}
@@ -224,58 +219,43 @@ deep_copy(const std::shared_ptr<const T_> & x)
return std::shared_ptr<T_>();
}
-namespace
-{
- template <typename T_>
- std::shared_ptr<Sequence<std::shared_ptr<const T_> > > get_requirements(const std::shared_ptr<const PackageDepSpecRequirementSequence> & s)
- {
- auto result(std::make_shared<Sequence<std::shared_ptr<const T_> > >());
- for (auto i(s->begin()), i_end(s->end()) ;
- i != i_end ; ++i)
- {
- auto v(visitor_cast<const T_>(**i));
- if (! v)
- continue;
-
- result->push_back(std::static_pointer_cast<const T_>(*i));
- }
-
- return result;
- }
-}
-
PythonPackageDepSpec::PythonPackageDepSpec(const PackageDepSpec & p) :
PythonStringDepSpec(p.text()),
_imp(
- p.package_name_requirement(),
- p.category_name_part_requirement(),
- p.package_name_part_requirement(),
- get_requirements<VersionRequirement>(p.requirements()),
- p.any_slot_requirement(),
- p.exact_slot_requirement(),
- p.in_repository_requirement(),
- p.from_repository_requirement(),
- get_requirements<KeyRequirement>(p.requirements()),
- get_requirements<ChoiceRequirement>(p.requirements()),
+ deep_copy(p.package_ptr()),
+ deep_copy(p.category_name_part_ptr()),
+ deep_copy(p.package_name_part_ptr()),
+ std::make_shared<VersionRequirements>(),
+ p.version_requirements_mode(),
+ p.slot_requirement_ptr(),
+ deep_copy(p.in_repository_ptr()),
+ deep_copy(p.from_repository_ptr()),
+ p.additional_requirements_ptr(),
stringify(p))
{
+ if (p.version_requirements_ptr())
+ {
+ std::copy(p.version_requirements_ptr()->begin(), p.version_requirements_ptr()->end(),
+ _imp->version_requirements->back_inserter());
+ }
}
PythonPackageDepSpec::PythonPackageDepSpec(const PythonPackageDepSpec & p) :
PythonStringDepSpec(p.text()),
_imp(
- p.package_name_requirement(),
- p.category_name_part_requirement(),
- p.package_name_part_requirement(),
- p.all_version_requirements(),
- p.any_slot_requirement(),
- p.exact_slot_requirement(),
- p.in_repository_requirement(),
- p.from_repository_requirement(),
- p.all_key_requirements(),
- p.all_choice_requirements(),
+ deep_copy(p.package_ptr()),
+ deep_copy(p.category_name_part_ptr()),
+ deep_copy(p.package_name_part_ptr()),
+ std::make_shared<VersionRequirements>(),
+ p.version_requirements_mode(),
+ p.slot_requirement_ptr(),
+ deep_copy(p.in_repository_ptr()),
+ deep_copy(p.from_repository_ptr()),
+ p.additional_requirements_ptr(),
p.py_str())
{
+ std::copy(p.version_requirements_ptr()->begin(), p.version_requirements_ptr()->end(),
+ _imp->version_requirements->back_inserter());
}
PythonPackageDepSpec::~PythonPackageDepSpec()
@@ -284,51 +264,43 @@ PythonPackageDepSpec::~PythonPackageDepSpec()
PythonPackageDepSpec::operator PackageDepSpec() const
{
- MutablePackageDepSpecData p({ });
+ PartiallyMadePackageDepSpec p((PartiallyMadePackageDepSpecOptions()));
- if (package_name_requirement())
- p.require_package(package_name_requirement()->name());
+ if (package_ptr())
+ p.package(*package_ptr());
- if (category_name_part_requirement())
- p.require_category_name_part(category_name_part_requirement()->name_part());
+ if (category_name_part_ptr())
+ p.category_name_part(*category_name_part_ptr());
- if (package_name_part_requirement())
- p.require_package_name_part(package_name_part_requirement()->name_part());
+ if (package_name_part_ptr())
+ p.package_name_part(*package_name_part_ptr());
- if (all_version_requirements())
- {
- for (auto i(all_version_requirements()->begin()), i_end(all_version_requirements()->end()) ;
- i != i_end ; ++i)
- p.require_version((*i)->combiner(), (*i)->version_operator(), (*i)->version_spec());
- }
-
- if (any_slot_requirement())
- p.require_any_slot(any_slot_requirement()->locking());
+ p.version_requirements_mode(version_requirements_mode());
- if (exact_slot_requirement())
- p.require_exact_slot(exact_slot_requirement()->name(), exact_slot_requirement()->locked());
+ if (slot_requirement_ptr())
+ p.slot_requirement(slot_requirement_ptr());
- if (in_repository_requirement())
- p.require_in_repository(in_repository_requirement()->name());
+ if (in_repository_ptr())
+ p.in_repository(*in_repository_ptr());
- if (from_repository_requirement())
- p.require_from_repository(from_repository_requirement()->name());
+ if (from_repository_ptr())
+ p.from_repository(*from_repository_ptr());
- if (all_choice_requirements())
+ if (additional_requirements_ptr())
{
- for (ChoiceRequirementSequence::ConstIterator i(all_choice_requirements()->begin()),
- i_end(all_choice_requirements()->end()) ; i != i_end ; ++i)
- p.require_choice(*i);
+ for (AdditionalPackageDepSpecRequirements::ConstIterator i(additional_requirements_ptr()->begin()),
+ i_end(additional_requirements_ptr()->end()) ; i != i_end ; ++i)
+ p.additional_requirement(*i);
}
- if (all_key_requirements())
+ if (version_requirements_ptr())
{
- for (auto i(all_key_requirements()->begin()), i_end(all_key_requirements()->end()) ;
- i != i_end ; ++i)
- p.require_key((*i)->key_type(), (*i)->key(), (*i)->operation(), (*i)->pattern());
+ for (VersionRequirements::ConstIterator i(version_requirements_ptr()->begin()),
+ i_end(version_requirements_ptr()->end()) ; i != i_end ; ++i)
+ p.version_requirement(*i);
}
- return PackageDepSpec(p);
+ return p.to_package_dep_spec();
}
@@ -337,64 +309,64 @@ PythonPackageDepSpec::operator std::shared_ptr<PackageDepSpec>() const
return std::make_shared<PackageDepSpec>(*this);
}
-const std::shared_ptr<const NameRequirement>
-PythonPackageDepSpec::package_name_requirement() const
+std::shared_ptr<const QualifiedPackageName>
+PythonPackageDepSpec::package_ptr() const
{
- return _imp->package_name_requirement;
+ return _imp->package_ptr;
}
-const std::shared_ptr<const PackageNamePartRequirement>
-PythonPackageDepSpec::package_name_part_requirement() const
+std::shared_ptr<const PackageNamePart>
+PythonPackageDepSpec::package_name_part_ptr() const
{
- return _imp->package_name_part_requirement;
+ return _imp->package_name_part_ptr;
}
-const std::shared_ptr<const CategoryNamePartRequirement>
-PythonPackageDepSpec::category_name_part_requirement() const
+std::shared_ptr<const CategoryNamePart>
+PythonPackageDepSpec::category_name_part_ptr() const
{
- return _imp->category_name_part_requirement;
+ return _imp->category_name_part_ptr;
}
-const std::shared_ptr<const VersionRequirementSequence>
-PythonPackageDepSpec::all_version_requirements() const
+std::shared_ptr<const VersionRequirements>
+PythonPackageDepSpec::version_requirements_ptr() const
{
- return _imp->all_versions;
+ return _imp->version_requirements;
}
-const std::shared_ptr<const AnySlotRequirement>
-PythonPackageDepSpec::any_slot_requirement() const
+VersionRequirementsMode
+PythonPackageDepSpec::version_requirements_mode() const
{
- return _imp->any_slot;
+ return _imp->version_requirements_mode;
}
-const std::shared_ptr<const ExactSlotRequirement>
-PythonPackageDepSpec::exact_slot_requirement() const
+void
+PythonPackageDepSpec::set_version_requirements_mode(const VersionRequirementsMode m)
{
- return _imp->exact_slot;
+ _imp->version_requirements_mode = m;
}
-const std::shared_ptr<const InRepositoryRequirement>
-PythonPackageDepSpec::in_repository_requirement() const
+std::shared_ptr<const SlotRequirement>
+PythonPackageDepSpec::slot_requirement_ptr() const
{
- return _imp->in_repository;
+ return _imp->slot;
}
-const std::shared_ptr<const FromRepositoryRequirement>
-PythonPackageDepSpec::from_repository_requirement() const
+std::shared_ptr<const RepositoryName>
+PythonPackageDepSpec::in_repository_ptr() const
{
- return _imp->from_repository;
+ return _imp->in_repository;
}
-const std::shared_ptr<const ChoiceRequirementSequence>
-PythonPackageDepSpec::all_choice_requirements() const
+std::shared_ptr<const RepositoryName>
+PythonPackageDepSpec::from_repository_ptr() const
{
- return _imp->all_choices;
+ return _imp->from_repository;
}
-const std::shared_ptr<const KeyRequirementSequence>
-PythonPackageDepSpec::all_key_requirements() const
+std::shared_ptr<const AdditionalPackageDepSpecRequirements>
+PythonPackageDepSpec::additional_requirements_ptr() const
{
- return _imp->all_keys;
+ return _imp->additional_requirements;
}
std::string
@@ -1228,40 +1200,47 @@ void expose_dep_spec()
bp::no_init
)
- .add_property("package_name_requirement", &PythonPackageDepSpec::package_name_requirement,
- "[ro] NameRequirement\n"
- "Qualified package name requirement (may be None)."
+ .add_property("package", &PythonPackageDepSpec::package_ptr,
+ "[ro] QualifiedPackageName\n"
+ "Qualified package name."
+ )
+
+ .add_property("package_name_part", &PythonPackageDepSpec::package_name_part_ptr,
+ "[ro] PackageNamePart\n"
+ "Package name part (may be None)"
)
- .add_property("package_name_part_requirement", &PythonPackageDepSpec::package_name_part_requirement,
- "[ro] CategoryNamePartRequirement\n"
- "Package name part requirement (may be None)"
+ .add_property("category_name_part", &PythonPackageDepSpec::category_name_part_ptr,
+ "[ro] CategoryNamePart\n"
+ "Category name part (may be None)."
)
- .add_property("category_name_part_requirement", &PythonPackageDepSpec::category_name_part_requirement,
- "[ro] CategoryNamePartRequirement\n"
- "Category name part requirement (may be None)."
+ .add_property("version_requirements", &PythonPackageDepSpec::version_requirements_ptr,
+ "[ro] VersionRequirements\n"
+ "Version requirements (may be None)."
)
- .add_property("exact_slot", &PythonPackageDepSpec::exact_slot_requirement,
- "[ro] ExactSlotRequirement\n"
- "Exact slot requirement (may be None)."
+ .add_property("version_requirements_mode", &PythonPackageDepSpec::version_requirements_mode,
+ "[ro] VersionRequirementsMode\n"
+ "Version requirements mode."
)
- .add_property("any_slot", &PythonPackageDepSpec::any_slot_requirement,
- "[ro] AnySlotRequirement\n"
- "Any slot requirement (may be None)."
+#if 0
+ .add_property("slot", &PythonPackageDepSpec::slot_ptr,
+ "[ro] SlotName\n"
+ "Slot name (may be None)."
)
+#endif
- .add_property("in_repository_requirement", &PythonPackageDepSpec::in_repository_requirement,
- "[ro] InRepositoryRequirement\n"
- "In repository requirement (may be None)."
+ .add_property("in_repository", &PythonPackageDepSpec::in_repository_ptr,
+ "[ro] RepositoryName\n"
+ "In repository name (may be None)."
)
- .add_property("from_repository_requirement", &PythonPackageDepSpec::from_repository_requirement,
- "[ro] FromRepositoryRequirement\n"
- "From repository requirement (may be None)."
+ .add_property("from_repository", &PythonPackageDepSpec::from_repository_ptr,
+ "[ro] RepositoryName\n"
+ "From repository name (may be None)."
)
#if 0
diff --git a/python/dep_spec.hh b/python/dep_spec.hh
index a6e407f..1a10fc1 100644
--- a/python/dep_spec.hh
+++ b/python/dep_spec.hh
@@ -172,16 +172,16 @@ namespace paludis
operator PackageDepSpec() const;
operator std::shared_ptr<PackageDepSpec>() const;
- const std::shared_ptr<const NameRequirement> package_name_requirement() const;
- const std::shared_ptr<const PackageNamePartRequirement> package_name_part_requirement() const;
- const std::shared_ptr<const CategoryNamePartRequirement> category_name_part_requirement() const;
- const std::shared_ptr<const VersionRequirementSequence> all_version_requirements() const;
- const std::shared_ptr<const InRepositoryRequirement> in_repository_requirement() const;
- const std::shared_ptr<const FromRepositoryRequirement> from_repository_requirement() const;
- const std::shared_ptr<const ExactSlotRequirement> exact_slot_requirement() const;
- const std::shared_ptr<const AnySlotRequirement> any_slot_requirement() const;
- const std::shared_ptr<const KeyRequirementSequence> all_key_requirements() const;
- const std::shared_ptr<const ChoiceRequirementSequence> all_choice_requirements() const;
+ std::shared_ptr<const QualifiedPackageName> package_ptr() const;
+ std::shared_ptr<const PackageNamePart> package_name_part_ptr() const;
+ std::shared_ptr<const CategoryNamePart> category_name_part_ptr() const;
+ std::shared_ptr<const VersionRequirements> version_requirements_ptr() const;
+ VersionRequirementsMode version_requirements_mode() const;
+ void set_version_requirements_mode(const VersionRequirementsMode m);
+ std::shared_ptr<const SlotRequirement> slot_requirement_ptr() const;
+ std::shared_ptr<const RepositoryName> in_repository_ptr() const;
+ std::shared_ptr<const RepositoryName> from_repository_ptr() const;
+ std::shared_ptr<const AdditionalPackageDepSpecRequirements> additional_requirements_ptr() const;
std::string py_str() const;
};
diff --git a/python/dep_spec_TEST.py b/python/dep_spec_TEST.py
index da992cf..ec22662 100755
--- a/python/dep_spec_TEST.py
+++ b/python/dep_spec_TEST.py
@@ -64,12 +64,24 @@ class TestCase_1_DepSpecs(unittest.TestCase):
def test_05_package(self):
self.get_depspecs()
- self.assertEqual(str(self.pds.package_name_requirement.name), "foo/bar")
+ self.assertEqual(str(self.pds.package), "foo/bar")
def test_06_in_from_repository(self):
self.get_depspecs()
- self.assertEqual(str(self.pds.in_repository_requirement.name), "testrepo")
- self.assertEqual(self.pds.from_repository_requirement, None)
+ self.assertEqual(str(self.pds.in_repository), "testrepo")
+ self.assertEqual(self.pds.from_repository, None)
+
+ def test_07_version_requirements(self):
+ self.get_depspecs()
+ vrc = self.pds.version_requirements
+
+ self.assertEquals(len(list(vrc)), 1)
+ self.assertEquals(iter(vrc).next().version_spec, VersionSpec("1"))
+ self.assertEquals(iter(vrc).next().version_operator.value, VersionOperator(">=").value)
+
+ def test_08_version_requirements_mode(self):
+ self.get_depspecs()
+ self.assertEquals(self.pds.version_requirements_mode, VersionRequirementsMode.AND)
### def test_09_additional_requirements(self):
### spec = parse_user_package_dep_spec("foo/monkey[foo]", UserPackageDepSpecOptions())
diff --git a/python/generator_TEST.py b/python/generator_TEST.py
index a35833b..4d8b0de 100644
--- a/python/generator_TEST.py
+++ b/python/generator_TEST.py
@@ -2,7 +2,7 @@
# vim: set fileencoding=utf-8 sw=4 sts=4 et :
#
-# Copyright (c) 2008, 2011 Ciaran McCreesh
+# 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
@@ -35,8 +35,8 @@ class TestCase_01_Generator(unittest.TestCase):
self.assertEquals(str(Generator.Matches(parse_user_package_dep_spec("foo/bar",
env, []), MatchPackageOptions())), "packages matching foo/bar")
self.assertEquals(str(Generator.Matches(parse_user_package_dep_spec("foo/bar",
- env, []), [MatchPackageOption.IGNORE_CHOICE_REQUIREMENTS])),
- "packages matching foo/bar (ignoring choice requirements)")
+ env, []), [MatchPackageOption.IGNORE_ADDITIONAL_REQUIREMENTS])),
+ "packages matching foo/bar (ignoring additional requirements)")
if __name__ == "__main__":
diff --git a/python/mask_TEST.py b/python/mask_TEST.py
index 5190afd..f38a2da 100755
--- a/python/mask_TEST.py
+++ b/python/mask_TEST.py
@@ -98,7 +98,7 @@ class TestCase_01_Masks(unittest.TestCase):
self.assertEquals(m.key(), "A")
self.assertEquals(m.description(), "by association")
- self.assertEquals(m.associated_package_spec().package_name_requirement.name, "masked/repo")
+ self.assertEquals(m.associated_package_spec().package, "masked/repo")
elif os.environ.get("PALUDIS_ENABLE_VIRTUALS_REPOSITORY") != "no":
raise "oops"
diff --git a/python/package_dep_spec_constraint.cc b/python/package_dep_spec_constraint.cc
deleted file mode 100644
index d794a39..0000000
--- a/python/package_dep_spec_constraint.cc
+++ /dev/null
@@ -1,253 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2007 Piotr Jaroszyński
- * Copyright (c) 2011 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 <python/paludis_python.hh>
-#include <paludis/util/wrapped_forward_iterator-impl.hh>
-#include <paludis/util/fs_path.hh>
-#include <paludis/package_dep_spec_requirement.hh>
-
-using namespace paludis;
-using namespace paludis::python;
-namespace bp = boost::python;
-
-// For classes derived from PackageDepSpecRequirement
-template <typename C_>
-class class_package_dep_spec_requirement :
- public bp::class_<C_, std::shared_ptr<C_>, bp::bases<PackageDepSpecRequirement>, boost::noncopyable>
-{
- public:
- template <class Init_>
- class_package_dep_spec_requirement(const std::string & name, const std::string & class_doc, Init_ initspec) :
- bp::class_<C_, std::shared_ptr<C_>, bp::bases<PackageDepSpecRequirement>, boost::noncopyable>(
- name.c_str(), class_doc.c_str(), initspec)
- {
- bp::register_ptr_to_python<std::shared_ptr<const C_> >();
- bp::implicitly_convertible<std::shared_ptr<C_>, std::shared_ptr<PackageDepSpecRequirement> >();
- }
-};
-
-void expose_package_dep_spec_requirement()
-{
- /**
- * Enums
- */
- enum_auto("KeyRequirementOperation", last_kro,
- "The operation for a KeyRequirement");
-
- /**
- * PackageDepSpecRequirement
- */
- bp::register_ptr_to_python<std::shared_ptr<const PackageDepSpecRequirement> >();
- bp::implicitly_convertible<std::shared_ptr<PackageDepSpecRequirement>,
- std::shared_ptr<const PackageDepSpecRequirement> >();
- bp::class_<PackageDepSpecRequirement, boost::noncopyable>
- (
- "PackageDepSpecRequirement",
- "Base class for a requirement for a PackageDepSpec.",
- bp::no_init
- )
- ;
-
- /**
- * NameRequirement
- */
- class_package_dep_spec_requirement<NameRequirement>
- (
- "NameRequirement",
- "A cat/pkg requirement for a PackageDepSpec.",
- bp::no_init
- )
-
- .add_property("name", &NameRequirement::name,
- "[RO] The cat/pkg in question"
- )
- ;
-
- /**
- * PackageNamePartRequirement
- */
- class_package_dep_spec_requirement<PackageNamePartRequirement>
- (
- "PackageNamePartRequirement",
- "A /pkg requirement for a PackageDepSpec.",
- bp::no_init
- )
-
- .add_property("name_part", &PackageNamePartRequirement::name_part,
- "[RO] The /pkg in question"
- )
- ;
-
- /**
- * CategoryNamePartRequirement
- */
- class_package_dep_spec_requirement<CategoryNamePartRequirement>
- (
- "CategoryNamePartRequirement",
- "A cat/ requirement for a PackageDepSpec.",
- bp::no_init
- )
-
- .add_property("name_part", &CategoryNamePartRequirement::name_part,
- "[RO] The cat/ in question"
- )
- ;
-
- /**
- * InRepositoryRequirement
- */
- class_package_dep_spec_requirement<InRepositoryRequirement>
- (
- "InRepositoryRequirement",
- "A ::repo requirement for a PackageDepSpec.",
- bp::no_init
- )
-
- .add_property("name", &InRepositoryRequirement::name,
- "[RO] The ::repo name in question"
- )
- ;
-
- /**
- * FromRepositoryRequirement
- */
- class_package_dep_spec_requirement<FromRepositoryRequirement>
- (
- "FromRepositoryRequirement",
- "A ::repo-> requirement for a PackageDepSpec.",
- bp::no_init
- )
-
- .add_property("name", &FromRepositoryRequirement::name,
- "[RO] The ::repo-> name in question"
- )
- ;
-
- /**
- * InstalledAtPathRequirement
- */
- class_package_dep_spec_requirement<InstalledAtPathRequirement>
- (
- "InstalledAtPathRequirement",
- "A ::/ requirement for a PackageDepSpec.",
- bp::no_init
- )
-
- .add_property("path", &InstalledAtPathRequirement::path,
- "[RO] The ::/ path in question"
- )
- ;
-
- /**
- * InstallableToPathRequirement
- */
- class_package_dep_spec_requirement<InstallableToPathRequirement>
- (
- "InstalledableToPathRequirement",
- "A ::/? requirement for a PackageDepSpec.",
- bp::no_init
- )
-
- .add_property("path", &InstallableToPathRequirement::path,
- "[RO] The ::/? path in question"
- )
-
- .add_property("include_masked", &InstallableToPathRequirement::include_masked,
- "[RO] Whether to include masked, as per ::/??"
- )
- ;
-
- /**
- * InstallableToRepositoryRequirement
- */
- class_package_dep_spec_requirement<InstallableToRepositoryRequirement>
- (
- "InstalledableToPathRequirement",
- "A ::/? requirement for a PackageDepSpec.",
- bp::no_init
- )
-
- .add_property("name", &InstallableToRepositoryRequirement::name,
- "[RO] The ::repo? in question"
- )
-
- .add_property("include_masked", &InstallableToRepositoryRequirement::include_masked,
- "[RO] Whether to include masked, as per ::repo??"
- )
- ;
-
- /**
- * AnySlotRequirement
- */
- class_package_dep_spec_requirement<AnySlotRequirement>
- (
- "AnySlotRequirement",
- "A :* or := requirement for a PackageDepSpec.",
- bp::no_init
- )
-
- .add_property("locking", &AnySlotRequirement::locking,
- "[RO] Are we locking (:= rather than :*)?"
- )
- ;
-
- /**
- * ExactSlotRequirement
- */
- class_package_dep_spec_requirement<ExactSlotRequirement>
- (
- "ExactSlotRequirement",
- "A :slot or :=slot requirement for a PackageDepSpec.",
- bp::no_init
- )
-
- .add_property("locked", &ExactSlotRequirement::locked,
- "[RO] Are we locked (:=blah)?"
- )
-
- .add_property("name", &ExactSlotRequirement::name,
- "[RO] The slot name"
- )
- ;
-
- /**
- * KeyRequirement
- */
- class_package_dep_spec_requirement<KeyRequirement>
- (
- "KeyRequirement",
- "A [.key=value] requirement for a PackageDepSpec.",
- bp::no_init
- )
-
- .add_property("key", &KeyRequirement::key,
- "[RO] The key"
- )
-
- .add_property("pattern", &KeyRequirement::pattern,
- "[RO] The pattern"
- )
-
- .add_property("operation", &KeyRequirement::operation,
- "[RO] The operation"
- )
- ;
-}
-
diff --git a/python/paludis_python.hh b/python/paludis_python.hh
index 5df4800..aacf7be 100644
--- a/python/paludis_python.hh
+++ b/python/paludis_python.hh
@@ -188,11 +188,11 @@ void expose_mask() PALUDIS_VISIBLE;
void expose_match_package() PALUDIS_VISIBLE;
void expose_metadata_key() PALUDIS_VISIBLE;
void expose_name() PALUDIS_VISIBLE;
-void expose_package_dep_spec_requirement() PALUDIS_VISIBLE;
void expose_package_id() PALUDIS_VISIBLE;
void expose_repository() PALUDIS_VISIBLE;
void expose_selection() PALUDIS_VISIBLE;
void expose_version_operator() PALUDIS_VISIBLE;
+void expose_version_requirements() PALUDIS_VISIBLE;
void expose_version_spec() PALUDIS_VISIBLE;
#endif
diff --git a/python/paludis_python_so.cc b/python/paludis_python_so.cc
index 179a119..f8b4e3e 100644
--- a/python/paludis_python_so.cc
+++ b/python/paludis_python_so.cc
@@ -33,10 +33,10 @@ BOOST_PYTHON_MODULE(paludis)
expose_exception();
expose_version_spec();
expose_version_operator();
+ expose_version_requirements();
expose_fs_path();
expose_contents();
expose_filter(); /* must be before dep_spec */
- expose_package_dep_spec_requirement();
expose_dep_spec();
expose_dep_label();
expose_name();
diff --git a/python/version_requirements.cc b/python/version_requirements.cc
new file mode 100644
index 0000000..3ec32da
--- /dev/null
+++ b/python/version_requirements.cc
@@ -0,0 +1,85 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Piotr Jaroszyński
+ *
+ * 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 <python/paludis_python.hh>
+#include <python/iterable.hh>
+
+#include <paludis/version_requirements.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/make_named_values.hh>
+
+using namespace paludis;
+using namespace paludis::python;
+namespace bp = boost::python;
+
+namespace
+{
+ VersionRequirement * make_version_requirement(const VersionOperator & op, const VersionSpec & spec)
+ {
+ return new VersionRequirement(make_named_values<VersionRequirement>(
+ n::version_operator() = op,
+ n::version_spec() = spec
+ ));
+ }
+}
+
+void expose_version_requirements()
+{
+ /**
+ * Enums
+ */
+ enum_auto("VersionRequirementsMode", last_vr,
+ "Whether our version requirements are an 'and' or an 'or' set.");
+
+ /**
+ * VersionRequirement
+ */
+ bp::class_<VersionRequirement>
+ (
+ "VersionRequirement",
+ bp::no_init
+ )
+
+ .def("__init__",
+ bp::make_constructor(&make_version_requirement),
+ "__init__(VersionOperator, VersionSpec)"
+ )
+
+ .add_property("version_operator",
+ &named_values_getter<VersionRequirement, n::version_operator, VersionOperator, &VersionRequirement::version_operator>,
+ &named_values_setter<VersionRequirement, n::version_operator, VersionOperator, &VersionRequirement::version_operator>,
+ "[rw] VersionOperator"
+ )
+
+ .add_property("version_spec",
+ &named_values_getter<VersionRequirement, n::version_spec, VersionSpec, &VersionRequirement::version_spec>,
+ &named_values_setter<VersionRequirement, n::version_spec, VersionSpec, &VersionRequirement::version_spec>,
+ "[rw] VersionSpec"
+ )
+ ;
+
+ /**
+ * VersionRequirements
+ */
+ class_iterable<VersionRequirements>
+ (
+ "VersionRequirements",
+ "Iterable collection of VersionRequirement instances, usually for a PackageDepSpec."
+ );
+}
diff --git a/python/version_requirements_TEST.py b/python/version_requirements_TEST.py
new file mode 100755
index 0000000..46321ed
--- /dev/null
+++ b/python/version_requirements_TEST.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+# vim: set fileencoding=utf-8 sw=4 sts=4 et :
+
+#
+# Copyright (c) 2007 Piotr Jaroszyński
+#
+# 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
+#
+
+from paludis import *
+import unittest
+
+class TestCase_VersionRequirements(unittest.TestCase):
+ def test_01_init(self):
+ VersionRequirement("<", VersionSpec("0"))
+ VersionRequirement(VersionOperatorValue.LESS, VersionSpec("0"))
+
+ def test_02_data_members(self):
+ v1 = VersionRequirement("<", VersionSpec("0"))
+ v1.version_operator = ">"
+ v1.version_spec = VersionSpec("1")
+
+ self.assertEquals(str(v1.version_operator), ">")
+ self.assertEquals(str(v1.version_spec), "1")
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/ruby/Makefile.am b/ruby/Makefile.am
index 3f46ae0..ade8df5 100644
--- a/ruby/Makefile.am
+++ b/ruby/Makefile.am
@@ -50,7 +50,6 @@ IF_RUBY_SOURCES = \
metadata_key.cc \
name.cc \
nice_names-nn.hh nice_names-nn.cc \
- package_dep_spec_constraint.cc \
package_id.cc \
paludis_ruby.cc paludis_ruby.hh \
qualified_package_name.cc \
diff --git a/ruby/demos/find_unmanaged_files.rb b/ruby/demos/find_unmanaged_files.rb
index 8e05448..d41f7c1 100755
--- a/ruby/demos/find_unmanaged_files.rb
+++ b/ruby/demos/find_unmanaged_files.rb
@@ -12,12 +12,12 @@ def get_contents(pids, directories, root)
in_contents= []
pids.each do |pid|
next if pid.contents_key.nil?
- contents = pid.contents_key.parse_value
+ contents = pid.contents_key.value
contents.each do |entry|
next if entry.kind_of? ContentsOtherEntry
directories.each do |directory|
- if (root + entry.location_key.parse_value)[0,directory.length] == directory
- in_contents << root + entry.location_key.parse_value
+ if (root + entry.location_key.value)[0,directory.length] == directory
+ in_contents << root + entry.location_key.value
break;
end
end
@@ -72,7 +72,7 @@ opts.each do | opt, arg |
end
env = Paludis::EnvironmentFactory.instance.create env_spec
-root = env.preferred_root_key.parse_value[-1] == ?/ ? env.preferred_root_key.parse_value.chop : env.preferred_root_key.parse_value
+root = env.preferred_root_key.value[-1] == ?/ ? env.preferred_root_key.value.chop : env.preferred_root_key.value
directories = []
diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc
index 09518dd..9f6790b 100644
--- a/ruby/dep_spec.cc
+++ b/ruby/dep_spec.cc
@@ -19,12 +19,10 @@
*/
#include <paludis_ruby.hh>
-
#include <paludis/dep_spec.hh>
#include <paludis/user_dep_spec.hh>
+#include <paludis/version_requirements.hh>
#include <paludis/version_operator.hh>
-#include <paludis/package_dep_spec_requirement.hh>
-
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/options.hh>
@@ -33,7 +31,6 @@
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/util/accept_visitor.hh>
-
#include <algorithm>
#include <list>
#include <ruby.h>
@@ -64,6 +61,58 @@ namespace
static VALUE c_exactly_one_dep_spec;
static VALUE c_conditional_dep_spec;
+ static VALUE c_version_requirements_mode;
+
+ static VALUE c_slot_requirement;
+ static VALUE c_slot_exact_requirement;
+ static VALUE c_slot_any_locked_requirement;
+ static VALUE c_slot_any_unlocked_requirement;
+
+ struct V
+ {
+ VALUE value;
+ std::shared_ptr<const SlotRequirement> mm;
+
+ V(std::shared_ptr<const SlotRequirement> _m) :
+ mm(_m)
+ {
+ }
+
+ void visit(const SlotExactRequirement &)
+ {
+ value = Data_Wrap_Struct(c_slot_exact_requirement, 0, &Common<std::shared_ptr<const SlotRequirement> >::free,
+ new std::shared_ptr<const SlotRequirement>(mm));
+ }
+
+ void visit(const SlotAnyLockedRequirement &)
+ {
+ value = Data_Wrap_Struct(c_slot_any_locked_requirement, 0, &Common<std::shared_ptr<const SlotRequirement> >::free,
+ new std::shared_ptr<const SlotRequirement>(mm));
+ }
+
+ void visit(const SlotAnyUnlockedRequirement &)
+ {
+ value = Data_Wrap_Struct(c_slot_any_unlocked_requirement, 0, &Common<std::shared_ptr<const SlotRequirement> >::free,
+ new std::shared_ptr<const SlotRequirement>(mm));
+ }
+
+ };
+
+ VALUE
+ slot_requirement_to_value(std::shared_ptr<const SlotRequirement> m)
+ {
+ try
+ {
+ V v(m);
+ m->accept(v);
+ return v.value;
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
struct WrappedSpecBase;
template <typename> struct WrappedSpec;
@@ -527,193 +576,217 @@ namespace
/*
* call-seq:
- * package_name_requirement -> NameRequirement or Nil
+ * package -> QualifiedPackageName or Nil
*
- * Fetch the package name requirement (may be Nil).
+ * Fetch the package name.
*/
VALUE
- package_dep_spec_package_name_requirement(VALUE self)
+ package_dep_spec_package(VALUE self)
{
std::shared_ptr<WrappedSpecBase> * ptr;
Data_Get_Struct(self, std::shared_ptr<WrappedSpecBase>, ptr);
- if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->package_name_requirement()))
+ if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->package_ptr()))
return Qnil;
- return package_dep_spec_requirement_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->package_name_requirement());
+ return qualified_package_name_to_value(*std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->package_ptr());
}
/*
* call-seq:
- * package_name_part_requirement -> PackageNamePartRequirement or Nil
+ * package_name_part -> String or Nil
*
- * Fetch the package name part requirement (may be Nil).
+ * Fetch the package name part.
*/
VALUE
- package_dep_spec_package_name_part_requirement(VALUE self)
+ package_dep_spec_package_name_part(VALUE self)
{
std::shared_ptr<WrappedSpecBase> * ptr;
Data_Get_Struct(self, std::shared_ptr<WrappedSpecBase>, ptr);
- if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->package_name_part_requirement()))
+ if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->package_name_part_ptr()))
return Qnil;
- return package_dep_spec_requirement_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->package_name_part_requirement());
+ return rb_str_new2(stringify(*std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->
+ package_name_part_ptr()).c_str());
}
/*
* call-seq:
- * category_name_part_requirement -> CategoryNamePartRequirement or Nil
+ * category_name_part -> String or Nil
*
- * Fetch the category name part requirement (may be Nil).
+ * Fetch the category name part.
*/
VALUE
- package_dep_spec_category_name_part_requirement(VALUE self)
+ package_dep_spec_category_name_part(VALUE self)
{
std::shared_ptr<WrappedSpecBase> * ptr;
Data_Get_Struct(self, std::shared_ptr<WrappedSpecBase>, ptr);
- if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->category_name_part_requirement()))
+ if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->category_name_part_ptr()))
return Qnil;
- return package_dep_spec_requirement_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->category_name_part_requirement());
+ return rb_str_new2(stringify(*std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->
+ category_name_part_ptr()).c_str());
}
/*
* call-seq:
- * any_slot_requirement -> AnySlotRequirement or Nil
+ * text -> String
*
- * Fetch the any-slot requirement (may be Nil).
+ * Fetch our text.
*/
VALUE
- package_dep_spec_any_slot_requirement(VALUE self)
+ string_dep_spec_text(VALUE self)
{
std::shared_ptr<WrappedSpecBase> * ptr;
Data_Get_Struct(self, std::shared_ptr<WrappedSpecBase>, ptr);
- if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->any_slot_requirement()))
- return Qnil;
- return package_dep_spec_requirement_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->any_slot_requirement());
+ return rb_str_new2(stringify(std::static_pointer_cast<const StringDepSpec>((*ptr)->base_spec())->text()).c_str());
}
/*
* call-seq:
- * exact_slot_requirement -> ExactSlotRequirement or Nil
+ * to_s -> String
*
- * Fetch the exact-slot requirement (may be Nil).
+ * Fetch a string representation of ourself.
*/
- VALUE
- package_dep_spec_exact_slot_requirement(VALUE self)
+ template <typename T_>
+ VALUE dep_spec_to_s(VALUE self)
{
std::shared_ptr<WrappedSpecBase> * ptr;
Data_Get_Struct(self, std::shared_ptr<WrappedSpecBase>, ptr);
- if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->exact_slot_requirement()))
- return Qnil;
- return package_dep_spec_requirement_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->exact_slot_requirement());
+ return rb_str_new2(stringify(*std::static_pointer_cast<const WrappedSpec<T_> >(*ptr)->spec()).c_str());
}
/*
* call-seq:
- * text -> String
+ * slot_requirement -> SlotRequirement or Nil
*
- * Fetch our text.
+ * Fetch the slot requirement.
*/
VALUE
- string_dep_spec_text(VALUE self)
+ package_dep_spec_slot_requirement_ptr(VALUE self)
{
std::shared_ptr<WrappedSpecBase> * ptr;
Data_Get_Struct(self, std::shared_ptr<WrappedSpecBase>, ptr);
- return rb_str_new2(stringify(std::static_pointer_cast<const StringDepSpec>((*ptr)->base_spec())->text()).c_str());
+ if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->slot_requirement_ptr()))
+ return Qnil;
+ return slot_requirement_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->slot_requirement_ptr());
}
/*
* call-seq:
- * to_s -> String
+ * in_repository -> String or Nil
*
- * Fetch a string representation of ourself.
+ * Fetch the in-repository name.
*/
- template <typename T_>
- VALUE dep_spec_to_s(VALUE self)
+ VALUE
+ package_dep_spec_in_repository_ptr(VALUE self)
{
std::shared_ptr<WrappedSpecBase> * ptr;
Data_Get_Struct(self, std::shared_ptr<WrappedSpecBase>, ptr);
- return rb_str_new2(stringify(*std::static_pointer_cast<const WrappedSpec<T_> >(*ptr)->spec()).c_str());
+ if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->in_repository_ptr()))
+ return Qnil;
+ return rb_str_new2(stringify((*std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->in_repository_ptr())).c_str());
}
/*
* call-seq:
- * in_repository_requirement -> InRepositoryRequirement or Nil
+ * from_repository -> String or Nil
*
- * Fetch the in-repository name.
+ * Fetch the from-repository name.
*/
VALUE
- package_dep_spec_in_repository_requirement(VALUE self)
+ package_dep_spec_from_repository_ptr(VALUE self)
{
std::shared_ptr<WrappedSpecBase> * ptr;
Data_Get_Struct(self, std::shared_ptr<WrappedSpecBase>, ptr);
- if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->in_repository_requirement()))
+ if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->from_repository_ptr()))
return Qnil;
- return package_dep_spec_requirement_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->in_repository_requirement());
+ return rb_str_new2(stringify((*std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->from_repository_ptr())).c_str());
}
/*
* call-seq:
- * from_repository_requirement -> FromRepositoryRequirement or Nil
+ * installable_to_repository -> Hash or Nil
*
- * Fetch the from-repository requirement.
+ * Fetch the installable-to-repository requirement.
*/
VALUE
- package_dep_spec_from_repository_requirement(VALUE self)
+ package_dep_spec_installable_to_repository(VALUE self)
{
std::shared_ptr<WrappedSpecBase> * ptr;
Data_Get_Struct(self, std::shared_ptr<WrappedSpecBase>, ptr);
- if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->from_repository_requirement()))
+ std::shared_ptr<const InstallableToRepository> i2r(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installable_to_repository_ptr());
+ if (! i2r)
return Qnil;
- return package_dep_spec_requirement_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->from_repository_requirement());
+ VALUE result(rb_hash_new());
+ rb_hash_aset(result, ID2SYM(rb_intern("repository")),
+ rb_str_new2(stringify(i2r->repository()).c_str()));
+ rb_hash_aset(result, ID2SYM(rb_intern("include_masked?")),
+ i2r->include_masked() ? Qtrue : Qfalse);
+ return result;
}
/*
* call-seq:
- * installed_at_path_requirement ->
- * InstalledAtPathRequirement or Nil
+ * installed_at_path -> String or Nil
*
* Fetch the installed-at-path requirement.
*/
VALUE
- package_dep_spec_installed_at_path_requirement(VALUE self)
+ package_dep_spec_installed_at_path(VALUE self)
{
std::shared_ptr<WrappedSpecBase> * ptr;
Data_Get_Struct(self, std::shared_ptr<WrappedSpecBase>, ptr);
- if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installed_at_path_requirement()))
+ if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installed_at_path_ptr()))
return Qnil;
- return package_dep_spec_requirement_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installed_at_path_requirement());
+ return rb_str_new2(stringify((*std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installed_at_path_ptr())).c_str());
}
/*
* call-seq:
- * installable_to_path_requirement -> InstallableToPathRequirement or Nil
+ * installable_to_path -> Hash or Nil
*
* Fetch the installable-to-path requirement.
*/
VALUE
- package_dep_spec_installable_to_path_requirement(VALUE self)
+ package_dep_spec_installable_to_path(VALUE self)
{
std::shared_ptr<WrappedSpecBase> * ptr;
Data_Get_Struct(self, std::shared_ptr<WrappedSpecBase>, ptr);
- if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installable_to_path_requirement()))
+ std::shared_ptr<const InstallableToPath> i2p(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installable_to_path_ptr());
+ if (! i2p)
return Qnil;
- return package_dep_spec_requirement_to_value(
- std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installable_to_path_requirement());
+ VALUE result(rb_hash_new());
+ rb_hash_aset(result, ID2SYM(rb_intern("path")),
+ rb_str_new2(stringify(i2p->path()).c_str()));
+ rb_hash_aset(result, ID2SYM(rb_intern("include_masked?")),
+ i2p->include_masked() ? Qtrue : Qfalse);
+ return result;
}
/*
* call-seq:
- * installable_to_path_requirement -> InstallableToRepositoryRequirement or Nil
+ * version_requirements -> Array
*
- * Fetch the installable-to-path requirement.
+ * Fetch the version requirements. E.g. [ {:operator => '=', :spec => VersionSpec.new('0.1') } ]
*/
VALUE
- package_dep_spec_installable_to_repository_requirement(VALUE self)
+ package_dep_spec_version_requirements_ptr(VALUE self)
{
std::shared_ptr<WrappedSpecBase> * ptr;
Data_Get_Struct(self, std::shared_ptr<WrappedSpecBase>, ptr);
- if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installable_to_repository_requirement()))
- return Qnil;
- return package_dep_spec_requirement_to_value(
- std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installable_to_repository_requirement());
+ VALUE result(rb_ary_new());
+ VALUE result_hash;
+ if (std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->version_requirements_ptr())
+ for (VersionRequirements::ConstIterator i(std::static_pointer_cast<const PackageDepSpec>((*ptr)->base_spec())->
+ version_requirements_ptr()->begin()),
+ i_end(std::static_pointer_cast<const PackageDepSpec>((*ptr)->base_spec())->version_requirements_ptr()->end()) ;
+ i != i_end; ++i)
+ {
+ result_hash = rb_hash_new();
+ rb_hash_aset(result_hash, ID2SYM(rb_intern("operator")),
+ rb_str_new2(stringify(i->version_operator()).c_str()));
+ rb_hash_aset(result_hash, ID2SYM(rb_intern("spec")),
+ version_spec_to_value(i->version_spec()));
+ rb_ary_push(result, result_hash);
+ }
+ return result;
}
#ifdef CIARANM_REMOVED_THIS
@@ -748,6 +821,14 @@ namespace
}
#endif
+ VALUE
+ package_dep_spec_version_requirements_mode(VALUE self)
+ {
+ std::shared_ptr<WrappedSpecBase> * ptr;
+ Data_Get_Struct(self, std::shared_ptr<WrappedSpecBase>, ptr);
+ return INT2FIX(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->version_requirements_mode());
+ }
+
/*
* Document-method: original_url
* call-seq: original_url -> String
@@ -884,6 +965,14 @@ namespace
}
+ VALUE
+ slot_exact_requirement_slot(VALUE self)
+ {
+ std::shared_ptr<const SlotExactRequirement> * ptr;
+ Data_Get_Struct(self, std::shared_ptr<const SlotExactRequirement>, ptr);
+ return rb_str_new2(stringify((*ptr)->slot()).c_str());
+ }
+
void do_register_dep_spec()
{
/*
@@ -1018,16 +1107,17 @@ namespace
* use Paludis::parse_user_package_dep_spec.
*/
c_package_dep_spec = rb_define_class_under(paludis_module(), "PackageDepSpec", c_string_dep_spec);
- rb_define_method(c_package_dep_spec, "package_name_requirement", RUBY_FUNC_CAST(&package_dep_spec_package_name_requirement), 0);
- rb_define_method(c_package_dep_spec, "package_name_part_requirement", RUBY_FUNC_CAST(&package_dep_spec_package_name_part_requirement), 0);
- rb_define_method(c_package_dep_spec, "category_name_part_requirement", RUBY_FUNC_CAST(&package_dep_spec_category_name_part_requirement), 0);
- rb_define_method(c_package_dep_spec, "in_repository_requirement", RUBY_FUNC_CAST(&package_dep_spec_in_repository_requirement), 0);
- rb_define_method(c_package_dep_spec, "from_repository_requirement", RUBY_FUNC_CAST(&package_dep_spec_from_repository_requirement), 0);
- rb_define_method(c_package_dep_spec, "installable_to_repository_requirement", RUBY_FUNC_CAST(&package_dep_spec_installable_to_repository_requirement), 0);
- rb_define_method(c_package_dep_spec, "installed_at_path_requirement", RUBY_FUNC_CAST(&package_dep_spec_installed_at_path_requirement), 0);
- rb_define_method(c_package_dep_spec, "installable_to_path_requirement", RUBY_FUNC_CAST(&package_dep_spec_installable_to_path_requirement), 0);
- rb_define_method(c_package_dep_spec, "any_slot_requirement", RUBY_FUNC_CAST(&package_dep_spec_any_slot_requirement), 0);
- rb_define_method(c_package_dep_spec, "exact_slot_requirement", RUBY_FUNC_CAST(&package_dep_spec_exact_slot_requirement), 0);
+ rb_define_method(c_package_dep_spec, "package", RUBY_FUNC_CAST(&package_dep_spec_package), 0);
+ rb_define_method(c_package_dep_spec, "package_name_part", RUBY_FUNC_CAST(&package_dep_spec_package_name_part), 0);
+ rb_define_method(c_package_dep_spec, "category_name_part", RUBY_FUNC_CAST(&package_dep_spec_category_name_part), 0);
+ rb_define_method(c_package_dep_spec, "slot_requirement", RUBY_FUNC_CAST(&package_dep_spec_slot_requirement_ptr), 0);
+ rb_define_method(c_package_dep_spec, "in_repository", RUBY_FUNC_CAST(&package_dep_spec_in_repository_ptr), 0);
+ rb_define_method(c_package_dep_spec, "from_repository", RUBY_FUNC_CAST(&package_dep_spec_from_repository_ptr), 0);
+ rb_define_method(c_package_dep_spec, "installable_to_repository", RUBY_FUNC_CAST(&package_dep_spec_installable_to_repository), 0);
+ rb_define_method(c_package_dep_spec, "installed_at_path", RUBY_FUNC_CAST(&package_dep_spec_installed_at_path), 0);
+ rb_define_method(c_package_dep_spec, "installable_to_path", RUBY_FUNC_CAST(&package_dep_spec_installable_to_path), 0);
+ rb_define_method(c_package_dep_spec, "version_requirements", RUBY_FUNC_CAST(&package_dep_spec_version_requirements_ptr), 0);
+ rb_define_method(c_package_dep_spec, "version_requirements_mode", RUBY_FUNC_CAST(&package_dep_spec_version_requirements_mode), 0);
#ifdef CIARANM_REMOVED_THIS
rb_define_method(c_package_dep_spec, "use_requirements", RUBY_FUNC_CAST(&package_dep_spec_use_requirements), 0);
#endif
@@ -1093,7 +1183,52 @@ namespace
VALUE (* block_dep_spec_to_s) (VALUE) = &dep_spec_to_s<BlockDepSpec>;
rb_define_method(c_block_dep_spec, "to_s", RUBY_FUNC_CAST(block_dep_spec_to_s), 0);
+ /*
+ * Document-module: Paludis::VersionRequirementsMode
+ *
+ * What sort of VersionRequirements to we have.
+ *
+ */
+ c_version_requirements_mode = rb_define_module_under(paludis_module(), "VersionRequirementsMode");
+ for (VersionRequirementsMode l(static_cast<VersionRequirementsMode>(0)), l_end(last_vr) ; l != l_end ;
+ l = static_cast<VersionRequirementsMode>(static_cast<int>(l) + 1))
+ rb_define_const(c_version_requirements_mode, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
+
+ // cc_enum_special<paludis/version_requirements.hh, VersionRequirementsMode, c_version_requirements_mode>
+
rb_define_module_function(paludis_module(), "parse_user_package_dep_spec", RUBY_FUNC_CAST(&paludis_parse_user_dep_spec), -1);
+
+ /*
+ * Document-class: Paludis::SlotRequirement
+ *
+ * A SlotRequirement
+ */
+ c_slot_requirement = rb_define_class_under(paludis_module(), "SlotRequirement", rb_cObject);
+ rb_funcall(c_slot_requirement, rb_intern("private_class_method"), 1, rb_str_new2("new"));
+ rb_define_method(c_slot_requirement, "as_string", RUBY_FUNC_CAST(&Common<std::shared_ptr<const SlotRequirement> >::to_s_via_ptr), 0);
+ rb_define_method(c_slot_requirement, "to_s", RUBY_FUNC_CAST(&Common<std::shared_ptr<const SlotRequirement> >::to_s_via_ptr), 0);
+
+ /*
+ * Document-class: Paludis::ExactSlotRequirement
+ *
+ * An exact slot requiremet (:)
+ */
+ c_slot_exact_requirement = rb_define_class_under(paludis_module(), "SlotExactRequirement", c_slot_requirement);
+ rb_define_method(c_slot_exact_requirement, "slot", RUBY_FUNC_CAST(&slot_exact_requirement_slot), 0);
+
+ /*
+ * Document-class: Paludis::SlotAnyLockedRequirement
+ *
+ * An any locked slot requiremet (:=)
+ */
+ c_slot_any_locked_requirement = rb_define_class_under(paludis_module(), "SlotAnyLockedRequirement", c_slot_requirement);
+
+ /*
+ * Document-class: Paludis::ExactSlotRequirement
+ *
+ * An any unlocked slot requiremet (:*)
+ */
+ c_slot_any_unlocked_requirement = rb_define_class_under(paludis_module(), "SlotAnyUnlockedRequirement", c_slot_requirement);
}
}
diff --git a/ruby/dep_spec_TEST.rb b/ruby/dep_spec_TEST.rb
index d8c7f05..526186a 100644
--- a/ruby/dep_spec_TEST.rb
+++ b/ruby/dep_spec_TEST.rb
@@ -130,77 +130,97 @@ module Paludis
end
def test_slot
- assert_equal "100", pda.exact_slot_requirement.name
- assert_nil pdb.exact_slot_requirement
- assert_nil pdc.exact_slot_requirement
- assert_nil pdd.exact_slot_requirement
- assert_nil pde.exact_slot_requirement
+ assert_kind_of SlotExactRequirement, pda.slot_requirement
+ assert_equal ":100", pda.slot_requirement.to_s
+ assert_equal "100", pda.slot_requirement.slot
+ assert_nil pdb.slot_requirement
+ assert_nil pdc.slot_requirement
+ assert_nil pdd.slot_requirement
+ assert_nil pde.slot_requirement
end
def test_package
- assert_equal QualifiedPackageName.new("foo/bar"), pda.package_name_requirement.name
- assert_nil pdb.package_name_requirement
- assert_equal QualifiedPackageName.new("foo/bar"), pdc.package_name_requirement.name
- assert_nil pdd.package_name_requirement
- assert_equal QualifiedPackageName.new("foo/bar"), pde.package_name_requirement.name
+ assert_equal QualifiedPackageName.new("foo/bar"), pda.package
+ assert_nil pdb.package
+ assert_equal QualifiedPackageName.new("foo/bar"), pdc.package
+ assert_nil pdd.package
+ assert_equal QualifiedPackageName.new("foo/bar"), pde.package
end
def test_from_repository
- assert_nil pda.from_repository_requirement
- assert_nil pdb.from_repository_requirement
- assert_nil pdc.from_repository_requirement
- assert_nil pdd.from_repository_requirement
- assert_equal "testrepo", pde.from_repository_requirement.name
+ assert_nil pda.from_repository
+ assert_nil pdb.from_repository
+ assert_nil pdc.from_repository
+ assert_nil pdd.from_repository
+ assert_equal "testrepo", pde.from_repository
end
def test_in_repository
- assert_equal "testrepo", pda.in_repository_requirement.name
- assert_nil pdb.in_repository_requirement
- assert_nil pdc.in_repository_requirement
- assert_nil pdd.in_repository_requirement
- assert_nil pde.in_repository_requirement
+ assert_equal "testrepo", pda.in_repository
+ assert_nil pdb.in_repository
+ assert_nil pdc.in_repository
+ assert_nil pdd.in_repository
+ assert_nil pde.in_repository
end
def test_installable_to_repository
- assert_nil pda.installable_to_repository_requirement
- assert_nil pdb.installable_to_repository_requirement
- assert_equal "installed", pdc.installable_to_repository_requirement.name
- assert ! pdc.installable_to_repository_requirement.include_masked?
- assert_nil pdd.installable_to_repository_requirement
- assert_nil pde.installable_to_repository_requirement
+ assert_nil pda.installable_to_repository
+ assert_nil pdb.installable_to_repository
+ assert_kind_of Hash, pdc.installable_to_repository
+ assert_equal "installed", pdc.installable_to_repository[:repository]
+ assert ! pdc.installable_to_repository[:include_masked?]
+ assert_nil pdd.installable_to_repository
+ assert_nil pde.installable_to_repository
end
def test_installed_at_path
- assert_nil pda.installed_at_path_requirement
- assert_nil pdb.installed_at_path_requirement
- assert_nil pdc.installed_at_path_requirement
- assert_nil pdd.installed_at_path_requirement
- assert_equal "/mychroot", pde.installed_at_path_requirement.path
+ assert_nil pda.installed_at_path
+ assert_nil pdb.installed_at_path
+ assert_nil pdc.installed_at_path
+ assert_nil pdd.installed_at_path
+ assert_equal "/mychroot", pde.installed_at_path
end
def test_installable_to_path
- assert_nil pda.installable_to_path_requirement
- assert_nil pdb.installable_to_path_requirement
- assert_nil pdc.installable_to_path_requirement
- assert_equal "/", pdd.installable_to_path_requirement.path
- assert pdd.installable_to_path_requirement.include_masked?
- assert_nil pde.installable_to_path_requirement
+ assert_nil pda.installable_to_path
+ assert_nil pdb.installable_to_path
+ assert_nil pdc.installable_to_path
+ assert_kind_of Hash, pdd.installable_to_path
+ assert_equal "/", pdd.installable_to_path[:path]
+ assert pdd.installable_to_path[:include_masked?]
+ assert_nil pde.installable_to_path
end
def test_package_name_part
- assert_nil pda.package_name_part_requirement
- assert_equal "bar", pdb.package_name_part_requirement.name_part
- assert_nil pdc.package_name_part_requirement
- assert_nil pdd.package_name_part_requirement
- assert_nil pde.package_name_part_requirement
+ assert_nil pda.package_name_part
+ assert_equal "bar", pdb.package_name_part
+ assert_nil pdc.package_name_part
+ assert_nil pdd.package_name_part
+ assert_nil pde.package_name_part
end
def test_category_name_part
- assert_nil pda.category_name_part_requirement
- assert_nil pdb.category_name_part_requirement
- assert_nil pdc.category_name_part_requirement
- assert_equal "foo", pdd.category_name_part_requirement.name_part
- assert_nil pde.category_name_part_requirement
+ assert_nil pda.category_name_part
+ assert_nil pdb.category_name_part
+ assert_nil pdc.category_name_part
+ assert_equal "foo", pdd.category_name_part
+ assert_nil pde.category_name_part
+ end
+
+ def test_version_requirements
+ assert_kind_of Array, pda.version_requirements
+ assert_equal 1, pda.version_requirements.size
+ assert_equal VersionSpec.new('1'), pda.version_requirements.first[:spec]
+ assert_equal ">=", pda.version_requirements.first[:operator]
+ assert_equal 0, pdb.version_requirements.size
+ assert_equal 0, pdc.version_requirements.size
+ assert_equal 0, pdd.version_requirements.size
+ assert_equal 0, pde.version_requirements.size
+ end
+
+ def test_version_requirements_mode
+ assert_kind_of Fixnum, pda.version_requirements_mode
+ assert_equal VersionRequirementsMode::And, pda.version_requirements_mode
end
### def test_use_requirements
diff --git a/ruby/generator_TEST.rb b/ruby/generator_TEST.rb
index 9359a14..7b91c08 100644
--- a/ruby/generator_TEST.rb
+++ b/ruby/generator_TEST.rb
@@ -59,8 +59,8 @@ module Paludis
assert_equal Generator::Matches.new(Paludis::parse_user_package_dep_spec("a/b", env, []), nil, []).to_s,
"packages matching a/b"
assert_equal Generator::Matches.new(Paludis::parse_user_package_dep_spec("a/b", env, []),
- nil, [:ignore_choice_requirements]).to_s,
- "packages matching a/b (ignoring choice requirements)"
+ nil, [:ignore_additional_requirements]).to_s,
+ "packages matching a/b (ignoring additional requirements)"
end
end
diff --git a/ruby/package_dep_spec_constraint.cc b/ruby/package_dep_spec_constraint.cc
deleted file mode 100644
index 678a3e6..0000000
--- a/ruby/package_dep_spec_constraint.cc
+++ /dev/null
@@ -1,527 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2011 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_ruby.hh>
-
-#include <paludis/package_dep_spec_requirement.hh>
-
-#include <algorithm>
-#include <list>
-#include <ruby.h>
-
-using namespace paludis;
-using namespace paludis::ruby;
-
-namespace
-{
- static VALUE c_package_dep_spec_requirement;
- static VALUE c_name_requirement;
- static VALUE c_package_name_part_requirement;
- static VALUE c_category_name_part_requirement;
- static VALUE c_version_requirement;
- static VALUE c_in_repository_requirement;
- static VALUE c_from_repository_requirement;
- static VALUE c_installed_at_path_requirement;
- static VALUE c_installable_to_path_requirement;
- static VALUE c_installable_to_repository_requirement;
- static VALUE c_any_slot_requirement;
- static VALUE c_exact_slot_requirement;
- static VALUE c_key_requirement;
- static VALUE c_choice_requirement;
-
- static VALUE c_key_requirement_operation;
-
- struct V
- {
- VALUE value;
- std::shared_ptr<const PackageDepSpecRequirement> mm;
-
- V(const std::shared_ptr<const PackageDepSpecRequirement> & m) :
- mm(m)
- {
- }
-
- void visit(const NameRequirement &)
- {
- value = Data_Wrap_Struct(c_name_requirement, 0, &Common<std::shared_ptr<const PackageDepSpecRequirement> >::free,
- new std::shared_ptr<const PackageDepSpecRequirement>(mm));
- }
-
- void visit(const CategoryNamePartRequirement &)
- {
- value = Data_Wrap_Struct(c_category_name_part_requirement, 0, &Common<std::shared_ptr<const PackageDepSpecRequirement> >::free,
- new std::shared_ptr<const PackageDepSpecRequirement>(mm));
- }
-
- void visit(const PackageNamePartRequirement &)
- {
- value = Data_Wrap_Struct(c_package_name_part_requirement, 0, &Common<std::shared_ptr<const PackageDepSpecRequirement> >::free,
- new std::shared_ptr<const PackageDepSpecRequirement>(mm));
- }
-
- void visit(const VersionRequirement &)
- {
- value = Data_Wrap_Struct(c_version_requirement, 0, &Common<std::shared_ptr<const PackageDepSpecRequirement> >::free,
- new std::shared_ptr<const PackageDepSpecRequirement>(mm));
- }
-
- void visit(const InRepositoryRequirement &)
- {
- value = Data_Wrap_Struct(c_in_repository_requirement, 0, &Common<std::shared_ptr<const PackageDepSpecRequirement> >::free,
- new std::shared_ptr<const PackageDepSpecRequirement>(mm));
- }
-
- void visit(const FromRepositoryRequirement &)
- {
- value = Data_Wrap_Struct(c_from_repository_requirement, 0, &Common<std::shared_ptr<const PackageDepSpecRequirement> >::free,
- new std::shared_ptr<const PackageDepSpecRequirement>(mm));
- }
-
- void visit(const InstalledAtPathRequirement &)
- {
- value = Data_Wrap_Struct(c_installed_at_path_requirement, 0, &Common<std::shared_ptr<const PackageDepSpecRequirement> >::free,
- new std::shared_ptr<const PackageDepSpecRequirement>(mm));
- }
-
- void visit(const InstallableToPathRequirement &)
- {
- value = Data_Wrap_Struct(c_installable_to_path_requirement, 0, &Common<std::shared_ptr<const PackageDepSpecRequirement> >::free,
- new std::shared_ptr<const PackageDepSpecRequirement>(mm));
- }
-
- void visit(const InstallableToRepositoryRequirement &)
- {
- value = Data_Wrap_Struct(c_installable_to_repository_requirement, 0, &Common<std::shared_ptr<const PackageDepSpecRequirement> >::free,
- new std::shared_ptr<const PackageDepSpecRequirement>(mm));
- }
-
- void visit(const AnySlotRequirement &)
- {
- value = Data_Wrap_Struct(c_any_slot_requirement, 0, &Common<std::shared_ptr<const PackageDepSpecRequirement> >::free,
- new std::shared_ptr<const PackageDepSpecRequirement>(mm));
- }
-
- void visit(const ExactSlotRequirement &)
- {
- value = Data_Wrap_Struct(c_exact_slot_requirement, 0, &Common<std::shared_ptr<const PackageDepSpecRequirement> >::free,
- new std::shared_ptr<const PackageDepSpecRequirement>(mm));
- }
-
- void visit(const KeyRequirement &)
- {
- value = Data_Wrap_Struct(c_key_requirement, 0, &Common<std::shared_ptr<const PackageDepSpecRequirement> >::free,
- new std::shared_ptr<const PackageDepSpecRequirement>(mm));
- }
-
- void visit(const ChoiceRequirement &)
- {
- value = Data_Wrap_Struct(c_choice_requirement, 0, &Common<std::shared_ptr<const PackageDepSpecRequirement> >::free,
- new std::shared_ptr<const PackageDepSpecRequirement>(mm));
- }
- };
-
- /*
- * Document-method: name
- *
- * The name requirement.
- */
- static VALUE
- name_requirement_name(VALUE self)
- {
- std::shared_ptr<const PackageDepSpecRequirement> * ptr;
- Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecRequirement>, ptr);
- return qualified_package_name_to_value((std::static_pointer_cast<const NameRequirement>(*ptr))->name());
- }
-
- /*
- * Document-method: name_part
- *
- * The name part requirement.
- */
- static VALUE
- package_name_part_requirement_name_part(VALUE self)
- {
- std::shared_ptr<const PackageDepSpecRequirement> * ptr;
- Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecRequirement>, ptr);
- return rb_str_new2(stringify((std::static_pointer_cast<const PackageNamePartRequirement>(*ptr))->name_part()).c_str());
- }
-
- /*
- * Document-method: name_part
- *
- * The name part requirement.
- */
- static VALUE
- category_name_part_requirement_name_part(VALUE self)
- {
- std::shared_ptr<const PackageDepSpecRequirement> * ptr;
- Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecRequirement>, ptr);
- return rb_str_new2(stringify((std::static_pointer_cast<const CategoryNamePartRequirement>(*ptr))->name_part()).c_str());
- }
-
- /*
- * Document-method: name
- *
- * The name requirement.
- */
- static VALUE
- in_repository_requirement_name(VALUE self)
- {
- std::shared_ptr<const PackageDepSpecRequirement> * ptr;
- Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecRequirement>, ptr);
- return rb_str_new2(stringify((std::static_pointer_cast<const InRepositoryRequirement>(*ptr))->name()).c_str());
- }
-
- /*
- * Document-method: name
- *
- * The name requirement.
- */
- static VALUE
- from_repository_requirement_name(VALUE self)
- {
- std::shared_ptr<const PackageDepSpecRequirement> * ptr;
- Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecRequirement>, ptr);
- return rb_str_new2(stringify((std::static_pointer_cast<const FromRepositoryRequirement>(*ptr))->name()).c_str());
- }
-
- /*
- * Document-method: path
- *
- * The path requirement.
- */
- static VALUE
- installed_at_path_requirement_path(VALUE self)
- {
- std::shared_ptr<const PackageDepSpecRequirement> * ptr;
- Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecRequirement>, ptr);
- return rb_str_new2(stringify((std::static_pointer_cast<const InstalledAtPathRequirement>(*ptr))->path()).c_str());
- }
-
- /*
- * Document-method: path
- *
- * The path requirement.
- */
- static VALUE
- installable_to_path_requirement_path(VALUE self)
- {
- std::shared_ptr<const PackageDepSpecRequirement> * ptr;
- Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecRequirement>, ptr);
- return rb_str_new2(stringify((std::static_pointer_cast<const InstallableToPathRequirement>(*ptr))->path()).c_str());
- }
-
- /*
- * Document-method: include_masked?
- *
- * The include-masked requirement.
- */
- static VALUE
- installable_to_path_requirement_include_masked(VALUE self)
- {
- std::shared_ptr<const PackageDepSpecRequirement> * ptr;
- Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecRequirement>, ptr);
- return (std::static_pointer_cast<const InstallableToPathRequirement>(*ptr))->include_masked() ? Qtrue : Qfalse;
- }
-
- /*
- * Document-method: name
- *
- * The name requirement.
- */
- static VALUE
- installable_to_repository_requirement_name(VALUE self)
- {
- std::shared_ptr<const PackageDepSpecRequirement> * ptr;
- Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecRequirement>, ptr);
- return rb_str_new2(stringify((std::static_pointer_cast<const InstallableToRepositoryRequirement>(*ptr))->name()).c_str());
- }
-
- /*
- * Document-method: include_masked?
- *
- * The include-masked requirement.
- */
- static VALUE
- installable_to_repository_requirement_include_masked(VALUE self)
- {
- std::shared_ptr<const PackageDepSpecRequirement> * ptr;
- Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecRequirement>, ptr);
- return (std::static_pointer_cast<const InstallableToRepositoryRequirement>(*ptr))->include_masked() ? Qtrue : Qfalse;
- }
-
- /*
- * Document-method: locking?
- *
- * The locking requirement.
- */
- static VALUE
- any_slot_requirement_locking(VALUE self)
- {
- std::shared_ptr<const PackageDepSpecRequirement> * ptr;
- Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecRequirement>, ptr);
- return (std::static_pointer_cast<const AnySlotRequirement>(*ptr))->locking() ? Qtrue : Qfalse;
- }
-
- /*
- * Document-method: locked?
- *
- * The locked requirement.
- */
- static VALUE
- exact_slot_requirement_locked(VALUE self)
- {
- std::shared_ptr<const PackageDepSpecRequirement> * ptr;
- Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecRequirement>, ptr);
- return (std::static_pointer_cast<const ExactSlotRequirement>(*ptr))->locked() ? Qtrue : Qfalse;
- }
-
- /*
- * Document-method: name
- *
- * The name requirement.
- */
- static VALUE
- exact_slot_requirement_name(VALUE self)
- {
- std::shared_ptr<const PackageDepSpecRequirement> * ptr;
- Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecRequirement>, ptr);
- return rb_str_new2(stringify((std::static_pointer_cast<const ExactSlotRequirement>(*ptr))->name()).c_str());
- }
-
- /*
- * Document-method: key
- *
- * The key requirement.
- */
- static VALUE
- key_requirement_key(VALUE self)
- {
- std::shared_ptr<const PackageDepSpecRequirement> * ptr;
- Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecRequirement>, ptr);
- return rb_str_new2(stringify((std::static_pointer_cast<const KeyRequirement>(*ptr))->key()).c_str());
- }
-
- /*
- * Document-method: pattern
- *
- * The pattern requirement.
- */
- static VALUE
- key_requirement_pattern(VALUE self)
- {
- std::shared_ptr<const PackageDepSpecRequirement> * ptr;
- Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecRequirement>, ptr);
- return rb_str_new2(stringify((std::static_pointer_cast<const KeyRequirement>(*ptr))->pattern()).c_str());
- }
-
- /*
- * Document-method: operation
- *
- * The operation requirement.
- */
- static VALUE
- key_requirement_operation(VALUE self)
- {
- std::shared_ptr<const PackageDepSpecRequirement> * ptr;
- Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecRequirement>, ptr);
- return INT2FIX((std::static_pointer_cast<const KeyRequirement>(*ptr))->operation());
- }
-
- void do_register_package_dep_spec_requirement()
- {
- /*
- * Document-class: Paludis::PackageDepSpecRequirement
- *
- * Represents a requirement in a PackageDepSpec.
- */
- c_package_dep_spec_requirement = rb_define_class_under(paludis_module(), "PackageDepSpecRequirement", rb_cObject);
- rb_funcall(c_package_dep_spec_requirement, rb_intern("private_class_method"), 1, rb_str_new2("new"));
-
- /*
- * Document-class: Paludis::NameRequirement
- *
- * Represents a cat/pkg name requirement in a PackageDepSpec.
- */
- c_name_requirement = rb_define_class_under(
- paludis_module(), "NameRequirement", c_package_dep_spec_requirement);
- rb_funcall(c_name_requirement, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_package_dep_spec_requirement, "name", RUBY_FUNC_CAST(&name_requirement_name), 0);
-
- /*
- * Document-class: Paludis::PackageNamePartRequirement
- *
- * Represents a /pkg name requirement in a PackageDepSpec.
- */
- c_package_name_part_requirement = rb_define_class_under(
- paludis_module(), "PackageNamePartRequirement", c_package_dep_spec_requirement);
- rb_funcall(c_package_name_part_requirement, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_package_name_part_requirement, "name_part", RUBY_FUNC_CAST(
- &package_name_part_requirement_name_part), 0);
-
- /*
- * Document-class: Paludis::CategoryNamePartRequirement
- *
- * Represents a /pkg name requirement in a PackageDepSpec.
- */
- c_category_name_part_requirement = rb_define_class_under(
- paludis_module(), "CategoryNamePartRequirement", c_package_dep_spec_requirement);
- rb_funcall(c_category_name_part_requirement, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_category_name_part_requirement, "name_part", RUBY_FUNC_CAST(
- &category_name_part_requirement_name_part), 0);
-
- /*
- * Document-class: Paludis::InRepositoryRequirement
- *
- * Represents a /pkg name requirement in a PackageDepSpec.
- */
- c_in_repository_requirement = rb_define_class_under(
- paludis_module(), "InRepositoryRequirement", c_package_dep_spec_requirement);
- rb_funcall(c_in_repository_requirement, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_in_repository_requirement, "name", RUBY_FUNC_CAST(
- &in_repository_requirement_name), 0);
-
- /*
- * Document-class: Paludis::FromRepositoryRequirement
- *
- * Represents a /pkg name requirement in a PackageDepSpec.
- */
- c_from_repository_requirement = rb_define_class_under(
- paludis_module(), "FromRepositoryRequirement", c_package_dep_spec_requirement);
- rb_funcall(c_from_repository_requirement, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_from_repository_requirement, "name", RUBY_FUNC_CAST(
- &from_repository_requirement_name), 0);
-
- /*
- * Document-class: Paludis::InstalledAtPathRequirement
- *
- * Represents a ::/ path requirement in a PackageDepSpec.
- */
- c_installed_at_path_requirement = rb_define_class_under(
- paludis_module(), "InstalledAtPathRequirement", c_package_dep_spec_requirement);
- rb_funcall(c_installed_at_path_requirement, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_installed_at_path_requirement, "path", RUBY_FUNC_CAST(
- &installed_at_path_requirement_path), 0);
-
- /*
- * Document-class: Paludis::InstallableToPathRequirement
- *
- * Represents a ::/? path requirement in a PackageDepSpec.
- */
- c_installable_to_path_requirement = rb_define_class_under(
- paludis_module(), "InstallableToPathRequirement", c_package_dep_spec_requirement);
- rb_funcall(c_installable_to_path_requirement, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_installable_to_path_requirement, "path", RUBY_FUNC_CAST(
- &installable_to_path_requirement_path), 0);
- rb_define_method(c_installable_to_path_requirement, "include_masked?", RUBY_FUNC_CAST(
- &installable_to_path_requirement_include_masked), 0);
-
- /*
- * Document-class: Paludis::InstallableToRepositoryRequirement
- *
- * Represents a ::repo? repository requirement in a PackageDepSpec.
- */
- c_installable_to_repository_requirement = rb_define_class_under(
- paludis_module(), "InstallableToRepositoryRequirement", c_package_dep_spec_requirement);
- rb_funcall(c_installable_to_repository_requirement, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_installable_to_repository_requirement, "name", RUBY_FUNC_CAST(
- &installable_to_repository_requirement_name), 0);
- rb_define_method(c_installable_to_repository_requirement, "include_masked?", RUBY_FUNC_CAST(
- &installable_to_repository_requirement_include_masked), 0);
-
- /*
- * Document-class: Paludis::AnySlotRequirement
- *
- * Represents a :* or := requirement in a PackageDepSpec.
- */
- c_any_slot_requirement = rb_define_class_under(
- paludis_module(), "AnySlotRequirement", c_package_dep_spec_requirement);
- rb_funcall(c_any_slot_requirement, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_any_slot_requirement, "locking?", RUBY_FUNC_CAST(
- &any_slot_requirement_locking), 0);
-
- /*
- * Document-class: Paludis::ExactSlotRequirement
- *
- * Represents a :slot or :=slot requirement in a PackageDepSpec.
- */
- c_exact_slot_requirement = rb_define_class_under(
- paludis_module(), "ExactSlotRequirement", c_package_dep_spec_requirement);
- rb_funcall(c_exact_slot_requirement, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_exact_slot_requirement, "locked?", RUBY_FUNC_CAST(
- &exact_slot_requirement_locked), 0);
- rb_define_method(c_exact_slot_requirement, "name", RUBY_FUNC_CAST(
- &exact_slot_requirement_name), 0);
-
- /*
- * Document-class: Paludis::KeyRequirement
- *
- * Represents a [.key=value] requirement in a PackageDepSpec.
- */
- c_key_requirement = rb_define_class_under(
- paludis_module(), "KeyRequirement", c_package_dep_spec_requirement);
- rb_funcall(c_key_requirement, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_key_requirement, "key", RUBY_FUNC_CAST(
- &key_requirement_key), 0);
- rb_define_method(c_key_requirement, "pattern", RUBY_FUNC_CAST(
- &key_requirement_pattern), 0);
- rb_define_method(c_key_requirement, "operation", RUBY_FUNC_CAST(
- &key_requirement_operation), 0);
-
- /*
- * Document-module: Paludis::KeyRequirementOperation
- *
- * The operation for a KeyRequirement.
- */
- c_key_requirement_operation = rb_define_module_under(paludis_module(), "KeyRequirementOperation");
- for (KeyRequirementOperation l(static_cast<KeyRequirementOperation>(0)), l_end(last_kro) ; l != l_end ;
- l = static_cast<KeyRequirementOperation>(static_cast<int>(l) + 1))
- rb_define_const(c_key_requirement_operation, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
-
- // cc_enum_special<paludis/package_dep_spec_requirement-se.hh, KeyRequirement, c_key_requirement_operation>
-
- /*
- * Document-class: Paludis::ChoiceRequirement
- *
- * Represents a [flag] requirement in a PackageDepSpec.
- */
- c_choice_requirement = rb_define_class_under(
- paludis_module(), "ChoiceRequirement", c_package_dep_spec_requirement);
- rb_funcall(c_choice_requirement, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- }
-}
-
-VALUE
-paludis::ruby::package_dep_spec_requirement_to_value(const std::shared_ptr<const PackageDepSpecRequirement> & m)
-{
- try
- {
- V v(m);
- m->accept(v);
- return v.value;
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
-}
-
-RegisterRubyClass::Register paludis_ruby_register_package_dep_spec_requirement PALUDIS_ATTRIBUTE((used))
- (&do_register_package_dep_spec_requirement);
-
diff --git a/ruby/paludis_ruby.cc b/ruby/paludis_ruby.cc
index 4900726..cf749d2 100644
--- a/ruby/paludis_ruby.cc
+++ b/ruby/paludis_ruby.cc
@@ -384,8 +384,8 @@ paludis::ruby::value_to_match_package_options(VALUE v)
{
VALUE entry(rb_ary_entry(v, i));
Check_Type(entry, T_SYMBOL);
- if (SYM2ID(entry) == rb_intern("ignore_choice_requirements"))
- o += mpo_ignore_choice_requirements;
+ if (SYM2ID(entry) == rb_intern("ignore_additional_requirements"))
+ o += mpo_ignore_additional_requirements;
else
rb_raise(rb_eArgError, "Unknown MatchPackageOptions option '%s'", rb_obj_as_string(entry));
}
@@ -396,8 +396,8 @@ VALUE
paludis::ruby::match_package_options_to_value(const MatchPackageOptions & o)
{
VALUE a(rb_ary_new());
- if (o[mpo_ignore_choice_requirements])
- rb_ary_push(a, ID2SYM(rb_intern("ignore_choice_requirements")));
+ if (o[mpo_ignore_additional_requirements])
+ rb_ary_push(a, ID2SYM(rb_intern("ignore_additional_requirements")));
return a;
}
diff --git a/ruby/paludis_ruby.hh b/ruby/paludis_ruby.hh
index 0e2eb46..aab1fb1 100644
--- a/ruby/paludis_ruby.hh
+++ b/ruby/paludis_ruby.hh
@@ -105,7 +105,6 @@ namespace paludis
VALUE choice_value_to_value(const std::shared_ptr<const ChoiceValue> & c);
VALUE match_package_options_to_value(const MatchPackageOptions & c);
VALUE bool_to_value(bool b);
- VALUE package_dep_spec_requirement_to_value(const std::shared_ptr<const PackageDepSpecRequirement> &);
VersionSpec value_to_version_spec(VALUE v);
std::shared_ptr<const PackageID> value_to_package_id(VALUE, bool nil_ok = false);
diff --git a/src/clients/cave/cmd_digest.cc b/src/clients/cave/cmd_digest.cc
index c78379f..3c8ea88 100644
--- a/src/clients/cave/cmd_digest.cc
+++ b/src/clients/cave/cmd_digest.cc
@@ -47,7 +47,7 @@
#include <paludis/metadata_key.hh>
#include <paludis/standard_output_manager.hh>
#include <paludis/action.hh>
-#include <paludis/dep_spec_data.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <cstdlib>
#include <iostream>
@@ -116,7 +116,7 @@ DigestCommand::run(
throw args::DoHelp("digest takes exactly two parameters");
RepositoryName repo(*next(cmdline.begin_parameters()));
- Filter repo_filter(filter::Matches(MutablePackageDepSpecData({ }).require_in_repository(repo), make_null_shared_ptr(), { }));
+ Filter repo_filter(filter::Matches(make_package_dep_spec({ }).in_repository(repo), make_null_shared_ptr(), { }));
QualifiedPackageName pkg(std::string::npos == cmdline.begin_parameters()->find('/') ?
env->fetch_unique_qualified_package_name(PackageNamePart(*cmdline.begin_parameters()), repo_filter) :
QualifiedPackageName(*cmdline.begin_parameters()));
diff --git a/src/clients/cave/cmd_display_resolution.cc b/src/clients/cave/cmd_display_resolution.cc
index 0a5e8f1..16182dd 100755
--- a/src/clients/cave/cmd_display_resolution.cc
+++ b/src/clients/cave/cmd_display_resolution.cc
@@ -79,7 +79,6 @@
#include <paludis/changed_choices.hh>
#include <paludis/mask_utils.hh>
#include <paludis/dep_spec_annotations.hh>
-#include <paludis/package_dep_spec_requirement.hh>
#include <set>
#include <iterator>
@@ -1427,35 +1426,15 @@ namespace
s.append(" (and " + stringify(c->second.second.size() - 1) + " more)");
cout << fuc(fs_unable_unsuitable_did_not_meet(), fv<'s'>(s));
- if (constraint->spec().if_package() &&
- package_dep_spec_has_properties(*constraint->spec().if_package(), make_named_values<PackageDepSpecProperties>(
- n::has_any_slot_requirement() = indeterminate,
- n::has_category_name_part() = indeterminate,
- n::has_choice_requirements() = true,
- n::has_exact_slot_requirement() = indeterminate,
- n::has_from_repository() = indeterminate,
- n::has_in_repository() = indeterminate,
- n::has_installable_to_path() = indeterminate,
- n::has_installable_to_repository() = indeterminate,
- n::has_installed_at_path() = indeterminate,
- n::has_key_requirements() = indeterminate,
- n::has_package() = indeterminate,
- n::has_package_name_part() = indeterminate,
- n::has_tag() = indeterminate,
- n::has_version_requirements() = indeterminate
- )) &&
+ if (constraint->spec().if_package() && constraint->spec().if_package()->additional_requirements_ptr() &&
(! match_package(*env, *constraint->spec().if_package(), u->package_id(), constraint->from_id(), { })) &&
- match_package(*env, *constraint->spec().if_package(), u->package_id(), constraint->from_id(), { mpo_ignore_choice_requirements }))
+ match_package(*env, *constraint->spec().if_package(), u->package_id(), constraint->from_id(), { mpo_ignore_additional_requirements }))
{
- for (auto a(constraint->spec().if_package()->requirements()->begin()),
- a_end(constraint->spec().if_package()->requirements()->end()) ;
+ for (AdditionalPackageDepSpecRequirements::ConstIterator a(constraint->spec().if_package()->additional_requirements_ptr()->begin()),
+ a_end(constraint->spec().if_package()->additional_requirements_ptr()->end()) ;
a != a_end ; ++a)
{
- auto a_choice(visitor_cast<const ChoiceRequirement>(**a));
- if (! a_choice)
- continue;
-
- const std::pair<bool, std::string> p(a_choice->requirement_met(env.get(), 0, u->package_id(), constraint->from_id(), 0));
+ const std::pair<bool, std::string> p((*a)->requirement_met(env.get(), 0, u->package_id(), constraint->from_id(), 0));
if (p.first)
continue;
diff --git a/src/clients/cave/cmd_execute_resolution.cc b/src/clients/cave/cmd_execute_resolution.cc
index ac530c1..b9b71c1 100644
--- a/src/clients/cave/cmd_execute_resolution.cc
+++ b/src/clients/cave/cmd_execute_resolution.cc
@@ -25,10 +25,8 @@
#include "colours.hh"
#include "resume_data.hh"
#include "format_user_config.hh"
-
#include <paludis/args/do_help.hh>
#include <paludis/args/escape.hh>
-
#include <paludis/util/safe_ifstream.hh>
#include <paludis/util/safe_ofstream.hh>
#include <paludis/util/system.hh>
@@ -50,7 +48,6 @@
#include <paludis/util/timestamp.hh>
#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/util/process.hh>
-
#include <paludis/resolver/resolutions_by_resolvent.hh>
#include <paludis/resolver/reason.hh>
#include <paludis/resolver/sanitised_dependencies.hh>
@@ -65,7 +62,6 @@
#include <paludis/resolver/job.hh>
#include <paludis/resolver/job_state.hh>
#include <paludis/resolver/job_requirements.hh>
-
#include <paludis/package_id.hh>
#include <paludis/version_spec.hh>
#include <paludis/metadata_key.hh>
@@ -84,7 +80,6 @@
#include <paludis/filter.hh>
#include <paludis/elike_blocker.hh>
#include <paludis/repository.hh>
-#include <paludis/package_dep_spec_requirement.hh>
#include <set>
#include <iterator>
@@ -328,7 +323,7 @@ namespace
const auto replacing_ids((*env)[selection::BestVersionOnly(generator::Matches(*i, make_null_shared_ptr(), { }))]);
if (replacing_ids->empty())
r.append(stringify(*i));
- else if (id_specs->empty() || id_specs->begin()->package_name_requirement()->name() != (*replacing_ids->begin())->name())
+ else if (id_specs->empty() || *id_specs->begin()->package_ptr() != (*replacing_ids->begin())->name())
r.append(stringify(**replacing_ids->begin()));
else
r.append((*replacing_ids->begin())->canonical_form(idcf_no_name));
@@ -685,18 +680,16 @@ namespace
PackageDepSpec spec(parse_user_package_dep_spec(std::get<2>(p), env.get(), { updso_no_disambiguation }));
if (package_dep_spec_has_properties(spec, make_named_values<PackageDepSpecProperties>(
- n::has_any_slot_requirement() = false,
+ n::has_additional_requirements() = false,
n::has_category_name_part() = false,
- n::has_choice_requirements() = false,
- n::has_exact_slot_requirement() = false,
n::has_from_repository() = false,
n::has_in_repository() = false,
n::has_installable_to_path() = false,
n::has_installable_to_repository() = false,
n::has_installed_at_path() = false,
- n::has_key_requirements() = false,
n::has_package() = true,
n::has_package_name_part() = false,
+ n::has_slot_requirement() = false,
n::has_tag() = indeterminate,
n::has_version_requirements() = false
)))
diff --git a/src/clients/cave/cmd_fix_linkage.cc b/src/clients/cave/cmd_fix_linkage.cc
index 01c0305..af28ee3 100644
--- a/src/clients/cave/cmd_fix_linkage.cc
+++ b/src/clients/cave/cmd_fix_linkage.cc
@@ -28,7 +28,6 @@
#include <paludis/util/make_named_values.hh>
#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/util/create_iterator-impl.hh>
-
#include <paludis/broken_linkage_finder.hh>
#include <paludis/package_id.hh>
#include <paludis/name.hh>
@@ -37,8 +36,8 @@
#include <paludis/metadata_key.hh>
#include <paludis/notifier_callback.hh>
#include <paludis/version_operator.hh>
-#include <paludis/version_spec.hh>
-#include <paludis/dep_spec_data.hh>
+#include <paludis/version_requirements.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <iostream>
#include <set>
@@ -208,13 +207,15 @@ FixLinkageCommand::run(
cout << endl;
}
- MutablePackageDepSpecData part_spec({ });
- part_spec.require_package((*pkg_it)->name());
+ PartiallyMadePackageDepSpec part_spec({ });
+ part_spec.package((*pkg_it)->name());
if ((*pkg_it)->slot_key())
- part_spec.require_exact_slot((*pkg_it)->slot_key()->parse_value(), false);
+ part_spec.slot_requirement(std::make_shared<UserSlotExactRequirement>((*pkg_it)->slot_key()->parse_value()));
if (cmdline.a_exact.specified())
- part_spec.require_version(vrc_and, vo_equal, (*pkg_it)->version());
+ part_spec.version_requirement(make_named_values<VersionRequirement>(
+ n::version_operator() = vo_equal,
+ n::version_spec() = (*pkg_it)->version()));
targets->push_back(std::make_pair(stringify(PackageDepSpec(part_spec)), join(broken_files.begin(), broken_files.end(), ", ")));
}
diff --git a/src/clients/cave/cmd_graph_jobs.cc b/src/clients/cave/cmd_graph_jobs.cc
index 34ba7d7..5583422 100644
--- a/src/clients/cave/cmd_graph_jobs.cc
+++ b/src/clients/cave/cmd_graph_jobs.cc
@@ -21,9 +21,7 @@
#include "resolve_cmdline.hh"
#include "exceptions.hh"
#include "command_command_line.hh"
-
#include <paludis/args/do_help.hh>
-
#include <paludis/util/safe_ifstream.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/make_shared_copy.hh>
@@ -33,16 +31,13 @@
#include <paludis/util/fs_path.hh>
#include <paludis/util/join.hh>
#include <paludis/util/process.hh>
-
#include <paludis/resolver/job_list.hh>
#include <paludis/resolver/job_lists.hh>
#include <paludis/resolver/job.hh>
#include <paludis/resolver/job_requirements.hh>
-
#include <paludis/serialise-impl.hh>
#include <paludis/dep_spec.hh>
#include <paludis/name.hh>
-#include <paludis/package_dep_spec_requirement.hh>
#include <iostream>
#include <cstdlib>
@@ -91,15 +86,15 @@ namespace
std::string short_spec(const PackageDepSpec & p, bool full)
{
- if (full || ! p.package_name_requirement())
+ if (full || ! p.package_ptr())
return stringify(p);
else
{
- std::string result(stringify(p.package_name_requirement()->name().package()));
- if (p.exact_slot_requirement())
- result = result + ":" + stringify(p.exact_slot_requirement()->name());
- if (p.in_repository_requirement())
- result = result + "::" + stringify(p.in_repository_requirement()->name());
+ std::string result(stringify(p.package_ptr()->package()));
+ if (p.slot_requirement_ptr())
+ result = result + stringify(*p.slot_requirement_ptr());
+ if (p.in_repository_ptr())
+ result = result + "::" + stringify(*p.in_repository_ptr());
return result;
}
}
diff --git a/src/clients/cave/cmd_mirror.cc b/src/clients/cave/cmd_mirror.cc
index 2d92677..f515609 100644
--- a/src/clients/cave/cmd_mirror.cc
+++ b/src/clients/cave/cmd_mirror.cc
@@ -48,6 +48,7 @@
#include <paludis/metadata_key.hh>
#include <paludis/standard_output_manager.hh>
#include <paludis/action.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <cstdlib>
#include <iostream>
diff --git a/src/clients/cave/cmd_print_spec.cc b/src/clients/cave/cmd_print_spec.cc
index b984ad0..00124bd 100644
--- a/src/clients/cave/cmd_print_spec.cc
+++ b/src/clients/cave/cmd_print_spec.cc
@@ -20,10 +20,8 @@
#include "cmd_print_spec.hh"
#include "exceptions.hh"
#include "format_string.hh"
-
#include <paludis/args/args.hh>
#include <paludis/args/do_help.hh>
-
#include <paludis/util/visitor_cast.hh>
#include <paludis/util/set.hh>
#include <paludis/util/iterator_funcs.hh>
@@ -34,16 +32,14 @@
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/join.hh>
#include <paludis/util/make_named_values.hh>
-
#include <paludis/environment.hh>
#include <paludis/metadata_key.hh>
#include <paludis/user_dep_spec.hh>
+#include <paludis/additional_package_dep_spec_requirement.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/version_operator.hh>
-#include <paludis/version_spec.hh>
-#include <paludis/elike_use_requirement.hh>
-#include <paludis/dep_spec_data.hh>
-
+#include <paludis/version_requirements.hh>
#include <iostream>
#include <algorithm>
@@ -122,43 +118,45 @@ namespace
const PrintSpecCommandLine & cmdline
)
{
- MutablePackageDepSpecData s(*spec.data());
+ PartiallyMadePackageDepSpec s(spec);
if (cmdline.a_package.specified())
{
- s.unrequire_package();
- s.unrequire_package_name_part();
- s.unrequire_category_name_part();
- if (! cmdline.a_package.argument().empty())
- s.require_package(QualifiedPackageName(cmdline.a_package.argument()));
+ if (cmdline.a_package.argument().empty())
+ s.clear_package();
+ else
+ s.package(QualifiedPackageName(cmdline.a_package.argument()));
}
if (cmdline.a_slot_requirement.specified())
{
- s.unrequire_exact_slot();
- s.unrequire_any_slot();
- if (! cmdline.a_slot_requirement.argument().empty())
- s.require_exact_slot(SlotName(cmdline.a_slot_requirement.argument()), false);
+ if (cmdline.a_slot_requirement.argument().empty())
+ s.clear_slot_requirement();
+ else
+ s.slot_requirement(std::make_shared<UserSlotExactRequirement>(SlotName(cmdline.a_slot_requirement.argument())));
}
if (cmdline.a_in_repository.specified())
{
- s.unrequire_in_repository();
- if (! cmdline.a_in_repository.argument().empty())
- s.require_in_repository(RepositoryName(cmdline.a_in_repository.argument()));
+ if (cmdline.a_in_repository.argument().empty())
+ s.clear_in_repository();
+ else
+ s.in_repository(RepositoryName(cmdline.a_in_repository.argument()));
}
if (cmdline.a_from_repository.specified())
{
- s.unrequire_from_repository();
- if (! cmdline.a_from_repository.argument().empty())
- s.require_from_repository(RepositoryName(cmdline.a_from_repository.argument()));
+ if (cmdline.a_from_repository.argument().empty())
+ s.clear_from_repository();
+ else
+ s.from_repository(RepositoryName(cmdline.a_from_repository.argument()));
}
if (cmdline.a_installable_to_repository.specified())
{
- s.unrequire_installable_to_repository();
- if (! cmdline.a_installable_to_repository.argument().empty())
+ if (cmdline.a_installable_to_repository.argument().empty())
+ s.clear_installable_to_repository();
+ else
{
std::string repo(cmdline.a_installable_to_repository.argument());
bool include_masked(false);
@@ -168,21 +166,26 @@ namespace
include_masked = true;
}
- s.require_installable_to_repository(RepositoryName(repo), include_masked);
+ s.installable_to_repository(make_named_values<InstallableToRepository>(
+ n::include_masked() = include_masked,
+ n::repository() = RepositoryName(repo)
+ ));
}
}
if (cmdline.a_installed_at_path.specified())
{
- s.unrequire_installed_at_path();
- if (! cmdline.a_installed_at_path.argument().empty())
- s.require_installed_at_path(FSPath(cmdline.a_installed_at_path.argument()));
+ if (cmdline.a_installed_at_path.argument().empty())
+ s.clear_installed_at_path();
+ else
+ s.installed_at_path(FSPath(cmdline.a_installed_at_path.argument()));
}
if (cmdline.a_installable_to_path.specified())
{
- s.unrequire_installable_to_path();
- if (! cmdline.a_installable_to_path.argument().empty())
+ if (cmdline.a_installable_to_path.argument().empty())
+ s.clear_installable_to_path();
+ else
{
std::string path(cmdline.a_installable_to_path.argument());
bool include_masked(false);
@@ -192,43 +195,32 @@ namespace
include_masked = true;
}
- s.require_installable_to_path(FSPath(path), include_masked);
+ s.installable_to_path(make_named_values<InstallableToPath>(
+ n::include_masked() = include_masked,
+ n::path() = FSPath(path)
+ ));
}
}
- if (cmdline.a_package_part.specified() || cmdline.a_category_part.specified())
- {
- s.unrequire_package();
- s.unrequire_package_name_part();
- s.unrequire_category_name_part();
- }
-
if (cmdline.a_package_part.specified())
{
- if (! cmdline.a_package_part.argument().empty())
- s.require_package_name_part(PackageNamePart(cmdline.a_package_part.argument()));
+ if (cmdline.a_package_part.argument().empty())
+ s.clear_package_name_part();
+ else
+ s.package_name_part(PackageNamePart(cmdline.a_package_part.argument()));
}
if (cmdline.a_category_part.specified())
{
- if (! cmdline.a_category_part.argument().empty())
- s.require_category_name_part(CategoryNamePart(cmdline.a_category_part.argument()));
- }
-
- VersionRequirementCombiner vrc(vrc_and);
- if (cmdline.a_version_requirements_mode.specified())
- {
- if (cmdline.a_version_requirements_mode.argument() == "and")
- vrc = vrc_and;
- else if (cmdline.a_version_requirements_mode.argument() == "or")
- vrc = vrc_or;
+ if (cmdline.a_category_part.argument().empty())
+ s.clear_category_name_part();
else
- throw args::DoHelp("Argument for --" + cmdline.a_version_requirements_mode.long_name() + " unrecognised");
+ s.category_name_part(CategoryNamePart(cmdline.a_category_part.argument()));
}
if (cmdline.a_version_requirement.specified())
{
- s.unrequire_versions();
+ s.clear_version_requirements();
for (args::StringSetArg::ConstIterator a(cmdline.a_version_requirement.begin_args()),
a_end(cmdline.a_version_requirement.end_args()) ;
@@ -240,22 +232,33 @@ namespace
throw args::DoHelp("--" + cmdline.a_version_requirement.long_name() + " arguments should be in the form =1.23");
std::string op(a->substr(0, p)), ver(a->substr(p));
- s.require_version(vrc, VersionOperator(op), VersionSpec(ver, {}));
+
+ s.version_requirement(make_named_values<VersionRequirement>(
+ n::version_operator() = VersionOperator(op),
+ n::version_spec() = VersionSpec(ver, {})
+ ));
}
}
+ if (cmdline.a_version_requirements_mode.specified())
+ {
+ if (cmdline.a_version_requirements_mode.argument() == "and")
+ s.version_requirements_mode(vr_and);
+ else if (cmdline.a_version_requirements_mode.argument() == "or")
+ s.version_requirements_mode(vr_or);
+ else
+ throw args::DoHelp("Argument for --" + cmdline.a_version_requirements_mode.long_name() + " unrecognised");
+ }
+
if (cmdline.a_additional_requirement.specified())
{
- s.unrequire_choices();
+ s.clear_additional_requirements();
for (args::StringSetArg::ConstIterator a(cmdline.a_additional_requirement.begin_args()),
a_end(cmdline.a_additional_requirement.end_args()) ;
a != a_end ; ++a)
if (! a->empty())
- {
- auto k(parse_elike_use_requirement(*a, { }));
- s.require_choice(k);
- }
+ s.additional_requirement(std::make_shared<UserKeyRequirement>(*a));
}
cout << PackageDepSpec(s) << endl;
diff --git a/src/clients/cave/cmd_report.cc b/src/clients/cave/cmd_report.cc
index 1959a6d..6d6704a 100644
--- a/src/clients/cave/cmd_report.cc
+++ b/src/clients/cave/cmd_report.cc
@@ -37,9 +37,9 @@
#include <paludis/metadata_key.hh>
#include <paludis/mask.hh>
#include <paludis/match_package.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
+#include <paludis/version_requirements.hh>
#include <paludis/action.hh>
-#include <paludis/version_operator.hh>
-#include <paludis/dep_spec_data.hh>
#include <paludis/util/set.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
@@ -107,9 +107,11 @@ namespace
{
auto ids((*env)[selection::BestVersionOnly((
generator::InRepository(RepositoryName(*r)) &
- generator::Matches(MutablePackageDepSpecData({ })
- .require_package(id->name())
- .require_version(vrc_and, vo_equal, id->version()),
+ generator::Matches(make_package_dep_spec({ })
+ .package(id->name())
+ .version_requirement(make_named_values<VersionRequirement>(
+ n::version_operator() = vo_equal,
+ n::version_spec() = id->version())),
make_null_shared_ptr(), { })) |
filter::SupportsAction<InstallAction>())]);
diff --git a/src/clients/cave/cmd_show.cc b/src/clients/cave/cmd_show.cc
index 2f4ce6b..0adbc26 100644
--- a/src/clients/cave/cmd_show.cc
+++ b/src/clients/cave/cmd_show.cc
@@ -25,20 +25,8 @@
#include "format_user_config.hh"
#include "parse_spec_with_nice_error.hh"
-#include <paludis/util/set.hh>
-#include <paludis/util/wrapped_forward_iterator.hh>
-#include <paludis/util/visitor_cast.hh>
-#include <paludis/util/indirect_iterator-impl.hh>
-#include <paludis/util/pretty_print.hh>
-#include <paludis/util/timestamp.hh>
-#include <paludis/util/make_null_shared_ptr.hh>
-#include <paludis/util/accept_visitor.hh>
-#include <paludis/util/stringify.hh>
-#include <paludis/util/join.hh>
-
#include <paludis/args/args.hh>
#include <paludis/args/do_help.hh>
-
#include <paludis/name.hh>
#include <paludis/environment.hh>
#include <paludis/repository.hh>
@@ -49,16 +37,26 @@
#include <paludis/selection.hh>
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/visitor_cast.hh>
+#include <paludis/util/indirect_iterator-impl.hh>
+#include <paludis/util/pretty_print.hh>
+#include <paludis/util/timestamp.hh>
+#include <paludis/util/make_null_shared_ptr.hh>
+#include <paludis/util/accept_visitor.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/join.hh>
#include <paludis/action.hh>
#include <paludis/mask.hh>
#include <paludis/choice.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <paludis/mask_utils.hh>
#include <paludis/permitted_choice_value_parameter_values.hh>
#include <paludis/contents.hh>
#include <paludis/dep_spec_data.hh>
#include <paludis/dep_spec_annotations.hh>
#include <paludis/match_package.hh>
-
#include <cstdlib>
#include <iostream>
#include <algorithm>
@@ -254,7 +252,7 @@ namespace
for (PackageIDSequence::ConstIterator i(names->begin()), i_end(names->end()) ;
i != i_end ; ++i)
{
- PackageDepSpec name_spec(MutablePackageDepSpecData({ }).require_package((*i)->name()));
+ PackageDepSpec name_spec(make_package_dep_spec({ }).package((*i)->name()));
cout << fuc(select_format_for_spec(env, name_spec, make_null_shared_ptr(),
fs_wildcard_spec_installed(),
fs_wildcard_spec_installable(),
@@ -1352,9 +1350,7 @@ namespace
for (auto r(repos.begin()), r_end(repos.end()) ; r != r_end ; ++r)
{
auto r_ids((*env)[selection::AllVersionsGroupedBySlot(generator::Matches(
- MutablePackageDepSpecData(*s.data())
- .unrequire_in_repository()
- .require_in_repository(*r), make_null_shared_ptr(), { }))]);
+ PartiallyMadePackageDepSpec(s).in_repository(*r), make_null_shared_ptr(), { }))]);
if (! r_ids->empty())
do_one_package_with_ids(cmdline, env, basic_ppos, s, r_ids, cout, rest_out);
}
@@ -1381,9 +1377,7 @@ namespace
for (PackageIDSequence::ConstIterator i(ids->begin()), i_end(ids->end()) ;
i != i_end ; ++i)
- do_one_package(cmdline, env, basic_ppos, MutablePackageDepSpecData(*s.data())
- .unrequire_package()
- .require_package((*i)->name()));
+ do_one_package(cmdline, env, basic_ppos, PartiallyMadePackageDepSpec(s).package((*i)->name()));
}
}
@@ -1425,7 +1419,7 @@ ShowCommand::run(
try
{
PackageDepSpec spec(parse_spec_with_nice_error(*p, env.get(), { updso_throw_if_set, updso_allow_wildcards }, filter::All()));
- if ((! spec.package_name_requirement()))
+ if ((! spec.package_ptr()))
do_one_wildcard(env, spec);
else
do_one_package(cmdline, env, basic_ppos, spec);
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index e9356af..b095dfc 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -106,7 +106,6 @@
#include <paludis/generator.hh>
#include <paludis/selection.hh>
#include <paludis/elike_blocker.hh>
-#include <paludis/package_dep_spec_properties.hh>
#include <algorithm>
#include <iostream>
@@ -1125,23 +1124,7 @@ paludis::cave::resolve_common(
if ('!' != t->at(0) && std::string::npos != t->find('/'))
{
PackageDepSpec ts(parse_spec_with_nice_error(*t, env.get(), { }, filter::All()));
-
- if (package_dep_spec_has_properties(ts, make_named_values<PackageDepSpecProperties>(
- n::has_any_slot_requirement() = indeterminate,
- n::has_category_name_part() = indeterminate,
- n::has_choice_requirements() = indeterminate,
- n::has_exact_slot_requirement() = indeterminate,
- n::has_from_repository() = indeterminate,
- n::has_in_repository() = indeterminate,
- n::has_installable_to_path() = indeterminate,
- n::has_installable_to_repository() = indeterminate,
- n::has_installed_at_path() = indeterminate,
- n::has_key_requirements() = indeterminate,
- n::has_package() = indeterminate,
- n::has_package_name_part() = indeterminate,
- n::has_tag() = indeterminate,
- n::has_version_requirements() = true
- )))
+ if (ts.version_requirements_ptr() && ! ts.version_requirements_ptr()->empty())
{
confirm_helper.add_permit_downgrade_spec(ts);
confirm_helper.add_permit_old_version_spec(ts);