aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-02-15 11:36:47 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-02-15 11:36:47 +0000
commit7e125b4740d8bb50aa06b97d1dc070dfbce8bb3a (patch)
treea690976211d4e380d4ffbccfdf5ae53d7b0f1e38 /python
parentae7109237069623709637fd16b0230dddcccda8d (diff)
downloadpaludis-7e125b4740d8bb50aa06b97d1dc070dfbce8bb3a.tar.gz
paludis-7e125b4740d8bb50aa06b97d1dc070dfbce8bb3a.tar.xz
Start removing the global concept of use flags: rename UseDepSpec to ConditionalDepSpec, move the descent logic into the spec.
Diffstat (limited to 'python')
-rw-r--r--python/dep_spec.cc98
-rw-r--r--python/dep_spec.hh31
-rw-r--r--python/formatter.cc36
-rw-r--r--python/nice_names.nn4
4 files changed, 84 insertions, 85 deletions
diff --git a/python/dep_spec.cc b/python/dep_spec.cc
index b89bbad..e58da2b 100644
--- a/python/dep_spec.cc
+++ b/python/dep_spec.cc
@@ -46,7 +46,7 @@ template class ConstAcceptInterface<PythonDepSpecVisitorTypes>;
template class ConstAcceptInterfaceVisitsThis<PythonDepSpecVisitorTypes, PythonAllDepSpec>;
template class ConstAcceptInterfaceVisitsThis<PythonDepSpecVisitorTypes, PythonAnyDepSpec>;
-template class ConstAcceptInterfaceVisitsThis<PythonDepSpecVisitorTypes, PythonUseDepSpec>;
+template class ConstAcceptInterfaceVisitsThis<PythonDepSpecVisitorTypes, PythonConditionalDepSpec>;
template class ConstAcceptInterfaceVisitsThis<PythonDepSpecVisitorTypes, PythonPackageDepSpec>;
template class ConstAcceptInterfaceVisitsThis<PythonDepSpecVisitorTypes, PythonBlockDepSpec>;
template class ConstAcceptInterfaceVisitsThis<PythonDepSpecVisitorTypes, PythonPlainTextDepSpec>;
@@ -59,7 +59,7 @@ template class ConstAcceptInterfaceVisitsThis<PythonDepSpecVisitorTypes, PythonN
template class Visits<const PythonAllDepSpec>;
template class Visits<const PythonAnyDepSpec>;
-template class Visits<const PythonUseDepSpec>;
+template class Visits<const PythonConditionalDepSpec>;
template class Visits<const PythonPackageDepSpec>;
template class Visits<const PythonBlockDepSpec>;
template class Visits<const PythonPlainTextDepSpec>;
@@ -81,8 +81,8 @@ PythonDepSpec::~PythonDepSpec()
{
}
-const PythonUseDepSpec *
-PythonDepSpec::as_use_dep_spec() const
+const PythonConditionalDepSpec *
+PythonDepSpec::as_conditional_dep_spec() const
{
return 0;
}
@@ -184,34 +184,33 @@ PythonAllDepSpec::PythonAllDepSpec(const AllDepSpec &)
{
}
-PythonUseDepSpec::PythonUseDepSpec(const UseFlagName & our_flag, bool is_inverse) :
- _flag(our_flag),
- _inverse(is_inverse)
+PythonConditionalDepSpec::PythonConditionalDepSpec(const ConditionalDepSpec & d) :
+ _data(d.data())
{
}
-PythonUseDepSpec::PythonUseDepSpec(const UseDepSpec & d) :
- _flag(d.flag()),
- _inverse(d.inverse())
+const PythonConditionalDepSpec *
+PythonConditionalDepSpec::as_conditional_dep_spec() const
{
+ return this;
}
-const PythonUseDepSpec *
-PythonUseDepSpec::as_use_dep_spec() const
+bool
+PythonConditionalDepSpec::condition_met() const
{
- return this;
+ return _data->condition_met();
}
-UseFlagName
-PythonUseDepSpec::flag() const
+bool
+PythonConditionalDepSpec::condition_meetable() const
{
- return _flag;
+ return _data->condition_meetable();
}
-bool
-PythonUseDepSpec::inverse() const
+const tr1::shared_ptr<const ConditionalDepSpecData>
+PythonConditionalDepSpec::data() const
{
- return _inverse;
+ return _data;
}
PythonStringDepSpec::PythonStringDepSpec(const std::string & s) :
@@ -572,11 +571,11 @@ SpecTreeToPython::visit_sequence(const AnyDepSpec & d,
}
void
-SpecTreeToPython::visit_sequence(const UseDepSpec & d,
+SpecTreeToPython::visit_sequence(const ConditionalDepSpec & d,
GenericSpecTree::ConstSequenceIterator cur,
GenericSpecTree::ConstSequenceIterator end)
{
- tr1::shared_ptr<PythonUseDepSpec> py_cds(new PythonUseDepSpec(d));
+ tr1::shared_ptr<PythonConditionalDepSpec> py_cds(new PythonConditionalDepSpec(d));
_current_parent->add_child(py_cds);
Save<tr1::shared_ptr<PythonCompositeDepSpec> > old_parent(&_current_parent, py_cds);
std::for_each(cur, end, accept_visitor(*this));
@@ -650,7 +649,7 @@ struct AllowedTypes<LicenseSpecTree>
{
AllowedTypes(const AllDepSpec &) {};
AllowedTypes(const AnyDepSpec &) {};
- AllowedTypes(const UseDepSpec &) {};
+ AllowedTypes(const ConditionalDepSpec &) {};
AllowedTypes(const LicenseDepSpec &) {};
};
@@ -658,7 +657,7 @@ template<>
struct AllowedTypes<FetchableURISpecTree>
{
AllowedTypes(const AllDepSpec &) {};
- AllowedTypes(const UseDepSpec &) {};
+ AllowedTypes(const ConditionalDepSpec &) {};
AllowedTypes(const FetchableURISpecTree &) {};
AllowedTypes(const URILabelsDepSpec &) {};
};
@@ -667,7 +666,7 @@ template<>
struct AllowedTypes<SimpleURISpecTree>
{
AllowedTypes(const AllDepSpec &) {};
- AllowedTypes(const UseDepSpec &) {};
+ AllowedTypes(const ConditionalDepSpec &) {};
AllowedTypes(const SimpleURIDepSpec &) {};
};
@@ -675,7 +674,7 @@ template<>
struct AllowedTypes<ProvideSpecTree>
{
AllowedTypes(const AllDepSpec &) {};
- AllowedTypes(const UseDepSpec &) {};
+ AllowedTypes(const ConditionalDepSpec &) {};
AllowedTypes(const PackageDepSpec &) {};
};
@@ -683,7 +682,7 @@ template<>
struct AllowedTypes<RestrictSpecTree>
{
AllowedTypes(const AllDepSpec &) {};
- AllowedTypes(const UseDepSpec &) {};
+ AllowedTypes(const ConditionalDepSpec &) {};
AllowedTypes(const PlainTextDepSpec &) {};
};
@@ -692,7 +691,7 @@ struct AllowedTypes<DependencySpecTree>
{
AllowedTypes(const AllDepSpec &) {};
AllowedTypes(const AnyDepSpec &) {};
- AllowedTypes(const UseDepSpec &) {};
+ AllowedTypes(const ConditionalDepSpec &) {};
AllowedTypes(const PackageDepSpec &) {};
AllowedTypes(const BlockDepSpec &) {};
AllowedTypes(const DependencyLabelsDepSpec &) {};
@@ -777,9 +776,9 @@ SpecTreeFromPython<H_>::visit(const PythonAnyDepSpec & d)
template <typename H_>
void
-SpecTreeFromPython<H_>::visit(const PythonUseDepSpec & d)
+SpecTreeFromPython<H_>::visit(const PythonConditionalDepSpec & d)
{
- dispatch<H_, UseDepSpec>(this, d);
+ dispatch<H_, ConditionalDepSpec>(this, d);
}
template <typename H_>
@@ -879,16 +878,16 @@ SpecTreeFromPython<H_>::real_visit(const PythonAnyDepSpec & d)
template <typename H_>
void
-SpecTreeFromPython<H_>::real_visit(const PythonUseDepSpec & d)
+SpecTreeFromPython<H_>::real_visit(const PythonConditionalDepSpec & d)
{
- tr1::shared_ptr<ConstTreeSequence<H_, UseDepSpec> > cds(
- new ConstTreeSequence<H_, UseDepSpec>(make_shared_ptr(
- new UseDepSpec(d.flag(), d.inverse()))));
+ tr1::shared_ptr<ConstTreeSequence<H_, ConditionalDepSpec> > cds(
+ new ConstTreeSequence<H_, ConditionalDepSpec>(make_shared_ptr(
+ new ConditionalDepSpec(d.data()))));
_add(cds);
Save<tr1::function<void (tr1::shared_ptr<ConstAcceptInterface<H_> >)> > old_add(&_add,
- tr1::bind(&ConstTreeSequence<H_, UseDepSpec>::add, cds, tr1::placeholders::_1));
+ tr1::bind(&ConstTreeSequence<H_, ConditionalDepSpec>::add, cds, tr1::placeholders::_1));
std::for_each(IndirectIterator<PythonCompositeDepSpec::ConstIterator, const PythonDepSpec>(d.begin()),
IndirectIterator<PythonCompositeDepSpec::ConstIterator, const PythonDepSpec>(d.end()),
accept_visitor(*this));
@@ -1092,10 +1091,10 @@ void expose_dep_spec()
"Base class for a dependency spec.",
bp::no_init
)
- .def("as_use_dep_spec", &PythonDepSpec::as_use_dep_spec,
+ .def("as_conditional_dep_spec", &PythonDepSpec::as_conditional_dep_spec,
bp::return_value_policy<bp::reference_existing_object>(),
- "as_use_dep_spec() -> UseDepSpec\n"
- "Return us as a UseDepSpec, or None if we are not a UseDepSpec."
+ "as_conditional_dep_spec() -> ConditionalDepSpec\n"
+ "Return us as a ConditionalDepSpec, or None if we are not a ConditionalDepSpec."
)
.def("as_package_dep_spec", &PythonDepSpec::as_package_dep_spec,
@@ -1141,23 +1140,22 @@ void expose_dep_spec()
);
/**
- * UseDepSpec
+ * ConditionalDepSpec
*/
- bp::class_<PythonUseDepSpec, bp::bases<PythonCompositeDepSpec>, boost::noncopyable>
+ bp::class_<PythonConditionalDepSpec, bp::bases<PythonCompositeDepSpec>, boost::noncopyable>
(
- "UseDepSpec",
+ "ConditionalDepSpec",
"Represents a use? ( ) dependency spec.",
- bp::init<const UseFlagName &, bool>("__init__(UseFlagName, inverse_bool)")
+ bp::no_init
)
- .add_property("flag", &UseDepSpec::flag,
- "[ro] UseFlagName\n"
- "Our use flag name."
- )
-
- .add_property("inverse", &UseDepSpec::inverse,
- "[ro] bool\n"
- "Are we a ! flag?"
- )
+ .def("condition_met", &PythonConditionalDepSpec::condition_met,
+ "condition_met() -> bool\n"
+ "Is our condition met?"
+ )
+ .def("condition_meetable", &PythonConditionalDepSpec::condition_meetable,
+ "condition_met() -> bool\n"
+ "Is our condition meetable?"
+ )
;
/**
diff --git a/python/dep_spec.hh b/python/dep_spec.hh
index 98f8638..687dad3 100644
--- a/python/dep_spec.hh
+++ b/python/dep_spec.hh
@@ -32,7 +32,7 @@ namespace paludis
class PythonCompositeDepSpec;
class PythonAllDepSpec;
class PythonAnyDepSpec;
- class PythonUseDepSpec;
+ class PythonConditionalDepSpec;
class PythonStringDepSpec;
class PythonPlainTextDepSpec;
class PythonLicenseDepSpec;
@@ -50,7 +50,7 @@ namespace paludis
PythonDepSpec,
PythonAnyDepSpec,
PythonAllDepSpec,
- PythonUseDepSpec,
+ PythonConditionalDepSpec,
PythonBlockDepSpec,
PythonPlainTextDepSpec,
PythonLicenseDepSpec,
@@ -74,7 +74,7 @@ namespace paludis
public:
virtual ~PythonDepSpec();
- virtual const PythonUseDepSpec * as_use_dep_spec() const
+ virtual const PythonConditionalDepSpec * as_conditional_dep_spec() const
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const PythonPackageDepSpec * as_package_dep_spec() const
@@ -120,21 +120,22 @@ namespace paludis
PythonAllDepSpec(const AllDepSpec &);
};
- class PALUDIS_VISIBLE PythonUseDepSpec :
+ class PALUDIS_VISIBLE PythonConditionalDepSpec :
public PythonCompositeDepSpec,
- public ConstAcceptInterfaceVisitsThis<PythonDepSpecVisitorTypes, PythonUseDepSpec>
+ public ConstAcceptInterfaceVisitsThis<PythonDepSpecVisitorTypes, PythonConditionalDepSpec>
{
private:
- const UseFlagName _flag;
- const bool _inverse;
+ const tr1::shared_ptr<const ConditionalDepSpecData> _data;
public:
- PythonUseDepSpec(const UseFlagName &, bool);
- PythonUseDepSpec(const UseDepSpec &);
+ PythonConditionalDepSpec(const ConditionalDepSpec &);
- UseFlagName flag() const;
- bool inverse() const;
- virtual const PythonUseDepSpec * as_use_dep_spec() const;
+ virtual const PythonConditionalDepSpec * as_conditional_dep_spec() const;
+
+ bool condition_met() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ bool condition_meetable() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ const tr1::shared_ptr<const ConditionalDepSpecData> data() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
class PALUDIS_VISIBLE PythonStringDepSpec :
@@ -296,7 +297,7 @@ namespace paludis
GenericSpecTree::ConstSequenceIterator,
GenericSpecTree::ConstSequenceIterator);
- void visit_sequence(const UseDepSpec &,
+ void visit_sequence(const ConditionalDepSpec &,
GenericSpecTree::ConstSequenceIterator,
GenericSpecTree::ConstSequenceIterator);
@@ -340,7 +341,7 @@ namespace paludis
void visit(const PythonAllDepSpec &);
void visit(const PythonAnyDepSpec &);
- void visit(const PythonUseDepSpec &);
+ void visit(const PythonConditionalDepSpec &);
void visit(const PythonPackageDepSpec &);
void visit(const PythonPlainTextDepSpec &);
void visit(const PythonBlockDepSpec &);
@@ -353,7 +354,7 @@ namespace paludis
void real_visit(const PythonAllDepSpec &);
void real_visit(const PythonAnyDepSpec &);
- void real_visit(const PythonUseDepSpec &);
+ void real_visit(const PythonConditionalDepSpec &);
void real_visit(const PythonPackageDepSpec &);
void real_visit(const PythonPlainTextDepSpec &);
void real_visit(const PythonBlockDepSpec &);
diff --git a/python/formatter.cc b/python/formatter.cc
index fdc1e13..f3bc389 100644
--- a/python/formatter.cc
+++ b/python/formatter.cc
@@ -355,7 +355,7 @@ class PythonFormatterWrapper :
public PythonCanFormat<URILabelsDepSpec>,
public PythonCanFormat<PlainTextDepSpec>,
public PythonCanFormat<LicenseDepSpec>,
- public PythonCanFormat<UseDepSpec>,
+ public PythonCanFormat<ConditionalDepSpec>,
public PythonCanFormat<NamedSetDepSpec>,
public PythonCanSpace,
public bp::wrapper<PythonFormatterWrapper>
@@ -531,19 +531,19 @@ void expose_formatter()
;
/**
- * CanFormatUseDepSpec
+ * CanFormatConditionalDepSpec
*/
- bp::class_<PythonCanFormatWrapper<UseDepSpec>, boost::noncopyable>
+ bp::class_<PythonCanFormatWrapper<ConditionalDepSpec>, boost::noncopyable>
(
- "CanFormatUseDepSpec",
- "Descendents of this class implement the necessary methods to format a UseDepSpec.",
+ "CanFormatConditionalDepSpec",
+ "Descendents of this class implement the necessary methods to format a ConditionalDepSpec.",
bp::init<>("__init__()")
)
- .def("format_use_dep_spec_plain", &PythonCanFormatWrapper<UseDepSpec>::format_plain)
- .def("format_use_dep_spec_enabled", &PythonCanFormatWrapper<UseDepSpec>::format_enabled)
- .def("format_use_dep_spec_disabled", &PythonCanFormatWrapper<UseDepSpec>::format_disabled)
- .def("format_use_dep_spec_forced", &PythonCanFormatWrapper<UseDepSpec>::format_forced)
- .def("format_use_dep_spec_masked", &PythonCanFormatWrapper<UseDepSpec>::format_masked)
+ .def("format_conditional_dep_spec_plain", &PythonCanFormatWrapper<ConditionalDepSpec>::format_plain)
+ .def("format_conditional_dep_spec_enabled", &PythonCanFormatWrapper<ConditionalDepSpec>::format_enabled)
+ .def("format_conditional_dep_spec_disabled", &PythonCanFormatWrapper<ConditionalDepSpec>::format_disabled)
+ .def("format_conditional_dep_spec_forced", &PythonCanFormatWrapper<ConditionalDepSpec>::format_forced)
+ .def("format_conditional_dep_spec_masked", &PythonCanFormatWrapper<ConditionalDepSpec>::format_masked)
;
/**
@@ -623,7 +623,7 @@ void expose_formatter()
*/
bp::class_<LicenseSpecTree::ItemFormatter,
bp::bases<
- CanFormat<UseDepSpec>,
+ CanFormat<ConditionalDepSpec>,
CanFormat<LicenseDepSpec> >,
boost::noncopyable>
(
@@ -638,7 +638,7 @@ void expose_formatter()
*/
bp::class_<ProvideSpecTree::ItemFormatter,
bp::bases<
- CanFormat<UseDepSpec>,
+ CanFormat<ConditionalDepSpec>,
CanFormat<PackageDepSpec> >,
boost::noncopyable>
(
@@ -653,7 +653,7 @@ void expose_formatter()
*/
bp::class_<DependencySpecTree::ItemFormatter,
bp::bases<
- CanFormat<UseDepSpec>,
+ CanFormat<ConditionalDepSpec>,
CanFormat<PackageDepSpec>,
CanFormat<NamedSetDepSpec>,
CanFormat<DependencyLabelsDepSpec> >,
@@ -670,7 +670,7 @@ void expose_formatter()
*/
bp::class_<RestrictSpecTree::ItemFormatter,
bp::bases<
- CanFormat<UseDepSpec>,
+ CanFormat<ConditionalDepSpec>,
CanFormat<PlainTextDepSpec> >,
boost::noncopyable>
(
@@ -685,7 +685,7 @@ void expose_formatter()
*/
bp::class_<SimpleURISpecTree::ItemFormatter,
bp::bases<
- CanFormat<UseDepSpec>,
+ CanFormat<ConditionalDepSpec>,
CanFormat<SimpleURIDepSpec> >,
boost::noncopyable>
(
@@ -700,7 +700,7 @@ void expose_formatter()
*/
bp::class_<FetchableURISpecTree::ItemFormatter,
bp::bases<
- CanFormat<UseDepSpec>,
+ CanFormat<ConditionalDepSpec>,
CanFormat<FetchableURIDepSpec>,
CanFormat<URILabelsDepSpec> >,
boost::noncopyable>
@@ -738,7 +738,7 @@ void expose_formatter()
CanFormat<URILabelsDepSpec>,
CanFormat<PlainTextDepSpec>,
CanFormat<LicenseDepSpec>,
- CanFormat<UseDepSpec>,
+ CanFormat<ConditionalDepSpec>,
CanFormat<NamedSetDepSpec>,
CanSpace>,
boost::noncopyable>
@@ -782,7 +782,7 @@ void expose_formatter()
CanFormat<URILabelsDepSpec>,
CanFormat<PlainTextDepSpec>,
CanFormat<LicenseDepSpec>,
- CanFormat<UseDepSpec>,
+ CanFormat<ConditionalDepSpec>,
CanFormat<NamedSetDepSpec>,
CanSpace>,
boost::noncopyable>
diff --git a/python/nice_names.nn b/python/nice_names.nn
index 36ce9b6..4d35d29 100644
--- a/python/nice_names.nn
+++ b/python/nice_names.nn
@@ -27,7 +27,7 @@ make_nn_NiceNames() {
name "SimpleURIDepSpec"
name "AllDepSpec"
name "AnyDepSpec"
- name "UseDepSpec"
+ name "ConditionalDepSpec"
name "BlockDepSpec"
name "StringDepSpec"
name "NamedSetDepSpec"
@@ -82,7 +82,7 @@ make_nn_LowercaseNiceNames() {
name "URILabelsDepSpec" "uri_labels_dep_spec"
name "PlainTextDepSpec" "plain_text_dep_spec"
name "LicenseDepSpec" "license_dep_spec"
- name "UseDepSpec" "use_dep_spec"
+ name "ConditionalDepSpec" "conditional_dep_spec"
name "NamedSetDepSpec" "named_set_dep_spec"
name "format::Plain" "plain"