aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/dep_spec.cc43
-rw-r--r--python/dep_spec.hh14
-rw-r--r--python/nice_names.nn1
3 files changed, 58 insertions, 0 deletions
diff --git a/python/dep_spec.cc b/python/dep_spec.cc
index 9f544929a..7e109162b 100644
--- a/python/dep_spec.cc
+++ b/python/dep_spec.cc
@@ -152,6 +152,14 @@ PythonExactlyOneDepSpec::PythonExactlyOneDepSpec(const ExactlyOneDepSpec &)
{
}
+PythonAtMostOneDepSpec::PythonAtMostOneDepSpec()
+{
+}
+
+PythonAtMostOneDepSpec::PythonAtMostOneDepSpec(const AtMostOneDepSpec &)
+{
+}
+
PythonAllDepSpec::PythonAllDepSpec()
{
}
@@ -539,6 +547,15 @@ SpecTreeToPython::visit(const GenericSpecTree::NodeType<ExactlyOneDepSpec>::Type
}
void
+SpecTreeToPython::visit(const GenericSpecTree::NodeType<AtMostOneDepSpec>::Type & node)
+{
+ std::shared_ptr<PythonAtMostOneDepSpec> py_cds(std::make_shared<PythonAtMostOneDepSpec>(*node.spec()));
+ _current_parent->add_child(py_cds);
+ Save<std::shared_ptr<PythonCompositeDepSpec> > old_parent(&_current_parent, py_cds);
+ std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this));
+}
+
+void
SpecTreeToPython::visit(const GenericSpecTree::NodeType<ConditionalDepSpec>::Type & node)
{
std::shared_ptr<PythonConditionalDepSpec> py_cds(std::make_shared<PythonConditionalDepSpec>(*node.spec()));
@@ -657,6 +674,7 @@ struct AllowedTypes<RequiredUseSpecTree>
AllowedTypes(const AllDepSpec &) {};
AllowedTypes(const AnyDepSpec &) {};
AllowedTypes(const ExactlyOneDepSpec &) {};
+ AllowedTypes(const AtMostOneDepSpec &) {};
AllowedTypes(const ConditionalDepSpec &) {};
AllowedTypes(const PlainTextDepSpec &) {};
};
@@ -758,6 +776,13 @@ SpecTreeFromPython<H_>::visit(const PythonExactlyOneDepSpec & d)
template <typename H_>
void
+SpecTreeFromPython<H_>::visit(const PythonAtMostOneDepSpec & d)
+{
+ dispatch<H_, AtMostOneDepSpec>(this, d);
+}
+
+template <typename H_>
+void
SpecTreeFromPython<H_>::visit(const PythonConditionalDepSpec & d)
{
dispatch<H_, ConditionalDepSpec>(this, d);
@@ -859,6 +884,14 @@ SpecTreeFromPython<H_>::real_visit(const PythonExactlyOneDepSpec & d)
template <typename H_>
void
+SpecTreeFromPython<H_>::real_visit(const PythonAtMostOneDepSpec & d)
+{
+ Save<std::shared_ptr<typename H_::BasicInnerNode> > old_add_to(&_add_to, _add_to->append(std::make_shared<AtMostOneDepSpec>()));
+ std::for_each(indirect_iterator(d.begin()), indirect_iterator(d.end()), accept_visitor(*this));
+}
+
+template <typename H_>
+void
SpecTreeFromPython<H_>::real_visit(const PythonConditionalDepSpec & d)
{
Save<std::shared_ptr<typename H_::BasicInnerNode> > old_add_to(&_add_to, _add_to->append(std::make_shared<ConditionalDepSpec>(d.data())));
@@ -1123,6 +1156,16 @@ void expose_dep_spec()
);
/**
+ * AtMostOneDepSpec
+ */
+ bp::class_<PythonAtMostOneDepSpec, bp::bases<PythonCompositeDepSpec>, boost::noncopyable>
+ (
+ "AtMostOneDepSpec",
+ "Represents a \"?? ( )\" dependency block.",
+ bp::init<>("__init__()")
+ );
+
+ /**
* AllDepSpec
*/
bp::class_<PythonAllDepSpec, bp::bases<PythonCompositeDepSpec>, boost::noncopyable>
diff --git a/python/dep_spec.hh b/python/dep_spec.hh
index 1a10fc191..bd4825193 100644
--- a/python/dep_spec.hh
+++ b/python/dep_spec.hh
@@ -33,6 +33,7 @@ namespace paludis
class PythonAllDepSpec;
class PythonAnyDepSpec;
class PythonExactlyOneDepSpec;
+ class PythonAtMostOneDepSpec;
class PythonConditionalDepSpec;
class PythonStringDepSpec;
class PythonPlainTextDepSpec;
@@ -50,6 +51,7 @@ namespace paludis
public virtual DeclareAbstractAcceptMethods<PythonDepSpec, MakeTypeList<
PythonAnyDepSpec,
PythonExactlyOneDepSpec,
+ PythonAtMostOneDepSpec,
PythonAllDepSpec,
PythonConditionalDepSpec,
PythonBlockDepSpec,
@@ -115,6 +117,15 @@ namespace paludis
PythonExactlyOneDepSpec(const ExactlyOneDepSpec &);
};
+ class PALUDIS_VISIBLE PythonAtMostOneDepSpec :
+ public PythonCompositeDepSpec,
+ public ImplementAcceptMethods<PythonDepSpec, PythonAtMostOneDepSpec>
+ {
+ public:
+ PythonAtMostOneDepSpec();
+ PythonAtMostOneDepSpec(const AtMostOneDepSpec &);
+ };
+
class PALUDIS_VISIBLE PythonAllDepSpec :
public PythonCompositeDepSpec,
public ImplementAcceptMethods<PythonDepSpec, PythonAllDepSpec>
@@ -302,6 +313,7 @@ namespace paludis
void visit(const GenericSpecTree::NodeType<AllDepSpec>::Type &);
void visit(const GenericSpecTree::NodeType<AnyDepSpec>::Type &);
void visit(const GenericSpecTree::NodeType<ExactlyOneDepSpec>::Type &);
+ void visit(const GenericSpecTree::NodeType<AtMostOneDepSpec>::Type &);
void visit(const GenericSpecTree::NodeType<ConditionalDepSpec>::Type &);
void visit(const GenericSpecTree::NodeType<PackageDepSpec>::Type &);
@@ -339,6 +351,7 @@ namespace paludis
void visit(const PythonAllDepSpec &);
void visit(const PythonAnyDepSpec &);
void visit(const PythonExactlyOneDepSpec &);
+ void visit(const PythonAtMostOneDepSpec &);
void visit(const PythonConditionalDepSpec &);
void visit(const PythonPackageDepSpec &);
void visit(const PythonPlainTextDepSpec &);
@@ -354,6 +367,7 @@ namespace paludis
void real_visit(const PythonAllDepSpec &);
void real_visit(const PythonAnyDepSpec &);
void real_visit(const PythonExactlyOneDepSpec &);
+ void real_visit(const PythonAtMostOneDepSpec &);
void real_visit(const PythonConditionalDepSpec &);
void real_visit(const PythonPackageDepSpec &);
void real_visit(const PythonPlainTextDepSpec &);
diff --git a/python/nice_names.nn b/python/nice_names.nn
index 8494d26a0..da233373b 100644
--- a/python/nice_names.nn
+++ b/python/nice_names.nn
@@ -28,6 +28,7 @@ make_nn_NiceNames() {
name "AllDepSpec"
name "AnyDepSpec"
name "ExactlyOneDepSpec"
+ name "AtMostOneDepSpec"
name "ConditionalDepSpec"
name "BlockDepSpec"
name "StringDepSpec"