aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-12-04 22:03:40 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-12-04 22:03:40 +0000
commit57211c15f04a7fd382263319a154a555c757f09f (patch)
tree2e44e54591605475c0fdf061eceeae90d6a2c258
parentf2476fe77fe49511a4c22544bf2cbccbc5cfd6cb (diff)
downloadpaludis-57211c15f04a7fd382263319a154a555c757f09f.tar.gz
paludis-57211c15f04a7fd382263319a154a555c757f09f.tar.xz
GenericSpecTree can contain ExactlyOneDepSpec
-rw-r--r--paludis/repositories/e/dep_spec_pretty_printer.cc40
-rw-r--r--paludis/repositories/e/dep_spec_pretty_printer.hh3
-rw-r--r--paludis/spec_tree-fwd.hh3
-rw-r--r--paludis/spec_tree.cc2
-rw-r--r--paludis/user_dep_spec.cc6
-rw-r--r--python/dep_spec.cc42
-rw-r--r--python/dep_spec.hh14
-rw-r--r--python/nice_names.nn1
-rw-r--r--ruby/dep_spec.cc19
-rw-r--r--ruby/nice_names.nn1
-rw-r--r--src/clients/cave/cmd_match.cc5
-rw-r--r--src/clients/inquisitio/key_extractor.cc5
12 files changed, 139 insertions, 2 deletions
diff --git a/paludis/repositories/e/dep_spec_pretty_printer.cc b/paludis/repositories/e/dep_spec_pretty_printer.cc
index 5f20eb8..b679f1a 100644
--- a/paludis/repositories/e/dep_spec_pretty_printer.cc
+++ b/paludis/repositories/e/dep_spec_pretty_printer.cc
@@ -166,6 +166,10 @@ namespace
{
}
+ void visit(const GenericSpecTree::NodeType<ExactlyOneDepSpec>::Type &)
+ {
+ }
+
void visit(const GenericSpecTree::NodeType<AnyDepSpec>::Type &)
{
}
@@ -266,6 +270,42 @@ DepSpecPrettyPrinter::visit(const GenericSpecTree::NodeType<AnyDepSpec>::Type &
}
void
+DepSpecPrettyPrinter::visit(const GenericSpecTree::NodeType<ExactlyOneDepSpec>::Type & node)
+{
+ Save<bool> old_outer(&_imp->outer_block, false);
+ Save<bool> old_needs_parens(&_imp->all_needs_parens, true);
+
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.indent(_imp->indent);
+ else if (_imp->need_space)
+ _imp->s << " ";
+ _imp->s << "^^ (";
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.newline();
+ else
+ _imp->need_space = true;
+
+ {
+ Save<unsigned> old_indent(&_imp->indent, _imp->indent + 1);
+ Save<bool> extra_label_indent(&_imp->extra_label_indent, false);
+ std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this));
+ }
+
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.indent(_imp->indent);
+ else if (_imp->need_space)
+ _imp->s << " ";
+ _imp->s << ")";
+
+ do_annotations(*node.spec());
+
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.newline();
+ else
+ _imp->need_space = true;
+}
+
+void
DepSpecPrettyPrinter::visit(const GenericSpecTree::NodeType<ConditionalDepSpec>::Type & node)
{
Save<bool> old_outer(&_imp->outer_block, false);
diff --git a/paludis/repositories/e/dep_spec_pretty_printer.hh b/paludis/repositories/e/dep_spec_pretty_printer.hh
index 78c81c3..59d85c8 100644
--- a/paludis/repositories/e/dep_spec_pretty_printer.hh
+++ b/paludis/repositories/e/dep_spec_pretty_printer.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009, 2010 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
@@ -93,6 +93,7 @@ namespace paludis
void visit(const GenericSpecTree::NodeType<AllDepSpec>::Type & node);
void visit(const GenericSpecTree::NodeType<AnyDepSpec>::Type & node);
+ void visit(const GenericSpecTree::NodeType<ExactlyOneDepSpec>::Type & node);
void visit(const GenericSpecTree::NodeType<ConditionalDepSpec>::Type & node);
void visit(const GenericSpecTree::NodeType<PackageDepSpec>::Type & node);
void visit(const GenericSpecTree::NodeType<BlockDepSpec>::Type & node);
diff --git a/paludis/spec_tree-fwd.hh b/paludis/spec_tree-fwd.hh
index 90549ec..f4da151 100644
--- a/paludis/spec_tree-fwd.hh
+++ b/paludis/spec_tree-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2008, 2009, 2010 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
@@ -83,6 +83,7 @@ namespace paludis
SpecTreeLeafNodeType<NamedSetDepSpec>,
SpecTreeInnerNodeType<AllDepSpec>,
SpecTreeInnerNodeType<AnyDepSpec>,
+ SpecTreeInnerNodeType<ExactlyOneDepSpec>,
SpecTreeInnerNodeType<ConditionalDepSpec>
>::Type, AllDepSpec> GenericSpecTree;
diff --git a/paludis/spec_tree.cc b/paludis/spec_tree.cc
index 9825165..2166aba 100644
--- a/paludis/spec_tree.cc
+++ b/paludis/spec_tree.cc
@@ -189,6 +189,7 @@ template class SpecTree<MakeTypeList<
SpecTreeLeafNodeType<NamedSetDepSpec>,
SpecTreeInnerNodeType<AllDepSpec>,
SpecTreeInnerNodeType<AnyDepSpec>,
+ SpecTreeInnerNodeType<ExactlyOneDepSpec>,
SpecTreeInnerNodeType<ConditionalDepSpec>
>::Type, AllDepSpec>;
@@ -269,6 +270,7 @@ template class LeafNode<GenericSpecTree, LicenseDepSpec>;
template class LeafNode<GenericSpecTree, URILabelsDepSpec>;
template class InnerNode<GenericSpecTree, AllDepSpec>;
template class InnerNode<GenericSpecTree, AnyDepSpec>;
+template class InnerNode<GenericSpecTree, ExactlyOneDepSpec>;
template class InnerNode<GenericSpecTree, ConditionalDepSpec>;
/* DependencySpecTree */
diff --git a/paludis/user_dep_spec.cc b/paludis/user_dep_spec.cc
index ce4b7a2..cdc2274 100644
--- a/paludis/user_dep_spec.cc
+++ b/paludis/user_dep_spec.cc
@@ -429,6 +429,12 @@ namespace
accept_visitor_returning<bool>(*this));
}
+ bool visit(const GenericSpecTree::NodeType<ExactlyOneDepSpec>::Type & n) const
+ {
+ return indirect_iterator(n.end()) != std::find_if(indirect_iterator(n.begin()), indirect_iterator(n.end()),
+ accept_visitor_returning<bool>(*this));
+ }
+
bool visit(const GenericSpecTree::NodeType<ConditionalDepSpec>::Type & n) const
{
if (n.spec()->condition_met())
diff --git a/python/dep_spec.cc b/python/dep_spec.cc
index 0d568a4..a631f58 100644
--- a/python/dep_spec.cc
+++ b/python/dep_spec.cc
@@ -148,6 +148,14 @@ PythonAnyDepSpec::PythonAnyDepSpec(const AnyDepSpec &)
{
}
+PythonExactlyOneDepSpec::PythonExactlyOneDepSpec()
+{
+}
+
+PythonExactlyOneDepSpec::PythonExactlyOneDepSpec(const ExactlyOneDepSpec &)
+{
+}
+
PythonAllDepSpec::PythonAllDepSpec()
{
}
@@ -548,6 +556,15 @@ SpecTreeToPython::visit(const GenericSpecTree::NodeType<AnyDepSpec>::Type & node
}
void
+SpecTreeToPython::visit(const GenericSpecTree::NodeType<ExactlyOneDepSpec>::Type & node)
+{
+ std::shared_ptr<PythonExactlyOneDepSpec> py_cds(std::make_shared<PythonExactlyOneDepSpec>(*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()));
@@ -758,6 +775,13 @@ SpecTreeFromPython<H_>::visit(const PythonAnyDepSpec & d)
template <typename H_>
void
+SpecTreeFromPython<H_>::visit(const PythonExactlyOneDepSpec & d)
+{
+ dispatch<H_, ExactlyOneDepSpec>(this, d);
+}
+
+template <typename H_>
+void
SpecTreeFromPython<H_>::visit(const PythonConditionalDepSpec & d)
{
dispatch<H_, ConditionalDepSpec>(this, d);
@@ -851,6 +875,14 @@ SpecTreeFromPython<H_>::real_visit(const PythonAnyDepSpec & d)
template <typename H_>
void
+SpecTreeFromPython<H_>::real_visit(const PythonExactlyOneDepSpec & d)
+{
+ Save<std::shared_ptr<typename H_::BasicInnerNode> > old_add_to(&_add_to, _add_to->append(std::make_shared<ExactlyOneDepSpec>()));
+ 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())));
@@ -1108,6 +1140,16 @@ void expose_dep_spec()
);
/**
+ * ExactlyOneDepSpec
+ */
+ bp::class_<PythonExactlyOneDepSpec, bp::bases<PythonCompositeDepSpec>, boost::noncopyable>
+ (
+ "ExactlyOneDepSpec",
+ "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 466a5ea..08ab372 100644
--- a/python/dep_spec.hh
+++ b/python/dep_spec.hh
@@ -32,6 +32,7 @@ namespace paludis
class PythonCompositeDepSpec;
class PythonAllDepSpec;
class PythonAnyDepSpec;
+ class PythonExactlyOneDepSpec;
class PythonConditionalDepSpec;
class PythonStringDepSpec;
class PythonPlainTextDepSpec;
@@ -48,6 +49,7 @@ namespace paludis
class PALUDIS_VISIBLE PythonDepSpec :
public virtual DeclareAbstractAcceptMethods<PythonDepSpec, MakeTypeList<
PythonAnyDepSpec,
+ PythonExactlyOneDepSpec,
PythonAllDepSpec,
PythonConditionalDepSpec,
PythonBlockDepSpec,
@@ -102,6 +104,15 @@ namespace paludis
PythonAnyDepSpec(const AnyDepSpec &);
};
+ class PALUDIS_VISIBLE PythonExactlyOneDepSpec :
+ public PythonCompositeDepSpec,
+ public ImplementAcceptMethods<PythonDepSpec, PythonExactlyOneDepSpec>
+ {
+ public:
+ PythonExactlyOneDepSpec();
+ PythonExactlyOneDepSpec(const ExactlyOneDepSpec &);
+ };
+
class PALUDIS_VISIBLE PythonAllDepSpec :
public PythonCompositeDepSpec,
public ImplementAcceptMethods<PythonDepSpec, PythonAllDepSpec>
@@ -290,6 +301,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<ConditionalDepSpec>::Type &);
void visit(const GenericSpecTree::NodeType<PackageDepSpec>::Type &);
@@ -326,6 +338,7 @@ namespace paludis
void visit(const PythonAllDepSpec &);
void visit(const PythonAnyDepSpec &);
+ void visit(const PythonExactlyOneDepSpec &);
void visit(const PythonConditionalDepSpec &);
void visit(const PythonPackageDepSpec &);
void visit(const PythonPlainTextDepSpec &);
@@ -340,6 +353,7 @@ namespace paludis
void real_visit(const PythonAllDepSpec &);
void real_visit(const PythonAnyDepSpec &);
+ void real_visit(const PythonExactlyOneDepSpec &);
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 b7f5cf2..5ef30e6 100644
--- a/python/nice_names.nn
+++ b/python/nice_names.nn
@@ -27,6 +27,7 @@ make_nn_NiceNames() {
name "SimpleURIDepSpec"
name "AllDepSpec"
name "AnyDepSpec"
+ name "ExactlyOneDepSpec"
name "ConditionalDepSpec"
name "BlockDepSpec"
name "StringDepSpec"
diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc
index aacaf70..1550683 100644
--- a/ruby/dep_spec.cc
+++ b/ruby/dep_spec.cc
@@ -59,6 +59,7 @@ namespace
static VALUE c_all_dep_spec;
static VALUE c_any_dep_spec;
+ static VALUE c_exactly_one_dep_spec;
static VALUE c_conditional_dep_spec;
static VALUE c_version_requirements_mode;
@@ -130,6 +131,7 @@ namespace
WrappedSpec<NamedSetDepSpec>,
WrappedSpec<AllDepSpec>,
WrappedSpec<AnyDepSpec>,
+ WrappedSpec<ExactlyOneDepSpec>,
WrappedSpec<ConditionalDepSpec>
>::Type>
{
@@ -265,6 +267,12 @@ namespace
wrapped.reset((new WrappedSpec<AnyDepSpec>(std::static_pointer_cast<AnyDepSpec>(node.spec()->clone())))->add_children(node.begin(), node.end()));
klass = c_any_dep_spec;
}
+
+ void visit(const GenericSpecTree::NodeType<ExactlyOneDepSpec>::Type & node)
+ {
+ wrapped.reset((new WrappedSpec<ExactlyOneDepSpec>(std::static_pointer_cast<ExactlyOneDepSpec>(node.spec()->clone())))->add_children(node.begin(), node.end()));
+ klass = c_exactly_one_dep_spec;
+ }
};
template <typename T_>
@@ -1123,6 +1131,17 @@ namespace
rb_define_method(c_any_dep_spec, "each", RUBY_FUNC_CAST((&Composite<AllDepSpec>::each)), 0);
/*
+ * Document-class: Paludis::ExactlyOneDepSpec
+ *
+ * Represents a "^^ ( )" dependency block. Includes
+ * Enumerable[http://www.ruby-doc.org/core/classes/Enumerable.html].
+ */
+ c_exactly_one_dep_spec = rb_define_class_under(paludis_module(), "ExactlyOneDepSpec", c_dep_spec);
+ rb_funcall(c_exactly_one_dep_spec, rb_intern("private_class_method"), 1, rb_str_new2("new"));
+ rb_include_module(c_exactly_one_dep_spec, rb_mEnumerable);
+ rb_define_method(c_exactly_one_dep_spec, "each", RUBY_FUNC_CAST((&Composite<AllDepSpec>::each)), 0);
+
+ /*
* Document-class: Paludis::ConditionalDepSpec
*
* Represents a use? ( ) dependency spec. Includes
diff --git a/ruby/nice_names.nn b/ruby/nice_names.nn
index d923538..3752a25 100644
--- a/ruby/nice_names.nn
+++ b/ruby/nice_names.nn
@@ -24,6 +24,7 @@ make_nn_NiceNames() {
name "SimpleURIDepSpec"
name "AllDepSpec"
name "AnyDepSpec"
+ name "ExactlyOneDepSpec"
name "ConditionalDepSpec"
name "BlockDepSpec"
name "StringDepSpec"
diff --git a/src/clients/cave/cmd_match.cc b/src/clients/cave/cmd_match.cc
index 077f6cc..18c2f9b 100644
--- a/src/clients/cave/cmd_match.cc
+++ b/src/clients/cave/cmd_match.cc
@@ -175,6 +175,11 @@ namespace
std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this));
}
+ void visit(const GenericSpecTree::NodeType<ExactlyOneDepSpec>::Type & node)
+ {
+ std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this));
+ }
+
void visit(const GenericSpecTree::NodeType<SimpleURIDepSpec>::Type & node)
{
texts.push_back(stringify(*node.spec()));
diff --git a/src/clients/inquisitio/key_extractor.cc b/src/clients/inquisitio/key_extractor.cc
index 04e56f1..186a4aa 100644
--- a/src/clients/inquisitio/key_extractor.cc
+++ b/src/clients/inquisitio/key_extractor.cc
@@ -104,6 +104,11 @@ namespace
std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this));
}
+ void visit(const GenericSpecTree::NodeType<ExactlyOneDepSpec>::Type & node)
+ {
+ std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this));
+ }
+
void visit(const GenericSpecTree::NodeType<ConditionalDepSpec>::Type & node)
{
if (! result)