aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-13 13:07:30 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-13 13:07:30 +0000
commit582061c6d236560eb2fc7a23dd51489dfc00eece (patch)
tree49f03388d794fa91461987d0f183e4e741a60e42
parent4deaae9847fc456f85737eaa9aa3e189dd98784c (diff)
downloadpaludis-582061c6d236560eb2fc7a23dd51489dfc00eece.tar.gz
paludis-582061c6d236560eb2fc7a23dd51489dfc00eece.tar.xz
Clean up repository use interface. Fixes: ticket:228
-rw-r--r--paludis/dep_list/dep_list.cc4
-rw-r--r--paludis/environment_implementation.cc6
-rw-r--r--paludis/environments/paludis/paludis_environment.cc6
-rw-r--r--paludis/environments/portage/portage_environment.cc6
-rw-r--r--paludis/qa/deps_visible_check.cc4
-rw-r--r--paludis/qa/iuse_check.cc2
-rw-r--r--paludis/repositories/fake/fake_repository_base.cc8
-rw-r--r--paludis/repositories/fake/fake_repository_base.hh9
-rw-r--r--paludis/repositories/gentoo/portage_repository.cc8
-rw-r--r--paludis/repositories/gentoo/portage_repository.hh9
-rw-r--r--paludis/repositories/gentoo/portage_repository_TEST.cc22
-rw-r--r--paludis/repositories/gentoo/portage_repository_profile.cc68
-rw-r--r--paludis/repositories/gentoo/portage_repository_profile.hh6
-rw-r--r--paludis/repositories/gentoo/use_desc.cc17
-rw-r--r--paludis/repositories/gentoo/use_desc.hh2
-rw-r--r--paludis/repositories/gentoo/vdb_repository.cc15
-rw-r--r--paludis/repositories/gentoo/vdb_repository.hh8
-rw-r--r--paludis/repository.cc53
-rw-r--r--paludis/repository.hh53
-rw-r--r--python/repository.cc16
-rwxr-xr-xpython/repository_TEST.py17
-rw-r--r--ruby/repository.cc35
-rw-r--r--ruby/repository_TEST.rb44
-rw-r--r--src/output/console_install_task.cc2
-rw-r--r--src/output/use_flag_pretty_printer.cc8
25 files changed, 186 insertions, 242 deletions
diff --git a/paludis/dep_list/dep_list.cc b/paludis/dep_list/dep_list.cc
index 1113d0a..235a4f8 100644
--- a/paludis/dep_list/dep_list.cc
+++ b/paludis/dep_list/dep_list.cc
@@ -806,12 +806,12 @@ DepList::AddVisitor::visit(const UseDepSpec * const a)
std::for_each(a->begin(), a->end(), accept_visitor(this));
else if (a->inverse())
{
- if (! u->query_use_force(a->flag(), d->_imp->current_pde()))
+ if ((! d->_imp->current_pde()) || (! u->query_use_force(a->flag(), *d->_imp->current_pde())))
std::for_each(a->begin(), a->end(), accept_visitor(this));
}
else
{
- if (! u->query_use_mask(a->flag(), d->_imp->current_pde()))
+ if ((! d->_imp->current_pde()) || (! u->query_use_mask(a->flag(), *d->_imp->current_pde())))
std::for_each(a->begin(), a->end(), accept_visitor(this));
}
}
diff --git a/paludis/environment_implementation.cc b/paludis/environment_implementation.cc
index bdf4946..cfa2cb6 100644
--- a/paludis/environment_implementation.cc
+++ b/paludis/environment_implementation.cc
@@ -376,15 +376,15 @@ EnvironmentImplementation::query_use(const UseFlagName & f, const PackageDatabas
if (repo && repo->use_interface)
{
- if (repo->use_interface->query_use_mask(f, &e))
+ if (repo->use_interface->query_use_mask(f, e))
return false;
- if (repo->use_interface->query_use_force(f, &e))
+ if (repo->use_interface->query_use_force(f, e))
return true;
}
if (repo && repo->use_interface)
{
- switch (repo->use_interface->query_use(f, &e))
+ switch (repo->use_interface->query_use(f, e))
{
case use_disabled:
case use_unspecified:
diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc
index d75ebb1..870c72b 100644
--- a/paludis/environments/paludis/paludis_environment.cc
+++ b/paludis/environments/paludis/paludis_environment.cc
@@ -162,9 +162,9 @@ PaludisEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry
if (repo->use_interface)
{
- if (repo->use_interface->query_use_mask(f, &e))
+ if (repo->use_interface->query_use_mask(f, e))
return false;
- if (repo->use_interface->query_use_force(f, &e))
+ if (repo->use_interface->query_use_force(f, e))
return true;
}
@@ -191,7 +191,7 @@ PaludisEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry
/* check use: package database config */
if (repo->use_interface)
{
- switch (repo->use_interface->query_use(f, &e))
+ switch (repo->use_interface->query_use(f, e))
{
case use_disabled:
case use_unspecified:
diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc
index db8b09e..6597643 100644
--- a/paludis/environments/portage/portage_environment.cc
+++ b/paludis/environments/portage/portage_environment.cc
@@ -434,9 +434,9 @@ PortageEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry
if (repo->use_interface)
{
- if (repo->use_interface->query_use_mask(f, &e))
+ if (repo->use_interface->query_use_mask(f, e))
return false;
- if (repo->use_interface->query_use_force(f, &e))
+ if (repo->use_interface->query_use_force(f, e))
return true;
}
@@ -444,7 +444,7 @@ PortageEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry
/* check use: repo */
if (repo->use_interface)
- state = repo->use_interface->query_use(f, &e);
+ state = repo->use_interface->query_use(f, e);
/* check use: general user config */
std::set<std::string>::const_iterator u(_imp->use_with_expands.find(stringify(f)));
diff --git a/paludis/qa/deps_visible_check.cc b/paludis/qa/deps_visible_check.cc
index f8dc4ad..70320a3 100644
--- a/paludis/qa/deps_visible_check.cc
+++ b/paludis/qa/deps_visible_check.cc
@@ -56,10 +56,10 @@ namespace
if (! i)
return true;
- if (i->query_use_mask(u->flag(), &pde) && ! u->inverse())
+ if (i->query_use_mask(u->flag(), pde) && ! u->inverse())
return false;
- if (i->query_use_force(u->flag(), &pde) && u->inverse())
+ if (i->query_use_force(u->flag(), pde) && u->inverse())
return false;
/* arch flags aren't necessarily use masked. stupid! */
diff --git a/paludis/qa/iuse_check.cc b/paludis/qa/iuse_check.cc
index 11cb6c3..3c7210e 100644
--- a/paludis/qa/iuse_check.cc
+++ b/paludis/qa/iuse_check.cc
@@ -93,7 +93,7 @@ IuseCheck::operator() (const EbuildCheckData & e) const
for (std::set<UseFlagName>::iterator i(iuse.begin()), i_end(iuse.end()) ; i != i_end ; ++i)
if ("" == e.environment->package_database()->fetch_repository(ee.repository)->use_interface->
- describe_use_flag(*i, &ee))
+ describe_use_flag(*i, ee))
result << Message(qal_minor, "Use flag '" + stringify(*i) + "' has no description");
}
catch (const NameError & err)
diff --git a/paludis/repositories/fake/fake_repository_base.cc b/paludis/repositories/fake/fake_repository_base.cc
index 3499b64..13356a8 100644
--- a/paludis/repositories/fake/fake_repository_base.cc
+++ b/paludis/repositories/fake/fake_repository_base.cc
@@ -200,19 +200,19 @@ FakeRepositoryBase::do_query_profile_masks(const QualifiedPackageName &, const V
}
UseFlagState
-FakeRepositoryBase::do_query_use(const UseFlagName &, const PackageDatabaseEntry *) const
+FakeRepositoryBase::do_query_use(const UseFlagName &, const PackageDatabaseEntry &) const
{
return use_unspecified;
}
bool
-FakeRepositoryBase::do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const
+FakeRepositoryBase::do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry &) const
{
return false;
}
bool
-FakeRepositoryBase::do_query_use_force(const UseFlagName &, const PackageDatabaseEntry *) const
+FakeRepositoryBase::do_query_use_force(const UseFlagName &, const PackageDatabaseEntry &) const
{
return false;
}
@@ -273,7 +273,7 @@ FakeRepositoryBase::sets_list() const
std::string
FakeRepositoryBase::do_describe_use_flag(const UseFlagName &,
- const PackageDatabaseEntry * const) const
+ const PackageDatabaseEntry &) const
{
return "";
}
diff --git a/paludis/repositories/fake/fake_repository_base.hh b/paludis/repositories/fake/fake_repository_base.hh
index 2b2b4a5..0bf423f 100644
--- a/paludis/repositories/fake/fake_repository_base.hh
+++ b/paludis/repositories/fake/fake_repository_base.hh
@@ -102,15 +102,14 @@ namespace paludis
protected:
/* RepositoryUseInterface */
- virtual UseFlagState do_query_use(const UseFlagName &, const PackageDatabaseEntry *) const;
- virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const;
- virtual bool do_query_use_force(const UseFlagName &, const PackageDatabaseEntry *) const;
+ virtual UseFlagState do_query_use(const UseFlagName &, const PackageDatabaseEntry &) const;
+ virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry &) const;
+ virtual bool do_query_use_force(const UseFlagName &, const PackageDatabaseEntry &) const;
virtual std::tr1::shared_ptr<const UseFlagNameCollection> do_arch_flags() const;
virtual std::tr1::shared_ptr<const UseFlagNameCollection> do_use_expand_flags() const;
virtual std::tr1::shared_ptr<const UseFlagNameCollection> do_use_expand_hidden_prefixes() const;
virtual std::tr1::shared_ptr<const UseFlagNameCollection> do_use_expand_prefixes() const;
- virtual std::string do_describe_use_flag(const UseFlagName &,
- const PackageDatabaseEntry * const) const;
+ virtual std::string do_describe_use_flag(const UseFlagName &, const PackageDatabaseEntry &) const;
/* end of RepositoryUseInterface */
diff --git a/paludis/repositories/gentoo/portage_repository.cc b/paludis/repositories/gentoo/portage_repository.cc
index f2c86b6..3404fd8 100644
--- a/paludis/repositories/gentoo/portage_repository.cc
+++ b/paludis/repositories/gentoo/portage_repository.cc
@@ -718,14 +718,14 @@ PortageRepository::do_query_profile_masks(const QualifiedPackageName & n,
}
UseFlagState
-PortageRepository::do_query_use(const UseFlagName & f, const PackageDatabaseEntry * e) const
+PortageRepository::do_query_use(const UseFlagName & f, const PackageDatabaseEntry & e) const
{
_imp->need_profiles();
return _imp->profile_ptr->use_state_ignoring_masks(f, e);
}
bool
-PortageRepository::do_query_use_mask(const UseFlagName & u, const PackageDatabaseEntry * e) const
+PortageRepository::do_query_use_mask(const UseFlagName & u, const PackageDatabaseEntry & e) const
{
_imp->need_profiles();
return _imp->profile_ptr->use_masked(u, e) ||
@@ -733,7 +733,7 @@ PortageRepository::do_query_use_mask(const UseFlagName & u, const PackageDatabas
}
bool
-PortageRepository::do_query_use_force(const UseFlagName & u, const PackageDatabaseEntry * e) const
+PortageRepository::do_query_use_force(const UseFlagName & u, const PackageDatabaseEntry & e) const
{
_imp->need_profiles();
return _imp->profile_ptr->use_forced(u, e);
@@ -1211,7 +1211,7 @@ PortageRepository::set_profile_by_arch(const UseFlagName & arch)
std::string
PortageRepository::do_describe_use_flag(const UseFlagName & f,
- const PackageDatabaseEntry * const e) const
+ const PackageDatabaseEntry & e) const
{
if (_imp->use_desc.empty())
for (std::list<FSEntry>::const_iterator p(_imp->profiles_dir_locations.begin()),
diff --git a/paludis/repositories/gentoo/portage_repository.hh b/paludis/repositories/gentoo/portage_repository.hh
index 59e2d2d..4048d88 100644
--- a/paludis/repositories/gentoo/portage_repository.hh
+++ b/paludis/repositories/gentoo/portage_repository.hh
@@ -121,15 +121,14 @@ namespace paludis
/* RepositoryUseInterface */
- virtual UseFlagState do_query_use(const UseFlagName &, const PackageDatabaseEntry *) const;
- virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const;
- virtual bool do_query_use_force(const UseFlagName &, const PackageDatabaseEntry *) const;
+ virtual UseFlagState do_query_use(const UseFlagName &, const PackageDatabaseEntry &) const;
+ virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry &) const;
+ virtual bool do_query_use_force(const UseFlagName &, const PackageDatabaseEntry &) const;
virtual std::tr1::shared_ptr<const UseFlagNameCollection> do_arch_flags() const;
virtual std::tr1::shared_ptr<const UseFlagNameCollection> do_use_expand_flags() const;
virtual std::tr1::shared_ptr<const UseFlagNameCollection> do_use_expand_hidden_prefixes() const;
virtual std::tr1::shared_ptr<const UseFlagNameCollection> do_use_expand_prefixes() const;
- virtual std::string do_describe_use_flag(const UseFlagName &,
- const PackageDatabaseEntry * const) const;
+ virtual std::string do_describe_use_flag(const UseFlagName &, const PackageDatabaseEntry &) const;
/* end of RepositoryUseInterface */
diff --git a/paludis/repositories/gentoo/portage_repository_TEST.cc b/paludis/repositories/gentoo/portage_repository_TEST.cc
index a3aaab3..cfe88a2 100644
--- a/paludis/repositories/gentoo/portage_repository_TEST.cc
+++ b/paludis/repositories/gentoo/portage_repository_TEST.cc
@@ -623,17 +623,17 @@ namespace test_cases
PackageDatabaseEntry p4(QualifiedPackageName("cat-one/pkg-one"), VersionSpec("2"),
RepositoryName("test-repo-9"));
- TEST_CHECK(repo->query_use(UseFlagName("flag1"), &p1) == use_enabled);
- TEST_CHECK(repo->query_use(UseFlagName("flag2"), &p1) == use_disabled);
- TEST_CHECK(repo->query_use_mask(UseFlagName("flag2"), &p1));
- TEST_CHECK(repo->query_use_mask(UseFlagName("flag2"), &p3));
- TEST_CHECK(repo->query_use_mask(UseFlagName("flag3"), &p2));
- TEST_CHECK(! repo->query_use_mask(UseFlagName("flag3"), &p1));
- TEST_CHECK(repo->query_use_mask(UseFlagName("flag3"), &p4));
- TEST_CHECK(repo->query_use(UseFlagName("flag3"), &p1) == use_enabled);
- TEST_CHECK(repo->query_use(UseFlagName("flag4"), &p3) == use_enabled);
- TEST_CHECK(repo->query_use(UseFlagName("flag5"), &p2) == use_enabled);
- TEST_CHECK(repo->query_use(UseFlagName("flag5"), &p1) == use_unspecified);
+ TEST_CHECK(repo->query_use(UseFlagName("flag1"), p1) == use_enabled);
+ TEST_CHECK(repo->query_use(UseFlagName("flag2"), p1) == use_disabled);
+ TEST_CHECK(repo->query_use_mask(UseFlagName("flag2"), p1));
+ TEST_CHECK(repo->query_use_mask(UseFlagName("flag2"), p3));
+ TEST_CHECK(repo->query_use_mask(UseFlagName("flag3"), p2));
+ TEST_CHECK(! repo->query_use_mask(UseFlagName("flag3"), p1));
+ TEST_CHECK(repo->query_use_mask(UseFlagName("flag3"), p4));
+ TEST_CHECK(repo->query_use(UseFlagName("flag3"), p1) == use_enabled);
+ TEST_CHECK(repo->query_use(UseFlagName("flag4"), p3) == use_enabled);
+ TEST_CHECK(repo->query_use(UseFlagName("flag5"), p2) == use_enabled);
+ TEST_CHECK(repo->query_use(UseFlagName("flag5"), p1) == use_unspecified);
}
}
} test_portage_repository_query_use;
diff --git a/paludis/repositories/gentoo/portage_repository_profile.cc b/paludis/repositories/gentoo/portage_repository_profile.cc
index f4c05f0..82854da 100644
--- a/paludis/repositories/gentoo/portage_repository_profile.cc
+++ b/paludis/repositories/gentoo/portage_repository_profile.cc
@@ -586,7 +586,7 @@ PortageRepositoryProfile::~PortageRepositoryProfile()
bool
PortageRepositoryProfile::use_masked(const UseFlagName & u,
- const PackageDatabaseEntry * const e) const
+ const PackageDatabaseEntry & e) const
{
bool result(false);
for (StackedValuesList::const_iterator i(_imp->stacked_values_list.begin()),
@@ -596,25 +596,23 @@ PortageRepositoryProfile::use_masked(const UseFlagName & u,
if (i->use_mask.end() != f)
result = f->second;
- if (e)
- for (PackageFlagStatusMapList::const_iterator g(i->package_use_mask.begin()),
- g_end(i->package_use_mask.end()) ; g != g_end ; ++g)
- {
- if (! match_package(*_imp->env, *g->first, *e))
- continue;
+ for (PackageFlagStatusMapList::const_iterator g(i->package_use_mask.begin()),
+ g_end(i->package_use_mask.end()) ; g != g_end ; ++g)
+ {
+ if (! match_package(*_imp->env, *g->first, e))
+ continue;
- FlagStatusMap::const_iterator h(g->second.find(u));
- if (g->second.end() != h)
- result = h->second;
- }
+ FlagStatusMap::const_iterator h(g->second.find(u));
+ if (g->second.end() != h)
+ result = h->second;
+ }
}
return result;
}
bool
-PortageRepositoryProfile::use_forced(const UseFlagName & u,
- const PackageDatabaseEntry * const e) const
+PortageRepositoryProfile::use_forced(const UseFlagName & u, const PackageDatabaseEntry & e) const
{
bool result(false);
for (StackedValuesList::const_iterator i(_imp->stacked_values_list.begin()),
@@ -624,17 +622,16 @@ PortageRepositoryProfile::use_forced(const UseFlagName & u,
if (i->use_force.end() != f)
result = f->second;
- if (e)
- for (PackageFlagStatusMapList::const_iterator g(i->package_use_force.begin()),
- g_end(i->package_use_force.end()) ; g != g_end ; ++g)
- {
- if (! match_package(*_imp->env, *g->first, *e))
- continue;
+ for (PackageFlagStatusMapList::const_iterator g(i->package_use_force.begin()),
+ g_end(i->package_use_force.end()) ; g != g_end ; ++g)
+ {
+ if (! match_package(*_imp->env, *g->first, e))
+ continue;
- FlagStatusMap::const_iterator h(g->second.find(u));
- if (g->second.end() != h)
- result = h->second;
- }
+ FlagStatusMap::const_iterator h(g->second.find(u));
+ if (g->second.end() != h)
+ result = h->second;
+ }
}
return result;
@@ -642,7 +639,7 @@ PortageRepositoryProfile::use_forced(const UseFlagName & u,
UseFlagState
PortageRepositoryProfile::use_state_ignoring_masks(const UseFlagName & u,
- const PackageDatabaseEntry * const e) const
+ const PackageDatabaseEntry & e) const
{
UseFlagState result(use_unspecified);
@@ -651,22 +648,21 @@ PortageRepositoryProfile::use_state_ignoring_masks(const UseFlagName & u,
for (StackedValuesList::const_iterator i(_imp->stacked_values_list.begin()),
i_end(_imp->stacked_values_list.end()) ; i != i_end ; ++i)
{
- if (e)
- for (PackageFlagStatusMapList::const_iterator g(i->package_use.begin()),
- g_end(i->package_use.end()) ; g != g_end ; ++g)
- {
- if (! match_package(*_imp->env, *g->first, *e))
- continue;
+ for (PackageFlagStatusMapList::const_iterator g(i->package_use.begin()),
+ g_end(i->package_use.end()) ; g != g_end ; ++g)
+ {
+ if (! match_package(*_imp->env, *g->first, e))
+ continue;
- FlagStatusMap::const_iterator h(g->second.find(u));
- if (g->second.end() != h)
- result = h->second ? use_enabled : use_disabled;
- }
+ FlagStatusMap::const_iterator h(g->second.find(u));
+ if (g->second.end() != h)
+ result = h->second ? use_enabled : use_disabled;
+ }
}
- if (use_unspecified == result && e && _imp->repository->has_version(e->name, e->version))
+ if (use_unspecified == result && _imp->repository->has_version(e.name, e.version))
{
- std::tr1::shared_ptr<const VersionMetadata> m(_imp->repository->version_metadata(e->name, e->version));
+ std::tr1::shared_ptr<const VersionMetadata> m(_imp->repository->version_metadata(e.name, e.version));
if (m->ebuild_interface)
{
IUseFlagCollection::Iterator i(m->ebuild_interface->iuse()->find(IUseFlag(u, use_unspecified)));
diff --git a/paludis/repositories/gentoo/portage_repository_profile.hh b/paludis/repositories/gentoo/portage_repository_profile.hh
index 9bee182..9d2f861 100644
--- a/paludis/repositories/gentoo/portage_repository_profile.hh
+++ b/paludis/repositories/gentoo/portage_repository_profile.hh
@@ -67,13 +67,13 @@ namespace paludis
///\{
/// Is a use flag masked?
- bool use_masked(const UseFlagName &, const PackageDatabaseEntry * const) const;
+ bool use_masked(const UseFlagName &, const PackageDatabaseEntry &) const;
/// Is a use flag forced?
- bool use_forced(const UseFlagName &, const PackageDatabaseEntry * const) const;
+ bool use_forced(const UseFlagName &, const PackageDatabaseEntry &) const;
/// Use flag state, ignoring mask and force?
- UseFlagState use_state_ignoring_masks(const UseFlagName &, const PackageDatabaseEntry * const) const;
+ UseFlagState use_state_ignoring_masks(const UseFlagName &, const PackageDatabaseEntry &) const;
///\}
diff --git a/paludis/repositories/gentoo/use_desc.cc b/paludis/repositories/gentoo/use_desc.cc
index 28596b4..7d5ced8 100644
--- a/paludis/repositories/gentoo/use_desc.cc
+++ b/paludis/repositories/gentoo/use_desc.cc
@@ -76,20 +76,17 @@ UseDesc::~UseDesc()
}
std::string
-UseDesc::describe(const UseFlagName & f, const PackageDatabaseEntry * const e) const
+UseDesc::describe(const UseFlagName & f, const PackageDatabaseEntry & e) const
{
- if (e)
- {
- MakeHashedMap<std::string, std::string>::Type::const_iterator i(
- _imp->desc.find(stringify(e->name) + ":" + stringify(f)));
- if (_imp->desc.end() != i)
- return i->second;
- }
-
- MakeHashedMap<std::string, std::string>::Type::const_iterator i(_imp->desc.find(stringify(f)));
+ MakeHashedMap<std::string, std::string>::Type::const_iterator i(
+ _imp->desc.find(stringify(e.name) + ":" + stringify(f)));
if (_imp->desc.end() != i)
return i->second;
+ MakeHashedMap<std::string, std::string>::Type::const_iterator j(_imp->desc.find(stringify(f)));
+ if (_imp->desc.end() != j)
+ return j->second;
+
return "";
}
diff --git a/paludis/repositories/gentoo/use_desc.hh b/paludis/repositories/gentoo/use_desc.hh
index 64ffc02..985d19e 100644
--- a/paludis/repositories/gentoo/use_desc.hh
+++ b/paludis/repositories/gentoo/use_desc.hh
@@ -52,7 +52,7 @@ namespace paludis
*
* May return an empty string.
*/
- std::string describe(const UseFlagName &, const PackageDatabaseEntry * const) const;
+ std::string describe(const UseFlagName &, const PackageDatabaseEntry &) const;
};
}
diff --git a/paludis/repositories/gentoo/vdb_repository.cc b/paludis/repositories/gentoo/vdb_repository.cc
index 49db7f1..0978e19 100644
--- a/paludis/repositories/gentoo/vdb_repository.cc
+++ b/paludis/repositories/gentoo/vdb_repository.cc
@@ -804,17 +804,16 @@ VDBRepository::do_installed_time(const QualifiedPackageName & q,
}
UseFlagState
-VDBRepository::do_query_use(const UseFlagName & f,
- const PackageDatabaseEntry * const e) const
+VDBRepository::do_query_use(const UseFlagName & f, const PackageDatabaseEntry & e) const
{
- if (e && e->repository == name())
+ if (e.repository == name())
{
if (! _imp->entries_valid)
- _imp->load_entries_for(e->name.category);
+ _imp->load_entries_for(e.name.category);
std::pair<std::vector<VDBEntry>::iterator, std::vector<VDBEntry>::iterator>
r(std::equal_range(_imp->entries.begin(), _imp->entries.end(), std::make_pair(
- e->name, e->version), VDBEntry::CompareVersion()));
+ e.name, e.version), VDBEntry::CompareVersion()));
if (r.first == r.second)
return use_unspecified;
@@ -832,13 +831,13 @@ VDBRepository::do_query_use(const UseFlagName & f,
}
bool
-VDBRepository::do_query_use_mask(const UseFlagName & u, const PackageDatabaseEntry * e) const
+VDBRepository::do_query_use_mask(const UseFlagName & u, const PackageDatabaseEntry & e) const
{
return use_disabled == do_query_use(u, e);
}
bool
-VDBRepository::do_query_use_force(const UseFlagName & u, const PackageDatabaseEntry * e) const
+VDBRepository::do_query_use_force(const UseFlagName & u, const PackageDatabaseEntry & e) const
{
return use_enabled == do_query_use(u, e);
}
@@ -1476,7 +1475,7 @@ VDBRepository::is_default_destination() const
std::string
VDBRepository::do_describe_use_flag(const UseFlagName &,
- const PackageDatabaseEntry * const) const
+ const PackageDatabaseEntry &) const
{
return "";
}
diff --git a/paludis/repositories/gentoo/vdb_repository.hh b/paludis/repositories/gentoo/vdb_repository.hh
index 5e96679..77052aa 100644
--- a/paludis/repositories/gentoo/vdb_repository.hh
+++ b/paludis/repositories/gentoo/vdb_repository.hh
@@ -102,9 +102,9 @@ namespace paludis
/* RepositoryUseInterface */
- virtual UseFlagState do_query_use(const UseFlagName &, const PackageDatabaseEntry *) const;
- virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const;
- virtual bool do_query_use_force(const UseFlagName &, const PackageDatabaseEntry *) const;
+ virtual UseFlagState do_query_use(const UseFlagName &, const PackageDatabaseEntry &) const;
+ virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry &) const;
+ virtual bool do_query_use_force(const UseFlagName &, const PackageDatabaseEntry &) const;
virtual std::tr1::shared_ptr<const UseFlagNameCollection> do_arch_flags() const;
virtual std::tr1::shared_ptr<const UseFlagNameCollection> do_use_expand_flags() const;
virtual std::tr1::shared_ptr<const UseFlagNameCollection> do_use_expand_hidden_prefixes() const;
@@ -177,7 +177,7 @@ namespace paludis
void merge(const MergeOptions &);
virtual std::string do_describe_use_flag(const UseFlagName &,
- const PackageDatabaseEntry * const) const;
+ const PackageDatabaseEntry &) const;
virtual FSEntry root() const;
diff --git a/paludis/repository.cc b/paludis/repository.cc
index 5665f00..58d1405 100644
--- a/paludis/repository.cc
+++ b/paludis/repository.cc
@@ -330,3 +330,56 @@ RepositoryHookInterface::~RepositoryHookInterface()
{
}
+UseFlagState
+RepositoryUseInterface::query_use(const UseFlagName & u, const PackageDatabaseEntry & pde) const
+{
+ if (do_query_use_mask(u, pde))
+ return use_disabled;
+ else if (do_query_use_force(u, pde))
+ return use_enabled;
+ else
+ return do_query_use(u, pde);
+}
+
+bool
+RepositoryUseInterface::query_use_mask(const UseFlagName & u, const PackageDatabaseEntry & pde) const
+{
+ return do_query_use_mask(u, pde);
+}
+
+bool
+RepositoryUseInterface::query_use_force(const UseFlagName & u, const PackageDatabaseEntry & pde) const
+{
+ return do_query_use_force(u, pde);
+}
+
+std::tr1::shared_ptr<const UseFlagNameCollection>
+RepositoryUseInterface::arch_flags() const
+{
+ return do_arch_flags();
+}
+
+std::tr1::shared_ptr<const UseFlagNameCollection>
+RepositoryUseInterface::use_expand_flags() const
+{
+ return do_use_expand_flags();
+}
+
+std::tr1::shared_ptr<const UseFlagNameCollection>
+RepositoryUseInterface::use_expand_hidden_prefixes() const
+{
+ return do_use_expand_hidden_prefixes();
+}
+
+std::tr1::shared_ptr<const UseFlagNameCollection>
+RepositoryUseInterface::use_expand_prefixes() const
+{
+ return do_use_expand_prefixes();
+}
+
+std::string
+RepositoryUseInterface::describe_use_flag(const UseFlagName & n, const PackageDatabaseEntry & pkg) const
+{
+ return do_describe_use_flag(n, pkg);
+}
+
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 8f8a6c8..ca04583 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -436,19 +436,19 @@ namespace paludis
/**
* Override in descendents: get use.
*/
- virtual UseFlagState do_query_use(const UseFlagName &, const PackageDatabaseEntry *) const
+ virtual UseFlagState do_query_use(const UseFlagName &, const PackageDatabaseEntry &) const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
* Override in descendents: get use mask.
*/
- virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const
+ virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry &) const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
* Override in descendents: get use force.
*/
- virtual bool do_query_use_force(const UseFlagName &, const PackageDatabaseEntry *) const
+ virtual bool do_query_use_force(const UseFlagName &, const PackageDatabaseEntry &) const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
@@ -479,7 +479,7 @@ namespace paludis
* Override in descendents: describe a use flag.
*/
virtual std::string do_describe_use_flag(const UseFlagName &,
- const PackageDatabaseEntry * const) const
+ const PackageDatabaseEntry &) const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
///\}
@@ -491,72 +491,43 @@ namespace paludis
/**
* Query the state of the specified use flag.
*/
- UseFlagState query_use(const UseFlagName & u, const PackageDatabaseEntry *pde) const
- {
- if (do_query_use_mask(u, pde))
- return use_disabled;
- else if (do_query_use_force(u, pde))
- return use_enabled;
- else
- return do_query_use(u, pde);
- }
+ UseFlagState query_use(const UseFlagName & u, const PackageDatabaseEntry &) const;
/**
* Query whether the specified use flag is masked.
*/
- bool query_use_mask(const UseFlagName & u, const PackageDatabaseEntry *pde) const
- {
- return do_query_use_mask(u, pde);
- }
+ bool query_use_mask(const UseFlagName & u, const PackageDatabaseEntry & pde) const;
/**
* Query whether the specified use flag is forced.
*/
- bool query_use_force(const UseFlagName & u, const PackageDatabaseEntry *pde) const
- {
- return do_query_use_force(u, pde);
- }
+ bool query_use_force(const UseFlagName & u, const PackageDatabaseEntry & pde) const;
/**
* Fetch all arch flags.
*/
- std::tr1::shared_ptr<const UseFlagNameCollection> arch_flags() const
- {
- return do_arch_flags();
- }
+ std::tr1::shared_ptr<const UseFlagNameCollection> arch_flags() const;
/**
* Fetch all expand flags.
*/
- std::tr1::shared_ptr<const UseFlagNameCollection> use_expand_flags() const
- {
- return do_use_expand_flags();
- }
+ std::tr1::shared_ptr<const UseFlagNameCollection> use_expand_flags() const;
/**
* Fetch all expand hidden flags.
*/
- std::tr1::shared_ptr<const UseFlagNameCollection> use_expand_hidden_prefixes() const
- {
- return do_use_expand_hidden_prefixes();
- }
+ std::tr1::shared_ptr<const UseFlagNameCollection> use_expand_hidden_prefixes() const;
/**
* Fetch all use expand prefixes.
*/
- std::tr1::shared_ptr<const UseFlagNameCollection> use_expand_prefixes() const
- {
- return do_use_expand_prefixes();
- }
+ std::tr1::shared_ptr<const UseFlagNameCollection> use_expand_prefixes() const;
/**
* Describe a use flag.
*/
std::string describe_use_flag(const UseFlagName & n,
- const PackageDatabaseEntry * const pkg) const
- {
- return do_describe_use_flag(n, pkg);
- }
+ const PackageDatabaseEntry & pkg) const;
///\}
diff --git a/python/repository.cc b/python/repository.cc
index e1a586b..4ec18c0 100644
--- a/python/repository.cc
+++ b/python/repository.cc
@@ -400,23 +400,23 @@ void PALUDIS_VISIBLE expose_repository()
bp::no_init
);
rusei.def("query_use", &RepositoryUseInterface::query_use,
- ("ufn", bp::arg("pde")=bp::object()),
- "query_use(UseFlagName, PackageDatabaseEntry=None) -> UseFlagState\n"
+ ("ufn", bp::arg("pde")),
+ "query_use(UseFlagName, PackageDatabaseEntry) -> UseFlagState\n"
"Query the state of the specified use flag."
);
rusei.def("query_use_mask", &RepositoryUseInterface::query_use_mask,
- ("ufn", bp::arg("pde")=bp::object()),
- "query_use_mask(UseFlagName, PackageDatabaseEntry=None) -> bool\n"
+ ("ufn", bp::arg("pde")),
+ "query_use_mask(UseFlagName, PackageDatabaseEntry) -> bool\n"
"Query whether the specified use flag is masked."
);
rusei.def("query_use_force", &RepositoryUseInterface::query_use_force,
- ("ufn", bp::arg("pde")=bp::object()),
- "query_use_force(UseFlagName, PackageDatabaseEntry=None) -> bool\n"
+ ("ufn", bp::arg("pde")),
+ "query_use_force(UseFlagName, PackageDatabaseEntry) -> bool\n"
"Query whether the specified use flag is forceed."
);
rusei.def("describe_use_flag", &RepositoryUseInterface::describe_use_flag,
- ("ufn", bp::arg("pde")=bp::object()),
- "describe_use_flag(UseFlagName, PackageDatabaseEntry=None) -> string\n"
+ ("ufn", bp::arg("pde")),
+ "describe_use_flag(UseFlagName, PackageDatabaseEntry) -> string\n"
"Describe a use flag."
);
diff --git a/python/repository_TEST.py b/python/repository_TEST.py
index 01c8573..87be830 100755
--- a/python/repository_TEST.py
+++ b/python/repository_TEST.py
@@ -195,14 +195,6 @@ class TestCase_Repository(unittest.TestCase):
self.assertEquals(ui.query_use("test6",p), UseFlagState.ENABLED)
self.assertEquals(ui.query_use("test7",p), UseFlagState.ENABLED)
- self.assert_(not ui.query_use_mask("test1"))
- self.assert_(not ui.query_use_mask("test2"))
- self.assert_(not ui.query_use_mask("test3"))
- self.assert_(ui.query_use_mask("test4"))
- self.assert_(not ui.query_use_mask("test5"))
- self.assert_(not ui.query_use_mask("test6"))
- self.assert_(not ui.query_use_mask("test7"))
-
self.assert_(not ui.query_use_mask("test1", p))
self.assert_(not ui.query_use_mask("test2", p))
self.assert_(not ui.query_use_mask("test3", p))
@@ -211,14 +203,6 @@ class TestCase_Repository(unittest.TestCase):
self.assert_(not ui.query_use_mask("test6", p))
self.assert_(not ui.query_use_mask("test7", p))
- self.assert_(not ui.query_use_force("test1"))
- self.assert_(not ui.query_use_force("test2"))
- self.assert_(not ui.query_use_force("test3"))
- self.assert_(not ui.query_use_force("test4"))
- self.assert_(not ui.query_use_force("test5"))
- self.assert_(ui.query_use_force("test6"))
- self.assert_(not ui.query_use_force("test7"))
-
self.assert_(not ui.query_use_force("test1", p))
self.assert_(not ui.query_use_force("test2", p))
self.assert_(not ui.query_use_force("test3", p))
@@ -227,7 +211,6 @@ class TestCase_Repository(unittest.TestCase):
self.assert_(ui.query_use_force("test6", p))
self.assert_(ui.query_use_force("test7", p))
- self.assert_(ui.describe_use_flag("test1"), "A test use flag")
self.assert_(ui.describe_use_flag("test1", p), "A test use flag")
def test_21_world_interface(self):
diff --git a/ruby/repository.cc b/ruby/repository.cc
index b15be6c..60171aa 100644
--- a/ruby/repository.cc
+++ b/ruby/repository.cc
@@ -621,9 +621,9 @@ namespace
* repository doesn't implement use_interface.
*/
- template <typename T_, T_ (RepositoryUseInterface::* m_) (const UseFlagName &, const PackageDatabaseEntry *) const> struct QueryUseMessage;
+ template <typename T_, T_ (RepositoryUseInterface::* m_) (const UseFlagName &, const PackageDatabaseEntry &) const> struct QueryUseMessage;
- template <typename T_, T_ trueval_, T_ falseval_, T_ (RepositoryUseInterface::* m_) (const UseFlagName &, const PackageDatabaseEntry *) const>
+ template <typename T_, T_ trueval_, T_ falseval_, T_ (RepositoryUseInterface::* m_) (const UseFlagName &, const PackageDatabaseEntry &) const>
struct QueryUse
{
static VALUE
@@ -637,19 +637,13 @@ namespace
if (use_interface)
{
- if (1 != argc && 2 != argc) {
+ if (2 != argc)
+ {
rb_raise(rb_eArgError, QueryUseMessage<T_, m_>::message, argc);
}
- T_ status;
-
- if (1 == argc)
- status = ((*use_interface).*m_)(UseFlagName(StringValuePtr(argv[0])), 0);
- else
- {
- PackageDatabaseEntry pde = value_to_package_database_entry(argv[1]);
- status = ((*use_interface).*m_)(UseFlagName(StringValuePtr(argv[0])), &pde);
- }
+ PackageDatabaseEntry pde = value_to_package_database_entry(argv[1]);
+ T_ status(((*use_interface).*m_)(UseFlagName(StringValuePtr(argv[0])), pde));
return status == trueval_ ? Qtrue : status == falseval_ ? Qfalse : Qnil;
}
@@ -670,21 +664,24 @@ namespace
{
static const char * message;
};
- const char * QueryUseMessage<UseFlagState, &RepositoryUseInterface::query_use>::message = "Repository.query_use expects one or two arguments, but got %d";
+ const char * QueryUseMessage<UseFlagState, &RepositoryUseInterface::query_use>::message =
+ "Repository.query_use expects two arguments, but got %d";
template<>
struct QueryUseMessage<bool, &RepositoryUseInterface::query_use_mask>
{
static const char * message;
};
- const char * QueryUseMessage<bool, &RepositoryUseInterface::query_use_mask>::message = "Repository.query_use_mask expects one or two arguments, but got %d";
+ const char * QueryUseMessage<bool, &RepositoryUseInterface::query_use_mask>::message =
+ "Repository.query_use_mask expects two arguments, but got %d";
template<>
struct QueryUseMessage<bool, &RepositoryUseInterface::query_use_force>
{
static const char * message;
};
- const char * QueryUseMessage<bool, &RepositoryUseInterface::query_use_force>::message = "Repository.query_use_force expects one or two arguments, but got %d";
+ const char * QueryUseMessage<bool, &RepositoryUseInterface::query_use_force>::message =
+ "Repository.query_use_force expects two arguments, but got %d";
/*
* Document-method: query_repository_masks
@@ -753,13 +750,7 @@ namespace
if (1 == argc || 2 ==argc)
{
UseFlagName ufn = UseFlagName(StringValuePtr(argv[0]));
- PackageDatabaseEntry * pde(0);
- if (2 == argc)
- {
- PackageDatabaseEntry pde2 = value_to_package_database_entry(argv[1]);
- pde = &pde2;
- }
-
+ PackageDatabaseEntry pde(value_to_package_database_entry(argv[1]));
return rb_str_new2(((*self_ptr)->use_interface->describe_use_flag(ufn, pde).c_str()));
}
diff --git a/ruby/repository_TEST.rb b/ruby/repository_TEST.rb
index e517d93..53e90ac 100644
--- a/ruby/repository_TEST.rb
+++ b/ruby/repository_TEST.rb
@@ -258,16 +258,6 @@ module Paludis
class TestCase_RepositoryQueryUse < Test::Unit::TestCase
include RepositoryTestCase
- def test_query_use_global
- assert repo.query_use('test1') == true
- assert repo.query_use('test2') == true
- assert repo.query_use('test3') == nil
- assert repo.query_use('test4') == false
- assert repo.query_use('test5') == nil
- assert repo.query_use('test6') == true
- assert repo.query_use('test7') == nil
- end
-
def test_query_use_local
p = PackageDatabaseEntry.new('foo/bar','2.0',repo.name)
@@ -282,9 +272,6 @@ module Paludis
def test_query_use_bad
assert_raise TypeError do
- repo.query_use(42)
- end
- assert_raise TypeError do
repo.query_use('test1',{})
end
@@ -298,16 +285,6 @@ module Paludis
class TestCase_RepositoryQueryUseMask < Test::Unit::TestCase
include RepositoryTestCase
- def test_query_use_mask_global
- assert ! repo.query_use_mask('test1')
- assert ! repo.query_use_mask('test2')
- assert ! repo.query_use_mask('test3')
- assert repo.query_use_mask('test4')
- assert ! repo.query_use_mask('test5')
- assert ! repo.query_use_mask('test6')
- assert ! repo.query_use_mask('test7')
- end
-
def test_query_use_mask_local
p = PackageDatabaseEntry.new('foo/bar','2.0',repo.name)
@@ -322,9 +299,6 @@ module Paludis
def test_query_use_mask_bad
assert_raise TypeError do
- repo.query_use_mask(42)
- end
- assert_raise TypeError do
repo.query_use_mask('test1',{})
end
@@ -338,16 +312,6 @@ module Paludis
class TestCase_RepositoryQueryUseForce < Test::Unit::TestCase
include RepositoryTestCase
- def test_query_use_force_global
- assert ! repo.query_use_force('test1')
- assert ! repo.query_use_force('test2')
- assert ! repo.query_use_force('test3')
- assert ! repo.query_use_force('test4')
- assert ! repo.query_use_force('test5')
- assert repo.query_use_force('test6')
- assert ! repo.query_use_force('test7')
- end
-
def test_query_use_force_local
p = PackageDatabaseEntry.new('foo/bar','2.0',repo.name)
@@ -362,9 +326,6 @@ module Paludis
def test_query_use_force_bad
assert_raise TypeError do
- repo.query_use_force(42)
- end
- assert_raise TypeError do
repo.query_use_force('test1',{})
end
@@ -544,11 +505,6 @@ module Paludis
assert_respond_to repo, :describe_use_flag
end
- def test_one_arg
- assert_kind_of String, repo.describe_use_flag('test1')
- assert_equal 'A test use flag', repo.describe_use_flag('test1')
- end
-
def test_two_args
pde = PackageDatabaseEntry.new('foo/bar','2.0','testrepo')
assert_kind_of String, repo.describe_use_flag('test1', pde)
diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc
index 633f659..9b061c1 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -915,7 +915,7 @@ ConsoleInstallTask::_add_descriptions(std::tr1::shared_ptr<const UseFlagNameColl
fetch_repository(p.repository)->use_interface);
if (i)
- d = i->describe_use_flag(*f, &p);
+ d = i->describe_use_flag(*f, p);
_all_use_descriptions->insert(UseDescription::create()
.flag(*f)
diff --git a/src/output/use_flag_pretty_printer.cc b/src/output/use_flag_pretty_printer.cc
index 65cc944..3dec23c 100644
--- a/src/output/use_flag_pretty_printer.cc
+++ b/src/output/use_flag_pretty_printer.cc
@@ -92,14 +92,14 @@ UseFlagPrettyPrinter::print_package_flags(const PackageDatabaseEntry & pkg,
if (environment()->query_use(*flag, pkg))
{
- if (use_interface && use_interface->query_use_force(*flag, &pkg))
+ if (use_interface && use_interface->query_use_force(*flag, pkg))
output_flag(render_as_forced_flag(stringify(*flag)));
else
output_flag(render_as_enabled_flag(stringify(*flag)));
}
else
{
- if (use_interface && use_interface->query_use_mask(*flag, &pkg))
+ if (use_interface && use_interface->query_use_mask(*flag, pkg))
output_flag(render_as_masked_flag(stringify(*flag)));
else
output_flag(render_as_disabled_flag(stringify(*flag)));
@@ -155,14 +155,14 @@ UseFlagPrettyPrinter::print_package_flags(const PackageDatabaseEntry & pkg,
if (environment()->query_use(*flag, pkg))
{
- if (use_interface && use_interface->query_use_force(*flag, &pkg))
+ if (use_interface && use_interface->query_use_force(*flag, pkg))
output_flag(render_as_forced_flag(stringify(expand_value)));
else
output_flag(render_as_enabled_flag(stringify(expand_value)));
}
else
{
- if (use_interface && use_interface->query_use_mask(*flag, &pkg))
+ if (use_interface && use_interface->query_use_mask(*flag, pkg))
output_flag(render_as_masked_flag(stringify(expand_value)));
else
output_flag(render_as_disabled_flag(stringify(expand_value)));