aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-08-13 16:28:42 +0000
committerAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-08-13 16:28:42 +0000
commit007927ebcbda6132d69783e79b35611793547435 (patch)
tree33419de0dba0936876628311c9f25586e712bf1e
parente29522118bccc9cee1c1b0e80c59062ba5b82e47 (diff)
downloadpaludis-007927ebcbda6132d69783e79b35611793547435.tar.gz
paludis-007927ebcbda6132d69783e79b35611793547435.tar.xz
(python) Headers clean up.
-rw-r--r--python/action.cc3
-rw-r--r--python/contents.cc3
-rw-r--r--python/dep_list.cc3
-rw-r--r--python/dep_spec.cc5
-rw-r--r--python/dep_tag.cc5
-rw-r--r--python/environment.cc3
-rw-r--r--python/fs_entry.cc3
-rw-r--r--python/iterable.hh49
-rw-r--r--python/log.cc2
-rw-r--r--python/mask.cc3
-rw-r--r--python/metadata_key.cc2
-rw-r--r--python/metadata_key.hh2
-rw-r--r--python/name.cc7
-rw-r--r--python/options.hh87
-rw-r--r--python/package_database.cc3
-rw-r--r--python/package_id.cc4
-rw-r--r--python/paludis_python.hh87
-rw-r--r--python/paludis_python_so.cc3
-rw-r--r--python/qa.cc9
-rw-r--r--python/query.cc2
-rw-r--r--python/repository.cc4
-rw-r--r--python/validated.hh48
-rw-r--r--python/version_operator.cc3
-rw-r--r--python/version_requirements.cc4
-rw-r--r--python/version_spec.cc6
25 files changed, 230 insertions, 120 deletions
diff --git a/python/action.cc b/python/action.cc
index 7fd9287..0b7ff8c 100644
--- a/python/action.cc
+++ b/python/action.cc
@@ -17,7 +17,8 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis_python.hh>
+#include <python/paludis_python.hh>
+#include <python/exception.hh>
#include <paludis/action.hh>
#include <paludis/util/tr1_memory.hh>
diff --git a/python/contents.cc b/python/contents.cc
index c98ccc4..9bf3170 100644
--- a/python/contents.cc
+++ b/python/contents.cc
@@ -17,7 +17,8 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis_python.hh>
+#include <python/paludis_python.hh>
+
#include <paludis/contents.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
diff --git a/python/dep_list.cc b/python/dep_list.cc
index a840051..6b6f282 100644
--- a/python/dep_list.cc
+++ b/python/dep_list.cc
@@ -17,7 +17,8 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis_python.hh>
+#include <python/paludis_python.hh>
+#include <python/exception.hh>
#include <paludis/dep_list/dep_list.hh>
#include <paludis/dep_list/exceptions.hh>
diff --git a/python/dep_spec.cc b/python/dep_spec.cc
index fb14f25..b3e1af5 100644
--- a/python/dep_spec.cc
+++ b/python/dep_spec.cc
@@ -17,8 +17,9 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <dep_spec.hh>
-#include <paludis_python.hh>
+#include "dep_spec.hh"
+#include <python/paludis_python.hh>
+#include <python/exception.hh>
#include <paludis/dep_tag.hh>
#include <paludis/version_requirements.hh>
diff --git a/python/dep_tag.cc b/python/dep_tag.cc
index b0491c4..471b9e9 100644
--- a/python/dep_tag.cc
+++ b/python/dep_tag.cc
@@ -17,11 +17,12 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis_python.hh>
+#include <python/paludis_python.hh>
+#include <python/exception.hh>
+#include <python/iterable.hh>
#include <paludis/dep_tag.hh>
#include <paludis/dep_spec.hh>
-#include <paludis/util/set.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
using namespace paludis;
diff --git a/python/environment.cc b/python/environment.cc
index 34419de..8599e6a 100644
--- a/python/environment.cc
+++ b/python/environment.cc
@@ -17,7 +17,8 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis_python.hh>
+#include <python/paludis_python.hh>
+#include <python/exception.hh>
#include <paludis/environment.hh>
#include <paludis/environments/environment_maker.hh>
diff --git a/python/fs_entry.cc b/python/fs_entry.cc
index 20af921..4e46ff5 100644
--- a/python/fs_entry.cc
+++ b/python/fs_entry.cc
@@ -17,7 +17,8 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis_python.hh>
+#include <python/paludis_python.hh>
+#include <python/exception.hh>
#include <paludis/util/fs_entry.hh>
diff --git a/python/iterable.hh b/python/iterable.hh
new file mode 100644
index 0000000..cd1be99
--- /dev/null
+++ b/python/iterable.hh
@@ -0,0 +1,49 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Piotr Jaroszyński <peper@gentoo.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_PYTHON_ITERABLE_HH
+#define PALUDIS_GUARD_PYTHON_ITERABLE_HH 1
+
+#include <python/paludis_python.hh>
+
+#include <paludis/util/sequence.hh>
+#include <paludis/util/set.hh>
+
+namespace paludis
+{
+ namespace python
+ {
+ // expose iterable classes
+ template <typename C_>
+ class class_iterable :
+ public boost::python::class_<C_, boost::noncopyable>
+ {
+ public:
+ class_iterable(const std::string & name, const std::string & class_doc) :
+ boost::python::class_<C_, boost::noncopyable>(name.c_str(), class_doc.c_str(),
+ boost::python::no_init)
+ {
+ this->def("__iter__", boost::python::range(&C_::begin, &C_::end));
+ register_shared_ptrs_to_python<C_>();
+ }
+ };
+ } // namespace paludis::python
+} // namespace paludis
+
+#endif
diff --git a/python/log.cc b/python/log.cc
index 1b2efdb..365332b 100644
--- a/python/log.cc
+++ b/python/log.cc
@@ -17,7 +17,7 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis_python.hh>
+#include <python/paludis_python.hh>
#include <paludis/util/log.hh>
diff --git a/python/mask.cc b/python/mask.cc
index c9cd5dd..cbd5a9c 100644
--- a/python/mask.cc
+++ b/python/mask.cc
@@ -17,7 +17,8 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis_python.hh>
+#include <python/paludis_python.hh>
+#include <python/iterable.hh>
#include <python/metadata_key.hh>
diff --git a/python/metadata_key.cc b/python/metadata_key.cc
index 3c96955..fbfb722 100644
--- a/python/metadata_key.cc
+++ b/python/metadata_key.cc
@@ -18,7 +18,7 @@
*/
#include "metadata_key.hh"
-#include <paludis_python.hh>
+#include <python/paludis_python.hh>
#include <paludis/name.hh>
#include <paludis/util/visitor-impl.hh>
diff --git a/python/metadata_key.hh b/python/metadata_key.hh
index e7d2e2d..07e330f 100644
--- a/python/metadata_key.hh
+++ b/python/metadata_key.hh
@@ -20,7 +20,7 @@
#ifndef PYTHON_GUARD_PYTHON_METADATA_KEY_HH
#define PYTHON_GUARD_PYTHON_METADATA_KEY_HH 1
-#include <paludis_python.hh>
+#include <python/paludis_python.hh>
#include <paludis/metadata_key.hh>
diff --git a/python/name.cc b/python/name.cc
index d341a3d..548f477 100644
--- a/python/name.cc
+++ b/python/name.cc
@@ -17,11 +17,12 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis_python.hh>
+#include <python/paludis_python.hh>
+#include <python/exception.hh>
+#include <python/validated.hh>
+#include <python/iterable.hh>
#include <paludis/name.hh>
-#include <paludis/util/set.hh>
-#include <paludis/util/sequence.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
using namespace paludis;
diff --git a/python/options.hh b/python/options.hh
new file mode 100644
index 0000000..641fc64
--- /dev/null
+++ b/python/options.hh
@@ -0,0 +1,87 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Piotr Jaroszyński <peper@gentoo.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_PYTHON_OPTIONS_HH
+#define PALUDIS_GUARD_PYTHON_OPTIONS_HH 1
+
+#include <python/paludis_python.hh>
+
+#include <paludis/util/options.hh>
+
+namespace paludis
+{
+ namespace python
+ {
+ // expose Options classes
+ template <typename O_>
+ class class_options :
+ public boost::python::class_<O_>
+ {
+ public:
+ class_options(const std::string & set_name, const std::string & bit_name,
+ const std::string & class_doc) :
+ boost::python::class_<O_>(set_name.c_str(), class_doc.c_str(),
+ boost::python::init<>("__init__()"))
+ {
+ this->add_property("any", &O_::any,
+ "[ro] bool\n"
+ "Is any bit enabled."
+ );
+ this->add_property("none", &O_::none,
+ "[ro] bool\n"
+ "Are all bits disabled."
+ );
+ this->def("__add__", &O_::operator+,
+ ("__add__("+bit_name+") -> "+set_name+"\n"
+ "Return a copy of ourself with the specified bit enabled.").c_str()
+ );
+ this->def("__iadd__", &O_::operator+=, boost::python::return_self<>(),
+ ("__iadd__("+bit_name+") -> "+set_name+"\n"
+ "Enable the specified bit.").c_str()
+ );
+ this->def("__sub__", &O_::operator-,
+ ("__sub__("+bit_name+") -> "+set_name+"\n"
+ "Return a copy of ourself with the specified bit disabled.").c_str()
+ );
+ this->def("__isub__", &O_::operator-=, boost::python::return_self<>(),
+ ("__isub__("+bit_name+") -> "+set_name+"\n"
+ "Disable the specified bit.").c_str()
+ );
+ this->def("__or__", &O_::operator|,
+ ("__or__("+set_name+") -> "+set_name+"\n"
+ "Return a copy of ourself, bitwise 'or'ed with another Options set.").c_str()
+ );
+ this->def("__ior__", &O_::operator|=, boost::python::return_self<>(),
+ ("__ior__("+set_name+") -> "+set_name+"\n"
+ "Enable any bits that are enabled in the parameter.").c_str()
+ );
+ this->def("__getitem__", &O_::operator[],
+ ("__getitem__("+bit_name+") -> bool\n"
+ "Returns whether the specified bit is enabled.").c_str()
+ );
+ this->def("subtract", &O_::subtract, boost::python::return_self<>(),
+ ("subtract("+set_name+") -> "+set_name+"\n"
+ "Disable any bits that are enabled in the parameter.").c_str()
+ );
+ }
+ };
+ } // namespace paludis::python
+} // namespace paludis
+
+#endif
diff --git a/python/package_database.cc b/python/package_database.cc
index e463c9a..9b283d3 100644
--- a/python/package_database.cc
+++ b/python/package_database.cc
@@ -17,7 +17,8 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis_python.hh>
+#include <python/paludis_python.hh>
+#include <python/exception.hh>
#include <paludis/dep_spec.hh>
#include <paludis/query.hh>
diff --git a/python/package_id.cc b/python/package_id.cc
index a936718..d2645bd 100644
--- a/python/package_id.cc
+++ b/python/package_id.cc
@@ -17,7 +17,8 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis_python.hh>
+#include <python/paludis_python.hh>
+#include <python/iterable.hh>
#include <paludis/package_id.hh>
#include <paludis/repositories/fake/fake_package_id.hh>
@@ -25,7 +26,6 @@
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
#include <paludis/action.hh>
-#include <paludis/util/sequence.hh>
#include <paludis/util/iterator.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
diff --git a/python/paludis_python.hh b/python/paludis_python.hh
index 68c5e87..95e9ebb 100644
--- a/python/paludis_python.hh
+++ b/python/paludis_python.hh
@@ -20,7 +20,6 @@
#ifndef PALUDIS_GUARD_PYTHON_PALUDIS_PYTHON_HH
#define PALUDIS_GUARD_PYTHON_PALUDIS_PYTHON_HH 1
-#include <exception.hh>
#include <paludis/util/tr1_memory.hh>
#include <paludis/util/stringify.hh>
@@ -132,92 +131,6 @@ namespace paludis
return ! (a == b);
}
- // expose Validated classes
- template <typename V_, typename Data_=std::string>
- class class_validated :
- public boost::python::class_<V_>
- {
- 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())
- )
- {
- this->def(boost::python::self_ns::str(boost::python::self));
- boost::python::implicitly_convertible<Data_, V_>();
- }
- };
-
- // expose iterable classes
- template <typename C_>
- class class_iterable :
- public boost::python::class_<C_, boost::noncopyable>
- {
- public:
- class_iterable(const std::string & name, const std::string & class_doc) :
- boost::python::class_<C_, boost::noncopyable>(name.c_str(), class_doc.c_str(),
- boost::python::no_init)
- {
- this->def("__iter__", boost::python::range(&C_::begin, &C_::end));
- register_shared_ptrs_to_python<C_>();
- }
- };
-
- // expose Options classes
- template <typename O_>
- class class_options :
- public boost::python::class_<O_>
- {
- public:
- class_options(const std::string & set_name, const std::string & bit_name,
- const std::string & class_doc) :
- boost::python::class_<O_>(set_name.c_str(), class_doc.c_str(),
- boost::python::init<>("__init__()"))
- {
- this->add_property("any", &O_::any,
- "[ro] bool\n"
- "Is any bit enabled."
- );
- this->add_property("none", &O_::none,
- "[ro] bool\n"
- "Are all bits disabled."
- );
- this->def("__add__", &O_::operator+,
- ("__add__("+bit_name+") -> "+set_name+"\n"
- "Return a copy of ourself with the specified bit enabled.").c_str()
- );
- this->def("__iadd__", &O_::operator+=, boost::python::return_self<>(),
- ("__iadd__("+bit_name+") -> "+set_name+"\n"
- "Enable the specified bit.").c_str()
- );
- this->def("__sub__", &O_::operator-,
- ("__sub__("+bit_name+") -> "+set_name+"\n"
- "Return a copy of ourself with the specified bit disabled.").c_str()
- );
- this->def("__isub__", &O_::operator-=, boost::python::return_self<>(),
- ("__isub__("+bit_name+") -> "+set_name+"\n"
- "Disable the specified bit.").c_str()
- );
- this->def("__or__", &O_::operator|,
- ("__or__("+set_name+") -> "+set_name+"\n"
- "Return a copy of ourself, bitwise 'or'ed with another Options set.").c_str()
- );
- this->def("__ior__", &O_::operator|=, boost::python::return_self<>(),
- ("__ior__("+set_name+") -> "+set_name+"\n"
- "Enable any bits that are enabled in the parameter.").c_str()
- );
- this->def("__getitem__", &O_::operator[],
- ("__getitem__("+bit_name+") -> bool\n"
- "Returns whether the specified bit is enabled.").c_str()
- );
- this->def("subtract", &O_::subtract, boost::python::return_self<>(),
- ("subtract("+set_name+") -> "+set_name+"\n"
- "Disable any bits that are enabled in the parameter.").c_str()
- );
- }
- };
-
// Convert to string
template <typename T_>
struct to_string
diff --git a/python/paludis_python_so.cc b/python/paludis_python_so.cc
index be4d429..a51db28 100644
--- a/python/paludis_python_so.cc
+++ b/python/paludis_python_so.cc
@@ -17,8 +17,7 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis_python.hh>
-
+#include <boost/python.hpp>
#include <boost/version.hpp>
void expose_action();
diff --git a/python/qa.cc b/python/qa.cc
index 75ba272..9e5ad22 100644
--- a/python/qa.cc
+++ b/python/qa.cc
@@ -17,10 +17,11 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis_python.hh>
+#include <python/paludis_python.hh>
+#include <python/exception.hh>
+#include <python/options.hh>
#include <paludis/qa.hh>
-#include <paludis/util/options.hh>
#include <paludis/util/fs_entry.hh>
using namespace paludis;
@@ -33,8 +34,8 @@ struct QAReporterWrapper :
{
void message(const QAMessage & msg)
{
- if (get_override("message"))
- get_override("message")(msg);
+ if (bp::override f = get_override("message"))
+ f(msg);
else
throw PythonMethodNotImplemented("QAReporter", "message");
}
diff --git a/python/query.cc b/python/query.cc
index 84d7450..18b23b8 100644
--- a/python/query.cc
+++ b/python/query.cc
@@ -17,7 +17,7 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis_python.hh>
+#include <python/paludis_python.hh>
#include <paludis/query.hh>
#include <paludis/dep_spec.hh>
diff --git a/python/repository.cc b/python/repository.cc
index ba225e6..26b660f 100644
--- a/python/repository.cc
+++ b/python/repository.cc
@@ -17,7 +17,8 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis_python.hh>
+#include <python/paludis_python.hh>
+#include <python/iterable.hh>
#include <paludis/repository.hh>
#include <paludis/repository_info.hh>
@@ -28,7 +29,6 @@
#include <paludis/package_id.hh>
#include <paludis/environment.hh>
#include <paludis/qa.hh>
-#include <paludis/util/set.hh>
#include <paludis/util/options.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
diff --git a/python/validated.hh b/python/validated.hh
new file mode 100644
index 0000000..cf71209
--- /dev/null
+++ b/python/validated.hh
@@ -0,0 +1,48 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Piotr Jaroszyński <peper@gentoo.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_PYTHON_VALIDATED_HH
+#define PALUDIS_GUARD_PYTHON_VALIDATED_HH 1
+
+#include <python/paludis_python.hh>
+
+namespace paludis
+{
+ namespace python
+ {
+ // expose Validated classes
+ template <typename V_, typename Data_=std::string>
+ class class_validated :
+ public boost::python::class_<V_>
+ {
+ 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())
+ )
+ {
+ this->def(boost::python::self_ns::str(boost::python::self));
+ boost::python::implicitly_convertible<Data_, V_>();
+ }
+ };
+ } // namespace paludis::python
+} // namespace paludis
+
+#endif
diff --git a/python/version_operator.cc b/python/version_operator.cc
index 00dd9a5..eacb1a4 100644
--- a/python/version_operator.cc
+++ b/python/version_operator.cc
@@ -17,7 +17,8 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis_python.hh>
+#include <python/paludis_python.hh>
+#include <python/exception.hh>
#include <paludis/version_operator.hh>
#include <paludis/version_spec.hh>
diff --git a/python/version_requirements.cc b/python/version_requirements.cc
index b0adc9a..d88cc6c 100644
--- a/python/version_requirements.cc
+++ b/python/version_requirements.cc
@@ -17,10 +17,10 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis_python.hh>
+#include <python/paludis_python.hh>
+#include <python/iterable.hh>
#include <paludis/version_requirements.hh>
-#include <paludis/util/sequence.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
using namespace paludis;
diff --git a/python/version_spec.cc b/python/version_spec.cc
index ae1dca7..1e50106 100644
--- a/python/version_spec.cc
+++ b/python/version_spec.cc
@@ -17,9 +17,11 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis_python.hh>
-#include <libwrapiter/libwrapiter_forward_iterator.hh>
+#include <python/paludis_python.hh>
+#include <python/exception.hh>
+
#include <paludis/version_spec.hh>
+#include <libwrapiter/libwrapiter_forward_iterator.hh>
using namespace paludis;
using namespace paludis::python;