Compare commits
21 Commits
svn-branch
...
svn-branch
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c58a615a5a | ||
|
|
4f6a37f80d | ||
|
|
338732793a | ||
|
|
8b0655ce94 | ||
|
|
36d24b9f8b | ||
|
|
35ff0adf2b | ||
|
|
115cde9c7f | ||
|
|
ef2a02c396 | ||
|
|
e3f6f01588 | ||
|
|
d7389277d3 | ||
|
|
8d2ca93e98 | ||
|
|
d47e3b2a15 | ||
|
|
27aa9382fc | ||
|
|
1a204046c7 | ||
|
|
3c98a72153 | ||
|
|
a4f028246a | ||
|
|
6ffeca641c | ||
|
|
22b65a1485 | ||
|
|
d45b9ea66b | ||
|
|
0373302165 | ||
|
|
ef53bedd0a |
@@ -1,66 +0,0 @@
|
||||
if (PYTHON_LIBRARIES)
|
||||
include_directories(${PYTHON_INCLUDE_PATH})
|
||||
|
||||
# Determine extra libraries we need to link against to build Python
|
||||
# extension modules.
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
|
||||
set(PYTHON_LIBRARIES ${PYTHON_LIBRARIES} "dl")
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(PYTHON_LIBRARIES ${PYTHON_LIBRARIES} "rt")
|
||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSD")
|
||||
set(PYTHON_LIBRARIES ${PYTHON_LIBRARIES} "pthread")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "DragonFly")
|
||||
# DragonFly is a variant of FreeBSD
|
||||
set(PYTHON_LIBRARIES ${PYTHON_LIBRARIES} "pthread")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "OSF")
|
||||
set(PYTHON_LIBRARIES ${PYTHON_LIBRARIES} "pthread" "dl")
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(PYTHON_LIBRARIES ${PYTHON_LIBRARIES} "rt")
|
||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "QNX")
|
||||
# No options necessary for QNX
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
# No options necessary for Mac OS X
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "HP-UX")
|
||||
set(PYTHON_LIBRARIES ${PYTHON_LIBRARIES} "rt")
|
||||
elseif(UNIX)
|
||||
# Assume -pthread and -ldl on all other variants
|
||||
set(PYTHON_LIBRARIES ${PYTHON_LIBRARIES} "pthread" "dl")
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(PYTHON_LIBRARIES ${PYTHON_LIBRARIES} "util")
|
||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
endif(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
|
||||
|
||||
################################################################################
|
||||
#-- Macro for building Boost.Python extension modules
|
||||
macro(boost_python_extension MODULE_NAME)
|
||||
parse_arguments(BPL_EXT
|
||||
""
|
||||
""
|
||||
${ARGN})
|
||||
|
||||
boost_add_single_library(
|
||||
${MODULE_NAME}
|
||||
${BPL_EXT_DEFAULT_ARGS}
|
||||
MODULE
|
||||
LINK_LIBS ${PYTHON_LIBRARIES}
|
||||
DEPENDS boost_python
|
||||
SHARED
|
||||
)
|
||||
|
||||
endmacro(boost_python_extension)
|
||||
#--
|
||||
################################################################################
|
||||
|
||||
|
||||
boost_library_project(
|
||||
Python
|
||||
SRCDIRS src
|
||||
TESTDIRS test
|
||||
HEADERS python.hpp python
|
||||
MODULARIZED
|
||||
DESCRIPTION "A framework for interfacing Python and C++. It allows you to quickly and seamlessly expose C++ classes functions and objects to Python, and vice-versa, using no special tools -- just your C++ compiler."
|
||||
AUTHORS "David Abrahams <dave -at- boostpro.com>"
|
||||
)
|
||||
endif (PYTHON_LIBRARIES)
|
||||
148
build/Jamfile.v2
@@ -4,6 +4,7 @@
|
||||
|
||||
import os ;
|
||||
import modules ;
|
||||
import feature ;
|
||||
|
||||
import python ;
|
||||
|
||||
@@ -22,6 +23,22 @@ if ! [ python.configured ] && ! ( --without-python in [ modules.peek : ARGV ] )
|
||||
}
|
||||
}
|
||||
|
||||
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 ] ;
|
||||
|
||||
project boost/python
|
||||
: source-location ../src
|
||||
;
|
||||
@@ -29,66 +46,79 @@ project boost/python
|
||||
rule cond ( test ? : yes * : no * ) { if $(test) { return $(yes) ; } else { return $(no) ; } }
|
||||
rule unless ( test ? : yes * : no * ) { if ! $(test) { return $(yes) ; } else { return $(no) ; } }
|
||||
|
||||
lib boost_python
|
||||
: # sources
|
||||
numeric.cpp
|
||||
list.cpp
|
||||
long.cpp
|
||||
dict.cpp
|
||||
tuple.cpp
|
||||
str.cpp
|
||||
slice.cpp
|
||||
rule lib_boost_python ( is-py3 ? )
|
||||
{
|
||||
|
||||
converter/from_python.cpp
|
||||
converter/registry.cpp
|
||||
converter/type_id.cpp
|
||||
object/enum.cpp
|
||||
object/class.cpp
|
||||
object/function.cpp
|
||||
object/inheritance.cpp
|
||||
object/life_support.cpp
|
||||
object/pickle_support.cpp
|
||||
errors.cpp
|
||||
module.cpp
|
||||
converter/builtin_converters.cpp
|
||||
converter/arg_to_python_base.cpp
|
||||
object/iterator.cpp
|
||||
object/stl_iterator.cpp
|
||||
object_protocol.cpp
|
||||
object_operators.cpp
|
||||
wrapper.cpp
|
||||
import.cpp
|
||||
exec.cpp
|
||||
object/function_doc_signature.cpp
|
||||
: # requirements
|
||||
<link>static:<define>BOOST_PYTHON_STATIC_LIB
|
||||
<define>BOOST_PYTHON_SOURCE
|
||||
|
||||
# On Windows, all code using Python has to link to the Python
|
||||
# import library.
|
||||
#
|
||||
# On *nix we never link libboost_python to libpython. When
|
||||
# extending Python, all Python symbols are provided by the
|
||||
# Python interpreter executable. When embedding Python, the
|
||||
# client executable is expected to explicitly link to
|
||||
# /python//python (the target representing libpython) itself.
|
||||
#
|
||||
# python_for_extensions is a target defined by Boost.Build to
|
||||
# provide the Python include paths, and on Windows, the Python
|
||||
# import library, as usage requirements.
|
||||
[ cond [ python.configured ] : <library>/python//python_for_extensions ]
|
||||
|
||||
# we prevent building when there is no python available
|
||||
# as it's not possible anyway, and to cause dependents to
|
||||
# fail to build
|
||||
[ unless [ python.configured ] : <build>no ]
|
||||
lib [ cond $(is-py3) : boost_python3 : boost_python ]
|
||||
: # sources
|
||||
numeric.cpp
|
||||
list.cpp
|
||||
long.cpp
|
||||
dict.cpp
|
||||
tuple.cpp
|
||||
str.cpp
|
||||
slice.cpp
|
||||
|
||||
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
|
||||
: # default build
|
||||
<link>shared
|
||||
: # usage requirements
|
||||
<link>static:<define>BOOST_PYTHON_STATIC_LIB
|
||||
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
|
||||
;
|
||||
converter/from_python.cpp
|
||||
converter/registry.cpp
|
||||
converter/type_id.cpp
|
||||
object/enum.cpp
|
||||
object/class.cpp
|
||||
object/function.cpp
|
||||
object/inheritance.cpp
|
||||
object/life_support.cpp
|
||||
object/pickle_support.cpp
|
||||
errors.cpp
|
||||
module.cpp
|
||||
converter/builtin_converters.cpp
|
||||
converter/arg_to_python_base.cpp
|
||||
object/iterator.cpp
|
||||
object/stl_iterator.cpp
|
||||
object_protocol.cpp
|
||||
object_operators.cpp
|
||||
wrapper.cpp
|
||||
import.cpp
|
||||
exec.cpp
|
||||
object/function_doc_signature.cpp
|
||||
: # requirements
|
||||
<link>static:<define>BOOST_PYTHON_STATIC_LIB
|
||||
<define>BOOST_PYTHON_SOURCE
|
||||
|
||||
# On Windows, all code using Python has to link to the Python
|
||||
# import library.
|
||||
#
|
||||
# On *nix we never link libboost_python to libpython. When
|
||||
# extending Python, all Python symbols are provided by the
|
||||
# Python interpreter executable. When embedding Python, the
|
||||
# client executable is expected to explicitly link to
|
||||
# /python//python (the target representing libpython) itself.
|
||||
#
|
||||
# python_for_extensions is a target defined by Boost.Build to
|
||||
# provide the Python include paths, and on Windows, the Python
|
||||
# import library, as usage requirements.
|
||||
[ cond [ python.configured ] : <library>/python//python_for_extensions ]
|
||||
|
||||
# we prevent building when there is no python available
|
||||
# as it's not possible anyway, and to cause dependents to
|
||||
# fail to build
|
||||
[ unless [ python.configured ] : <build>no ]
|
||||
|
||||
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
|
||||
[ cond $(is-py3) : <python>$(py3-version) ]
|
||||
: # 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 ;
|
||||
|
||||
if $(py3-version)
|
||||
{
|
||||
lib_boost_python yes ;
|
||||
boost-install boost_python3 ;
|
||||
}
|
||||
|
||||
0
doc/PyConDC_2003/bpl.html
Executable file → Normal file
0
doc/PyConDC_2003/bpl.pdf
Executable file → Normal file
0
doc/PyConDC_2003/python_cpp_mix.jpg
Executable file → Normal file
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
0
doc/PyConDC_2003/python_cpp_mix.png
Executable file → Normal file
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
0
doc/internals.html
Executable file → Normal file
0
doc/internals.rst
Executable file → Normal file
@@ -32,7 +32,43 @@
|
||||
<hr>
|
||||
|
||||
<dl class="page-index">
|
||||
|
||||
<dt>Current SVN</dt>
|
||||
<dd>
|
||||
<ul>
|
||||
<li>Python 3 support:</li>
|
||||
<ul>
|
||||
<li>All the current Boost.Python test cases passed. Extension modules using
|
||||
Boost.Python expected to support Python 3 smoothly.</li>
|
||||
<li>Introduced <code>object.contains</code> where <code>x.contains(y)</code>
|
||||
is equivalent to Python code <code>y in x</code>.
|
||||
Now <code>dict.has_key</code> is just a wrapper of <code>object.contains</code>.
|
||||
</li>
|
||||
<li>When building against Python 3, <code>str.decode</code> will be removed.</li>
|
||||
<li>When building against Python 3, the original signature of <code>list.sort</code>, which is:
|
||||
<pre>void sort(object_cref cmpfunc);</pre>
|
||||
will change to:
|
||||
<pre>void sort(args_proxy const &args, kwds_proxy const &kwds);</pre>
|
||||
|
||||
This is because in Python 3 <code>list.sort</code> requires all its arguments be keyword arguments.
|
||||
So you should call it like this:
|
||||
<pre>x.sort(*tuple(), **dict(make_tuple(make_tuple("reverse", true))));</pre>
|
||||
|
||||
</li>
|
||||
<li>According to <a href="http://www.python.org/dev/peps/pep-3123/">PEP 3123</a>,
|
||||
when building Boost.Python against Python older than 2.6, the following macros will
|
||||
be defined in Boost.Python header:
|
||||
<pre>
|
||||
# define Py_TYPE(o) (((PyObject*)(o))->ob_type)
|
||||
# define Py_REFCNT(o) (((PyObject*)(o))->ob_refcnt)
|
||||
# define Py_SIZE(o) (((PyVarObject*)(o))->ob_size)</pre>
|
||||
So extension writers can use these macro directly, to make code clean and compatible with Python 3.
|
||||
</li>
|
||||
</ul>
|
||||
</ul>
|
||||
</dd>
|
||||
|
||||
<dt>1.39.0 Release</dt>
|
||||
|
||||
<dd>
|
||||
<ul>
|
||||
|
||||
0
doc/tutorial/doc/html/images/alert.png
Executable file → Normal file
|
Before Width: | Height: | Size: 603 B After Width: | Height: | Size: 603 B |
0
doc/tutorial/doc/html/images/home.png
Executable file → Normal file
|
Before Width: | Height: | Size: 358 B After Width: | Height: | Size: 358 B |
0
doc/tutorial/doc/html/images/next.png
Executable file → Normal file
|
Before Width: | Height: | Size: 336 B After Width: | Height: | Size: 336 B |
0
doc/tutorial/doc/html/images/note.png
Executable file → Normal file
|
Before Width: | Height: | Size: 658 B After Width: | Height: | Size: 658 B |
0
doc/tutorial/doc/html/images/prev.png
Executable file → Normal file
|
Before Width: | Height: | Size: 334 B After Width: | Height: | Size: 334 B |
0
doc/tutorial/doc/html/images/tip.png
Executable file → Normal file
|
Before Width: | Height: | Size: 640 B After Width: | Height: | Size: 640 B |
0
doc/tutorial/doc/html/images/up.png
Executable file → Normal file
|
Before Width: | Height: | Size: 370 B After Width: | Height: | Size: 370 B |
@@ -186,10 +186,6 @@ And so on... Finally:
|
||||
Or something similar. If all is well, you should now have built the DLLs and
|
||||
run the Python program.
|
||||
|
||||
[note Starting from Boost 1.35, bjam erases the generated executables
|
||||
(e.g. pyd file) after the test has concluded to conserve disk space.
|
||||
To keep bjam from doing that, pass --preserve-test-targets to bjam.]
|
||||
|
||||
[:[*There you go... Have fun!]]
|
||||
|
||||
[endsect]
|
||||
|
||||
0
doc/v2/instance_holder.html
Executable file → Normal file
0
doc/v2/lvalue_from_pytype.html
Executable file → Normal file
0
doc/v2/operators.html
Executable file → Normal file
0
doc/v2/raw_function.html
Executable file → Normal file
0
doc/v2/return_arg.html
Executable file → Normal file
0
doc/v2/stl_iterator.html
Executable file → Normal file
0
doc/v2/type_id.html
Executable file → Normal file
0
doc/v2/wrapper.html
Executable file → Normal file
0
example/Jamroot
Executable file → Normal file
0
example/boost-build.jam
Executable file → Normal file
0
example/quickstart/Jamroot
Executable file → Normal file
9
example/tutorial/Jamroot
Executable file → Normal file
@@ -2,6 +2,15 @@
|
||||
# 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
|
||||
|
||||
0
include/boost/python/arg_from_python.hpp
Executable file → Normal file
0
include/boost/python/base_type_traits.hpp
Executable file → Normal file
0
include/boost/python/borrowed.hpp
Executable file → Normal file
0
include/boost/python/cast.hpp
Executable file → Normal file
0
include/boost/python/converter/arg_from_python.hpp
Executable file → Normal file
0
include/boost/python/converter/arg_to_python.hpp
Executable file → Normal file
0
include/boost/python/converter/arg_to_python_base.hpp
Executable file → Normal file
@@ -90,6 +90,14 @@ namespace detail
|
||||
BOOST_PYTHON_ARG_TO_PYTHON_BY_VALUE(T,expr)
|
||||
|
||||
// Specialize converters for signed and unsigned T to Python Int
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
|
||||
# define BOOST_PYTHON_TO_INT(T) \
|
||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(signed T, ::PyLong_FromLong(x), &PyLong_Type) \
|
||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(unsigned T, ::PyLong_FromUnsignedLong(x), &PyLong_Type)
|
||||
|
||||
#else
|
||||
|
||||
# define BOOST_PYTHON_TO_INT(T) \
|
||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(signed T, ::PyInt_FromLong(x), &PyInt_Type) \
|
||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE( \
|
||||
@@ -98,6 +106,7 @@ namespace detail
|
||||
(std::numeric_limits<long>::max)()) \
|
||||
? ::PyLong_FromUnsignedLong(x) \
|
||||
: ::PyInt_FromLong(x), &PyInt_Type)
|
||||
#endif
|
||||
|
||||
// Bool is not signed.
|
||||
#if PY_VERSION_HEX >= 0x02030000
|
||||
@@ -116,17 +125,24 @@ BOOST_PYTHON_TO_INT(long)
|
||||
// using Python's macro instead of Boost's - we don't seem to get the
|
||||
// config right all the time.
|
||||
# ifdef HAVE_LONG_LONG
|
||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(signed BOOST_PYTHON_LONG_LONG, ::PyLong_FromLongLong(x), &PyInt_Type)
|
||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(unsigned BOOST_PYTHON_LONG_LONG, ::PyLong_FromUnsignedLongLong(x), &PyInt_Type)
|
||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(signed BOOST_PYTHON_LONG_LONG, ::PyLong_FromLongLong(x), &PyLong_Type)
|
||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(unsigned BOOST_PYTHON_LONG_LONG, ::PyLong_FromUnsignedLongLong(x), &PyLong_Type)
|
||||
# endif
|
||||
|
||||
# undef BOOST_TO_PYTHON_INT
|
||||
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(char, converter::do_return_to_python(x), &PyUnicode_Type)
|
||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(char const*, converter::do_return_to_python(x), &PyUnicode_Type)
|
||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::string, ::PyUnicode_FromStringAndSize(x.data(),implicit_cast<ssize_t>(x.size())), &PyUnicode_Type)
|
||||
#else
|
||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(char, converter::do_return_to_python(x), &PyString_Type)
|
||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(char const*, converter::do_return_to_python(x), &PyString_Type)
|
||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::string, ::PyString_FromStringAndSize(x.data(),implicit_cast<ssize_t>(x.size())), &PyString_Type)
|
||||
#endif
|
||||
|
||||
#if defined(Py_USING_UNICODE) && !defined(BOOST_NO_STD_WSTRING)
|
||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::wstring, ::PyUnicode_FromWideChar(x.data(),implicit_cast<ssize_t>(x.size())), &PyString_Type)
|
||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::wstring, ::PyUnicode_FromWideChar(x.data(),implicit_cast<ssize_t>(x.size())), &PyUnicode_Type)
|
||||
# endif
|
||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(float, ::PyFloat_FromDouble(x), &PyFloat_Type)
|
||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(double, ::PyFloat_FromDouble(x), &PyFloat_Type)
|
||||
|
||||
0
include/boost/python/converter/context_result_converter.hpp
Executable file → Normal file
0
include/boost/python/converter/object_manager.hpp
Executable file → Normal file
@@ -34,7 +34,9 @@ struct pyobject_traits<PyObject>
|
||||
// This is not an exhaustive list; should be expanded.
|
||||
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Type);
|
||||
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(List);
|
||||
#if PY_VERSION_HEX < 0x03000000
|
||||
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Int);
|
||||
#endif
|
||||
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Long);
|
||||
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Dict);
|
||||
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Tuple);
|
||||
|
||||
0
include/boost/python/converter/pytype_function.hpp
Executable file → Normal file
0
include/boost/python/converter/return_from_python.hpp
Executable file → Normal file
0
include/boost/python/def_visitor.hpp
Executable file → Normal file
0
include/boost/python/detail/borrowed_ptr.hpp
Executable file → Normal file
0
include/boost/python/detail/convertible.hpp
Executable file → Normal file
0
include/boost/python/detail/copy_ctor_mutates_rhs.hpp
Executable file → Normal file
4
include/boost/python/detail/decorated_type_id.hpp
Executable file → Normal file
@@ -55,8 +55,8 @@ inline decorated_type_info::decorated_type_info(type_info base_t, decoration dec
|
||||
inline bool decorated_type_info::operator<(decorated_type_info const& rhs) const
|
||||
{
|
||||
return m_decoration < rhs.m_decoration
|
||||
|| m_decoration == rhs.m_decoration
|
||||
&& m_base_type < rhs.m_base_type;
|
||||
|| (m_decoration == rhs.m_decoration
|
||||
&& m_base_type < rhs.m_base_type);
|
||||
}
|
||||
|
||||
inline bool decorated_type_info::operator==(decorated_type_info const& rhs) const
|
||||
|
||||
0
include/boost/python/detail/def_helper_fwd.hpp
Executable file → Normal file
0
include/boost/python/detail/enable_if.hpp
Executable file → Normal file
0
include/boost/python/detail/force_instantiate.hpp
Executable file → Normal file
0
include/boost/python/detail/is_shared_ptr.hpp
Executable file → Normal file
0
include/boost/python/detail/is_wrapper.hpp
Executable file → Normal file
0
include/boost/python/detail/nullary_function_adaptor.hpp
Executable file → Normal file
4
include/boost/python/detail/operator_id.hpp
Executable file → Normal file
@@ -47,7 +47,11 @@ enum operator_id
|
||||
op_ixor,
|
||||
op_ior,
|
||||
op_complex,
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
op_bool,
|
||||
#else
|
||||
op_nonzero,
|
||||
#endif
|
||||
op_repr
|
||||
};
|
||||
|
||||
|
||||
0
include/boost/python/detail/prefix.hpp
Executable file → Normal file
0
include/boost/python/detail/python_type.hpp
Executable file → Normal file
0
include/boost/python/detail/sfinae.hpp
Executable file → Normal file
@@ -2,13 +2,15 @@
|
||||
// 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 TRANSLATE_EXCEPTION_DWA2002810_HPP
|
||||
# define TRANSLATE_EXCEPTION_DWA2002810_HPP
|
||||
#ifndef TRANSLATE_EXCEPTION_TDS20091020_HPP
|
||||
# define TRANSLATE_EXCEPTION_TDS20091020_HPP
|
||||
|
||||
# include <boost/python/detail/exception_handler.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>
|
||||
|
||||
|
||||
0
include/boost/python/detail/unwind_type.hpp
Executable file → Normal file
0
include/boost/python/detail/unwrap_type_id.hpp
Executable file → Normal file
0
include/boost/python/detail/unwrap_wrapper.hpp
Executable file → Normal file
0
include/boost/python/detail/value_arg.hpp
Executable file → Normal file
@@ -175,6 +175,19 @@ typedef int pid_t;
|
||||
( (op)->ob_type = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
|
||||
#endif
|
||||
|
||||
// Define Python 3 macros for Python 2.x
|
||||
#if PY_VERSION_HEX < 0x02060000
|
||||
|
||||
# define Py_TYPE(o) (((PyObject*)(o))->ob_type)
|
||||
# define Py_REFCNT(o) (((PyObject*)(o))->ob_refcnt)
|
||||
# define Py_SIZE(o) (((PyVarObject*)(o))->ob_size)
|
||||
|
||||
# define PyVarObject_HEAD_INIT(type, size) \
|
||||
PyObject_HEAD_INIT(type) size,
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __MWERKS__
|
||||
# pragma warn_possunwant off
|
||||
#elif _MSC_VER
|
||||
|
||||
0
include/boost/python/detail/wrapper_base.hpp
Executable file → Normal file
0
include/boost/python/docstring_options.hpp
Executable file → Normal file
@@ -79,7 +79,11 @@ void* enum_<T>::convertible_from_python(PyObject* obj)
|
||||
template <class T>
|
||||
void enum_<T>::construct(PyObject* obj, converter::rvalue_from_python_stage1_data* data)
|
||||
{
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
T x = static_cast<T>(PyLong_AS_LONG(obj));
|
||||
#else
|
||||
T x = static_cast<T>(PyInt_AS_LONG(obj));
|
||||
#endif
|
||||
void* const storage = ((converter::rvalue_from_python_storage<T>*)data)->storage.bytes;
|
||||
new (storage) T(x);
|
||||
data->convertible = storage;
|
||||
|
||||
@@ -20,6 +20,13 @@ object
|
||||
BOOST_PYTHON_DECL
|
||||
eval(str 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.
|
||||
object
|
||||
BOOST_PYTHON_DECL
|
||||
exec_statement(str 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.
|
||||
|
||||
0
include/boost/python/handle.hpp
Executable file → Normal file
0
include/boost/python/handle_fwd.hpp
Executable file → Normal file
0
include/boost/python/instance_holder.hpp
Executable file → Normal file
@@ -19,7 +19,7 @@ namespace detail
|
||||
{
|
||||
void append(object_cref); // append object to end
|
||||
|
||||
long count(object_cref value) const; // return number of occurrences of value
|
||||
ssize_t count(object_cref value) const; // return number of occurrences of value
|
||||
|
||||
void extend(object_cref sequence); // extend list by appending sequence elements
|
||||
|
||||
@@ -37,8 +37,12 @@ namespace detail
|
||||
void reverse(); // reverse *IN PLACE*
|
||||
|
||||
void sort(); // sort *IN PLACE*; if given, cmpfunc(x, y) -> -1, 0, 1
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
void sort(args_proxy const &args,
|
||||
kwds_proxy const &kwds);
|
||||
#else
|
||||
void sort(object_cref cmpfunc);
|
||||
|
||||
#endif
|
||||
|
||||
protected:
|
||||
list_base(); // new list
|
||||
@@ -113,13 +117,15 @@ class list : public detail::list_base
|
||||
base::remove(object(value));
|
||||
}
|
||||
|
||||
#if PY_VERSION_HEX <= 0x03000000
|
||||
void sort() { base::sort(); }
|
||||
|
||||
|
||||
template <class T>
|
||||
void sort(T const& value)
|
||||
{
|
||||
base::sort(object(value));
|
||||
}
|
||||
#endif
|
||||
|
||||
public: // implementation detail -- for internal use only
|
||||
BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(list, base)
|
||||
|
||||
4
include/boost/python/lvalue_from_pytype.hpp
Executable file → Normal file
@@ -63,7 +63,7 @@ struct extract_member
|
||||
{
|
||||
static MemberType& execute(InstanceType& c)
|
||||
{
|
||||
(void)c.ob_type; // static assertion
|
||||
(void)Py_TYPE(&c); // static assertion
|
||||
return c.*member;
|
||||
}
|
||||
};
|
||||
@@ -75,7 +75,7 @@ struct extract_identity
|
||||
{
|
||||
static InstanceType& execute(InstanceType& c)
|
||||
{
|
||||
(void)c.ob_type; // static assertion
|
||||
(void)Py_TYPE(&c); // static assertion
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,40 +11,49 @@
|
||||
|
||||
namespace boost { namespace python { namespace detail {
|
||||
|
||||
BOOST_PYTHON_DECL void init_module(char const* name, void(*)());
|
||||
BOOST_PYTHON_DECL PyObject* init_module(char const* name, void(*)());
|
||||
|
||||
}}}
|
||||
|
||||
# if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(BOOST_PYTHON_STATIC_MODULE)
|
||||
# if PY_VERSION_HEX >= 0x03000000
|
||||
|
||||
# define BOOST_PYTHON_MODULE_INIT(name) \
|
||||
void init_module_##name(); \
|
||||
extern "C" __declspec(dllexport) void init##name() \
|
||||
# define _BOOST_PYTHON_MODULE_INIT(name) \
|
||||
PyObject* PyInit_##name() \
|
||||
{ \
|
||||
return boost::python::detail::init_module( \
|
||||
#name,&init_module_##name); \
|
||||
} \
|
||||
void init_module_##name()
|
||||
|
||||
# else
|
||||
|
||||
# define _BOOST_PYTHON_MODULE_INIT(name) \
|
||||
void init##name() \
|
||||
{ \
|
||||
boost::python::detail::init_module( \
|
||||
#name,&init_module_##name); \
|
||||
} \
|
||||
void init_module_##name()
|
||||
|
||||
# endif
|
||||
|
||||
# if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(BOOST_PYTHON_STATIC_MODULE)
|
||||
|
||||
# define BOOST_PYTHON_MODULE_INIT(name) \
|
||||
void init_module_##name(); \
|
||||
extern "C" __declspec(dllexport) _BOOST_PYTHON_MODULE_INIT(name)
|
||||
|
||||
# elif BOOST_PYTHON_USE_GCC_SYMBOL_VISIBILITY
|
||||
|
||||
# define BOOST_PYTHON_MODULE_INIT(name) \
|
||||
void init_module_##name(); \
|
||||
extern "C" __attribute__ ((visibility("default"))) void init##name() \
|
||||
{ \
|
||||
boost::python::detail::init_module(#name, &init_module_##name); \
|
||||
} \
|
||||
void init_module_##name()
|
||||
extern "C" __attribute__ ((visibility("default"))) _BOOST_PYTHON_MODULE_INIT(name)
|
||||
|
||||
# else
|
||||
|
||||
# define BOOST_PYTHON_MODULE_INIT(name) \
|
||||
void init_module_##name(); \
|
||||
extern "C" void init##name() \
|
||||
{ \
|
||||
boost::python::detail::init_module(#name, &init_module_##name); \
|
||||
} \
|
||||
void init_module_##name()
|
||||
extern "C" _BOOST_PYTHON_MODULE_INIT(name)
|
||||
|
||||
# endif
|
||||
|
||||
|
||||
0
include/boost/python/object.hpp
Executable file → Normal file
0
include/boost/python/object/class_metadata.hpp
Executable file → Normal file
0
include/boost/python/object/function_doc_signature.hpp
Executable file → Normal file
0
include/boost/python/object/inheritance_query.hpp
Executable file → Normal file
@@ -129,7 +129,11 @@ namespace detail
|
||||
return class_<range_>(name, no_init)
|
||||
.def("__iter__", identity_function())
|
||||
.def(
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
"__next__"
|
||||
#else
|
||||
"next"
|
||||
#endif
|
||||
, make_function(
|
||||
next_fn()
|
||||
, policies
|
||||
|
||||
@@ -43,7 +43,7 @@ struct make_instance_impl
|
||||
|
||||
// Note the position of the internally-stored Holder,
|
||||
// for the sake of destruction
|
||||
instance->ob_size = offsetof(instance_t, storage);
|
||||
Py_SIZE(instance) = offsetof(instance_t, storage);
|
||||
|
||||
// Release ownership of the python object
|
||||
protect.cancel();
|
||||
|
||||
0
include/boost/python/object/stl_iterator_core.hpp
Executable file → Normal file
@@ -126,6 +126,10 @@ namespace api
|
||||
const_object_objattribute attr(object const&) const;
|
||||
object_objattribute attr(object const&);
|
||||
|
||||
// Wrap 'in' operator (aka. __contains__)
|
||||
template <class T>
|
||||
object contains(T const& key) const;
|
||||
|
||||
// item access
|
||||
//
|
||||
const_object_item operator[](object_cref) const;
|
||||
@@ -483,6 +487,15 @@ object api::object_operators<U>::operator()(detail::args_proxy const &args,
|
||||
|
||||
}
|
||||
|
||||
|
||||
template <typename U>
|
||||
template <class T>
|
||||
object api::object_operators<U>::contains(T const& key) const
|
||||
{
|
||||
return this->attr("__contains__")(object(key));
|
||||
}
|
||||
|
||||
|
||||
inline object::object()
|
||||
: object_base(python::incref(Py_None))
|
||||
{}
|
||||
|
||||
0
include/boost/python/object_items.hpp
Executable file → Normal file
@@ -60,7 +60,9 @@ inline
|
||||
object_operators<U>::operator bool_type() const
|
||||
{
|
||||
object_cref2 x = *static_cast<U const*>(this);
|
||||
return PyObject_IsTrue(x.ptr()) ? &object::ptr : 0;
|
||||
int is_true = PyObject_IsTrue(x.ptr());
|
||||
if (is_true < 0) throw_error_already_set();
|
||||
return is_true ? &object::ptr : 0;
|
||||
}
|
||||
|
||||
template <class U>
|
||||
@@ -68,7 +70,9 @@ inline bool
|
||||
object_operators<U>::operator!() const
|
||||
{
|
||||
object_cref2 x = *static_cast<U const*>(this);
|
||||
return !PyObject_IsTrue(x.ptr());
|
||||
int is_true = PyObject_IsTrue(x.ptr());
|
||||
if (is_true < 0) throw_error_already_set();
|
||||
return !is_true;
|
||||
}
|
||||
|
||||
# define BOOST_PYTHON_COMPARE_OP(op, opid) \
|
||||
|
||||
0
include/boost/python/object_protocol.hpp
Executable file → Normal file
0
include/boost/python/object_protocol_core.hpp
Executable file → Normal file
@@ -121,8 +121,7 @@ opaque<Pointee> opaque<Pointee>::instance;
|
||||
template <class Pointee>
|
||||
PyTypeObject opaque<Pointee>::type_object =
|
||||
{
|
||||
PyObject_HEAD_INIT(0)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
0,
|
||||
sizeof( BOOST_DEDUCED_TYPENAME opaque<Pointee>::python_instance ),
|
||||
0,
|
||||
|
||||
@@ -341,7 +341,11 @@ BOOST_PYTHON_UNARY_OPERATOR(neg, -, operator-)
|
||||
BOOST_PYTHON_UNARY_OPERATOR(pos, +, operator+)
|
||||
BOOST_PYTHON_UNARY_OPERATOR(abs, abs, abs)
|
||||
BOOST_PYTHON_UNARY_OPERATOR(invert, ~, operator~)
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
BOOST_PYTHON_UNARY_OPERATOR(bool, !!, operator!)
|
||||
#else
|
||||
BOOST_PYTHON_UNARY_OPERATOR(nonzero, !!, operator!)
|
||||
#endif
|
||||
BOOST_PYTHON_UNARY_OPERATOR(int, long, int_)
|
||||
BOOST_PYTHON_UNARY_OPERATOR(long, PyLong_FromLong, long_)
|
||||
BOOST_PYTHON_UNARY_OPERATOR(float, double, float_)
|
||||
|
||||
0
include/boost/python/other.hpp
Executable file → Normal file
0
include/boost/python/override.hpp
Executable file → Normal file
0
include/boost/python/proxy.hpp
Executable file → Normal file
0
include/boost/python/pure_virtual.hpp
Executable file → Normal file
0
include/boost/python/raw_function.hpp
Executable file → Normal file
0
include/boost/python/refcount.hpp
Executable file → Normal file
0
include/boost/python/return_arg.hpp
Executable file → Normal file
0
include/boost/python/self.hpp
Executable file → Normal file
0
include/boost/python/stl_iterator.hpp
Executable file → Normal file
@@ -37,10 +37,12 @@ namespace detail
|
||||
|
||||
long count(object_cref sub, object_cref start, object_cref end) const;
|
||||
|
||||
#if PY_VERSION_HEX < 0x03000000
|
||||
object decode() const;
|
||||
object decode(object_cref encoding) const;
|
||||
|
||||
object decode(object_cref encoding, object_cref errors) const;
|
||||
#endif
|
||||
|
||||
object encode() const;
|
||||
object encode(object_cref encoding) const;
|
||||
@@ -185,6 +187,7 @@ class str : public detail::str_base
|
||||
return base::count(object(sub), object(start));
|
||||
}
|
||||
|
||||
#if PY_VERSION_HEX < 0x03000000
|
||||
object decode() const { return base::decode(); }
|
||||
|
||||
template<class T>
|
||||
@@ -198,6 +201,7 @@ class str : public detail::str_base
|
||||
{
|
||||
return base::decode(object(encoding),object(errors));
|
||||
}
|
||||
#endif
|
||||
|
||||
object encode() const { return base::encode(); }
|
||||
|
||||
@@ -404,7 +408,11 @@ namespace converter
|
||||
{
|
||||
template <>
|
||||
struct object_manager_traits<str>
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
: pytype_object_manager_traits<&PyUnicode_Type,str>
|
||||
#else
|
||||
: pytype_object_manager_traits<&PyString_Type,str>
|
||||
#endif
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
0
include/boost/python/wrapper.hpp
Executable file → Normal file
@@ -1,3 +0,0 @@
|
||||
boost_module(python DEPENDS graph numeric)
|
||||
|
||||
# numeric is there because of boost/cast.hpp from libs/python/src/errors.cpp:11
|
||||
@@ -1,64 +0,0 @@
|
||||
if (PYTHON_DEBUG_LIBRARIES AND BUILD_BOOST_PYTHON)
|
||||
# We have detected that there might be Python debug libraries
|
||||
# available, but check for ourselves whether this is true by trying
|
||||
# to compile/link a program against them.
|
||||
set(CMAKE_REQUIRED_DEFINITIONS "-DBOOST_DEBUG_PYTHON -DPy_DEBUG")
|
||||
get_directory_property(CMAKE_REQUIRED_INCLUDES INCLUDE_DIRECTORIES)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${PYTHON_DEBUG_LIBRARIES})
|
||||
set(CHECK_PYDEBUG_SOURCE
|
||||
"#include <boost/python/object.hpp>")
|
||||
check_cxx_source_compiles(
|
||||
"#include <boost/python/object.hpp>
|
||||
void check(PyObject *obj) { Py_INCREF(obj); } int main() { }"
|
||||
PYDEBUG_CAN_BUILD)
|
||||
|
||||
# Setup an option to enable/disable building variants with Python
|
||||
# debugging. If we were able to link against the debug libraries,
|
||||
# default to ON; otherwise, default to OFF.
|
||||
option(BUILD_PYTHON_DEBUG
|
||||
"Build an additional Boost.Python library with Python debugging enabled"
|
||||
${PYDEBUG_CAN_BUILD})
|
||||
endif (PYTHON_DEBUG_LIBRARIES AND BUILD_BOOST_PYTHON)
|
||||
|
||||
# Always build the non-debug variants of the boost_python library
|
||||
set(BUILD_PYTHON_NODEBUG ON)
|
||||
|
||||
boost_add_library(boost_python
|
||||
numeric.cpp
|
||||
list.cpp
|
||||
long.cpp
|
||||
dict.cpp
|
||||
tuple.cpp
|
||||
str.cpp
|
||||
slice.cpp
|
||||
converter/from_python.cpp
|
||||
converter/registry.cpp
|
||||
converter/type_id.cpp
|
||||
object/enum.cpp
|
||||
object/class.cpp
|
||||
object/function.cpp
|
||||
object/inheritance.cpp
|
||||
object/life_support.cpp
|
||||
object/pickle_support.cpp
|
||||
errors.cpp
|
||||
module.cpp
|
||||
converter/builtin_converters.cpp
|
||||
converter/arg_to_python_base.cpp
|
||||
object/iterator.cpp
|
||||
object/stl_iterator.cpp
|
||||
object_protocol.cpp
|
||||
object_operators.cpp
|
||||
wrapper.cpp
|
||||
import.cpp
|
||||
exec.cpp
|
||||
object/function_doc_signature.cpp
|
||||
|
||||
STATIC_COMPILE_FLAGS "-DBOOST_PYTHON_SOURCE -DBOOST_PYTHON_STATIC_LIB"
|
||||
SHARED_COMPILE_FLAGS "-DBOOST_PYTHON_SOURCE"
|
||||
PYTHON_NODEBUG_LINK_LIBS "${PYTHON_LIBRARIES}"
|
||||
|
||||
# Support for Python debugging
|
||||
EXTRA_VARIANTS PYTHON_NODEBUG:PYTHON_DEBUG
|
||||
PYTHON_DEBUG_COMPILE_FLAGS "-DBOOST_DEBUG_PYTHON -DPy_DEBUG"
|
||||
PYTHON_DEBUG_LINK_LIBS "${PYTHON_DEBUG_LIBRARIES}"
|
||||
)
|
||||