diff options
author | 2011-03-28 23:44:02 +0100 | |
---|---|---|
committer | 2011-04-04 08:32:58 +0100 | |
commit | b7f5d7dbfeff2e406ef24ca471657e1735a4db4f (patch) | |
tree | c1af04c563afeff3b8410022f1cd9079299dd6ce | |
parent | 968efa61fa4abe5349ffc453ac46087867eaa29b (diff) | |
download | paludis-b7f5d7dbfeff2e406ef24ca471657e1735a4db4f.tar.gz paludis-b7f5d7dbfeff2e406ef24ca471657e1735a4db4f.tar.xz |
Start using constraints for PackageDepSpecs
47 files changed, 515 insertions, 124 deletions
diff --git a/doc/api/cplusplus/examples/example_dep_spec.cc b/doc/api/cplusplus/examples/example_dep_spec.cc index 081b201ed..074c5750e 100644 --- a/doc/api/cplusplus/examples/example_dep_spec.cc +++ b/doc/api/cplusplus/examples/example_dep_spec.cc @@ -59,8 +59,8 @@ int main(int argc, char * argv[]) /* Display information about the PackageDepSpec. */ cout << "Information about '" << spec << "':" << endl; - if (spec.package_ptr()) - cout << " " << left << setw(24) << "Package:" << " " << *spec.package_ptr() << endl; + if (spec.package_name_constraint()) + cout << " " << left << setw(24) << "Package:" << " " << spec.package_name_constraint()->name() << endl; if (spec.category_name_part_ptr()) cout << " " << left << setw(24) << "Category part:" << " " << *spec.category_name_part_ptr() << endl; 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()) diff --git a/python/Makefile.am b/python/Makefile.am index 4a275959e..e58412490 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -70,6 +70,7 @@ IF_PYTHON_SOURCES = \ nice_names-nn.hh nice_names-nn.cc \ log.cc \ package_id.cc \ + package_dep_spec_constraint.cc \ repository.cc \ selection.cc \ version_operator.cc \ diff --git a/python/dep_spec.cc b/python/dep_spec.cc index b53d3a768..98f009e56 100644 --- a/python/dep_spec.cc +++ b/python/dep_spec.cc @@ -29,6 +29,7 @@ #include <paludis/version_requirements.hh> #include <paludis/partially_made_package_dep_spec.hh> #include <paludis/dep_spec_data.hh> +#include <paludis/package_dep_spec_constraint.hh> #include <paludis/util/save.hh> #include <paludis/util/stringify.hh> @@ -72,7 +73,7 @@ namespace paludis template<> struct Imp<PythonPackageDepSpec> { - std::shared_ptr<const QualifiedPackageName> package_ptr; + std::shared_ptr<const NameConstraint> package_name_constraint; std::shared_ptr<const CategoryNamePart> category_name_part_ptr; std::shared_ptr<const PackageNamePart> package_name_part_ptr; std::shared_ptr<VersionRequirements> version_requirements; @@ -84,7 +85,7 @@ namespace paludis const std::string str; Imp( - const std::shared_ptr<const QualifiedPackageName> & q, + const std::shared_ptr<const NameConstraint> & q, const std::shared_ptr<const CategoryNamePart> & c, const std::shared_ptr<const PackageNamePart> & p, const std::shared_ptr<VersionRequirements> & v, @@ -94,7 +95,7 @@ namespace paludis const std::shared_ptr<const RepositoryName> & rf, const std::shared_ptr<const AdditionalPackageDepSpecRequirements> & u, const std::string & st) : - package_ptr(q), + package_name_constraint(q), category_name_part_ptr(c), package_name_part_ptr(p), version_requirements(v), @@ -222,7 +223,7 @@ deep_copy(const std::shared_ptr<const T_> & x) PythonPackageDepSpec::PythonPackageDepSpec(const PackageDepSpec & p) : PythonStringDepSpec(p.text()), _imp( - deep_copy(p.package_ptr()), + p.package_name_constraint(), deep_copy(p.category_name_part_ptr()), deep_copy(p.package_name_part_ptr()), std::make_shared<VersionRequirements>(), @@ -243,7 +244,7 @@ PythonPackageDepSpec::PythonPackageDepSpec(const PackageDepSpec & p) : PythonPackageDepSpec::PythonPackageDepSpec(const PythonPackageDepSpec & p) : PythonStringDepSpec(p.text()), _imp( - deep_copy(p.package_ptr()), + p.package_name_constraint(), deep_copy(p.category_name_part_ptr()), deep_copy(p.package_name_part_ptr()), std::make_shared<VersionRequirements>(), @@ -266,8 +267,8 @@ PythonPackageDepSpec::operator PackageDepSpec() const { PartiallyMadePackageDepSpec p((PartiallyMadePackageDepSpecOptions())); - if (package_ptr()) - p.package(*package_ptr()); + if (package_name_constraint()) + p.package(package_name_constraint()->name()); if (category_name_part_ptr()) p.category_name_part(*category_name_part_ptr()); @@ -309,10 +310,10 @@ PythonPackageDepSpec::operator std::shared_ptr<PackageDepSpec>() const return std::make_shared<PackageDepSpec>(*this); } -std::shared_ptr<const QualifiedPackageName> -PythonPackageDepSpec::package_ptr() const +const std::shared_ptr<const NameConstraint> +PythonPackageDepSpec::package_name_constraint() const { - return _imp->package_ptr; + return _imp->package_name_constraint; } std::shared_ptr<const PackageNamePart> @@ -1200,9 +1201,9 @@ void expose_dep_spec() bp::no_init ) - .add_property("package", &PythonPackageDepSpec::package_ptr, - "[ro] QualifiedPackageName\n" - "Qualified package name." + .add_property("package_name_constraint", &PythonPackageDepSpec::package_name_constraint, + "[ro] NameConstraint\n" + "Qualified package name constraint (may be None)." ) .add_property("package_name_part", &PythonPackageDepSpec::package_name_part_ptr, diff --git a/python/dep_spec.hh b/python/dep_spec.hh index 1a10fc191..f8e2be04d 100644 --- a/python/dep_spec.hh +++ b/python/dep_spec.hh @@ -172,7 +172,8 @@ namespace paludis operator PackageDepSpec() const; operator std::shared_ptr<PackageDepSpec>() const; - std::shared_ptr<const QualifiedPackageName> package_ptr() const; + const std::shared_ptr<const NameConstraint> package_name_constraint() const; + std::shared_ptr<const PackageNamePart> package_name_part_ptr() const; std::shared_ptr<const CategoryNamePart> category_name_part_ptr() const; std::shared_ptr<const VersionRequirements> version_requirements_ptr() const; diff --git a/python/dep_spec_TEST.py b/python/dep_spec_TEST.py index ec22662c4..d762401dc 100755 --- a/python/dep_spec_TEST.py +++ b/python/dep_spec_TEST.py @@ -64,7 +64,7 @@ class TestCase_1_DepSpecs(unittest.TestCase): def test_05_package(self): self.get_depspecs() - self.assertEqual(str(self.pds.package), "foo/bar") + self.assertEqual(str(self.pds.package_name_constraint.name), "foo/bar") def test_06_in_from_repository(self): self.get_depspecs() diff --git a/python/mask_TEST.py b/python/mask_TEST.py index f38a2dad3..40262ff86 100755 --- a/python/mask_TEST.py +++ b/python/mask_TEST.py @@ -98,7 +98,7 @@ class TestCase_01_Masks(unittest.TestCase): self.assertEquals(m.key(), "A") self.assertEquals(m.description(), "by association") - self.assertEquals(m.associated_package_spec().package, "masked/repo") + self.assertEquals(m.associated_package_spec().package_name_constraint.name, "masked/repo") elif os.environ.get("PALUDIS_ENABLE_VIRTUALS_REPOSITORY") != "no": raise "oops" diff --git a/python/package_dep_spec_constraint.cc b/python/package_dep_spec_constraint.cc new file mode 100644 index 000000000..aa212eb62 --- /dev/null +++ b/python/package_dep_spec_constraint.cc @@ -0,0 +1,77 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2007 Piotr JaroszyĆski + * Copyright (c) 2011 Ciaran McCreesh + * + * This file is part of the Paludis package manager. Paludis is free software; + * you can redistribute it and/or modify it under the terms of the GNU General + * Public License version 2, as published by the Free Software Foundation. + * + * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <python/paludis_python.hh> +#include <paludis/util/wrapped_forward_iterator-impl.hh> +#include <paludis/util/fs_path.hh> +#include <paludis/package_dep_spec_constraint.hh> + +using namespace paludis; +using namespace paludis::python; +namespace bp = boost::python; + +// For classes derived from PackageDepSpecConstraint +template <typename C_> +class class_package_dep_spec_constraint : + public bp::class_<C_, std::shared_ptr<C_>, bp::bases<PackageDepSpecConstraint>, boost::noncopyable> +{ + public: + template <class Init_> + class_package_dep_spec_constraint(const std::string & name, const std::string & class_doc, Init_ initspec) : + bp::class_<C_, std::shared_ptr<C_>, bp::bases<PackageDepSpecConstraint>, boost::noncopyable>( + name.c_str(), class_doc.c_str(), initspec) + { + bp::register_ptr_to_python<std::shared_ptr<const C_> >(); + bp::implicitly_convertible<std::shared_ptr<C_>, std::shared_ptr<PackageDepSpecConstraint> >(); + } +}; + +void expose_package_dep_spec_constraint() +{ + /** + * PackageDepSpecConstraint + */ + bp::register_ptr_to_python<std::shared_ptr<const PackageDepSpecConstraint> >(); + bp::implicitly_convertible<std::shared_ptr<PackageDepSpecConstraint>, + std::shared_ptr<const PackageDepSpecConstraint> >(); + bp::class_<PackageDepSpecConstraint, boost::noncopyable> + ( + "PackageDepSpecConstraint", + "Base class for a constraint for a PackageDepSpec.", + bp::no_init + ) + ; + + /** + * NameConstraint + */ + class_package_dep_spec_constraint<NameConstraint> + ( + "NameConstraint", + "A cat/pkg constraint for a PackageDepSpec.", + bp::no_init + ) + + .add_property("name", &NameConstraint::name, + "[RO] The cat/pkg in question" + ) + ; +} + diff --git a/python/paludis_python.hh b/python/paludis_python.hh index aacf7beac..640b521bc 100644 --- a/python/paludis_python.hh +++ b/python/paludis_python.hh @@ -188,6 +188,7 @@ void expose_mask() PALUDIS_VISIBLE; void expose_match_package() PALUDIS_VISIBLE; void expose_metadata_key() PALUDIS_VISIBLE; void expose_name() PALUDIS_VISIBLE; +void expose_package_dep_spec_constraint() PALUDIS_VISIBLE; void expose_package_id() PALUDIS_VISIBLE; void expose_repository() PALUDIS_VISIBLE; void expose_selection() PALUDIS_VISIBLE; diff --git a/python/paludis_python_so.cc b/python/paludis_python_so.cc index f8b4e3eca..b2ac1804c 100644 --- a/python/paludis_python_so.cc +++ b/python/paludis_python_so.cc @@ -37,6 +37,7 @@ BOOST_PYTHON_MODULE(paludis) expose_fs_path(); expose_contents(); expose_filter(); /* must be before dep_spec */ + expose_package_dep_spec_constraint(); expose_dep_spec(); expose_dep_label(); expose_name(); diff --git a/ruby/Makefile.am b/ruby/Makefile.am index ade8df5ca..3f46ae03c 100644 --- a/ruby/Makefile.am +++ b/ruby/Makefile.am @@ -50,6 +50,7 @@ IF_RUBY_SOURCES = \ metadata_key.cc \ name.cc \ nice_names-nn.hh nice_names-nn.cc \ + package_dep_spec_constraint.cc \ package_id.cc \ paludis_ruby.cc paludis_ruby.hh \ qualified_package_name.cc \ diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc index 9f6790bc0..b6628e8d7 100644 --- a/ruby/dep_spec.cc +++ b/ruby/dep_spec.cc @@ -19,10 +19,13 @@ */ #include <paludis_ruby.hh> + #include <paludis/dep_spec.hh> #include <paludis/user_dep_spec.hh> #include <paludis/version_requirements.hh> #include <paludis/version_operator.hh> +#include <paludis/package_dep_spec_constraint.hh> + #include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/util/sequence.hh> #include <paludis/util/options.hh> @@ -31,6 +34,7 @@ #include <paludis/util/indirect_iterator-impl.hh> #include <paludis/util/make_null_shared_ptr.hh> #include <paludis/util/accept_visitor.hh> + #include <algorithm> #include <list> #include <ruby.h> @@ -576,18 +580,18 @@ namespace /* * call-seq: - * package -> QualifiedPackageName or Nil + * package_name_constraint -> PackageDepSpecConstraint or Nil * - * Fetch the package name. + * Fetch the package name constraint (may be Nil). */ VALUE - package_dep_spec_package(VALUE self) + package_dep_spec_package_name_constraint(VALUE self) { std::shared_ptr<WrappedSpecBase> * ptr; Data_Get_Struct(self, std::shared_ptr<WrappedSpecBase>, ptr); - if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->package_ptr())) + if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->package_name_constraint())) return Qnil; - return qualified_package_name_to_value(*std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->package_ptr()); + return package_dep_spec_constraint_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->package_name_constraint()); } /* @@ -1107,7 +1111,7 @@ namespace * use Paludis::parse_user_package_dep_spec. */ c_package_dep_spec = rb_define_class_under(paludis_module(), "PackageDepSpec", c_string_dep_spec); - rb_define_method(c_package_dep_spec, "package", RUBY_FUNC_CAST(&package_dep_spec_package), 0); + 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", RUBY_FUNC_CAST(&package_dep_spec_package_name_part), 0); rb_define_method(c_package_dep_spec, "category_name_part", RUBY_FUNC_CAST(&package_dep_spec_category_name_part), 0); rb_define_method(c_package_dep_spec, "slot_requirement", RUBY_FUNC_CAST(&package_dep_spec_slot_requirement_ptr), 0); diff --git a/ruby/dep_spec_TEST.rb b/ruby/dep_spec_TEST.rb index 2866ee3fa..6c5363f3b 100644 --- a/ruby/dep_spec_TEST.rb +++ b/ruby/dep_spec_TEST.rb @@ -140,11 +140,11 @@ module Paludis end def test_package - assert_equal QualifiedPackageName.new("foo/bar"), pda.package - assert_nil pdb.package - assert_equal QualifiedPackageName.new("foo/bar"), pdc.package - assert_nil pdd.package - assert_equal QualifiedPackageName.new("foo/bar"), pde.package + assert_equal QualifiedPackageName.new("foo/bar"), pda.package_name_constraint.name + assert_nil pdb.package_name_constraint + assert_equal QualifiedPackageName.new("foo/bar"), pdc.package_name_constraint.name + assert_nil pdd.package_name_constraint + assert_equal QualifiedPackageName.new("foo/bar"), pde.package_name_constraint.name end def test_from_repository diff --git a/ruby/package_dep_spec_constraint.cc b/ruby/package_dep_spec_constraint.cc new file mode 100644 index 000000000..4cfd42f67 --- /dev/null +++ b/ruby/package_dep_spec_constraint.cc @@ -0,0 +1,105 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2011 Ciaran McCreesh + * + * This file is part of the Paludis package manager. Paludis is free software; + * you can redistribute it and/or modify it under the terms of the GNU General + * Public License version 2, as published by the Free Software Foundation. + * + * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <paludis_ruby.hh> + +#include <paludis/package_dep_spec_constraint.hh> + +#include <algorithm> +#include <list> +#include <ruby.h> + +using namespace paludis; +using namespace paludis::ruby; + +namespace +{ + static VALUE c_package_dep_spec_constraint; + static VALUE c_name_constraint; + + struct V + { + VALUE value; + std::shared_ptr<const PackageDepSpecConstraint> mm; + + V(const std::shared_ptr<const PackageDepSpecConstraint> & m) : + mm(m) + { + } + + void visit(const NameConstraint &) + { + value = Data_Wrap_Struct(c_name_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free, + new std::shared_ptr<const PackageDepSpecConstraint>(mm)); + } + }; + + /* + * Document-method: name + * + * The name constraint. + */ + static VALUE + name_constraint_name(VALUE self) + { + std::shared_ptr<const PackageDepSpecConstraint> * ptr; + Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecConstraint>, ptr); + return qualified_package_name_to_value((std::static_pointer_cast<const NameConstraint>(*ptr))->name()); + } + + void do_register_package_dep_spec_constraint() + { + /* + * Document-class: Paludis::PackageDepSpecConstraint + * + * Represents a constraint in a PackageDepSpec. + */ + c_package_dep_spec_constraint = rb_define_class_under(paludis_module(), "PackageDepSpecConstraint", rb_cObject); + rb_funcall(c_package_dep_spec_constraint, rb_intern("private_class_method"), 1, rb_str_new2("new")); + + /* + * Document-class: Paludis::NameConstraint + * + * Represents a cat/pkg name constraint in a PackageDepSpec. + */ + c_name_constraint = rb_define_class_under( + paludis_module(), "NameConstraint", c_package_dep_spec_constraint); + rb_funcall(c_name_constraint, rb_intern("private_class_method"), 1, rb_str_new2("new")); + rb_define_method(c_package_dep_spec_constraint, "name", RUBY_FUNC_CAST(&name_constraint_name), 0); + } +} + +VALUE +paludis::ruby::package_dep_spec_constraint_to_value(const std::shared_ptr<const PackageDepSpecConstraint> & m) +{ + try + { + V v(m); + m->accept(v); + return v.value; + } + catch (const std::exception & e) + { + exception_to_ruby_exception(e); + } +} + +RegisterRubyClass::Register paludis_ruby_register_package_dep_spec_constraint PALUDIS_ATTRIBUTE((used)) + (&do_register_package_dep_spec_constraint); + diff --git a/ruby/paludis_ruby.hh b/ruby/paludis_ruby.hh index aab1fb1c4..53d98b490 100644 --- a/ruby/paludis_ruby.hh +++ b/ruby/paludis_ruby.hh @@ -105,6 +105,7 @@ namespace paludis VALUE choice_value_to_value(const std::shared_ptr<const ChoiceValue> & c); VALUE match_package_options_to_value(const MatchPackageOptions & c); VALUE bool_to_value(bool b); + VALUE package_dep_spec_constraint_to_value(const std::shared_ptr<const PackageDepSpecConstraint> &); VersionSpec value_to_version_spec(VALUE v); std::shared_ptr<const PackageID> value_to_package_id(VALUE, bool nil_ok = false); diff --git a/src/clients/cave/cmd_execute_resolution.cc b/src/clients/cave/cmd_execute_resolution.cc index b9b71c12c..895be311e 100644 --- a/src/clients/cave/cmd_execute_resolution.cc +++ b/src/clients/cave/cmd_execute_resolution.cc @@ -25,8 +25,10 @@ #include "colours.hh" #include "resume_data.hh" #include "format_user_config.hh" + #include <paludis/args/do_help.hh> #include <paludis/args/escape.hh> + #include <paludis/util/safe_ifstream.hh> #include <paludis/util/safe_ofstream.hh> #include <paludis/util/system.hh> @@ -48,6 +50,7 @@ #include <paludis/util/timestamp.hh> #include <paludis/util/make_null_shared_ptr.hh> #include <paludis/util/process.hh> + #include <paludis/resolver/resolutions_by_resolvent.hh> #include <paludis/resolver/reason.hh> #include <paludis/resolver/sanitised_dependencies.hh> @@ -62,6 +65,7 @@ #include <paludis/resolver/job.hh> #include <paludis/resolver/job_state.hh> #include <paludis/resolver/job_requirements.hh> + #include <paludis/package_id.hh> #include <paludis/version_spec.hh> #include <paludis/metadata_key.hh> @@ -80,6 +84,7 @@ #include <paludis/filter.hh> #include <paludis/elike_blocker.hh> #include <paludis/repository.hh> +#include <paludis/package_dep_spec_constraint.hh> #include <set> #include <iterator> @@ -323,7 +328,7 @@ namespace const auto replacing_ids((*env)[selection::BestVersionOnly(generator::Matches(*i, make_null_shared_ptr(), { }))]); if (replacing_ids->empty()) r.append(stringify(*i)); - else if (id_specs->empty() || *id_specs->begin()->package_ptr() != (*replacing_ids->begin())->name()) + else if (id_specs->empty() || id_specs->begin()->package_name_constraint()->name() != (*replacing_ids->begin())->name()) r.append(stringify(**replacing_ids->begin())); else r.append((*replacing_ids->begin())->canonical_form(idcf_no_name)); diff --git a/src/clients/cave/cmd_graph_jobs.cc b/src/clients/cave/cmd_graph_jobs.cc index 5583422b7..2d1019b3e 100644 --- a/src/clients/cave/cmd_graph_jobs.cc +++ b/src/clients/cave/cmd_graph_jobs.cc @@ -21,7 +21,9 @@ #include "resolve_cmdline.hh" #include "exceptions.hh" #include "command_command_line.hh" + #include <paludis/args/do_help.hh> + #include <paludis/util/safe_ifstream.hh> #include <paludis/util/make_named_values.hh> #include <paludis/util/make_shared_copy.hh> @@ -31,13 +33,16 @@ #include <paludis/util/fs_path.hh> #include <paludis/util/join.hh> #include <paludis/util/process.hh> + #include <paludis/resolver/job_list.hh> #include <paludis/resolver/job_lists.hh> #include <paludis/resolver/job.hh> #include <paludis/resolver/job_requirements.hh> + #include <paludis/serialise-impl.hh> #include <paludis/dep_spec.hh> #include <paludis/name.hh> +#include <paludis/package_dep_spec_constraint.hh> #include <iostream> #include <cstdlib> @@ -86,11 +91,11 @@ namespace std::string short_spec(const PackageDepSpec & p, bool full) { - if (full || ! p.package_ptr()) + if (full || ! p.package_name_constraint()) return stringify(p); else { - std::string result(stringify(p.package_ptr()->package())); + std::string result(stringify(p.package_name_constraint()->name().package())); if (p.slot_requirement_ptr()) result = result + stringify(*p.slot_requirement_ptr()); if (p.in_repository_ptr()) diff --git a/src/clients/cave/cmd_show.cc b/src/clients/cave/cmd_show.cc index df3017767..a74421c97 100644 --- a/src/clients/cave/cmd_show.cc +++ b/src/clients/cave/cmd_show.cc @@ -1392,7 +1392,7 @@ ShowCommand::run( try { PackageDepSpec spec(parse_spec_with_nice_error(*p, env.get(), { updso_throw_if_set, updso_allow_wildcards }, filter::All())); - if ((! spec.package_ptr())) + if ((! spec.package_name_constraint())) do_one_wildcard(env, spec); else do_one_package(cmdline, env, basic_ppos, spec); |