diff options
-rw-r--r-- | paludis/repositories/e/Makefile.am | 4 | ||||
-rw-r--r-- | paludis/repositories/e/dep_parser.cc | 67 | ||||
-rw-r--r-- | paludis/repositories/e/parse_annotations.cc (renamed from paludis/repositories/e/apply_annotations.cc) | 10 | ||||
-rw-r--r-- | paludis/repositories/e/parse_annotations.hh (renamed from paludis/repositories/e/apply_annotations.hh) | 10 |
4 files changed, 51 insertions, 40 deletions
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am index 8feaeadf5..88d7c198f 100644 --- a/paludis/repositories/e/Makefile.am +++ b/paludis/repositories/e/Makefile.am @@ -22,7 +22,6 @@ endif noinst_HEADERS = \ a_finder.hh \ aa_visitor.hh \ - apply_annotations.hh \ can_skip_phase.hh \ check_fetched_files_visitor.hh \ check_userpriv.hh \ @@ -79,6 +78,7 @@ noinst_HEADERS = \ metadata_xml.hh \ myoption.hh \ myoptions_requirements_verifier.hh \ + parse_annotations.hh \ parse_dependency_label.hh \ parse_plain_text_label.hh \ parse_uri_label.hh \ @@ -102,7 +102,6 @@ noinst_HEADERS = \ libpaludiserepository_la_SOURCES = \ a_finder.cc \ aa_visitor.cc \ - apply_annotations.cc \ can_skip_phase.cc \ check_fetched_files_visitor.cc \ check_userpriv.cc \ @@ -154,6 +153,7 @@ libpaludiserepository_la_SOURCES = \ metadata_xml.cc \ myoption.cc \ myoptions_requirements_verifier.cc \ + parse_annotations.cc \ parse_dependency_label.cc \ parse_plain_text_label.cc \ parse_uri_label.cc \ diff --git a/paludis/repositories/e/dep_parser.cc b/paludis/repositories/e/dep_parser.cc index c80963c40..b13f2b39c 100644 --- a/paludis/repositories/e/dep_parser.cc +++ b/paludis/repositories/e/dep_parser.cc @@ -21,7 +21,7 @@ #include <paludis/repositories/e/parse_dependency_label.hh> #include <paludis/repositories/e/parse_uri_label.hh> #include <paludis/repositories/e/parse_plain_text_label.hh> -#include <paludis/repositories/e/apply_annotations.hh> +#include <paludis/repositories/e/parse_annotations.hh> #include <paludis/repositories/e/eapi.hh> #include <paludis/util/stringify.hh> #include <paludis/util/options.hh> @@ -379,24 +379,16 @@ namespace block = b; } - void fix_block_annotations( - const std::shared_ptr<BlockDepSpec> & if_block_spec, + void add_block_annotations( + std::shared_ptr<DepSpecAnnotations> & annotations, const BlockFixOp & block_fix_op) { - if (! if_block_spec) - return; - DepSpecAnnotationRole current_role(dsar_none); - if (if_block_spec->maybe_annotations()) - current_role = find_blocker_role_in_annotations(if_block_spec->maybe_annotations()); + if (annotations) + current_role = find_blocker_role_in_annotations(annotations); if (dsar_none != current_role) return; - std::shared_ptr<DepSpecAnnotations> annotations(std::make_shared<DepSpecAnnotations>()); - if (if_block_spec->maybe_annotations()) - std::for_each(if_block_spec->maybe_annotations()->begin(), if_block_spec->maybe_annotations()->end(), - std::bind(&DepSpecAnnotations::add, annotations, std::placeholders::_1)); - switch (block_fix_op) { case bfo_explicit_strong: @@ -426,19 +418,40 @@ namespace )); break; } - - if_block_spec->set_annotations(annotations); } - void apply_annotations_then_fixup( + void apply_maybe_blocker_annotations( const EAPI & eapi, const std::shared_ptr<DepSpec> & spec, const std::shared_ptr<BlockDepSpec> & if_block_spec, const BlockFixOp & block_fix_op, const std::shared_ptr<const Map<std::string, std::string> > & m) { - apply_annotations(eapi, spec, m); - fix_block_annotations(if_block_spec, block_fix_op); + auto annotations(parse_annotations(eapi, m)); + if (if_block_spec) + add_block_annotations(annotations, block_fix_op); + spec->set_annotations(annotations); + } + + void apply_maybe_blocker_no_annotations( + const std::shared_ptr<BlockDepSpec> & if_block_spec, + const BlockFixOp & block_fix_op) + { + if (if_block_spec) + { + auto annotations(std::make_shared<DepSpecAnnotations>()); + add_block_annotations(annotations, block_fix_op); + if_block_spec->set_annotations(annotations); + } + } + + void apply_non_blocker_annotations( + const EAPI & eapi, + const std::shared_ptr<DepSpec> & spec, + const std::shared_ptr<const Map<std::string, std::string> > & m) + { + auto annotations(parse_annotations(eapi, m)); + spec->set_annotations(annotations); } } @@ -462,7 +475,7 @@ paludis::erepository::parse_depend(const std::string & s, const Environment * co ELikeDepParserCallbacks callbacks( make_named_values<ELikeDepParserCallbacks>( n::on_all() = std::bind(&any_all_handler<DependencySpecTree, AllDepSpec>, std::ref(stack)), - n::on_annotations() = std::bind(&apply_annotations_then_fixup, std::cref(eapi), std::cref(thing_to_annotate), + n::on_annotations() = std::bind(&apply_maybe_blocker_annotations, std::cref(eapi), std::cref(thing_to_annotate), std::cref(thing_to_annotate_if_block), std::cref(block_fix_op), _1), n::on_any() = std::bind(&any_all_handler<DependencySpecTree, AnyDepSpec>, std::ref(stack)), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), @@ -473,7 +486,7 @@ paludis::erepository::parse_depend(const std::string & s, const Environment * co ParseStackTypes<DependencySpecTree>::AnnotationsGoHere(std::bind( &set_thing_to_annotate_maybe_block, std::ref(thing_to_annotate), _1, std::ref(thing_to_annotate_if_block), _2)), _1, std::cref(eapi)), - n::on_no_annotations() = std::bind(&fix_block_annotations, std::cref(thing_to_annotate_if_block), std::cref(block_fix_op)), + n::on_no_annotations() = std::bind(&apply_maybe_blocker_no_annotations, std::cref(thing_to_annotate_if_block), std::cref(block_fix_op)), n::on_pop() = std::bind(&pop_handler<DependencySpecTree>, std::ref(stack), ParseStackTypes<DependencySpecTree>::AnnotationsGoHere(std::bind( &set_thing_to_annotate_maybe_block, std::ref(thing_to_annotate), _1, std::ref(thing_to_annotate_if_block), _2)), s), @@ -509,7 +522,7 @@ paludis::erepository::parse_provide(const std::string & s, const Environment * c ELikeDepParserCallbacks callbacks( make_named_values<ELikeDepParserCallbacks>( n::on_all() = std::bind(&any_all_handler<ProvideSpecTree, AllDepSpec>, std::ref(stack)), - n::on_annotations() = std::bind(&apply_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), + n::on_annotations() = std::bind(&apply_non_blocker_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), n::on_any() = std::bind(&any_not_allowed_handler, s), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), n::on_error() = std::bind(&error_handler, s, _1), @@ -550,7 +563,7 @@ paludis::erepository::parse_fetchable_uri(const std::string & s, const Environme ELikeDepParserCallbacks callbacks( make_named_values<ELikeDepParserCallbacks>( n::on_all() = std::bind(&any_all_handler<FetchableURISpecTree, AllDepSpec>, std::ref(stack)), - n::on_annotations() = std::bind(&apply_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), + n::on_annotations() = std::bind(&apply_non_blocker_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), n::on_any() = std::bind(&any_not_allowed_handler, s), n::on_arrow() = std::bind(&arrow_handler<FetchableURISpecTree>, std::ref(stack), ParseStackTypes<FetchableURISpecTree>::AnnotationsGoHere(std::bind( @@ -595,7 +608,7 @@ paludis::erepository::parse_simple_uri(const std::string & s, const Environment ELikeDepParserCallbacks callbacks( make_named_values<ELikeDepParserCallbacks>( n::on_all() = std::bind(&any_all_handler<SimpleURISpecTree, AllDepSpec>, std::ref(stack)), - n::on_annotations() = std::bind(&apply_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), + n::on_annotations() = std::bind(&apply_non_blocker_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), n::on_any() = std::bind(&any_not_allowed_handler, s), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), n::on_error() = std::bind(&error_handler, s, _1), @@ -636,7 +649,7 @@ paludis::erepository::parse_license(const std::string & s, const Environment * c ELikeDepParserCallbacks callbacks( make_named_values<ELikeDepParserCallbacks>( n::on_all() = std::bind(&any_all_handler<LicenseSpecTree, AllDepSpec>, std::ref(stack)), - n::on_annotations() = std::bind(&apply_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), + n::on_annotations() = std::bind(&apply_non_blocker_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), n::on_any() = std::bind(&any_all_handler<LicenseSpecTree, AnyDepSpec>, std::ref(stack)), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), n::on_error() = std::bind(&error_handler, s, _1), @@ -677,7 +690,7 @@ paludis::erepository::parse_plain_text(const std::string & s, const Environment ELikeDepParserCallbacks callbacks( make_named_values<ELikeDepParserCallbacks>( n::on_all() = std::bind(&any_all_handler<PlainTextSpecTree, AllDepSpec>, std::ref(stack)), - n::on_annotations() = std::bind(&apply_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), + n::on_annotations() = std::bind(&apply_non_blocker_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), n::on_any() = std::bind(&any_not_allowed_handler, s), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), n::on_error() = std::bind(&error_handler, s, _1), @@ -718,7 +731,7 @@ paludis::erepository::parse_myoptions(const std::string & s, const Environment * ELikeDepParserCallbacks callbacks( make_named_values<ELikeDepParserCallbacks>( n::on_all() = std::bind(&any_all_handler<PlainTextSpecTree, AllDepSpec>, std::ref(stack)), - n::on_annotations() = std::bind(&apply_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), + n::on_annotations() = std::bind(&apply_non_blocker_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), n::on_any() = std::bind(&any_not_allowed_handler, s), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), n::on_error() = std::bind(&error_handler, s, _1), @@ -761,7 +774,7 @@ paludis::erepository::parse_required_use(const std::string & s, const Environmen ELikeDepParserCallbacks callbacks( make_named_values<ELikeDepParserCallbacks>( n::on_all() = std::bind(&any_all_handler<RequiredUseSpecTree, AllDepSpec>, std::ref(stack)), - n::on_annotations() = std::bind(&apply_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), + n::on_annotations() = std::bind(&apply_non_blocker_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), n::on_any() = std::bind(&any_all_handler<RequiredUseSpecTree, AnyDepSpec>, std::ref(stack)), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), n::on_error() = std::bind(&error_handler, s, _1), diff --git a/paludis/repositories/e/apply_annotations.cc b/paludis/repositories/e/parse_annotations.cc index d8ba39007..a4ab6ba5c 100644 --- a/paludis/repositories/e/apply_annotations.cc +++ b/paludis/repositories/e/parse_annotations.cc @@ -17,7 +17,7 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <paludis/repositories/e/apply_annotations.hh> +#include <paludis/repositories/e/parse_annotations.hh> #include <paludis/repositories/e/eapi.hh> #include <paludis/repositories/e/dep_parser.hh> #include <paludis/util/map.hh> @@ -26,15 +26,13 @@ #include <paludis/util/make_named_values.hh> #include <paludis/util/make_null_shared_ptr.hh> #include <paludis/dep_spec_annotations.hh> -#include <paludis/dep_spec.hh> using namespace paludis; using namespace paludis::erepository; -void -paludis::erepository::apply_annotations( +const std::shared_ptr<DepSpecAnnotations> +paludis::erepository::parse_annotations( const EAPI & eapi, - const std::shared_ptr<DepSpec> & spec, const std::shared_ptr<const Map<std::string, std::string> > & m) { auto annotations(std::make_shared<DepSpecAnnotations>()); @@ -123,6 +121,6 @@ paludis::erepository::apply_annotations( n::value() = k->second)); } - spec->set_annotations(annotations); + return annotations; } diff --git a/paludis/repositories/e/apply_annotations.hh b/paludis/repositories/e/parse_annotations.hh index 5e512fe6e..52b8b11ed 100644 --- a/paludis/repositories/e/apply_annotations.hh +++ b/paludis/repositories/e/parse_annotations.hh @@ -17,21 +17,21 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_APPLY_ANNOTATIONS_HH -#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_APPLY_ANNOTATIONS_HH 1 +#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_PARSE_ANNOTATIONS_HH +#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_PARSE_ANNOTATIONS_HH 1 #include <paludis/repositories/e/eapi-fwd.hh> #include <paludis/util/map-fwd.hh> -#include <paludis/dep_spec-fwd.hh> +#include <paludis/dep_spec_annotations-fwd.hh> #include <memory> namespace paludis { namespace erepository { - void apply_annotations( + const std::shared_ptr<DepSpecAnnotations> + parse_annotations( const EAPI & eapi, - const std::shared_ptr<DepSpec> & spec, const std::shared_ptr<const Map<std::string, std::string> > & m); } } |