summaryrefslogtreecommitdiff
path: root/boost/python
diff options
context:
space:
mode:
Diffstat (limited to 'boost/python')
-rw-r--r--boost/python/converter/pyobject_type.hpp7
-rw-r--r--boost/python/detail/config.hpp31
-rw-r--r--boost/python/detail/exception_handler.hpp2
-rw-r--r--[-rwxr-xr-x]boost/python/detail/wrapper_base.hpp2
-rw-r--r--boost/python/errors.hpp2
-rw-r--r--boost/python/numpy.hpp3
-rw-r--r--boost/python/numpy/config.hpp78
-rw-r--r--boost/python/numpy/dtype.hpp7
-rw-r--r--boost/python/numpy/invoke_matching.hpp6
-rw-r--r--boost/python/numpy/matrix.hpp4
-rw-r--r--boost/python/numpy/ndarray.hpp79
-rw-r--r--boost/python/numpy/numpy_object_mgr_traits.hpp4
-rw-r--r--boost/python/numpy/scalars.hpp2
-rw-r--r--boost/python/numpy/ufunc.hpp9
-rw-r--r--boost/python/object/instance.hpp2
15 files changed, 165 insertions, 73 deletions
diff --git a/boost/python/converter/pyobject_type.hpp b/boost/python/converter/pyobject_type.hpp
index 526f9f9dba..bde39e8057 100644
--- a/boost/python/converter/pyobject_type.hpp
+++ b/boost/python/converter/pyobject_type.hpp
@@ -9,8 +9,11 @@
namespace boost { namespace python { namespace converter {
-BOOST_PYTHON_DECL PyObject* checked_downcast_impl(PyObject*, PyTypeObject*);
-
+BOOST_PYTHON_DECL inline
+PyObject* checked_downcast_impl(PyObject *obj, PyTypeObject *type)
+{
+ return (PyType_IsSubtype(Py_TYPE(obj), type) ? obj : NULL);
+}
// Used as a base class for specializations which need to provide
// Python type checking capability.
template <class Object, PyTypeObject* pytype>
diff --git a/boost/python/detail/config.hpp b/boost/python/detail/config.hpp
index 11c16308fb..c92ecb32b0 100644
--- a/boost/python/detail/config.hpp
+++ b/boost/python/detail/config.hpp
@@ -64,31 +64,18 @@
#endif
#if defined(BOOST_PYTHON_DYNAMIC_LIB)
-
-# if !defined(_WIN32) && !defined(__CYGWIN__) \
- && !defined(BOOST_PYTHON_USE_GCC_SYMBOL_VISIBILITY) \
- && BOOST_WORKAROUND(__GNUC__, >= 3) && (__GNUC_MINOR__ >=5 || __GNUC__ > 3)
-# define BOOST_PYTHON_USE_GCC_SYMBOL_VISIBILITY 1
-# endif
-
-# if BOOST_PYTHON_USE_GCC_SYMBOL_VISIBILITY
+# if defined(BOOST_SYMBOL_EXPORT)
# if defined(BOOST_PYTHON_SOURCE)
-# define BOOST_PYTHON_DECL __attribute__ ((__visibility__("default")))
+# define BOOST_PYTHON_DECL BOOST_SYMBOL_EXPORT
+# define BOOST_PYTHON_DECL_FORWARD BOOST_SYMBOL_FORWARD_EXPORT
+# define BOOST_PYTHON_DECL_EXCEPTION BOOST_EXCEPTION_EXPORT
# define BOOST_PYTHON_BUILD_DLL
# else
-# define BOOST_PYTHON_DECL
-# endif
-# define BOOST_PYTHON_DECL_FORWARD
-# define BOOST_PYTHON_DECL_EXCEPTION __attribute__ ((__visibility__("default")))
-# elif (defined(_WIN32) || defined(__CYGWIN__))
-# if defined(BOOST_PYTHON_SOURCE)
-# define BOOST_PYTHON_DECL __declspec(dllexport)
-# define BOOST_PYTHON_BUILD_DLL
-# else
-# define BOOST_PYTHON_DECL __declspec(dllimport)
+# define BOOST_PYTHON_DECL BOOST_SYMBOL_IMPORT
+# define BOOST_PYTHON_DECL_FORWARD BOOST_SYMBOL_FORWARD_IMPORT
+# define BOOST_PYTHON_DECL_EXCEPTION BOOST_EXCEPTION_IMPORT
# endif
# endif
-
#endif
#ifndef BOOST_PYTHON_DECL
@@ -96,11 +83,11 @@
#endif
#ifndef BOOST_PYTHON_DECL_FORWARD
-# define BOOST_PYTHON_DECL_FORWARD BOOST_PYTHON_DECL
+# define BOOST_PYTHON_DECL_FORWARD
#endif
#ifndef BOOST_PYTHON_DECL_EXCEPTION
-# define BOOST_PYTHON_DECL_EXCEPTION BOOST_PYTHON_DECL
+# define BOOST_PYTHON_DECL_EXCEPTION
#endif
#if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042))
diff --git a/boost/python/detail/exception_handler.hpp b/boost/python/detail/exception_handler.hpp
index 7f49868be6..fdc9989836 100644
--- a/boost/python/detail/exception_handler.hpp
+++ b/boost/python/detail/exception_handler.hpp
@@ -11,7 +11,7 @@
namespace boost { namespace python { namespace detail {
-struct BOOST_PYTHON_DECL_FORWARD exception_handler;
+struct exception_handler;
typedef function2<bool, exception_handler const&, function0<void> const&> handler_function;
diff --git a/boost/python/detail/wrapper_base.hpp b/boost/python/detail/wrapper_base.hpp
index e5b93aa449..2a79e0c528 100755..100644
--- a/boost/python/detail/wrapper_base.hpp
+++ b/boost/python/detail/wrapper_base.hpp
@@ -14,7 +14,7 @@ class override;
namespace detail
{
- class BOOST_PYTHON_DECL_FORWARD wrapper_base;
+ class wrapper_base;
namespace wrapper_base_ // ADL disabler
{
diff --git a/boost/python/errors.hpp b/boost/python/errors.hpp
index 72960d9ea2..1eec6c2fe6 100644
--- a/boost/python/errors.hpp
+++ b/boost/python/errors.hpp
@@ -14,7 +14,7 @@
namespace boost { namespace python {
-struct BOOST_PYTHON_DECL_EXCEPTION error_already_set
+struct BOOST_PYTHON_DECL error_already_set
{
virtual ~error_already_set();
};
diff --git a/boost/python/numpy.hpp b/boost/python/numpy.hpp
index cd5876a8e4..18a6389d51 100644
--- a/boost/python/numpy.hpp
+++ b/boost/python/numpy.hpp
@@ -13,6 +13,7 @@
#include <boost/python/numpy/matrix.hpp>
#include <boost/python/numpy/ufunc.hpp>
#include <boost/python/numpy/invoke_matching.hpp>
+#include <boost/python/numpy/config.hpp>
namespace boost { namespace python { namespace numpy {
@@ -26,7 +27,7 @@ namespace boost { namespace python { namespace numpy {
* and "import_ufunc()", and then calls
* dtype::register_scalar_converters().
*/
-void initialize(bool register_scalar_converters=true);
+BOOST_NUMPY_DECL void initialize(bool register_scalar_converters=true);
}}} // namespace boost::python::numpy
diff --git a/boost/python/numpy/config.hpp b/boost/python/numpy/config.hpp
new file mode 100644
index 0000000000..6f39d3ce86
--- /dev/null
+++ b/boost/python/numpy/config.hpp
@@ -0,0 +1,78 @@
+// (C) Copyright Samuli-Petrus Korhonen 2017.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// The author gratefully acknowleges the support of NMR Solutions, Inc., in
+// producing this work.
+
+// Revision History:
+// 15 Feb 17 Initial version
+
+#ifndef CONFIG_NUMPY20170215_H_
+# define CONFIG_NUMPY20170215_H_
+
+# include <boost/config.hpp>
+
+/*****************************************************************************
+ *
+ * Set up dll import/export options:
+ *
+ ****************************************************************************/
+
+// backwards compatibility:
+#ifdef BOOST_NUMPY_STATIC_LIB
+# define BOOST_NUMPY_STATIC_LINK
+# elif !defined(BOOST_NUMPY_DYNAMIC_LIB)
+# define BOOST_NUMPY_DYNAMIC_LIB
+#endif
+
+#if defined(BOOST_NUMPY_DYNAMIC_LIB)
+# if defined(BOOST_SYMBOL_EXPORT)
+# if defined(BOOST_NUMPY_SOURCE)
+# define BOOST_NUMPY_DECL BOOST_SYMBOL_EXPORT
+# define BOOST_NUMPY_DECL_FORWARD BOOST_SYMBOL_FORWARD_EXPORT
+# define BOOST_NUMPY_DECL_EXCEPTION BOOST_EXCEPTION_EXPORT
+# define BOOST_NUMPY_BUILD_DLL
+# else
+# define BOOST_NUMPY_DECL BOOST_SYMBOL_IMPORT
+# define BOOST_NUMPY_DECL_FORWARD BOOST_SYMBOL_FORWARD_IMPORT
+# define BOOST_NUMPY_DECL_EXCEPTION BOOST_EXCEPTION_IMPORT
+# endif
+# endif
+
+#endif
+
+#ifndef BOOST_NUMPY_DECL
+# define BOOST_NUMPY_DECL
+#endif
+
+#ifndef BOOST_NUMPY_DECL_FORWARD
+# define BOOST_NUMPY_DECL_FORWARD
+#endif
+
+#ifndef BOOST_NUMPY_DECL_EXCEPTION
+# define BOOST_NUMPY_DECL_EXCEPTION
+#endif
+
+// enable automatic library variant selection ------------------------------//
+
+#if !defined(BOOST_NUMPY_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_NUMPY_NO_LIB)
+//
+// Set the name of our library, this will get undef'ed by auto_link.hpp
+// once it's done with it:
+//
+#define BOOST_LIB_NAME boost_numpy
+//
+// If we're importing code from a dll, then tell auto_link.hpp about it:
+//
+#ifdef BOOST_NUMPY_DYNAMIC_LIB
+# define BOOST_DYN_LINK
+#endif
+//
+// And include the header that does the work:
+//
+#include <boost/config/auto_link.hpp>
+#endif // auto-linking disabled
+
+#endif // CONFIG_NUMPY20170215_H_
diff --git a/boost/python/numpy/dtype.hpp b/boost/python/numpy/dtype.hpp
index 1284f9e5d8..b9e95f9beb 100644
--- a/boost/python/numpy/dtype.hpp
+++ b/boost/python/numpy/dtype.hpp
@@ -14,6 +14,7 @@
#include <boost/python.hpp>
#include <boost/python/numpy/numpy_object_mgr_traits.hpp>
+#include <boost/python/numpy/config.hpp>
#include <boost/mpl/for_each.hpp>
#include <boost/type_traits/add_pointer.hpp>
@@ -25,7 +26,7 @@ namespace boost { namespace python { namespace numpy {
*
* @todo This could have a lot more interesting accessors.
*/
-class dtype : public object {
+class BOOST_NUMPY_DECL dtype : public object {
static python::detail::new_reference convert(object::object_cref arg, bool align);
public:
@@ -55,7 +56,7 @@ public:
* This is more permissive than equality tests. For instance, if long and int are the same
* size, the dtypes corresponding to each will be equivalent, but not equal.
*/
- friend bool equivalent(dtype const & a, dtype const & b);
+ friend BOOST_NUMPY_DECL bool equivalent(dtype const & a, dtype const & b);
/**
* @brief Register from-Python converters for NumPy's built-in array scalar types.
@@ -69,7 +70,7 @@ public:
};
-bool equivalent(dtype const & a, dtype const & b);
+BOOST_NUMPY_DECL bool equivalent(dtype const & a, dtype const & b);
namespace detail
{
diff --git a/boost/python/numpy/invoke_matching.hpp b/boost/python/numpy/invoke_matching.hpp
index 90ec8ae2cb..095ca3a8db 100644
--- a/boost/python/numpy/invoke_matching.hpp
+++ b/boost/python/numpy/invoke_matching.hpp
@@ -19,7 +19,7 @@ namespace boost { namespace python { namespace numpy {
namespace detail
{
-struct add_pointer_meta
+struct BOOST_NUMPY_DECL add_pointer_meta
{
template <typename T>
struct apply
@@ -29,8 +29,8 @@ struct add_pointer_meta
};
-struct dtype_template_match_found {};
-struct nd_template_match_found {};
+struct BOOST_NUMPY_DECL dtype_template_match_found {};
+struct BOOST_NUMPY_DECL nd_template_match_found {};
template <typename Function>
struct dtype_template_invoker
diff --git a/boost/python/numpy/matrix.hpp b/boost/python/numpy/matrix.hpp
index af20e8f9be..829f544af5 100644
--- a/boost/python/numpy/matrix.hpp
+++ b/boost/python/numpy/matrix.hpp
@@ -14,6 +14,8 @@
#include <boost/python.hpp>
#include <boost/python/numpy/numpy_object_mgr_traits.hpp>
#include <boost/python/numpy/ndarray.hpp>
+#include <boost/python/numpy/config.hpp>
+
namespace boost { namespace python { namespace numpy {
@@ -27,7 +29,7 @@ namespace boost { namespace python { namespace numpy {
* bad things happen when Python shuts down. I think this solution is safe, but I'd
* love to get that confirmed.
*/
-class matrix : public ndarray
+class BOOST_NUMPY_DECL matrix : public ndarray
{
static object construct(object_cref obj, dtype const & dt, bool copy);
static object construct(object_cref obj, bool copy);
diff --git a/boost/python/numpy/ndarray.hpp b/boost/python/numpy/ndarray.hpp
index 2985907b5b..e5b6a9e94b 100644
--- a/boost/python/numpy/ndarray.hpp
+++ b/boost/python/numpy/ndarray.hpp
@@ -16,6 +16,8 @@
#include <boost/type_traits/is_integral.hpp>
#include <boost/python/numpy/numpy_object_mgr_traits.hpp>
#include <boost/python/numpy/dtype.hpp>
+#include <boost/python/numpy/config.hpp>
+
#include <vector>
namespace boost { namespace python { namespace numpy {
@@ -26,7 +28,8 @@ namespace boost { namespace python { namespace numpy {
* @todo This could have a lot more functionality (like boost::python::numeric::array).
* Right now all that exists is what was needed to move raw data between C++ and Python.
*/
-class ndarray : public object
+
+class BOOST_NUMPY_DECL ndarray : public object
{
/**
@@ -139,32 +142,32 @@ public:
/**
* @brief Construct a new array with the given shape and data type, with data initialized to zero.
*/
-ndarray zeros(python::tuple const & shape, dtype const & dt);
-ndarray zeros(int nd, Py_intptr_t const * shape, dtype const & dt);
+BOOST_NUMPY_DECL ndarray zeros(python::tuple const & shape, dtype const & dt);
+BOOST_NUMPY_DECL ndarray zeros(int nd, Py_intptr_t const * shape, dtype const & dt);
/**
* @brief Construct a new array with the given shape and data type, with data left uninitialized.
*/
-ndarray empty(python::tuple const & shape, dtype const & dt);
-ndarray empty(int nd, Py_intptr_t const * shape, dtype const & dt);
+BOOST_NUMPY_DECL ndarray empty(python::tuple const & shape, dtype const & dt);
+BOOST_NUMPY_DECL ndarray empty(int nd, Py_intptr_t const * shape, dtype const & dt);
/**
* @brief Construct a new array from an arbitrary Python sequence.
*
* @todo This does't seem to handle ndarray subtypes the same way that "numpy.array" does in Python.
*/
-ndarray array(object const & obj);
-ndarray array(object const & obj, dtype const & dt);
+BOOST_NUMPY_DECL ndarray array(object const & obj);
+BOOST_NUMPY_DECL ndarray array(object const & obj, dtype const & dt);
namespace detail
{
-ndarray from_data_impl(void * data,
- dtype const & dt,
- std::vector<Py_intptr_t> const & shape,
- std::vector<Py_intptr_t> const & strides,
- object const & owner,
- bool writeable);
+BOOST_NUMPY_DECL ndarray from_data_impl(void * data,
+ dtype const & dt,
+ std::vector<Py_intptr_t> const & shape,
+ std::vector<Py_intptr_t> const & strides,
+ object const & owner,
+ bool writeable);
template <typename Container>
ndarray from_data_impl(void * data,
@@ -180,12 +183,12 @@ ndarray from_data_impl(void * data,
return from_data_impl(data, dt, shape_, strides_, owner, writeable);
}
-ndarray from_data_impl(void * data,
- dtype const & dt,
- object const & shape,
- object const & strides,
- object const & owner,
- bool writeable);
+BOOST_NUMPY_DECL ndarray from_data_impl(void * data,
+ dtype const & dt,
+ object const & shape,
+ object const & strides,
+ object const & owner,
+ bool writeable);
} // namespace boost::python::numpy::detail
@@ -247,39 +250,53 @@ inline ndarray from_data(void const * data,
* @param[in] nd_max Maximum number of dimensions.
* @param[in] flags Bitwise OR of flags specifying additional requirements.
*/
-ndarray from_object(object const & obj, dtype const & dt,
- int nd_min, int nd_max, ndarray::bitflag flags=ndarray::NONE);
-
-inline ndarray from_object(object const & obj, dtype const & dt,
- int nd, ndarray::bitflag flags=ndarray::NONE)
+BOOST_NUMPY_DECL ndarray from_object(object const & obj,
+ dtype const & dt,
+ int nd_min,
+ int nd_max,
+ ndarray::bitflag flags=ndarray::NONE);
+
+BOOST_NUMPY_DECL inline ndarray from_object(object const & obj,
+ dtype const & dt,
+ int nd,
+ ndarray::bitflag flags=ndarray::NONE)
{
return from_object(obj, dt, nd, nd, flags);
}
-inline ndarray from_object(object const & obj, dtype const & dt, ndarray::bitflag flags=ndarray::NONE)
+BOOST_NUMPY_DECL inline ndarray from_object(object const & obj,
+ dtype const & dt,
+ ndarray::bitflag flags=ndarray::NONE)
{
return from_object(obj, dt, 0, 0, flags);
}
-ndarray from_object(object const & obj, int nd_min, int nd_max,
- ndarray::bitflag flags=ndarray::NONE);
+BOOST_NUMPY_DECL ndarray from_object(object const & obj,
+ int nd_min,
+ int nd_max,
+ ndarray::bitflag flags=ndarray::NONE);
-inline ndarray from_object(object const & obj, int nd, ndarray::bitflag flags=ndarray::NONE)
+BOOST_NUMPY_DECL inline ndarray from_object(object const & obj,
+ int nd,
+ ndarray::bitflag flags=ndarray::NONE)
{
return from_object(obj, nd, nd, flags);
}
-inline ndarray from_object(object const & obj, ndarray::bitflag flags=ndarray::NONE)
+BOOST_NUMPY_DECL inline ndarray from_object(object const & obj,
+ ndarray::bitflag flags=ndarray::NONE)
{
return from_object(obj, 0, 0, flags);
}
-inline ndarray::bitflag operator|(ndarray::bitflag a, ndarray::bitflag b)
+BOOST_NUMPY_DECL inline ndarray::bitflag operator|(ndarray::bitflag a,
+ ndarray::bitflag b)
{
return ndarray::bitflag(int(a) | int(b));
}
-inline ndarray::bitflag operator&(ndarray::bitflag a, ndarray::bitflag b)
+BOOST_NUMPY_DECL inline ndarray::bitflag operator&(ndarray::bitflag a,
+ ndarray::bitflag b)
{
return ndarray::bitflag(int(a) & int(b));
}
diff --git a/boost/python/numpy/numpy_object_mgr_traits.hpp b/boost/python/numpy/numpy_object_mgr_traits.hpp
index 8f9f444074..a138f4cd52 100644
--- a/boost/python/numpy/numpy_object_mgr_traits.hpp
+++ b/boost/python/numpy/numpy_object_mgr_traits.hpp
@@ -7,6 +7,8 @@
#ifndef boost_python_numpy_numpy_object_mgr_traits_hpp_
#define boost_python_numpy_numpy_object_mgr_traits_hpp_
+#include <boost/python/numpy/config.hpp>
+
/**
* @brief Macro that specializes object_manager_traits by requiring a
* source-file implementation of get_pytype().
@@ -14,7 +16,7 @@
#define NUMPY_OBJECT_MANAGER_TRAITS(manager) \
template <> \
-struct object_manager_traits<manager> \
+struct BOOST_NUMPY_DECL object_manager_traits<manager> \
{ \
BOOST_STATIC_CONSTANT(bool, is_specialized = true); \
static inline python::detail::new_reference adopt(PyObject* x) \
diff --git a/boost/python/numpy/scalars.hpp b/boost/python/numpy/scalars.hpp
index 0ba23c41ac..c2a83d8253 100644
--- a/boost/python/numpy/scalars.hpp
+++ b/boost/python/numpy/scalars.hpp
@@ -22,7 +22,7 @@ namespace boost { namespace python { namespace numpy {
*
* @todo This could have a lot more functionality.
*/
-class void_ : public object
+class BOOST_NUMPY_DECL void_ : public object
{
static python::detail::new_reference convert(object_cref arg, bool align);
public:
diff --git a/boost/python/numpy/ufunc.hpp b/boost/python/numpy/ufunc.hpp
index 9262b37840..7e249238af 100644
--- a/boost/python/numpy/ufunc.hpp
+++ b/boost/python/numpy/ufunc.hpp
@@ -15,6 +15,7 @@
#include <boost/python/numpy/numpy_object_mgr_traits.hpp>
#include <boost/python/numpy/dtype.hpp>
#include <boost/python/numpy/ndarray.hpp>
+#include <boost/python/numpy/config.hpp>
namespace boost { namespace python { namespace numpy {
@@ -34,7 +35,7 @@ namespace boost { namespace python { namespace numpy {
* It's more dangerous than most object managers, however - maybe it actually belongs in
* a detail namespace?
*/
-class multi_iter : public object
+class BOOST_NUMPY_DECL multi_iter : public object
{
public:
@@ -61,13 +62,13 @@ public:
};
/// @brief Construct a multi_iter over a single sequence or scalar object.
-multi_iter make_multi_iter(object const & a1);
+BOOST_NUMPY_DECL multi_iter make_multi_iter(object const & a1);
/// @brief Construct a multi_iter by broadcasting two objects.
-multi_iter make_multi_iter(object const & a1, object const & a2);
+BOOST_NUMPY_DECL multi_iter make_multi_iter(object const & a1, object const & a2);
/// @brief Construct a multi_iter by broadcasting three objects.
-multi_iter make_multi_iter(object const & a1, object const & a2, object const & a3);
+BOOST_NUMPY_DECL multi_iter make_multi_iter(object const & a1, object const & a2, object const & a3);
/**
* @brief Helps wrap a C++ functor taking a single scalar argument as a broadcasting ufunc-like
diff --git a/boost/python/object/instance.hpp b/boost/python/object/instance.hpp
index 177576ef82..9c28d6822d 100644
--- a/boost/python/object/instance.hpp
+++ b/boost/python/object/instance.hpp
@@ -11,7 +11,7 @@
namespace boost { namespace python
{
- struct BOOST_PYTHON_DECL_FORWARD instance_holder;
+ struct instance_holder;
}} // namespace boost::python
namespace boost { namespace python { namespace objects {