diff options
author | 2011-03-29 12:40:53 +0100 | |
---|---|---|
committer | 2011-04-04 08:32:59 +0100 | |
commit | 63ca918976505d042587bf7591dfce41b206b8cc (patch) | |
tree | f54fcf53236ecd673dffe431b3df5cbca3ffe9f0 /paludis | |
parent | 7d346bba37dfe95c858fa727bbc63bbc42074f30 (diff) | |
download | paludis-63ca918976505d042587bf7591dfce41b206b8cc.tar.gz paludis-63ca918976505d042587bf7591dfce41b206b8cc.tar.xz |
from repository to requirements
Diffstat (limited to 'paludis')
-rw-r--r-- | paludis/dep_spec.cc | 6 | ||||
-rw-r--r-- | paludis/dep_spec.hh | 5 | ||||
-rw-r--r-- | paludis/dep_spec_data.hh | 9 | ||||
-rw-r--r-- | paludis/fuzzy_finder.cc | 4 | ||||
-rw-r--r-- | paludis/match_package.cc | 4 | ||||
-rw-r--r-- | paludis/package_dep_spec_constraint-fwd.hh | 3 | ||||
-rw-r--r-- | paludis/package_dep_spec_constraint.cc | 18 | ||||
-rw-r--r-- | paludis/package_dep_spec_constraint.hh | 23 | ||||
-rw-r--r-- | paludis/package_dep_spec_properties.cc | 2 | ||||
-rw-r--r-- | paludis/partially_made_package_dep_spec.cc | 12 | ||||
-rw-r--r-- | paludis/user_dep_spec_TEST.cc | 6 |
11 files changed, 70 insertions, 22 deletions
diff --git a/paludis/dep_spec.cc b/paludis/dep_spec.cc index 793a43cfe..da912dfe3 100644 --- a/paludis/dep_spec.cc +++ b/paludis/dep_spec.cc @@ -590,10 +590,10 @@ PackageDepSpec::installable_to_repository_ptr() const return _imp->data->installable_to_repository_ptr(); } -std::shared_ptr<const RepositoryName> -PackageDepSpec::from_repository_ptr() const +const std::shared_ptr<const FromRepositoryConstraint> +PackageDepSpec::from_repository_constraint() const { - return _imp->data->from_repository_ptr(); + return _imp->data->from_repository_constraint(); } std::shared_ptr<const FSPath> diff --git a/paludis/dep_spec.hh b/paludis/dep_spec.hh index e2c4c1662..5af03b39b 100644 --- a/paludis/dep_spec.hh +++ b/paludis/dep_spec.hh @@ -402,9 +402,10 @@ namespace paludis std::shared_ptr<const InstallableToRepository> installable_to_repository_ptr() const; /** - * Fetch the from-repository requirement (may be a zero pointer). + * Fetch the single FromRepositoryConstraint, if we have one, or + * a null pointer otherwise. */ - std::shared_ptr<const RepositoryName> from_repository_ptr() const; + const std::shared_ptr<const FromRepositoryConstraint> from_repository_constraint() const; /** * Fetch the installed-at-path requirement (may be a zero pointer). diff --git a/paludis/dep_spec_data.hh b/paludis/dep_spec_data.hh index 70fbd860e..20af6bdf2 100644 --- a/paludis/dep_spec_data.hh +++ b/paludis/dep_spec_data.hh @@ -155,6 +155,8 @@ namespace paludis /** * Fetch the single InRepositoryConstraint, if we have one, or * a null pointer otherwise. + * + * \since 0.61 */ virtual const std::shared_ptr<const InRepositoryConstraint> in_repository_constraint() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0; @@ -167,9 +169,12 @@ namespace paludis virtual std::shared_ptr<const InstallableToRepository> installable_to_repository_ptr() const = 0; /** - * Fetch the from-repository requirement (may be a zero pointer). + * Fetch the single FromRepositoryConstraint, if we have one, or + * a null pointer otherwise. + * + * \since 0.61 */ - virtual std::shared_ptr<const RepositoryName> from_repository_ptr() const = 0; + virtual const std::shared_ptr<const FromRepositoryConstraint> from_repository_constraint() const = 0; /** * Fetch the installed-at-path requirement (may be a zero pointer). diff --git a/paludis/fuzzy_finder.cc b/paludis/fuzzy_finder.cc index 097de08ae..ce0a19374 100644 --- a/paludis/fuzzy_finder.cc +++ b/paludis/fuzzy_finder.cc @@ -153,8 +153,8 @@ FuzzyCandidatesFinder::FuzzyCandidatesFinder(const Environment & e, const std::s if (pds.in_repository_constraint()) g = g & generator::InRepository(pds.in_repository_constraint()->name()); - if (pds.from_repository_ptr()) - g = g & generator::FromRepository(*pds.from_repository_ptr()); + if (pds.from_repository_constraint()) + g = g & generator::FromRepository(pds.from_repository_constraint()->name()); } std::shared_ptr<const PackageIDSequence> ids(e[selection::BestVersionOnly(g | FuzzyPackageName(package) | filter)]); diff --git a/paludis/match_package.cc b/paludis/match_package.cc index 436514d62..f5bd18396 100644 --- a/paludis/match_package.cc +++ b/paludis/match_package.cc @@ -130,13 +130,13 @@ paludis::match_package_with_maybe_changes( if (spec.in_repository_constraint()->name() != id->repository_name()) return false; - if (spec.from_repository_ptr()) + if (spec.from_repository_constraint()) { if (! id->from_repositories_key()) return false; if (id->from_repositories_key()->value()->end() == id->from_repositories_key()->value()->find( - stringify(*spec.from_repository_ptr()))) + stringify(spec.from_repository_constraint()->name()))) return false; } diff --git a/paludis/package_dep_spec_constraint-fwd.hh b/paludis/package_dep_spec_constraint-fwd.hh index b64c0316f..630976518 100644 --- a/paludis/package_dep_spec_constraint-fwd.hh +++ b/paludis/package_dep_spec_constraint-fwd.hh @@ -37,6 +37,9 @@ namespace paludis class InRepositoryConstraint; typedef Pool<InRepositoryConstraint> InRepositoryConstraintPool; + + class FromRepositoryConstraint; + typedef Pool<FromRepositoryConstraint> FromRepositoryConstraintPool; } #endif diff --git a/paludis/package_dep_spec_constraint.cc b/paludis/package_dep_spec_constraint.cc index 2d5c6dfb0..39b4ee597 100644 --- a/paludis/package_dep_spec_constraint.cc +++ b/paludis/package_dep_spec_constraint.cc @@ -98,3 +98,21 @@ template class Singleton<Pool<InRepositoryConstraint> >; template const std::shared_ptr<const InRepositoryConstraint> Pool<InRepositoryConstraint>::create( const RepositoryName &) const; +FromRepositoryConstraint::FromRepositoryConstraint(const RepositoryName & n) : + _name(n) +{ +} + +FromRepositoryConstraint::~FromRepositoryConstraint() = default; + +const RepositoryName +FromRepositoryConstraint::name() const +{ + return _name; +} + +template class Pool<FromRepositoryConstraint>; +template class Singleton<Pool<FromRepositoryConstraint> >; +template const std::shared_ptr<const FromRepositoryConstraint> Pool<FromRepositoryConstraint>::create( + const RepositoryName &) const; + diff --git a/paludis/package_dep_spec_constraint.hh b/paludis/package_dep_spec_constraint.hh index 689c9ed7e..261707319 100644 --- a/paludis/package_dep_spec_constraint.hh +++ b/paludis/package_dep_spec_constraint.hh @@ -35,7 +35,8 @@ namespace paludis NameConstraint, PackageNamePartConstraint, CategoryNamePartConstraint, - InRepositoryConstraint + InRepositoryConstraint, + FromRepositoryConstraint >::Type> { public: @@ -118,10 +119,30 @@ namespace paludis const RepositoryName name() const PALUDIS_ATTRIBUTE((warn_unused_result)); }; + class PALUDIS_VISIBLE FromRepositoryConstraint : + public PackageDepSpecConstraint, + public ImplementAcceptMethods<PackageDepSpecConstraint, FromRepositoryConstraint> + { + friend class Pool<FromRepositoryConstraint>; + + private: + RepositoryName _name; + + FromRepositoryConstraint(const RepositoryName &); + + FromRepositoryConstraint(const FromRepositoryConstraint &) = delete; + + public: + ~FromRepositoryConstraint(); + + const RepositoryName name() const PALUDIS_ATTRIBUTE((warn_unused_result)); + }; + extern template class Pool<NameConstraint>; extern template class Pool<PackageNamePartConstraint>; extern template class Pool<CategoryNamePartConstraint>; extern template class Pool<InRepositoryConstraint>; + extern template class Pool<FromRepositoryConstraint>; } #endif diff --git a/paludis/package_dep_spec_properties.cc b/paludis/package_dep_spec_properties.cc index 7ee076ad4..11e038b83 100644 --- a/paludis/package_dep_spec_properties.cc +++ b/paludis/package_dep_spec_properties.cc @@ -43,7 +43,7 @@ paludis::package_dep_spec_has_properties(const PackageDepSpec & spec, const Pack result = result && check(bool(spec.additional_requirements_ptr()) && ! spec.additional_requirements_ptr()->empty(), properties.has_additional_requirements()); result = result && check(bool(spec.category_name_part_constraint()), properties.has_category_name_part()); - result = result && check(bool(spec.from_repository_ptr()), properties.has_from_repository()); + result = result && check(bool(spec.from_repository_constraint()), properties.has_from_repository()); result = result && check(bool(spec.in_repository_constraint()), properties.has_in_repository()); result = result && check(bool(spec.installable_to_path_ptr()), properties.has_installable_to_path()); result = result && check(bool(spec.installable_to_repository_ptr()), properties.has_installable_to_repository()); diff --git a/paludis/partially_made_package_dep_spec.cc b/paludis/partially_made_package_dep_spec.cc index 018308811..9f4e7f764 100644 --- a/paludis/partially_made_package_dep_spec.cc +++ b/paludis/partially_made_package_dep_spec.cc @@ -55,7 +55,7 @@ namespace VersionRequirementsMode version_requirements_mode_v; std::shared_ptr<const SlotRequirement> slot; std::shared_ptr<const InRepositoryConstraint> in_repository; - std::shared_ptr<const RepositoryName> from_repository; + std::shared_ptr<const FromRepositoryConstraint> from_repository; std::shared_ptr<const InstallableToRepository> installable_to_repository; std::shared_ptr<const FSPath> installed_at_path; std::shared_ptr<const InstallableToPath> installable_to_path; @@ -78,7 +78,7 @@ namespace version_requirements_mode_v(other.version_requirements_mode()), slot(other.slot_requirement_ptr()), in_repository(other.in_repository_constraint()), - from_repository(other.from_repository_ptr()), + from_repository(other.from_repository_constraint()), installable_to_repository(other.installable_to_repository_ptr()), installed_at_path(other.installed_at_path_ptr()), installable_to_path(other.installable_to_path_ptr()), @@ -168,8 +168,8 @@ namespace std::string left, right; bool need_arrow(false); - if (from_repository_ptr()) - left = stringify(*from_repository_ptr()); + if (from_repository_constraint()) + left = stringify(from_repository_constraint()->name()); if (in_repository_constraint()) right = stringify(in_repository_constraint()->name()); @@ -318,7 +318,7 @@ namespace return installable_to_repository; } - virtual std::shared_ptr<const RepositoryName> from_repository_ptr() const + virtual const std::shared_ptr<const FromRepositoryConstraint> from_repository_constraint() const { return from_repository; } @@ -433,7 +433,7 @@ PartiallyMadePackageDepSpec::clear_in_repository() PartiallyMadePackageDepSpec & PartiallyMadePackageDepSpec::from_repository(const RepositoryName & s) { - _imp->data->from_repository = std::make_shared<RepositoryName>(s); + _imp->data->from_repository = FromRepositoryConstraintPool::get_instance()->create(s); return *this; } diff --git a/paludis/user_dep_spec_TEST.cc b/paludis/user_dep_spec_TEST.cc index a38d3b276..d18b9f35a 100644 --- a/paludis/user_dep_spec_TEST.cc +++ b/paludis/user_dep_spec_TEST.cc @@ -135,11 +135,11 @@ UserDepSpecTest::check_spec( } if (from_repository.empty()) - EXPECT_TRUE(! spec.from_repository_ptr()); + EXPECT_TRUE(! spec.from_repository_constraint()); else { - EXPECT_TRUE(bool(spec.from_repository_ptr())); - EXPECT_EQ(from_repository, stringify(*spec.from_repository_ptr())); + EXPECT_TRUE(bool(spec.from_repository_constraint())); + EXPECT_EQ(from_repository, stringify(spec.from_repository_constraint()->name())); } if (in_repository.empty()) |