aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-07 16:09:55 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-07 16:09:55 +0000
commit79a451bdc08b1c7d9477796c94f55d882eacfa12 (patch)
treef733c0f251cd10e58aca59299f944c7aa0e24d57
parenta4c999be67cb412120d12eb2bb051b550f64736f (diff)
downloadpaludis-79a451bdc08b1c7d9477796c94f55d882eacfa12.tar.gz
paludis-79a451bdc08b1c7d9477796c94f55d882eacfa12.tar.xz
Split out more
-rw-r--r--paludis/repositories/e/Makefile.am2
-rw-r--r--paludis/repositories/e/apply_annotations.cc153
-rw-r--r--paludis/repositories/e/apply_annotations.hh45
-rw-r--r--paludis/repositories/e/dep_parser.cc135
4 files changed, 209 insertions, 126 deletions
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index d644f8e..8feaead 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 0000000..818227d
--- /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 <paludis/repositories/e/apply_annotations.hh>
+#include <paludis/repositories/e/eapi.hh>
+#include <paludis/repositories/e/dep_parser.hh>
+#include <paludis/util/map.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/make_named_values.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 EAPI & eapi,
+ std::shared_ptr<DepSpec> & spec,
+ std::shared_ptr<BlockDepSpec> & if_block_spec,
+ const std::shared_ptr<const Map<std::string, std::string> > & m)
+{
+ auto annotations(std::make_shared<DepSpecAnnotations>());
+ 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<DepSpecAnnotation>(
+ 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<DepSpec> & spec,
+ const std::shared_ptr<const Map<std::string, std::string> > & m)
+{
+ std::shared_ptr<BlockDepSpec> 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 0000000..5cc67f0
--- /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 <paludis/repositories/e/eapi-fwd.hh>
+#include <paludis/util/map-fwd.hh>
+#include <paludis/dep_spec-fwd.hh>
+#include <memory>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ void apply_annotations(
+ const EAPI & eapi,
+ std::shared_ptr<DepSpec> & spec,
+ std::shared_ptr<BlockDepSpec> & if_block_spec,
+ const std::shared_ptr<const Map<std::string, std::string> > & m);
+
+ void apply_annotations_not_block(
+ const EAPI & eapi,
+ std::shared_ptr<DepSpec> & spec,
+ const std::shared_ptr<const Map<std::string, std::string> > & m);
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/dep_parser.cc b/paludis/repositories/e/dep_parser.cc
index 2144397..738c786 100644
--- a/paludis/repositories/e/dep_parser.cc
+++ b/paludis/repositories/e/dep_parser.cc
@@ -21,6 +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/eapi.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/options.hh>
@@ -339,124 +340,6 @@ namespace
{
}
- void set_annotations_block(
- const EAPI & eapi,
- std::shared_ptr<DepSpec> & spec,
- std::shared_ptr<BlockDepSpec> & if_block_spec,
- const std::shared_ptr<const Map<std::string, std::string> > & m)
- {
- auto annotations(std::make_shared<DepSpecAnnotations>());
- 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<DepSpecAnnotation>(
- n::key() = k->first,
- n::role() = role,
- n::value() = k->second));
- }
-
- spec->set_annotations(annotations);
- }
-
- void set_annotations(
- const EAPI & eapi,
- std::shared_ptr<DepSpec> & spec,
- const std::shared_ptr<const Map<std::string, std::string> > & m)
- {
- std::shared_ptr<BlockDepSpec> not_block;
- set_annotations_block(eapi, spec, not_block, m);
- }
-
void set_thing_to_annotate(std::shared_ptr<DepSpec> & spec, const std::shared_ptr<DepSpec> & s)
{
spec = s;
@@ -489,7 +372,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(&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<DependencySpecTree, AnyDepSpec>, 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<ELikeDepParserCallbacks>(
n::on_all() = std::bind(&any_all_handler<ProvideSpecTree, AllDepSpec>, 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<ELikeDepParserCallbacks>(
n::on_all() = std::bind(&any_all_handler<FetchableURISpecTree, AllDepSpec>, 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<FetchableURISpecTree>, std::ref(stack),
ParseStackTypes<FetchableURISpecTree>::AnnotationsGoHere(std::bind(
@@ -615,7 +498,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(&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<ELikeDepParserCallbacks>(
n::on_all() = std::bind(&any_all_handler<LicenseSpecTree, AllDepSpec>, 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<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),
@@ -693,7 +576,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(&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<ELikeDepParserCallbacks>(
n::on_all() = std::bind(&any_all_handler<PlainTextSpecTree, AllDepSpec>, 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<ELikeDepParserCallbacks>(
n::on_all() = std::bind(&any_all_handler<RequiredUseSpecTree, AllDepSpec>, 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<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),