[paludis-commits] r4107 - in trunk: . python
peper at svn.pioto.org
peper at svn.pioto.org
Sun Dec 30 18:34:59 UTC 2007
Author: peper
Date: 2007-12-30 18:34:49 +0000 (Sun, 30 Dec 2007)
New Revision: 4107
Modified:
trunk/ChangeLog
trunk/python/validated.hh
Log:
(python) Add operators to Validated.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-12-30 18:34:26 UTC (rev 4106)
+++ trunk/ChangeLog 2007-12-30 18:34:49 UTC (rev 4107)
@@ -7,6 +7,10 @@
2007-12-30 Piotr Jaroszyński
+ * python/validated.hh: (python) Add operators to Validated.
+
+2007-12-30 Piotr Jaroszyński
+
* paludis/dep_spec.cc, paludis/dep_spec.se: Nuke unused code.
2007-12-29 Ciaran McCreesh
Modified: trunk/python/validated.hh
===================================================================
--- trunk/python/validated.hh 2007-12-30 18:34:26 UTC (rev 4106)
+++ trunk/python/validated.hh 2007-12-30 18:34:49 UTC (rev 4107)
@@ -22,26 +22,58 @@
#include <python/paludis_python.hh>
+#include <paludis/util/validated.hh>
+
namespace paludis
{
namespace python
{
// expose Validated classes
- template <typename V_, typename Data_=std::string>
- class class_validated :
- public boost::python::class_<V_>
+ template <typename V_>
+ class class_validated;
+
+ template <typename ValidatedDataType_, typename Validator_>
+ class class_validated<Validated<ValidatedDataType_, Validator_, true> > :
+ public boost::python::class_<Validated<ValidatedDataType_, Validator_, true> >
{
public:
class_validated(const std::string & name,
const std::string & class_doc, const std::string & init_arg="string") :
- boost::python::class_<V_>(name.c_str(), class_doc.c_str(),
- boost::python::init<const Data_ &>(("__init__("+init_arg+")").c_str())
+ boost::python::class_<Validated<ValidatedDataType_, Validator_, true> >(
+ name.c_str(), class_doc.c_str(),
+ boost::python::init<const ValidatedDataType_ &>(("__init__("+init_arg+")").c_str())
)
{
this->def(boost::python::self_ns::str(boost::python::self));
- boost::python::implicitly_convertible<Data_, V_>();
+ this->def("__cmp__",
+ &paludis::python::py_cmp<Validated<ValidatedDataType_, Validator_, true> >);
+ boost::python::implicitly_convertible<ValidatedDataType_,
+ Validated<ValidatedDataType_, Validator_, true> >();
}
};
+
+ template <typename ValidatedDataType_, typename Validator_>
+ class class_validated<Validated<ValidatedDataType_, Validator_, false> > :
+ public boost::python::class_<Validated<ValidatedDataType_, Validator_, false> >
+ {
+ public:
+ class_validated(const std::string & name,
+ const std::string & class_doc, const std::string & init_arg="string") :
+ boost::python::class_<Validated<ValidatedDataType_, Validator_, false> >(
+ name.c_str(), class_doc.c_str(),
+ boost::python::init<const ValidatedDataType_ &>(("__init__("+init_arg+")").c_str())
+ )
+ {
+ this->def(boost::python::self_ns::str(boost::python::self));
+ this->def("__eq__",
+ &paludis::python::py_eq<Validated<ValidatedDataType_, Validator_, false> >);
+ this->def("__ne__",
+ &paludis::python::py_ne<Validated<ValidatedDataType_, Validator_, false> >);
+ boost::python::implicitly_convertible<ValidatedDataType_,
+ Validated<ValidatedDataType_, Validator_, false> >();
+ }
+ };
+
} // namespace paludis::python
} // namespace paludis
More information about the paludis-commits
mailing list