diff options
author | 2011-06-25 08:24:02 +0100 | |
---|---|---|
committer | 2011-06-25 09:02:24 +0100 | |
commit | 7547462975c726ad00c1e9006b0574c30967e01d (patch) | |
tree | 41658391325e47df6cd45a54d289f9d270084fdf | |
parent | 89128c990d4dd0e1625dc07123811e67486b43b1 (diff) | |
download | paludis-7547462975c726ad00c1e9006b0574c30967e01d.tar.gz paludis-7547462975c726ad00c1e9006b0574c30967e01d.tar.xz |
Allow choice descriptions to be loaded later
-rw-r--r-- | paludis/repositories/e/e_choices_key.cc | 26 | ||||
-rw-r--r-- | paludis/repositories/e/e_choices_key.hh | 7 | ||||
-rw-r--r-- | paludis/repositories/e/e_installed_repository_id.cc | 4 | ||||
-rw-r--r-- | paludis/repositories/e/ebuild_id.cc | 4 |
4 files changed, 22 insertions, 19 deletions
diff --git a/paludis/repositories/e/e_choices_key.cc b/paludis/repositories/e/e_choices_key.cc index 43c2b23a3..fb2aedec7 100644 --- a/paludis/repositories/e/e_choices_key.cc +++ b/paludis/repositories/e/e_choices_key.cc @@ -64,7 +64,7 @@ namespace paludis const Environment * const env; const std::shared_ptr<const ERepositoryID> id; const std::shared_ptr<const ERepository> maybe_e_repository; - const std::shared_ptr<const Map<ChoiceNameWithPrefix, std::string> > maybe_descriptions; + const std::function<std::shared_ptr<const Map<ChoiceNameWithPrefix, std::string> > ()> descriptions_function; const std::string raw_name; const std::string human_name; @@ -72,12 +72,12 @@ namespace paludis Imp(const Environment * const e, const std::shared_ptr<const ERepositoryID> & i, const std::shared_ptr<const ERepository> & p, - const std::shared_ptr<const Map<ChoiceNameWithPrefix, std::string> > & d, + const std::function<std::shared_ptr<const Map<ChoiceNameWithPrefix, std::string> > ()> & d, const std::string & r, const std::string & h, const MetadataKeyType t) : env(e), id(i), maybe_e_repository(p), - maybe_descriptions(d), + descriptions_function(d), raw_name(r), human_name(h), type(t) @@ -91,7 +91,7 @@ EChoicesKey::EChoicesKey( const std::shared_ptr<const ERepositoryID> & i, const std::string & r, const std::string & h, const MetadataKeyType t, const std::shared_ptr<const ERepository> & p, - const std::shared_ptr<const Map<ChoiceNameWithPrefix, std::string> > & d) : + const std::function<std::shared_ptr<const Map<ChoiceNameWithPrefix, std::string> > ()> & d) : _imp(e, i, p, d, r, h, t) { } @@ -261,6 +261,8 @@ EChoicesKey::parse_value() const if (_imp->value) return _imp->value; + auto descriptions(_imp->descriptions_function()); + Context context("When making Choices key for '" + stringify(*_imp->id) + "':"); _imp->value = std::make_shared<Choices>(); @@ -268,15 +270,15 @@ EChoicesKey::parse_value() const return _imp->value; if (_imp->id->raw_myoptions_key()) - populate_myoptions(); + populate_myoptions(descriptions); else - populate_iuse(); + populate_iuse(descriptions); return _imp->value; } void -EChoicesKey::populate_myoptions() const +EChoicesKey::populate_myoptions(const std::shared_ptr<const Map<ChoiceNameWithPrefix, std::string> > & d) const { Context local_context("When using raw_myoptions_key to populate choices:"); @@ -352,7 +354,7 @@ EChoicesKey::populate_myoptions() const } void -EChoicesKey::populate_iuse() const +EChoicesKey::populate_iuse(const std::shared_ptr<const Map<ChoiceNameWithPrefix, std::string> > & d) const { Context local_context("When using raw_iuse_key and raw_use_key to populate choices:"); @@ -436,7 +438,7 @@ EChoicesKey::populate_iuse() const { 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(_imp->maybe_descriptions, it->first), false)); + ! it->second.implicit(), get_maybe_description(d, it->first), false)); use->add(choice); } @@ -471,7 +473,7 @@ EChoicesKey::populate_iuse() const } else use->add(_imp->id->make_choice_value(use, UnprefixedChoiceName(stringify(flag.first)), flag.second, false, false, - get_maybe_description(_imp->maybe_descriptions, flag.first), false)); + get_maybe_description(d, flag.first), false)); } } } @@ -551,7 +553,7 @@ EChoicesKey::populate_iuse() const 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(), - get_maybe_description(_imp->maybe_descriptions, i->first), false)); + get_maybe_description(d, i->first), false)); else exp->add(_imp->id->make_choice_value(exp, *v, indeterminate, false, false, "", false)); } @@ -575,7 +577,7 @@ EChoicesKey::populate_iuse() const std::string name(_imp->id->eapi()->supported()->choices_options()->fancy_test_flag()); choice = _imp->id->make_choice_value( use, UnprefixedChoiceName(name), indeterminate, true, true, - get_maybe_description(_imp->maybe_descriptions, ChoiceNameWithPrefix(name)), false); + get_maybe_description(d, ChoiceNameWithPrefix(name)), false); use->add(choice); } } diff --git a/paludis/repositories/e/e_choices_key.hh b/paludis/repositories/e/e_choices_key.hh index 795e15268..2daf04789 100644 --- a/paludis/repositories/e/e_choices_key.hh +++ b/paludis/repositories/e/e_choices_key.hh @@ -24,6 +24,7 @@ #include <paludis/choice-fwd.hh> #include <paludis/repositories/e/e_choice_value.hh> #include <paludis/util/map-fwd.hh> +#include <functional> namespace paludis { @@ -39,8 +40,8 @@ namespace paludis private: Pimp<EChoicesKey> _imp; - void populate_iuse() const; - void populate_myoptions() const; + void populate_iuse(const std::shared_ptr<const Map<ChoiceNameWithPrefix, std::string> > &) const; + void populate_myoptions(const std::shared_ptr<const Map<ChoiceNameWithPrefix, std::string> > &) const; public: EChoicesKey( @@ -50,7 +51,7 @@ namespace paludis const std::string &, const MetadataKeyType, const std::shared_ptr<const ERepository> & maybe_profile, - const std::shared_ptr<const Map<ChoiceNameWithPrefix, std::string> > & maybe_descriptions); + const std::function<std::shared_ptr<const Map<ChoiceNameWithPrefix, std::string> > ()> & maybe_descriptions_fn); ~EChoicesKey(); diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc index 6248e3663..141ee8e12 100644 --- a/paludis/repositories/e/e_installed_repository_id.cc +++ b/paludis/repositories/e/e_installed_repository_id.cc @@ -518,10 +518,10 @@ EInstalledRepositoryID::need_keys_added() const if (_imp->eapi->supported()) _imp->keys->choices = std::make_shared<EChoicesKey>(_imp->environment, shared_from_this(), "PALUDIS_CHOICES", _imp->eapi->supported()->ebuild_environment_variables()->description_choices(), - mkt_normal, make_null_shared_ptr(), make_null_shared_ptr()); + mkt_normal, make_null_shared_ptr(), std::bind(return_literal_function(make_null_shared_ptr()))); else _imp->keys->choices = std::make_shared<EChoicesKey>(_imp->environment, shared_from_this(), "PALUDIS_CHOICES", "Choices", mkt_normal, - make_null_shared_ptr(), make_null_shared_ptr()); + make_null_shared_ptr(), std::bind(return_literal_function(make_null_shared_ptr()))); add_metadata_key(_imp->keys->choices); diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc index 9ef642514..551596a01 100644 --- a/paludis/repositories/e/ebuild_id.cc +++ b/paludis/repositories/e/ebuild_id.cc @@ -431,7 +431,7 @@ EbuildID::need_keys_added() const _imp->choices = std::make_shared<EChoicesKey>(_imp->environment, shared_from_this(), "PALUDIS_CHOICES", _imp->eapi->supported()->ebuild_environment_variables()->description_choices(), mkt_normal, e_repo, - maybe_use_descriptions); + std::bind(return_literal_function(maybe_use_descriptions))); if (_imp->eapi->supported()->is_pbin()) { @@ -441,7 +441,7 @@ EbuildID::need_keys_added() const } else _imp->choices = std::make_shared<EChoicesKey>(_imp->environment, shared_from_this(), "PALUDIS_CHOICES", "Choices", mkt_normal, - e_repo, maybe_use_descriptions); + e_repo, std::bind(return_literal_function(maybe_use_descriptions))); add_metadata_key(_imp->choices); } |