aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-05-22 13:28:50 +0000
committerAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-05-22 13:28:50 +0000
commitd6205575ba1d134541d8b9d48e6912c69ef65b2a (patch)
treed2b83627166f9dd058992dc1668a954565bf9df4
parent69b524f747b352b99236551556d036d643e9b3f4 (diff)
downloadpaludis-d6205575ba1d134541d8b9d48e6912c69ef65b2a.tar.gz
paludis-d6205575ba1d134541d8b9d48e6912c69ef65b2a.tar.xz
(python) "using" and namespaces' abbreviations are bad in header files.
-rw-r--r--python/exception.hh7
-rwxr-xr-xpython/paludis_python.hh47
2 files changed, 25 insertions, 29 deletions
diff --git a/python/exception.hh b/python/exception.hh
index eebdf28..c3dcfb8 100644
--- a/python/exception.hh
+++ b/python/exception.hh
@@ -27,9 +27,6 @@
#include <boost/python.hpp>
-using namespace paludis;
-namespace bp = boost::python;
-
namespace paludis
{
namespace python
@@ -69,8 +66,8 @@ namespace paludis
_longname("paludis." + name),
_e(PyErr_NewException(const_cast<char*>(_longname.c_str()), base, NULL))
{
- PyModule_AddObject(bp::detail::current_scope, const_cast<char*>(_name.c_str()), _e);
- bp::register_exception_translator<Ex_>(
+ PyModule_AddObject(boost::python::detail::current_scope, const_cast<char*>(_name.c_str()), _e);
+ boost::python::register_exception_translator<Ex_>(
tr1::bind(tr1::mem_fn(&RegisteredException<Ex_>::translator),
this, tr1::placeholders::_1)
);
diff --git a/python/paludis_python.hh b/python/paludis_python.hh
index 1557278..f14e172 100755
--- a/python/paludis_python.hh
+++ b/python/paludis_python.hh
@@ -26,9 +26,6 @@
#include <boost/python.hpp>
-using namespace paludis;
-namespace bp = boost::python;
-
namespace paludis
{
// Make Boost.Python work with tr1::shared_ptr<>
@@ -52,14 +49,14 @@ namespace boost
{
// Make Boost.Python work with tr1::shared_ptr<>
template <typename T_>
- struct pointee<tr1::shared_ptr<T_> >
+ struct pointee<paludis::tr1::shared_ptr<T_> >
{
typedef T_ type;
};
// Make Boost.Python work with tr1::shared_ptr<const>
template <typename T_>
- struct pointee<tr1::shared_ptr<const T_> >
+ struct pointee<paludis::tr1::shared_ptr<const T_> >
{
typedef T_ type;
};
@@ -75,9 +72,9 @@ namespace paludis
void
register_shared_ptrs_to_python()
{
- bp::register_ptr_to_python<tr1::shared_ptr<T_> >();
- bp::register_ptr_to_python<tr1::shared_ptr<const T_> >();
- bp::implicitly_convertible<tr1::shared_ptr<T_>, tr1::shared_ptr<const T_> >();
+ boost::python::register_ptr_to_python<tr1::shared_ptr<T_> >();
+ boost::python::register_ptr_to_python<tr1::shared_ptr<const T_> >();
+ boost::python::implicitly_convertible<tr1::shared_ptr<T_>, tr1::shared_ptr<const T_> >();
}
// expose stringifyable enums
@@ -85,7 +82,7 @@ namespace paludis
void
enum_auto(const std::string & name, E_ e_last)
{
- bp::enum_<E_> enum_(name.c_str());
+ boost::python::enum_<E_> enum_(name.c_str());
for (E_ e(static_cast<E_>(0)); e != e_last ; e = static_cast<E_>(static_cast<int>(e) + 1))
{
const std::string e_name_low = stringify(e);
@@ -117,30 +114,31 @@ namespace paludis
// expose Validated classes
template <typename V_, typename Data_=std::string>
class class_validated :
- public bp::class_<V_>
+ public boost::python::class_<V_>
{
public:
class_validated(const std::string & name,
const std::string & class_doc, const std::string & init_arg="string") :
- bp::class_<V_>(name.c_str(), class_doc.c_str(),
- bp::init<const Data_ &>(("__init__("+init_arg+")").c_str())
+ boost::python::class_<V_>(name.c_str(), class_doc.c_str(),
+ boost::python::init<const Data_ &>(("__init__("+init_arg+")").c_str())
)
{
- this->def(bp::self_ns::str(bp::self));
- bp::implicitly_convertible<Data_, V_>();
+ this->def(boost::python::self_ns::str(boost::python::self));
+ boost::python::implicitly_convertible<Data_, V_>();
}
};
// expose *Collection classes
template <typename C_>
class class_collection :
- public bp::class_<C_, boost::noncopyable>
+ public boost::python::class_<C_, boost::noncopyable>
{
public:
class_collection(const std::string & name, const std::string & class_doc) :
- bp::class_<C_, boost::noncopyable>(name.c_str(), class_doc.c_str(), bp::no_init)
+ boost::python::class_<C_, boost::noncopyable>(name.c_str(), class_doc.c_str(),
+ boost::python::no_init)
{
- this->def("__iter__", bp::range(&C_::begin, &C_::end));
+ this->def("__iter__", boost::python::range(&C_::begin, &C_::end));
register_shared_ptrs_to_python<C_>();
}
};
@@ -148,12 +146,13 @@ namespace paludis
// expose Options classes
template <typename O_>
class class_options :
- public bp::class_<O_>
+ public boost::python::class_<O_>
{
public:
class_options(const std::string & set_name, const std::string & bit_name,
const std::string & class_doc) :
- bp::class_<O_>(set_name.c_str(), class_doc.c_str(), bp::init<>("__init__()"))
+ 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"
@@ -167,7 +166,7 @@ namespace paludis
("__add__("+bit_name+") -> "+set_name+"\n"
"Return a copy of ourself with the specified bit enabled.").c_str()
);
- this->def("__iadd__", &O_::operator+=, bp::return_self<>(),
+ this->def("__iadd__", &O_::operator+=, boost::python::return_self<>(),
("__iadd__("+bit_name+") -> "+set_name+"\n"
"Enable the specified bit.").c_str()
);
@@ -175,7 +174,7 @@ namespace paludis
("__sub__("+bit_name+") -> "+set_name+"\n"
"Return a copy of ourself with the specified bit disabled.").c_str()
);
- this->def("__isub__", &O_::operator-=, bp::return_self<>(),
+ this->def("__isub__", &O_::operator-=, boost::python::return_self<>(),
("__isub__("+bit_name+") -> "+set_name+"\n"
"Disable the specified bit.").c_str()
);
@@ -183,7 +182,7 @@ namespace paludis
("__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|=, bp::return_self<>(),
+ 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()
);
@@ -191,7 +190,7 @@ namespace paludis
("__getitem__("+bit_name+") -> bool\n"
"Returns whether the specified bit is enabled.").c_str()
);
- this->def("subtract", &O_::subtract, bp::return_self<>(),
+ 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()
);
@@ -216,7 +215,7 @@ namespace paludis
static PyObject *
convert(const std::pair<first_, second_> & x)
{
- return bp::incref(bp::make_tuple(x.first, x.second).ptr());
+ return boost::python::incref(boost::python::make_tuple(x.first, x.second).ptr());
}
};
} // namespace paludis::python