aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-26 18:36:51 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-26 18:36:51 +0000
commit16d72f25f751ba1d4260442d2e4615985913f592 (patch)
tree2827328c0eaa9725f120bd27f80d282c5dacfcc8
parent26459ac237d7db1d4dc908dd94a40e4018882fc4 (diff)
downloadpaludis-16d72f25f751ba1d4260442d2e4615985913f592.tar.gz
paludis-16d72f25f751ba1d4260442d2e4615985913f592.tar.xz
More EAPI work. Fixes: ticket:245
-rw-r--r--paludis/dep_spec_pretty_printer_TEST.cc17
-rw-r--r--paludis/eapi.cc12
-rw-r--r--paludis/eapi.hh1
-rw-r--r--paludis/eapi.sr1
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/portage_dep_parser-fwd.hh36
-rw-r--r--paludis/portage_dep_parser.cc99
-rw-r--r--paludis/portage_dep_parser.hh46
-rw-r--r--paludis/portage_dep_parser_TEST.cc58
-rw-r--r--paludis/qa/parse_deps_check.cc6
-rw-r--r--paludis/repositories/cran/cran_dep_parser.cc7
-rw-r--r--paludis/repositories/cran/cran_dep_parser.hh5
-rw-r--r--paludis/repositories/cran/cran_dep_parser_TEST.cc6
-rw-r--r--paludis/repositories/gentoo/vdb_repository.cc8
-rw-r--r--paludis/version_metadata.cc22
-rw-r--r--paludis/version_metadata.hh5
16 files changed, 216 insertions, 115 deletions
diff --git a/paludis/dep_spec_pretty_printer_TEST.cc b/paludis/dep_spec_pretty_printer_TEST.cc
index 1b22656..80edc4d 100644
--- a/paludis/dep_spec_pretty_printer_TEST.cc
+++ b/paludis/dep_spec_pretty_printer_TEST.cc
@@ -20,6 +20,7 @@
#include "dep_spec_pretty_printer.hh"
#include "portage_dep_parser.hh"
#include <paludis/util/visitor-impl.hh>
+#include <paludis/eapi.hh>
#include <test/test_runner.hh>
#include <test/test_framework.hh>
@@ -35,19 +36,19 @@ namespace test_cases
void run()
{
DepSpecPrettyPrinter p1(0, false);
- PortageDepParser::parse_depend("foo/bar bar/baz", pds_pm_permissive)->accept(p1);
+ PortageDepParser::parse_depend("foo/bar bar/baz", EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p1);
TEST_CHECK_STRINGIFY_EQUAL(p1, "foo/bar bar/baz");
DepSpecPrettyPrinter p2(0, false);
- PortageDepParser::parse_depend("foo/bar moo? ( bar/baz )", pds_pm_permissive)->accept(p2);
+ PortageDepParser::parse_depend("foo/bar moo? ( bar/baz )", EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p2);
TEST_CHECK_STRINGIFY_EQUAL(p2, "foo/bar moo? ( bar/baz )");
DepSpecPrettyPrinter p3(0, false);
- PortageDepParser::parse_depend("|| ( a/b ( c/d e/f ) )", pds_pm_permissive)->accept(p3);
+ PortageDepParser::parse_depend("|| ( a/b ( c/d e/f ) )", EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p3);
TEST_CHECK_STRINGIFY_EQUAL(p3, "|| ( a/b ( c/d e/f ) )");
DepSpecPrettyPrinter p4(0, false);
- PortageDepParser::parse_license("( ( ( ) a ) b )")->accept(p4);
+ PortageDepParser::parse_license("( ( ( ) a ) b )", EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p4);
TEST_CHECK_STRINGIFY_EQUAL(p4, "a b");
}
} test_pretty_printer_no_indent;
@@ -59,20 +60,20 @@ namespace test_cases
void run()
{
DepSpecPrettyPrinter p1(4);
- PortageDepParser::parse_depend("foo/bar bar/baz", pds_pm_permissive)->accept(p1);
+ PortageDepParser::parse_depend("foo/bar bar/baz", EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p1);
TEST_CHECK_STRINGIFY_EQUAL(p1, " foo/bar\n bar/baz\n");
DepSpecPrettyPrinter p2(4);
- PortageDepParser::parse_depend("foo/bar moo? ( bar/baz )", pds_pm_permissive)->accept(p2);
+ PortageDepParser::parse_depend("foo/bar moo? ( bar/baz )", EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p2);
TEST_CHECK_STRINGIFY_EQUAL(p2, " foo/bar\n moo? (\n bar/baz\n )\n");
DepSpecPrettyPrinter p3(4);
- PortageDepParser::parse_depend("|| ( a/b ( c/d e/f ) )", pds_pm_permissive)->accept(p3);
+ PortageDepParser::parse_depend("|| ( a/b ( c/d e/f ) )", EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p3);
TEST_CHECK_STRINGIFY_EQUAL(p3, " || (\n a/b\n (\n c/d\n"
" e/f\n )\n )\n");
DepSpecPrettyPrinter p4(4);
- PortageDepParser::parse_license("( ( ( ) a ) b )")->accept(p4);
+ PortageDepParser::parse_license("( ( ( ) a ) b )", EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p4);
TEST_CHECK_STRINGIFY_EQUAL(p4, " a\n b\n");
}
} test_pretty_printer_indent;
diff --git a/paludis/eapi.cc b/paludis/eapi.cc
index 3e7b8da..1f20e14 100644
--- a/paludis/eapi.cc
+++ b/paludis/eapi.cc
@@ -34,16 +34,20 @@ namespace paludis
Implementation()
{
values.insert(std::make_pair("0", EAPI("0", tr1::shared_ptr<SupportedEAPI>(new SupportedEAPI(
- pds_pm_eapi_0, pds_pm_eapi_0_strict, iuse_pm_eapi_0, iuse_pm_eapi_0_strict, false, false)))));
+ pds_pm_eapi_0, pds_pm_eapi_0_strict, dst_pm_eapi_0,
+ iuse_pm_eapi_0, iuse_pm_eapi_0_strict, false, false)))));
values.insert(std::make_pair("", EAPI("", tr1::shared_ptr<SupportedEAPI>(new SupportedEAPI(
- pds_pm_eapi_0, pds_pm_eapi_0_strict, iuse_pm_eapi_0, iuse_pm_eapi_0_strict, false, false)))));
+ pds_pm_eapi_0, pds_pm_eapi_0_strict, dst_pm_eapi_0,
+ iuse_pm_eapi_0, iuse_pm_eapi_0_strict, false, false)))));
values.insert(std::make_pair("paludis-1", EAPI("paludis-1", tr1::shared_ptr<SupportedEAPI>(new SupportedEAPI(
- pds_pm_permissive, pds_pm_permissive, iuse_pm_permissive, iuse_pm_permissive, true, true)))));
+ pds_pm_permissive, pds_pm_permissive, dst_pm_paludis_1,
+ iuse_pm_permissive, iuse_pm_permissive, true, true)))));
values.insert(std::make_pair("CRAN-1", EAPI("CRAN-1", tr1::shared_ptr<SupportedEAPI>(new SupportedEAPI(
- pds_pm_permissive, pds_pm_permissive, iuse_pm_permissive, iuse_pm_permissive, true, false)))));
+ pds_pm_permissive, pds_pm_permissive, dst_pm_eapi_0,
+ iuse_pm_permissive, iuse_pm_permissive, true, false)))));
}
};
}
diff --git a/paludis/eapi.hh b/paludis/eapi.hh
index 0a9b5e3..36bcf44 100644
--- a/paludis/eapi.hh
+++ b/paludis/eapi.hh
@@ -27,6 +27,7 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/name.hh>
#include <paludis/dep_spec-fwd.hh>
+#include <paludis/portage_dep_parser-fwd.hh>
namespace paludis
{
diff --git a/paludis/eapi.sr b/paludis/eapi.sr
index 09a9d35..3a67a20 100644
--- a/paludis/eapi.sr
+++ b/paludis/eapi.sr
@@ -4,6 +4,7 @@ make_class_SupportedEAPI()
key package_dep_spec_parse_mode PackageDepSpecParseMode
key strict_package_dep_spec_parse_mode PackageDepSpecParseMode
+ key dependency_spec_tree_parse_mode DependencySpecTreeParseMode
key iuse_flag_parse_mode IUseFlagParseMode
key strict_iuse_flag_parse_mode IUseFlagParseMode
diff --git a/paludis/files.m4 b/paludis/files.m4
index 2a48309..4272ebb 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -29,7 +29,7 @@ add(`package_database', `hh', `cc', `test', `se')
add(`package_database_entry', `hh', `cc', `sr')
add(`paludis', `hh', `cc')
add(`portage_dep_lexer', `hh', `cc', `test')
-add(`portage_dep_parser', `hh', `cc', `test')
+add(`portage_dep_parser', `hh', `cc', `fwd', `se', `test')
add(`query', `hh', `cc')
add(`repository', `hh', `fwd', `cc', `sr')
add(`repository_name_cache', `hh', `cc', `test', `testscript')
diff --git a/paludis/portage_dep_parser-fwd.hh b/paludis/portage_dep_parser-fwd.hh
new file mode 100644
index 0000000..dc44afd
--- /dev/null
+++ b/paludis/portage_dep_parser-fwd.hh
@@ -0,0 +1,36 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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_PORTAGE_DEP_PARSER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_PORTAGE_DEP_PARSER_FWD_HH 1
+
+#include <iosfwd>
+#include <paludis/util/attributes.hh>
+
+namespace paludis
+{
+ class PortageDepParser;
+ class DepStringNestingError;
+ class DepStringParseError;
+
+#include <paludis/portage_dep_parser-se.hh>
+
+}
+
+#endif
diff --git a/paludis/portage_dep_parser.cc b/paludis/portage_dep_parser.cc
index bb1452a..51650ed 100644
--- a/paludis/portage_dep_parser.cc
+++ b/paludis/portage_dep_parser.cc
@@ -18,6 +18,7 @@
*/
#include <paludis/dep_spec.hh>
+#include <paludis/eapi.hh>
#include <paludis/portage_dep_lexer.hh>
#include <paludis/portage_dep_parser.hh>
#include <paludis/util/exception.hh>
@@ -33,6 +34,8 @@
using namespace paludis;
+#include <paludis/portage_dep_parser-se.cc>
+
DepStringParseError::DepStringParseError(const std::string & d,
const std::string & m) throw () :
DepStringError(d, "in parse phase: " + m)
@@ -144,7 +147,8 @@ namespace
template <typename H_, bool>
struct HandleUse
{
- static void handle(const std::string & s, const std::string & i, std::stack<tr1::shared_ptr<Composite<H_> > > & stack)
+ static void handle(const std::string & s, const std::string & i,
+ std::stack<std::pair<tr1::shared_ptr<Composite<H_> >, bool> > & stack)
{
std::string f(i);
bool inv(f.length() && ('!' == f.at(0)));
@@ -162,15 +166,16 @@ namespace
tr1::shared_ptr<ConstTreeSequence<H_, UseDepSpec> > a(
new ConstTreeSequence<H_, UseDepSpec>(tr1::shared_ptr<UseDepSpec>(
new UseDepSpec(UseFlagName(f), inv))));
- stack.top()->add(a);
- stack.push(tr1::shared_ptr<Composite<H_> >(new RealComposite<H_, UseDepSpec>(a)));
+ stack.top().first->add(a);
+ stack.push(std::make_pair(tr1::shared_ptr<Composite<H_> >(new RealComposite<H_, UseDepSpec>(a)), false));
}
};
template <typename H_>
struct HandleUse<H_, false>
{
- static void handle(const std::string & s, const std::string &, std::stack<tr1::shared_ptr<Composite<H_> > > &)
+ static void handle(const std::string & s, const std::string &,
+ std::stack<std::pair<tr1::shared_ptr<Composite<H_> >, bool> > &)
{
throw DepStringParseError(s, "use? group is not allowed here");
}
@@ -179,35 +184,52 @@ namespace
template <typename H_, bool>
struct HandleAny
{
- static void handle(const std::string &, std::stack<tr1::shared_ptr<Composite<H_> > > & stack)
+ static void handle(const std::string &, std::stack<std::pair<tr1::shared_ptr<Composite<H_> >, bool> > & stack)
{
tr1::shared_ptr<ConstTreeSequence<H_, AnyDepSpec> > a(new ConstTreeSequence<H_, AnyDepSpec>(
tr1::shared_ptr<AnyDepSpec>(new AnyDepSpec)));
- stack.top()->add(a);
- stack.push(tr1::shared_ptr<Composite<H_> >(new RealComposite<H_, AnyDepSpec>(a)));
+ stack.top().first->add(a);
+ stack.push(std::make_pair(tr1::shared_ptr<Composite<H_> >(new RealComposite<H_, AnyDepSpec>(a)), true));
}
};
template <typename H_>
struct HandleAny<H_, false>
{
- static void handle(const std::string & s, std::stack<tr1::shared_ptr<Composite<H_> > > &)
+ static void handle(const std::string & s, std::stack<std::pair<tr1::shared_ptr<Composite<H_> >, bool> > &)
{
throw DepStringParseError(s, "|| is not allowed here");
}
};
+
+ bool disallow_any_use(const DependencySpecTreeParseMode tree_mode)
+ {
+ switch (tree_mode)
+ {
+ case dst_pm_eapi_0:
+ return false;
+
+ case dst_pm_paludis_1:
+ return true;
+
+ case last_dst_pm:
+ ;
+ }
+
+ throw InternalError(PALUDIS_HERE, "bad _tree_mode");
+ }
}
template <typename H_, typename I_, bool any_, bool use_>
tr1::shared_ptr<typename H_::ConstItem>
-PortageDepParser::_parse(const std::string & s, const I_ & p)
+PortageDepParser::_parse(const std::string & s, bool disallow_any_use, const I_ & p)
{
Context context("When parsing dependency string '" + s + "':");
- std::stack<tr1::shared_ptr<Composite<H_> > > stack;
- stack.push(tr1::shared_ptr<RealComposite<H_, AllDepSpec> >(new RealComposite<H_, AllDepSpec>(
- tr1::shared_ptr<ConstTreeSequence<H_, AllDepSpec> >(new ConstTreeSequence<H_, AllDepSpec>(
- tr1::shared_ptr<AllDepSpec>(new AllDepSpec))))));
+ std::stack<std::pair<tr1::shared_ptr<Composite<H_> >, bool> > stack;
+ stack.push(std::make_pair(tr1::shared_ptr<RealComposite<H_, AllDepSpec> >(new RealComposite<H_, AllDepSpec>(
+ tr1::shared_ptr<ConstTreeSequence<H_, AllDepSpec> >(new ConstTreeSequence<H_, AllDepSpec>(
+ tr1::shared_ptr<AllDepSpec>(new AllDepSpec))))), false));
PortageDepParserState state(dps_initial);
PortageDepLexer lexer(s);
@@ -233,7 +255,7 @@ PortageDepParser::_parse(const std::string & s, const I_ & p)
{
if (i->second.empty())
throw DepStringParseError(i->second, "Empty text entry");
- p.template add<H_>(i->second, stack.top());
+ p.template add<H_>(i->second, stack.top().first);
}
continue;
@@ -241,8 +263,8 @@ PortageDepParser::_parse(const std::string & s, const I_ & p)
{
tr1::shared_ptr<ConstTreeSequence<H_, AllDepSpec> > a(new ConstTreeSequence<H_, AllDepSpec>(
tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
- stack.top()->add(a);
- stack.push(tr1::shared_ptr<Composite<H_> >(new RealComposite<H_, AllDepSpec>(a)));
+ stack.top().first->add(a);
+ stack.push(std::make_pair(tr1::shared_ptr<Composite<H_> >(new RealComposite<H_, AllDepSpec>(a)), false));
state = dps_had_paren;
}
continue;
@@ -262,6 +284,8 @@ PortageDepParser::_parse(const std::string & s, const I_ & p)
continue;
case dpl_use_flag:
+ if (use_ && disallow_any_use && stack.top().second)
+ throw DepStringParseError(s, "use? group is not allowed immediately under a || ( )");
HandleUse<H_, use_>::handle(s, i->second, stack);
state = dps_had_use_flag;
continue;
@@ -387,7 +411,7 @@ PortageDepParser::_parse(const std::string & s, const I_ & p)
if (stack.empty())
throw DepStringNestingError(s);
- tr1::shared_ptr<Composite<H_> > result(stack.top());
+ tr1::shared_ptr<Composite<H_> > result(stack.top().first);
stack.pop();
if (! stack.empty())
throw DepStringNestingError(s);
@@ -395,32 +419,53 @@ PortageDepParser::_parse(const std::string & s, const I_ & p)
}
tr1::shared_ptr<DependencySpecTree::ConstItem>
-PortageDepParser::parse_depend(const std::string & s, const PackageDepSpecParseMode m)
+PortageDepParser::parse_depend(const std::string & s, const EAPI & e)
{
- return _parse<DependencySpecTree, ParsePackageOrBlockDepSpec, true, true>(s, ParsePackageOrBlockDepSpec(m));
+ if (! e.supported)
+ throw DepStringParseError(s, "Don't know how to parse EAPI '" + e.name + "' dependencies");
+
+ return _parse<DependencySpecTree, ParsePackageOrBlockDepSpec, true, true>(s,
+ disallow_any_use(e.supported->dependency_spec_tree_parse_mode),
+ ParsePackageOrBlockDepSpec(e.supported->package_dep_spec_parse_mode));
}
tr1::shared_ptr<ProvideSpecTree::ConstItem>
-PortageDepParser::parse_provide(const std::string & s)
+PortageDepParser::parse_provide(const std::string & s, const EAPI & e)
{
- return _parse<ProvideSpecTree, ParsePackageDepSpec, false, true>(s, ParsePackageDepSpec(pds_pm_eapi_0));
+ if (! e.supported)
+ throw DepStringParseError(s, "Don't know how to parse EAPI '" + e.name + "' provides");
+
+ return _parse<ProvideSpecTree, ParsePackageDepSpec, false, true>(s, false,
+ ParsePackageDepSpec(pds_pm_eapi_0));
}
tr1::shared_ptr<RestrictSpecTree::ConstItem>
-PortageDepParser::parse_restrict(const std::string & s)
+PortageDepParser::parse_restrict(const std::string & s, const EAPI & e)
{
- return _parse<RestrictSpecTree, ParseTextDepSpec, false, true>(s);
+ if (! e.supported)
+ throw DepStringParseError(s, "Don't know how to parse EAPI '" + e.name + "' restrictions");
+
+ return _parse<RestrictSpecTree, ParseTextDepSpec, false, true>(s, false,
+ ParseTextDepSpec());
}
tr1::shared_ptr<URISpecTree::ConstItem>
-PortageDepParser::parse_uri(const std::string & s)
+PortageDepParser::parse_uri(const std::string & s, const EAPI & e)
{
- return _parse<URISpecTree, ParseTextDepSpec, false, true>(s);
+ if (! e.supported)
+ throw DepStringParseError(s, "Don't know how to parse EAPI '" + e.name + "' URIs");
+
+ return _parse<URISpecTree, ParseTextDepSpec, false, true>(s, false,
+ ParseTextDepSpec());
}
tr1::shared_ptr<LicenseSpecTree::ConstItem>
-PortageDepParser::parse_license(const std::string & s)
+PortageDepParser::parse_license(const std::string & s, const EAPI & e)
{
- return _parse<LicenseSpecTree, ParseTextDepSpec, true, true>(s);
+ if (! e.supported)
+ throw DepStringParseError(s, "Don't know how to parse EAPI '" + e.name + "' licenses");
+
+ return _parse<LicenseSpecTree, ParseTextDepSpec, true, true>(s,
+ true, ParseTextDepSpec());
}
diff --git a/paludis/portage_dep_parser.hh b/paludis/portage_dep_parser.hh
index ba4c7c2..f693c69 100644
--- a/paludis/portage_dep_parser.hh
+++ b/paludis/portage_dep_parser.hh
@@ -20,8 +20,10 @@
#ifndef PALUDIS_GUARD_PALUDIS_PORTAGE_DEP_PARSER_HH
#define PALUDIS_GUARD_PALUDIS_PORTAGE_DEP_PARSER_HH 1
+#include <paludis/portage_dep_parser-fwd.hh>
#include <paludis/dep_spec.hh>
#include <paludis/portage_dep_lexer.hh>
+#include <paludis/eapi-fwd.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/instantiation_policy.hh>
#include <string>
@@ -68,33 +70,6 @@ namespace paludis
};
/**
- * Interface provided by PortageDepParserPolicy classes.
- *
- * \see PortageDepParserPolicy
- *
- * \ingroup grpdepparser
- */
- struct PALUDIS_VISIBLE PortageDepParserPolicyInterface
- {
- /**
- * Create a new text spec from the provided string.
- */
- virtual tr1::shared_ptr<DepSpec> new_text_spec(const std::string &) const = 0;
-
- /**
- * Are || ( ) deps permitted?
- */
- virtual bool permit_any_deps() const = 0;
-
- /**
- * Destructor.
- */
- virtual ~PortageDepParserPolicyInterface()
- {
- }
- };
-
- /**
* The PortageDepParser converts string representations of a dependency
* specification into a DepSpec instance. The PortageDepLexer class is
* used as the first stage.
@@ -106,34 +81,39 @@ namespace paludis
{
private:
template <typename H_, typename I_, bool any_, bool use_>
- static tr1::shared_ptr<typename H_::ConstItem> _parse(const std::string &, const I_ & = I_());
+ static tr1::shared_ptr<typename H_::ConstItem> _parse(const std::string &,
+ bool disallow_any_use, const I_ &);
public:
/**
* Parse a dependency heirarchy.
*/
static tr1::shared_ptr<DependencySpecTree::ConstItem> parse_depend(const std::string & s,
- const PackageDepSpecParseMode);
+ const EAPI &);
/**
* Parse a provide heirarchy.
*/
- static tr1::shared_ptr<ProvideSpecTree::ConstItem> parse_provide(const std::string & s);
+ static tr1::shared_ptr<ProvideSpecTree::ConstItem> parse_provide(const std::string & s,
+ const EAPI &);
/**
* Parse a restrict.
*/
- static tr1::shared_ptr<RestrictSpecTree::ConstItem> parse_restrict(const std::string & s);
+ static tr1::shared_ptr<RestrictSpecTree::ConstItem> parse_restrict(const std::string & s,
+ const EAPI &);
/**
* Parse a uri heirarchy.
*/
- static tr1::shared_ptr<URISpecTree::ConstItem> parse_uri(const std::string & s);
+ static tr1::shared_ptr<URISpecTree::ConstItem> parse_uri(const std::string & s,
+ const EAPI &);
/**
* Parse a license heirarchy.
*/
- static tr1::shared_ptr<LicenseSpecTree::ConstItem> parse_license(const std::string & s);
+ static tr1::shared_ptr<LicenseSpecTree::ConstItem> parse_license(const std::string & s,
+ const EAPI &);
};
}
diff --git a/paludis/portage_dep_parser_TEST.cc b/paludis/portage_dep_parser_TEST.cc
index 0374012..f104605 100644
--- a/paludis/portage_dep_parser_TEST.cc
+++ b/paludis/portage_dep_parser_TEST.cc
@@ -44,7 +44,8 @@ namespace test_cases
void run()
{
DepSpecPrettyPrinter d(0, false);
- PortageDepParser::parse_depend("", pds_pm_permissive)->accept(d);
+ PortageDepParser::parse_depend("",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "");
}
} test_dep_spec_parser_empty;
@@ -60,7 +61,8 @@ namespace test_cases
void run()
{
DepSpecPrettyPrinter d(0, false);
- PortageDepParser::parse_depend(" \n \t", pds_pm_permissive)->accept(d);
+ PortageDepParser::parse_depend(" \n \t",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "");
}
} test_dep_spec_parser_blank;
@@ -76,7 +78,8 @@ namespace test_cases
void run()
{
DepSpecPrettyPrinter d(0, false);
- PortageDepParser::parse_depend("app-editors/vim", pds_pm_permissive)->accept(d);
+ PortageDepParser::parse_depend("app-editors/vim",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "app-editors/vim");
}
} test_dep_spec_parser_package;
@@ -92,15 +95,18 @@ namespace test_cases
void run()
{
DepSpecPrettyPrinter d1(0, false);
- PortageDepParser::parse_depend(">=app-editors/vim-6.4_alpha", pds_pm_permissive)->accept(d1);
+ PortageDepParser::parse_depend(">=app-editors/vim-6.4_alpha",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d1);
TEST_CHECK_EQUAL(stringify(d1), ">=app-editors/vim-6.4_alpha");
DepSpecPrettyPrinter d2(0, false);
- PortageDepParser::parse_depend("=app-editors/vim-6.4_alpha-r1", pds_pm_permissive)->accept(d2);
+ PortageDepParser::parse_depend("=app-editors/vim-6.4_alpha-r1",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d2);
TEST_CHECK_EQUAL(stringify(d2), "=app-editors/vim-6.4_alpha-r1");
DepSpecPrettyPrinter d3(0, false);
- PortageDepParser::parse_depend(">=app-editors/vim-6.4_alpha:one", pds_pm_permissive)->accept(d3);
+ PortageDepParser::parse_depend(">=app-editors/vim-6.4_alpha:one",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d3);
TEST_CHECK_EQUAL(stringify(d3), ">=app-editors/vim-6.4_alpha:one");
}
} test_dep_spec_parser_decorated_package;
@@ -116,7 +122,8 @@ namespace test_cases
void run()
{
DepSpecPrettyPrinter d(0, false);
- PortageDepParser::parse_depend("app-editors/vim app-misc/hilite \nsys-apps/findutils", pds_pm_permissive)->accept(d);
+ PortageDepParser::parse_depend("app-editors/vim app-misc/hilite \nsys-apps/findutils",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "app-editors/vim app-misc/hilite sys-apps/findutils");
}
} test_dep_spec_parser_packages;
@@ -132,7 +139,8 @@ namespace test_cases
void run()
{
DepSpecPrettyPrinter d(0, false);
- PortageDepParser::parse_depend("|| ( one/one two/two )", pds_pm_permissive)->accept(d);
+ PortageDepParser::parse_depend("|| ( one/one two/two )",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "|| ( one/one two/two )");
}
} test_dep_spec_parser_any;
@@ -148,7 +156,8 @@ namespace test_cases
void run()
{
DepSpecPrettyPrinter d(0, false);
- PortageDepParser::parse_depend(" ( one/one two/two ) ", pds_pm_permissive)->accept(d);
+ PortageDepParser::parse_depend(" ( one/one two/two ) ",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "one/one two/two");
}
} test_dep_spec_parser_all;
@@ -164,7 +173,7 @@ namespace test_cases
void run()
{
DepSpecPrettyPrinter d(0, false);
- PortageDepParser::parse_depend("foo? ( one/one )", pds_pm_permissive)->accept(d);
+ PortageDepParser::parse_depend("foo? ( one/one )", EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "foo? ( one/one )");
}
} test_dep_spec_parser_use;
@@ -180,7 +189,7 @@ namespace test_cases
void run()
{
DepSpecPrettyPrinter d(0, false);
- PortageDepParser::parse_depend("!foo? ( one/one )", pds_pm_permissive)->accept(d);
+ PortageDepParser::parse_depend("!foo? ( one/one )", EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "!foo? ( one/one )");
}
} test_dep_spec_parser_inv_use;
@@ -196,11 +205,16 @@ namespace test_cases
void run()
{
DepSpecPrettyPrinter d(0, false);
- TEST_CHECK_THROWS(PortageDepParser::parse_depend("!foo? ( one/one", pds_pm_permissive)->accept(d), DepStringError);
- TEST_CHECK_THROWS(PortageDepParser::parse_depend("!foo? ( one/one ) )", pds_pm_permissive)->accept(d), DepStringError);
- TEST_CHECK_THROWS(PortageDepParser::parse_depend("( ( ( ) )", pds_pm_permissive)->accept(d), DepStringError);
- TEST_CHECK_THROWS(PortageDepParser::parse_depend("( ( ( ) ) ) )", pds_pm_permissive)->accept(d), DepStringError);
- TEST_CHECK_THROWS(PortageDepParser::parse_depend(")", pds_pm_permissive)->accept(d), DepStringError);
+ TEST_CHECK_THROWS(PortageDepParser::parse_depend("!foo? ( one/one",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ TEST_CHECK_THROWS(PortageDepParser::parse_depend("!foo? ( one/one ) )",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ TEST_CHECK_THROWS(PortageDepParser::parse_depend("( ( ( ) )",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ TEST_CHECK_THROWS(PortageDepParser::parse_depend("( ( ( ) ) ) )",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ TEST_CHECK_THROWS(PortageDepParser::parse_depend(")",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
}
} test_dep_spec_parser_bad_nesting;
@@ -215,10 +229,14 @@ namespace test_cases
void run()
{
DepSpecPrettyPrinter d(0, false);
- TEST_CHECK_THROWS(PortageDepParser::parse_depend("!foo? ||", pds_pm_permissive)->accept(d), DepStringError);
- TEST_CHECK_THROWS(PortageDepParser::parse_depend("(((", pds_pm_permissive)->accept(d), DepStringError);
- TEST_CHECK_THROWS(PortageDepParser::parse_depend(")", pds_pm_permissive)->accept(d), DepStringError);
- TEST_CHECK_THROWS(PortageDepParser::parse_depend("(foo/bar)", pds_pm_permissive)->accept(d), DepStringError);
+ TEST_CHECK_THROWS(PortageDepParser::parse_depend("!foo? ||",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ TEST_CHECK_THROWS(PortageDepParser::parse_depend("(((",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ TEST_CHECK_THROWS(PortageDepParser::parse_depend(")",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ TEST_CHECK_THROWS(PortageDepParser::parse_depend("(foo/bar)",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
}
} test_dep_spec_parser_bad_values;
}
diff --git a/paludis/qa/parse_deps_check.cc b/paludis/qa/parse_deps_check.cc
index 934e713..6582715 100644
--- a/paludis/qa/parse_deps_check.cc
+++ b/paludis/qa/parse_deps_check.cc
@@ -46,7 +46,7 @@ ParseDepsCheck::operator() (const EbuildCheckData & e) const
try
{
std::string depend(metadata->deps_interface->get_raw_build_depend());
- PortageDepParser::parse_depend(depend, metadata->eapi.supported->strict_package_dep_spec_parse_mode);
+ PortageDepParser::parse_depend(depend, metadata->eapi);
}
catch (const Exception & err)
{
@@ -57,7 +57,7 @@ ParseDepsCheck::operator() (const EbuildCheckData & e) const
try
{
std::string rdepend(metadata->deps_interface->get_raw_run_depend());
- PortageDepParser::parse_depend(rdepend, metadata->eapi.supported->strict_package_dep_spec_parse_mode);
+ PortageDepParser::parse_depend(rdepend, metadata->eapi);
}
catch (const Exception & err)
{
@@ -68,7 +68,7 @@ ParseDepsCheck::operator() (const EbuildCheckData & e) const
try
{
std::string pdepend(metadata->deps_interface->get_raw_post_depend());
- PortageDepParser::parse_depend(pdepend, metadata->eapi.supported->strict_package_dep_spec_parse_mode);
+ PortageDepParser::parse_depend(pdepend, metadata->eapi);
}
catch (const Exception & err)
{
diff --git a/paludis/repositories/cran/cran_dep_parser.cc b/paludis/repositories/cran/cran_dep_parser.cc
index 0a8e8a6..505c4a6 100644
--- a/paludis/repositories/cran/cran_dep_parser.cc
+++ b/paludis/repositories/cran/cran_dep_parser.cc
@@ -11,10 +11,13 @@
using namespace paludis;
tr1::shared_ptr<DependencySpecTree::ConstItem>
-CRANDepParser::parse(const std::string & s, const PackageDepSpecParseMode mode)
+CRANDepParser::parse(const std::string & s, const EAPI & e)
{
Context context("When parsing CRAN 'Depends:' string: '" + s + "':");
+ if (! e.supported)
+ throw InternalError(PALUDIS_HERE, "Got bad EAPI '" + e.name + "' for a CRAN package");
+
tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > result(
new ConstTreeSequence<DependencySpecTree, AllDepSpec>(tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
@@ -58,7 +61,7 @@ CRANDepParser::parse(const std::string & s, const PackageDepSpecParseMode mode)
spec_string = range + name + "-" + version;
tr1::shared_ptr<TreeLeaf<DependencySpecTree, PackageDepSpec> > spec(
new TreeLeaf<DependencySpecTree, PackageDepSpec>(tr1::shared_ptr<PackageDepSpec>(
- new PackageDepSpec(spec_string, mode))));
+ new PackageDepSpec(spec_string, e.supported->package_dep_spec_parse_mode))));
result->add(spec);
}
diff --git a/paludis/repositories/cran/cran_dep_parser.hh b/paludis/repositories/cran/cran_dep_parser.hh
index 41d9721..93d5f7b 100644
--- a/paludis/repositories/cran/cran_dep_parser.hh
+++ b/paludis/repositories/cran/cran_dep_parser.hh
@@ -1,7 +1,8 @@
#ifndef PALUDIS_GUARD_PALUDIS_CRAN_DEP_PARSER_HH
#define PALUDIS_GUARD_PALUDIS_CRAN_DEP_PARSER_HH 1
-#include <paludis/dep_spec.hh>
+#include <paludis/dep_spec-fwd.hh>
+#include <paludis/eapi-fwd.hh>
#include <string>
namespace paludis
@@ -18,7 +19,7 @@ namespace paludis
* Parse function.
*/
static tr1::shared_ptr<DependencySpecTree::ConstItem> parse(const std::string & s,
- const PackageDepSpecParseMode);
+ const EAPI &);
};
}
diff --git a/paludis/repositories/cran/cran_dep_parser_TEST.cc b/paludis/repositories/cran/cran_dep_parser_TEST.cc
index 0294448..5de4ab1 100644
--- a/paludis/repositories/cran/cran_dep_parser_TEST.cc
+++ b/paludis/repositories/cran/cran_dep_parser_TEST.cc
@@ -50,15 +50,15 @@ namespace test_cases
DepSpecPrettyPrinter d1(0, false), d2(0, false), d3(0, false);
// test R dependency
std::string dep1("R (>= 2.0.0)");
- CRANDepParser::parse(dep1, pds_pm_permissive)->accept(d1);
+ CRANDepParser::parse(dep1, EAPIData::get_instance()->eapi_from_string("CRAN-1"))->accept(d1);
TEST_CHECK_EQUAL(stringify(d1), ">=dev-lang/R-2.0.0");
// test varying whitespaces
std::string dep2("testpackage1 \t(<1.9)");
- CRANDepParser::parse(dep2, pds_pm_permissive)->accept(d2);
+ CRANDepParser::parse(dep2, EAPIData::get_instance()->eapi_from_string("CRAN-1"))->accept(d2);
TEST_CHECK_EQUAL(stringify(d2), "<cran/testpackage1-1.9");
// test for package-name and version normalisation
std::string dep3("R.matlab (>= 2.3-1)");
- CRANDepParser::parse(dep3, pds_pm_permissive)->accept(d3);
+ CRANDepParser::parse(dep3, EAPIData::get_instance()->eapi_from_string("CRAN-1"))->accept(d3);
TEST_CHECK_EQUAL(stringify(d3), ">=cran/R-matlab-2.3.1");
}
} test_cran_dep_parser;
diff --git a/paludis/repositories/gentoo/vdb_repository.cc b/paludis/repositories/gentoo/vdb_repository.cc
index 3d69a68..2e58648 100644
--- a/paludis/repositories/gentoo/vdb_repository.cc
+++ b/paludis/repositories/gentoo/vdb_repository.cc
@@ -1330,7 +1330,7 @@ VDBRepository::load_provided_using_cache() const
PackageDatabaseEntry dbe(QualifiedPackageName(tokens.at(0)), VersionSpec(tokens.at(1)), name());
DepSpecFlattener f(_imp->env, &dbe);
tr1::shared_ptr<ProvideSpecTree::ConstItem> pp(PortageDepParser::parse_provide(
- join(next(next(tokens.begin())), tokens.end(), " ")));
+ join(next(next(tokens.begin())), tokens.end(), " "), EAPIData::get_instance()->eapi_from_string("paludis-1")));
pp->accept(f);
for (DepSpecFlattener::Iterator p(f.begin()), p_end(f.end()) ; p != p_end ; ++p)
@@ -1368,7 +1368,8 @@ VDBRepository::load_provided_the_slow_way() const
if (e->metadata)
provide = e->metadata->ebuild_interface->provide();
else
- provide = PortageDepParser::parse_provide(file_contents(_imp->location, e->name, e->version, "PROVIDE"));
+ provide = PortageDepParser::parse_provide(file_contents(_imp->location, e->name, e->version, "PROVIDE"),
+ EAPIData::get_instance()->eapi_from_string("paludis-1"));
PackageDatabaseEntry dbe(e->name, e->version, name());
DepSpecFlattener f(_imp->env, &dbe);
@@ -1447,7 +1448,8 @@ VDBRepository::regenerate_provides_cache() const
if (c->metadata)
provide = c->metadata->ebuild_interface->provide();
else
- provide = PortageDepParser::parse_provide(file_contents(_imp->location, c->name, c->version, "PROVIDE"));
+ provide = PortageDepParser::parse_provide(file_contents(_imp->location, c->name, c->version, "PROVIDE"),
+ EAPIData::get_instance()->eapi_from_string("paludis-1"));
DepSpecPrettyPrinter p(0, false);
provide->accept(p);
diff --git a/paludis/version_metadata.cc b/paludis/version_metadata.cc
index 901bfaa..9f5f2b1 100644
--- a/paludis/version_metadata.cc
+++ b/paludis/version_metadata.cc
@@ -78,7 +78,7 @@ tr1::shared_ptr<const DependencySpecTree::ConstItem>
VersionMetadataDepsInterface::_make_depend(const std::string & s) const
{
if (version_metadata()->eapi.supported)
- return parser(s, version_metadata()->eapi.supported->package_dep_spec_parse_mode);
+ return parser(s, version_metadata()->eapi);
else
{
Log::get_instance()->message(ll_warning, lc_context) <<
@@ -92,7 +92,7 @@ tr1::shared_ptr<const RestrictSpecTree::ConstItem>
VersionMetadataEbuildInterface::_make_restrict(const std::string & s) const
{
if (version_metadata()->eapi.supported)
- return PortageDepParser::parse_restrict(s);
+ return PortageDepParser::parse_restrict(s, version_metadata()->eapi);
else
{
Log::get_instance()->message(ll_warning, lc_context) <<
@@ -106,7 +106,7 @@ tr1::shared_ptr<const ProvideSpecTree::ConstItem>
VersionMetadataEbuildInterface::_make_provide(const std::string & s) const
{
if (version_metadata()->eapi.supported)
- return PortageDepParser::parse_provide(s);
+ return PortageDepParser::parse_provide(s, version_metadata()->eapi);
else
{
Log::get_instance()->message(ll_warning, lc_context) <<
@@ -119,7 +119,15 @@ VersionMetadataEbuildInterface::_make_provide(const std::string & s) const
tr1::shared_ptr<const LicenseSpecTree::ConstItem>
VersionMetadataLicenseInterface::_make_license(const std::string & s) const
{
- return parser(s);
+ if (version_metadata()->eapi.supported)
+ return parser(s, version_metadata()->eapi);
+ else
+ {
+ Log::get_instance()->message(ll_warning, lc_context) <<
+ "Don't know how to parse license strings for EAPI '" + version_metadata()->eapi.name + "'";
+ return tr1::shared_ptr<LicenseSpecTree::ConstItem>(new ConstTreeSequence<LicenseSpecTree, AllDepSpec>(
+ tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
+ }
}
template <typename Item_, typename Container_>
@@ -155,19 +163,19 @@ VersionMetadataEbuildInterface::_make_iuse_collection(const std::string & s) con
tr1::shared_ptr<const URISpecTree::ConstItem>
VersionMetadataEbinInterface::_make_uri(const std::string & s) const
{
- return PortageDepParser::parse_uri(s);
+ return PortageDepParser::parse_uri(s, version_metadata()->eapi);
}
tr1::shared_ptr<const URISpecTree::ConstItem>
VersionMetadataEbuildInterface::_make_uri(const std::string & s) const
{
- return PortageDepParser::parse_uri(s);
+ return PortageDepParser::parse_uri(s, version_metadata()->eapi);
}
tr1::shared_ptr<const URISpecTree::ConstItem>
VersionMetadataBase::_make_text(const std::string & s) const
{
- return PortageDepParser::parse_uri(s);
+ return PortageDepParser::parse_uri(s, version_metadata()->eapi);
}
template <typename Item_, typename Container_>
diff --git a/paludis/version_metadata.hh b/paludis/version_metadata.hh
index 42cb01e..60c92e9 100644
--- a/paludis/version_metadata.hh
+++ b/paludis/version_metadata.hh
@@ -77,14 +77,15 @@ namespace paludis
* \ingroup grpversions
*/
typedef tr1::shared_ptr<DependencySpecTree::ConstItem> (* DepParserFunction) (const std::string &,
- const PackageDepSpecParseMode);
+ const EAPI &);
/**
* A pointer to a parse function for text.
*
* \ingroup grpversions
*/
- typedef tr1::shared_ptr<LicenseSpecTree::ConstItem> (* LicenseParserFunction) (const std::string &);
+ typedef tr1::shared_ptr<LicenseSpecTree::ConstItem> (* LicenseParserFunction) (const std::string &,
+ const EAPI &);
#include <paludis/version_metadata-sr.hh>