2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-19 16:32:16 +00:00

Compare commits

...

55 Commits

Author SHA1 Message Date
Stefan Seefeld
fed4f0d0f9 Fix version number. 2017-08-19 11:57:56 -04:00
Stefan Seefeld
39edfd45cf Fix traits qualification. 2017-08-19 11:57:39 -04:00
Stefan Seefeld
8c2a808cbe Remove 'numeric' documentation. 2017-07-31 11:38:40 -04:00
Stefan Seefeld
aeedea409a Merge branch 'develop' 2017-07-20 13:04:44 -04:00
Stefan Seefeld
2d1f66fd19 Remove module as obsoleted by Boost.NumPy. 2017-07-20 11:39:58 -04:00
Stefan Seefeld
69e38d2186 Fix documentation. 2017-07-20 10:11:19 -04:00
Stefan Seefeld
df6926551e Merge branch 'develop' 2017-06-25 18:27:19 -04:00
Stefan Seefeld
8536e97c67 Use utf-8 encoding 2017-06-25 14:33:42 -04:00
shreyans800755
142661dac8 Use std type_traits instead of boost type_traits
Fixes https://github.com/boostorg/python/issues/106
2017-06-25 14:17:41 -04:00
John Kirkham
d6554d6c65 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.
2017-06-12 09:32:31 -04:00
John Kirkham
90829714cc 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.
2017-06-12 09:32:31 -04:00
Stefan Seefeld
664d443df3 Fix Python3 compatibility bug. 2017-06-03 18:26:14 -04:00
Stefan Seefeld
c4fe369d69 Require NumPy 1.7 API. 2017-06-02 19:31:54 -04:00
Stefan Seefeld
7cfc47008e Rename test source 2017-06-02 19:31:54 -04:00
Raphael Isemann
1452dfe713 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.
2017-06-02 17:44:46 -04:00
Saliya
3613142839 Fixing compiling error 'error: ‘NPY_FLOAT16’ was not declared in this scope'
Signed-off-by: Saliya <hamparawa@gmail.com>
2017-06-02 15:35:04 -04:00
John Zwinck
b2f53e1acf 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<char*>.
2017-05-04 19:29:56 -04:00
Stefan Seefeld
3844c4fc5f Fix more missing symbols. 2017-04-14 13:14:05 -04:00
Stefan Seefeld
7d3df3d3a7 Merge branch 'develop' 2017-03-28 12:57:32 -04:00
Stefan Seefeld
df16e3e55e Fix typo. 2017-03-28 12:54:05 -04:00
Stefan Seefeld
ae747521b0 Merge branch 'develop' 2017-03-24 15:53:30 -04:00
Stefan Seefeld
3066c73c09 Fix Windows builds. 2017-03-24 15:39:13 -04:00
Stefan Seefeld
edd890bd2b More dllexport fixes 2017-03-24 15:39:13 -04:00
Stefan Seefeld
352792c90a Add more export symbols. 2017-03-16 20:14:39 -04:00
Stefan Seefeld
47faef65ee Fix documentation links. 2017-03-16 11:35:26 -04:00
Rene Rivera
5e4b44e0af Don't build numpy if there's no python version to target. 2017-03-06 10:39:01 -06:00
Rene Rivera
5121fc11f9 Don't build numpy if there's no python version to target. 2017-03-06 10:30:41 -06:00
Rene Rivera
07b1489f3b BPL builds targets need to always be defined. 2017-03-05 15:17:26 -06:00
Rene Rivera
471e6181b2 BPL builds targets need to always be defined. 2017-03-05 15:16:36 -06:00
Rene Rivera
44ea0562b2 Fix no pynumpy target when no numpy configured. 2017-03-05 09:00:27 -06:00
Rene Rivera
60fba03e99 Fix libs from referencing BPL when there is no python configured. 2017-03-05 09:00:10 -06:00
Rene Rivera
398e7f02b8 Fix no pynumpy target when no numpy configured. 2017-03-05 08:56:57 -06:00
Rene Rivera
1e315242ce Fix libs from referencing BPL when there is no python configured. 2017-03-03 22:28:22 -06:00
al3xst
77ee91d5c5 Updated python library reference url
Due to changes on the python website, the url to the pickle library reference page was invalid.
2017-03-03 18:29:05 -05:00
Stefan Seefeld
e3c9dd78aa Merge branch 'develop' 2017-03-03 18:07:49 -05:00
Rene Rivera
e670de2795 Fix empty numpy lib name caused by missing parens for lib name map. 2017-03-02 21:55:49 -06:00
Rene Rivera
367b793ac9 Merge branch 'develop' of https://github.com/boostorg/python.git into develop 2017-03-01 10:15:47 -06:00
Rene Rivera
8c170d9193 Fix building of multiple BPL libs even when the configured python does
not match.
2017-03-01 10:15:37 -06:00
SPKorhonen
bd7b8ecba5 Fix for missing export symbols, issue #98 (#110)
Fix for missing export symbols in shared library of boost::python::numpy
2017-02-15 11:53:28 -05:00
Jürgen Hunold
0224f54ae0 Switch^Cisibility support to BOOST_SYMBOL_EXPORT. Refs #2114 2017-02-13 10:43:23 -05:00
Stefan Seefeld
d14b8cf411 Fix library dependency with Python 3. 2017-01-03 21:17:51 -05:00
Tadeu Manoel
4e0b96faa8 Fix conversion of PyUnicodeObject to wstring (#93) 2016-12-14 07:58:07 -05:00
Tadeu Manoel
7178a70176 Fix a problem where test_builtin_converters.py is not being run (#94)
This was happening because the module docstring was not the first statement.
2016-12-14 07:54:37 -05:00
Stefan Seefeld
aaf9022770 Merge branch 'develop' 2016-11-02 14:12:45 -04:00
Vladimir Prus
36bbdde2fe Use Boost-global python tagging. 2016-10-28 11:56:15 +03:00
Stefan Seefeld
1df6d84b80 Fix Python 3 incompatibility. 2016-10-27 08:37:25 -04:00
Stefan Seefeld
e968329174 Clean up examples. 2016-10-23 21:34:16 -04:00
Stefan Seefeld
07c8cbe652 Adjust to Boost.Build changes. 2016-10-23 21:27:31 -04:00
Stefan Seefeld
163e469bc4 Minor fixes. 2016-10-19 11:25:48 -04:00
Stefan Seefeld
ac39d2ed69 Fix doc build. 2016-10-19 07:34:34 -04:00
Stefan Seefeld
264f6ae4b9 Work around a sphinx bug. 2016-10-18 21:14:47 -04:00
Stefan Seefeld
84c96447e2 Add NumPy support to the BB-based build logic. 2016-10-18 16:32:05 -04:00
Stefan Seefeld
dc8d68d3fc Fix id clash in hierarchical tocs. 2016-10-16 20:30:15 -04:00
Rene Rivera
88ea1f9626 Fix syntax error caused by merging. 2016-10-10 12:22:25 -05:00
Rene Rivera
731ba745ca Add, and update, documentation build targets. 2016-10-10 12:22:10 -05:00
145 changed files with 894 additions and 1600 deletions

View File

@@ -39,6 +39,7 @@ arch = ARGUMENTS.get('arch', platform.machine())
env_vars = {}
if 'CXX' in os.environ: env_vars['CXX'] = os.environ['CXX']
if 'CXXFLAGS' in os.environ: env_vars['CXXFLAGS'] = os.environ['CXXFLAGS'].split()
env_vars['ENV'] = os.environ #{'PATH': os.environ['PATH'], 'TMP' : os.environ['TMP']}
env = Environment(toolpath=['config/tools'],
tools=['default', 'libs', 'tests', 'doc', 'sphinx4scons'],
variables=vars,
@@ -84,7 +85,7 @@ if not GetOption('verbose'):
config.ui.pretty_output(env)
# build
env['BPL_VERSION'] = '1.62'
env['BPL_VERSION'] = '1.65'
for e in config.variants(env):
variant_dir=e.subst("$BOOST_CURRENT_VARIANT_DIR")
e.SConscript('src/SConscript', variant_dir=variant_dir + '/src',

View File

@@ -69,13 +69,15 @@ install:
# pip will build them from source using the MSVC compiler matching the
# target Python version and architecture
- easy_install scons
- easy_install sphinx
- pip install numpy
#- "%CMD_IN_ENV% pip install -r dev-requirements.txt"
build_script:
# Build the compiled extension
#- "%CMD_IN_ENV% python setup.py build"
- scons config arch=%ARCH% --boost-include=%BOOST_PREFIX%
- scons arch=%ARCH%
- scons arch=%ARCH% --verbose
test_script:
# Run the project tests

View File

@@ -6,6 +6,7 @@ import os ;
import indirect ;
import modules ;
import feature ;
import property ;
import python ;
@@ -30,54 +31,27 @@ else
;
}
rule find-py3-version
{
local versions = [ feature.values python ] ;
local py3ver ;
for local v in $(versions)
{
if $(v) >= 3.0
{
py3ver = $(v) ;
}
}
return $(py3ver) ;
}
py3-version = [ find-py3-version ] ;
py2-version = [ py-version 2 ] ;
py3-version = [ py-version 3 ] ;
project boost/python
: source-location ../src
: requirements
-<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
<tag>@$(__name__).tag
;
rule tag ( name : type ? : property-set )
{
local result = $(name) ;
if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB
{
if $(name) = boost_python && $(PYTHON_ID)
{
result = $(result)-$(PYTHON_ID) ;
}
}
# forward to the boost tagging rule
return [ indirect.call $(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
$(result) : $(type) : $(property-set) ] ;
}
rule cond ( test ? : yes * : no * ) { if $(test) { return $(yes) ; } else { return $(no) ; } }
rule unless ( test ? : yes * : no * ) { if ! $(test) { return $(yes) ; } else { return $(no) ; } }
local rule eq ( a : b ) { if $(a) = $(b) { return 1 ; } }
rule lib_boost_python ( is-py3 ? )
lib_boost_python(2) = boost_python ;
lib_boost_python(3) = boost_python3 ;
lib_boost_python($(py2-version)) = $(lib_boost_python(2)) ;
lib_boost_python($(py3-version)) = $(lib_boost_python(3)) ;
rule lib_boost_python ( version )
{
lib [ cond $(is-py3) : boost_python3 : boost_python ]
lib $(lib_boost_python($(version)))
: # sources
numeric.cpp
list.cpp
long.cpp
dict.cpp
@@ -131,21 +105,83 @@ rule lib_boost_python ( is-py3 ? )
<dependency>config-warning
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
[ cond $(is-py3) : <python>$(py3-version) ]
<python>$(version)
-<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).python-tag
<conditional>@python.require-py
: # default build
<link>shared
: # usage requirements
<link>static:<define>BOOST_PYTHON_STATIC_LIB
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
;
}
lib_boost_python ;
boost-install boost_python ;
lib_boost_numpy(2) = boost_numpy ;
lib_boost_numpy(3) = boost_numpy3 ;
if $(py3-version)
lib_boost_numpy($(py2-version)) = $(lib_boost_numpy(2)) ;
lib_boost_numpy($(py3-version)) = $(lib_boost_numpy(3)) ;
rule lib_boost_numpy ( version )
{
lib_boost_python yes ;
boost-install boost_python3 ;
numpy-include = [ python.numpy-include ] ;
lib $(lib_boost_numpy($(version)))
: # sources
numpy/dtype.cpp
numpy/matrix.cpp
numpy/ndarray.cpp
numpy/numpy.cpp
numpy/scalars.cpp
numpy/ufunc.cpp
: # requirements
<link>static:<define>BOOST_NUMPY_STATIC_LIB
<define>BOOST_NUMPY_SOURCE
[ cond [ python.numpy ] : <library>/python//python_for_extensions ]
[ unless [ python.numpy ] : <build>no ]
<include>$(numpy-include)
<library>$(lib_boost_python($(version)))
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
<python>$(version)
-<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).python-tag
<conditional>@python.require-py
: # default build
<link>shared
: # usage requirements
<link>static:<define>BOOST_NUMPY_STATIC_LIB
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
;
}
libraries = ;
for local N in 2 3
{
if $(py$(N)-version)
{
lib_boost_python $(py$(N)-version) ;
libraries += $(lib_boost_python($(py$(N)-version))) ;
}
else
{
alias $(lib_boost_python($(N))) ;
}
if $(py$(N)-version) && [ python.numpy ]
{
lib_boost_numpy $(py$(N)-version) ;
libraries += $(lib_boost_numpy($(py$(N)-version))) ;
}
else
{
alias $(lib_boost_numpy($(N))) ;
}
}
boost-install $(libraries) ;

View File

@@ -4,10 +4,14 @@
# 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 boostbook ;
import quickbook ;
import docutils ;
import os ;
path-constant here : . ;
path-constant images : html/images ;
project python/doc
: requirements
-<xsl:param>boost.defaults=Boost
@@ -17,9 +21,16 @@ project python/doc
<format>html:<xsl:param>chunk.section.depth=1
;
import boostbook ;
import quickbook ;
import docutils ;
make numpy : numpy/index.rst : @sphinx-build ;
if [ os.name ] = NT
{
actions sphinx-build { chdir "$(>:D)" && make clean && make html}
}
else
{
actions sphinx-build { make -C "$(>:D)" clean html}
}
boostbook python : python.qbk
: <format>html:<name>$(here)/html
@@ -51,5 +62,5 @@ html article : article.rst
###############################################################################
alias boostdoc ;
explicit boostdoc ;
alias boostrelease : python tutorial reference article ;
alias boostrelease : python tutorial reference numpy article ;
explicit boostrelease ;

BIN
doc/images/jam.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@@ -6,6 +6,7 @@ SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
HTMLDIR = ../html/numpy
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
@@ -39,9 +40,9 @@ clean:
-rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(HTMLDIR)
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
@echo "Build finished. The HTML pages are in $(HTMLDIR)."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml

View File

@@ -27,12 +27,12 @@
}
.admonition-title { font-weight: bold;}
#table-of-contents
.toctree-wrapper
{
border: 1px solid #dcdcdc;
padding: 1em;
margin: 0 2em;
}
#table-of-contents .caption,
#table-of-contents .topic-title { font-weight: bold;}
.toctree-wrapper .caption,
.toctree-wrapper .topic-title { font-weight: bold;}

View File

@@ -7,7 +7,6 @@ Welcome to the documentation of the Boost.Python NumPy extension!
=================================================================
.. toctree::
:caption: Table of Contents
:maxdepth: 2
Tutorial <tutorial/index>

View File

@@ -6,6 +6,7 @@ if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set BUILDDIR=_build
set HTMLDIR=../html/numpy
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
if NOT "%PAPER%" == "" (
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
@@ -41,10 +42,10 @@ if "%1" == "clean" (
)
if "%1" == "html" (
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %HTMLDIR%
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
echo.Build finished. The HTML pages are in %HTMLDIR%.
goto end
)

View File

@@ -2,7 +2,6 @@ Boost.Python NumPy extension Reference
======================================
.. toctree::
:caption: Table of Contents
:maxdepth: 2
dtype

View File

@@ -2,7 +2,6 @@ Boost.Python NumPy extension Tutorial
=====================================
.. toctree::
:caption: Table of Contents
:maxdepth: 2
simple

View File

@@ -38,7 +38,7 @@ The `indexing_suite` class is the base class for the management of C++ container
[[__iter__(self)]
[This method is called when an iterator is required for a container. This method should return a new iterator object that can iterate over all the objects in the container. For mappings, it should iterate over the keys of the container, and should also be made available as the method iterkeys().
Iterator objects also need to implement this method; they are required to return themselves. For more information on iterator objects, see [@http://www.python.org/doc/current/lib/typeiter.html Iterator Types] in the [@http://www.python.org/doc/current/lib/lib.html Python Library Reference].]]
Iterator objects also need to implement this method; they are required to return themselves. For more information on iterator objects, see [@https://docs.python.org/3/library/stdtypes.html#iterator-types Iterator Types] in the [@https://docs.python.org/3/library/index.html Python Library Reference].]]
[[__contains__(self, item)]
[Called to implement membership test operators. Should return true if item is in self, false otherwise. For mapping objects, this should consider the keys of the mapping rather than the values or the key-item pairs.]]

View File

@@ -1,153 +0,0 @@
[section boost/python/numeric.hpp]
[section Introduction]
Exposes a [link concepts.objectwrapper.typewrapper_concept_requirements TypeWrapper] for the Python [@http://www.python.org/dev/doc/devel/lib/typesmapping.html array] type.
[endsect]
[section Class `array`]
Provides access to the array types of [@http://www.pfdubois.com/numpy/ Numerical Python]\ 's [@http://www.pfdubois.com/numpy/#Numeric Numeric] and [@http://stsdas.stsci.edu/numarray/index.html NumArray] modules. With the exception of the functions documented below, the semantics of the constructors and member functions defined below can be fully understood by reading the [link concepts.objectwrapper.typewrapper_concept_requirements TypeWrapper] concept definition. Since array is publicly derived from object, the public object interface applies to array instances as well.
The default behavior is to use numarray.NDArray as the associated Python type if the numarray module is installed in the default location. Otherwise it falls back to use Numeric.ArrayType. If neither extension module is installed, overloads of wrapped C++ functions with numeric::array parameters will never be matched, and other attempted uses of numeric::array will raise an appropriate Python exception. The associated Python type can be set manually using the set_module_and_type(...) static function.
``
namespace boost { namespace python { namespace numeric
{
class array : public object
{
public:
object astype();
template <class Type>
object astype(Type const& type_);
template <class Type>
array new_(Type const& type_) const;
template <class Sequence>
void resize(Sequence const& x);
void resize(long x1);
void resize(long x1, long x2);
...
void resize(long x1, long x2,...long xn);
template <class Sequence>
void setshape(Sequence const& x);
void setshape(long x1);
void setshape(long x1, long x2);
...
void setshape(long x1, long x2,...long xn);
template <class Indices, class Values>
void put(Indices const& indices, Values const& values);
template <class Sequence>
object take(Sequence const& sequence, long axis = 0);
template <class File>
void tofile(File const& f) const;
object factory();
template <class Sequence>
object factory(Sequence const&);
template <class Sequence, class Typecode>
object factory(Sequence const&, Typecode const&, bool copy = true, bool savespace = false);
template <class Sequence, class Typecode, class Type>
object factory(Sequence const&, Typecode const&, bool copy, bool savespace, Type const&);
template <class Sequence, class Typecode, class Type, class Shape>
object factory(Sequence const&, Typecode const&, bool copy, bool savespace, Type const&, Shape const&);
template <class T1>
explicit array(T1 const& x1);
template <class T1, class T2>
explicit array(T1 const& x1, T2 const& x2);
...
template <class T1, class T2,...class Tn>
explicit array(T1 const& x1, T2 const& x2,...Tn const& xn);
static void set_module_and_type();
static void set_module_and_type(char const* package_path = 0, char const* type_name = 0);
static void get_module_name();
object argmax(long axis=-1);
object argmin(long axis=-1);
object argsort(long axis=-1);
void byteswap();
object copy() const;
object diagonal(long offset = 0, long axis1 = 0, long axis2 = 1) const;
void info() const;
bool is_c_array() const;
bool isbyteswapped() const;
void sort();
object trace(long offset = 0, long axis1 = 0, long axis2 = 1) const;
object type() const;
char typecode() const;
object getflat() const;
long getrank() const;
object getshape() const;
bool isaligned() const;
bool iscontiguous() const;
long itemsize() const;
long nelements() const;
object nonzero() const;
void ravel();
object repeat(object const& repeats, long axis=0);
void setflat(object const& flat);
void swapaxes(long axis1, long axis2);
str tostring() const;
void transpose(object const& axes = object());
object view() const;
};
}}}
``
[endsect]
[section Class `array` observer functions]
``
object factory();
template <class Sequence>
object factory(Sequence const&);
template <class Sequence, class Typecode>
object factory(Sequence const&, Typecode const&, bool copy = true, bool savespace = false);
template <class Sequence, class Typecode, class Type>
object factory(Sequence const&, Typecode const&, bool copy, bool savespace, Type const&);
template <class Sequence, class Typecode, class Type, class Shape>
object factory(Sequence const&, Typecode const&, bool copy, bool savespace, Type const&, Shape const&);
``
These functions map to the underlying array type's array() function family. They are not called "array" because of the C++ limitation that you can't define a member function with the same name as its enclosing class.
``
template <class Type>
array new_(Type const&) const;
``
This function maps to the underlying array type's new() function. It is not called "new" because that is a keyword in C++.
[endsect]
[section Class `array` static functions]
``
static void set_module_and_type(char const* package_path, char const* type_name);
static void set_module_and_type();
``
[variablelist
[[Requires][package_path and type_name, if supplied, is an [link ntbs].]]
[[Effects][The first form sets the package path of the module that supplies the type named by type_name to package_path. The second form restores the default search behavior. The associated Python type will be searched for only the first time it is needed, and thereafter the first time it is needed after an invocation of set_module_and_type.]]
]
``static std::string get_module_name()``
[variablelist
[[Effects][Returns the name of the module containing the class that will be held by new `numeric::array` instances.]]
]
[endsect]
[section Example]
``
#include <boost/python/numeric.hpp>
#include <boost/python/tuple.hpp>
// sets the first element in a 2d numeric array
void set_first_element(numeric::array& y, double value)
{
y[make_tuple(0,0)] = value;
}
``
[endsect]
[endsect]

View File

@@ -5,7 +5,6 @@
[include dict.qbk]
[include list.qbk]
[include long.qbk]
[include numeric.qbk]
[include object.qbk]
[include str.qbk]
[include slice.qbk]

View File

@@ -4,7 +4,7 @@ Pickle is a Python module for object serialization, also known as persistence, m
It is often necessary to save and restore the contents of an object to a file. One approach to this problem is to write a pair of functions that read and write data from a file in a special format. A powerful alternative approach is to use Python's pickle module. Exploiting Python's ability for introspection, the pickle module recursively converts nearly arbitrary Python objects into a stream of bytes that can be written to a file.
The Boost Python Library supports the pickle module through the interface as described in detail in the [@http://www.python.org/doc/current/lib/module-pickle.html Python Library Reference for pickle]. This interface involves the special methods `__getinitargs__`, `__getstate__` and `__setstate__` as described in the following. Note that `Boost.Python` is also fully compatible with Python's cPickle module.
The Boost Python Library supports the pickle module through the interface as described in detail in the [@https://docs.python.org/2/library/pickle.html Python Library Reference for pickle]. This interface involves the special methods `__getinitargs__`, `__getstate__` and `__setstate__` as described in the following. Note that `Boost.Python` is also fully compatible with Python's cPickle module.
[endsect]
[section The Pickle Interface]
At the user level, the Boost.Python pickle interface involves three special methods:

View File

@@ -105,14 +105,6 @@ list odd_elements(list l)
return l[slice(_,_,2)];
}
// Perform a multidimensional extended slice of a Numeric.array
numeric::array even_columns(numeric::array arr)
{
// select every other column, starting with the second, of a 2-D array.
// Equivalent to "return arr[:, 1::2]" in Python.
return arr[make_tuple( slice(), slice(1,_,2))];
}
// Perform a summation over a slice of a std::vector.
double partial_sum(std::vector<double> const& Foo, const slice index)
{

View File

@@ -92,7 +92,7 @@ who had to use a different tool.
We will skip over the details. Our objective will be to simply create
the hello world module and run it in Python. For a complete reference to
building Boost.Python, check out: [@../../../building.html
building Boost.Python, check out: [@../building.html
building.html]. After this brief ['bjam] tutorial, we should have built
the DLLs and run a python program using the extension.
@@ -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

View File

@@ -1,43 +1,35 @@
# Copyright David Abrahams 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)
# Copyright Stefan Seefeld 2016.
# 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)
# Specify the path to the Boost project. If you move this project,
# adjust this path to refer to the Boost root directory.
use-project boost
: ../../.. ;
import python ;
# Set up the project-wide requirements that everything uses the
# boost_python library from the project whose global ID is
# /boost/python.
project
: requirements <library>/boost/python//boost_python
<implicit-dependency>/boost//headers
: usage-requirements <implicit-dependency>/boost//headers
;
# Declare the three extension modules. You can specify multiple
# source files after the colon separated by spaces.
python-extension getting_started1 : getting_started1.cpp ;
python-extension getting_started2 : getting_started2.cpp ;
python-extension std_pair_ext : std_pair.cpp ;
# A little "rule" (function) to clean up the syntax of declaring tests
# of these extension modules.
local rule run-test ( test-name : sources + )
if ! [ python.configured ]
{
import testing ;
testing.make-test run-pyd : $(sources) : : $(test-name) ;
ECHO "warning: no Python configured in user-config.jam" ;
ECHO "warning: will use default configuration" ;
using python ;
}
# Declare test targets
run-test test1 : getting_started1 test_getting_started1.py ;
run-test test2 : getting_started2 test_getting_started2.py ;
run-test test3 : std_pair_ext test_std_pair.py ;
# Adjust the following if Boost.Python isn't installed in a default location
lib boost_python ;
# A target that runs all the tests
alias test : test1 test2 test3 ;
project
: requirements
# <include>/path/to/boost/python
<library>boost_python
;
# Only run tests when explicitly requested
explicit test test1 test2 test3 ;
rule run-test ( test-name : sources + )
{
import testing ;
testing.make-test run-pyd : $(sources) : : $(test-name) ;
}
build-project quickstart ;
build-project tutorial ;
if [ python.numpy ]
{
build-project numpy ;
}

View File

@@ -1,16 +0,0 @@
.. Copyright David Abrahams 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)
To get started with the Boost Python Library, use the examples
getting_started1.cpp and getting_started2.cpp. Invoking
bjam --toolset=your-toolset test
in this directory will build and run the examples. See
http://www.boost.org/more/getting_started.html for details about the
--toolset= option.
If you move this example from its place in the Boost development tree
you'll need to edit the two lines indicated in Jamroot and
boost-build.jam.

11
example/README.md Normal file
View File

@@ -0,0 +1,11 @@
![logo](https://raw.githubusercontent.com/boostorg/python/develop/doc/images/bpl.png)
# Examples
This directory contains various examples using Boost.Python.
You may compile these using the `bjam` command either in this directory
or in any of the subdirectories.
You may need to adjust the paths in the Jamroot file if Boost.Python
is not installed in a default location.
See http://boostorg.github.io/python/doc/html/building/no_install_quickstart.html
for details.

View File

@@ -1,7 +0,0 @@
# Copyright David Abrahams 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)
# Edit this path to point at the tools/build/src subdirectory of your
# Boost installation. Absolute paths work, too.
boost-build ../../../tools/build/src ;

View File

@@ -1,25 +0,0 @@
// Copyright Ralf W. Grosse-Kunstleve 2002-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)
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
#include <string>
namespace { // Avoid cluttering the global namespace.
// A couple of simple C++ functions that we want to expose to Python.
std::string greet() { return "hello, world"; }
int square(int number) { return number * number; }
}
namespace python = boost::python;
// Python requires an exported function called init<module-name> in every
// extension module. This is where we build the module contents.
BOOST_PYTHON_MODULE(getting_started1)
{
// Add regular functions to the module.
python::def("greet", greet);
python::def("square", square);
}

View File

@@ -1,41 +0,0 @@
// Copyright Ralf W. Grosse-Kunstleve 2002-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)
#include <boost/python/class.hpp>
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
#include <iostream>
#include <string>
namespace { // Avoid cluttering the global namespace.
// A friendly class.
class hello
{
public:
hello(const std::string& country) { this->country = country; }
std::string greet() const { return "Hello from " + country; }
private:
std::string country;
};
// A function taking a hello object as an argument.
std::string invite(const hello& w) {
return w.greet() + "! Please come soon!";
}
}
BOOST_PYTHON_MODULE(getting_started2)
{
using namespace boost::python;
class_<hello>("hello", init<std::string>())
// Add a regular member function.
.def("greet", &hello::greet)
// Add invite() as a member of hello!
.def("invite", invite)
;
// Also add invite() as a regular function to the module.
def("invite", invite);
}

29
example/numpy/Jamfile Normal file
View File

@@ -0,0 +1,29 @@
# Copyright Stefan Seefeld 2016.
# 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 python ;
# Adjust the following if Boost.Python isn't installed in a default location
lib boost_numpy
:
: <search>/usr/local/Boost/lib
<include>/usr/local/Boost/include
;
project numpy
: requirements
<include>/usr/local/Boost/include
<library>boost_numpy
<location>.
;
exe simple : simple.cpp boost_numpy /python//python ;
exe dtype : dtype.cpp boost_numpy /python//python ;
exe ndarray : ndarray.cpp /python//python ;
exe fromdata : fromdata.cpp /python//python ;
exe ufunc : ufunc.cpp /python//python ;
exe wrap : wrap.cpp /python//python ;
python-extension gaussian : gaussian.cpp ;

View File

@@ -12,11 +12,11 @@
*
*/
#include <boost/numpy.hpp>
#include <boost/python/numpy.hpp>
#include <iostream>
namespace p = boost::python;
namespace np = boost::numpy;
namespace np = boost::python::numpy;
int main(int argc, char **argv)
{

View File

@@ -8,11 +8,11 @@
* manipulate data in either Python or C++ and have the changes reflected in both.
*/
#include <boost/numpy.hpp>
#include <boost/python/numpy.hpp>
#include <iostream>
namespace p = boost::python;
namespace np = boost::numpy;
namespace np = boost::python::numpy;
int main(int argc, char **argv)

View File

@@ -3,7 +3,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/numpy.hpp>
#include <boost/python/numpy.hpp>
#include <cmath>
#include <memory>
@@ -14,7 +14,7 @@ const double M_PI = boost::math::constants::pi<double>();
#endif
namespace bp = boost::python;
namespace bn = boost::numpy;
namespace bn = boost::python::numpy;
/**
* A 2x2 matrix class, purely for demonstration purposes.

View File

@@ -11,11 +11,11 @@
* non-unit strides.
*/
#include <boost/numpy.hpp>
#include <boost/python/numpy.hpp>
#include <iostream>
namespace p = boost::python;
namespace np = boost::numpy;
namespace np = boost::python::numpy;
#if _MSC_VER
using boost::uint8_t;

View File

@@ -3,11 +3,11 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/numpy.hpp>
#include <boost/python/numpy.hpp>
#include <iostream>
namespace p = boost::python;
namespace np = boost::numpy;
namespace np = boost::python::numpy;
int main(int argc, char **argv)
{

View File

@@ -11,11 +11,11 @@
* None of the methods like np::add, np::multiply etc are supported as yet
*/
#include <boost/numpy.hpp>
#include <boost/python/numpy.hpp>
#include <iostream>
namespace p = boost::python;
namespace np = boost::numpy;
namespace np = boost::python::numpy;
// Create the structs necessary to implement the ufuncs

View File

@@ -23,12 +23,12 @@
* Python. Again, see the Gaussian demo for an example.
*/
#include <boost/numpy.hpp>
#include <boost/python/numpy.hpp>
#include <boost/scoped_array.hpp>
#include <iostream>
namespace p = boost::python;
namespace np = boost::numpy;
namespace np = boost::python::numpy;
// This is roughly the most efficient way to write a C/C++ function that operates
// on a 2-d NumPy array - operate directly on the array by incrementing a pointer

Binary file not shown.

View File

@@ -1,23 +1,15 @@
# Copyright David Abrahams 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)
# Copyright Stefan Seefeld 2016.
# 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)
# Specify the path to the Boost project. If you move this project,
# adjust the path to refer to the Boost root directory.
use-project boost
: ../../../.. ;
# Set up the project-wide requirements that everything uses the
# boost_python library defined in the project whose global ID is
# /boost/python.
project boost-python-quickstart
: requirements <library>/boost/python//boost_python
<implicit-dependency>/boost//headers
: usage-requirements <implicit-dependency>/boost//headers
;
# Make the definition of the python-extension rule available
import python ;
import testing ;
project quickstart
: requirements
<location>.
;
# Declare a Python extension called hello.
python-extension extending : extending.cpp ;
@@ -25,8 +17,6 @@ python-extension extending : extending.cpp ;
# Declare an executable called embedding that embeds Python
exe embedding : embedding.cpp /python//python ;
import testing ;
# Declare a test of the extension module
testing.make-test run-pyd : extending test_extending.py : : test_ext ;

View File

@@ -1,7 +0,0 @@
# Copyright David Abrahams 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)
# Edit this path to point at the tools/build/src subdirectory of your
# Boost installation. Absolute paths work, too.
boost-build ../../../../tools/build/src ;

View File

@@ -1,6 +1,7 @@
#! /usr/bin/env python
# Copyright Stefan Seefeld 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)
print 'Hello World !'
print('Hello World !')
number = 42

View File

@@ -1,3 +1,4 @@
#! /usr/bin/env python
# Copyright Ralf W. Grosse-Kunstleve 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)

View File

@@ -1,49 +0,0 @@
// Copyright Ralf W. Grosse-Kunstleve 2002-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)
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
#include <boost/python/tuple.hpp>
#include <boost/python/to_python_converter.hpp>
namespace { // Avoid cluttering the global namespace.
// Converts a std::pair instance to a Python tuple.
template <typename T1, typename T2>
struct std_pair_to_tuple
{
static PyObject* convert(std::pair<T1, T2> const& p)
{
return boost::python::incref(
boost::python::make_tuple(p.first, p.second).ptr());
}
static PyTypeObject const *get_pytype () {return &PyTuple_Type; }
};
// Helper for convenience.
template <typename T1, typename T2>
struct std_pair_to_python_converter
{
std_pair_to_python_converter()
{
boost::python::to_python_converter<
std::pair<T1, T2>,
std_pair_to_tuple<T1, T2>,
true //std_pair_to_tuple has get_pytype
>();
}
};
// Example function returning a std::pair.
std::pair<int, int>
foo() { return std::pair<int, int>(3, 5); }
} // namespace anonymous
BOOST_PYTHON_MODULE(std_pair_ext)
{
using namespace boost::python;
std_pair_to_python_converter<int, int>();
def("foo", foo);
}

View File

@@ -1,21 +0,0 @@
# Copyright Ralf W. Grosse-Kunstleve 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)
r'''>>> import getting_started1
>>> print getting_started1.greet()
hello, world
>>> number = 11
>>> print number, '*', number, '=', getting_started1.square(number)
11 * 11 = 121
'''
def run(args = None):
if args is not None:
import sys
sys.argv = args
import doctest, test_getting_started1
return doctest.testmod(test_getting_started1)
if __name__ == '__main__':
import sys
sys.exit(run()[0])

View File

@@ -1,34 +0,0 @@
# Copyright Ralf W. Grosse-Kunstleve 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)
r'''>>> from getting_started2 import *
>>> hi = hello('California')
>>> hi.greet()
'Hello from California'
>>> invite(hi)
'Hello from California! Please come soon!'
>>> hi.invite()
'Hello from California! Please come soon!'
>>> class wordy(hello):
... def greet(self):
... return hello.greet(self) + ', where the weather is fine'
...
>>> hi2 = wordy('Florida')
>>> hi2.greet()
'Hello from Florida, where the weather is fine'
>>> invite(hi2)
'Hello from Florida! Please come soon!'
'''
def run(args = None):
if args is not None:
import sys
sys.argv = args
import doctest, test_getting_started2
return doctest.testmod(test_getting_started2)
if __name__ == '__main__':
import sys
sys.exit(run()[0])

View File

@@ -1,6 +0,0 @@
# Copyright Ralf W. Grosse-Kunstleve 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)
import std_pair_ext
assert std_pair_ext.foo() == (3, 5)
print "OK"

19
example/tutorial/Jamfile Normal file
View File

@@ -0,0 +1,19 @@
# Copyright Stefan Seefeld 2016.
# 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 python ;
project tutorial
: requirements
<location>.
;
python-extension hello_ext : hello.cpp ;
run-test hello : hello_ext hello.py ;
alias test : hello ;
explicit test ;

View File

@@ -1,51 +0,0 @@
# Copyright David Abrahams 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)
import python ;
if ! [ python.configured ]
{
ECHO "notice: no Python configured in user-config.jam" ;
ECHO "notice: will use default configuration" ;
using python ;
}
# Specify the path to the Boost project. If you move this project,
# adjust this path to refer to the Boost root directory.
use-project boost
: ../../../.. ;
# Set up the project-wide requirements that everything uses the
# boost_python library from the project whose global ID is
# /boost/python.
project
: requirements <library>/boost/python//boost_python
<implicit-dependency>/boost//headers
: usage-requirements <implicit-dependency>/boost//headers
;
# Declare the three extension modules. You can specify multiple
# source files after the colon separated by spaces.
python-extension hello_ext : hello.cpp ;
# Put the extension and Boost.Python DLL in the current directory, so
# that running script by hand works.
install convenient_copy
: hello_ext
: <install-dependencies>on <install-type>SHARED_LIB <install-type>PYTHON_EXTENSION
<location>.
;
# A little "rule" (function) to clean up the syntax of declaring tests
# of these extension modules.
local rule run-test ( test-name : sources + )
{
import testing ;
testing.make-test run-pyd : $(sources) : : $(test-name) ;
}
# Declare test targets
run-test hello : hello_ext hello.py ;

View File

@@ -1,7 +1,8 @@
#! /usr/bin/env python
# Copyright Joel de Guzman 2002-2007. 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)
# Hello World Example from the tutorial
import hello_ext
print hello_ext.greet()
print(hello_ext.greet())

View File

@@ -42,7 +42,6 @@
# include <boost/python/make_function.hpp>
# include <boost/python/manage_new_object.hpp>
# include <boost/python/module.hpp>
# include <boost/python/numeric.hpp>
# include <boost/python/object.hpp>
# include <boost/python/object_protocol.hpp>
# include <boost/python/object_protocol_core.hpp>

View File

@@ -9,7 +9,7 @@
# include <boost/python/converter/arg_from_python.hpp>
# if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) \
|| BOOST_WORKAROUND(BOOST_INTEL_WIN, BOOST_TESTED_AT(800))
# include <boost/type_traits/remove_cv.hpp>
# include <boost/python/detail/type_traits.hpp>
#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<T>::type
typename detail::remove_cv<T>::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<T>::type
typename detail::remove_cv<T>::type
# else
T
# endif

View File

@@ -11,10 +11,7 @@
# include <boost/config.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/python/detail/type_list.hpp>
# include <boost/type_traits/is_reference.hpp>
# include <boost/type_traits/remove_reference.hpp>
# include <boost/type_traits/remove_cv.hpp>
# include <boost/python/detail/type_traits.hpp>
# include <boost/preprocessor/enum_params.hpp>
# include <boost/preprocessor/repeat.hpp>
@@ -116,9 +113,9 @@ namespace detail
template <class T>
struct is_reference_to_keywords
{
BOOST_STATIC_CONSTANT(bool, is_ref = is_reference<T>::value);
typedef typename remove_reference<T>::type deref;
typedef typename remove_cv<deref>::type key_t;
BOOST_STATIC_CONSTANT(bool, is_ref = detail::is_reference<T>::value);
typedef typename detail::remove_reference<T>::type deref;
typedef typename detail::remove_cv<deref>::type key_t;
BOOST_STATIC_CONSTANT(bool, is_key = is_keywords<key_t>::value);
BOOST_STATIC_CONSTANT(bool, value = (is_ref & is_key));

View File

@@ -6,8 +6,8 @@
# define BASES_DWA2002321_HPP
# include <boost/python/detail/prefix.hpp>
# include <boost/type_traits/object_traits.hpp>
# include <boost/python/detail/type_list.hpp>
# include <boost/python/detail/type_traits.hpp>
# include <boost/mpl/if.hpp>
# include <boost/mpl/bool.hpp>
# include <boost/preprocessor/enum_params_with_a_default.hpp>

View File

@@ -6,9 +6,8 @@
# define CAST_DWA200269_HPP
# include <boost/python/detail/prefix.hpp>
# include <boost/python/detail/type_traits.hpp>
# include <boost/type_traits/same_traits.hpp>
# include <boost/type_traits/cv_traits.hpp>
# include <boost/type.hpp>
# include <boost/python/base_type_traits.hpp>
# include <boost/python/detail/convertible.hpp>
@@ -76,9 +75,9 @@ namespace detail
template <class Source, class Target>
inline Target* upcast_impl(Source* x, Target*)
{
typedef typename add_cv<Source>::type src_t;
typedef typename add_cv<Target>::type target_t;
bool const same = is_same<src_t,target_t>::value;
typedef typename detail::add_cv<Source>::type src_t;
typedef typename detail::add_cv<Target>::type target_t;
bool const same = detail::is_same<src_t,target_t>::value;
return detail::upcaster<same>::execute(x, (Target*)0);
}

View File

@@ -28,13 +28,10 @@
# include <boost/python/detail/operator_id.hpp>
# include <boost/python/detail/def_helper.hpp>
# include <boost/python/detail/force_instantiate.hpp>
# include <boost/python/detail/type_traits.hpp>
# include <boost/python/detail/unwrap_type_id.hpp>
# include <boost/python/detail/unwrap_wrapper.hpp>
# include <boost/type_traits/is_same.hpp>
# include <boost/type_traits/is_member_function_pointer.hpp>
# include <boost/type_traits/is_polymorphic.hpp>
# include <boost/mpl/size.hpp>
# include <boost/mpl/for_each.hpp>
# include <boost/mpl/bool.hpp>
@@ -53,7 +50,6 @@
# ifdef BOOST_PYTHON_NO_MEMBER_POINTER_ORDERING
# include <boost/mpl/and.hpp>
# include <boost/type_traits/is_member_pointer.hpp>
# endif
namespace boost { namespace python {
@@ -84,8 +80,8 @@ namespace detail
template <class T>
struct is_data_member_pointer
: mpl::and_<
is_member_pointer<T>
, mpl::not_<is_member_function_pointer<T> >
detail::is_member_pointer<T>
, mpl::not_<detail::is_member_function_pointer<T> >
>
{};
@@ -138,11 +134,11 @@ namespace detail
must_be_derived_class_member(Default const&)
{
// https://svn.boost.org/trac/boost/ticket/5803
//typedef typename assertion<mpl::not_<is_same<Default,Fn> > >::failed test0;
//typedef typename assertion<mpl::not_<detail::is_same<Default,Fn> > >::failed test0;
# if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
typedef typename assertion<is_polymorphic<T> >::failed test1 BOOST_ATTRIBUTE_UNUSED;
typedef typename assertion<detail::is_polymorphic<T> >::failed test1 BOOST_ATTRIBUTE_UNUSED;
# endif
typedef typename assertion<is_member_function_pointer<Fn> >::failed test2 BOOST_ATTRIBUTE_UNUSED;
typedef typename assertion<detail::is_member_function_pointer<Fn> >::failed test2 BOOST_ATTRIBUTE_UNUSED;
not_a_derived_class_member<Default>(Fn());
}
};

View File

@@ -8,8 +8,7 @@
# include <boost/python/detail/prefix.hpp>
# include <boost/python/converter/from_python.hpp>
# include <boost/python/detail/indirect_traits.hpp>
# include <boost/type_traits/transform_traits.hpp>
# include <boost/type_traits/cv_traits.hpp>
# include <boost/python/detail/type_traits.hpp>
# include <boost/python/converter/rvalue_from_python_data.hpp>
# include <boost/mpl/eval_if.hpp>
# include <boost/mpl/if.hpp>
@@ -106,7 +105,7 @@ struct reference_arg_from_python : arg_lvalue_from_python_base
template <class T>
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<U> args from Python to C++

View File

@@ -24,11 +24,7 @@
# include <boost/python/detail/convertible.hpp>
# include <boost/python/detail/string_literal.hpp>
# include <boost/python/detail/value_is_shared_ptr.hpp>
# include <boost/type_traits/cv_traits.hpp>
# include <boost/type_traits/composite_traits.hpp>
# include <boost/type_traits/function_traits.hpp>
# include <boost/python/detail/type_traits.hpp>
# include <boost/mpl/or.hpp>
@@ -116,9 +112,9 @@ namespace detail
, typename mpl::if_<
mpl::or_<
is_function<T>
boost::python::detail::is_function<T>
, indirect_traits::is_pointer_to_function<T>
, is_member_function_pointer<T>
, boost::python::detail::is_member_function_pointer<T>
>
, function_arg_to_python<T>
@@ -127,7 +123,7 @@ namespace detail
, object_manager_arg_to_python<T>
, typename mpl::if_<
is_pointer<T>
boost::python::detail::is_pointer<T>
, pointer_deep_arg_to_python<T>
, typename mpl::if_<

View File

@@ -8,7 +8,7 @@
# include <boost/python/handle.hpp>
# include <boost/python/cast.hpp>
# include <boost/python/converter/pyobject_traits.hpp>
# include <boost/type_traits/object_traits.hpp>
# include <boost/python/detail/type_traits.hpp>
# include <boost/mpl/if.hpp>
# include <boost/python/detail/indirect_traits.hpp>
# include <boost/mpl/bool.hpp>

View File

@@ -6,7 +6,7 @@
# define POINTER_TYPE_ID_DWA2002222_HPP
# include <boost/python/type_id.hpp>
# include <boost/type_traits/composite_traits.hpp>
# include <boost/python/detail/type_traits.hpp>
namespace boost { namespace python { namespace converter {
@@ -59,7 +59,7 @@ template <class T>
type_info pointer_type_id(T(*)() = 0)
{
return detail::pointer_typeid_select<
is_reference<T>::value
boost::python::detail::is_lvalue_reference<T>::value
>::execute((T(*)())0);
}

View File

@@ -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>

View File

@@ -8,6 +8,7 @@
# include <boost/python/detail/prefix.hpp>
# include <boost/python/converter/registered.hpp>
# include <boost/python/detail/unwind_type.hpp>
# include <boost/python/detail/type_traits.hpp>
namespace boost { namespace python {
@@ -53,7 +54,7 @@ inline python::type_info unwind_type_id_(boost::type<void>* = 0, mpl::true_* =0)
template <class T>
inline python::type_info unwind_type_id(boost::type<T>* p= 0)
{
return unwind_type_id_(p, (mpl::bool_<boost::is_void<T>::value >*)0 );
return unwind_type_id_(p, (mpl::bool_<boost::python::detail::is_void<T>::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<T>*)0, (mpl::bool_<boost::is_void<T>::value >*)0 )
detail::unwind_type_id_((boost::type<T>*)0, (mpl::bool_<boost::python::detail::is_void<T>::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<T>*) 0, (mpl::bool_<boost::is_void<T>::value >*)0 )
detail::unwind_type_id_((boost::type<T>*) 0, (mpl::bool_<boost::python::detail::is_void<T>::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<T>*)0, (mpl::bool_<boost::is_void<T>::value >*)0 )
detail::unwind_type_id_((boost::type<T>*)0, (mpl::bool_<boost::python::detail::is_void<T>::value >*)0 )
);
return r ? r->to_python_target_type(): 0;
}

View File

@@ -10,9 +10,7 @@
#include <boost/python/type_id.hpp>
#include <boost/python/converter/registry.hpp>
#include <boost/python/converter/registrations.hpp>
#include <boost/type_traits/transform_traits.hpp>
#include <boost/type_traits/cv_traits.hpp>
#include <boost/type_traits/is_void.hpp>
#include <boost/python/detail/type_traits.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/type.hpp>
#include <memory>
@@ -44,8 +42,8 @@ namespace detail
template <class T>
struct registered
: detail::registered_base<
typename add_reference<
typename add_cv<T>::type
typename boost::python::detail::add_lvalue_reference<
typename boost::python::detail::add_cv<T>::type
>::type
>
{

View File

@@ -7,8 +7,7 @@
# include <boost/python/converter/registered.hpp>
# include <boost/python/converter/pointer_type_id.hpp>
# include <boost/python/converter/registry.hpp>
# include <boost/type_traits/transform_traits.hpp>
# include <boost/type_traits/cv_traits.hpp>
# include <boost/python/detail/type_traits.hpp>
namespace boost { namespace python { namespace converter {
@@ -17,9 +16,9 @@ struct registration;
template <class T>
struct registered_pointee
: registered<
typename remove_pointer<
typename remove_cv<
typename remove_reference<T>::type
typename boost::python::detail::remove_pointer<
typename boost::python::detail::remove_cv<
typename boost::python::detail::remove_reference<T>::type
>::type
>::type
>

View File

@@ -14,7 +14,7 @@
# include <boost/python/detail/void_return.hpp>
# include <boost/python/errors.hpp>
# include <boost/python/handle.hpp>
# include <boost/type_traits/has_trivial_copy.hpp>
# include <boost/python/detail/type_traits.hpp>
# include <boost/mpl/and.hpp>
# include <boost/mpl/bool.hpp>

View File

@@ -8,9 +8,8 @@
# include <boost/python/converter/constructor_function.hpp>
# include <boost/python/detail/referent_storage.hpp>
# include <boost/python/detail/destroy.hpp>
# include <boost/python/detail/type_traits.hpp>
# include <boost/static_assert.hpp>
# include <boost/type_traits/add_reference.hpp>
# include <boost/type_traits/add_cv.hpp>
# include <cstddef>
// 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<T>::type
typename boost::python::detail::add_lvalue_reference<T>::type
>::type storage;
};
@@ -110,7 +109,8 @@ struct rvalue_from_python_data : rvalue_from_python_storage<T>
// Destroys any object constructed in the storage.
~rvalue_from_python_data();
private:
typedef typename add_reference<typename add_cv<T>::type>::type ref_type;
typedef typename boost::python::detail::add_lvalue_reference<
typename boost::python::detail::add_cv<T>::type>::type ref_type;
};
//

View File

@@ -19,14 +19,7 @@
# include <boost/python/detail/indirect_traits.hpp>
# include <boost/python/detail/not_specified.hpp>
# include <boost/python/detail/value_arg.hpp>
# include <boost/type_traits/add_const.hpp>
# include <boost/type_traits/add_reference.hpp>
# include <boost/type_traits/is_member_pointer.hpp>
# if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
# include <boost/type_traits/remove_cv.hpp>
# endif
# include <boost/python/detail/type_traits.hpp>
# include <boost/mpl/eval_if.hpp>
# include <boost/mpl/if.hpp>
@@ -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 <class D, class P>
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 <class D, class Policies>
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>(d), policies, mpl::vector1<D&>()
@@ -169,18 +162,18 @@ namespace detail
// Handle non-member pointers without policies
template <class D>
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<D>::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 <class C, class D, class Policies>
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<C>::type Class;
typedef typename detail::remove_cv<C>::type Class;
#else
typedef C Class;
#endif
@@ -193,18 +186,18 @@ namespace detail
// Handle pointers-to-members without policies
template <class C, class D>
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<D>::type policies;
return detail::make_getter(pm, policies(), mpl::true_(), 0);
return detail::make_getter(pm, policies(), detail::true_(), 0);
}
// Handle references
template <class D, class P>
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 <class D, class Policies>
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<D>(p), policies, mpl::vector2<void,D const&>()
@@ -226,7 +219,7 @@ namespace detail
// Handle pointers-to-members
template <class C, class D, class Policies>
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<D,C>(pm)
@@ -237,9 +230,9 @@ namespace detail
// Handle references
template <class D, class Policies>
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 <class D, class Policies>
inline object make_getter(D& d, Policies const& policies)
{
return detail::make_getter(d, policies, is_member_pointer<D>(), 0L);
return detail::make_getter(d, policies, detail::is_member_pointer<D>(), 0L);
}
template <class D, class Policies>
inline object make_getter(D const& d, Policies const& policies)
{
return detail::make_getter(d, policies, is_member_pointer<D>(), 0L);
return detail::make_getter(d, policies, detail::is_member_pointer<D>(), 0L);
}
template <class D>
@@ -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<D>(), 0L);
return detail::make_getter(x, policy, detail::is_member_pointer<D>(), 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<D>(), 0L);
return detail::make_getter(d, policy, detail::is_member_pointer<D>(), 0L);
}
# endif
@@ -290,26 +283,26 @@ inline object make_getter(D const& d)
template <class D, class Policies>
inline object make_setter(D& x, Policies const& policies)
{
return detail::make_setter(x, policies, is_member_pointer<D>(), 0);
return detail::make_setter(x, policies, detail::is_member_pointer<D>(), 0);
}
template <class D, class Policies>
inline object make_setter(D const& x, Policies const& policies)
{
return detail::make_setter(x, policies, is_member_pointer<D>(), 0);
return detail::make_setter(x, policies, detail::is_member_pointer<D>(), 0);
}
template <class D>
inline object make_setter(D& x)
{
return detail::make_setter(x, default_call_policies(), is_member_pointer<D>(), 0);
return detail::make_setter(x, default_call_policies(), detail::is_member_pointer<D>(), 0);
}
# if !BOOST_WORKAROUND(__EDG_VERSION__, <= 238)
template <class D>
inline object make_setter(D const& x)
{
return detail::make_setter(x, default_call_policies(), is_member_pointer<D>(), 0);
return detail::make_setter(x, default_call_policies(), detail::is_member_pointer<D>(), 0);
}
# endif

View File

@@ -8,10 +8,8 @@
# include <boost/python/detail/prefix.hpp>
# include <boost/mpl/if.hpp>
# include <boost/python/to_python_value.hpp>
# include <boost/python/detail/type_traits.hpp>
# include <boost/python/detail/value_arg.hpp>
# include <boost/type_traits/transform_traits.hpp>
# include <boost/type_traits/is_pointer.hpp>
# include <boost/type_traits/is_reference.hpp>
# include <boost/mpl/or.hpp>
# include <boost/mpl/front.hpp>
@@ -64,7 +62,7 @@ struct default_result_converter
struct apply
{
typedef typename mpl::if_<
mpl::or_<is_pointer<R>, is_reference<R> >
mpl::or_<detail::is_pointer<R>, detail::is_reference<R> >
, detail::specify_a_return_value_policy_to_wrap_functions_returning<R>
, boost::python::to_python_value<
typename detail::value_arg<R>::type

View File

@@ -8,8 +8,7 @@
# include <boost/config.hpp>
# include <boost/type.hpp>
# include <boost/mpl/if.hpp>
# include <boost/type_traits/object_traits.hpp>
# include <boost/type_traits/cv_traits.hpp>
# include <boost/python/detail/type_traits.hpp>
# include <boost/python/tag.hpp>
namespace boost { namespace python { namespace detail {

View File

@@ -16,6 +16,7 @@
# include <boost/python/detail/invoke.hpp>
# include <boost/python/detail/signature.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/python/detail/type_traits.hpp>
# include <boost/python/arg_from_python.hpp>
# include <boost/python/converter/context_result_converter.hpp>
@@ -31,9 +32,6 @@
# include <boost/compressed_pair.hpp>
# include <boost/type_traits/is_same.hpp>
# include <boost/type_traits/is_convertible.hpp>
# include <boost/mpl/apply.hpp>
# include <boost/mpl/eval_if.hpp>
# include <boost/mpl/identity.hpp>
@@ -236,7 +234,7 @@ struct caller_arity<N>
typedef typename select_result_converter<Policies, rtype>::type result_converter;
static const signature_element ret = {
(boost::is_void<rtype>::value ? "void" : type_id<rtype>().name())
(is_void<rtype>::value ? "void" : type_id<rtype>().name())
, &detail::converter_target_type<result_converter>::get_pytype
, boost::detail::indirect_traits::is_reference_to_non_const<rtype>::value
};

View File

@@ -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))
@@ -118,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:
//

View File

@@ -7,11 +7,11 @@
# if defined(__EDG_VERSION__) && __EDG_VERSION__ <= 241
# include <boost/mpl/if.hpp>
# include <boost/type_traits/conversion_traits.hpp>
# include <boost/python/detail/type_traits.hpp>
# 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;

View File

@@ -4,7 +4,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef CV_CATEGORY_DWA200222_HPP
# define CV_CATEGORY_DWA200222_HPP
# include <boost/type_traits/cv_traits.hpp>
# include <boost/python/detail/type_traits.hpp>
namespace boost { namespace python { namespace detail {
@@ -26,8 +26,8 @@ struct cv_category
// BOOST_STATIC_CONSTANT(bool, c = is_const<T>::value);
// BOOST_STATIC_CONSTANT(bool, v = is_volatile<T>::value);
typedef cv_tag<
::boost::is_const<T>::value
, ::boost::is_volatile<T>::value
is_const<T>::value
, is_volatile<T>::value
> type;
};

View File

@@ -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)

View File

@@ -7,7 +7,7 @@
# include <boost/python/type_id.hpp>
# include <boost/python/detail/indirect_traits.hpp>
# include <boost/type_traits/cv_traits.hpp>
# include <boost/python/detail/type_traits.hpp>
namespace boost { namespace python { namespace detail {

View File

@@ -6,12 +6,11 @@
# define DEF_HELPER_DWA200287_HPP
# include <boost/python/args.hpp>
# include <boost/type_traits/same_traits.hpp>
# include <boost/python/detail/indirect_traits.hpp>
# include <boost/python/detail/type_traits.hpp>
# include <boost/mpl/not.hpp>
# include <boost/mpl/and.hpp>
# include <boost/mpl/or.hpp>
# include <boost/type_traits/add_reference.hpp>
# include <boost/mpl/lambda.hpp>
# include <boost/mpl/apply.hpp>
# include <boost/tuple/tuple.hpp>
@@ -73,7 +72,8 @@ namespace detail
struct tuple_extract_base_select
{
typedef typename Tuple::head_type head_type;
typedef typename mpl::apply1<Predicate, typename add_reference<head_type>::type>::type match_t;
typedef typename mpl::apply1<Predicate,
typename add_lvalue_reference<head_type>::type>::type match_t;
BOOST_STATIC_CONSTANT(bool, match = match_t::value);
typedef typename tuple_extract_impl<match>::template apply<Tuple,Predicate> type;
};

View File

@@ -12,7 +12,7 @@
#define DEFAULTS_DEF_JDG20020811_HPP
#include <boost/python/detail/defaults_gen.hpp>
#include <boost/type_traits.hpp>
#include <boost/python/detail/type_traits.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/size.hpp>
#include <boost/static_assert.hpp>
@@ -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<void, return_type>::value
is_same<void, return_type>::value
, void_return_type
, non_void_return_type
>::type stubs_type;

View File

@@ -5,7 +5,7 @@
#ifndef DESTROY_DWA2002221_HPP
# define DESTROY_DWA2002221_HPP
# include <boost/type_traits/is_array.hpp>
# include <boost/python/detail/type_traits.hpp>
# include <boost/detail/workaround.hpp>
namespace boost { namespace python { namespace detail {
@@ -30,7 +30,7 @@ struct value_destroyer<true>
for (T const volatile* p = first; p != first + sizeof(A)/sizeof(T); ++p)
{
value_destroyer<
boost::is_array<T>::value
is_array<T>::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<T>::value)
(is_array<T>::value)
>::execute((const volatile T*)p);
}

View File

@@ -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;

View File

@@ -11,8 +11,6 @@
# include <boost/python/detail/preprocessor.hpp>
# include <boost/python/detail/none.hpp>
# include <boost/type_traits/is_member_function_pointer.hpp>
# include <boost/preprocessor/iterate.hpp>
# include <boost/preprocessor/facilities/intercept.hpp>
# include <boost/preprocessor/repetition/enum_trailing_params.hpp>

View File

@@ -5,7 +5,7 @@
#ifndef POINTEE_DWA2002323_HPP
# define POINTEE_DWA2002323_HPP
# include <boost/type_traits/object_traits.hpp>
# include <boost/python/detail/type_traits.hpp>
namespace boost { namespace python { namespace detail {

View File

@@ -11,8 +11,8 @@
# include <boost/type.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/python/detail/type_traits.hpp>
# include <boost/type_traits/object_traits.hpp>
# include <boost/mpl/if.hpp>
# include <boost/preprocessor/comma_if.hpp>

View File

@@ -7,8 +7,7 @@
# include <cstddef>
# include <boost/type.hpp>
# include <boost/type_traits/array_traits.hpp>
# include <boost/type_traits/same_traits.hpp>
# include <boost/python/detail/type_traits.hpp>
# include <boost/mpl/bool.hpp>
# include <boost/detail/workaround.hpp>

View File

@@ -6,11 +6,9 @@
# define TRANSLATE_EXCEPTION_TDS20091020_HPP
# include <boost/python/detail/exception_handler.hpp>
# include <boost/python/detail/type_traits.hpp>
# include <boost/call_traits.hpp>
# include <boost/type_traits/add_const.hpp>
# include <boost/type_traits/add_reference.hpp>
# include <boost/type_traits/remove_reference.hpp>
# include <boost/function/function0.hpp>
@@ -33,7 +31,7 @@ struct translate_exception
typename add_const<ExceptionType>::type
>::type exception_non_ref;
# else
typedef typename add_reference<
typedef typename add_lvalue_reference<
typename add_const<ExceptionType>::type
>::type exception_cref;
# endif

View File

@@ -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 <boost/type_traits/transform_traits.hpp>
# include <boost/type_traits/same_traits.hpp>
# include <boost/type_traits/cv_traits.hpp>
# include <boost/type_traits/is_polymorphic.hpp>
# include <boost/type_traits/composite_traits.hpp>
# include <boost/type_traits/conversion_traits.hpp>
# include <boost/type_traits/add_pointer.hpp>
# include <boost/type_traits/remove_pointer.hpp>
# include <boost/type_traits/is_void.hpp>
# include <boost/type_traits/object_traits.hpp>
# include <boost/type_traits/add_lvalue_reference.hpp>
# include <boost/type_traits/function_traits.hpp>
# include <boost/type_traits/is_scalar.hpp>
# include <boost/type_traits/alignment_traits.hpp>
# include <boost/mpl/bool.hpp>
#else
# include <type_traits>
#endif
# include <boost/type_traits/is_base_and_derived.hpp>
# include <boost/type_traits/alignment_traits.hpp>
# include <boost/type_traits/has_trivial_copy.hpp>
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<bool, true>;
using false_ = std::integral_constant<bool, false>;
#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

View File

@@ -7,7 +7,7 @@
# include <boost/python/detail/cv_category.hpp>
# include <boost/python/detail/indirect_traits.hpp>
# include <boost/type_traits/object_traits.hpp>
# include <boost/python/detail/type_traits.hpp>
namespace boost { namespace python { namespace detail {
@@ -155,10 +155,10 @@ unwind_type(boost::type<U>*p =0, Generator* =0)
#endif
{
BOOST_STATIC_CONSTANT(int, indirection
= (boost::is_pointer<U>::value ? pointer_ : 0)
= (is_pointer<U>::value ? pointer_ : 0)
+ (indirect_traits::is_reference_to_pointer<U>::value
? reference_to_pointer_
: boost::is_reference<U>::value
: is_lvalue_reference<U>::value
? reference_
: 0));

View File

@@ -6,8 +6,7 @@
# include <boost/python/detail/copy_ctor_mutates_rhs.hpp>
# include <boost/mpl/if.hpp>
# include <boost/type_traits/add_reference.hpp>
# include <boost/type_traits/add_const.hpp>
# include <boost/python/detail/indirect_traits.hpp>
namespace boost { namespace python { namespace detail {
@@ -16,7 +15,7 @@ struct value_arg
: mpl::if_<
copy_ctor_mutates_rhs<T>
, T
, typename add_reference<
, typename add_lvalue_reference<
typename add_const<T>::type
>::type
>

View File

@@ -9,11 +9,11 @@
# include <boost/mpl/bool.hpp>
# include <boost/preprocessor/enum_params.hpp>
# include <boost/type_traits/remove_reference.hpp>
# include <boost/type_traits/remove_cv.hpp>
# include <boost/python/detail/type_traits.hpp>
# include <boost/python/detail/is_xxx.hpp>
namespace boost { namespace python { namespace detail {
# define BOOST_PYTHON_VALUE_IS_XXX_DEF(name, qualified_name, nargs) \
template <class X_> \
struct value_is_##name \
@@ -24,9 +24,10 @@ struct value_is_##name \
typename remove_reference<X_>::type \
>::type \
>::value); \
typedef mpl::bool_<value> type; \
typedef mpl::bool_<value> type; \
\
};
}}} // namespace boost::python::detail
#endif // VALUE_IS_XXX_DWA2003224_HPP

View File

@@ -5,7 +5,7 @@
#ifndef VOID_PTR_DWA200239_HPP
# define VOID_PTR_DWA200239_HPP
# include <boost/type_traits/remove_cv.hpp>
# include <boost/python/detail/type_traits.hpp>
namespace boost { namespace python { namespace detail {

11
include/boost/python/detail/wrapper_base.hpp Executable file → Normal file
View File

@@ -5,8 +5,7 @@
# define WRAPPER_BASE_DWA2004722_HPP
# include <boost/python/detail/prefix.hpp>
# include <boost/type_traits/is_polymorphic.hpp>
# include <boost/mpl/bool.hpp>
# include <boost/python/detail/type_traits.hpp>
namespace boost { namespace python {
@@ -14,21 +13,21 @@ class override;
namespace detail
{
class BOOST_PYTHON_DECL_FORWARD wrapper_base;
class wrapper_base;
namespace wrapper_base_ // ADL disabler
{
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 <class T>
inline PyObject*
owner_impl(T const volatile* x, mpl::true_);
owner_impl(T const volatile* x, detail::true_);
template <class T>
inline PyObject*
@@ -59,7 +58,7 @@ namespace detail
{
template <class T>
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<wrapper_base const volatile*>(x))
{

View File

@@ -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();
};

View File

@@ -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());
}
}

View File

@@ -27,7 +27,7 @@
#include <boost/mpl/joint_view.hpp>
#include <boost/mpl/back.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/python/detail/type_traits.hpp>
#include <boost/preprocessor/enum_params_with_a_default.hpp>
#include <boost/preprocessor/enum_params.hpp>

View File

@@ -8,12 +8,10 @@
# include <boost/python/detail/prefix.hpp>
# include <boost/python/detail/target.hpp>
# include <boost/python/detail/type_traits.hpp>
# include <boost/python/object/iterator.hpp>
# include <boost/python/object_core.hpp>
# include <boost/type_traits/cv_traits.hpp>
# include <boost/type_traits/transform_traits.hpp>
# 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 <class T>
struct iterators
: detail::iterators_impl<
boost::is_const<T>::value
detail::is_const<T>::value
>::template apply<T>
{
};

View File

@@ -13,6 +13,7 @@
# include <boost/python/type_id.hpp>
# include <boost/python/converter/registry.hpp>
# include <boost/python/detail/void_ptr.hpp>
# include <boost/python/detail/type_traits.hpp>
namespace boost { namespace python {
@@ -35,7 +36,7 @@ namespace detail
{
static inline void* execute(PyObject* op)
{
typedef typename boost::add_reference<U>::type param;
typedef typename add_lvalue_reference<U>::type param;
return &Extractor::execute(
boost::python::detail::void_ptr_to_reference(
op, (param(*)())0 )

View File

@@ -43,19 +43,19 @@ namespace detail
private:
template <class U>
void dispatch(U* x, mpl::true_) const
void dispatch(U* x, detail::true_) const
{
#if __cplusplus < 201103L
std::auto_ptr<U> owner(x);
dispatch(owner, mpl::false_());
dispatch(owner, detail::false_());
#else
std::unique_ptr<U> owner(x);
dispatch(std::move(owner), mpl::false_());
dispatch(std::move(owner), detail::false_());
#endif
}
template <class Ptr>
void dispatch(Ptr x, mpl::false_) const
void dispatch(Ptr x, detail::false_) const
{
typedef typename pointee<Ptr>::type value_type;
typedef objects::pointer_holder<Ptr,value_type> holder;

View File

@@ -7,9 +7,9 @@
# include <boost/python/detail/prefix.hpp>
# include <boost/python/detail/indirect_traits.hpp>
# include <boost/python/detail/type_traits.hpp>
# include <boost/mpl/if.hpp>
# include <boost/python/to_python_indirect.hpp>
# include <boost/type_traits/composite_traits.hpp>
namespace boost { namespace python {
@@ -29,7 +29,7 @@ struct manage_new_object
struct apply
{
typedef typename mpl::if_c<
boost::is_pointer<T>::value
detail::is_pointer<T>::value
, to_python_indirect<T, detail::make_owning_holder>
, detail::manage_new_object_requires_a_pointer_return_type<T>
>::type type;

View File

@@ -1,242 +0,0 @@
// Copyright David Abrahams 2002.
// 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 NUMARRAY_DWA2002922_HPP
# define NUMARRAY_DWA2002922_HPP
# include <boost/python/detail/prefix.hpp>
# include <boost/python/tuple.hpp>
# include <boost/python/str.hpp>
# include <boost/preprocessor/iteration/local.hpp>
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/repetition/enum.hpp>
# include <boost/preprocessor/repetition/enum_params.hpp>
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
namespace boost { namespace python { namespace numeric {
class array;
namespace aux
{
struct BOOST_PYTHON_DECL array_base : object
{
# define BOOST_PP_LOCAL_MACRO(n) \
array_base(BOOST_PP_ENUM_PARAMS_Z(1, n, object const& x));
# define BOOST_PP_LOCAL_LIMITS (1, 7)
# include BOOST_PP_LOCAL_ITERATE()
object argmax(long axis=-1);
object argmin(long axis=-1);
object argsort(long axis=-1);
object astype(object const& type = object());
void byteswap();
object copy() const;
object diagonal(long offset = 0, long axis1 = 0, long axis2 = 1) const;
void info() const;
bool is_c_array() const;
bool isbyteswapped() const;
array new_(object type) const;
void sort();
object trace(long offset = 0, long axis1 = 0, long axis2 = 1) const;
object type() const;
char typecode() const;
object factory(
object const& sequence = object()
, object const& typecode = object()
, bool copy = true
, bool savespace = false
, object type = object()
, object shape = object());
object getflat() const;
long getrank() const;
object getshape() const;
bool isaligned() const;
bool iscontiguous() const;
long itemsize() const;
long nelements() const;
object nonzero() const;
void put(object const& indices, object const& values);
void ravel();
object repeat(object const& repeats, long axis=0);
void resize(object const& shape);
void setflat(object const& flat);
void setshape(object const& shape);
void swapaxes(long axis1, long axis2);
object take(object const& sequence, long axis = 0) const;
void tofile(object const& file) const;
str tostring() const;
void transpose(object const& axes = object());
object view() const;
public: // implementation detail - do not touch.
BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(array_base, object);
};
struct BOOST_PYTHON_DECL array_object_manager_traits
{
static bool check(PyObject* obj);
static detail::new_non_null_reference adopt(PyObject* obj);
static PyTypeObject const* get_pytype() ;
};
} // namespace aux
class array : public aux::array_base
{
typedef aux::array_base base;
public:
object astype() { return base::astype(); }
template <class Type>
object astype(Type const& type_)
{
return base::astype(object(type_));
}
template <class Type>
array new_(Type const& type_) const
{
return base::new_(object(type_));
}
template <class Sequence>
void resize(Sequence const& x)
{
base::resize(object(x));
}
# define BOOST_PP_LOCAL_MACRO(n) \
void resize(BOOST_PP_ENUM_PARAMS_Z(1, n, long x)) \
{ \
resize(make_tuple(BOOST_PP_ENUM_PARAMS_Z(1, n, x))); \
}
# define BOOST_PP_LOCAL_LIMITS (1, BOOST_PYTHON_MAX_ARITY)
# include BOOST_PP_LOCAL_ITERATE()
template <class Sequence>
void setshape(Sequence const& x)
{
base::setshape(object(x));
}
# define BOOST_PP_LOCAL_MACRO(n) \
void setshape(BOOST_PP_ENUM_PARAMS_Z(1, n, long x)) \
{ \
setshape(make_tuple(BOOST_PP_ENUM_PARAMS_Z(1, n, x))); \
}
# define BOOST_PP_LOCAL_LIMITS (1, BOOST_PYTHON_MAX_ARITY)
# include BOOST_PP_LOCAL_ITERATE()
template <class Indices, class Values>
void put(Indices const& indices, Values const& values)
{
base::put(object(indices), object(values));
}
template <class Sequence>
object take(Sequence const& sequence, long axis = 0)
{
return base::take(object(sequence), axis);
}
template <class File>
void tofile(File const& f) const
{
base::tofile(object(f));
}
object factory()
{
return base::factory();
}
template <class Sequence>
object factory(Sequence const& sequence)
{
return base::factory(object(sequence));
}
template <class Sequence, class Typecode>
object factory(
Sequence const& sequence
, Typecode const& typecode_
, bool copy = true
, bool savespace = false
)
{
return base::factory(object(sequence), object(typecode_), copy, savespace);
}
template <class Sequence, class Typecode, class Type>
object factory(
Sequence const& sequence
, Typecode const& typecode_
, bool copy
, bool savespace
, Type const& type
)
{
return base::factory(object(sequence), object(typecode_), copy, savespace, object(type));
}
template <class Sequence, class Typecode, class Type, class Shape>
object factory(
Sequence const& sequence
, Typecode const& typecode_
, bool copy
, bool savespace
, Type const& type
, Shape const& shape
)
{
return base::factory(object(sequence), object(typecode_), copy, savespace, object(type), object(shape));
}
# define BOOST_PYTHON_ENUM_AS_OBJECT(z, n, x) object(BOOST_PP_CAT(x,n))
# define BOOST_PP_LOCAL_MACRO(n) \
template <BOOST_PP_ENUM_PARAMS_Z(1, n, class T)> \
explicit array(BOOST_PP_ENUM_BINARY_PARAMS_Z(1, n, T, const& x)) \
: base(BOOST_PP_ENUM_1(n, BOOST_PYTHON_ENUM_AS_OBJECT, x)) \
{}
# define BOOST_PP_LOCAL_LIMITS (1, 7)
# include BOOST_PP_LOCAL_ITERATE()
# undef BOOST_PYTHON_AS_OBJECT
static BOOST_PYTHON_DECL void set_module_and_type(char const* package_name = 0, char const* type_attribute_name = 0);
static BOOST_PYTHON_DECL std::string get_module_name();
public: // implementation detail -- for internal use only
BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(array, base);
};
} // namespace boost::python::numeric
namespace converter
{
template <>
struct object_manager_traits< numeric::array >
: numeric::aux::array_object_manager_traits
{
BOOST_STATIC_CONSTANT(bool, is_specialized = true);
};
}
}} // namespace boost::python
#endif // NUMARRAY_DWA2002922_HPP

View File

@@ -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

View File

@@ -0,0 +1,84 @@
// (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:
//
#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:
//
#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
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#endif // CONFIG_NUMPY20170215_H_

View File

@@ -13,10 +13,10 @@
*/
#include <boost/python.hpp>
#include <boost/python/numpy/config.hpp>
#include <boost/python/numpy/numpy_object_mgr_traits.hpp>
#include <boost/mpl/for_each.hpp>
#include <boost/type_traits/add_pointer.hpp>
#include <boost/python/detail/type_traits.hpp>
namespace boost { namespace python { namespace numpy {
@@ -25,7 +25,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 +55,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 +69,7 @@ public:
};
bool equivalent(dtype const & a, dtype const & b);
BOOST_NUMPY_DECL bool equivalent(dtype const & a, dtype const & b);
namespace detail
{
@@ -89,7 +89,7 @@ struct builtin_dtype<T,true> {
};
template <>
struct builtin_dtype<bool,true> {
struct BOOST_NUMPY_DECL builtin_dtype<bool,true> {
static dtype get();
};

View File

@@ -15,6 +15,7 @@
*/
#include <boost/python.hpp>
#include <boost/python/numpy/config.hpp>
#ifdef BOOST_PYTHON_NUMPY_INTERNAL
#define NO_IMPORT_ARRAY
#define NO_IMPORT_UFUNC

View File

@@ -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

View File

@@ -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);

View File

@@ -13,9 +13,11 @@
#include <boost/python.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/python/detail/type_traits.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,
@@ -173,19 +176,19 @@ ndarray from_data_impl(void * data,
Container strides,
object const & owner,
bool writeable,
typename boost::enable_if< boost::is_integral<typename Container::value_type> >::type * enabled = NULL)
typename boost::enable_if< boost::python::detail::is_integral<typename Container::value_type> >::type * enabled = NULL)
{
std::vector<Py_intptr_t> shape_(shape.begin(),shape.end());
std::vector<Py_intptr_t> strides_(strides.begin(), strides.end());
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);
BOOST_NUMPY_DECL 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 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));
}

View File

@@ -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) \

View File

@@ -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:

Some files were not shown because too many files have changed in this diff Show More