From 3844c4fc5fa44dcc2b74deb3b2cb1935175ef407 Mon Sep 17 00:00:00 2001 From: Stefan Seefeld Date: Fri, 14 Apr 2017 13:14:05 -0400 Subject: [PATCH 01/11] Fix more missing symbols. --- include/boost/python/numpy/dtype.hpp | 2 +- src/numpy/dtype.cpp | 38 +++++++++++++++------------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/include/boost/python/numpy/dtype.hpp b/include/boost/python/numpy/dtype.hpp index b9e95f9b..834d0016 100644 --- a/include/boost/python/numpy/dtype.hpp +++ b/include/boost/python/numpy/dtype.hpp @@ -90,7 +90,7 @@ struct builtin_dtype { }; template <> -struct builtin_dtype { +struct BOOST_NUMPY_DECL builtin_dtype { static dtype get(); }; diff --git a/src/numpy/dtype.cpp b/src/numpy/dtype.cpp index 13904ddd..e0a22299 100644 --- a/src/numpy/dtype.cpp +++ b/src/numpy/dtype.cpp @@ -11,29 +11,33 @@ #include #define DTYPE_FROM_CODE(code) \ - dtype(python::detail::new_reference(reinterpret_cast(PyArray_DescrFromType(code)))) + dtype(python::detail::new_reference(reinterpret_cast(PyArray_DescrFromType(code)))) #define BUILTIN_INT_DTYPE(bits) \ - template <> struct builtin_int_dtype< bits, false > { \ - static dtype get() { return DTYPE_FROM_CODE(NPY_INT ## bits); } \ - }; \ - template <> struct builtin_int_dtype< bits, true > { \ - static dtype get() { return DTYPE_FROM_CODE(NPY_UINT ## bits); } \ - }; \ - template dtype get_int_dtype< bits, false >(); \ - template dtype get_int_dtype< bits, true >() + template <> struct builtin_int_dtype \ + { \ + static dtype get() { return DTYPE_FROM_CODE(NPY_INT ## bits);} \ + }; \ + template <> struct builtin_int_dtype \ + { \ + static dtype get() { return DTYPE_FROM_CODE(NPY_UINT ## bits);} \ + }; \ + template BOOST_NUMPY_DECL dtype get_int_dtype(); \ + template BOOST_NUMPY_DECL dtype get_int_dtype() #define BUILTIN_FLOAT_DTYPE(bits) \ - template <> struct builtin_float_dtype< bits > { \ - static dtype get() { return DTYPE_FROM_CODE(NPY_FLOAT ## bits); } \ - }; \ - template dtype get_float_dtype< bits >() + template <> struct builtin_float_dtype \ + { \ + static dtype get() { return DTYPE_FROM_CODE(NPY_FLOAT ## bits);} \ + }; \ + template BOOST_NUMPY_DECL dtype get_float_dtype() #define BUILTIN_COMPLEX_DTYPE(bits) \ - template <> struct builtin_complex_dtype< bits > { \ - static dtype get() { return DTYPE_FROM_CODE(NPY_COMPLEX ## bits); } \ - }; \ - template dtype get_complex_dtype< bits >() + template <> struct builtin_complex_dtype \ + { \ + static dtype get() { return DTYPE_FROM_CODE(NPY_COMPLEX ## bits);} \ + }; \ + template BOOST_NUMPY_DECL dtype get_complex_dtype() namespace boost { namespace python { namespace converter { NUMPY_OBJECT_MANAGER_TRAITS_IMPL(PyArrayDescr_Type, numpy::dtype) From b2f53e1acfe08829de63637c2adc13ccfa5fe034 Mon Sep 17 00:00:00 2001 From: John Zwinck Date: Fri, 21 Oct 2016 15:55:06 +0800 Subject: [PATCH 02/11] exec/eval(): add overloads for char const* Many times the caller may have a string created in C++, so there is no need to wrap it in a Python object when the only thing done with the object is extract. --- doc/tutorial.qbk | 2 ++ include/boost/python/exec.hpp | 16 ++++++++++ src/exec.cpp | 56 ++++++++++++++++++++++++----------- 3 files changed, 56 insertions(+), 18 deletions(-) diff --git a/doc/tutorial.qbk b/doc/tutorial.qbk index 74126476..a1f7fc24 100644 --- a/doc/tutorial.qbk +++ b/doc/tutorial.qbk @@ -1417,6 +1417,8 @@ eval evaluates the given expression and returns the resulting value. exec executes the given code (typically a set of statements) returning the result, and exec_file executes the code contained in the given file. +There are also overloads taking `char const*` instead of str as the first argument. + The [^globals] and [^locals] parameters are Python dictionaries containing the globals and locals of the context in which to run the code. For most intents and purposes you can use the namespace dictionary of the diff --git a/include/boost/python/exec.hpp b/include/boost/python/exec.hpp index 3ed1e15c..32a74991 100644 --- a/include/boost/python/exec.hpp +++ b/include/boost/python/exec.hpp @@ -20,6 +20,10 @@ object BOOST_PYTHON_DECL eval(str string, object global = object(), object local = object()); +object +BOOST_PYTHON_DECL +eval(char const *string, object global = object(), object local = object()); + // Execute an individual python statement from str. // global and local are the global and local scopes respectively, // used during execution. @@ -27,6 +31,10 @@ object BOOST_PYTHON_DECL exec_statement(str string, object global = object(), object local = object()); +object +BOOST_PYTHON_DECL +exec_statement(char const *string, object global = object(), object local = object()); + // Execute python source code from str. // global and local are the global and local scopes respectively, // used during execution. @@ -34,6 +42,10 @@ object BOOST_PYTHON_DECL exec(str string, object global = object(), object local = object()); +object +BOOST_PYTHON_DECL +exec(char const *string, object global = object(), object local = object()); + // Execute python source code from file filename. // global and local are the global and local scopes respectively, // used during execution. @@ -41,6 +53,10 @@ object BOOST_PYTHON_DECL exec_file(str filename, object global = object(), object local = object()); +object +BOOST_PYTHON_DECL +exec_file(char const *filename, object global = object(), object local = object()); + } } diff --git a/src/exec.cpp b/src/exec.cpp index fa2860e4..603a6f01 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -15,6 +15,11 @@ namespace python { object BOOST_PYTHON_DECL eval(str string, object global, object local) +{ + return eval(python::extract(string)); +} + +object BOOST_PYTHON_DECL eval(char const *string, object global, object local) { // Set suitable default values for global and local dicts. if (global.is_none()) @@ -26,7 +31,7 @@ object BOOST_PYTHON_DECL eval(str string, object global, object local) } if (local.is_none()) local = global; // should be 'char const *' but older python versions don't use 'const' yet. - char *s = python::extract(string); + char *s = const_cast(string); PyObject* result = PyRun_String(s, Py_eval_input, global.ptr(), local.ptr()); if (!result) throw_error_already_set(); return object(detail::new_reference(result)); @@ -34,23 +39,10 @@ object BOOST_PYTHON_DECL eval(str string, object global, object local) object BOOST_PYTHON_DECL exec(str string, object global, object local) { - // Set suitable default values for global and local dicts. - if (global.is_none()) - { - if (PyObject *g = PyEval_GetGlobals()) - global = object(detail::borrowed_reference(g)); - else - global = dict(); - } - if (local.is_none()) local = global; - // should be 'char const *' but older python versions don't use 'const' yet. - char *s = python::extract(string); - PyObject* result = PyRun_String(s, Py_file_input, global.ptr(), local.ptr()); - if (!result) throw_error_already_set(); - return object(detail::new_reference(result)); + return exec(python::extract(string)); } -object BOOST_PYTHON_DECL exec_statement(str string, object global, object local) +object BOOST_PYTHON_DECL exec(char const *string, object global, object local) { // Set suitable default values for global and local dicts. if (global.is_none()) @@ -62,7 +54,30 @@ object BOOST_PYTHON_DECL exec_statement(str string, object global, object local) } if (local.is_none()) local = global; // should be 'char const *' but older python versions don't use 'const' yet. - char *s = python::extract(string); + char *s = const_cast(string); + PyObject* result = PyRun_String(s, Py_file_input, global.ptr(), local.ptr()); + if (!result) throw_error_already_set(); + return object(detail::new_reference(result)); +} + +object BOOST_PYTHON_DECL exec_statement(str string, object global, object local) +{ + return exec_statement(python::extract(string), global, local); +} + +object BOOST_PYTHON_DECL exec_statement(char const *string, object global, object local) +{ + // Set suitable default values for global and local dicts. + if (global.is_none()) + { + if (PyObject *g = PyEval_GetGlobals()) + global = object(detail::borrowed_reference(g)); + else + global = dict(); + } + if (local.is_none()) local = global; + // should be 'char const *' but older python versions don't use 'const' yet. + char *s = const_cast(string); PyObject* result = PyRun_String(s, Py_single_input, global.ptr(), local.ptr()); if (!result) throw_error_already_set(); return object(detail::new_reference(result)); @@ -72,6 +87,11 @@ object BOOST_PYTHON_DECL exec_statement(str string, object global, object local) // global and local are the global and local scopes respectively, // used during execution. object BOOST_PYTHON_DECL exec_file(str filename, object global, object local) +{ + return exec_file(python::extract(filename), global, local); +} + +object BOOST_PYTHON_DECL exec_file(char const *filename, object global, object local) { // Set suitable default values for global and local dicts. if (global.is_none()) @@ -83,7 +103,7 @@ object BOOST_PYTHON_DECL exec_file(str filename, object global, object local) } if (local.is_none()) local = global; // should be 'char const *' but older python versions don't use 'const' yet. - char *f = python::extract(filename); + char *f = const_cast(filename); // Let python open the file to avoid potential binary incompatibilities. #if PY_VERSION_HEX >= 0x03040000 FILE *fs = _Py_fopen(f, "r"); From 36131428399835ff4861325dce354d81096986eb Mon Sep 17 00:00:00 2001 From: Saliya Date: Mon, 8 May 2017 17:12:36 +0530 Subject: [PATCH 03/11] =?UTF-8?q?Fixing=20compiling=20error=20'error:=20?= =?UTF-8?q?=E2=80=98NPY=5FFLOAT16=E2=80=99=20was=20not=20declared=20in=20t?= =?UTF-8?q?his=20scope'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Saliya --- src/numpy/dtype.cpp | 2 ++ 1 file changed, 2 insertions(+) mode change 100644 => 100755 src/numpy/dtype.cpp diff --git a/src/numpy/dtype.cpp b/src/numpy/dtype.cpp old mode 100644 new mode 100755 index e0a22299..88a20a27 --- a/src/numpy/dtype.cpp +++ b/src/numpy/dtype.cpp @@ -62,7 +62,9 @@ BUILTIN_INT_DTYPE(8); BUILTIN_INT_DTYPE(16); BUILTIN_INT_DTYPE(32); BUILTIN_INT_DTYPE(64); +#ifdef NPY_FLOAT16 BUILTIN_FLOAT_DTYPE(16); +#endif BUILTIN_FLOAT_DTYPE(32); BUILTIN_FLOAT_DTYPE(64); BUILTIN_COMPLEX_DTYPE(64); From 1452dfe713ac17751b062846f6a87e51e12a31c9 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Fri, 2 Jun 2017 14:59:41 +0200 Subject: [PATCH 04/11] Reencoded a few headers that used Windows-1252 with UTF-8. Nearly every header in the boost codebase is UTF-8, but here there are a few headers which are using Windows-1252, which makes it impossible for some tools to parse those files. This patch just reencodes them with UTF-8 like the rest of the codebase. I checked that the name of the author is still correct after this change. No functional change intended. --- include/boost/python/detail/dealloc.hpp | 2 +- include/boost/python/opaque_pointer_converter.hpp | 2 +- include/boost/python/return_opaque_pointer.hpp | 2 +- test/crossmod_opaque.py | 2 +- test/crossmod_opaque_a.cpp | 2 +- test/crossmod_opaque_b.cpp | 2 +- test/opaque.py | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/boost/python/detail/dealloc.hpp b/include/boost/python/detail/dealloc.hpp index f2d914b1..ce07926e 100644 --- a/include/boost/python/detail/dealloc.hpp +++ b/include/boost/python/detail/dealloc.hpp @@ -1,4 +1,4 @@ -// Copyright Gottfried Ganßauge 2003. +// Copyright Gottfried Ganßauge 2003. // 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) diff --git a/include/boost/python/opaque_pointer_converter.hpp b/include/boost/python/opaque_pointer_converter.hpp index e95c49bb..c46a65a8 100644 --- a/include/boost/python/opaque_pointer_converter.hpp +++ b/include/boost/python/opaque_pointer_converter.hpp @@ -1,4 +1,4 @@ -// Copyright Gottfried Ganßauge 2003..2006. +// Copyright Gottfried Ganßauge 2003..2006. // 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) diff --git a/include/boost/python/return_opaque_pointer.hpp b/include/boost/python/return_opaque_pointer.hpp index cf544d80..4654e3bd 100644 --- a/include/boost/python/return_opaque_pointer.hpp +++ b/include/boost/python/return_opaque_pointer.hpp @@ -1,4 +1,4 @@ -// Copyright Gottfried Ganßauge 2003. +// Copyright Gottfried Ganßauge 2003. // 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) diff --git a/test/crossmod_opaque.py b/test/crossmod_opaque.py index e542fa6d..c51aac76 100644 --- a/test/crossmod_opaque.py +++ b/test/crossmod_opaque.py @@ -1,5 +1,5 @@ # -*- coding: latin-1 -*- -# Copyright Gottfried Ganßauge 2006. +# Copyright Gottfried Ganßauge 2006. # 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) diff --git a/test/crossmod_opaque_a.cpp b/test/crossmod_opaque_a.cpp index 80283f47..62ed4331 100644 --- a/test/crossmod_opaque_a.cpp +++ b/test/crossmod_opaque_a.cpp @@ -1,4 +1,4 @@ -// Copyright Gottfried Ganßauge 2006. +// Copyright Gottfried Ganßauge 2006. // 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) diff --git a/test/crossmod_opaque_b.cpp b/test/crossmod_opaque_b.cpp index 1e3e18bc..3d661339 100644 --- a/test/crossmod_opaque_b.cpp +++ b/test/crossmod_opaque_b.cpp @@ -1,4 +1,4 @@ -// Copyright Gottfried Ganßauge 2006. +// Copyright Gottfried Ganßauge 2006. // 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) diff --git a/test/opaque.py b/test/opaque.py index 311b1893..719c4243 100644 --- a/test/opaque.py +++ b/test/opaque.py @@ -1,5 +1,5 @@ # -*- coding: latin-1 -*- -# Copyright Gottfried Ganßauge 2003..2006. Distributed under the Boost +# Copyright Gottfried Ganßauge 2003..2006. 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) From 7cfc47008e54dd3f3c1f100f32fb6df4eab3c9ec Mon Sep 17 00:00:00 2001 From: Stefan Seefeld Date: Fri, 2 Jun 2017 19:30:22 -0400 Subject: [PATCH 05/11] Rename test source --- test/Jamfile | 2 +- test/SConscript | 2 +- test/{test_builtin_converters.cpp => builtin_converters.cpp} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename test/{test_builtin_converters.cpp => builtin_converters.cpp} (100%) diff --git a/test/Jamfile b/test/Jamfile index 72d60d37..7f088cf7 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -115,7 +115,7 @@ bpl-test crossmod_exception [ bpl-test keywords : keywords.cpp keywords_test.py ] -[ python-extension builtin_converters_ext : test_builtin_converters.cpp /boost/python//boost_python ] +[ python-extension builtin_converters_ext : builtin_converters.cpp /boost/python//boost_python ] [ bpl-test builtin_converters : test_builtin_converters.py builtin_converters_ext ] [ bpl-test test_pointer_adoption ] diff --git a/test/SConscript b/test/SConscript index 3a0fcf06..eaeefaca 100644 --- a/test/SConscript +++ b/test/SConscript @@ -116,7 +116,7 @@ else: test = env.BoostRunPythonScript('test_builtin_converters.py') Depends( test, - env.PythonExtension('builtin_converters_ext', ['test_builtin_converters.cpp']) + env.PythonExtension('builtin_converters_ext', ['builtin_converters.cpp']) ) tests+=test test = env.BoostRunPythonScript('map_indexing_suite.py') diff --git a/test/test_builtin_converters.cpp b/test/builtin_converters.cpp similarity index 100% rename from test/test_builtin_converters.cpp rename to test/builtin_converters.cpp From c4fe369d69ffc55391c8d875960651aee9fc6bff Mon Sep 17 00:00:00 2001 From: Stefan Seefeld Date: Fri, 2 Jun 2017 19:31:26 -0400 Subject: [PATCH 06/11] Require NumPy 1.7 API. --- include/boost/python/numpy/config.hpp | 2 ++ include/boost/python/numpy/dtype.hpp | 3 +-- include/boost/python/numpy/internal.hpp | 1 + src/numpy/ndarray.cpp | 28 ++++++++++++------------- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/include/boost/python/numpy/config.hpp b/include/boost/python/numpy/config.hpp index 6f39d3ce..8cd0af47 100644 --- a/include/boost/python/numpy/config.hpp +++ b/include/boost/python/numpy/config.hpp @@ -75,4 +75,6 @@ #include #endif // auto-linking disabled +#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION + #endif // CONFIG_NUMPY20170215_H_ diff --git a/include/boost/python/numpy/dtype.hpp b/include/boost/python/numpy/dtype.hpp index 834d0016..f3aca7db 100644 --- a/include/boost/python/numpy/dtype.hpp +++ b/include/boost/python/numpy/dtype.hpp @@ -13,9 +13,8 @@ */ #include -#include #include - +#include #include #include diff --git a/include/boost/python/numpy/internal.hpp b/include/boost/python/numpy/internal.hpp index fed31cbb..c24718f0 100644 --- a/include/boost/python/numpy/internal.hpp +++ b/include/boost/python/numpy/internal.hpp @@ -15,6 +15,7 @@ */ #include +#include #ifdef BOOST_PYTHON_NUMPY_INTERNAL #define NO_IMPORT_ARRAY #define NO_IMPORT_UFUNC diff --git a/src/numpy/ndarray.cpp b/src/numpy/ndarray.cpp index 710e3d49..8ae67b89 100644 --- a/src/numpy/ndarray.cpp +++ b/src/numpy/ndarray.cpp @@ -22,20 +22,20 @@ namespace detail ndarray::bitflag numpy_to_bitflag(int const f) { ndarray::bitflag r = ndarray::NONE; - if (f & NPY_C_CONTIGUOUS) r = (r | ndarray::C_CONTIGUOUS); - if (f & NPY_F_CONTIGUOUS) r = (r | ndarray::F_CONTIGUOUS); - if (f & NPY_ALIGNED) r = (r | ndarray::ALIGNED); - if (f & NPY_WRITEABLE) r = (r | ndarray::WRITEABLE); + if (f & NPY_ARRAY_C_CONTIGUOUS) r = (r | ndarray::C_CONTIGUOUS); + if (f & NPY_ARRAY_F_CONTIGUOUS) r = (r | ndarray::F_CONTIGUOUS); + if (f & NPY_ARRAY_ALIGNED) r = (r | ndarray::ALIGNED); + if (f & NPY_ARRAY_WRITEABLE) r = (r | ndarray::WRITEABLE); return r; } int bitflag_to_numpy(ndarray::bitflag f) { int r = 0; - if (f & ndarray::C_CONTIGUOUS) r |= NPY_C_CONTIGUOUS; - if (f & ndarray::F_CONTIGUOUS) r |= NPY_F_CONTIGUOUS; - if (f & ndarray::ALIGNED) r |= NPY_ALIGNED; - if (f & ndarray::WRITEABLE) r |= NPY_WRITEABLE; + if (f & ndarray::C_CONTIGUOUS) r |= NPY_ARRAY_C_CONTIGUOUS; + if (f & ndarray::F_CONTIGUOUS) r |= NPY_ARRAY_F_CONTIGUOUS; + if (f & ndarray::ALIGNED) r |= NPY_ARRAY_ALIGNED; + if (f & ndarray::WRITEABLE) r |= NPY_ARRAY_WRITEABLE; return r; } @@ -119,10 +119,10 @@ ndarray from_data_impl(void * data, } int itemsize = dt.get_itemsize(); int flags = 0; - if (writeable) flags |= NPY_WRITEABLE; - if (is_c_contiguous(shape, strides, itemsize)) flags |= NPY_C_CONTIGUOUS; - if (is_f_contiguous(shape, strides, itemsize)) flags |= NPY_F_CONTIGUOUS; - if (is_aligned(strides, itemsize)) flags |= NPY_ALIGNED; + if (writeable) flags |= NPY_ARRAY_WRITEABLE; + if (is_c_contiguous(shape, strides, itemsize)) flags |= NPY_ARRAY_C_CONTIGUOUS; + if (is_f_contiguous(shape, strides, itemsize)) flags |= NPY_ARRAY_F_CONTIGUOUS; + if (is_aligned(strides, itemsize)) flags |= NPY_ARRAY_ALIGNED; ndarray r(python::detail::new_reference (PyArray_NewFromDescr(&PyArray_Type, incref_dtype(dt), @@ -243,13 +243,13 @@ ndarray empty(int nd, Py_intptr_t const * shape, dtype const & dt) ndarray array(python::object const & obj) { return ndarray(python::detail::new_reference - (PyArray_FromAny(obj.ptr(), NULL, 0, 0, NPY_ENSUREARRAY, NULL))); + (PyArray_FromAny(obj.ptr(), NULL, 0, 0, NPY_ARRAY_ENSUREARRAY, NULL))); } ndarray array(python::object const & obj, dtype const & dt) { return ndarray(python::detail::new_reference - (PyArray_FromAny(obj.ptr(), detail::incref_dtype(dt), 0, 0, NPY_ENSUREARRAY, NULL))); + (PyArray_FromAny(obj.ptr(), detail::incref_dtype(dt), 0, 0, NPY_ARRAY_ENSUREARRAY, NULL))); } ndarray from_object(python::object const & obj, dtype const & dt, int nd_min, int nd_max, ndarray::bitflag flags) From 664d443df3d575876a524e7f8c6e3384d254dd34 Mon Sep 17 00:00:00 2001 From: Stefan Seefeld Date: Sat, 3 Jun 2017 18:26:14 -0400 Subject: [PATCH 07/11] Fix Python3 compatibility bug. --- test/test_builtin_converters.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/test_builtin_converters.py b/test/test_builtin_converters.py index adc397e1..e612ed23 100644 --- a/test/test_builtin_converters.py +++ b/test/test_builtin_converters.py @@ -1,6 +1,9 @@ # Copyright David Abrahams 2004. 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) +import sys +if (sys.version_info.major >= 3): + long = int r""" >>> from builtin_converters_ext import * @@ -74,7 +77,7 @@ False test unsigned long values which don't fit in a signed long. strip any 'L' characters in case the platform has > 32 bit longs ->>> hex(rewrap_value_unsigned_long(0x80000001L)).replace('L','') +>>> hex(rewrap_value_unsigned_long(long(0x80000001))).replace('L','') '0x80000001' >>> rewrap_value_long_long(42) == 42 From 90829714cc606ecffabb2a151091f10f81e28259 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Sat, 10 Jun 2017 18:22:57 -0400 Subject: [PATCH 08/11] Fix `BOOST_LIB_NAME` for Python 3 This was reusing the Python 2 name on Python 3, which is incorrect since the Python 3 library for Boost.Python now has a `3` in it. Hence this checks against the Python version and defines this correctly. --- include/boost/python/detail/config.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/boost/python/detail/config.hpp b/include/boost/python/detail/config.hpp index c92ecb32..3e4b7c9e 100644 --- a/include/boost/python/detail/config.hpp +++ b/include/boost/python/detail/config.hpp @@ -105,7 +105,11 @@ // 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_python +#if PY_MAJOR_VERSION == 2 +# define BOOST_LIB_NAME boost_python +#elif PY_MAJOR_VERSION == 3 +# define BOOST_LIB_NAME boost_python3 +#endif // // If we're importing code from a dll, then tell auto_link.hpp about it: // From d6554d6c65383873ab5415f12d04ce14146208b7 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Sat, 10 Jun 2017 22:43:08 -0400 Subject: [PATCH 09/11] Handle `BOOST_LIB_NAME` for NumPy on Python 2/3 This was reusing the Python 2 name on Python 3, which is incorrect since the Python 3 library for Boost.NumPy has a `3` in it. Hence this checks against the Python version and defines this correctly. --- include/boost/python/numpy/config.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/boost/python/numpy/config.hpp b/include/boost/python/numpy/config.hpp index 8cd0af47..97178906 100644 --- a/include/boost/python/numpy/config.hpp +++ b/include/boost/python/numpy/config.hpp @@ -62,7 +62,11 @@ // 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 PY_MAJOR_VERSION == 2 +# define BOOST_LIB_NAME boost_numpy +#elif PY_MAJOR_VERSION == 3 +# define BOOST_LIB_NAME boost_numpy3 +#endif // // If we're importing code from a dll, then tell auto_link.hpp about it: // From 142661dac8feaa0342c04a2160eb10a86175bb54 Mon Sep 17 00:00:00 2001 From: shreyans800755 Date: Sun, 25 Jun 2017 02:03:58 +0530 Subject: [PATCH 10/11] Use std type_traits instead of boost type_traits Fixes https://github.com/boostorg/python/issues/106 --- include/boost/python/arg_from_python.hpp | 6 +- include/boost/python/args.hpp | 11 +- include/boost/python/bases.hpp | 2 +- include/boost/python/cast.hpp | 9 +- include/boost/python/class.hpp | 16 +-- .../python/converter/arg_from_python.hpp | 5 +- .../boost/python/converter/arg_to_python.hpp | 12 +- .../boost/python/converter/object_manager.hpp | 2 +- .../python/converter/pointer_type_id.hpp | 4 +- .../python/converter/pytype_function.hpp | 9 +- include/boost/python/converter/registered.hpp | 8 +- .../python/converter/registered_pointee.hpp | 9 +- .../python/converter/return_from_python.hpp | 2 +- .../converter/rvalue_from_python_data.hpp | 8 +- include/boost/python/data_members.hpp | 59 +++++----- .../boost/python/default_call_policies.hpp | 6 +- include/boost/python/detail/borrowed_ptr.hpp | 3 +- include/boost/python/detail/caller.hpp | 6 +- include/boost/python/detail/convertible.hpp | 4 +- include/boost/python/detail/cv_category.hpp | 6 +- .../boost/python/detail/decorated_type_id.hpp | 2 +- include/boost/python/detail/def_helper.hpp | 6 +- include/boost/python/detail/defaults_def.hpp | 4 +- include/boost/python/detail/destroy.hpp | 6 +- include/boost/python/detail/invoke.hpp | 2 - include/boost/python/detail/pointee.hpp | 2 +- include/boost/python/detail/result.hpp | 2 +- .../boost/python/detail/string_literal.hpp | 3 +- .../python/detail/translate_exception.hpp | 6 +- include/boost/python/detail/type_traits.hpp | 110 ++++++++++++++++++ include/boost/python/detail/unwind_type.hpp | 6 +- include/boost/python/detail/value_arg.hpp | 5 +- include/boost/python/detail/value_is_xxx.hpp | 9 +- include/boost/python/detail/void_ptr.hpp | 2 +- include/boost/python/detail/wrapper_base.hpp | 9 +- include/boost/python/init.hpp | 2 +- include/boost/python/iterator.hpp | 6 +- include/boost/python/lvalue_from_pytype.hpp | 3 +- include/boost/python/make_constructor.hpp | 8 +- include/boost/python/manage_new_object.hpp | 4 +- include/boost/python/numpy/dtype.hpp | 2 +- include/boost/python/numpy/ndarray.hpp | 4 +- .../boost/python/object/class_metadata.hpp | 36 +++--- include/boost/python/object/forward.hpp | 11 +- include/boost/python/object/inheritance.hpp | 7 +- include/boost/python/object/instance.hpp | 6 +- include/boost/python/object/iterator.hpp | 9 +- include/boost/python/object/make_instance.hpp | 5 +- .../boost/python/object/make_ptr_instance.hpp | 8 +- .../boost/python/object/pointer_holder.hpp | 5 +- include/boost/python/object_core.hpp | 17 ++- .../boost/python/opaque_pointer_converter.hpp | 5 +- include/boost/python/pointee.hpp | 10 +- .../python/reference_existing_object.hpp | 4 +- include/boost/python/return_arg.hpp | 3 +- include/boost/python/return_by_value.hpp | 3 +- include/boost/python/signature.hpp | 4 +- .../indexing/detail/indexing_suite_detail.hpp | 6 +- .../python/suite/indexing/indexing_suite.hpp | 10 +- include/boost/python/to_python_indirect.hpp | 15 +-- include/boost/python/to_python_value.hpp | 4 +- include/boost/python/type_id.hpp | 2 +- test/bases.cpp | 10 +- test/enum_ext.cpp | 4 +- test/if_else.cpp | 12 +- test/indirect_traits_test.cpp | 1 - test/pointee.cpp | 8 +- test/select_holder.cpp | 4 +- 68 files changed, 324 insertions(+), 275 deletions(-) create mode 100644 include/boost/python/detail/type_traits.hpp diff --git a/include/boost/python/arg_from_python.hpp b/include/boost/python/arg_from_python.hpp index 05611edb..983726b0 100755 --- a/include/boost/python/arg_from_python.hpp +++ b/include/boost/python/arg_from_python.hpp @@ -9,7 +9,7 @@ # include # if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) \ || BOOST_WORKAROUND(BOOST_INTEL_WIN, BOOST_TESTED_AT(800)) -# include +# include #endif namespace boost { namespace python { @@ -19,7 +19,7 @@ struct arg_from_python : converter::select_arg_from_python< # if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) \ || BOOST_WORKAROUND(BOOST_INTEL_WIN, BOOST_TESTED_AT(800)) - typename boost::remove_cv::type + typename detail::remove_cv::type # else T # endif @@ -28,7 +28,7 @@ struct arg_from_python typedef typename converter::select_arg_from_python< # if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) \ || BOOST_WORKAROUND(BOOST_INTEL_WIN, BOOST_TESTED_AT(800)) - typename boost::remove_cv::type + typename detail::remove_cv::type # else T # endif diff --git a/include/boost/python/args.hpp b/include/boost/python/args.hpp index 55d1283b..27731bd8 100644 --- a/include/boost/python/args.hpp +++ b/include/boost/python/args.hpp @@ -11,10 +11,7 @@ # include # include # include - -# include -# include -# include +# include # include # include @@ -116,9 +113,9 @@ namespace detail template struct is_reference_to_keywords { - BOOST_STATIC_CONSTANT(bool, is_ref = is_reference::value); - typedef typename remove_reference::type deref; - typedef typename remove_cv::type key_t; + BOOST_STATIC_CONSTANT(bool, is_ref = detail::is_reference::value); + typedef typename detail::remove_reference::type deref; + typedef typename detail::remove_cv::type key_t; BOOST_STATIC_CONSTANT(bool, is_key = is_keywords::value); BOOST_STATIC_CONSTANT(bool, value = (is_ref & is_key)); diff --git a/include/boost/python/bases.hpp b/include/boost/python/bases.hpp index 614d6223..efcac3f3 100644 --- a/include/boost/python/bases.hpp +++ b/include/boost/python/bases.hpp @@ -6,8 +6,8 @@ # define BASES_DWA2002321_HPP # include -# include # include +# include # include # include # include diff --git a/include/boost/python/cast.hpp b/include/boost/python/cast.hpp index bad7e282..c0dd229e 100755 --- a/include/boost/python/cast.hpp +++ b/include/boost/python/cast.hpp @@ -6,9 +6,8 @@ # define CAST_DWA200269_HPP # include +# include -# include -# include # include # include # include @@ -76,9 +75,9 @@ namespace detail template inline Target* upcast_impl(Source* x, Target*) { - typedef typename add_cv::type src_t; - typedef typename add_cv::type target_t; - bool const same = is_same::value; + typedef typename detail::add_cv::type src_t; + typedef typename detail::add_cv::type target_t; + bool const same = detail::is_same::value; return detail::upcaster::execute(x, (Target*)0); } diff --git a/include/boost/python/class.hpp b/include/boost/python/class.hpp index 70ca6d01..77f915ba 100644 --- a/include/boost/python/class.hpp +++ b/include/boost/python/class.hpp @@ -28,13 +28,10 @@ # include # include # include +# include # include # include -# include -# include -# include - # include # include # include @@ -53,7 +50,6 @@ # ifdef BOOST_PYTHON_NO_MEMBER_POINTER_ORDERING # include -# include # endif namespace boost { namespace python { @@ -84,8 +80,8 @@ namespace detail template struct is_data_member_pointer : mpl::and_< - is_member_pointer - , mpl::not_ > + detail::is_member_pointer + , mpl::not_ > > {}; @@ -138,11 +134,11 @@ namespace detail must_be_derived_class_member(Default const&) { // https://svn.boost.org/trac/boost/ticket/5803 - //typedef typename assertion > >::failed test0; + //typedef typename assertion > >::failed test0; # if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407) - typedef typename assertion >::failed test1 BOOST_ATTRIBUTE_UNUSED; + typedef typename assertion >::failed test1 BOOST_ATTRIBUTE_UNUSED; # endif - typedef typename assertion >::failed test2 BOOST_ATTRIBUTE_UNUSED; + typedef typename assertion >::failed test2 BOOST_ATTRIBUTE_UNUSED; not_a_derived_class_member(Fn()); } }; diff --git a/include/boost/python/converter/arg_from_python.hpp b/include/boost/python/converter/arg_from_python.hpp index 61bbaad5..0c0daabc 100644 --- a/include/boost/python/converter/arg_from_python.hpp +++ b/include/boost/python/converter/arg_from_python.hpp @@ -8,8 +8,7 @@ # include # include # include -# include -# include +# include # include # include # include @@ -106,7 +105,7 @@ struct reference_arg_from_python : arg_lvalue_from_python_base template struct arg_rvalue_from_python { - typedef typename boost::add_reference< + typedef typename boost::python::detail::add_lvalue_reference< T // We can't add_const here, or it would be impossible to pass // auto_ptr args from Python to C++ diff --git a/include/boost/python/converter/arg_to_python.hpp b/include/boost/python/converter/arg_to_python.hpp index 3a19ec43..bbecae72 100755 --- a/include/boost/python/converter/arg_to_python.hpp +++ b/include/boost/python/converter/arg_to_python.hpp @@ -24,11 +24,7 @@ # include # include # include - -# include -# include -# include - +# include # include @@ -116,9 +112,9 @@ namespace detail , typename mpl::if_< mpl::or_< - is_function + boost::python::detail::is_function , indirect_traits::is_pointer_to_function - , is_member_function_pointer + , boost::python::detail::is_member_function_pointer > , function_arg_to_python @@ -127,7 +123,7 @@ namespace detail , object_manager_arg_to_python , typename mpl::if_< - is_pointer + boost::python::detail::is_pointer , pointer_deep_arg_to_python , typename mpl::if_< diff --git a/include/boost/python/converter/object_manager.hpp b/include/boost/python/converter/object_manager.hpp index 46682455..b2271a7e 100644 --- a/include/boost/python/converter/object_manager.hpp +++ b/include/boost/python/converter/object_manager.hpp @@ -8,7 +8,7 @@ # include # include # include -# include +# include # include # include # include diff --git a/include/boost/python/converter/pointer_type_id.hpp b/include/boost/python/converter/pointer_type_id.hpp index 963f58f7..49eeda42 100644 --- a/include/boost/python/converter/pointer_type_id.hpp +++ b/include/boost/python/converter/pointer_type_id.hpp @@ -6,7 +6,7 @@ # define POINTER_TYPE_ID_DWA2002222_HPP # include -# include +# include namespace boost { namespace python { namespace converter { @@ -59,7 +59,7 @@ template type_info pointer_type_id(T(*)() = 0) { return detail::pointer_typeid_select< - is_reference::value + boost::python::detail::is_lvalue_reference::value >::execute((T(*)())0); } diff --git a/include/boost/python/converter/pytype_function.hpp b/include/boost/python/converter/pytype_function.hpp index 95d0f66d..8e0a4e79 100755 --- a/include/boost/python/converter/pytype_function.hpp +++ b/include/boost/python/converter/pytype_function.hpp @@ -8,6 +8,7 @@ # include # include # include +# include namespace boost { namespace python { @@ -53,7 +54,7 @@ inline python::type_info unwind_type_id_(boost::type* = 0, mpl::true_* =0) template inline python::type_info unwind_type_id(boost::type* p= 0) { - return unwind_type_id_(p, (mpl::bool_::value >*)0 ); + return unwind_type_id_(p, (mpl::bool_::value >*)0 ); } } @@ -64,7 +65,7 @@ struct expected_pytype_for_arg static PyTypeObject const *get_pytype() { const converter::registration *r=converter::registry::query( - detail::unwind_type_id_((boost::type*)0, (mpl::bool_::value >*)0 ) + detail::unwind_type_id_((boost::type*)0, (mpl::bool_::value >*)0 ) ); return r ? r->expected_from_python_type(): 0; } @@ -77,7 +78,7 @@ struct registered_pytype static PyTypeObject const *get_pytype() { const converter::registration *r=converter::registry::query( - detail::unwind_type_id_((boost::type*) 0, (mpl::bool_::value >*)0 ) + detail::unwind_type_id_((boost::type*) 0, (mpl::bool_::value >*)0 ) ); return r ? r->m_class_object: 0; } @@ -111,7 +112,7 @@ struct to_python_target_type static PyTypeObject const *get_pytype() { const converter::registration *r=converter::registry::query( - detail::unwind_type_id_((boost::type*)0, (mpl::bool_::value >*)0 ) + detail::unwind_type_id_((boost::type*)0, (mpl::bool_::value >*)0 ) ); return r ? r->to_python_target_type(): 0; } diff --git a/include/boost/python/converter/registered.hpp b/include/boost/python/converter/registered.hpp index a622250d..73f4d984 100644 --- a/include/boost/python/converter/registered.hpp +++ b/include/boost/python/converter/registered.hpp @@ -10,9 +10,7 @@ #include #include #include -#include -#include -#include +#include #include #include #include @@ -44,8 +42,8 @@ namespace detail template struct registered : detail::registered_base< - typename add_reference< - typename add_cv::type + typename boost::python::detail::add_lvalue_reference< + typename boost::python::detail::add_cv::type >::type > { diff --git a/include/boost/python/converter/registered_pointee.hpp b/include/boost/python/converter/registered_pointee.hpp index 974cb6d8..28b2988c 100644 --- a/include/boost/python/converter/registered_pointee.hpp +++ b/include/boost/python/converter/registered_pointee.hpp @@ -7,8 +7,7 @@ # include # include # include -# include -# include +# include namespace boost { namespace python { namespace converter { @@ -17,9 +16,9 @@ struct registration; template struct registered_pointee : registered< - typename remove_pointer< - typename remove_cv< - typename remove_reference::type + typename boost::python::detail::remove_pointer< + typename boost::python::detail::remove_cv< + typename boost::python::detail::remove_reference::type >::type >::type > diff --git a/include/boost/python/converter/return_from_python.hpp b/include/boost/python/converter/return_from_python.hpp index 5db97485..a995a290 100755 --- a/include/boost/python/converter/return_from_python.hpp +++ b/include/boost/python/converter/return_from_python.hpp @@ -14,7 +14,7 @@ # include # include # include -# include +# include # include # include diff --git a/include/boost/python/converter/rvalue_from_python_data.hpp b/include/boost/python/converter/rvalue_from_python_data.hpp index 471a5255..acb38f84 100644 --- a/include/boost/python/converter/rvalue_from_python_data.hpp +++ b/include/boost/python/converter/rvalue_from_python_data.hpp @@ -8,9 +8,8 @@ # include # include # include +# include # include -# include -# include # include // Data management for potential rvalue conversions from Python to C++ @@ -78,7 +77,7 @@ struct rvalue_from_python_storage // Storage for the result, in case an rvalue must be constructed typename python::detail::referent_storage< - typename add_reference::type + typename boost::python::detail::add_lvalue_reference::type >::type storage; }; @@ -110,7 +109,8 @@ struct rvalue_from_python_data : rvalue_from_python_storage // Destroys any object constructed in the storage. ~rvalue_from_python_data(); private: - typedef typename add_reference::type>::type ref_type; + typedef typename boost::python::detail::add_lvalue_reference< + typename boost::python::detail::add_cv::type>::type ref_type; }; // diff --git a/include/boost/python/data_members.hpp b/include/boost/python/data_members.hpp index 5d3309cf..989f7d7f 100644 --- a/include/boost/python/data_members.hpp +++ b/include/boost/python/data_members.hpp @@ -19,14 +19,7 @@ # include # include # include - -# include -# include -# include - -# if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) -# include -# endif +# include # include # include @@ -147,20 +140,20 @@ namespace detail // boost::python::make_getter are used to dispatch behavior. The // third argument is a workaround for a CWPro8 partial ordering bug // with pointers to data members. It should be convertible to - // mpl::true_ iff the first argument is a pointer-to-member, and - // mpl::false_ otherwise. The fourth argument is for compilers + // detail::true_ iff the first argument is a pointer-to-member, and + // detail::false_ otherwise. The fourth argument is for compilers // which don't support partial ordering at all and should always be // passed 0L. - // + #if BOOST_WORKAROUND(__EDG_VERSION__, <= 238) template - inline object make_getter(D& d, P& p, mpl::false_, ...); + inline object make_getter(D& d, P& p, detail::false_, ...); #endif // Handle non-member pointers with policies template - inline object make_getter(D* d, Policies const& policies, mpl::false_, int) + inline object make_getter(D* d, Policies const& policies, detail::false_, int) { return python::make_function( detail::datum(d), policies, mpl::vector1() @@ -169,18 +162,18 @@ namespace detail // Handle non-member pointers without policies template - inline object make_getter(D* d, not_specified, mpl::false_, long) + inline object make_getter(D* d, not_specified, detail::false_, long) { typedef typename default_datum_getter_policy::type policies; - return detail::make_getter(d, policies(), mpl::false_(), 0); + return detail::make_getter(d, policies(), detail::false_(), 0); } // Handle pointers-to-members with policies template - inline object make_getter(D C::*pm, Policies const& policies, mpl::true_, int) + inline object make_getter(D C::*pm, Policies const& policies, detail::true_, int) { #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) - typedef typename remove_cv::type Class; + typedef typename detail::remove_cv::type Class; #else typedef C Class; #endif @@ -193,18 +186,18 @@ namespace detail // Handle pointers-to-members without policies template - inline object make_getter(D C::*pm, not_specified, mpl::true_, long) + inline object make_getter(D C::*pm, not_specified, detail::true_, long) { typedef typename default_member_getter_policy::type policies; - return detail::make_getter(pm, policies(), mpl::true_(), 0); + return detail::make_getter(pm, policies(), detail::true_(), 0); } // Handle references template - inline object make_getter(D& d, P& p, mpl::false_, ...) + inline object make_getter(D& d, P& p, detail::false_, ...) { // Just dispatch to the handler for pointer types. - return detail::make_getter(&d, p, mpl::false_(), 0L); + return detail::make_getter(&d, p, detail::false_(), 0L); } // @@ -217,7 +210,7 @@ namespace detail // Handle non-member pointers template - inline object make_setter(D* p, Policies const& policies, mpl::false_, int) + inline object make_setter(D* p, Policies const& policies, detail::false_, int) { return python::make_function( detail::datum(p), policies, mpl::vector2() @@ -226,7 +219,7 @@ namespace detail // Handle pointers-to-members template - inline object make_setter(D C::*pm, Policies const& policies, mpl::true_, int) + inline object make_setter(D C::*pm, Policies const& policies, detail::true_, int) { return python::make_function( detail::member(pm) @@ -237,9 +230,9 @@ namespace detail // Handle references template - inline object make_setter(D& x, Policies const& policies, mpl::false_, ...) + inline object make_setter(D& x, Policies const& policies, detail::false_, ...) { - return detail::make_setter(&x, policies, mpl::false_(), 0L); + return detail::make_setter(&x, policies, detail::false_(), 0L); } } @@ -253,13 +246,13 @@ namespace detail template inline object make_getter(D& d, Policies const& policies) { - return detail::make_getter(d, policies, is_member_pointer(), 0L); + return detail::make_getter(d, policies, detail::is_member_pointer(), 0L); } template inline object make_getter(D const& d, Policies const& policies) { - return detail::make_getter(d, policies, is_member_pointer(), 0L); + return detail::make_getter(d, policies, detail::is_member_pointer(), 0L); } template @@ -267,7 +260,7 @@ inline object make_getter(D& x) { detail::not_specified policy = detail::not_specified(); // suppress a SunPro warning - return detail::make_getter(x, policy, is_member_pointer(), 0L); + return detail::make_getter(x, policy, detail::is_member_pointer(), 0L); } # if !BOOST_WORKAROUND(__EDG_VERSION__, <= 238) @@ -276,7 +269,7 @@ inline object make_getter(D const& d) { detail::not_specified policy = detail::not_specified(); // Suppress a SunPro warning - return detail::make_getter(d, policy, is_member_pointer(), 0L); + return detail::make_getter(d, policy, detail::is_member_pointer(), 0L); } # endif @@ -290,26 +283,26 @@ inline object make_getter(D const& d) template inline object make_setter(D& x, Policies const& policies) { - return detail::make_setter(x, policies, is_member_pointer(), 0); + return detail::make_setter(x, policies, detail::is_member_pointer(), 0); } template inline object make_setter(D const& x, Policies const& policies) { - return detail::make_setter(x, policies, is_member_pointer(), 0); + return detail::make_setter(x, policies, detail::is_member_pointer(), 0); } template inline object make_setter(D& x) { - return detail::make_setter(x, default_call_policies(), is_member_pointer(), 0); + return detail::make_setter(x, default_call_policies(), detail::is_member_pointer(), 0); } # if !BOOST_WORKAROUND(__EDG_VERSION__, <= 238) template inline object make_setter(D const& x) { - return detail::make_setter(x, default_call_policies(), is_member_pointer(), 0); + return detail::make_setter(x, default_call_policies(), detail::is_member_pointer(), 0); } # endif diff --git a/include/boost/python/default_call_policies.hpp b/include/boost/python/default_call_policies.hpp index fcc242a9..c8822573 100644 --- a/include/boost/python/default_call_policies.hpp +++ b/include/boost/python/default_call_policies.hpp @@ -8,10 +8,8 @@ # include # include # include +# include # include -# include -# include -# include # include # include @@ -64,7 +62,7 @@ struct default_result_converter struct apply { typedef typename mpl::if_< - mpl::or_, is_reference > + mpl::or_, detail::is_reference > , detail::specify_a_return_value_policy_to_wrap_functions_returning , boost::python::to_python_value< typename detail::value_arg::type diff --git a/include/boost/python/detail/borrowed_ptr.hpp b/include/boost/python/detail/borrowed_ptr.hpp index d91d05c9..7d78739e 100644 --- a/include/boost/python/detail/borrowed_ptr.hpp +++ b/include/boost/python/detail/borrowed_ptr.hpp @@ -8,8 +8,7 @@ # include # include # include -# include -# include +# include # include namespace boost { namespace python { namespace detail { diff --git a/include/boost/python/detail/caller.hpp b/include/boost/python/detail/caller.hpp index e479bf42..c572d35a 100644 --- a/include/boost/python/detail/caller.hpp +++ b/include/boost/python/detail/caller.hpp @@ -16,6 +16,7 @@ # include # include # include +# include # include # include @@ -31,9 +32,6 @@ # include -# include -# include - # include # include # include @@ -236,7 +234,7 @@ struct caller_arity typedef typename select_result_converter::type result_converter; static const signature_element ret = { - (boost::is_void::value ? "void" : type_id().name()) + (is_void::value ? "void" : type_id().name()) , &detail::converter_target_type::get_pytype , boost::detail::indirect_traits::is_reference_to_non_const::value }; diff --git a/include/boost/python/detail/convertible.hpp b/include/boost/python/detail/convertible.hpp index 2ce552f5..1ff350ec 100755 --- a/include/boost/python/detail/convertible.hpp +++ b/include/boost/python/detail/convertible.hpp @@ -7,11 +7,11 @@ # if defined(__EDG_VERSION__) && __EDG_VERSION__ <= 241 # include -# include +# include # endif // Supplies a runtime is_convertible check which can be used with tag -// dispatching to work around the Metrowerks Pro7 limitation with boost::is_convertible +// dispatching to work around the Metrowerks Pro7 limitation with boost/std::is_convertible namespace boost { namespace python { namespace detail { typedef char* yes_convertible; diff --git a/include/boost/python/detail/cv_category.hpp b/include/boost/python/detail/cv_category.hpp index d32dd0fd..eb5a8eb9 100644 --- a/include/boost/python/detail/cv_category.hpp +++ b/include/boost/python/detail/cv_category.hpp @@ -4,7 +4,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #ifndef CV_CATEGORY_DWA200222_HPP # define CV_CATEGORY_DWA200222_HPP -# include +# include namespace boost { namespace python { namespace detail { @@ -26,8 +26,8 @@ struct cv_category // BOOST_STATIC_CONSTANT(bool, c = is_const::value); // BOOST_STATIC_CONSTANT(bool, v = is_volatile::value); typedef cv_tag< - ::boost::is_const::value - , ::boost::is_volatile::value + is_const::value + , is_volatile::value > type; }; diff --git a/include/boost/python/detail/decorated_type_id.hpp b/include/boost/python/detail/decorated_type_id.hpp index 535508b4..2596f310 100644 --- a/include/boost/python/detail/decorated_type_id.hpp +++ b/include/boost/python/detail/decorated_type_id.hpp @@ -7,7 +7,7 @@ # include # include -# include +# include namespace boost { namespace python { namespace detail { diff --git a/include/boost/python/detail/def_helper.hpp b/include/boost/python/detail/def_helper.hpp index 92db09ed..24f9c5cd 100644 --- a/include/boost/python/detail/def_helper.hpp +++ b/include/boost/python/detail/def_helper.hpp @@ -6,12 +6,11 @@ # define DEF_HELPER_DWA200287_HPP # include -# include # include +# include # include # include # include -# include # include # include # include @@ -73,7 +72,8 @@ namespace detail struct tuple_extract_base_select { typedef typename Tuple::head_type head_type; - typedef typename mpl::apply1::type>::type match_t; + typedef typename mpl::apply1::type>::type match_t; BOOST_STATIC_CONSTANT(bool, match = match_t::value); typedef typename tuple_extract_impl::template apply type; }; diff --git a/include/boost/python/detail/defaults_def.hpp b/include/boost/python/detail/defaults_def.hpp index 68799f83..a721b767 100644 --- a/include/boost/python/detail/defaults_def.hpp +++ b/include/boost/python/detail/defaults_def.hpp @@ -12,7 +12,7 @@ #define DEFAULTS_DEF_JDG20020811_HPP #include -#include +#include #include #include #include @@ -238,7 +238,7 @@ namespace detail typedef typename OverloadsT::non_void_return_type non_void_return_type; typedef typename mpl::if_c< - boost::is_same::value + is_same::value , void_return_type , non_void_return_type >::type stubs_type; diff --git a/include/boost/python/detail/destroy.hpp b/include/boost/python/detail/destroy.hpp index 3ea64553..d35b2b53 100644 --- a/include/boost/python/detail/destroy.hpp +++ b/include/boost/python/detail/destroy.hpp @@ -5,7 +5,7 @@ #ifndef DESTROY_DWA2002221_HPP # define DESTROY_DWA2002221_HPP -# include +# include # include namespace boost { namespace python { namespace detail { @@ -30,7 +30,7 @@ struct value_destroyer for (T const volatile* p = first; p != first + sizeof(A)/sizeof(T); ++p) { value_destroyer< - boost::is_array::value + is_array::value >::execute(p); } } @@ -48,7 +48,7 @@ inline void destroy_referent_impl(void* p, T& (*)()) // note: cv-qualification needed for MSVC6 // must come *before* T for metrowerks value_destroyer< - (boost::is_array::value) + (is_array::value) >::execute((const volatile T*)p); } diff --git a/include/boost/python/detail/invoke.hpp b/include/boost/python/detail/invoke.hpp index 939fa118..4c5296ff 100644 --- a/include/boost/python/detail/invoke.hpp +++ b/include/boost/python/detail/invoke.hpp @@ -11,8 +11,6 @@ # include # include -# include - # include # include # include diff --git a/include/boost/python/detail/pointee.hpp b/include/boost/python/detail/pointee.hpp index e18c1f49..e786b376 100644 --- a/include/boost/python/detail/pointee.hpp +++ b/include/boost/python/detail/pointee.hpp @@ -5,7 +5,7 @@ #ifndef POINTEE_DWA2002323_HPP # define POINTEE_DWA2002323_HPP -# include +# include namespace boost { namespace python { namespace detail { diff --git a/include/boost/python/detail/result.hpp b/include/boost/python/detail/result.hpp index 8ccc3c50..2390693a 100644 --- a/include/boost/python/detail/result.hpp +++ b/include/boost/python/detail/result.hpp @@ -11,8 +11,8 @@ # include # include +# include -# include # include # include diff --git a/include/boost/python/detail/string_literal.hpp b/include/boost/python/detail/string_literal.hpp index a56e72ec..0961ec7c 100644 --- a/include/boost/python/detail/string_literal.hpp +++ b/include/boost/python/detail/string_literal.hpp @@ -7,8 +7,7 @@ # include # include -# include -# include +# include # include # include diff --git a/include/boost/python/detail/translate_exception.hpp b/include/boost/python/detail/translate_exception.hpp index df7ec2dd..877db2b2 100644 --- a/include/boost/python/detail/translate_exception.hpp +++ b/include/boost/python/detail/translate_exception.hpp @@ -6,11 +6,9 @@ # define TRANSLATE_EXCEPTION_TDS20091020_HPP # include +# include # include -# include -# include -# include # include @@ -33,7 +31,7 @@ struct translate_exception typename add_const::type >::type exception_non_ref; # else - typedef typename add_reference< + typedef typename add_lvalue_reference< typename add_const::type >::type exception_cref; # endif diff --git a/include/boost/python/detail/type_traits.hpp b/include/boost/python/detail/type_traits.hpp new file mode 100644 index 00000000..df940c7e --- /dev/null +++ b/include/boost/python/detail/type_traits.hpp @@ -0,0 +1,110 @@ +// Copyright Shreyans Doshi 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) + +#ifndef BOOST_PYTHON_DETAIL_TYPE_TRAITS_HPP +# define BOOST_PYTHON_DETAIL_TYPE_TRAITS_HPP + + +#if __cplusplus < 201103L +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +#else +# include +#endif + +# include +# include +# include + + +namespace boost { namespace python { namespace detail { + +#if __cplusplus < 201103L + using boost::alignment_of; + using boost::add_const; + using boost::add_cv; + using boost::add_lvalue_reference; + using boost::add_pointer; + + using boost::is_array; + using boost::is_class; + using boost::is_const; + using boost::is_convertible; + using boost::is_enum; + using boost::is_function; + using boost::is_integral; + using boost::is_lvalue_reference; + using boost::is_member_function_pointer; + using boost::is_member_pointer; + using boost::is_pointer; + using boost::is_polymorphic; + using boost::is_reference; + using boost::is_same; + using boost::is_scalar; + using boost::is_union; + using boost::is_void; + using boost::is_volatile; + + using boost::remove_reference; + using boost::remove_pointer; + using boost::remove_cv; + using boost::remove_const; + + using boost::mpl::true_; + using boost::mpl::false_; +#else + using std::alignment_of; + using std::add_const; + using std::add_cv; + using std::add_lvalue_reference; + using std::add_pointer; + + using std::is_array; + using std::is_class; + using std::is_const; + using std::is_convertible; + using std::is_enum; + using std::is_function; + using std::is_integral; + using std::is_lvalue_reference; + using std::is_member_function_pointer; + using std::is_member_pointer; + using std::is_pointer; + using std::is_polymorphic; + using std::is_reference; + using std::is_same; + using std::is_scalar; + using std::is_union; + using std::is_void; + using std::is_volatile; + + using std::remove_reference; + using std::remove_pointer; + using std::remove_cv; + using std::remove_const; + + using true_ = std::integral_constant; + using false_ = std::integral_constant; +#endif + using boost::is_base_and_derived; + using boost::type_with_alignment; + using boost::has_trivial_copy; +}}} // namespace boost::python::detail + + +#endif //BOOST_DETAIL_TYPE_TRAITS_HPP diff --git a/include/boost/python/detail/unwind_type.hpp b/include/boost/python/detail/unwind_type.hpp index 9a997c9d..f6cdab64 100755 --- a/include/boost/python/detail/unwind_type.hpp +++ b/include/boost/python/detail/unwind_type.hpp @@ -7,7 +7,7 @@ # include # include -# include +# include namespace boost { namespace python { namespace detail { @@ -155,10 +155,10 @@ unwind_type(boost::type*p =0, Generator* =0) #endif { BOOST_STATIC_CONSTANT(int, indirection - = (boost::is_pointer::value ? pointer_ : 0) + = (is_pointer::value ? pointer_ : 0) + (indirect_traits::is_reference_to_pointer::value ? reference_to_pointer_ - : boost::is_reference::value + : is_lvalue_reference::value ? reference_ : 0)); diff --git a/include/boost/python/detail/value_arg.hpp b/include/boost/python/detail/value_arg.hpp index 747588d6..2c938dac 100755 --- a/include/boost/python/detail/value_arg.hpp +++ b/include/boost/python/detail/value_arg.hpp @@ -6,8 +6,7 @@ # include # include -# include -# include +# include namespace boost { namespace python { namespace detail { @@ -16,7 +15,7 @@ struct value_arg : mpl::if_< copy_ctor_mutates_rhs , T - , typename add_reference< + , typename add_lvalue_reference< typename add_const::type >::type > diff --git a/include/boost/python/detail/value_is_xxx.hpp b/include/boost/python/detail/value_is_xxx.hpp index fbb9defd..e270f89c 100644 --- a/include/boost/python/detail/value_is_xxx.hpp +++ b/include/boost/python/detail/value_is_xxx.hpp @@ -9,11 +9,11 @@ # include # include - -# include -# include +# include # include +namespace boost { namespace python { namespace detail { + # define BOOST_PYTHON_VALUE_IS_XXX_DEF(name, qualified_name, nargs) \ template \ struct value_is_##name \ @@ -24,9 +24,10 @@ struct value_is_##name \ typename remove_reference::type \ >::type \ >::value); \ - typedef mpl::bool_ type; \ + typedef mpl::bool_ type; \ \ }; +}}} // namespace boost::python::detail #endif // VALUE_IS_XXX_DWA2003224_HPP diff --git a/include/boost/python/detail/void_ptr.hpp b/include/boost/python/detail/void_ptr.hpp index 06f68010..5543b23a 100644 --- a/include/boost/python/detail/void_ptr.hpp +++ b/include/boost/python/detail/void_ptr.hpp @@ -5,7 +5,7 @@ #ifndef VOID_PTR_DWA200239_HPP # define VOID_PTR_DWA200239_HPP -# include +# include namespace boost { namespace python { namespace detail { diff --git a/include/boost/python/detail/wrapper_base.hpp b/include/boost/python/detail/wrapper_base.hpp index 2a79e0c5..60ac9943 100644 --- a/include/boost/python/detail/wrapper_base.hpp +++ b/include/boost/python/detail/wrapper_base.hpp @@ -5,8 +5,7 @@ # define WRAPPER_BASE_DWA2004722_HPP # include -# include -# include +# include namespace boost { namespace python { @@ -21,14 +20,14 @@ namespace detail inline PyObject* get_owner(wrapper_base const volatile& w); inline PyObject* - owner_impl(void const volatile* /*x*/, mpl::false_) + owner_impl(void const volatile* /*x*/, detail::false_) { return 0; } template inline PyObject* - owner_impl(T const volatile* x, mpl::true_); + owner_impl(T const volatile* x, detail::true_); template inline PyObject* @@ -59,7 +58,7 @@ namespace detail { template inline PyObject* - owner_impl(T const volatile* x, mpl::true_) + owner_impl(T const volatile* x, detail::true_) { if (wrapper_base const volatile* w = dynamic_cast(x)) { diff --git a/include/boost/python/init.hpp b/include/boost/python/init.hpp index 792de58e..0ee763cc 100644 --- a/include/boost/python/init.hpp +++ b/include/boost/python/init.hpp @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include diff --git a/include/boost/python/iterator.hpp b/include/boost/python/iterator.hpp index a64a9207..7c06ca23 100644 --- a/include/boost/python/iterator.hpp +++ b/include/boost/python/iterator.hpp @@ -8,12 +8,10 @@ # include # include +# include # include # include -# include -# include - # if defined(BOOST_MSVC) && (BOOST_MSVC == 1400) /* > warning C4180: qualifier applied to function type has no meaning; ignored Peter Dimov wrote: @@ -80,7 +78,7 @@ namespace detail template struct iterators : detail::iterators_impl< - boost::is_const::value + detail::is_const::value >::template apply { }; diff --git a/include/boost/python/lvalue_from_pytype.hpp b/include/boost/python/lvalue_from_pytype.hpp index e15dfbbb..59d31b89 100644 --- a/include/boost/python/lvalue_from_pytype.hpp +++ b/include/boost/python/lvalue_from_pytype.hpp @@ -13,6 +13,7 @@ # include # include # include +# include namespace boost { namespace python { @@ -35,7 +36,7 @@ namespace detail { static inline void* execute(PyObject* op) { - typedef typename boost::add_reference::type param; + typedef typename add_lvalue_reference::type param; return &Extractor::execute( boost::python::detail::void_ptr_to_reference( op, (param(*)())0 ) diff --git a/include/boost/python/make_constructor.hpp b/include/boost/python/make_constructor.hpp index 92a7951d..053d050c 100644 --- a/include/boost/python/make_constructor.hpp +++ b/include/boost/python/make_constructor.hpp @@ -43,19 +43,19 @@ namespace detail private: template - void dispatch(U* x, mpl::true_) const + void dispatch(U* x, detail::true_) const { #if __cplusplus < 201103L std::auto_ptr owner(x); - dispatch(owner, mpl::false_()); + dispatch(owner, detail::false_()); #else std::unique_ptr owner(x); - dispatch(std::move(owner), mpl::false_()); + dispatch(std::move(owner), detail::false_()); #endif } template - void dispatch(Ptr x, mpl::false_) const + void dispatch(Ptr x, detail::false_) const { typedef typename pointee::type value_type; typedef objects::pointer_holder holder; diff --git a/include/boost/python/manage_new_object.hpp b/include/boost/python/manage_new_object.hpp index 9585b13a..9ff341c1 100644 --- a/include/boost/python/manage_new_object.hpp +++ b/include/boost/python/manage_new_object.hpp @@ -7,9 +7,9 @@ # include # include +# include # include # include -# include namespace boost { namespace python { @@ -29,7 +29,7 @@ struct manage_new_object struct apply { typedef typename mpl::if_c< - boost::is_pointer::value + detail::is_pointer::value , to_python_indirect , detail::manage_new_object_requires_a_pointer_return_type >::type type; diff --git a/include/boost/python/numpy/dtype.hpp b/include/boost/python/numpy/dtype.hpp index f3aca7db..4673745e 100644 --- a/include/boost/python/numpy/dtype.hpp +++ b/include/boost/python/numpy/dtype.hpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include namespace boost { namespace python { namespace numpy { diff --git a/include/boost/python/numpy/ndarray.hpp b/include/boost/python/numpy/ndarray.hpp index e5b6a9e9..98a4cb15 100644 --- a/include/boost/python/numpy/ndarray.hpp +++ b/include/boost/python/numpy/ndarray.hpp @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include #include @@ -176,7 +176,7 @@ ndarray from_data_impl(void * data, Container strides, object const & owner, bool writeable, - typename boost::enable_if< boost::is_integral >::type * enabled = NULL) + typename boost::enable_if< boost::python::detail::is_integral >::type * enabled = NULL) { std::vector shape_(shape.begin(),shape.end()); std::vector strides_(strides.begin(), strides.end()); diff --git a/include/boost/python/object/class_metadata.hpp b/include/boost/python/object/class_metadata.hpp index 8e750b85..93303ecb 100644 --- a/include/boost/python/object/class_metadata.hpp +++ b/include/boost/python/object/class_metadata.hpp @@ -17,14 +17,11 @@ #include #include +#include #include #include -#include -#include -#include - #include #include #include @@ -35,9 +32,6 @@ #include #include -#include - -#include #include #include @@ -56,7 +50,7 @@ struct register_base_of template inline void operator()(Base*) const { - BOOST_MPL_ASSERT_NOT((is_same)); + BOOST_MPL_ASSERT_NOT((boost::python::detail::is_same)); // Register the Base class register_dynamic_id(); @@ -65,14 +59,14 @@ struct register_base_of register_conversion(false); // Register the down-cast, if appropriate. - this->register_downcast((Base*)0, is_polymorphic()); + this->register_downcast((Base*)0, boost::python::detail::is_polymorphic()); } private: - static inline void register_downcast(void*, mpl::false_) {} + static inline void register_downcast(void*, boost::python::detail::false_) {} template - static inline void register_downcast(Base*, mpl::true_) + static inline void register_downcast(Base*, boost::python::detail::true_) { register_conversion(true); } @@ -98,7 +92,7 @@ inline void register_shared_ptr_from_python_and_casts(T*, Bases) // interface to mpl::for_each to avoid an MSVC 6 bug. // register_dynamic_id(); - mpl::for_each(register_base_of(), (Bases*)0, (add_pointer*)0); + mpl::for_each(register_base_of(), (Bases*)0, (boost::python::detail::add_pointer*)0); } // @@ -109,7 +103,7 @@ struct select_held_type : mpl::if_< mpl::or_< python::detail::specifies_bases - , is_same + , boost::python::detail::is_same > , Prev , T @@ -156,9 +150,9 @@ struct class_metadata >::type bases; typedef mpl::or_< - is_same - , is_same - , is_same + boost::python::detail::is_same + , boost::python::detail::is_same + , boost::python::detail::is_same > is_noncopyable; // @@ -167,11 +161,11 @@ struct class_metadata // Compute the actual type that will be held in the Holder. typedef typename mpl::if_< - is_same, T, held_type_arg + boost::python::detail::is_same, T, held_type_arg >::type held_type; // Determine if the object will be held by value - typedef mpl::bool_::value> use_value_holder; + typedef mpl::bool_::value> use_value_holder; // Compute the "wrapped type", that is, if held_type is a smart // pointer, we're talking about the pointee. @@ -185,7 +179,7 @@ struct class_metadata typedef mpl::bool_< mpl::or_< has_back_reference - , is_same + , boost::python::detail::is_same , is_base_and_derived >::value > use_back_reference; @@ -214,7 +208,7 @@ struct class_metadata template inline static void register_aux(python::wrapper*) { - typedef typename mpl::not_ >::type use_callback; + typedef typename mpl::not_ >::type use_callback; class_metadata::register_aux2((T2*)0, use_callback()); } @@ -243,7 +237,7 @@ struct class_metadata inline static void maybe_register_pointer_to_python(...) {} #ifndef BOOST_PYTHON_NO_PY_SIGNATURES - inline static void maybe_register_pointer_to_python(void*,void*,mpl::true_*) + inline static void maybe_register_pointer_to_python(void*,void*,mpl::true_*) { objects::copy_class_object(python::type_id(), python::type_id >()); objects::copy_class_object(python::type_id(), python::type_id >()); diff --git a/include/boost/python/object/forward.hpp b/include/boost/python/object/forward.hpp index 30613d8e..c6515bb5 100644 --- a/include/boost/python/object/forward.hpp +++ b/include/boost/python/object/forward.hpp @@ -6,11 +6,9 @@ # define FORWARD_DWA20011215_HPP # include -# include -# include -# include # include # include +# include # include # include @@ -22,7 +20,8 @@ namespace boost { namespace python { namespace objects { template struct reference_to_value { - typedef typename add_reference::type>::type reference; + typedef typename boost::python::detail::add_lvalue_reference::type>::type reference; reference_to_value(reference x) : m_value(x) {} reference get() const { return m_value; } @@ -36,7 +35,7 @@ struct reference_to_value template struct forward : mpl::if_< - mpl::or_, is_scalar > + mpl::or_, boost::python::detail::is_scalar > , T , reference_to_value > @@ -65,7 +64,7 @@ struct unforward_cref template struct unforward_cref > - : add_reference::type> + : boost::python::detail::add_lvalue_reference::type> { }; diff --git a/include/boost/python/object/inheritance.hpp b/include/boost/python/object/inheritance.hpp index b49a0442..eb7fca28 100644 --- a/include/boost/python/object/inheritance.hpp +++ b/include/boost/python/object/inheritance.hpp @@ -8,9 +8,8 @@ # include # include # include -# include -# include # include +# include namespace boost { namespace python { namespace objects { @@ -58,7 +57,7 @@ struct non_polymorphic_id_generator template struct dynamic_id_generator : mpl::if_< - boost::is_polymorphic + boost::python::detail::is_polymorphic , boost::python::objects::polymorphic_id_generator , boost::python::objects::non_polymorphic_id_generator > @@ -104,7 +103,7 @@ struct implicit_cast_generator template struct cast_generator : mpl::if_< - is_base_and_derived + detail::is_base_and_derived , implicit_cast_generator , dynamic_cast_generator > diff --git a/include/boost/python/object/instance.hpp b/include/boost/python/object/instance.hpp index 9c28d682..27b91a1e 100644 --- a/include/boost/python/object/instance.hpp +++ b/include/boost/python/object/instance.hpp @@ -6,7 +6,7 @@ # define INSTANCE_DWA200295_HPP # include -# include + # include namespace boost { namespace python @@ -25,8 +25,8 @@ struct instance PyObject* weakrefs; instance_holder* objects; - typedef typename type_with_alignment< - ::boost::alignment_of::value + typedef typename boost::python::detail::type_with_alignment< + boost::python::detail::alignment_of::value >::type align_t; union diff --git a/include/boost/python/object/iterator.hpp b/include/boost/python/object/iterator.hpp index db522471..e2f65721 100644 --- a/include/boost/python/object/iterator.hpp +++ b/include/boost/python/object/iterator.hpp @@ -6,6 +6,7 @@ # define ITERATOR_DWA2002510_HPP # include +# include # include # include @@ -24,10 +25,6 @@ # include -# include -# include -# include - # include namespace boost { namespace python { namespace objects { @@ -202,8 +199,8 @@ inline object make_iterator_function( ) { typedef typename Accessor1::result_type iterator; - typedef typename add_const::type iterator_const; - typedef typename add_reference::type iterator_cref; + typedef typename boost::python::detail::add_const::type iterator_const; + typedef typename boost::python::detail::add_lvalue_reference::type iterator_cref; return detail::make_iterator_function( get_start diff --git a/include/boost/python/object/make_instance.hpp b/include/boost/python/object/make_instance.hpp index 5f2630ad..31ec08f7 100644 --- a/include/boost/python/object/make_instance.hpp +++ b/include/boost/python/object/make_instance.hpp @@ -9,10 +9,10 @@ # include # include # include +# include # include # include # include -# include namespace boost { namespace python { namespace objects { @@ -24,7 +24,8 @@ struct make_instance_impl template static inline PyObject* execute(Arg& x) { - BOOST_MPL_ASSERT((mpl::or_, is_union >)); + BOOST_MPL_ASSERT((mpl::or_, + boost::python::detail::is_union >)); PyTypeObject* type = Derived::get_class_object(x); diff --git a/include/boost/python/object/make_ptr_instance.hpp b/include/boost/python/object/make_ptr_instance.hpp index 3a281902..21089c6b 100644 --- a/include/boost/python/object/make_ptr_instance.hpp +++ b/include/boost/python/object/make_ptr_instance.hpp @@ -7,7 +7,7 @@ # include # include -# include +# include # include # include # include @@ -47,7 +47,7 @@ struct make_ptr_instance return 0; // means "return None". PyTypeObject* derived = get_derived_class_object( - BOOST_DEDUCED_TYPENAME is_polymorphic::type(), p); + BOOST_DEDUCED_TYPENAME boost::python::detail::is_polymorphic::type(), p); if (derived) return derived; @@ -55,7 +55,7 @@ struct make_ptr_instance } template - static inline PyTypeObject* get_derived_class_object(mpl::true_, U const volatile* x) + static inline PyTypeObject* get_derived_class_object(boost::python::detail::true_, U const volatile* x) { converter::registration const* r = converter::registry::query( type_info(typeid(*get_pointer(x))) @@ -64,7 +64,7 @@ struct make_ptr_instance } template - static inline PyTypeObject* get_derived_class_object(mpl::false_, U*) + static inline PyTypeObject* get_derived_class_object(boost::python::detail::false_, U*) { return 0; } diff --git a/include/boost/python/object/pointer_holder.hpp b/include/boost/python/object/pointer_holder.hpp index b28cbd83..c5caefe6 100644 --- a/include/boost/python/object/pointer_holder.hpp +++ b/include/boost/python/object/pointer_holder.hpp @@ -21,6 +21,7 @@ # include # include # include +# include # include @@ -35,8 +36,6 @@ # include -# include - namespace boost { namespace python { template class wrapper; @@ -128,7 +127,7 @@ inline pointer_holder_back_reference::pointer_holder_back_referen template void* pointer_holder::holds(type_info dst_t, bool null_ptr_only) { - typedef typename boost::remove_const< Value >::type non_const_value; + typedef typename boost::python::detail::remove_const< Value >::type non_const_value; if (dst_t == python::type_id() && !(null_ptr_only && get_pointer(this->m_p)) diff --git a/include/boost/python/object_core.hpp b/include/boost/python/object_core.hpp index 209310ff..16480d0d 100644 --- a/include/boost/python/object_core.hpp +++ b/include/boost/python/object_core.hpp @@ -31,10 +31,7 @@ # include # include # include - -# include -# include -# include +# include namespace boost { namespace python { @@ -165,7 +162,7 @@ namespace api // It's too late to specify anything other than docstrings if // the callable object is already wrapped. BOOST_STATIC_ASSERT( - (is_same::value + (detail::is_same::value || detail::is_string_literal::value)); objects::add_to_namespace(cl, name, this->derived_visitor(), helper.doc()); @@ -208,8 +205,8 @@ namespace api template struct is_derived - : is_convertible< - typename remove_reference::type* + : boost::python::detail::is_convertible< + typename detail::remove_reference::type* , U const* > {}; @@ -280,14 +277,14 @@ namespace api struct object_initializer_impl { static PyObject* - get(object const& x, mpl::true_) + get(object const& x, detail::true_) { return python::incref(x.ptr()); } template static PyObject* - get(T const& x, mpl::false_) + get(T const& x, detail::false_) { return python::incref(converter::arg_to_python(x).get()); } @@ -298,7 +295,7 @@ namespace api { template static PyObject* - get(proxy const& x, mpl::false_) + get(proxy const& x, detail::false_) { return python::incref(x.operator object().ptr()); } diff --git a/include/boost/python/opaque_pointer_converter.hpp b/include/boost/python/opaque_pointer_converter.hpp index c46a65a8..12098520 100644 --- a/include/boost/python/opaque_pointer_converter.hpp +++ b/include/boost/python/opaque_pointer_converter.hpp @@ -13,14 +13,11 @@ # include # include # include +# include # include # include # include -# include -# include -# include - # include # include diff --git a/include/boost/python/pointee.hpp b/include/boost/python/pointee.hpp index ab8bb874..7ec01e08 100644 --- a/include/boost/python/pointee.hpp +++ b/include/boost/python/pointee.hpp @@ -6,9 +6,7 @@ # define POINTEE_DWA2002323_HPP # include - -# include -# include +# include namespace boost { namespace python { @@ -17,7 +15,7 @@ namespace detail template struct pointee_impl { - template struct apply : remove_pointer {}; + template struct apply : detail::remove_pointer {}; }; template <> @@ -33,11 +31,11 @@ namespace detail template struct pointee : detail::pointee_impl< - ::boost::is_pointer::value + detail::is_pointer::value >::template apply { }; -}} // namespace boost::python::detail +}} // namespace boost::python #endif // POINTEE_DWA2002323_HPP diff --git a/include/boost/python/reference_existing_object.hpp b/include/boost/python/reference_existing_object.hpp index 8c241071..4c834407 100644 --- a/include/boost/python/reference_existing_object.hpp +++ b/include/boost/python/reference_existing_object.hpp @@ -9,7 +9,7 @@ # include # include # include -# include +# include namespace boost { namespace python { @@ -31,7 +31,7 @@ struct reference_existing_object struct apply { BOOST_STATIC_CONSTANT( - bool, ok = is_pointer::value || is_reference::value); + bool, ok = detail::is_pointer::value || detail::is_reference::value); typedef typename mpl::if_c< ok diff --git a/include/boost/python/return_arg.hpp b/include/boost/python/return_arg.hpp index e869a58d..de239939 100644 --- a/include/boost/python/return_arg.hpp +++ b/include/boost/python/return_arg.hpp @@ -12,8 +12,7 @@ # include #endif -# include -# include +# include # include # include diff --git a/include/boost/python/return_by_value.hpp b/include/boost/python/return_by_value.hpp index 593fc59c..42d7076d 100644 --- a/include/boost/python/return_by_value.hpp +++ b/include/boost/python/return_by_value.hpp @@ -8,8 +8,7 @@ # include # include -# include -# include +# include # include diff --git a/include/boost/python/signature.hpp b/include/boost/python/signature.hpp index de4c5126..9b323a28 100644 --- a/include/boost/python/signature.hpp +++ b/include/boost/python/signature.hpp @@ -14,9 +14,9 @@ # include # include -# include # include +# include # include # include # include @@ -42,7 +42,7 @@ template struct most_derived { typedef typename mpl::if_< - is_convertible + detail::is_convertible , C1 , C2 >::type type; diff --git a/include/boost/python/suite/indexing/detail/indexing_suite_detail.hpp b/include/boost/python/suite/indexing/detail/indexing_suite_detail.hpp index 70df8a72..eb8b81c0 100644 --- a/include/boost/python/suite/indexing/detail/indexing_suite_detail.hpp +++ b/include/boost/python/suite/indexing/detail/indexing_suite_detail.hpp @@ -11,7 +11,7 @@ # include # include # include -# include +# include # include # include #include @@ -465,14 +465,14 @@ namespace boost { namespace python { namespace detail { template static object - base_get_item_helper(DataType const& p, mpl::true_) + base_get_item_helper(DataType const& p, detail::true_) { return object(ptr(p)); } template static object - base_get_item_helper(DataType const& x, mpl::false_) + base_get_item_helper(DataType const& x, detail::false_) { return object(x); } diff --git a/include/boost/python/suite/indexing/indexing_suite.hpp b/include/boost/python/suite/indexing/indexing_suite.hpp index 40301fdf..3469a2a4 100644 --- a/include/boost/python/suite/indexing/indexing_suite.hpp +++ b/include/boost/python/suite/indexing/indexing_suite.hpp @@ -14,7 +14,7 @@ # include # include # include -# include +# include namespace boost { namespace python { @@ -122,10 +122,10 @@ namespace boost { namespace python { mpl::bool_ , mpl::not_ > , typename mpl::or_< - is_same - , is_same > - , is_same > - , is_same > >::type> + detail::is_same + , detail::is_same > + , detail::is_same > + , detail::is_same > >::type> no_proxy; typedef detail::container_element diff --git a/include/boost/python/to_python_indirect.hpp b/include/boost/python/to_python_indirect.hpp index af6ed33b..212e1db3 100644 --- a/include/boost/python/to_python_indirect.hpp +++ b/include/boost/python/to_python_indirect.hpp @@ -18,10 +18,7 @@ # include -# include -# include - -# include +# include # if defined(__ICL) && __ICL < 600 # include @@ -38,7 +35,7 @@ struct to_python_indirect inline PyObject* operator()(U const& ref) const { - return this->execute(const_cast(ref), is_pointer()); + return this->execute(const_cast(ref), detail::is_pointer()); } #ifndef BOOST_PYTHON_NO_PY_SIGNATURES inline PyTypeObject const* @@ -49,20 +46,20 @@ struct to_python_indirect #endif private: template - inline PyObject* execute(U* ptr, mpl::true_) const + inline PyObject* execute(U* ptr, detail::true_) const { // No special NULL treatment for references if (ptr == 0) return python::detail::none(); else - return this->execute(*ptr, mpl::false_()); + return this->execute(*ptr, detail::false_()); } template - inline PyObject* execute(U const& x, mpl::false_) const + inline PyObject* execute(U const& x, detail::false_) const { U* const p = &const_cast(x); - if (is_polymorphic::value) + if (detail::is_polymorphic::value) { if (PyObject* o = detail::wrapper_base_::owner(p)) return incref(o); diff --git a/include/boost/python/to_python_value.hpp b/include/boost/python/to_python_value.hpp index 2681f8a3..2066d3a2 100644 --- a/include/boost/python/to_python_value.hpp +++ b/include/boost/python/to_python_value.hpp @@ -19,14 +19,12 @@ #include #include +#include #include #include -#include - #include #include -#include namespace boost { namespace python { diff --git a/include/boost/python/type_id.hpp b/include/boost/python/type_id.hpp index 38b7f7b4..601601c3 100644 --- a/include/boost/python/type_id.hpp +++ b/include/boost/python/type_id.hpp @@ -14,7 +14,7 @@ # include # include # include -# include +# include # ifndef BOOST_PYTHON_HAVE_GCC_CP_DEMANGLE # if defined(__GNUC__) \ diff --git a/test/bases.cpp b/test/bases.cpp index 84beb061..4e00f544 100644 --- a/test/bases.cpp +++ b/test/bases.cpp @@ -4,7 +4,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include #include -#include +#include struct A; struct B; @@ -42,8 +42,8 @@ int main() int , boost::python::detail::select_bases::type > collected1; - BOOST_STATIC_ASSERT((boost::is_same >::value)); - BOOST_STATIC_ASSERT((boost::is_same::type,boost::python::bases<> >::value)); + BOOST_STATIC_ASSERT((boost::python::detail::is_same >::value)); + BOOST_STATIC_ASSERT((boost::python::detail::is_same::type,boost::python::bases<> >::value)); typedef boost::python::detail::select_bases< int @@ -55,8 +55,8 @@ int main() >::type > collected2; - BOOST_STATIC_ASSERT((boost::is_same >::value)); - BOOST_STATIC_ASSERT((boost::is_same,long>::type,boost::python::bases >::value)); + BOOST_STATIC_ASSERT((boost::python::detail::is_same >::value)); + BOOST_STATIC_ASSERT((boost::python::detail::is_same,long>::type,boost::python::bases >::value)); return 0; } diff --git a/test/enum_ext.cpp b/test/enum_ext.cpp index e5c4f4fa..74224f1d 100644 --- a/test/enum_ext.cpp +++ b/test/enum_ext.cpp @@ -7,7 +7,7 @@ #include #include #if BOOST_WORKAROUND(__MWERKS__, <= 0x2407) -# include +#include # include #endif using namespace boost::python; @@ -17,7 +17,7 @@ enum color { red = 1, green = 2, blue = 4, blood = 1 }; #if BOOST_WORKAROUND(__MWERKS__, <= 0x2407) namespace boost // Pro7 has a hard time detecting enums { - template <> struct is_enum : boost::mpl::true_ {}; + template <> struct boost::python::detail::is_enum : boost::mpl::true_ {}; } #endif diff --git a/test/if_else.cpp b/test/if_else.cpp index 1c6258db..60cc5319 100644 --- a/test/if_else.cpp +++ b/test/if_else.cpp @@ -4,7 +4,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include #include -#include +#include typedef char c1; typedef char c2[2]; @@ -35,10 +35,10 @@ struct choose int main() { - BOOST_STATIC_ASSERT((boost::is_same::type,c1>::value)); - BOOST_STATIC_ASSERT((boost::is_same::type,c2>::value)); - BOOST_STATIC_ASSERT((boost::is_same::type,c3>::value)); - BOOST_STATIC_ASSERT((boost::is_same::type,c4>::value)); - BOOST_STATIC_ASSERT((boost::is_same::type,void*>::value)); + BOOST_STATIC_ASSERT((boost::python::detail::is_same::type,c1>::value)); + BOOST_STATIC_ASSERT((boost::python::detail::is_same::type,c2>::value)); + BOOST_STATIC_ASSERT((boost::python::detail::is_same::type,c3>::value)); + BOOST_STATIC_ASSERT((boost::python::detail::is_same::type,c4>::value)); + BOOST_STATIC_ASSERT((boost::python::detail::is_same::type,void*>::value)); return 0; } diff --git a/test/indirect_traits_test.cpp b/test/indirect_traits_test.cpp index 594cfe55..da4cc245 100644 --- a/test/indirect_traits_test.cpp +++ b/test/indirect_traits_test.cpp @@ -4,7 +4,6 @@ //#include #define BOOST_ENABLE_ASSERT_HANDLER #include -#include #include #include #include diff --git a/test/pointee.cpp b/test/pointee.cpp index d962e79f..2aa5dc3d 100644 --- a/test/pointee.cpp +++ b/test/pointee.cpp @@ -3,7 +3,7 @@ // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include #include #include #include @@ -13,19 +13,19 @@ struct A; int main() { BOOST_STATIC_ASSERT( - (boost::is_same< + (boost::python::detail::is_same< boost::python::pointee >::type , char** >::value)); BOOST_STATIC_ASSERT( - (boost::is_same< + (boost::python::detail::is_same< boost::python::pointee >::type , A>::value)); #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION BOOST_STATIC_ASSERT( - (boost::is_same< + (boost::python::detail::is_same< boost::python::pointee::type , char >::value)); diff --git a/test/select_holder.cpp b/test/select_holder.cpp index 4ecc52e7..8650bd06 100644 --- a/test/select_holder.cpp +++ b/test/select_holder.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -29,7 +29,7 @@ namespace boost { namespace python template void assert_same(U* = 0, T* = 0) { - BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::python::detail::is_same::value)); } From 8536e97c6779a2d2504dde930e464620b9778fb6 Mon Sep 17 00:00:00 2001 From: Stefan Seefeld Date: Wed, 14 Jun 2017 10:44:16 -0400 Subject: [PATCH 11/11] Use utf-8 encoding --- test/crossmod_opaque.py | 2 +- test/opaque.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/crossmod_opaque.py b/test/crossmod_opaque.py index c51aac76..533ac16f 100644 --- a/test/crossmod_opaque.py +++ b/test/crossmod_opaque.py @@ -1,4 +1,4 @@ -# -*- coding: latin-1 -*- +# -*- coding: utf-8 -*- # Copyright Gottfried Ganßauge 2006. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at diff --git a/test/opaque.py b/test/opaque.py index 719c4243..9f566372 100644 --- a/test/opaque.py +++ b/test/opaque.py @@ -1,4 +1,4 @@ -# -*- coding: latin-1 -*- +# -*- coding: utf-8 -*- # Copyright Gottfried Ganßauge 2003..2006. 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)