aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-29 11:03:54 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-04 08:32:58 +0100
commit5574c81a3c60266d023d18dfc115803da8b12e6b (patch)
tree659da456cb9813045fd32067a3db11d7c7d7ce82
parentb7f5d7dbfeff2e406ef24ca471657e1735a4db4f (diff)
downloadpaludis-5574c81a3c60266d023d18dfc115803da8b12e6b.tar.gz
paludis-5574c81a3c60266d023d18dfc115803da8b12e6b.tar.xz
category and package parts to requirements
-rw-r--r--doc/api/cplusplus/examples/example_dep_spec.cc8
-rw-r--r--paludis/dep_spec.cc12
-rw-r--r--paludis/dep_spec.hh14
-rw-r--r--paludis/dep_spec_data.hh19
-rw-r--r--paludis/generator.cc17
-rw-r--r--paludis/match_package.cc4
-rw-r--r--paludis/package_dep_spec_constraint-fwd.hh6
-rw-r--r--paludis/package_dep_spec_constraint.cc39
-rw-r--r--paludis/package_dep_spec_constraint.hh45
-rw-r--r--paludis/package_dep_spec_properties.cc4
-rw-r--r--paludis/partially_made_package_dep_spec.cc24
-rw-r--r--paludis/resolver/match_qpns.cc4
-rw-r--r--paludis/user_dep_spec_TEST.cc12
-rw-r--r--python/dep_spec.cc52
-rw-r--r--python/dep_spec.hh4
-rw-r--r--python/package_dep_spec_constraint.cc30
-rw-r--r--ruby/dep_spec.cc28
-rw-r--r--ruby/dep_spec_TEST.rb20
-rw-r--r--ruby/package_dep_spec_constraint.cc62
19 files changed, 297 insertions, 107 deletions
diff --git a/doc/api/cplusplus/examples/example_dep_spec.cc b/doc/api/cplusplus/examples/example_dep_spec.cc
index 074c575..ba65dae 100644
--- a/doc/api/cplusplus/examples/example_dep_spec.cc
+++ b/doc/api/cplusplus/examples/example_dep_spec.cc
@@ -62,11 +62,11 @@ int main(int argc, char * argv[])
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;
+ if (spec.category_name_part_constraint())
+ cout << " " << left << setw(24) << "Category part:" << " " << spec.category_name_part_constraint()->name_part() << endl;
- if (spec.package_name_part_ptr())
- cout << " " << left << setw(24) << "Package part:" << " " << *spec.package_name_part_ptr() << endl;
+ if (spec.package_name_part_constraint())
+ cout << " " << left << setw(24) << "Package part:" << " " << spec.package_name_part_constraint()->name_part() << endl;
if (spec.version_requirements_ptr() && ! spec.version_requirements_ptr()->empty())
{
diff --git a/paludis/dep_spec.cc b/paludis/dep_spec.cc
index 8f29957..dac1df3 100644
--- a/paludis/dep_spec.cc
+++ b/paludis/dep_spec.cc
@@ -548,16 +548,16 @@ PackageDepSpec::package_name_constraint() const
return _imp->data->package_name_constraint();
}
-std::shared_ptr<const PackageNamePart>
-PackageDepSpec::package_name_part_ptr() const
+const std::shared_ptr<const PackageNamePartConstraint>
+PackageDepSpec::package_name_part_constraint() const
{
- return _imp->data->package_name_part_ptr();
+ return _imp->data->package_name_part_constraint();
}
-std::shared_ptr<const CategoryNamePart>
-PackageDepSpec::category_name_part_ptr() const
+const std::shared_ptr<const CategoryNamePartConstraint>
+PackageDepSpec::category_name_part_constraint() const
{
- return _imp->data->category_name_part_ptr();
+ return _imp->data->category_name_part_constraint();
}
std::shared_ptr<const VersionRequirements>
diff --git a/paludis/dep_spec.hh b/paludis/dep_spec.hh
index 5bf2b68..881b826 100644
--- a/paludis/dep_spec.hh
+++ b/paludis/dep_spec.hh
@@ -356,14 +356,20 @@ namespace paludis
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.
+ * Fetch the single PackageNamePartConstraint, if we have one, or
+ * a null pointer otherwise.
+ *
+ * \since 0.61
*/
- std::shared_ptr<const PackageNamePart> package_name_part_ptr() const;
+ const std::shared_ptr<const PackageNamePartConstraint> package_name_part_constraint() const;
/**
- * Fetch the category name part, if wildcarded, or a zero pointer otherwise.
+ * Fetch the single CategoryNamePartConstraint, if we have one, or
+ * a null pointer otherwise.
+ *
+ * \since 0.61
*/
- std::shared_ptr<const CategoryNamePart> category_name_part_ptr() const;
+ const std::shared_ptr<const CategoryNamePartConstraint> category_name_part_constraint() const;
/**
* Fetch the version requirements (may be a zero pointer).
diff --git a/paludis/dep_spec_data.hh b/paludis/dep_spec_data.hh
index 973434f..53c1c62 100644
--- a/paludis/dep_spec_data.hh
+++ b/paludis/dep_spec_data.hh
@@ -116,17 +116,26 @@ namespace paludis
*
* \since 0.61
*/
- virtual const std::shared_ptr<const NameConstraint> package_name_constraint() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 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.
+ * Fetch the single PackageNamePartConstraint, if we have one, or
+ * a null pointer otherwise.
+ *
+ * \since 0.61
*/
- virtual std::shared_ptr<const PackageNamePart> package_name_part_ptr() const = 0;
+ virtual const std::shared_ptr<const PackageNamePartConstraint> package_name_part_constraint() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
- * Fetch the category name part, if wildcarded, or a zero pointer otherwise.
+ * Fetch the single CategoryNamePartConstraint, if we have one, or
+ * a null pointer otherwise.
+ *
+ * \since 0.61
*/
- virtual std::shared_ptr<const CategoryNamePart> category_name_part_ptr() const = 0;
+ virtual const std::shared_ptr<const CategoryNamePartConstraint> category_name_part_constraint() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
* Fetch the version requirements (may be a zero pointer).
diff --git a/paludis/generator.cc b/paludis/generator.cc
index ce85afa..5602195 100644
--- a/paludis/generator.cc
+++ b/paludis/generator.cc
@@ -367,28 +367,27 @@ namespace
const std::shared_ptr<const RepositoryNameSet> & repos,
const RepositoryContentMayExcludes & x) const
{
- if (spec.category_name_part_ptr())
+ if (spec.category_name_part_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.category_name_part_ptr(), x))
+ if (env->fetch_repository(*r)->has_category_named(spec.category_name_part_constraint()->name_part(), x))
{
- result->insert(*spec.category_name_part_ptr());
+ result->insert(spec.category_name_part_constraint()->name_part());
break;
}
return result;
}
- else if (spec.package_name_part_ptr())
+ else if (spec.package_name_part_constraint())
{
std::shared_ptr<CategoryNamePartSet> result(std::make_shared<CategoryNamePartSet>());
for (RepositoryNameSet::ConstIterator r(repos->begin()), r_end(repos->end()) ;
r != r_end ; ++r)
{
std::shared_ptr<const CategoryNamePartSet> cats(
- env->fetch_repository(*r)
- ->category_names_containing_package(*spec.package_name_part_ptr(), x));
+ env->fetch_repository(*r)->category_names_containing_package(spec.package_name_part_constraint()->name_part(), x));
std::copy(cats->begin(), cats->end(), result->inserter());
}
@@ -417,15 +416,15 @@ namespace
const std::shared_ptr<const CategoryNamePartSet> & cats,
const RepositoryContentMayExcludes & x) const
{
- if (spec.package_name_part_ptr())
+ if (spec.package_name_part_constraint())
{
std::shared_ptr<QualifiedPackageNameSet> result(std::make_shared<QualifiedPackageNameSet>());
for (RepositoryNameSet::ConstIterator r(repos->begin()), r_end(repos->end()) ;
r != r_end ; ++r)
for (CategoryNamePartSet::ConstIterator c(cats->begin()), c_end(cats->end()) ;
c != c_end ; ++c)
- if (env->fetch_repository(*r)->has_package_named(*c + *spec.package_name_part_ptr(), x))
- result->insert(*c + *spec.package_name_part_ptr());
+ if (env->fetch_repository(*r)->has_package_named(*c + spec.package_name_part_constraint()->name_part(), x))
+ result->insert(*c + spec.package_name_part_constraint()->name_part());
return result;
}
diff --git a/paludis/match_package.cc b/paludis/match_package.cc
index e50a17e..f9eb55e 100644
--- a/paludis/match_package.cc
+++ b/paludis/match_package.cc
@@ -90,10 +90,10 @@ paludis::match_package_with_maybe_changes(
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())
+ if (spec.package_name_part_constraint() && spec.package_name_part_constraint()->name_part() != id->name().package())
return false;
- if (spec.category_name_part_ptr() && *spec.category_name_part_ptr() != id->name().category())
+ if (spec.category_name_part_constraint() && spec.category_name_part_constraint()->name_part() != id->name().category())
return false;
if (spec.version_requirements_ptr())
diff --git a/paludis/package_dep_spec_constraint-fwd.hh b/paludis/package_dep_spec_constraint-fwd.hh
index ebd25cc..24284f3 100644
--- a/paludis/package_dep_spec_constraint-fwd.hh
+++ b/paludis/package_dep_spec_constraint-fwd.hh
@@ -28,6 +28,12 @@ namespace paludis
class NameConstraint;
typedef Pool<NameConstraint> NameConstraintPool;
+
+ class PackageNamePartConstraint;
+ typedef Pool<PackageNamePartConstraint> PackageNamePartConstraintPool;
+
+ class CategoryNamePartConstraint;
+ typedef Pool<CategoryNamePartConstraint> CategoryNamePartConstraintPool;
}
#endif
diff --git a/paludis/package_dep_spec_constraint.cc b/paludis/package_dep_spec_constraint.cc
index ea35fad..7ffa904 100644
--- a/paludis/package_dep_spec_constraint.cc
+++ b/paludis/package_dep_spec_constraint.cc
@@ -41,5 +41,42 @@ NameConstraint::name() const
template class Pool<NameConstraint>;
template class Singleton<Pool<NameConstraint> >;
-template const std::shared_ptr<const NameConstraint> Pool<NameConstraint>::create(const QualifiedPackageName &) const;
+template const std::shared_ptr<const NameConstraint> Pool<NameConstraint>::create(
+ const QualifiedPackageName &) const;
+
+CategoryNamePartConstraint::CategoryNamePartConstraint(const CategoryNamePart & n) :
+ _name_part(n)
+{
+}
+
+CategoryNamePartConstraint::~CategoryNamePartConstraint() = default;
+
+const CategoryNamePart
+CategoryNamePartConstraint::name_part() const
+{
+ return _name_part;
+}
+
+template class Pool<CategoryNamePartConstraint>;
+template class Singleton<Pool<CategoryNamePartConstraint> >;
+template const std::shared_ptr<const CategoryNamePartConstraint> Pool<CategoryNamePartConstraint>::create(
+ const CategoryNamePart &) const;
+
+PackageNamePartConstraint::PackageNamePartConstraint(const PackageNamePart & n) :
+ _name_part(n)
+{
+}
+
+PackageNamePartConstraint::~PackageNamePartConstraint() = default;
+
+const PackageNamePart
+PackageNamePartConstraint::name_part() const
+{
+ return _name_part;
+}
+
+template class Pool<PackageNamePartConstraint>;
+template class Singleton<Pool<PackageNamePartConstraint> >;
+template const std::shared_ptr<const PackageNamePartConstraint> Pool<PackageNamePartConstraint>::create(
+ const PackageNamePart &) const;
diff --git a/paludis/package_dep_spec_constraint.hh b/paludis/package_dep_spec_constraint.hh
index e9dbf16..34bf644 100644
--- a/paludis/package_dep_spec_constraint.hh
+++ b/paludis/package_dep_spec_constraint.hh
@@ -32,7 +32,10 @@ namespace paludis
{
class PALUDIS_VISIBLE PackageDepSpecConstraint :
public virtual DeclareAbstractAcceptMethods<PackageDepSpecConstraint, MakeTypeList<
- NameConstraint>::Type>
+ NameConstraint,
+ PackageNamePartConstraint,
+ CategoryNamePartConstraint
+ >::Type>
{
public:
virtual ~PackageDepSpecConstraint() = 0;
@@ -57,7 +60,47 @@ namespace paludis
const QualifiedPackageName name() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
+ class PALUDIS_VISIBLE CategoryNamePartConstraint :
+ public PackageDepSpecConstraint,
+ public ImplementAcceptMethods<PackageDepSpecConstraint, CategoryNamePartConstraint>
+ {
+ friend class Pool<CategoryNamePartConstraint>;
+
+ private:
+ CategoryNamePart _name_part;
+
+ CategoryNamePartConstraint(const CategoryNamePart &);
+
+ CategoryNamePartConstraint(const CategoryNamePartConstraint &) = delete;
+
+ public:
+ ~CategoryNamePartConstraint();
+
+ const CategoryNamePart name_part() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class PALUDIS_VISIBLE PackageNamePartConstraint :
+ public PackageDepSpecConstraint,
+ public ImplementAcceptMethods<PackageDepSpecConstraint, PackageNamePartConstraint>
+ {
+ friend class Pool<PackageNamePartConstraint>;
+
+ private:
+ PackageNamePart _name_part;
+
+ PackageNamePartConstraint(const PackageNamePart &);
+
+ PackageNamePartConstraint(const PackageNamePartConstraint &) = delete;
+
+ public:
+ ~PackageNamePartConstraint();
+
+ const PackageNamePart name_part() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
extern template class Pool<NameConstraint>;
+ extern template class Pool<PackageNamePartConstraint>;
+ extern template class Pool<CategoryNamePartConstraint>;
}
#endif
diff --git a/paludis/package_dep_spec_properties.cc b/paludis/package_dep_spec_properties.cc
index 68ee5c6..d964df8 100644
--- a/paludis/package_dep_spec_properties.cc
+++ b/paludis/package_dep_spec_properties.cc
@@ -42,14 +42,14 @@ paludis::package_dep_spec_has_properties(const PackageDepSpec & spec, const Pack
bool result(true);
result = result && check(bool(spec.additional_requirements_ptr()) && ! spec.additional_requirements_ptr()->empty(), properties.has_additional_requirements());
- result = result && check(bool(spec.category_name_part_ptr()), properties.has_category_name_part());
+ result = result && check(bool(spec.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.in_repository_ptr()), properties.has_in_repository());
result = result && check(bool(spec.installable_to_path_ptr()), properties.has_installable_to_path());
result = result && check(bool(spec.installable_to_repository_ptr()), properties.has_installable_to_repository());
result = result && check(bool(spec.installed_at_path_ptr()), properties.has_installed_at_path());
result = result && check(bool(spec.package_name_constraint()), properties.has_package());
- result = result && check(bool(spec.package_name_part_ptr()), properties.has_package_name_part());
+ result = result && check(bool(spec.package_name_part_constraint()), properties.has_package_name_part());
result = result && check(bool(spec.slot_requirement_ptr()), properties.has_slot_requirement());
result = result && check(spec.version_requirements_ptr() && ! spec.version_requirements_ptr()->empty(), properties.has_version_requirements());
diff --git a/paludis/partially_made_package_dep_spec.cc b/paludis/partially_made_package_dep_spec.cc
index bd000bd..98eca7c 100644
--- a/paludis/partially_made_package_dep_spec.cc
+++ b/paludis/partially_made_package_dep_spec.cc
@@ -49,8 +49,8 @@ namespace
PackageDepSpecData
{
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<const PackageNamePartConstraint> package_name_part;
+ std::shared_ptr<const CategoryNamePartConstraint> category_name_part;
std::shared_ptr<VersionRequirements> version_requirements;
VersionRequirementsMode version_requirements_mode_v;
std::shared_ptr<const SlotRequirement> slot;
@@ -72,8 +72,8 @@ namespace
PartiallyMadePackageDepSpecData(const PackageDepSpecData & other) :
PackageDepSpecData(other),
package(other.package_name_constraint()),
- package_name_part(other.package_name_part_ptr()),
- category_name_part(other.category_name_part_ptr()),
+ package_name_part(other.package_name_part_constraint()),
+ category_name_part(other.category_name_part_constraint()),
version_requirements(other.version_requirements_ptr() ? new VersionRequirements : 0),
version_requirements_mode_v(other.version_requirements_mode()),
slot(other.slot_requirement_ptr()),
@@ -135,15 +135,15 @@ namespace
s << package_name_constraint()->name();
else
{
- if (category_name_part_ptr())
- s << *category_name_part_ptr();
+ if (category_name_part_constraint())
+ s << category_name_part_constraint()->name_part();
else
s << "*";
s << "/";
- if (package_name_part_ptr())
- s << *package_name_part_ptr();
+ if (package_name_part_constraint())
+ s << package_name_part_constraint()->name_part();
else
s << "*";
}
@@ -283,12 +283,12 @@ namespace
return package;
}
- virtual std::shared_ptr<const PackageNamePart> package_name_part_ptr() const
+ virtual const std::shared_ptr<const PackageNamePartConstraint> package_name_part_constraint() const
{
return package_name_part;
}
- virtual std::shared_ptr<const CategoryNamePart> category_name_part_ptr() const
+ virtual const std::shared_ptr<const CategoryNamePartConstraint> category_name_part_constraint() const
{
return category_name_part;
}
@@ -489,7 +489,7 @@ PartiallyMadePackageDepSpec::clear_installable_to_path()
PartiallyMadePackageDepSpec &
PartiallyMadePackageDepSpec::package_name_part(const PackageNamePart & part)
{
- _imp->data->package_name_part = std::make_shared<PackageNamePart>(part);
+ _imp->data->package_name_part = PackageNamePartConstraintPool::get_instance()->create(part);
return *this;
}
@@ -503,7 +503,7 @@ PartiallyMadePackageDepSpec::clear_package_name_part()
PartiallyMadePackageDepSpec &
PartiallyMadePackageDepSpec::category_name_part(const CategoryNamePart & part)
{
- _imp->data->category_name_part = std::make_shared<CategoryNamePart>(part);
+ _imp->data->category_name_part = CategoryNamePartConstraintPool::get_instance()->create(part);
return *this;
}
diff --git a/paludis/resolver/match_qpns.cc b/paludis/resolver/match_qpns.cc
index 91a7973..366429c 100644
--- a/paludis/resolver/match_qpns.cc
+++ b/paludis/resolver/match_qpns.cc
@@ -58,9 +58,9 @@ paludis::resolver::match_qpns(
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())
+ if (spec.package_name_part_constraint() && spec.package_name_part_constraint()->name_part() != package.package())
return false;
- if (spec.category_name_part_ptr() && *spec.category_name_part_ptr() != package.category())
+ if (spec.category_name_part_constraint() && spec.category_name_part_constraint()->name_part() != package.category())
return false;
return true;
diff --git a/paludis/user_dep_spec_TEST.cc b/paludis/user_dep_spec_TEST.cc
index d4d05dd..7e325da 100644
--- a/paludis/user_dep_spec_TEST.cc
+++ b/paludis/user_dep_spec_TEST.cc
@@ -99,19 +99,19 @@ UserDepSpecTest::check_spec(
}
if (category_name_part.empty())
- EXPECT_TRUE(! spec.category_name_part_ptr());
+ EXPECT_TRUE(! spec.category_name_part_constraint());
else
{
- EXPECT_TRUE(bool(spec.category_name_part_ptr()));
- EXPECT_EQ(category_name_part, stringify(*spec.category_name_part_ptr()));
+ EXPECT_TRUE(bool(spec.category_name_part_constraint()));
+ EXPECT_EQ(category_name_part, stringify(spec.category_name_part_constraint()->name_part()));
}
if (package_name_part.empty())
- EXPECT_TRUE(! spec.package_name_part_ptr());
+ EXPECT_TRUE(! spec.package_name_part_constraint());
else
{
- EXPECT_TRUE(bool(spec.package_name_part_ptr()));
- EXPECT_EQ(package_name_part, stringify(*spec.package_name_part_ptr()));
+ EXPECT_TRUE(bool(spec.package_name_part_constraint()));
+ EXPECT_EQ(package_name_part, stringify(spec.package_name_part_constraint()->name_part()));
}
if (! version_requirement_mode.empty())
diff --git a/python/dep_spec.cc b/python/dep_spec.cc
index 98f009e..a602f25 100644
--- a/python/dep_spec.cc
+++ b/python/dep_spec.cc
@@ -74,8 +74,8 @@ namespace paludis
struct Imp<PythonPackageDepSpec>
{
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<const CategoryNamePartConstraint> category_name_part_constraint;
+ std::shared_ptr<const PackageNamePartConstraint> package_name_part_constraint;
std::shared_ptr<VersionRequirements> version_requirements;
VersionRequirementsMode version_requirements_mode;
std::shared_ptr<const SlotRequirement> slot;
@@ -86,8 +86,8 @@ namespace paludis
Imp(
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<const CategoryNamePartConstraint> & c,
+ const std::shared_ptr<const PackageNamePartConstraint> & p,
const std::shared_ptr<VersionRequirements> & v,
const VersionRequirementsMode m,
const std::shared_ptr<const SlotRequirement> & s,
@@ -96,8 +96,8 @@ namespace paludis
const std::shared_ptr<const AdditionalPackageDepSpecRequirements> & u,
const std::string & st) :
package_name_constraint(q),
- category_name_part_ptr(c),
- package_name_part_ptr(p),
+ category_name_part_constraint(c),
+ package_name_part_constraint(p),
version_requirements(v),
version_requirements_mode(m),
slot(s),
@@ -224,8 +224,8 @@ PythonPackageDepSpec::PythonPackageDepSpec(const PackageDepSpec & p) :
PythonStringDepSpec(p.text()),
_imp(
p.package_name_constraint(),
- deep_copy(p.category_name_part_ptr()),
- deep_copy(p.package_name_part_ptr()),
+ p.category_name_part_constraint(),
+ p.package_name_part_constraint(),
std::make_shared<VersionRequirements>(),
p.version_requirements_mode(),
p.slot_requirement_ptr(),
@@ -245,8 +245,8 @@ PythonPackageDepSpec::PythonPackageDepSpec(const PythonPackageDepSpec & p) :
PythonStringDepSpec(p.text()),
_imp(
p.package_name_constraint(),
- deep_copy(p.category_name_part_ptr()),
- deep_copy(p.package_name_part_ptr()),
+ p.category_name_part_constraint(),
+ p.package_name_part_constraint(),
std::make_shared<VersionRequirements>(),
p.version_requirements_mode(),
p.slot_requirement_ptr(),
@@ -270,11 +270,11 @@ PythonPackageDepSpec::operator PackageDepSpec() const
if (package_name_constraint())
p.package(package_name_constraint()->name());
- if (category_name_part_ptr())
- p.category_name_part(*category_name_part_ptr());
+ if (category_name_part_constraint())
+ p.category_name_part(category_name_part_constraint()->name_part());
- if (package_name_part_ptr())
- p.package_name_part(*package_name_part_ptr());
+ if (package_name_part_constraint())
+ p.package_name_part(package_name_part_constraint()->name_part());
p.version_requirements_mode(version_requirements_mode());
@@ -316,16 +316,16 @@ PythonPackageDepSpec::package_name_constraint() const
return _imp->package_name_constraint;
}
-std::shared_ptr<const PackageNamePart>
-PythonPackageDepSpec::package_name_part_ptr() const
+const std::shared_ptr<const PackageNamePartConstraint>
+PythonPackageDepSpec::package_name_part_constraint() const
{
- return _imp->package_name_part_ptr;
+ return _imp->package_name_part_constraint;
}
-std::shared_ptr<const CategoryNamePart>
-PythonPackageDepSpec::category_name_part_ptr() const
+const std::shared_ptr<const CategoryNamePartConstraint>
+PythonPackageDepSpec::category_name_part_constraint() const
{
- return _imp->category_name_part_ptr;
+ return _imp->category_name_part_constraint;
}
std::shared_ptr<const VersionRequirements>
@@ -1206,14 +1206,14 @@ void expose_dep_spec()
"Qualified package name constraint (may be None)."
)
- .add_property("package_name_part", &PythonPackageDepSpec::package_name_part_ptr,
- "[ro] PackageNamePart\n"
- "Package name part (may be None)"
+ .add_property("package_name_part_constraint", &PythonPackageDepSpec::package_name_part_constraint,
+ "[ro] CategoryNamePartConstraint\n"
+ "Package name part constraint (may be None)"
)
- .add_property("category_name_part", &PythonPackageDepSpec::category_name_part_ptr,
- "[ro] CategoryNamePart\n"
- "Category name part (may be None)."
+ .add_property("category_name_part_constraint", &PythonPackageDepSpec::category_name_part_constraint,
+ "[ro] CategoryNamePartConstraint\n"
+ "Category name part constraint (may be None)."
)
.add_property("version_requirements", &PythonPackageDepSpec::version_requirements_ptr,
diff --git a/python/dep_spec.hh b/python/dep_spec.hh
index f8e2be0..e36d85a 100644
--- a/python/dep_spec.hh
+++ b/python/dep_spec.hh
@@ -173,9 +173,9 @@ namespace paludis
operator std::shared_ptr<PackageDepSpec>() const;
const std::shared_ptr<const NameConstraint> package_name_constraint() const;
+ const std::shared_ptr<const PackageNamePartConstraint> package_name_part_constraint() const;
+ const std::shared_ptr<const CategoryNamePartConstraint> category_name_part_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;
VersionRequirementsMode version_requirements_mode() const;
void set_version_requirements_mode(const VersionRequirementsMode m);
diff --git a/python/package_dep_spec_constraint.cc b/python/package_dep_spec_constraint.cc
index aa212eb..686bdf3 100644
--- a/python/package_dep_spec_constraint.cc
+++ b/python/package_dep_spec_constraint.cc
@@ -73,5 +73,35 @@ void expose_package_dep_spec_constraint()
"[RO] The cat/pkg in question"
)
;
+
+ /**
+ * PackageNamePartConstraint
+ */
+ class_package_dep_spec_constraint<PackageNamePartConstraint>
+ (
+ "PackageNamePartConstraint",
+ "A /pkg constraint for a PackageDepSpec.",
+ bp::no_init
+ )
+
+ .add_property("name_part", &PackageNamePartConstraint::name_part,
+ "[RO] The /pkg in question"
+ )
+ ;
+
+ /**
+ * CategoryNamePartConstraint
+ */
+ class_package_dep_spec_constraint<CategoryNamePartConstraint>
+ (
+ "CategoryNamePartConstraint",
+ "A cat/ constraint for a PackageDepSpec.",
+ bp::no_init
+ )
+
+ .add_property("name_part", &CategoryNamePartConstraint::name_part,
+ "[RO] The cat/ in question"
+ )
+ ;
}
diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc
index b6628e8..4584a2e 100644
--- a/ruby/dep_spec.cc
+++ b/ruby/dep_spec.cc
@@ -580,7 +580,7 @@ namespace
/*
* call-seq:
- * package_name_constraint -> PackageDepSpecConstraint or Nil
+ * package_name_constraint -> NameConstraint or Nil
*
* Fetch the package name constraint (may be Nil).
*/
@@ -596,36 +596,34 @@ namespace
/*
* call-seq:
- * package_name_part -> String or Nil
+ * package_name_part_constraint -> PackageNamePartConstraint or Nil
*
- * Fetch the package name part.
+ * Fetch the package name part constraint (may be Nil).
*/
VALUE
- package_dep_spec_package_name_part(VALUE self)
+ package_dep_spec_package_name_part_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_name_part_ptr()))
+ if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->package_name_part_constraint()))
return Qnil;
- return rb_str_new2(stringify(*std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->
- package_name_part_ptr()).c_str());
+ return package_dep_spec_constraint_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->package_name_part_constraint());
}
/*
* call-seq:
- * category_name_part -> String or Nil
+ * category_name_part_constraint -> CategoryNamePartConstraint or Nil
*
- * Fetch the category name part.
+ * Fetch the category name part constraint (may be Nil).
*/
VALUE
- package_dep_spec_category_name_part(VALUE self)
+ package_dep_spec_category_name_part_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()->category_name_part_ptr()))
+ if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->category_name_part_constraint()))
return Qnil;
- return rb_str_new2(stringify(*std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->
- category_name_part_ptr()).c_str());
+ return package_dep_spec_constraint_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->category_name_part_constraint());
}
/*
@@ -1112,8 +1110,8 @@ namespace
*/
c_package_dep_spec = rb_define_class_under(paludis_module(), "PackageDepSpec", c_string_dep_spec);
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, "package_name_part_constraint", RUBY_FUNC_CAST(&package_dep_spec_package_name_part_constraint), 0);
+ rb_define_method(c_package_dep_spec, "category_name_part_constraint", RUBY_FUNC_CAST(&package_dep_spec_category_name_part_constraint), 0);
rb_define_method(c_package_dep_spec, "slot_requirement", RUBY_FUNC_CAST(&package_dep_spec_slot_requirement_ptr), 0);
rb_define_method(c_package_dep_spec, "in_repository", RUBY_FUNC_CAST(&package_dep_spec_in_repository_ptr), 0);
rb_define_method(c_package_dep_spec, "from_repository", RUBY_FUNC_CAST(&package_dep_spec_from_repository_ptr), 0);
diff --git a/ruby/dep_spec_TEST.rb b/ruby/dep_spec_TEST.rb
index 6c5363f..7c58554 100644
--- a/ruby/dep_spec_TEST.rb
+++ b/ruby/dep_spec_TEST.rb
@@ -192,19 +192,19 @@ module Paludis
end
def test_package_name_part
- assert_nil pda.package_name_part
- assert_equal "bar", pdb.package_name_part
- assert_nil pdc.package_name_part
- assert_nil pdd.package_name_part
- assert_nil pde.package_name_part
+ assert_nil pda.package_name_part_constraint
+ assert_equal "bar", pdb.package_name_part_constraint.name_part
+ assert_nil pdc.package_name_part_constraint
+ assert_nil pdd.package_name_part_constraint
+ assert_nil pde.package_name_part_constraint
end
def test_category_name_part
- assert_nil pda.category_name_part
- assert_nil pdb.category_name_part
- assert_nil pdc.category_name_part
- assert_equal "foo", pdd.category_name_part
- assert_nil pde.category_name_part
+ assert_nil pda.category_name_part_constraint
+ assert_nil pdb.category_name_part_constraint
+ assert_nil pdc.category_name_part_constraint
+ assert_equal "foo", pdd.category_name_part_constraint.name_part
+ assert_nil pde.category_name_part_constraint
end
def test_version_requirements
diff --git a/ruby/package_dep_spec_constraint.cc b/ruby/package_dep_spec_constraint.cc
index 4cfd42f..925b70e 100644
--- a/ruby/package_dep_spec_constraint.cc
+++ b/ruby/package_dep_spec_constraint.cc
@@ -32,6 +32,8 @@ namespace
{
static VALUE c_package_dep_spec_constraint;
static VALUE c_name_constraint;
+ static VALUE c_package_name_part_constraint;
+ static VALUE c_category_name_part_constraint;
struct V
{
@@ -48,6 +50,18 @@ namespace
value = Data_Wrap_Struct(c_name_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free,
new std::shared_ptr<const PackageDepSpecConstraint>(mm));
}
+
+ void visit(const CategoryNamePartConstraint &)
+ {
+ value = Data_Wrap_Struct(c_category_name_part_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free,
+ new std::shared_ptr<const PackageDepSpecConstraint>(mm));
+ }
+
+ void visit(const PackageNamePartConstraint &)
+ {
+ value = Data_Wrap_Struct(c_package_name_part_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free,
+ new std::shared_ptr<const PackageDepSpecConstraint>(mm));
+ }
};
/*
@@ -63,6 +77,32 @@ namespace
return qualified_package_name_to_value((std::static_pointer_cast<const NameConstraint>(*ptr))->name());
}
+ /*
+ * Document-method: name_part
+ *
+ * The name part constraint.
+ */
+ static VALUE
+ package_name_part_constraint_name_part(VALUE self)
+ {
+ std::shared_ptr<const PackageDepSpecConstraint> * ptr;
+ Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecConstraint>, ptr);
+ return rb_str_new2(stringify((std::static_pointer_cast<const PackageNamePartConstraint>(*ptr))->name_part()).c_str());
+ }
+
+ /*
+ * Document-method: name_part
+ *
+ * The name part constraint.
+ */
+ static VALUE
+ category_name_part_constraint_name_part(VALUE self)
+ {
+ std::shared_ptr<const PackageDepSpecConstraint> * ptr;
+ Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecConstraint>, ptr);
+ return rb_str_new2(stringify((std::static_pointer_cast<const CategoryNamePartConstraint>(*ptr))->name_part()).c_str());
+ }
+
void do_register_package_dep_spec_constraint()
{
/*
@@ -82,6 +122,28 @@ namespace
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);
+
+ /*
+ * Document-class: Paludis::PackageNamePartConstraint
+ *
+ * Represents a /pkg name constraint in a PackageDepSpec.
+ */
+ c_package_name_part_constraint = rb_define_class_under(
+ paludis_module(), "PackageNamePartConstraint", c_package_dep_spec_constraint);
+ rb_funcall(c_package_name_part_constraint, rb_intern("private_class_method"), 1, rb_str_new2("new"));
+ rb_define_method(c_package_name_part_constraint, "name_part", RUBY_FUNC_CAST(
+ &package_name_part_constraint_name_part), 0);
+
+ /*
+ * Document-class: Paludis::CategoryNamePartConstraint
+ *
+ * Represents a /pkg name constraint in a PackageDepSpec.
+ */
+ c_category_name_part_constraint = rb_define_class_under(
+ paludis_module(), "CategoryNamePartConstraint", c_package_dep_spec_constraint);
+ rb_funcall(c_category_name_part_constraint, rb_intern("private_class_method"), 1, rb_str_new2("new"));
+ rb_define_method(c_category_name_part_constraint, "name_part", RUBY_FUNC_CAST(
+ &category_name_part_constraint_name_part), 0);
}
}