aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-08-06 22:29:05 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-08-06 22:29:05 +0100
commit690f227d9efcbd1bf4e232591faf8b3885fc3b76 (patch)
treee8eef637815980649516ef49083e26d4fb48bb28
parenta5a402331f246c81bdd14dea34639ec2f916928c (diff)
downloadpaludis-690f227d9efcbd1bf4e232591faf8b3885fc3b76.tar.gz
paludis-690f227d9efcbd1bf4e232591faf8b3885fc3b76.tar.xz
Better tracking of choice origins
-rw-r--r--paludis/choice-fwd.hh5
-rw-r--r--paludis/choice.cc2
-rw-r--r--paludis/choice.hh6
-rw-r--r--paludis/choice.se21
-rw-r--r--paludis/elike_choices.cc42
-rw-r--r--paludis/elike_choices.hh14
-rw-r--r--paludis/elike_use_requirement.cc2
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/repositories/e/e_choice_value.cc14
-rw-r--r--paludis/repositories/e/e_choice_value.hh4
-rw-r--r--paludis/repositories/e/e_choices_key.cc22
-rw-r--r--paludis/repositories/e/e_installed_repository_id.cc4
-rw-r--r--paludis/repositories/e/e_installed_repository_id.hh2
-rw-r--r--paludis/repositories/e/e_repository_id.hh2
-rw-r--r--paludis/repositories/e/ebuild_id.cc4
-rw-r--r--paludis/repositories/e/ebuild_id.hh2
-rw-r--r--paludis/repositories/fake/fake_package_id.cc4
-rw-r--r--paludis/resolver/get_sameness.cc4
-rw-r--r--python/choices.cc9
-rw-r--r--python/choices_TEST.py4
-rw-r--r--ruby/choice.cc45
-rw-r--r--ruby/choice_TEST.rb8
-rwxr-xr-xsrc/clients/cave/cmd_display_resolution.cc2
-rw-r--r--src/clients/cave/cmd_show.cc22
24 files changed, 147 insertions, 99 deletions
diff --git a/paludis/choice-fwd.hh b/paludis/choice-fwd.hh
index 120a9c0..01b702a 100644
--- a/paludis/choice-fwd.hh
+++ b/paludis/choice-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2009, 2010 Ciaran McCreesh
+ * Copyright (c) 2008, 2009, 2010, 2011 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -22,6 +22,7 @@
#include <paludis/util/attributes.hh>
#include <paludis/util/wrapped_value-fwd.hh>
+#include <iosfwd>
/** \file
* Forward declarations for paludis/choice.hh .
@@ -70,6 +71,8 @@ namespace paludis
* \since 0.32
*/
typedef WrappedValue<UnprefixedChoiceNameTag> UnprefixedChoiceName;
+
+#include <paludis/choice-se.hh>
}
#endif
diff --git a/paludis/choice.cc b/paludis/choice.cc
index 79ce1ea..3c7b4fb 100644
--- a/paludis/choice.cc
+++ b/paludis/choice.cc
@@ -29,6 +29,8 @@
using namespace paludis;
+#include <paludis/choice-se.cc>
+
typedef std::list<std::shared_ptr<const Choice> > ChoicesList;
typedef std::list<std::shared_ptr<const ChoiceValue> > ChoiceList;
diff --git a/paludis/choice.hh b/paludis/choice.hh
index ae1622f..7090b1d 100644
--- a/paludis/choice.hh
+++ b/paludis/choice.hh
@@ -358,12 +358,14 @@ namespace paludis
virtual const std::string description() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
- * Is this flag explicitly listed?
+ * The origin of this choice.
+ *
+ * \since 0.66
*
* Use this to avoid showing things like LINGUAS values that aren't listed
* in IUSE but that end up as a ChoiceValue anyway.
*/
- virtual bool explicitly_listed() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ virtual ChoiceOrigin origin() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
* This flag's parameter, or an empty string if it doesn't have one.
diff --git a/paludis/choice.se b/paludis/choice.se
new file mode 100644
index 0000000..28b359b
--- /dev/null
+++ b/paludis/choice.se
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+# vim: set sw=4 sts=4 et ft=sh :
+
+make_enum_ChoiceOrigin()
+{
+ prefix co
+
+ key co_explicit "An explicitly listed (e.g. IUSE) choice"
+ key co_implicit "An implicit (e.g. unlisted LINGUAS) choice"
+ key co_special "A special (e.g. build_options) choice"
+
+ doxygen_comment << "END"
+ /**
+ * Whether a choice is implicit, explicit or special.
+ *
+ * \see Choice
+ * \ingroup g_choices
+ */
+END
+}
+
diff --git a/paludis/elike_choices.cc b/paludis/elike_choices.cc
index 0425bf7..d659f27 100644
--- a/paludis/elike_choices.cc
+++ b/paludis/elike_choices.cc
@@ -135,10 +135,10 @@ ELikeOptionalTestsChoiceValue::description() const
return "Run tests considered by the package to be optional";
}
-bool
-ELikeOptionalTestsChoiceValue::explicitly_listed() const
+ChoiceOrigin
+ELikeOptionalTestsChoiceValue::origin() const
{
- return true;
+ return co_special;
}
const std::string
@@ -209,10 +209,10 @@ ELikeRecommendedTestsChoiceValue::description() const
return "Run tests considered by the package to be recommended";
}
-bool
-ELikeRecommendedTestsChoiceValue::explicitly_listed() const
+ChoiceOrigin
+ELikeRecommendedTestsChoiceValue::origin() const
{
- return true;
+ return co_special;
}
const std::string
@@ -301,10 +301,10 @@ ELikeExpensiveTestsChoiceValue::description() const
return "Run tests considered by the package to be useful, but expensive";
}
-bool
-ELikeExpensiveTestsChoiceValue::explicitly_listed() const
+ChoiceOrigin
+ELikeExpensiveTestsChoiceValue::origin() const
{
- return true;
+ return co_special;
}
const std::string
@@ -396,10 +396,10 @@ ELikeJobsChoiceValue::description() const
return "How many jobs the package's build system should use, where supported";
}
-bool
-ELikeJobsChoiceValue::explicitly_listed() const
+ChoiceOrigin
+ELikeJobsChoiceValue::origin() const
{
- return true;
+ return co_special;
}
const std::string
@@ -469,10 +469,10 @@ ELikeTraceChoiceValue::description() const
return "Trace actions executed by the package (very noisy, for debugging broken builds only)";
}
-bool
-ELikeTraceChoiceValue::explicitly_listed() const
+ChoiceOrigin
+ELikeTraceChoiceValue::origin() const
{
- return true;
+ return co_special;
}
const std::string
@@ -545,10 +545,10 @@ ELikePreserveWorkChoiceValue::description() const
return "Do not remove build directories, and do not modify the image when merging";
}
-bool
-ELikePreserveWorkChoiceValue::explicitly_listed() const
+ChoiceOrigin
+ELikePreserveWorkChoiceValue::origin() const
{
- return true;
+ return co_special;
}
const std::string
@@ -628,10 +628,10 @@ ELikeSymbolsChoiceValue::description() const
return "How to handle debug symbols in installed files";
}
-bool
-ELikeSymbolsChoiceValue::explicitly_listed() const
+ChoiceOrigin
+ELikeSymbolsChoiceValue::origin() const
{
- return true;
+ return co_special;
}
const std::string
diff --git a/paludis/elike_choices.hh b/paludis/elike_choices.hh
index ac07b97..e994597 100644
--- a/paludis/elike_choices.hh
+++ b/paludis/elike_choices.hh
@@ -47,7 +47,7 @@ namespace paludis
virtual bool enabled_by_default() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual bool locked() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::string description() const PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool explicitly_listed() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual ChoiceOrigin origin() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::string parameter() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::shared_ptr<const PermittedChoiceValueParameterValues> permitted_parameter_values() const
PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -74,7 +74,7 @@ namespace paludis
virtual bool enabled_by_default() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual bool locked() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::string description() const PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool explicitly_listed() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual ChoiceOrigin origin() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::string parameter() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::shared_ptr<const PermittedChoiceValueParameterValues> permitted_parameter_values() const
PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -101,7 +101,7 @@ namespace paludis
virtual bool enabled_by_default() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual bool locked() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::string description() const PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool explicitly_listed() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual ChoiceOrigin origin() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::string parameter() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::shared_ptr<const PermittedChoiceValueParameterValues> permitted_parameter_values() const
PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -127,7 +127,7 @@ namespace paludis
virtual bool enabled_by_default() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual bool locked() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::string description() const PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool explicitly_listed() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual ChoiceOrigin origin() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::string parameter() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::shared_ptr<const PermittedChoiceValueParameterValues> permitted_parameter_values() const
PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -152,7 +152,7 @@ namespace paludis
virtual bool enabled_by_default() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual bool locked() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::string description() const PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool explicitly_listed() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual ChoiceOrigin origin() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::string parameter() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::shared_ptr<const PermittedChoiceValueParameterValues> permitted_parameter_values() const
PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -184,7 +184,7 @@ namespace paludis
virtual bool enabled_by_default() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual bool locked() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::string description() const PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool explicitly_listed() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual ChoiceOrigin origin() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::string parameter() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::shared_ptr<const PermittedChoiceValueParameterValues> permitted_parameter_values() const
PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -211,7 +211,7 @@ namespace paludis
virtual bool enabled_by_default() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual bool locked() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::string description() const PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool explicitly_listed() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual ChoiceOrigin origin() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::string parameter() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::shared_ptr<const PermittedChoiceValueParameterValues> permitted_parameter_values() const
PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/paludis/elike_use_requirement.cc b/paludis/elike_use_requirement.cc
index 82b242e..af891f4 100644
--- a/paludis/elike_use_requirement.cc
+++ b/paludis/elike_use_requirement.cc
@@ -269,7 +269,7 @@ namespace
return false;
}
- if (v->locked() || ! v->explicitly_listed())
+ if (v->locked() || co_explicit != v->origin())
return false;
return changed_choices.add_override_if_possible(flag, ! v->enabled());;
diff --git a/paludis/files.m4 b/paludis/files.m4
index d7b398f..22052c8 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -19,7 +19,7 @@ add(`broken_linkage_finder', `hh', `cc')
add(`buffer_output_manager', `hh', `cc', `fwd')
add(`call_pretty_printer', `hh', `cc', `fwd')
add(`changed_choices', `hh', `cc', `fwd')
-add(`choice', `hh', `cc', `fwd')
+add(`choice', `hh', `cc', `se', `fwd')
add(`comma_separated_dep_parser', `hh', `cc', `gtest')
add(`comma_separated_dep_pretty_printer', `hh', `cc', `fwd')
add(`command_output_manager', `hh', `cc', `fwd')
diff --git a/paludis/repositories/e/e_choice_value.cc b/paludis/repositories/e/e_choice_value.cc
index 1ea1f50..4e67916 100644
--- a/paludis/repositories/e/e_choice_value.cc
+++ b/paludis/repositories/e/e_choice_value.cc
@@ -44,7 +44,7 @@ namespace
bool enabled_by_default() const;
bool locked() const;
const std::string description() const;
- bool explicitly_listed() const;
+ ChoiceOrigin origin() const;
const std::string parameter() const PALUDIS_ATTRIBUTE((warn_unused_result));
const std::shared_ptr<const PermittedChoiceValueParameterValues> permitted_parameter_values() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
@@ -91,10 +91,10 @@ EChoiceValue::locked() const
return _params.locked();
}
-bool
-EChoiceValue::explicitly_listed() const
+ChoiceOrigin
+EChoiceValue::origin() const
{
- return _params.explicitly_listed();
+ return _params.origin();
}
const std::string
@@ -119,7 +119,7 @@ namespace paludis
Hash<std::string> description_hash;
Hash<bool> enabled_hash;
Hash<bool> enabled_by_default_hash;
- Hash<bool> explicitly_listed_hash;
+ Hash<bool> origin_hash;
Hash<bool> locked_hash;
Hash<UnprefixedChoiceName> unprefixed_choice_name_hash;
@@ -131,7 +131,7 @@ namespace paludis
^ description_hash(p.description())
^ enabled_hash(p.enabled())
^ enabled_by_default_hash(p.enabled_by_default())
- ^ explicitly_listed_hash(p.explicitly_listed())
+ ^ origin_hash(p.origin())
^ locked_hash(p.locked())
^ unprefixed_choice_name_hash(p.unprefixed_choice_name())
;
@@ -146,7 +146,7 @@ namespace paludis
&& (a.description() == b.description())
&& (a.enabled() == b.enabled())
&& (a.enabled_by_default() == b.enabled_by_default())
- && (a.explicitly_listed() == b.explicitly_listed())
+ && (a.origin() == b.origin())
&& (a.locked() == b.locked())
&& (a.unprefixed_choice_name() == b.unprefixed_choice_name())
;
diff --git a/paludis/repositories/e/e_choice_value.hh b/paludis/repositories/e/e_choice_value.hh
index 7b33e63..9480ee4 100644
--- a/paludis/repositories/e/e_choice_value.hh
+++ b/paludis/repositories/e/e_choice_value.hh
@@ -36,8 +36,8 @@ namespace paludis
typedef Name<struct name_description> description;
typedef Name<struct name_enabled> enabled;
typedef Name<struct name_enabled_by_default> enabled_by_default;
- typedef Name<struct name_explicitly_listed> explicitly_listed;
typedef Name<struct name_locked> locked;
+ typedef Name<struct name_origin> origin;
typedef Name<struct name_unprefixed_choice_name> unprefixed_choice_name;
}
@@ -50,8 +50,8 @@ namespace paludis
NamedValue<n::description, std::string> description;
NamedValue<n::enabled, bool> enabled;
NamedValue<n::enabled_by_default, bool> enabled_by_default;
- NamedValue<n::explicitly_listed, bool> explicitly_listed;
NamedValue<n::locked, bool> locked;
+ NamedValue<n::origin, ChoiceOrigin> origin;
NamedValue<n::unprefixed_choice_name, UnprefixedChoiceName> unprefixed_choice_name;
};
diff --git a/paludis/repositories/e/e_choices_key.cc b/paludis/repositories/e/e_choices_key.cc
index 64cedf1..54c70ff 100644
--- a/paludis/repositories/e/e_choices_key.cc
+++ b/paludis/repositories/e/e_choices_key.cc
@@ -191,9 +191,9 @@ namespace
const UnprefixedChoiceName & unprefixed,
const std::string & description,
const Tribool s,
- const bool b)
+ const ChoiceOrigin o)
{
- return id->make_choice_value(choice, unprefixed, s, false, b, description, false);
+ return id->make_choice_value(choice, unprefixed, s, false, o, description, false);
}
std::string get_maybe_description(const std::shared_ptr<const Map<ChoiceNameWithPrefix, std::string> > & m,
@@ -328,7 +328,7 @@ EChoicesKey::populate_myoptions() const
{
for (MyOptionsFinder::Descriptions::const_iterator v(p->second.begin()), v_end(p->second.end()) ;
v != v_end ; ++v)
- exp->add(make_myoption(_imp->id, exp, v->first, v->second, indeterminate, true));
+ exp->add(make_myoption(_imp->id, exp, v->first, v->second, indeterminate, co_explicit));
myoptions.prefixes.erase(p);
}
}
@@ -340,7 +340,7 @@ EChoicesKey::populate_myoptions() const
Context local_local_context("When using empty prefix to populate choices:");
for (MyOptionsFinder::Descriptions::const_iterator v(p->second.begin()), v_end(p->second.end()) ;
v != v_end ; ++v)
- options->add(make_myoption(_imp->id, options, v->first, v->second, indeterminate, true));
+ options->add(make_myoption(_imp->id, options, v->first, v->second, indeterminate, co_explicit));
myoptions.prefixes.erase(p);
}
@@ -439,7 +439,7 @@ EChoicesKey::populate_iuse(const std::shared_ptr<const Map<ChoiceNameWithPrefix,
{
std::shared_ptr<const ChoiceValue> choice(_imp->id->make_choice_value(
use, UnprefixedChoiceName(stringify(it->first)), it->second.default_value(), false,
- ! it->second.implicit(), get_maybe_description(d, it->first), false));
+ it->second.implicit() ? co_implicit : co_explicit, get_maybe_description(d, it->first), false));
use->add(choice);
}
@@ -473,7 +473,7 @@ EChoicesKey::populate_iuse(const std::shared_ptr<const Map<ChoiceNameWithPrefix,
/* don't need to worry */
}
else
- use->add(_imp->id->make_choice_value(use, UnprefixedChoiceName(stringify(flag.first)), flag.second, false, false,
+ use->add(_imp->id->make_choice_value(use, UnprefixedChoiceName(stringify(flag.first)), flag.second, false, co_implicit,
get_maybe_description(d, flag.first), false));
}
}
@@ -495,7 +495,7 @@ EChoicesKey::populate_iuse(const std::shared_ptr<const Map<ChoiceNameWithPrefix,
for (Set<UnprefixedChoiceName>::ConstIterator a(_imp->maybe_e_repository->arch_flags()->begin()), a_end(_imp->maybe_e_repository->arch_flags()->end()) ;
a != a_end ; ++a)
- arch->add(_imp->id->make_choice_value(arch, *a, indeterminate, false, false, "", false));
+ arch->add(_imp->id->make_choice_value(arch, *a, indeterminate, false, co_implicit, "", false));
}
if (_imp->id->raw_use_expand_key())
@@ -553,10 +553,10 @@ EChoicesKey::populate_iuse(const std::shared_ptr<const Map<ChoiceNameWithPrefix,
{
std::map<ChoiceNameWithPrefix, ChoiceOptions>::const_iterator i(i_values.find(ChoiceNameWithPrefix(lower_u + delim + stringify(*v))));
if (i_values.end() != i)
- exp->add(_imp->id->make_choice_value(exp, *v, i->second.default_value(), false, ! i->second.implicit(),
+ exp->add(_imp->id->make_choice_value(exp, *v, i->second.default_value(), false, i->second.implicit() ? co_implicit : co_explicit,
get_maybe_description(d, i->first), false));
else
- exp->add(_imp->id->make_choice_value(exp, *v, indeterminate, false, false, "", false));
+ exp->add(_imp->id->make_choice_value(exp, *v, indeterminate, false, co_implicit, "", false));
}
}
}
@@ -572,12 +572,12 @@ EChoicesKey::populate_iuse(const std::shared_ptr<const Map<ChoiceNameWithPrefix,
choice = _imp->value->find_by_name_with_prefix(ELikeOptionalTestsChoiceValue::canonical_name_with_prefix());
if (choice)
use->add(_imp->id->make_choice_value(use, UnprefixedChoiceName(_imp->id->eapi()->supported()->choices_options()->fancy_test_flag()),
- choice->enabled(), true, true, "", true));
+ choice->enabled(), true, co_explicit, "", true));
else
{
std::string name(_imp->id->eapi()->supported()->choices_options()->fancy_test_flag());
choice = _imp->id->make_choice_value(
- use, UnprefixedChoiceName(name), indeterminate, true, true,
+ use, UnprefixedChoiceName(name), indeterminate, true, co_explicit,
get_maybe_description(d, ChoiceNameWithPrefix(name)), false);
use->add(choice);
}
diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc
index 141ee8e..62fb0de 100644
--- a/paludis/repositories/e/e_installed_repository_id.cc
+++ b/paludis/repositories/e/e_installed_repository_id.cc
@@ -1032,7 +1032,7 @@ EInstalledRepositoryID::slot_key() const
const std::shared_ptr<const ChoiceValue>
EInstalledRepositoryID::make_choice_value(const std::shared_ptr<const Choice> & c, const UnprefixedChoiceName & v,
- const Tribool, const bool, const bool explicitly_listed, const std::string & override_description, const bool) const
+ const Tribool, const bool, const ChoiceOrigin origin, const std::string & override_description, const bool) const
{
if (! eapi()->supported())
throw InternalError(PALUDIS_HERE, "Unsupported EAPI");
@@ -1061,8 +1061,8 @@ EInstalledRepositoryID::make_choice_value(const std::shared_ptr<const Choice> &
n::description() = override_description,
n::enabled() = enabled,
n::enabled_by_default() = enabled,
- n::explicitly_listed() = explicitly_listed,
n::locked() = true,
+ n::origin() = origin,
n::unprefixed_choice_name() = v
));
}
diff --git a/paludis/repositories/e/e_installed_repository_id.hh b/paludis/repositories/e/e_installed_repository_id.hh
index ab0fd99..b4b091d 100644
--- a/paludis/repositories/e/e_installed_repository_id.hh
+++ b/paludis/repositories/e/e_installed_repository_id.hh
@@ -104,7 +104,7 @@ namespace paludis
virtual const std::shared_ptr<const ChoiceValue> make_choice_value(
const std::shared_ptr<const Choice> &, const UnprefixedChoiceName &, const Tribool,
- const bool, const bool, const std::string &, const bool) const;
+ const bool, const ChoiceOrigin, const std::string &, const bool) const;
virtual void add_build_options(const std::shared_ptr<Choices> &) const;
diff --git a/paludis/repositories/e/e_repository_id.hh b/paludis/repositories/e/e_repository_id.hh
index 43c0f41..9bdaed3 100644
--- a/paludis/repositories/e/e_repository_id.hh
+++ b/paludis/repositories/e/e_repository_id.hh
@@ -61,7 +61,7 @@ namespace paludis
virtual const std::shared_ptr<const ChoiceValue> make_choice_value(
const std::shared_ptr<const Choice> &, const UnprefixedChoiceName &, const Tribool,
- const bool, const bool, const std::string &, const bool)
+ const bool, const ChoiceOrigin, const std::string &, const bool)
const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
virtual void add_build_options(const std::shared_ptr<Choices> &) const = 0;
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index f6d1c6a..15eb875 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -1441,7 +1441,7 @@ EbuildID::make_choice_value(
const UnprefixedChoiceName & value_name,
const Tribool iuse_default,
const bool iuse_default_wins,
- const bool explicitly_listed,
+ const ChoiceOrigin origin,
const std::string & override_description,
const bool force_locked
) const
@@ -1521,8 +1521,8 @@ EbuildID::make_choice_value(
n::description() = get_description(e_repo->use_desc(), override_description, name(), choice->prefix(), value_name),
n::enabled() = enabled,
n::enabled_by_default() = enabled_by_default,
- n::explicitly_listed() = explicitly_listed,
n::locked() = force_locked || locked,
+ n::origin() = origin,
n::unprefixed_choice_name() = value_name
));
}
diff --git a/paludis/repositories/e/ebuild_id.hh b/paludis/repositories/e/ebuild_id.hh
index 2b4589c..db04dab 100644
--- a/paludis/repositories/e/ebuild_id.hh
+++ b/paludis/repositories/e/ebuild_id.hh
@@ -161,7 +161,7 @@ namespace paludis
virtual const std::shared_ptr<const ChoiceValue> make_choice_value(
const std::shared_ptr<const Choice> &, const UnprefixedChoiceName &, const Tribool,
- const bool, const bool, const std::string &, const bool) const;
+ const bool, const ChoiceOrigin, const std::string &, const bool) const;
virtual void add_build_options(const std::shared_ptr<Choices> &) const;
diff --git a/paludis/repositories/fake/fake_package_id.cc b/paludis/repositories/fake/fake_package_id.cc
index a63ddf0..068fae7 100644
--- a/paludis/repositories/fake/fake_package_id.cc
+++ b/paludis/repositories/fake/fake_package_id.cc
@@ -457,9 +457,9 @@ namespace
return "monkey";
}
- virtual bool explicitly_listed() const
+ virtual ChoiceOrigin origin() const
{
- return true;
+ return co_explicit;
}
virtual const std::string parameter() const PALUDIS_ATTRIBUTE((warn_unused_result))
diff --git a/paludis/resolver/get_sameness.cc b/paludis/resolver/get_sameness.cc
index 64c7d63..a993df4 100644
--- a/paludis/resolver/get_sameness.cc
+++ b/paludis/resolver/get_sameness.cc
@@ -160,7 +160,7 @@ paludis::resolver::get_sameness(
for (Choice::ConstIterator i((*k)->begin()), i_end((*k)->end()) ;
i != i_end ; ++i)
- if ((*i)->explicitly_listed())
+ if (co_explicit == (*i)->origin())
i_common.insert((*i)->name_with_prefix());
}
@@ -172,7 +172,7 @@ paludis::resolver::get_sameness(
for (Choice::ConstIterator i((*k)->begin()), i_end((*k)->end()) ;
i != i_end ; ++i)
- if ((*i)->explicitly_listed())
+ if (co_explicit == (*i)->origin())
u_common.insert((*i)->name_with_prefix());
}
diff --git a/python/choices.cc b/python/choices.cc
index 5cda2bb..18287ef 100644
--- a/python/choices.cc
+++ b/python/choices.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2010 Ciaran McCreesh
+ * Copyright (c) 2008, 2010, 2011 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -121,8 +121,8 @@ void expose_choices()
"[ro] String\n"
)
- .add_property("explicitly_listed", &ChoiceValue::explicitly_listed,
- "[ro] bool\n"
+ .add_property("origin", &ChoiceValue::origin,
+ "[ro] ChoiceOrigin\n"
)
;
@@ -159,5 +159,8 @@ void expose_choices()
"UnprefixedChoiceName",
"A choice name, without prefix."
);
+
+ enum_auto("ChoiceOrigin", last_co,
+ "The origin of a ChoiceValue");
}
diff --git a/python/choices_TEST.py b/python/choices_TEST.py
index e22b0a5..161cbef 100644
--- a/python/choices_TEST.py
+++ b/python/choices_TEST.py
@@ -122,7 +122,7 @@ class TestCase_03_ChoiceValue(unittest.TestCase):
self.assertEquals(self.use_testflag.enabled_by_default, False)
self.assertEquals(self.use_testflag.locked, False)
self.assertEquals(self.use_testflag.description, "the test flag")
- self.assertEquals(self.use_testflag.explicitly_listed, True)
+ self.assertEquals(self.use_testflag.origin, ChoiceOrigin.EXPLICIT)
def test_02_linguas_en(self):
self.assert_(self.linguas_en)
@@ -132,7 +132,7 @@ class TestCase_03_ChoiceValue(unittest.TestCase):
self.assertEquals(self.linguas_en.enabled_by_default, False)
self.assertEquals(self.linguas_en.locked, False)
self.assertEquals(self.linguas_en.description, "English")
- self.assertEquals(self.linguas_en.explicitly_listed, True)
+ self.assertEquals(self.linguas_en.origin, ChoiceOrigin.EXPLICIT)
if __name__ == "__main__":
unittest.main()
diff --git a/ruby/choice.cc b/ruby/choice.cc
index be9209c..5d91379 100644
--- a/ruby/choice.cc
+++ b/ruby/choice.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2008, 2009, 2011 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -30,6 +30,7 @@ namespace
static VALUE c_choice;
static VALUE c_choices;
static VALUE c_choice_value;
+ static VALUE c_choice_origin;
/*
* call-seq:
@@ -296,17 +297,6 @@ namespace
*/
FAKE_RDOC_METHOD(choice_value_locked)
- /*
- * call-seq:
- * explicitly_listed? -> true or false
- *
- * Is this flag explicitly listed?
- *
- * Use this to avoid showing things like LINGUAS values that aren't listed
- * in IUSE but that end up as a ChoiceValue anyway.
- */
- FAKE_RDOC_METHOD(choice_value_explicitly_listed)
-
template <typename R_, R_ (ChoiceValue::* r_) () const>
struct ChoiceValueBoolishMembers
{
@@ -324,6 +314,22 @@ namespace
}
};
+ /*
+ * call-seq:
+ * origin? -> ChoiceOrigin
+ *
+ * Is this flag explicitly listed?
+ *
+ * Use this to avoid showing things like LINGUAS values that aren't listed
+ * in IUSE but that end up as a ChoiceValue anyway.
+ */
+ VALUE
+ choice_value_origin(VALUE self_v)
+ {
+ std::shared_ptr<const ChoiceValue> self(value_to_choice_value(self_v));
+ return INT2FIX(self->origin());
+ }
+
void do_register_choice()
{
/*
@@ -363,6 +369,18 @@ namespace
rb_include_module(c_choice, rb_mEnumerable);
/*
+ * Document-module: Paludis::ChoiceOrigin
+ *
+ * The origin of a Choice
+ */
+ c_choice_origin = rb_define_module_under(paludis_module(), "ChoiceOrigin");
+ for (ChoiceOrigin l(static_cast<ChoiceOrigin>(0)), l_end(last_co) ; l != l_end ;
+ l = static_cast<ChoiceOrigin>(static_cast<int>(l) + 1))
+ rb_define_const(c_choice_origin, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
+
+ // cc_enum_special<paludis/choice.hh, ChoiceOrigin, c_choice_origin>
+
+ /*
* Document-class: Paludis::ChoiceValue
*
* A single ChoiceValue object for a Choice.
@@ -381,8 +399,7 @@ namespace
(&ChoiceValueBoolishMembers<bool, &ChoiceValue::locked>::fetch)), 0);
rb_define_method(c_choice_value, "description", RDOC_IS_STUPID(choice_value_description,
(&ChoiceValueStringishMembers<std::string, &ChoiceValue::description>::fetch)), 0);
- rb_define_method(c_choice_value, "explicitly_listed?", RDOC_IS_STUPID(choice_value_explicitly_listed,
- (&ChoiceValueBoolishMembers<bool, &ChoiceValue::explicitly_listed>::fetch)), 0);
+ rb_define_method(c_choice_value, "origin", RUBY_FUNC_CAST(&choice_value_origin), 0);
}
}
diff --git a/ruby/choice_TEST.rb b/ruby/choice_TEST.rb
index 782f367..886275a 100644
--- a/ruby/choice_TEST.rb
+++ b/ruby/choice_TEST.rb
@@ -194,10 +194,10 @@ module Paludis
assert_equal "", linguas_en.description
end
- def test_explicitly_listed
- assert use_flag1.explicitly_listed?
- assert use_flag2.explicitly_listed?
- assert linguas_en.explicitly_listed?
+ def test_choice_origin
+ assert_equal ChoiceOrigin::Explicit, use_flag1.origin
+ assert_equal ChoiceOrigin::Explicit, use_flag2.origin
+ assert_equal ChoiceOrigin::Explicit, linguas_en.origin
end
end
end
diff --git a/src/clients/cave/cmd_display_resolution.cc b/src/clients/cave/cmd_display_resolution.cc
index 2d8e51f..21f972f 100755
--- a/src/clients/cave/cmd_display_resolution.cc
+++ b/src/clients/cave/cmd_display_resolution.cc
@@ -574,7 +574,7 @@ namespace
for (Choice::ConstIterator i((*k)->begin()), i_end((*k)->end()) ;
i != i_end ; ++i)
{
- if (! (*i)->explicitly_listed())
+ if (co_implicit == (*i)->origin())
continue;
Tribool changed_state(indeterminate);
diff --git a/src/clients/cave/cmd_show.cc b/src/clients/cave/cmd_show.cc
index 7cdd054..22a2368 100644
--- a/src/clients/cave/cmd_show.cc
+++ b/src/clients/cave/cmd_show.cc
@@ -350,7 +350,7 @@ namespace
if (maybe_old_value->enabled() != value->enabled())
return "*";
}
- else if (maybe_old_id && value->explicitly_listed() && choice->consider_added_or_changed())
+ else if (maybe_old_id && co_explicit == value->origin() && choice->consider_added_or_changed())
{
if (old_id_is_installed)
return "+";
@@ -797,16 +797,16 @@ namespace
if ((*c)->begin() == (*c)->end())
continue;
- bool any_explicit(false);
+ bool any_explicitish(false);
for (Choice::ConstIterator v((*c)->begin()), v_end((*c)->end()) ;
v != v_end ; ++v)
- if ((*v)->explicitly_listed())
+ if (co_implicit != (*v)->origin())
{
- any_explicit = true;
+ any_explicitish = true;
break;
}
- if (! any_explicit)
+ if (! any_explicitish)
continue;
}
@@ -820,7 +820,7 @@ namespace
v != v_end ; ++v)
{
if (! cmdline.a_internal_keys.specified())
- if (! (*v)->explicitly_listed())
+ if (co_implicit == (*v)->origin())
continue;
if ((*v)->enabled())
@@ -878,16 +878,16 @@ namespace
if ((*c)->begin() == (*c)->end())
continue;
- bool any_explicit(false);
+ bool any_explicitish(false);
for (Choice::ConstIterator v((*c)->begin()), v_end((*c)->end()) ;
v != v_end ; ++v)
- if ((*v)->explicitly_listed())
+ if (co_implicit != (*v)->origin())
{
- any_explicit = true;
+ any_explicitish = true;
break;
}
- if (! any_explicit)
+ if (! any_explicitish)
continue;
}
@@ -904,7 +904,7 @@ namespace
v != v_end ; ++v)
{
if (! cmdline.a_internal_keys.specified())
- if (! (*v)->explicitly_listed())
+ if (co_implicit == (*v)->origin())
continue;
if ((*v)->enabled())