Better tracking of choice origins
This commit is contained in:
parent
a5a402331f
commit
690f227d9e
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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.
|
||||
|
21
paludis/choice.se
Normal file
21
paludis/choice.se
Normal file
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
|
@ -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());;
|
||||
|
@ -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')
|
||||
|
@ -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())
|
||||
;
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
));
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
));
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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))
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
{
|
||||
/*
|
||||
@ -362,6 +368,18 @@ namespace
|
||||
rb_define_method(c_choice, "each", RUBY_FUNC_CAST(&choice_each), 0);
|
||||
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
|
||||
*
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user