diff options
author | 2011-03-28 23:44:02 +0100 | |
---|---|---|
committer | 2011-04-04 08:32:58 +0100 | |
commit | b7f5d7dbfeff2e406ef24ca471657e1735a4db4f (patch) | |
tree | c1af04c563afeff3b8410022f1cd9079299dd6ce /paludis | |
parent | 968efa61fa4abe5349ffc453ac46087867eaa29b (diff) | |
download | paludis-b7f5d7dbfeff2e406ef24ca471657e1735a4db4f.tar.gz paludis-b7f5d7dbfeff2e406ef24ca471657e1735a4db4f.tar.xz |
Start using constraints for PackageDepSpecs
Diffstat (limited to 'paludis')
30 files changed, 279 insertions, 91 deletions
diff --git a/paludis/dep_spec.cc b/paludis/dep_spec.cc index 35a7996b1..8f29957be 100644 --- a/paludis/dep_spec.cc +++ b/paludis/dep_spec.cc @@ -542,10 +542,10 @@ PackageDepSpec::PackageDepSpec(const PackageDepSpec & d) : set_annotations(d.maybe_annotations()); } -std::shared_ptr<const QualifiedPackageName> -PackageDepSpec::package_ptr() const +const std::shared_ptr<const NameConstraint> +PackageDepSpec::package_name_constraint() const { - return _imp->data->package_ptr(); + return _imp->data->package_name_constraint(); } std::shared_ptr<const PackageNamePart> diff --git a/paludis/dep_spec.hh b/paludis/dep_spec.hh index 68b5c70e1..5bf2b6822 100644 --- a/paludis/dep_spec.hh +++ b/paludis/dep_spec.hh @@ -41,6 +41,7 @@ #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_constraint-fwd.hh> #include <memory> @@ -347,9 +348,12 @@ namespace paludis ///\} /** - * Fetch the package name (may be a zero pointer). + * Fetch the single NameConstraint, if we have one, or + * a null pointer otherwise. + * + * \since 0.61 */ - std::shared_ptr<const QualifiedPackageName> package_ptr() const; + const std::shared_ptr<const NameConstraint> package_name_constraint() const PALUDIS_ATTRIBUTE((warn_unused_result)); /** * Fetch the package name part, if wildcarded, or a zero pointer otherwise. diff --git a/paludis/dep_spec_data.hh b/paludis/dep_spec_data.hh index cae1276b5..973434ff8 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 Ciaran McCreesh + * 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 @@ -33,6 +33,7 @@ #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_constraint-fwd.hh> #include <string> #include <memory> @@ -110,9 +111,12 @@ namespace paludis virtual std::string as_string() const = 0; /** - * Fetch the package name (may be a zero pointer). + * Fetch the single NameConstraint, if we have one, or + * a null pointer otherwise. + * + * \since 0.61 */ - virtual std::shared_ptr<const QualifiedPackageName> package_ptr() const = 0; + virtual const std::shared_ptr<const NameConstraint> package_name_constraint() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0; /** * Fetch the package name part, if wildcarded, or a zero pointer otherwise. diff --git a/paludis/environments/paludis/keywords_conf.cc b/paludis/environments/paludis/keywords_conf.cc index 4837cfb12..dd90b2375 100644 --- a/paludis/environments/paludis/keywords_conf.cc +++ b/paludis/environments/paludis/keywords_conf.cc @@ -17,18 +17,21 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "keywords_conf.hh" +#include <paludis/environments/paludis/keywords_conf.hh> +#include <paludis/environments/paludis/paludis_environment.hh> +#include <paludis/environments/paludis/bashable_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_constraint.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> @@ -38,6 +41,7 @@ #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> @@ -104,9 +108,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_ptr()) + if (d->package_name_constraint()) { - KeywordsList & k(_imp->qualified[*d->package_ptr()][d]); + KeywordsList & k(_imp->qualified[d->package_name_constraint()->name()][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 7e5829278..70b274801 100644 --- a/paludis/environments/paludis/licenses_conf.cc +++ b/paludis/environments/paludis/licenses_conf.cc @@ -17,7 +17,10 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "licenses_conf.hh" +#include <paludis/environments/paludis/licenses_conf.hh> +#include <paludis/environments/paludis/paludis_environment.hh> +#include <paludis/environments/paludis/bashable_conf.hh> + #include <paludis/environment.hh> #include <paludis/name.hh> #include <paludis/dep_spec.hh> @@ -26,9 +29,9 @@ #include <paludis/match_package.hh> #include <paludis/util/config_file.hh> #include <paludis/package_id.hh> +#include <paludis/package_dep_spec_constraint.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> @@ -37,6 +40,7 @@ #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> @@ -104,9 +108,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_ptr()) + if (d->package_name_constraint()) { - LicensesList & k(_imp->qualified[*d->package_ptr()][d]); + LicensesList & k(_imp->qualified[d->package_name_constraint()->name()][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 fa9c313d0..1eafbf180 100644 --- a/paludis/environments/paludis/suggestions_conf.cc +++ b/paludis/environments/paludis/suggestions_conf.cc @@ -21,6 +21,7 @@ #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> @@ -31,6 +32,7 @@ #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> @@ -39,6 +41,8 @@ #include <paludis/match_package.hh> #include <paludis/package_id.hh> #include <paludis/dep_spec_annotations.hh> +#include <paludis/package_dep_spec_constraint.hh> + #include <unordered_map> #include <list> #include <vector> @@ -146,9 +150,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_ptr()) + if (d->package_name_constraint()) { - ValuesList & k(_imp->qualified[*d->package_ptr()][d]); + ValuesList & k(_imp->qualified[d->package_name_constraint()->name()][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)); @@ -208,10 +212,10 @@ SuggestionsConf::interest_in_suggestion( else { if (! l->pkg_requirement.empty()) - if (stringify(spec.package_ptr()->package()) != l->pkg_requirement) + if (stringify(spec.package_name_constraint()->name().package()) != l->pkg_requirement) continue; if (! l->cat_requirement.empty()) - if (stringify(spec.package_ptr()->category()) != l->cat_requirement) + if (stringify(spec.package_name_constraint()->name().category()) != l->cat_requirement) continue; return l->negated ? false : true; @@ -252,10 +256,10 @@ SuggestionsConf::interest_in_suggestion( else { if (! l->pkg_requirement.empty()) - if (stringify(spec.package_ptr()->package()) != l->pkg_requirement) + if (stringify(spec.package_name_constraint()->name().package()) != l->pkg_requirement) continue; if (! l->cat_requirement.empty()) - if (stringify(spec.package_ptr()->category()) != l->cat_requirement) + if (stringify(spec.package_name_constraint()->name().category()) != l->cat_requirement) continue; return l->negated ? false : true; @@ -283,10 +287,10 @@ SuggestionsConf::interest_in_suggestion( else { if (! l->pkg_requirement.empty()) - if (stringify(spec.package_ptr()->package()) != l->pkg_requirement) + if (stringify(spec.package_name_constraint()->name().package()) != l->pkg_requirement) continue; if (! l->cat_requirement.empty()) - if (stringify(spec.package_ptr()->category()) != l->cat_requirement) + if (stringify(spec.package_name_constraint()->name().category()) != l->cat_requirement) continue; return l->negated ? false : true; diff --git a/paludis/files.m4 b/paludis/files.m4 index 8e44a2e18..abc367b12 100644 --- a/paludis/files.m4 +++ b/paludis/files.m4 @@ -76,6 +76,7 @@ add(`output_manager', `hh', `fwd', `cc', `se') 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_constraint', `hh', `cc', `fwd') add(`package_dep_spec_properties', `hh', `cc', `fwd') add(`package_id', `hh', `cc', `fwd', `se') add(`paludis', `hh') diff --git a/paludis/fuzzy_finder.cc b/paludis/fuzzy_finder.cc index 3846609ba..a96316530 100644 --- a/paludis/fuzzy_finder.cc +++ b/paludis/fuzzy_finder.cc @@ -28,6 +28,7 @@ #include <paludis/filter_handler.hh> #include <paludis/filtered_generator.hh> #include <paludis/selection.hh> +#include <paludis/package_dep_spec_constraint.hh> #include <paludis/util/pimp-impl.hh> #include <paludis/util/wrapped_forward_iterator-impl.hh> @@ -143,10 +144,10 @@ FuzzyCandidatesFinder::FuzzyCandidatesFinder(const Environment & e, const std::s { PackageDepSpec pds(parse_user_package_dep_spec(name, &e, { })); - if (pds.package_ptr()) + if (pds.package_name_constraint()) { - g = g & generator::Category(pds.package_ptr()->category()); - package = stringify(pds.package_ptr()->package()); + g = g & generator::Category(pds.package_name_constraint()->name().category()); + package = stringify(pds.package_name_constraint()->name().package()); } if (pds.in_repository_ptr()) diff --git a/paludis/generator.cc b/paludis/generator.cc index e38ebede9..ce85afa5d 100644 --- a/paludis/generator.cc +++ b/paludis/generator.cc @@ -29,6 +29,7 @@ #include <paludis/package_id.hh> #include <paludis/metadata_key.hh> #include <paludis/repository.hh> +#include <paludis/package_dep_spec_constraint.hh> #include <paludis/util/pimp-impl.hh> #include <paludis/util/set.hh> @@ -393,14 +394,14 @@ namespace return result; } - else if (spec.package_ptr()) + else if (spec.package_name_constraint()) { 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(spec.package_ptr()->category(), x)) + if (env->fetch_repository(*r)->has_category_named(spec.package_name_constraint()->name().category(), x)) { - result->insert(spec.package_ptr()->category()); + result->insert(spec.package_name_constraint()->name().category()); break; } @@ -428,14 +429,14 @@ namespace return result; } - else if (spec.package_ptr()) + else if (spec.package_name_constraint()) { 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(*spec.package_ptr(), x)) + if (env->fetch_repository(*r)->has_package_named(spec.package_name_constraint()->name(), x)) { - result->insert(*spec.package_ptr()); + result->insert(spec.package_name_constraint()->name()); break; } diff --git a/paludis/match_package.cc b/paludis/match_package.cc index 5b0fa7d2d..e50a17e3d 100644 --- a/paludis/match_package.cc +++ b/paludis/match_package.cc @@ -28,6 +28,7 @@ #include <paludis/action.hh> #include <paludis/repository.hh> #include <paludis/additional_package_dep_spec_requirement.hh> +#include <paludis/package_dep_spec_constraint.hh> #include <paludis/util/set.hh> #include <paludis/util/options.hh> @@ -86,7 +87,7 @@ paludis::match_package_with_maybe_changes( const ChangedChoices * const maybe_changes_to_target, const MatchPackageOptions & options) { - if (spec.package_ptr() && *spec.package_ptr() != id->name()) + if (spec.package_name_constraint() && spec.package_name_constraint()->name() != id->name()) return false; if (spec.package_name_part_ptr() && *spec.package_name_part_ptr() != id->name().package()) diff --git a/paludis/package_dep_spec_collection.cc b/paludis/package_dep_spec_collection.cc index 280921c3e..f09cba5a4 100644 --- a/paludis/package_dep_spec_collection.cc +++ b/paludis/package_dep_spec_collection.cc @@ -22,6 +22,7 @@ #include <paludis/package_id.hh> #include <paludis/dep_spec.hh> #include <paludis/match_package.hh> +#include <paludis/package_dep_spec_constraint.hh> #include <list> #include <map> @@ -53,8 +54,8 @@ PackageDepSpecCollection::~PackageDepSpecCollection() = default; void PackageDepSpecCollection::insert(const PackageDepSpec & spec) { - if (spec.package_ptr()) - _imp->by_name.insert(std::make_pair(*spec.package_ptr(), spec)); + if (spec.package_name_constraint()) + _imp->by_name.insert(std::make_pair(spec.package_name_constraint()->name(), spec)); else _imp->unnamed.push_back(spec); } diff --git a/paludis/package_dep_spec_constraint-fwd.hh b/paludis/package_dep_spec_constraint-fwd.hh new file mode 100644 index 000000000..ebd25ccad --- /dev/null +++ b/paludis/package_dep_spec_constraint-fwd.hh @@ -0,0 +1,33 @@ +/* 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_CONSTRAINT_FWD_HH +#define PALUDIS_GUARD_PALUDIS_PACKAGE_DEP_SPEC_CONSTRAINT_FWD_HH 1 + +#include <paludis/util/pool-fwd.hh> + +namespace paludis +{ + class PackageDepSpecConstraint; + + class NameConstraint; + typedef Pool<NameConstraint> NameConstraintPool; +} + +#endif diff --git a/paludis/package_dep_spec_constraint.cc b/paludis/package_dep_spec_constraint.cc new file mode 100644 index 000000000..ea35fad10 --- /dev/null +++ b/paludis/package_dep_spec_constraint.cc @@ -0,0 +1,45 @@ +/* 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_constraint.hh> +#include <paludis/util/pool-impl.hh> +#include <paludis/util/pimp-impl.hh> +#include <paludis/util/singleton-impl.hh> + +using namespace paludis; + +PackageDepSpecConstraint::~PackageDepSpecConstraint() = default; + +NameConstraint::NameConstraint(const QualifiedPackageName & n) : + _name(n) +{ +} + +NameConstraint::~NameConstraint() = default; + +const QualifiedPackageName +NameConstraint::name() const +{ + return _name; +} + +template class Pool<NameConstraint>; +template class Singleton<Pool<NameConstraint> >; +template const std::shared_ptr<const NameConstraint> Pool<NameConstraint>::create(const QualifiedPackageName &) const; + diff --git a/paludis/package_dep_spec_constraint.hh b/paludis/package_dep_spec_constraint.hh new file mode 100644 index 000000000..e9dbf16b9 --- /dev/null +++ b/paludis/package_dep_spec_constraint.hh @@ -0,0 +1,63 @@ +/* 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_CONSTRAINT_HH +#define PALUDIS_GUARD_PALUDIS_PACKAGE_DEP_SPEC_CONSTRAINT_HH 1 + +#include <paludis/package_dep_spec_constraint-fwd.hh> +#include <paludis/name.hh> + +#include <paludis/util/attributes.hh> +#include <paludis/util/pool.hh> +#include <paludis/util/visitor.hh> +#include <paludis/util/type_list.hh> + +namespace paludis +{ + class PALUDIS_VISIBLE PackageDepSpecConstraint : + public virtual DeclareAbstractAcceptMethods<PackageDepSpecConstraint, MakeTypeList< + NameConstraint>::Type> + { + public: + virtual ~PackageDepSpecConstraint() = 0; + }; + + class PALUDIS_VISIBLE NameConstraint : + public PackageDepSpecConstraint, + public ImplementAcceptMethods<PackageDepSpecConstraint, NameConstraint> + { + friend class Pool<NameConstraint>; + + private: + QualifiedPackageName _name; + + NameConstraint(const QualifiedPackageName &); + + NameConstraint(const NameConstraint &) = delete; + + public: + ~NameConstraint(); + + const QualifiedPackageName name() const PALUDIS_ATTRIBUTE((warn_unused_result)); + }; + + extern template class Pool<NameConstraint>; +} + +#endif diff --git a/paludis/package_dep_spec_properties.cc b/paludis/package_dep_spec_properties.cc index 75a1efc96..68ee5c6b3 100644 --- a/paludis/package_dep_spec_properties.cc +++ b/paludis/package_dep_spec_properties.cc @@ -48,7 +48,7 @@ paludis::package_dep_spec_has_properties(const PackageDepSpec & spec, const Pack 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_constraint()), 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()); diff --git a/paludis/paludislike_options_conf.cc b/paludis/paludislike_options_conf.cc index 7e54947c0..471f437f8 100644 --- a/paludis/paludislike_options_conf.cc +++ b/paludis/paludislike_options_conf.cc @@ -18,6 +18,7 @@ */ #include <paludis/paludislike_options_conf.hh> + #include <paludis/util/pimp-impl.hh> #include <paludis/util/hashes.hh> #include <paludis/util/named_value.hh> @@ -33,6 +34,7 @@ #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> @@ -42,6 +44,8 @@ #include <paludis/environment.hh> #include <paludis/spec_tree.hh> #include <paludis/package_dep_spec_properties.hh> +#include <paludis/package_dep_spec_constraint.hh> + #include <unordered_map> #include <unordered_set> #include <list> @@ -208,10 +212,10 @@ PaludisLikeOptionsConf::add_file(const FSPath & f) continue; } - if (d->package_ptr()) + if (d->package_name_constraint()) { SpecificSpecs::iterator i(_imp->specific_specs.insert(std::make_pair( - *d->package_ptr(), + d->package_name_constraint()->name(), SpecsWithValuesGroups())).first); values_groups = &i->second.insert(i->second.end(), make_named_values<SpecWithValuesGroups>( diff --git a/paludis/partially_made_package_dep_spec.cc b/paludis/partially_made_package_dep_spec.cc index e94883a88..bd000bd9c 100644 --- a/paludis/partially_made_package_dep_spec.cc +++ b/paludis/partially_made_package_dep_spec.cc @@ -28,6 +28,7 @@ #include <paludis/version_requirements.hh> #include <paludis/additional_package_dep_spec_requirement.hh> #include <paludis/dep_spec_data.hh> +#include <paludis/package_dep_spec_constraint.hh> #include <iterator> #include <algorithm> #include <ostream> @@ -47,7 +48,7 @@ namespace struct PartiallyMadePackageDepSpecData : PackageDepSpecData { - std::shared_ptr<const QualifiedPackageName> package; + std::shared_ptr<const NameConstraint> package; std::shared_ptr<const PackageNamePart> package_name_part; std::shared_ptr<const CategoryNamePart> category_name_part; std::shared_ptr<VersionRequirements> version_requirements; @@ -70,7 +71,7 @@ namespace PartiallyMadePackageDepSpecData(const PackageDepSpecData & other) : PackageDepSpecData(other), - package(other.package_ptr()), + package(other.package_name_constraint()), 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), @@ -130,8 +131,8 @@ namespace } } - if (package_ptr()) - s << *package_ptr(); + if (package_name_constraint()) + s << package_name_constraint()->name(); else { if (category_name_part_ptr()) @@ -277,7 +278,7 @@ namespace return s.str(); } - virtual std::shared_ptr<const QualifiedPackageName> package_ptr() const + virtual const std::shared_ptr<const NameConstraint> package_name_constraint() const { return package; } @@ -390,7 +391,7 @@ PartiallyMadePackageDepSpec::~PartiallyMadePackageDepSpec() PartiallyMadePackageDepSpec & PartiallyMadePackageDepSpec::package(const QualifiedPackageName & name) { - _imp->data->package = std::make_shared<QualifiedPackageName>(name); + _imp->data->package = NameConstraintPool::get_instance()->create(name); return *this; } diff --git a/paludis/repositories/e/exheres_mask_store.cc b/paludis/repositories/e/exheres_mask_store.cc index daf75e65a..5b5a0e16b 100644 --- a/paludis/repositories/e/exheres_mask_store.cc +++ b/paludis/repositories/e/exheres_mask_store.cc @@ -37,6 +37,7 @@ #include <paludis/match_package.hh> #include <paludis/dep_spec_flattener.hh> #include <paludis/dep_spec_annotations.hh> +#include <paludis/package_dep_spec_constraint.hh> #include <algorithm> #include <unordered_map> @@ -164,8 +165,8 @@ ExheresMaskStore::_populate() for (auto s(flat_specs.begin()), s_end(flat_specs.end()) ; s != s_end ; ++s) { - if ((*s)->package_ptr()) - _imp->repo_mask[*(*s)->package_ptr()].push_back(std::make_pair(**s, make_mask_info(**s, *f))); + if ((*s)->package_name_constraint()) + _imp->repo_mask[(*s)->package_name_constraint()->name()].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/traditional_mask_store.cc b/paludis/repositories/e/traditional_mask_store.cc index 002acf519..f969ab332 100644 --- a/paludis/repositories/e/traditional_mask_store.cc +++ b/paludis/repositories/e/traditional_mask_store.cc @@ -21,15 +21,18 @@ #include <paludis/repositories/e/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_constraint.hh> #include <algorithm> #include <unordered_map> @@ -98,8 +101,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_ptr()) - _imp->repo_mask[*a.package_ptr()].push_back(std::make_pair(a, line->second.second)); + if (a.package_name_constraint()) + _imp->repo_mask[a.package_name_constraint()->name()].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 27e3c0025..50a26c8cb 100644 --- a/paludis/repositories/e/traditional_profile.cc +++ b/paludis/repositories/e/traditional_profile.cc @@ -51,6 +51,7 @@ #include <paludis/distribution.hh> #include <paludis/package_id.hh> #include <paludis/metadata_key.hh> +#include <paludis/package_dep_spec_constraint.hh> #include <unordered_map> #include <unordered_set> @@ -360,8 +361,8 @@ namespace line->first->supported()->package_dep_spec_parse_options(), line->first->supported()->version_spec_options()))); - if (a->package_ptr()) - _imp->package_mask[*a->package_ptr()].push_back(std::make_pair(a, line->second.second)); + if (a->package_name_constraint()) + _imp->package_mask[a->package_name_constraint()->name()].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 bef18331e..1a70d48db 100644 --- a/paludis/repositories/e/vdb_repository.cc +++ b/paludis/repositories/e/vdb_repository.cc @@ -54,6 +54,7 @@ #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_constraint.hh> #include <paludis/util/accept_visitor.hh> #include <paludis/util/mutex.hh> @@ -1105,13 +1106,12 @@ VDBRepository::need_package_ids(const CategoryNamePart & c) const if (std::string::npos == s.rfind('-')) continue; - 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())); + PackageDepSpec p(parse_user_package_dep_spec("=" + stringify(c) + "/" + s, _imp->params.environment(), { })); + q->insert(p.package_name_constraint()->name()); + IDMap::iterator i(_imp->ids.find(p.package_name_constraint()->name())); if (_imp->ids.end() == i) - 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)); + i = _imp->ids.insert(std::make_pair(p.package_name_constraint()->name(), std::make_shared<PackageIDSequence>())).first; + i->second->push_back(make_id(p.package_name_constraint()->name(), p.version_requirements_ptr()->begin()->version_spec(), *d)); } catch (const InternalError &) { @@ -1269,11 +1269,11 @@ namespace void visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node) { - if (node.spec()->package_ptr() && rewrites.end() != rewrites.find(*node.spec()->package_ptr())) + if (node.spec()->package_name_constraint() && rewrites.end() != rewrites.find(node.spec()->package_name_constraint()->name())) { changed = true; str << f.prettify(PartiallyMadePackageDepSpec(*node.spec()) - .package(rewrites.find(*node.spec()->package_ptr())->second)) << " "; + .package(rewrites.find(node.spec()->package_name_constraint()->name())->second)) << " "; } else str << f.prettify(*node.spec()) << " "; diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc index 735a1bbaf..b0e0dbd1b 100644 --- a/paludis/resolver/decider.cc +++ b/paludis/resolver/decider.cc @@ -40,6 +40,7 @@ #include <paludis/resolver/same_slot.hh> #include <paludis/resolver/reason_utils.hh> #include <paludis/resolver/make_uninstall_blocker.hh> + #include <paludis/util/exception.hh> #include <paludis/util/stringify.hh> #include <paludis/util/make_named_values.hh> @@ -53,6 +54,7 @@ #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> @@ -72,6 +74,7 @@ #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_constraint.hh> #include <paludis/util/pimp-impl.hh> @@ -1331,9 +1334,9 @@ Decider::find_any_score( } /* explicit preferences come first */ - if (spec.package_ptr()) + if (spec.package_name_constraint()) { - Tribool prefer_or_avoid(_imp->fns.prefer_or_avoid_fn()(*spec.package_ptr())); + Tribool prefer_or_avoid(_imp->fns.prefer_or_avoid_fn()(spec.package_name_constraint()->name())); 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()) @@ -1476,7 +1479,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_ptr()) + generator::Package(spec.blocking().package_name_constraint()->name()) )]); for (PackageIDSequence::ConstIterator i(ids->begin()), i_end(ids->end()) ; i != i_end ; ++i) @@ -1539,7 +1542,7 @@ Decider::_get_error_resolvents_for( ), *t); - auto ids(_find_installable_id_candidates_for(*spec.package_ptr(), filter::All(), true, true)); + auto ids(_find_installable_id_candidates_for(spec.package_name_constraint()->name(), filter::All(), true, true)); if (! ids->empty()) resolvent.slot() = make_named_values<SlotNameOrNull>( n::name_or_null() = (*ids->rbegin())->slot_key() ? diff --git a/paludis/resolver/get_use_existing_nothing_helper.cc b/paludis/resolver/get_use_existing_nothing_helper.cc index ed454323e..a07421a69 100644 --- a/paludis/resolver/get_use_existing_nothing_helper.cc +++ b/paludis/resolver/get_use_existing_nothing_helper.cc @@ -34,6 +34,7 @@ #include <paludis/filter.hh> #include <paludis/filtered_generator.hh> #include <paludis/environment.hh> +#include <paludis/package_dep_spec_constraint.hh> #include <list> using namespace paludis; @@ -216,11 +217,11 @@ GetUseExistingNothingHelper::operator() ( { Context context("When determining use existing for '" + stringify(spec) + "':"); - if (spec.package_ptr()) + if (spec.package_name_constraint()) { - if (use_existing_from_withish(_imp->env, *spec.package_ptr(), _imp->without_specs)) + if (use_existing_from_withish(_imp->env, spec.package_name_constraint()->name(), _imp->without_specs)) return std::make_pair(ue_if_possible, true); - if (use_existing_from_withish(_imp->env, *spec.package_ptr(), _imp->with_specs)) + if (use_existing_from_withish(_imp->env, spec.package_name_constraint()->name(), _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 305f0194b..92d4aee0a 100644 --- a/paludis/resolver/interest_in_spec_helper.cc +++ b/paludis/resolver/interest_in_spec_helper.cc @@ -39,6 +39,7 @@ #include <paludis/metadata_key.hh> #include <paludis/match_package.hh> #include <paludis/dep_spec_annotations.hh> +#include <paludis/package_dep_spec_constraint.hh> #include <list> #include <set> @@ -269,7 +270,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_ptr())) + if (match_qpns(*_imp->env, *l, dep.spec().if_package()->package_name_constraint()->name())) return si_take; } @@ -298,7 +299,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_ptr())) + if (match_qpns(*_imp->env, *l, dep.spec().if_package()->package_name_constraint()->name())) return si_ignore; } diff --git a/paludis/resolver/match_qpns.cc b/paludis/resolver/match_qpns.cc index 6ad289294..91a797347 100644 --- a/paludis/resolver/match_qpns.cc +++ b/paludis/resolver/match_qpns.cc @@ -18,11 +18,14 @@ */ #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/util/make_named_values.hh> +#include <paludis/package_dep_spec_constraint.hh> using namespace paludis; using namespace paludis::resolver; @@ -53,7 +56,7 @@ paludis::resolver::match_qpns( ))) return false; - if (spec.package_ptr() && *spec.package_ptr() != package) + if (spec.package_name_constraint() && spec.package_name_constraint()->name() != package) return false; if (spec.package_name_part_ptr() && *spec.package_name_part_ptr() != package.package()) return false; diff --git a/paludis/resolver/resolvent.cc b/paludis/resolver/resolvent.cc index 1ed9426a6..46d340895 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 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,6 +29,7 @@ #include <paludis/package_id.hh> #include <paludis/metadata_key.hh> #include <paludis/serialise-impl.hh> +#include <paludis/package_dep_spec_constraint.hh> using namespace paludis; using namespace paludis::resolver; @@ -83,7 +84,7 @@ Resolvent::Resolvent( const SlotName & s, const DestinationType t) : destination_type(n::destination_type() = t), - package(n::package() = *spec.package_ptr()), + package(n::package() = spec.package_name_constraint()->name()), slot(make_named_values<SlotNameOrNull>( n::name_or_null() = std::make_shared<SlotName>(s), n::null_means_unknown() = false @@ -96,7 +97,7 @@ Resolvent::Resolvent( const SlotNameOrNull & s, const DestinationType t) : destination_type(n::destination_type() = t), - package(n::package() = *spec.package_ptr()), + package(n::package() = spec.package_name_constraint()->name()), slot(s) { } diff --git a/paludis/resolver/sanitised_dependencies.cc b/paludis/resolver/sanitised_dependencies.cc index 8439536d0..ac0921fd9 100644 --- a/paludis/resolver/sanitised_dependencies.cc +++ b/paludis/resolver/sanitised_dependencies.cc @@ -169,7 +169,7 @@ namespace void visit_package_spec(const PackageDepSpec & spec) { - if (spec.package_ptr()) + if (spec.package_name_constraint()) visit_package_or_block_spec(PackageOrBlockDepSpec(spec)); else super_complicated = true; @@ -177,7 +177,7 @@ namespace void visit_block_spec(const BlockDepSpec & spec) { - if (spec.blocking().package_ptr()) + if (spec.blocking().package_name_constraint()) 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 d41bd385b..06b16b4f6 100644 --- a/paludis/resolver/spec_rewriter.cc +++ b/paludis/resolver/spec_rewriter.cc @@ -38,6 +38,7 @@ #include <paludis/metadata_key.hh> #include <paludis/partially_made_package_dep_spec.hh> #include <paludis/elike_blocker.hh> +#include <paludis/package_dep_spec_constraint.hh> #include <map> #include <set> @@ -92,13 +93,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_ptr()) + if (s.if_package() && s.if_package()->package_name_constraint()) { - if (s.if_package()->package_ptr()->category() != CategoryNamePart("virtual")) + if (s.if_package()->package_name_constraint()->name().category() != CategoryNamePart("virtual")) return make_null_shared_ptr(); _need_rewrites(); - Rewrites::const_iterator r(_imp->rewrites.find(*s.if_package()->package_ptr())); + Rewrites::const_iterator r(_imp->rewrites.find(s.if_package()->package_name_constraint()->name())); if (r == _imp->rewrites.end()) return make_null_shared_ptr(); @@ -112,13 +113,13 @@ SpecRewriter::rewrite_if_special(const PackageOrBlockDepSpec & s, const std::sha return result; } - else if (s.if_block() && s.if_block()->blocking().package_ptr()) + else if (s.if_block() && s.if_block()->blocking().package_name_constraint()) { - if (s.if_block()->blocking().package_ptr()->category() != CategoryNamePart("virtual")) + if (s.if_block()->blocking().package_name_constraint()->name().category() != CategoryNamePart("virtual")) return make_null_shared_ptr(); _need_rewrites(); - Rewrites::const_iterator r(_imp->rewrites.find(*s.if_block()->blocking().package_ptr())); + Rewrites::const_iterator r(_imp->rewrites.find(s.if_block()->blocking().package_name_constraint()->name())); if (r == _imp->rewrites.end()) return make_null_shared_ptr(); diff --git a/paludis/set_file.cc b/paludis/set_file.cc index e3c0f2b0e..6d1c767b9 100644 --- a/paludis/set_file.cc +++ b/paludis/set_file.cc @@ -39,6 +39,7 @@ #include <paludis/filtered_generator.hh> #include <paludis/partially_made_package_dep_spec.hh> #include <paludis/metadata_key.hh> +#include <paludis/package_dep_spec_constraint.hh> #include <list> #include <vector> @@ -238,13 +239,13 @@ namespace } std::shared_ptr<PackageDepSpec> spec(std::make_shared<PackageDepSpec>(params.parser()(tokens.at(1)))); - if (spec->package_ptr()) + if (spec->package_name_constraint()) { 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_ptr()) | + generator::Package(spec->package_name_constraint()->name()) | filter::InstalledAtRoot(params.environment()->preferred_root_key()->value()))]->empty()) result->top()->append(spec); } @@ -262,14 +263,14 @@ namespace } std::shared_ptr<PackageDepSpec> spec(std::make_shared<PackageDepSpec>(params.parser()(tokens.at(1)))); - if (spec->package_ptr()) + if (spec->package_name_constraint()) { 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( make_package_dep_spec({ }) - .package(*spec->package_ptr()) + .package(spec->package_name_constraint()->name()) .slot_requirement(spec->slot_requirement_ptr()), make_null_shared_ptr(), { }) | filter::InstalledAtRoot(params.environment()->preferred_root_key()->value()))]->empty()) diff --git a/paludis/user_dep_spec_TEST.cc b/paludis/user_dep_spec_TEST.cc index a5fbf9ea5..d4d05ddfb 100644 --- a/paludis/user_dep_spec_TEST.cc +++ b/paludis/user_dep_spec_TEST.cc @@ -21,6 +21,7 @@ #include <paludis/user_dep_spec.hh> #include <paludis/match_package.hh> #include <paludis/version_requirements.hh> +#include <paludis/package_dep_spec_constraint.hh> #include <paludis/util/clone-impl.hh> #include <paludis/util/sequence.hh> @@ -90,11 +91,11 @@ UserDepSpecTest::check_spec( { if (package.empty()) - EXPECT_TRUE(! spec.package_ptr()); + EXPECT_TRUE(! spec.package_name_constraint()); else { - EXPECT_TRUE(bool(spec.package_ptr())); - EXPECT_EQ(package, stringify(*spec.package_ptr())); + EXPECT_TRUE(bool(spec.package_name_constraint())); + EXPECT_EQ(package, stringify(spec.package_name_constraint()->name())); } if (category_name_part.empty()) |