diff options
author | 2011-03-30 11:37:31 +0100 | |
---|---|---|
committer | 2011-04-04 08:32:59 +0100 | |
commit | 28626b8aa3b39d400f8f9eb3a0730ac101b2e53a (patch) | |
tree | c60cfb02dcee2efcf7045ccfd53316e5a8fe94a8 | |
parent | a004eeed5dda3432dcb1a4c0a865ae24daae4fd3 (diff) | |
download | paludis-28626b8aa3b39d400f8f9eb3a0730ac101b2e53a.tar.gz paludis-28626b8aa3b39d400f8f9eb3a0730ac101b2e53a.tar.xz |
slot to requirements
51 files changed, 455 insertions, 587 deletions
diff --git a/doc/api/cplusplus/examples/example_dep_spec.cc b/doc/api/cplusplus/examples/example_dep_spec.cc index 71b6c936b..8b72b16df 100644 --- a/doc/api/cplusplus/examples/example_dep_spec.cc +++ b/doc/api/cplusplus/examples/example_dep_spec.cc @@ -98,8 +98,8 @@ int main(int argc, char * argv[]) cout << endl; } - if (spec.slot_requirement_ptr()) - cout << " " << left << setw(24) << "Slot:" << " " << *spec.slot_requirement_ptr() << endl; + if (spec.exact_slot_constraint()) + cout << " " << left << setw(24) << "Slot:" << " " << spec.exact_slot_constraint()->name() << endl; if (spec.in_repository_constraint()) cout << " " << left << setw(24) << "In repository:" << " " << diff --git a/paludis/common_sets.cc b/paludis/common_sets.cc index 183c2a4f0..308e3b868 100644 --- a/paludis/common_sets.cc +++ b/paludis/common_sets.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2009, 2010 Ciaran McCreesh + * Copyright (c) 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 @@ -27,7 +27,6 @@ #include <paludis/filtered_generator.hh> #include <paludis/metadata_key.hh> #include <paludis/package_id.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> @@ -59,8 +58,7 @@ namespace result->top()->append(std::make_shared<PackageDepSpec>( make_package_dep_spec({ }) .package((*i)->name()) - .slot_requirement(std::make_shared<ELikeSlotExactRequirement>( - (*i)->slot_key()->value(), false)) + .exact_slot_constraint((*i)->slot_key()->value(), false) )); else result->top()->append(std::make_shared<PackageDepSpec>( diff --git a/paludis/dep_spec.cc b/paludis/dep_spec.cc index 4b5fe744b..432f0fbf6 100644 --- a/paludis/dep_spec.cc +++ b/paludis/dep_spec.cc @@ -572,10 +572,16 @@ PackageDepSpec::version_requirements_mode() const return _imp->data->version_requirements_mode(); } -std::shared_ptr<const SlotRequirement> -PackageDepSpec::slot_requirement_ptr() const +const std::shared_ptr<const AnySlotConstraint> +PackageDepSpec::any_slot_constraint() const { - return _imp->data->slot_requirement_ptr(); + return _imp->data->any_slot_constraint(); +} + +const std::shared_ptr<const ExactSlotConstraint> +PackageDepSpec::exact_slot_constraint() const +{ + return _imp->data->exact_slot_constraint(); } const std::shared_ptr<const InRepositoryConstraint> diff --git a/paludis/dep_spec.hh b/paludis/dep_spec.hh index d99e9f154..9c6bb9ae2 100644 --- a/paludis/dep_spec.hh +++ b/paludis/dep_spec.hh @@ -34,7 +34,6 @@ #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> @@ -351,9 +350,20 @@ namespace paludis VersionRequirementsMode version_requirements_mode() const; /** - * Fetch the slot requirement (may be a zero pointer). + * Fetch the single ExactSlotConstraint, if we have one, or + * a null pointer otherwise. + * + * \since 0.61 + */ + const std::shared_ptr<const ExactSlotConstraint> exact_slot_constraint() const; + + /** + * Fetch the single AnySlotConstraint, if we have one, or + * a null pointer otherwise. + * + * \since 0.61 */ - std::shared_ptr<const SlotRequirement> slot_requirement_ptr() const; + const std::shared_ptr<const AnySlotConstraint> any_slot_constraint() const; /** * Fetch the single InRepositoryConstraint, if we have one, or diff --git a/paludis/dep_spec_data.hh b/paludis/dep_spec_data.hh index 4652caf2f..6f4dc6458 100644 --- a/paludis/dep_spec_data.hh +++ b/paludis/dep_spec_data.hh @@ -27,7 +27,6 @@ #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> @@ -148,9 +147,20 @@ namespace paludis virtual VersionRequirementsMode version_requirements_mode() const = 0; /** - * Fetch the slot name (may be a zero pointer). + * Fetch the single ExactSlotConstraint, if we have one, or + * a null pointer otherwise. + * + * \since 0.61 + */ + virtual const std::shared_ptr<const ExactSlotConstraint> exact_slot_constraint() const = 0; + + /** + * Fetch the single AnySlotConstraint, if we have one, or + * a null pointer otherwise. + * + * \since 0.61 */ - virtual std::shared_ptr<const SlotRequirement> slot_requirement_ptr() const = 0; + virtual const std::shared_ptr<const AnySlotConstraint> any_slot_constraint() const = 0; /** * Fetch the single InRepositoryConstraint, if we have one, or diff --git a/paludis/elike_package_dep_spec.cc b/paludis/elike_package_dep_spec.cc index 91433ef17..1c70cdb3b 100644 --- a/paludis/elike_package_dep_spec.cc +++ b/paludis/elike_package_dep_spec.cc @@ -19,7 +19,6 @@ #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> @@ -292,7 +291,7 @@ paludis::elike_remove_trailing_slot_if_exists(std::string & s, PartiallyMadePack Log::get_instance()->message("e.package_dep_spec.slot_star_not_allowed", ll_warning, lc_context) << "Slot '*' dependencies not safe for use here"; } - result.slot_requirement(std::make_shared<ELikeSlotAnyUnlockedRequirement>()); + result.any_slot_constraint(false); } else if ('=' == match.at(0)) { @@ -306,9 +305,9 @@ paludis::elike_remove_trailing_slot_if_exists(std::string & s, PartiallyMadePack } if (1 == match.length()) - result.slot_requirement(std::make_shared<ELikeSlotAnyLockedRequirement>()); + result.any_slot_constraint(true); else - result.slot_requirement(std::make_shared<ELikeSlotExactRequirement>(SlotName(s.substr(slot_p + 2)), true)); + result.exact_slot_constraint(SlotName(s.substr(slot_p + 2)), true); } else { @@ -320,7 +319,7 @@ paludis::elike_remove_trailing_slot_if_exists(std::string & s, PartiallyMadePack Log::get_instance()->message("e.package_dep_spec.slot_not_allowed", ll_warning, lc_context) << "Slot dependencies not safe for use here"; } - result.slot_requirement(std::make_shared<ELikeSlotExactRequirement>(SlotName(s.substr(slot_p + 1)), false)); + result.exact_slot_constraint(SlotName(s.substr(slot_p + 1)), false); } s.erase(slot_p); } diff --git a/paludis/elike_slot_requirement-fwd.hh b/paludis/elike_slot_requirement-fwd.hh deleted file mode 100644 index 9ec151304..000000000 --- a/paludis/elike_slot_requirement-fwd.hh +++ /dev/null @@ -1,30 +0,0 @@ -/* 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 deleted file mode 100644 index ea52fe434..000000000 --- a/paludis/elike_slot_requirement.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* 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 deleted file mode 100644 index ad33609ef..000000000 --- a/paludis/elike_slot_requirement.hh +++ /dev/null @@ -1,58 +0,0 @@ -/* 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/files.m4 b/paludis/files.m4 index abc367b12..7b69c2d81 100644 --- a/paludis/files.m4 +++ b/paludis/files.m4 @@ -38,7 +38,6 @@ 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') @@ -93,7 +92,6 @@ add(`selection_cache', `hh', `cc', `fwd') 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') diff --git a/paludis/generator.cc b/paludis/generator.cc index 1484bbb29..bc5dcdae8 100644 --- a/paludis/generator.cc +++ b/paludis/generator.cc @@ -306,7 +306,9 @@ namespace { if (package_dep_spec_has_properties(spec, make_named_values<PackageDepSpecProperties>( n::has_additional_requirements() = indeterminate, + n::has_any_slot_requirement() = indeterminate, n::has_category_name_part() = indeterminate, + n::has_exact_slot_requirement() = indeterminate, n::has_from_repository() = indeterminate, n::has_in_repository() = false, n::has_installable_to_path() = indeterminate, @@ -314,7 +316,6 @@ namespace n::has_installed_at_path() = false, n::has_package() = indeterminate, n::has_package_name_part() = indeterminate, - n::has_slot_requirement() = indeterminate, n::has_tag() = indeterminate, n::has_version_requirements() = indeterminate ))) diff --git a/paludis/match_package.cc b/paludis/match_package.cc index 9995bf35f..424628f3b 100644 --- a/paludis/match_package.cc +++ b/paludis/match_package.cc @@ -23,7 +23,6 @@ #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> @@ -47,36 +46,6 @@ using namespace paludis; #include <paludis/match_package-se.cc> -namespace -{ - struct SlotRequirementChecker - { - const std::shared_ptr<const PackageID> id; - bool result; - - SlotRequirementChecker(const std::shared_ptr<const PackageID> & i) : - id(i), - result(true) - { - } - - void visit(const SlotExactRequirement & s) - { - result = id->slot_key() && id->slot_key()->value() == s.slot(); - } - - void visit(const SlotAnyLockedRequirement &) - { - result = true; - } - - void visit(const SlotAnyUnlockedRequirement &) - { - result = true; - } - }; -} - bool paludis::match_package_with_maybe_changes( const Environment & env, @@ -194,14 +163,17 @@ paludis::match_package_with_maybe_changes( return false; } - if (spec.slot_requirement_ptr()) + if (spec.exact_slot_constraint()) { - SlotRequirementChecker v(id); - spec.slot_requirement_ptr()->accept(v); - if (! v.result) + if ((! id->slot_key()) || (id->slot_key()->value() != spec.exact_slot_constraint()->name())) return false; } + if (spec.any_slot_constraint()) + { + /* don't care */ + } + if (! options[mpo_ignore_additional_requirements]) { if (spec.additional_requirements_ptr()) diff --git a/paludis/package_dep_spec_constraint-fwd.hh b/paludis/package_dep_spec_constraint-fwd.hh index b949a2b7f..b8c43a693 100644 --- a/paludis/package_dep_spec_constraint-fwd.hh +++ b/paludis/package_dep_spec_constraint-fwd.hh @@ -49,6 +49,12 @@ namespace paludis class InstallableToRepositoryConstraint; typedef Pool<InstallableToRepositoryConstraint> InstallableToRepositoryConstraintPool; + + class ExactSlotConstraint; + typedef Pool<ExactSlotConstraint> ExactSlotConstraintPool; + + class AnySlotConstraint; + typedef Pool<AnySlotConstraint> AnySlotConstraintPool; } #endif diff --git a/paludis/package_dep_spec_constraint.cc b/paludis/package_dep_spec_constraint.cc index dc1f4ad65..b1e6b96c9 100644 --- a/paludis/package_dep_spec_constraint.cc +++ b/paludis/package_dep_spec_constraint.cc @@ -184,3 +184,44 @@ template class Singleton<Pool<InstallableToRepositoryConstraint> >; template const std::shared_ptr<const InstallableToRepositoryConstraint> Pool<InstallableToRepositoryConstraint>::create( const RepositoryName &, const bool & ...) const; +ExactSlotConstraint::ExactSlotConstraint(const SlotName & n, const bool i) : + _name(n), + _locked(i) +{ +} + +ExactSlotConstraint::~ExactSlotConstraint() = default; + +const SlotName +ExactSlotConstraint::name() const +{ + return _name; +} + +bool +ExactSlotConstraint::locked() const +{ + return _locked; +} + +template class Pool<ExactSlotConstraint>; +template class Singleton<Pool<ExactSlotConstraint> >; +template const std::shared_ptr<const ExactSlotConstraint> Pool<ExactSlotConstraint>::create(const SlotName &, const bool & ...) const; + +AnySlotConstraint::AnySlotConstraint(const bool i) : + _locking(i) +{ +} + +AnySlotConstraint::~AnySlotConstraint() = default; + +bool +AnySlotConstraint::locking() const +{ + return _locking; +} + +template class Pool<AnySlotConstraint>; +template class Singleton<Pool<AnySlotConstraint> >; +template const std::shared_ptr<const AnySlotConstraint> Pool<AnySlotConstraint>::create(const bool &) const; + diff --git a/paludis/package_dep_spec_constraint.hh b/paludis/package_dep_spec_constraint.hh index 7e71bd646..f23ba66e6 100644 --- a/paludis/package_dep_spec_constraint.hh +++ b/paludis/package_dep_spec_constraint.hh @@ -40,7 +40,9 @@ namespace paludis FromRepositoryConstraint, InstalledAtPathConstraint, InstallableToPathConstraint, - InstallableToRepositoryConstraint + InstallableToRepositoryConstraint, + AnySlotConstraint, + ExactSlotConstraint >::Type> { public: @@ -203,6 +205,46 @@ namespace paludis bool include_masked() const PALUDIS_ATTRIBUTE((warn_unused_result)); }; + class PALUDIS_VISIBLE ExactSlotConstraint : + public PackageDepSpecConstraint, + public ImplementAcceptMethods<PackageDepSpecConstraint, ExactSlotConstraint> + { + friend class Pool<ExactSlotConstraint>; + + private: + SlotName _name; + bool _locked; + + ExactSlotConstraint(const SlotName &, const bool); + + ExactSlotConstraint(const ExactSlotConstraint &) = delete; + + public: + ~ExactSlotConstraint(); + + const SlotName name() const PALUDIS_ATTRIBUTE((warn_unused_result)); + bool locked() const PALUDIS_ATTRIBUTE((warn_unused_result)); + }; + + class PALUDIS_VISIBLE AnySlotConstraint : + public PackageDepSpecConstraint, + public ImplementAcceptMethods<PackageDepSpecConstraint, AnySlotConstraint> + { + friend class Pool<AnySlotConstraint>; + + private: + bool _locking; + + AnySlotConstraint(const bool); + + AnySlotConstraint(const AnySlotConstraint &) = delete; + + public: + ~AnySlotConstraint(); + + bool locking() const PALUDIS_ATTRIBUTE((warn_unused_result)); + }; + extern template class Pool<NameConstraint>; extern template class Pool<PackageNamePartConstraint>; extern template class Pool<CategoryNamePartConstraint>; @@ -211,6 +253,8 @@ namespace paludis extern template class Pool<InstalledAtPathConstraint>; extern template class Pool<InstallableToPathConstraint>; extern template class Pool<InstallableToRepositoryConstraint>; + extern template class Pool<ExactSlotConstraint>; + extern template class Pool<AnySlotConstraint>; } #endif diff --git a/paludis/package_dep_spec_properties.cc b/paludis/package_dep_spec_properties.cc index dbb057fad..000b20c07 100644 --- a/paludis/package_dep_spec_properties.cc +++ b/paludis/package_dep_spec_properties.cc @@ -50,7 +50,8 @@ paludis::package_dep_spec_has_properties(const PackageDepSpec & spec, const Pack result = result && check(bool(spec.installed_at_path_constraint()), properties.has_installed_at_path()); result = result && check(bool(spec.package_name_constraint()), properties.has_package()); result = result && check(bool(spec.package_name_part_constraint()), properties.has_package_name_part()); - result = result && check(bool(spec.slot_requirement_ptr()), properties.has_slot_requirement()); + result = result && check(bool(spec.exact_slot_constraint()), properties.has_exact_slot_requirement()); + result = result && check(bool(spec.any_slot_constraint()), properties.has_any_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 45ed0fac6..e9eff067c 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 Ciaran McCreesh + * Copyright (c) 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 @@ -29,7 +29,9 @@ namespace paludis namespace n { typedef Name<struct name_has_additional_requirements> has_additional_requirements; + typedef Name<struct name_has_any_slot_requirement> has_any_slot_requirement; typedef Name<struct name_has_category_name_part> has_category_name_part; + 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; @@ -37,7 +39,6 @@ namespace paludis typedef Name<struct name_has_installed_at_path> has_installed_at_path; 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; } @@ -51,7 +52,9 @@ namespace paludis struct PackageDepSpecProperties { NamedValue<n::has_additional_requirements, Tribool> has_additional_requirements; + NamedValue<n::has_any_slot_requirement, Tribool> has_any_slot_requirement; NamedValue<n::has_category_name_part, Tribool> has_category_name_part; + 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; @@ -59,7 +62,6 @@ namespace paludis NamedValue<n::has_installed_at_path, Tribool> has_installed_at_path; 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; }; diff --git a/paludis/paludislike_options_conf.cc b/paludis/paludislike_options_conf.cc index 471f437f8..8af91db93 100644 --- a/paludis/paludislike_options_conf.cc +++ b/paludis/paludislike_options_conf.cc @@ -342,7 +342,9 @@ namespace { return package_dep_spec_has_properties(spec, make_named_values<PackageDepSpecProperties>( n::has_additional_requirements() = false, + n::has_any_slot_requirement() = indeterminate, n::has_category_name_part() = false, + n::has_exact_slot_requirement() = false, n::has_from_repository() = false, n::has_in_repository() = false, n::has_installable_to_path() = false, @@ -350,7 +352,6 @@ namespace n::has_installed_at_path() = 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.cc b/paludis/partially_made_package_dep_spec.cc index 5de8177f4..b070d0c06 100644 --- a/paludis/partially_made_package_dep_spec.cc +++ b/paludis/partially_made_package_dep_spec.cc @@ -53,7 +53,8 @@ namespace std::shared_ptr<const CategoryNamePartConstraint> category_name_part; std::shared_ptr<VersionRequirements> version_requirements; VersionRequirementsMode version_requirements_mode_v; - std::shared_ptr<const SlotRequirement> slot; + std::shared_ptr<const AnySlotConstraint> any_slot; + std::shared_ptr<const ExactSlotConstraint> exact_slot; std::shared_ptr<const InRepositoryConstraint> in_repository; std::shared_ptr<const FromRepositoryConstraint> from_repository; std::shared_ptr<const InstallableToRepositoryConstraint> installable_to_repository; @@ -76,7 +77,8 @@ namespace category_name_part(other.category_name_part_constraint()), version_requirements(other.version_requirements_ptr() ? new VersionRequirements : 0), version_requirements_mode_v(other.version_requirements_mode()), - slot(other.slot_requirement_ptr()), + any_slot(other.any_slot_constraint()), + exact_slot(other.exact_slot_constraint()), in_repository(other.in_repository_constraint()), from_repository(other.from_repository_constraint()), installable_to_repository(other.installable_to_repository_constraint()), @@ -101,7 +103,8 @@ namespace category_name_part(other.category_name_part), version_requirements(other.version_requirements), version_requirements_mode_v(other.version_requirements_mode_v), - slot(other.slot), + any_slot(other.any_slot), + exact_slot(other.exact_slot), in_repository(other.in_repository), from_repository(other.from_repository), installable_to_repository(other.installable_to_repository), @@ -162,8 +165,23 @@ namespace } } - if (slot_requirement_ptr()) - s << stringify(*slot_requirement_ptr()); + if (exact_slot_constraint()) + { + if (exact_slot_constraint()->locked()) + s << ":="; + else + s << ":"; + + s << stringify(exact_slot_constraint()->name()); + } + + if (any_slot_constraint()) + { + if (any_slot_constraint()->locking()) + s << ":="; + else + s << ":*"; + } std::string left, right; bool need_arrow(false); @@ -303,9 +321,14 @@ namespace return version_requirements_mode_v; } - virtual std::shared_ptr<const SlotRequirement> slot_requirement_ptr() const + virtual const std::shared_ptr<const ExactSlotConstraint> exact_slot_constraint() const + { + return exact_slot; + } + + virtual const std::shared_ptr<const AnySlotConstraint> any_slot_constraint() const { - return slot; + return any_slot; } virtual const std::shared_ptr<const InRepositoryConstraint> in_repository_constraint() const @@ -403,16 +426,30 @@ PartiallyMadePackageDepSpec::clear_package() } PartiallyMadePackageDepSpec & -PartiallyMadePackageDepSpec::slot_requirement(const std::shared_ptr<const SlotRequirement> & s) +PartiallyMadePackageDepSpec::any_slot_constraint(const bool s) +{ + _imp->data->any_slot = AnySlotConstraintPool::get_instance()->create(s); + return *this; +} + +PartiallyMadePackageDepSpec & +PartiallyMadePackageDepSpec::exact_slot_constraint(const SlotName & n, const bool s) +{ + _imp->data->exact_slot = ExactSlotConstraintPool::get_instance()->create(n, s); + return *this; +} + +PartiallyMadePackageDepSpec & +PartiallyMadePackageDepSpec::clear_exact_slot() { - _imp->data->slot = s; + _imp->data->exact_slot.reset(); return *this; } PartiallyMadePackageDepSpec & -PartiallyMadePackageDepSpec::clear_slot_requirement() +PartiallyMadePackageDepSpec::clear_any_slot() { - _imp->data->slot.reset(); + _imp->data->any_slot.reset(); return *this; } diff --git a/paludis/partially_made_package_dep_spec.hh b/paludis/partially_made_package_dep_spec.hh index 6eb9d5ff7..78f7d16ee 100644 --- a/paludis/partially_made_package_dep_spec.hh +++ b/paludis/partially_made_package_dep_spec.hh @@ -63,16 +63,34 @@ namespace paludis PartiallyMadePackageDepSpec & clear_package(); /** - * Set our slot requirements, return ourself. + * Set our exact slot requirements, return ourself. + * + * \since 0.61 */ - PartiallyMadePackageDepSpec & slot_requirement(const std::shared_ptr<const SlotRequirement> &); + PartiallyMadePackageDepSpec & exact_slot_constraint( + const SlotName &, const bool); /** - * Clear our slot requirements, return ourself. + * Set our locked slot requirements, return ourself. * - * \since 0.55 + * \since 0.61 + */ + PartiallyMadePackageDepSpec & any_slot_constraint( + const bool); + + /** + * Clear our exact slot requirements, return ourself. + * + * \since 0.61 + */ + PartiallyMadePackageDepSpec & clear_exact_slot(); + + /** + * Clear our any slot requirements, return ourself. + * + * \since 0.61 */ - PartiallyMadePackageDepSpec & clear_slot_requirement(); + PartiallyMadePackageDepSpec & clear_any_slot(); /** * Set our in-repository requirement, return ourself. diff --git a/paludis/repositories/e/e_repository_sets.cc b/paludis/repositories/e/e_repository_sets.cc index 186b28b61..d9f15fe01 100644 --- a/paludis/repositories/e/e_repository_sets.cc +++ b/paludis/repositories/e/e_repository_sets.cc @@ -26,7 +26,6 @@ #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> diff --git a/paludis/repositories/e/fix_locked_dependencies.cc b/paludis/repositories/e/fix_locked_dependencies.cc index bb613609b..1f952e271 100644 --- a/paludis/repositories/e/fix_locked_dependencies.cc +++ b/paludis/repositories/e/fix_locked_dependencies.cc @@ -28,13 +28,13 @@ #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/partially_made_package_dep_spec.hh> +#include <paludis/package_dep_spec_constraint.hh> #include <functional> #include <algorithm> #include <list> @@ -99,11 +99,7 @@ namespace do { - if (! node.spec()->slot_requirement_ptr()) - break; - - const SlotAnyLockedRequirement * const r(visitor_cast<const SlotAnyLockedRequirement>(*node.spec()->slot_requirement_ptr())); - if (! r) + if ((! node.spec()->any_slot_constraint()) || (! node.spec()->any_slot_constraint()->locking())) break; std::shared_ptr<const PackageIDSequence> matches((*env)[selection::AllVersionsSorted( @@ -113,8 +109,9 @@ namespace if ((*matches->last())->slot_key()) { - PackageDepSpec new_s(PartiallyMadePackageDepSpec(*node.spec()).slot_requirement( - std::make_shared<ELikeSlotExactRequirement>((*matches->last())->slot_key()->value(), true))); + PackageDepSpec new_s(PartiallyMadePackageDepSpec(*node.spec()) + .clear_any_slot() + .exact_slot_constraint((*matches->last())->slot_key()->value(), true)); c = std::make_shared<PackageDepSpec>(new_s); } } while (false); diff --git a/paludis/repositories/virtuals/package_id.cc b/paludis/repositories/virtuals/package_id.cc index a2231e576..f4f48a42f 100644 --- a/paludis/repositories/virtuals/package_id.cc +++ b/paludis/repositories/virtuals/package_id.cc @@ -75,8 +75,7 @@ namespace paludis .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()->value() : SlotName("UNKNOWN"))) + .exact_slot_constraint(v->slot_key() ? v->slot_key()->value() : SlotName("UNKNOWN"), false) .in_repository(v->repository_name())) : std::make_shared<PackageDepSpec>( diff --git a/paludis/resolver/collect_depped_upon.cc b/paludis/resolver/collect_depped_upon.cc index 46bfa86b3..257aae510 100644 --- a/paludis/resolver/collect_depped_upon.cc +++ b/paludis/resolver/collect_depped_upon.cc @@ -29,10 +29,10 @@ #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_constraint.hh> #include <algorithm> using namespace paludis; @@ -108,8 +108,7 @@ namespace { auto spec(s.spec()); - if (s.spec()->slot_requirement_ptr() && visitor_cast<const SlotAnyUnlockedRequirement>( - *s.spec()->slot_requirement_ptr())) + if (s.spec()->any_slot_constraint() && ! s.spec()->any_slot_constraint()->locking()) { auto best_eventual_id(best_eventual(env, *s.spec(), id_for_specs, newly_available)); if (! best_eventual_id) @@ -117,7 +116,7 @@ namespace if (best_eventual_id && best_eventual_id->slot_key()) { PartiallyMadePackageDepSpec part_spec(*s.spec()); - part_spec.slot_requirement(std::make_shared<ELikeSlotExactRequirement>(best_eventual_id->slot_key()->value(), false)); + part_spec.exact_slot_constraint(best_eventual_id->slot_key()->value(), false); spec = std::make_shared<PackageDepSpec>(part_spec); } } diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc index b0e0dbd1b..3af2dc5cd 100644 --- a/paludis/resolver/decider.cc +++ b/paludis/resolver/decider.cc @@ -65,10 +65,8 @@ #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> @@ -1434,27 +1432,6 @@ 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 @@ -1462,11 +1439,8 @@ 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().slot_requirement_ptr()) - { - SlotNameFinder f; - exact_slot = spec.blocking().slot_requirement_ptr()->accept_returning<std::shared_ptr<SlotName> >(f); - } + if (spec.blocking().exact_slot_constraint()) + exact_slot = make_shared_copy(spec.blocking().exact_slot_constraint()->name()); DestinationTypes destination_types(_get_destination_types_for_blocker(spec, reason)); std::shared_ptr<Resolvents> result(std::make_shared<Resolvents>()); @@ -1507,11 +1481,8 @@ Decider::_get_resolvents_for( std::shared_ptr<SlotName> exact_slot; - if (spec.slot_requirement_ptr()) - { - SlotNameFinder f; - exact_slot = spec.slot_requirement_ptr()->accept_returning<std::shared_ptr<SlotName> >(f); - } + if (spec.exact_slot_constraint()) + exact_slot = make_shared_copy(spec.exact_slot_constraint()->name()); return _imp->fns.get_resolvents_for_fn()(spec, maybe_from_package_id_from_reason(reason), exact_slot, reason); } diff --git a/paludis/resolver/find_replacing_helper.cc b/paludis/resolver/find_replacing_helper.cc index 88e315501..42906b6ec 100644 --- a/paludis/resolver/find_replacing_helper.cc +++ b/paludis/resolver/find_replacing_helper.cc @@ -25,7 +25,6 @@ #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 89ea8b9f6..b725c5885 100644 --- a/paludis/resolver/get_constraints_for_dependent_helper.cc +++ b/paludis/resolver/get_constraints_for_dependent_helper.cc @@ -34,7 +34,6 @@ #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; @@ -85,7 +84,7 @@ GetConstraintsForDependentHelper::operator() ( PartiallyMadePackageDepSpec partial_spec({ }); partial_spec.package(id->name()); if (id->slot_key()) - partial_spec.slot_requirement(std::make_shared<ELikeSlotExactRequirement>(id->slot_key()->value(), false)); + partial_spec.exact_slot_constraint(id->slot_key()->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 c410c78f7..eef5082ab 100644 --- a/paludis/resolver/get_constraints_for_purge_helper.cc +++ b/paludis/resolver/get_constraints_for_purge_helper.cc @@ -34,7 +34,6 @@ #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; @@ -80,7 +79,7 @@ GetConstraintsForPurgeHelper::operator() ( PartiallyMadePackageDepSpec partial_spec({ }); partial_spec.package(id->name()); if (id->slot_key()) - partial_spec.slot_requirement(std::make_shared<ELikeSlotExactRequirement>(id->slot_key()->value(), false)); + partial_spec.exact_slot_constraint(id->slot_key()->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_destination_types_for_blocker_helper.cc b/paludis/resolver/get_destination_types_for_blocker_helper.cc index 6a8c80ded..6dc2c30b9 100644 --- a/paludis/resolver/get_destination_types_for_blocker_helper.cc +++ b/paludis/resolver/get_destination_types_for_blocker_helper.cc @@ -32,7 +32,6 @@ #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 efd29b159..a80aefa62 100644 --- a/paludis/resolver/get_destination_types_for_error_helper.cc +++ b/paludis/resolver/get_destination_types_for_error_helper.cc @@ -32,7 +32,6 @@ #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/match_qpns.cc b/paludis/resolver/match_qpns.cc index 366429cc5..2af1ee3d3 100644 --- a/paludis/resolver/match_qpns.cc +++ b/paludis/resolver/match_qpns.cc @@ -42,7 +42,9 @@ paludis::resolver::match_qpns( * but we're lazy) */ if (! package_dep_spec_has_properties(spec, make_named_values<PackageDepSpecProperties>( n::has_additional_requirements() = false, + n::has_any_slot_requirement() = false, n::has_category_name_part() = indeterminate, + n::has_exact_slot_requirement() = false, n::has_from_repository() = false, n::has_in_repository() = false, n::has_installable_to_path() = false, @@ -50,7 +52,6 @@ paludis::resolver::match_qpns( n::has_installed_at_path() = 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 ))) diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc index 284ac1dbe..820f0f7d6 100644 --- a/paludis/resolver/resolver_test.cc +++ b/paludis/resolver/resolver_test.cc @@ -52,7 +52,6 @@ #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 ac0921fd9..d283ab577 100644 --- a/paludis/resolver/sanitised_dependencies.cc +++ b/paludis/resolver/sanitised_dependencies.cc @@ -36,7 +36,6 @@ #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> diff --git a/paludis/set_file.cc b/paludis/set_file.cc index 6d1c767b9..c5dc4c8ef 100644 --- a/paludis/set_file.cc +++ b/paludis/set_file.cc @@ -169,6 +169,18 @@ namespace } }; + PackageDepSpec name_and_slot(const PackageDepSpec & spec) + { + if (spec.exact_slot_constraint()) + return make_package_dep_spec({ }) + .package(spec.package_name_constraint()->name()) + .exact_slot_constraint(spec.exact_slot_constraint()->name(), spec.exact_slot_constraint()->locked()) + ; + else + return make_package_dep_spec({ }) + .package(spec.package_name_constraint()->name()); + } + void do_one_conf_line(const std::string & line, std::shared_ptr<SetSpecTree> result, const SetFileParams & params) @@ -269,10 +281,7 @@ namespace 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( - make_package_dep_spec({ }) - .package(spec->package_name_constraint()->name()) - .slot_requirement(spec->slot_requirement_ptr()), - make_null_shared_ptr(), { }) | + name_and_slot(*spec), make_null_shared_ptr(), { }) | filter::InstalledAtRoot(params.environment()->preferred_root_key()->value()))]->empty()) result->top()->append(spec); } diff --git a/paludis/slot_requirement-fwd.hh b/paludis/slot_requirement-fwd.hh deleted file mode 100644 index 09852be46..000000000 --- a/paludis/slot_requirement-fwd.hh +++ /dev/null @@ -1,36 +0,0 @@ -/* 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_SLOT_REQUIREMENT_FWD_HH -#define PALUDIS_GUARD_PALUDIS_SLOT_REQUIREMENT_FWD_HH 1 - -#include <iosfwd> -#include <paludis/util/attributes.hh> - -namespace paludis -{ - 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 deleted file mode 100644 index 97690e7e8..000000000 --- a/paludis/slot_requirement.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* 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 deleted file mode 100644 index d1c329338..000000000 --- a/paludis/slot_requirement.hh +++ /dev/null @@ -1,59 +0,0 @@ -/* 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 4a8a66d5c..c31ce0883 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 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2008, 2009, 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 @@ -63,8 +63,6 @@ namespace paludis ///\} }; - struct UserSlotExactRequirement; - struct UserKeyRequirement; /** diff --git a/paludis/user_dep_spec.cc b/paludis/user_dep_spec.cc index f2590cd8a..c2de82816 100644 --- a/paludis/user_dep_spec.cc +++ b/paludis/user_dep_spec.cc @@ -245,7 +245,7 @@ namespace std::string::size_type slot_p(s.rfind(':')); if (std::string::npos != slot_p) { - result.slot_requirement(std::make_shared<UserSlotExactRequirement>(SlotName(s.substr(slot_p + 1)))); + result.exact_slot_constraint(SlotName(s.substr(slot_p + 1)), false); s.erase(slot_p); } } @@ -376,22 +376,6 @@ 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") { diff --git a/paludis/user_dep_spec.hh b/paludis/user_dep_spec.hh index d42684504..656791100 100644 --- a/paludis/user_dep_spec.hh +++ b/paludis/user_dep_spec.hh @@ -22,7 +22,6 @@ #include <paludis/user_dep_spec-fwd.hh> #include <paludis/dep_spec.hh> -#include <paludis/slot_requirement.hh> #include <paludis/filter.hh> #include <paludis/additional_package_dep_spec_requirement.hh> #include <paludis/util/pimp.hh> @@ -53,24 +52,6 @@ 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)); - }; - /** * A key requirement for a user PackageDepSpec. * diff --git a/paludis/user_dep_spec_TEST.cc b/paludis/user_dep_spec_TEST.cc index b8a69c35f..d266be6a0 100644 --- a/paludis/user_dep_spec_TEST.cc +++ b/paludis/user_dep_spec_TEST.cc @@ -127,11 +127,11 @@ UserDepSpecTest::check_spec( } if (slot_requirement.empty()) - EXPECT_TRUE(! spec.slot_requirement_ptr()); + EXPECT_TRUE(! spec.exact_slot_constraint()); else { - EXPECT_TRUE(bool(spec.slot_requirement_ptr())); - EXPECT_EQ(slot_requirement, stringify(*spec.slot_requirement_ptr())); + EXPECT_TRUE(bool(spec.exact_slot_constraint())); + EXPECT_EQ(slot_requirement, ":" + stringify(spec.exact_slot_constraint()->name())); } if (from_repository.empty()) diff --git a/python/dep_spec.cc b/python/dep_spec.cc index 5d5ce2fd1..ab05cfb12 100644 --- a/python/dep_spec.cc +++ b/python/dep_spec.cc @@ -78,7 +78,8 @@ namespace paludis std::shared_ptr<const PackageNamePartConstraint> package_name_part_constraint; std::shared_ptr<VersionRequirements> version_requirements; VersionRequirementsMode version_requirements_mode; - std::shared_ptr<const SlotRequirement> slot; + std::shared_ptr<const AnySlotConstraint> any_slot; + std::shared_ptr<const ExactSlotConstraint> exact_slot; std::shared_ptr<const InRepositoryConstraint> in_repository; std::shared_ptr<const FromRepositoryConstraint> from_repository; std::shared_ptr<const AdditionalPackageDepSpecRequirements> additional_requirements; @@ -90,7 +91,8 @@ namespace paludis const std::shared_ptr<const PackageNamePartConstraint> & p, const std::shared_ptr<VersionRequirements> & v, const VersionRequirementsMode m, - const std::shared_ptr<const SlotRequirement> & s, + const std::shared_ptr<const AnySlotConstraint> & s, + const std::shared_ptr<const ExactSlotConstraint> & xs, const std::shared_ptr<const InRepositoryConstraint> & ri, const std::shared_ptr<const FromRepositoryConstraint> & rf, const std::shared_ptr<const AdditionalPackageDepSpecRequirements> & u, @@ -100,7 +102,8 @@ namespace paludis package_name_part_constraint(p), version_requirements(v), version_requirements_mode(m), - slot(s), + any_slot(s), + exact_slot(xs), in_repository(ri), from_repository(rf), additional_requirements(u), @@ -228,7 +231,8 @@ PythonPackageDepSpec::PythonPackageDepSpec(const PackageDepSpec & p) : p.package_name_part_constraint(), std::make_shared<VersionRequirements>(), p.version_requirements_mode(), - p.slot_requirement_ptr(), + p.any_slot_constraint(), + p.exact_slot_constraint(), p.in_repository_constraint(), p.from_repository_constraint(), p.additional_requirements_ptr(), @@ -249,7 +253,8 @@ PythonPackageDepSpec::PythonPackageDepSpec(const PythonPackageDepSpec & p) : p.package_name_part_constraint(), std::make_shared<VersionRequirements>(), p.version_requirements_mode(), - p.slot_requirement_ptr(), + p.any_slot_constraint(), + p.exact_slot_constraint(), p.in_repository_constraint(), p.from_repository_constraint(), p.additional_requirements_ptr(), @@ -278,8 +283,11 @@ PythonPackageDepSpec::operator PackageDepSpec() const p.version_requirements_mode(version_requirements_mode()); - if (slot_requirement_ptr()) - p.slot_requirement(slot_requirement_ptr()); + if (any_slot_constraint()) + p.any_slot_constraint(any_slot_constraint()->locking()); + + if (exact_slot_constraint()) + p.exact_slot_constraint(exact_slot_constraint()->name(), exact_slot_constraint()->locked()); if (in_repository_constraint()) p.in_repository(in_repository_constraint()->name()); @@ -346,10 +354,16 @@ PythonPackageDepSpec::set_version_requirements_mode(const VersionRequirementsMod _imp->version_requirements_mode = m; } -std::shared_ptr<const SlotRequirement> -PythonPackageDepSpec::slot_requirement_ptr() const +const std::shared_ptr<const AnySlotConstraint> +PythonPackageDepSpec::any_slot_constraint() const +{ + return _imp->any_slot; +} + +const std::shared_ptr<const ExactSlotConstraint> +PythonPackageDepSpec::exact_slot_constraint() const { - return _imp->slot; + return _imp->exact_slot; } const std::shared_ptr<const InRepositoryConstraint> @@ -1226,12 +1240,15 @@ void expose_dep_spec() "Version requirements mode." ) -#if 0 - .add_property("slot", &PythonPackageDepSpec::slot_ptr, - "[ro] SlotName\n" - "Slot name (may be None)." + .add_property("exact_slot", &PythonPackageDepSpec::exact_slot_constraint, + "[ro] ExactSlotConstraint\n" + "Exact slot constraint (may be None)." + ) + + .add_property("any_slot", &PythonPackageDepSpec::any_slot_constraint, + "[ro] AnySlotConstraint\n" + "Any slot constraint (may be None)." ) -#endif .add_property("in_repository_constraint", &PythonPackageDepSpec::in_repository_constraint, "[ro] InRepositoryConstraint\n" diff --git a/python/dep_spec.hh b/python/dep_spec.hh index 46963aca0..d53d4ebc0 100644 --- a/python/dep_spec.hh +++ b/python/dep_spec.hh @@ -177,11 +177,12 @@ namespace paludis const std::shared_ptr<const CategoryNamePartConstraint> category_name_part_constraint() const; const std::shared_ptr<const InRepositoryConstraint> in_repository_constraint() const; const std::shared_ptr<const FromRepositoryConstraint> from_repository_constraint() const; + const std::shared_ptr<const ExactSlotConstraint> exact_slot_constraint() const; + const std::shared_ptr<const AnySlotConstraint> any_slot_constraint() 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 AdditionalPackageDepSpecRequirements> additional_requirements_ptr() const; std::string py_str() const; diff --git a/python/package_dep_spec_constraint.cc b/python/package_dep_spec_constraint.cc index e89f463d9..c78ba4127 100644 --- a/python/package_dep_spec_constraint.cc +++ b/python/package_dep_spec_constraint.cc @@ -186,5 +186,39 @@ void expose_package_dep_spec_constraint() "[RO] Whether to include masked, as per ::repo??" ) ; + + /** + * AnySlotConstraint + */ + class_package_dep_spec_constraint<AnySlotConstraint> + ( + "AnySlotConstraint", + "A :* or := constraint for a PackageDepSpec.", + bp::no_init + ) + + .add_property("locking", &AnySlotConstraint::locking, + "[RO] Are we locking (:= rather than :*)?" + ) + ; + + /** + * ExactSlotConstraint + */ + class_package_dep_spec_constraint<ExactSlotConstraint> + ( + "ExactSlotConstraint", + "A :slot or :=slot constraint for a PackageDepSpec.", + bp::no_init + ) + + .add_property("locked", &ExactSlotConstraint::locked, + "[RO] Are we locked (:=blah)?" + ) + + .add_property("name", &ExactSlotConstraint::name, + "[RO] The slot name" + ) + ; } diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc index da98fb9f8..6e6e2a696 100644 --- a/ruby/dep_spec.cc +++ b/ruby/dep_spec.cc @@ -67,56 +67,6 @@ namespace 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; @@ -628,46 +578,62 @@ namespace /* * call-seq: - * text -> String + * any_slot_constraint -> AnySlotConstraint or Nil * - * Fetch our text. + * Fetch the any-slot constraint (may be Nil). */ VALUE - string_dep_spec_text(VALUE self) + package_dep_spec_any_slot_constraint(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()->any_slot_constraint())) + return Qnil; + return package_dep_spec_constraint_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->any_slot_constraint()); } /* * call-seq: - * to_s -> String + * exact_slot_constraint -> ExactSlotConstraint or Nil * - * Fetch a string representation of ourself. + * Fetch the exact-slot constraint (may be Nil). */ - template <typename T_> - VALUE dep_spec_to_s(VALUE self) + VALUE + package_dep_spec_exact_slot_constraint(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()->exact_slot_constraint())) + return Qnil; + return package_dep_spec_constraint_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->exact_slot_constraint()); } /* * call-seq: - * slot_requirement -> SlotRequirement or Nil + * text -> String * - * Fetch the slot requirement. + * Fetch our text. */ VALUE - package_dep_spec_slot_requirement_ptr(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()->slot_requirement_ptr())) - return Qnil; - return slot_requirement_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->slot_requirement_ptr()); + return rb_str_new2(stringify(std::static_pointer_cast<const StringDepSpec>((*ptr)->base_spec())->text()).c_str()); + } + + /* + * call-seq: + * to_s -> String + * + * Fetch a string representation of ourself. + */ + template <typename T_> + VALUE dep_spec_to_s(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()); } /* @@ -958,14 +924,6 @@ 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() { /* @@ -1103,12 +1061,13 @@ namespace rb_define_method(c_package_dep_spec, "package_name_constraint", RUBY_FUNC_CAST(&package_dep_spec_package_name_constraint), 0); rb_define_method(c_package_dep_spec, "package_name_part_constraint", RUBY_FUNC_CAST(&package_dep_spec_package_name_part_constraint), 0); rb_define_method(c_package_dep_spec, "category_name_part_constraint", RUBY_FUNC_CAST(&package_dep_spec_category_name_part_constraint), 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_constraint", RUBY_FUNC_CAST(&package_dep_spec_in_repository_constraint), 0); rb_define_method(c_package_dep_spec, "from_repository_constraint", RUBY_FUNC_CAST(&package_dep_spec_from_repository_constraint), 0); rb_define_method(c_package_dep_spec, "installable_to_repository_constraint", RUBY_FUNC_CAST(&package_dep_spec_installable_to_repository_constraint), 0); rb_define_method(c_package_dep_spec, "installed_at_path_constraint", RUBY_FUNC_CAST(&package_dep_spec_installed_at_path_constraint), 0); rb_define_method(c_package_dep_spec, "installable_to_path_constraint", RUBY_FUNC_CAST(&package_dep_spec_installable_to_path_constraint), 0); + rb_define_method(c_package_dep_spec, "any_slot_constraint", RUBY_FUNC_CAST(&package_dep_spec_any_slot_constraint), 0); + rb_define_method(c_package_dep_spec, "exact_slot_constraint", RUBY_FUNC_CAST(&package_dep_spec_exact_slot_constraint), 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 @@ -1190,38 +1149,6 @@ namespace // 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 7e3db1b9c..d0d63e3f1 100644 --- a/ruby/dep_spec_TEST.rb +++ b/ruby/dep_spec_TEST.rb @@ -130,13 +130,11 @@ module Paludis end def test_slot - 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 + assert_equal "100", pda.exact_slot_constraint.name + assert_nil pdb.exact_slot_constraint + assert_nil pdc.exact_slot_constraint + assert_nil pdd.exact_slot_constraint + assert_nil pde.exact_slot_constraint end def test_package diff --git a/ruby/package_dep_spec_constraint.cc b/ruby/package_dep_spec_constraint.cc index 4d4ed3852..62799087a 100644 --- a/ruby/package_dep_spec_constraint.cc +++ b/ruby/package_dep_spec_constraint.cc @@ -39,6 +39,8 @@ namespace static VALUE c_installed_at_path_constraint; static VALUE c_installable_to_path_constraint; static VALUE c_installable_to_repository_constraint; + static VALUE c_any_slot_constraint; + static VALUE c_exact_slot_constraint; struct V { @@ -97,6 +99,18 @@ namespace value = Data_Wrap_Struct(c_installable_to_repository_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free, new std::shared_ptr<const PackageDepSpecConstraint>(mm)); } + + void visit(const AnySlotConstraint &) + { + value = Data_Wrap_Struct(c_any_slot_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free, + new std::shared_ptr<const PackageDepSpecConstraint>(mm)); + } + + void visit(const ExactSlotConstraint &) + { + value = Data_Wrap_Struct(c_exact_slot_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free, + new std::shared_ptr<const PackageDepSpecConstraint>(mm)); + } }; /* @@ -229,6 +243,45 @@ namespace return (std::static_pointer_cast<const InstallableToRepositoryConstraint>(*ptr))->include_masked() ? Qtrue : Qfalse; } + /* + * Document-method: locking? + * + * The locking constraint. + */ + static VALUE + any_slot_constraint_locking(VALUE self) + { + std::shared_ptr<const PackageDepSpecConstraint> * ptr; + Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecConstraint>, ptr); + return (std::static_pointer_cast<const AnySlotConstraint>(*ptr))->locking() ? Qtrue : Qfalse; + } + + /* + * Document-method: locked? + * + * The locked constraint. + */ + static VALUE + exact_slot_constraint_locked(VALUE self) + { + std::shared_ptr<const PackageDepSpecConstraint> * ptr; + Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecConstraint>, ptr); + return (std::static_pointer_cast<const ExactSlotConstraint>(*ptr))->locked() ? Qtrue : Qfalse; + } + + /* + * Document-method: name + * + * The name constraint. + */ + static VALUE + exact_slot_constraint_name(VALUE self) + { + std::shared_ptr<const PackageDepSpecConstraint> * ptr; + Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecConstraint>, ptr); + return rb_str_new2(stringify((std::static_pointer_cast<const ExactSlotConstraint>(*ptr))->name()).c_str()); + } + void do_register_package_dep_spec_constraint() { /* @@ -329,6 +382,30 @@ namespace &installable_to_repository_constraint_name), 0); rb_define_method(c_installable_to_repository_constraint, "include_masked?", RUBY_FUNC_CAST( &installable_to_repository_constraint_include_masked), 0); + + /* + * Document-class: Paludis::AnySlotConstraint + * + * Represents a :* or := constraint in a PackageDepSpec. + */ + c_any_slot_constraint = rb_define_class_under( + paludis_module(), "AnySlotConstraint", c_package_dep_spec_constraint); + rb_funcall(c_any_slot_constraint, rb_intern("private_class_method"), 1, rb_str_new2("new")); + rb_define_method(c_any_slot_constraint, "locking?", RUBY_FUNC_CAST( + &any_slot_constraint_locking), 0); + + /* + * Document-class: Paludis::ExactSlotConstraint + * + * Represents a :slot or :=slot constraint in a PackageDepSpec. + */ + c_exact_slot_constraint = rb_define_class_under( + paludis_module(), "ExactSlotConstraint", c_package_dep_spec_constraint); + rb_funcall(c_exact_slot_constraint, rb_intern("private_class_method"), 1, rb_str_new2("new")); + rb_define_method(c_exact_slot_constraint, "locked?", RUBY_FUNC_CAST( + &exact_slot_constraint_locked), 0); + rb_define_method(c_exact_slot_constraint, "name", RUBY_FUNC_CAST( + &exact_slot_constraint_name), 0); } } diff --git a/src/clients/cave/cmd_execute_resolution.cc b/src/clients/cave/cmd_execute_resolution.cc index 895be311e..d72dc114b 100644 --- a/src/clients/cave/cmd_execute_resolution.cc +++ b/src/clients/cave/cmd_execute_resolution.cc @@ -686,7 +686,9 @@ 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_additional_requirements() = false, + n::has_any_slot_requirement() = false, n::has_category_name_part() = false, + n::has_exact_slot_requirement() = false, n::has_from_repository() = false, n::has_in_repository() = false, n::has_installable_to_path() = false, @@ -694,7 +696,6 @@ namespace n::has_installed_at_path() = 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 1c9047223..a99f227c5 100644 --- a/src/clients/cave/cmd_fix_linkage.cc +++ b/src/clients/cave/cmd_fix_linkage.cc @@ -210,7 +210,7 @@ FixLinkageCommand::run( PartiallyMadePackageDepSpec part_spec({ }); part_spec.package((*pkg_it)->name()); if ((*pkg_it)->slot_key()) - part_spec.slot_requirement(std::make_shared<UserSlotExactRequirement>((*pkg_it)->slot_key()->value())); + part_spec.exact_slot_constraint((*pkg_it)->slot_key()->value(), false); if (cmdline.a_exact.specified()) part_spec.version_requirement(make_named_values<VersionRequirement>( diff --git a/src/clients/cave/cmd_graph_jobs.cc b/src/clients/cave/cmd_graph_jobs.cc index b573f2847..ff47d9905 100644 --- a/src/clients/cave/cmd_graph_jobs.cc +++ b/src/clients/cave/cmd_graph_jobs.cc @@ -96,8 +96,8 @@ namespace else { std::string result(stringify(p.package_name_constraint()->name().package())); - if (p.slot_requirement_ptr()) - result = result + stringify(*p.slot_requirement_ptr()); + if (p.exact_slot_constraint()) + result = result + ":" + stringify(p.exact_slot_constraint()->name()); if (p.in_repository_constraint()) result = result + "::" + stringify(p.in_repository_constraint()->name()); return result; diff --git a/src/clients/cave/cmd_print_spec.cc b/src/clients/cave/cmd_print_spec.cc index e861e4934..a693bcff5 100644 --- a/src/clients/cave/cmd_print_spec.cc +++ b/src/clients/cave/cmd_print_spec.cc @@ -131,9 +131,15 @@ namespace if (cmdline.a_slot_requirement.specified()) { if (cmdline.a_slot_requirement.argument().empty()) - s.clear_slot_requirement(); + { + s.clear_any_slot(); + s.clear_exact_slot(); + } else - s.slot_requirement(std::make_shared<UserSlotExactRequirement>(SlotName(cmdline.a_slot_requirement.argument()))); + { + s.clear_any_slot(); + s.exact_slot_constraint(SlotName(cmdline.a_slot_requirement.argument()), false); + } } if (cmdline.a_in_repository.specified()) |