From 79a451bdc08b1c7d9477796c94f55d882eacfa12 Mon Sep 17 00:00:00 2001 From: Ciaran McCreesh Date: Mon, 7 Mar 2011 16:09:55 +0000 Subject: Split out more --- paludis/repositories/e/Makefile.am | 2 + paludis/repositories/e/apply_annotations.cc | 153 ++++++++++++++++++++++++++++ paludis/repositories/e/apply_annotations.hh | 45 ++++++++ paludis/repositories/e/dep_parser.cc | 135 ++---------------------- 4 files changed, 209 insertions(+), 126 deletions(-) create mode 100644 paludis/repositories/e/apply_annotations.cc create mode 100644 paludis/repositories/e/apply_annotations.hh diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am index d644f8e30..8feaeadf5 100644 --- a/paludis/repositories/e/Makefile.am +++ b/paludis/repositories/e/Makefile.am @@ -22,6 +22,7 @@ endif noinst_HEADERS = \ a_finder.hh \ aa_visitor.hh \ + apply_annotations.hh \ can_skip_phase.hh \ check_fetched_files_visitor.hh \ check_userpriv.hh \ @@ -101,6 +102,7 @@ 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 \ diff --git a/paludis/repositories/e/apply_annotations.cc b/paludis/repositories/e/apply_annotations.cc new file mode 100644 index 000000000..818227d69 --- /dev/null +++ b/paludis/repositories/e/apply_annotations.cc @@ -0,0 +1,153 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2005, 2006, 2007, 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 + * Public License version 2, as published by the Free Software Foundation. + * + * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace paludis; +using namespace paludis::erepository; + +void +paludis::erepository::apply_annotations( + const EAPI & eapi, + std::shared_ptr & spec, + std::shared_ptr & if_block_spec, + const std::shared_ptr > & m) +{ + auto annotations(std::make_shared()); + for (auto k(m->begin()), k_end(m->end()) ; + k != k_end ; ++k) + { + if (k->first.empty()) + continue; + + DepSpecAnnotationRole role(dsar_none); + + /* blocks */ + if (if_block_spec && (! eapi.supported()->annotations()->blocker_resolution().empty())) + { + if (k->first == eapi.supported()->annotations()->blocker_resolution()) + { + if (k->second.empty()) + { + } + else if (k->second == eapi.supported()->annotations()->blocker_resolution_manual()) + { + if_block_spec->set_block_kind(bk_manual); + role = dsar_blocker_manual; + } + else if (k->second == eapi.supported()->annotations()->blocker_resolution_uninstall_blocked_after()) + { + if_block_spec->set_block_kind(bk_uninstall_blocked_after); + role = dsar_blocker_uninstall_blocked_after; + } + else if (k->second == eapi.supported()->annotations()->blocker_resolution_uninstall_blocked_before()) + { + if_block_spec->set_block_kind(bk_uninstall_blocked_before); + role = dsar_blocker_uninstall_blocked_before; + } + else if (k->second == eapi.supported()->annotations()->blocker_resolution_upgrade_blocked_before()) + { + if_block_spec->set_block_kind(bk_upgrade_blocked_before); + role = dsar_blocker_upgrade_blocked_before; + } + else + throw EDepParseError(stringify(*if_block_spec), "Unknown value '" + k->second + "' for annotation '" + k->first + "'"); + } + } + + /* myoptions number-selected */ + if (dsar_none == role) + { + if (k->first == eapi.supported()->annotations()->myoptions_number_selected()) + { + if (k->second.empty()) + { + } + else if (k->second == eapi.supported()->annotations()->myoptions_number_selected_at_least_one()) + role = dsar_myoptions_n_at_least_one; + else if (k->second == eapi.supported()->annotations()->myoptions_number_selected_at_most_one()) + role = dsar_myoptions_n_at_most_one; + else if (k->second == eapi.supported()->annotations()->myoptions_number_selected_exactly_one()) + role = dsar_myoptions_n_exactly_one; + else + throw EDepParseError(k->first, "Unknown value '" + k->second + "' for annotation '" + k->first + "'"); + } + } + + /* myoptions requires */ + if (dsar_none == role) + { + if (k->first == eapi.supported()->annotations()->myoptions_requires()) + role = dsar_myoptions_requires; + } + + /* suggestions */ + if (dsar_none == role) + { + if (k->first == eapi.supported()->annotations()->suggestions_group_name()) + role = dsar_suggestions_group_name; + } + + /* general */ + if (dsar_none == role) + { + if (k->first == eapi.supported()->annotations()->general_description()) + role = dsar_general_description; + else if (k->first == eapi.supported()->annotations()->general_url()) + role = dsar_general_url; + else if (k->first == eapi.supported()->annotations()->general_note()) + role = dsar_general_note; + else if (k->first == eapi.supported()->annotations()->general_lang()) + role = dsar_general_lang; + else if (k->first == eapi.supported()->ebuild_options()->bracket_merged_variables_annotation()) + role = dsar_general_defined_in; + } + + if (dsar_none == role) + Log::get_instance()->message("e.dep_parser.unknown_annotation", ll_qa, lc_context) + << "Unknown annotation '" << k->first << "' = '" << k->second << "'"; + + annotations->add(make_named_values( + n::key() = k->first, + n::role() = role, + n::value() = k->second)); + } + + spec->set_annotations(annotations); +} + +void +paludis::erepository::apply_annotations_not_block( + const EAPI & eapi, + std::shared_ptr & spec, + const std::shared_ptr > & m) +{ + std::shared_ptr not_block; + apply_annotations(eapi, spec, not_block, m); +} + + diff --git a/paludis/repositories/e/apply_annotations.hh b/paludis/repositories/e/apply_annotations.hh new file mode 100644 index 000000000..5cc67f0ec --- /dev/null +++ b/paludis/repositories/e/apply_annotations.hh @@ -0,0 +1,45 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2005, 2006, 2007, 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 + * Public License version 2, as published by the Free Software Foundation. + * + * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * 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 + +#include +#include +#include +#include + +namespace paludis +{ + namespace erepository + { + void apply_annotations( + const EAPI & eapi, + std::shared_ptr & spec, + std::shared_ptr & if_block_spec, + const std::shared_ptr > & m); + + void apply_annotations_not_block( + const EAPI & eapi, + std::shared_ptr & spec, + const std::shared_ptr > & m); + } +} + +#endif diff --git a/paludis/repositories/e/dep_parser.cc b/paludis/repositories/e/dep_parser.cc index 214439749..738c78616 100644 --- a/paludis/repositories/e/dep_parser.cc +++ b/paludis/repositories/e/dep_parser.cc @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -339,124 +340,6 @@ namespace { } - void set_annotations_block( - const EAPI & eapi, - std::shared_ptr & spec, - std::shared_ptr & if_block_spec, - const std::shared_ptr > & m) - { - auto annotations(std::make_shared()); - for (auto k(m->begin()), k_end(m->end()) ; - k != k_end ; ++k) - { - if (k->first.empty()) - continue; - - DepSpecAnnotationRole role(dsar_none); - - /* blocks */ - if (if_block_spec && (! eapi.supported()->annotations()->blocker_resolution().empty())) - { - if (k->first == eapi.supported()->annotations()->blocker_resolution()) - { - if (k->second.empty()) - { - } - else if (k->second == eapi.supported()->annotations()->blocker_resolution_manual()) - { - if_block_spec->set_block_kind(bk_manual); - role = dsar_blocker_manual; - } - else if (k->second == eapi.supported()->annotations()->blocker_resolution_uninstall_blocked_after()) - { - if_block_spec->set_block_kind(bk_uninstall_blocked_after); - role = dsar_blocker_uninstall_blocked_after; - } - else if (k->second == eapi.supported()->annotations()->blocker_resolution_uninstall_blocked_before()) - { - if_block_spec->set_block_kind(bk_uninstall_blocked_before); - role = dsar_blocker_uninstall_blocked_before; - } - else if (k->second == eapi.supported()->annotations()->blocker_resolution_upgrade_blocked_before()) - { - if_block_spec->set_block_kind(bk_upgrade_blocked_before); - role = dsar_blocker_upgrade_blocked_before; - } - else - throw EDepParseError(stringify(*if_block_spec), "Unknown value '" + k->second + "' for annotation '" + k->first + "'"); - } - } - - /* myoptions number-selected */ - if (dsar_none == role) - { - if (k->first == eapi.supported()->annotations()->myoptions_number_selected()) - { - if (k->second.empty()) - { - } - else if (k->second == eapi.supported()->annotations()->myoptions_number_selected_at_least_one()) - role = dsar_myoptions_n_at_least_one; - else if (k->second == eapi.supported()->annotations()->myoptions_number_selected_at_most_one()) - role = dsar_myoptions_n_at_most_one; - else if (k->second == eapi.supported()->annotations()->myoptions_number_selected_exactly_one()) - role = dsar_myoptions_n_exactly_one; - else - throw EDepParseError(k->first, "Unknown value '" + k->second + "' for annotation '" + k->first + "'"); - } - } - - /* myoptions requires */ - if (dsar_none == role) - { - if (k->first == eapi.supported()->annotations()->myoptions_requires()) - role = dsar_myoptions_requires; - } - - /* suggestions */ - if (dsar_none == role) - { - if (k->first == eapi.supported()->annotations()->suggestions_group_name()) - role = dsar_suggestions_group_name; - } - - /* general */ - if (dsar_none == role) - { - if (k->first == eapi.supported()->annotations()->general_description()) - role = dsar_general_description; - else if (k->first == eapi.supported()->annotations()->general_url()) - role = dsar_general_url; - else if (k->first == eapi.supported()->annotations()->general_note()) - role = dsar_general_note; - else if (k->first == eapi.supported()->annotations()->general_lang()) - role = dsar_general_lang; - else if (k->first == eapi.supported()->ebuild_options()->bracket_merged_variables_annotation()) - role = dsar_general_defined_in; - } - - if (dsar_none == role) - Log::get_instance()->message("e.dep_parser.unknown_annotation", ll_qa, lc_context) - << "Unknown annotation '" << k->first << "' = '" << k->second << "'"; - - annotations->add(make_named_values( - n::key() = k->first, - n::role() = role, - n::value() = k->second)); - } - - spec->set_annotations(annotations); - } - - void set_annotations( - const EAPI & eapi, - std::shared_ptr & spec, - const std::shared_ptr > & m) - { - std::shared_ptr not_block; - set_annotations_block(eapi, spec, not_block, m); - } - void set_thing_to_annotate(std::shared_ptr & spec, const std::shared_ptr & s) { spec = s; @@ -489,7 +372,7 @@ paludis::erepository::parse_depend(const std::string & s, const Environment * co ELikeDepParserCallbacks callbacks( make_named_values( n::on_all() = std::bind(&any_all_handler, std::ref(stack)), - n::on_annotations() = std::bind(&set_annotations_block, std::cref(eapi), std::ref(thing_to_annotate), + n::on_annotations() = std::bind(&apply_annotations, std::cref(eapi), std::ref(thing_to_annotate), std::ref(thing_to_annotate_if_block), _1), n::on_any() = std::bind(&any_all_handler, std::ref(stack)), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), @@ -533,7 +416,7 @@ paludis::erepository::parse_provide(const std::string & s, const Environment * c ELikeDepParserCallbacks callbacks( make_named_values( n::on_all() = std::bind(&any_all_handler, std::ref(stack)), - n::on_annotations() = std::bind(&set_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), + n::on_annotations() = std::bind(&apply_annotations_not_block, 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), @@ -572,7 +455,7 @@ paludis::erepository::parse_fetchable_uri(const std::string & s, const Environme ELikeDepParserCallbacks callbacks( make_named_values( n::on_all() = std::bind(&any_all_handler, std::ref(stack)), - n::on_annotations() = std::bind(&set_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), + n::on_annotations() = std::bind(&apply_annotations_not_block, 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, std::ref(stack), ParseStackTypes::AnnotationsGoHere(std::bind( @@ -615,7 +498,7 @@ paludis::erepository::parse_simple_uri(const std::string & s, const Environment ELikeDepParserCallbacks callbacks( make_named_values( n::on_all() = std::bind(&any_all_handler, std::ref(stack)), - n::on_annotations() = std::bind(&set_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), + n::on_annotations() = std::bind(&apply_annotations_not_block, 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), @@ -654,7 +537,7 @@ paludis::erepository::parse_license(const std::string & s, const Environment * c ELikeDepParserCallbacks callbacks( make_named_values( n::on_all() = std::bind(&any_all_handler, std::ref(stack)), - n::on_annotations() = std::bind(&set_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), + n::on_annotations() = std::bind(&apply_annotations_not_block, std::cref(eapi), std::ref(thing_to_annotate), _1), n::on_any() = std::bind(&any_all_handler, std::ref(stack)), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), n::on_error() = std::bind(&error_handler, s, _1), @@ -693,7 +576,7 @@ paludis::erepository::parse_plain_text(const std::string & s, const Environment ELikeDepParserCallbacks callbacks( make_named_values( n::on_all() = std::bind(&any_all_handler, std::ref(stack)), - n::on_annotations() = std::bind(&set_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), + n::on_annotations() = std::bind(&apply_annotations_not_block, 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), @@ -732,7 +615,7 @@ paludis::erepository::parse_myoptions(const std::string & s, const Environment * ELikeDepParserCallbacks callbacks( make_named_values( n::on_all() = std::bind(&any_all_handler, std::ref(stack)), - n::on_annotations() = std::bind(&set_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), + n::on_annotations() = std::bind(&apply_annotations_not_block, 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), @@ -773,7 +656,7 @@ paludis::erepository::parse_required_use(const std::string & s, const Environmen ELikeDepParserCallbacks callbacks( make_named_values( n::on_all() = std::bind(&any_all_handler, std::ref(stack)), - n::on_annotations() = std::bind(&set_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), + n::on_annotations() = std::bind(&apply_annotations_not_block, std::cref(eapi), std::ref(thing_to_annotate), _1), n::on_any() = std::bind(&any_all_handler, std::ref(stack)), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), n::on_error() = std::bind(&error_handler, s, _1), -- cgit v1.2.3