Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64321 - in sandbox/numpy: boost/python/numpy libs/python/numpy/src
From: talljimbo_at_[hidden]
Date: 2010-07-24 20:18:20


Author: jbosch
Date: 2010-07-24 20:18:18 EDT (Sat, 24 Jul 2010)
New Revision: 64321
URL: http://svn.boost.org/trac/boost/changeset/64321

Log:
boost.python.numpy - adding missing symbols, fixed constness in dtype
Text files modified:
   sandbox/numpy/boost/python/numpy/dtype.hpp | 23 +++++++++++++++++++++--
   sandbox/numpy/libs/python/numpy/src/dtype.cpp | 5 +++++
   2 files changed, 26 insertions(+), 2 deletions(-)

Modified: sandbox/numpy/boost/python/numpy/dtype.hpp
==============================================================================
--- sandbox/numpy/boost/python/numpy/dtype.hpp (original)
+++ sandbox/numpy/boost/python/numpy/dtype.hpp 2010-07-24 20:18:18 EDT (Sat, 24 Jul 2010)
@@ -47,7 +47,7 @@
     BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(dtype, object);
 
     template <typename Sequence, typename Function>
- void invoke_matching_template(Function f);
+ void invoke_matching_template(Function f) const;
 
 };
 
@@ -83,10 +83,29 @@
     Function m_func;
 };
 
+template <typename Function>
+struct dtype_template_invoker< boost::reference_wrapper<Function> > {
+
+ template <typename T>
+ void operator()(T * x) const {
+ if (dtype::get_builtin<T>() == m_dtype) {
+ m_func.template apply<T>();
+ throw dtype_template_match_found();
+ }
+ }
+
+ dtype_template_invoker(dtype const & dtype_, Function & func) :
+ m_dtype(dtype_), m_func(func) {}
+
+private:
+ dtype const & m_dtype;
+ Function & m_func;
+};
+
 } // namespace boost::python::numpy::detail
 
 template <typename Sequence, typename Function>
-void dtype::invoke_matching_template(Function f) {
+void dtype::invoke_matching_template(Function f) const {
     detail::dtype_template_invoker<Function> invoker(*this, f);
     try {
         boost::mpl::for_each< Sequence, detail::add_pointer_meta >(invoker);

Modified: sandbox/numpy/libs/python/numpy/src/dtype.cpp
==============================================================================
--- sandbox/numpy/libs/python/numpy/src/dtype.cpp (original)
+++ sandbox/numpy/libs/python/numpy/src/dtype.cpp 2010-07-24 20:18:18 EDT (Sat, 24 Jul 2010)
@@ -30,6 +30,10 @@
     template dtype dtype::get_builtin< std::complex<creal> >()
 
 namespace boost { namespace python {
+namespace converter {
+NUMPY_OBJECT_MANAGER_TRAITS_IMPL(PyArrayDescr_Type, python::numpy::dtype)
+} // namespace boost::python::converter
+
 namespace numpy {
 
 template <typename T> struct dtype_traits;
@@ -61,6 +65,7 @@
 NUMPY_DTYPE_TRAITS_BUILTIN(npy_int, NPY_INT);
 NUMPY_DTYPE_TRAITS_BUILTIN(npy_ulong, NPY_ULONG);
 NUMPY_DTYPE_TRAITS_BUILTIN(npy_long, NPY_LONG);
+NUMPY_DTYPE_TRAITS_BUILTIN(npy_longlong, NPY_LONGLONG);
 NUMPY_DTYPE_TRAITS_BUILTIN(npy_float, NPY_FLOAT);
 NUMPY_DTYPE_TRAITS_BUILTIN(npy_double, NPY_DOUBLE);
 NUMPY_DTYPE_TRAITS_BUILTIN(npy_longdouble, NPY_LONGDOUBLE);


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk