aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-29 13:23:41 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-04 08:32:59 +0100
commitbc262ad74eb8d80eb979a5c5591b222d5fc1eb36 (patch)
tree6da646abbdea2c1948347abe2679fa1f79be1d15
parent63ca918976505d042587bf7591dfce41b206b8cc (diff)
downloadpaludis-bc262ad74eb8d80eb979a5c5591b222d5fc1eb36.tar.gz
paludis-bc262ad74eb8d80eb979a5c5591b222d5fc1eb36.tar.xz
installed at path to requirements
-rw-r--r--doc/api/cplusplus/examples/example_dep_spec.cc4
-rw-r--r--paludis/dep_spec.cc6
-rw-r--r--paludis/dep_spec.hh7
-rw-r--r--paludis/dep_spec_data.hh7
-rw-r--r--paludis/generator.cc8
-rw-r--r--paludis/match_package.cc4
-rw-r--r--paludis/package_dep_spec_constraint-fwd.hh3
-rw-r--r--paludis/package_dep_spec_constraint.cc18
-rw-r--r--paludis/package_dep_spec_constraint.hh24
-rw-r--r--paludis/package_dep_spec_properties.cc2
-rw-r--r--paludis/partially_made_package_dep_spec.cc12
-rw-r--r--paludis/user_dep_spec_TEST.cc6
-rw-r--r--python/package_dep_spec_constraint.cc15
-rw-r--r--ruby/dep_spec.cc11
-rw-r--r--ruby/dep_spec_TEST.rb10
-rw-r--r--ruby/package_dep_spec_constraint.cc31
16 files changed, 130 insertions, 38 deletions
diff --git a/doc/api/cplusplus/examples/example_dep_spec.cc b/doc/api/cplusplus/examples/example_dep_spec.cc
index 6ef4e86..d8256a5 100644
--- a/doc/api/cplusplus/examples/example_dep_spec.cc
+++ b/doc/api/cplusplus/examples/example_dep_spec.cc
@@ -109,9 +109,9 @@ int main(int argc, char * argv[])
cout << " " << left << setw(24) << "From repository:" << " " <<
spec.from_repository_constraint()->name() << endl;
- if (spec.installed_at_path_ptr())
+ if (spec.installed_at_path_constraint())
cout << " " << left << setw(24) << "Installed at path:" << " " <<
- *spec.installed_at_path_ptr() << endl;
+ spec.installed_at_path_constraint()->path() << endl;
if (spec.installable_to_path_ptr())
cout << " " << left << setw(24) << "Installable to path:" << " " <<
diff --git a/paludis/dep_spec.cc b/paludis/dep_spec.cc
index da912df..8d254ea 100644
--- a/paludis/dep_spec.cc
+++ b/paludis/dep_spec.cc
@@ -596,10 +596,10 @@ PackageDepSpec::from_repository_constraint() const
return _imp->data->from_repository_constraint();
}
-std::shared_ptr<const FSPath>
-PackageDepSpec::installed_at_path_ptr() const
+const std::shared_ptr<const InstalledAtPathConstraint>
+PackageDepSpec::installed_at_path_constraint() const
{
- return _imp->data->installed_at_path_ptr();
+ return _imp->data->installed_at_path_constraint();
}
std::shared_ptr<const InstallableToPath>
diff --git a/paludis/dep_spec.hh b/paludis/dep_spec.hh
index 5af03b3..5058aa6 100644
--- a/paludis/dep_spec.hh
+++ b/paludis/dep_spec.hh
@@ -408,11 +408,12 @@ namespace paludis
const std::shared_ptr<const FromRepositoryConstraint> from_repository_constraint() const;
/**
- * Fetch the installed-at-path requirement (may be a zero pointer).
+ * Fetch the single InstalledAtPathConstraint, if we have one, or
+ * a null pointer otherwise.
*
- * \since 0.32
+ * \since 0.61
*/
- std::shared_ptr<const FSPath> installed_at_path_ptr() const;
+ const std::shared_ptr<const InstalledAtPathConstraint> installed_at_path_constraint() const;
/**
* Fetch the installable-to-path requirement (may be a zero pointer).
diff --git a/paludis/dep_spec_data.hh b/paludis/dep_spec_data.hh
index 20af6bd..b94d5df 100644
--- a/paludis/dep_spec_data.hh
+++ b/paludis/dep_spec_data.hh
@@ -177,11 +177,12 @@ namespace paludis
virtual const std::shared_ptr<const FromRepositoryConstraint> from_repository_constraint() const = 0;
/**
- * Fetch the installed-at-path requirement (may be a zero pointer).
+ * Fetch the single InstalledAtPathConstraint, if we have one, or
+ * a null pointer otherwise.
*
- * \since 0.32
+ * \since 0.61
*/
- virtual std::shared_ptr<const FSPath> installed_at_path_ptr() const = 0;
+ virtual const std::shared_ptr<const InstalledAtPathConstraint> installed_at_path_constraint() const = 0;
/**
* Fetch the installable-to-path requirement (may be a zero pointer).
diff --git a/paludis/generator.cc b/paludis/generator.cc
index f8b7996..1484bbb 100644
--- a/paludis/generator.cc
+++ b/paludis/generator.cc
@@ -326,12 +326,12 @@ namespace
{
if (env->has_repository_named(spec.in_repository_constraint()->name()))
{
- if (spec.installed_at_path_ptr())
+ if (spec.installed_at_path_constraint())
{
std::shared_ptr<const Repository> repo(env->fetch_repository(spec.in_repository_constraint()->name()));
if (! repo->installed_root_key())
return result;
- if (repo->installed_root_key()->value() != *spec.installed_at_path_ptr())
+ if (repo->installed_root_key()->value() != spec.installed_at_path_constraint()->path())
return result;
}
@@ -340,7 +340,7 @@ namespace
}
else
{
- if (spec.installed_at_path_ptr())
+ if (spec.installed_at_path_constraint())
{
for (auto i(env->begin_repositories()),
i_end(env->end_repositories()) ; i != i_end ; ++i)
@@ -348,7 +348,7 @@ namespace
if (! (*i)->installed_root_key())
continue;
- if ((*i)->installed_root_key()->value() != *spec.installed_at_path_ptr())
+ if ((*i)->installed_root_key()->value() != spec.installed_at_path_constraint()->path())
continue;
result->insert((*i)->name());
diff --git a/paludis/match_package.cc b/paludis/match_package.cc
index f5bd183..5c77b1d 100644
--- a/paludis/match_package.cc
+++ b/paludis/match_package.cc
@@ -140,12 +140,12 @@ paludis::match_package_with_maybe_changes(
return false;
}
- if (spec.installed_at_path_ptr())
+ if (spec.installed_at_path_constraint())
{
auto repo(env.fetch_repository(id->repository_name()));
if (! repo->installed_root_key())
return false;
- if (repo->installed_root_key()->value() != *spec.installed_at_path_ptr())
+ if (repo->installed_root_key()->value() != spec.installed_at_path_constraint()->path())
return false;
}
diff --git a/paludis/package_dep_spec_constraint-fwd.hh b/paludis/package_dep_spec_constraint-fwd.hh
index 6309765..e395b31 100644
--- a/paludis/package_dep_spec_constraint-fwd.hh
+++ b/paludis/package_dep_spec_constraint-fwd.hh
@@ -40,6 +40,9 @@ namespace paludis
class FromRepositoryConstraint;
typedef Pool<FromRepositoryConstraint> FromRepositoryConstraintPool;
+
+ class InstalledAtPathConstraint;
+ typedef Pool<InstalledAtPathConstraint> InstalledAtPathConstraintPool;
}
#endif
diff --git a/paludis/package_dep_spec_constraint.cc b/paludis/package_dep_spec_constraint.cc
index 39b4ee5..fe1d9ca 100644
--- a/paludis/package_dep_spec_constraint.cc
+++ b/paludis/package_dep_spec_constraint.cc
@@ -116,3 +116,21 @@ template class Singleton<Pool<FromRepositoryConstraint> >;
template const std::shared_ptr<const FromRepositoryConstraint> Pool<FromRepositoryConstraint>::create(
const RepositoryName &) const;
+InstalledAtPathConstraint::InstalledAtPathConstraint(const FSPath & n) :
+ _path(n)
+{
+}
+
+InstalledAtPathConstraint::~InstalledAtPathConstraint() = default;
+
+const FSPath
+InstalledAtPathConstraint::path() const
+{
+ return _path;
+}
+
+template class Pool<InstalledAtPathConstraint>;
+template class Singleton<Pool<InstalledAtPathConstraint> >;
+template const std::shared_ptr<const InstalledAtPathConstraint> Pool<InstalledAtPathConstraint>::create(
+ const FSPath &) const;
+
diff --git a/paludis/package_dep_spec_constraint.hh b/paludis/package_dep_spec_constraint.hh
index 2617073..88eae45 100644
--- a/paludis/package_dep_spec_constraint.hh
+++ b/paludis/package_dep_spec_constraint.hh
@@ -27,6 +27,7 @@
#include <paludis/util/pool.hh>
#include <paludis/util/visitor.hh>
#include <paludis/util/type_list.hh>
+#include <paludis/util/fs_path.hh>
namespace paludis
{
@@ -36,7 +37,8 @@ namespace paludis
PackageNamePartConstraint,
CategoryNamePartConstraint,
InRepositoryConstraint,
- FromRepositoryConstraint
+ FromRepositoryConstraint,
+ InstalledAtPathConstraint
>::Type>
{
public:
@@ -138,11 +140,31 @@ namespace paludis
const RepositoryName name() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
+ class PALUDIS_VISIBLE InstalledAtPathConstraint :
+ public PackageDepSpecConstraint,
+ public ImplementAcceptMethods<PackageDepSpecConstraint, InstalledAtPathConstraint>
+ {
+ friend class Pool<InstalledAtPathConstraint>;
+
+ private:
+ FSPath _path;
+
+ InstalledAtPathConstraint(const FSPath &);
+
+ InstalledAtPathConstraint(const InstalledAtPathConstraint &) = delete;
+
+ public:
+ ~InstalledAtPathConstraint();
+
+ const FSPath path() 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>;
+ extern template class Pool<InstalledAtPathConstraint>;
}
#endif
diff --git a/paludis/package_dep_spec_properties.cc b/paludis/package_dep_spec_properties.cc
index 11e038b..394395b 100644
--- a/paludis/package_dep_spec_properties.cc
+++ b/paludis/package_dep_spec_properties.cc
@@ -47,7 +47,7 @@ paludis::package_dep_spec_has_properties(const PackageDepSpec & spec, const Pack
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());
- result = result && check(bool(spec.installed_at_path_ptr()), properties.has_installed_at_path());
+ result = result && check(bool(spec.installed_at_path_constraint()), properties.has_installed_at_path());
result = result && check(bool(spec.package_name_constraint()), properties.has_package());
result = result && check(bool(spec.package_name_part_constraint()), properties.has_package_name_part());
result = result && check(bool(spec.slot_requirement_ptr()), properties.has_slot_requirement());
diff --git a/paludis/partially_made_package_dep_spec.cc b/paludis/partially_made_package_dep_spec.cc
index 9f4e7f7..5454f00 100644
--- a/paludis/partially_made_package_dep_spec.cc
+++ b/paludis/partially_made_package_dep_spec.cc
@@ -57,7 +57,7 @@ namespace
std::shared_ptr<const InRepositoryConstraint> in_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 InstalledAtPathConstraint> installed_at_path;
std::shared_ptr<const InstallableToPath> installable_to_path;
std::shared_ptr<AdditionalPackageDepSpecRequirements> additional_requirements;
PartiallyMadePackageDepSpecOptions options_for_partially_made_package_dep_spec_v;
@@ -80,7 +80,7 @@ namespace
in_repository(other.in_repository_constraint()),
from_repository(other.from_repository_constraint()),
installable_to_repository(other.installable_to_repository_ptr()),
- installed_at_path(other.installed_at_path_ptr()),
+ installed_at_path(other.installed_at_path_constraint()),
installable_to_path(other.installable_to_path_ptr()),
additional_requirements(other.additional_requirements_ptr() ? new AdditionalPackageDepSpecRequirements : 0),
options_for_partially_made_package_dep_spec_v(other.options_for_partially_made_package_dep_spec())
@@ -174,14 +174,14 @@ namespace
if (in_repository_constraint())
right = stringify(in_repository_constraint()->name());
- if (installed_at_path_ptr())
+ if (installed_at_path_constraint())
{
if (! right.empty())
{
need_arrow = true;
right.append("->");
}
- right.append(stringify(*installed_at_path_ptr()));
+ right.append(stringify(installed_at_path_constraint()->path()));
}
if (installable_to_repository_ptr())
@@ -323,7 +323,7 @@ namespace
return from_repository;
}
- virtual std::shared_ptr<const FSPath> installed_at_path_ptr() const
+ virtual const std::shared_ptr<const InstalledAtPathConstraint> installed_at_path_constraint() const
{
return installed_at_path;
}
@@ -461,7 +461,7 @@ PartiallyMadePackageDepSpec::clear_installable_to_repository()
PartiallyMadePackageDepSpec &
PartiallyMadePackageDepSpec::installed_at_path(const FSPath & s)
{
- _imp->data->installed_at_path = std::make_shared<FSPath>(s);
+ _imp->data->installed_at_path = InstalledAtPathConstraintPool::get_instance()->create(s);
return *this;
}
diff --git a/paludis/user_dep_spec_TEST.cc b/paludis/user_dep_spec_TEST.cc
index d18b9f3..73461f0 100644
--- a/paludis/user_dep_spec_TEST.cc
+++ b/paludis/user_dep_spec_TEST.cc
@@ -161,11 +161,11 @@ UserDepSpecTest::check_spec(
}
if (installed_at_path.empty())
- EXPECT_TRUE(! spec.installed_at_path_ptr());
+ EXPECT_TRUE(! spec.installed_at_path_constraint());
else
{
- EXPECT_TRUE(bool(spec.installed_at_path_ptr()));
- EXPECT_EQ(installed_at_path, stringify(*spec.installed_at_path_ptr()));
+ EXPECT_TRUE(bool(spec.installed_at_path_constraint()));
+ EXPECT_EQ(installed_at_path, stringify(spec.installed_at_path_constraint()->path()));
}
if (installable_to_path_f.empty())
diff --git a/python/package_dep_spec_constraint.cc b/python/package_dep_spec_constraint.cc
index e1e3b34..2b17ae1 100644
--- a/python/package_dep_spec_constraint.cc
+++ b/python/package_dep_spec_constraint.cc
@@ -133,5 +133,20 @@ void expose_package_dep_spec_constraint()
"[RO] The ::repo-> name in question"
)
;
+
+ /**
+ * InstalledAtPathConstraint
+ */
+ class_package_dep_spec_constraint<InstalledAtPathConstraint>
+ (
+ "InstalledAtPathConstraint",
+ "A ::/ constraint for a PackageDepSpec.",
+ bp::no_init
+ )
+
+ .add_property("path", &InstalledAtPathConstraint::path,
+ "[RO] The ::/ path in question"
+ )
+ ;
}
diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc
index ff3deb6..7c13eab 100644
--- a/ruby/dep_spec.cc
+++ b/ruby/dep_spec.cc
@@ -726,18 +726,19 @@ namespace
/*
* call-seq:
- * installed_at_path -> String or Nil
+ * installed_at_path_constraint ->
+ * InstalledAtPathConstraint or Nil
*
* Fetch the installed-at-path requirement.
*/
VALUE
- package_dep_spec_installed_at_path(VALUE self)
+ package_dep_spec_installed_at_path_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()->installed_at_path_ptr()))
+ if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installed_at_path_constraint()))
return Qnil;
- return rb_str_new2(stringify((*std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installed_at_path_ptr())).c_str());
+ return package_dep_spec_constraint_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installed_at_path_constraint());
}
/*
@@ -1116,7 +1117,7 @@ namespace
rb_define_method(c_package_dep_spec, "in_repository_constraint", RUBY_FUNC_CAST(&package_dep_spec_in_repository_constraint), 0);
rb_define_method(c_package_dep_spec, "from_repository_constraint", RUBY_FUNC_CAST(&package_dep_spec_from_repository_constraint), 0);
rb_define_method(c_package_dep_spec, "installable_to_repository", RUBY_FUNC_CAST(&package_dep_spec_installable_to_repository), 0);
- rb_define_method(c_package_dep_spec, "installed_at_path", RUBY_FUNC_CAST(&package_dep_spec_installed_at_path), 0);
+ rb_define_method(c_package_dep_spec, "installed_at_path_constraint", RUBY_FUNC_CAST(&package_dep_spec_installed_at_path_constraint), 0);
rb_define_method(c_package_dep_spec, "installable_to_path", RUBY_FUNC_CAST(&package_dep_spec_installable_to_path), 0);
rb_define_method(c_package_dep_spec, "version_requirements", RUBY_FUNC_CAST(&package_dep_spec_version_requirements_ptr), 0);
rb_define_method(c_package_dep_spec, "version_requirements_mode", RUBY_FUNC_CAST(&package_dep_spec_version_requirements_mode), 0);
diff --git a/ruby/dep_spec_TEST.rb b/ruby/dep_spec_TEST.rb
index 58b8817..565968e 100644
--- a/ruby/dep_spec_TEST.rb
+++ b/ruby/dep_spec_TEST.rb
@@ -174,11 +174,11 @@ module Paludis
end
def test_installed_at_path
- assert_nil pda.installed_at_path
- assert_nil pdb.installed_at_path
- assert_nil pdc.installed_at_path
- assert_nil pdd.installed_at_path
- assert_equal "/mychroot", pde.installed_at_path
+ assert_nil pda.installed_at_path_constraint
+ assert_nil pdb.installed_at_path_constraint
+ assert_nil pdc.installed_at_path_constraint
+ assert_nil pdd.installed_at_path_constraint
+ assert_equal "/mychroot", pde.installed_at_path_constraint.path
end
def test_installable_to_path
diff --git a/ruby/package_dep_spec_constraint.cc b/ruby/package_dep_spec_constraint.cc
index 9e4757b..10e6509 100644
--- a/ruby/package_dep_spec_constraint.cc
+++ b/ruby/package_dep_spec_constraint.cc
@@ -36,6 +36,7 @@ namespace
static VALUE c_category_name_part_constraint;
static VALUE c_in_repository_constraint;
static VALUE c_from_repository_constraint;
+ static VALUE c_installed_at_path_constraint;
struct V
{
@@ -76,6 +77,12 @@ namespace
value = Data_Wrap_Struct(c_from_repository_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free,
new std::shared_ptr<const PackageDepSpecConstraint>(mm));
}
+
+ void visit(const InstalledAtPathConstraint &)
+ {
+ value = Data_Wrap_Struct(c_installed_at_path_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free,
+ new std::shared_ptr<const PackageDepSpecConstraint>(mm));
+ }
};
/*
@@ -143,6 +150,19 @@ namespace
return rb_str_new2(stringify((std::static_pointer_cast<const FromRepositoryConstraint>(*ptr))->name()).c_str());
}
+ /*
+ * Document-method: path
+ *
+ * The path constraint.
+ */
+ static VALUE
+ installed_at_path_constraint_path(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 InstalledAtPathConstraint>(*ptr))->path()).c_str());
+ }
+
void do_register_package_dep_spec_constraint()
{
/*
@@ -206,6 +226,17 @@ namespace
rb_funcall(c_from_repository_constraint, rb_intern("private_class_method"), 1, rb_str_new2("new"));
rb_define_method(c_from_repository_constraint, "name", RUBY_FUNC_CAST(
&from_repository_constraint_name), 0);
+
+ /*
+ * Document-class: Paludis::InstalledAtPathConstraint
+ *
+ * Represents a ::/ path constraint in a PackageDepSpec.
+ */
+ c_installed_at_path_constraint = rb_define_class_under(
+ paludis_module(), "InRepositoryConstraint", c_package_dep_spec_constraint);
+ rb_funcall(c_installed_at_path_constraint, rb_intern("private_class_method"), 1, rb_str_new2("new"));
+ rb_define_method(c_installed_at_path_constraint, "path", RUBY_FUNC_CAST(
+ &installed_at_path_constraint_path), 0);
}
}