Skip to content

Commit 65b3aad

Browse files
author
Ralf W. Grosse-Kunstleve
committed
merging current boost/python and libs/python from trunk into release branch
[SVN r63937]
1 parent e13ebcd commit 65b3aad

File tree

8 files changed

+63
-31
lines changed

8 files changed

+63
-31
lines changed

build/Jamfile.v2

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,20 @@ if ! [ python.configured ] && ! ( --without-python in [ modules.peek : ARGV ] )
1414
# Attempt default configuration of python
1515
import toolset : using ;
1616
using python ;
17-
18-
if ! [ python.configured ]
19-
{
20-
ECHO "WARNING: No python installation configured and autoconfiguration" ;
21-
ECHO " failed. See http://www.boost.org/libs/python/doc/building.html" ;
22-
ECHO " for configuration instructions or pass --without-python to" ;
23-
ECHO " suppress this message and silently skip all Boost.Python targets" ;
24-
}
17+
}
18+
19+
if [ python.configured ] || ( --without-python in [ modules.peek : ARGV ] )
20+
{
21+
alias config-warning ;
22+
}
23+
else
24+
{
25+
message config-warning
26+
: "warning: No python installation configured and autoconfiguration"
27+
: "note: failed. See http://www.boost.org/libs/python/doc/building.html"
28+
: "note: for configuration instructions or pass --without-python to"
29+
: "note: suppress this message and silently skip all Boost.Python targets"
30+
;
2531
}
2632

2733
rule find-py3-version
@@ -122,6 +128,7 @@ rule lib_boost_python ( is-py3 ? )
122128
# as it's not possible anyway, and to cause dependents to
123129
# fail to build
124130
[ unless [ python.configured ] : <build>no ]
131+
<dependency>config-warning
125132

126133
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
127134
[ cond $(is-py3) : <python>$(py3-version) ]

include/boost/python/converter/builtin_converters.hpp

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,30 @@ BOOST_PYTHON_TO_INT(short)
122122
BOOST_PYTHON_TO_INT(int)
123123
BOOST_PYTHON_TO_INT(long)
124124

125-
// using Python's macro instead of Boost's - we don't seem to get the
126-
// config right all the time.
127-
# ifdef HAVE_LONG_LONG
125+
# if defined(_MSC_VER) && defined(_WIN64)
126+
/* Under 64-bit Windows std::size_t is "unsigned long long". To avoid
127+
getting a Python long for each std::size_t the value is checked before
128+
the conversion. A std::size_t is converted to a simple Python int
129+
if possible; a Python long appears only if the value is too small or
130+
too large to fit into a simple int. */
131+
BOOST_PYTHON_TO_PYTHON_BY_VALUE(
132+
signed BOOST_PYTHON_LONG_LONG,
133+
( x < static_cast<signed BOOST_PYTHON_LONG_LONG>(
134+
(std::numeric_limits<long>::min)())
135+
|| x > static_cast<signed BOOST_PYTHON_LONG_LONG>(
136+
(std::numeric_limits<long>::max)()))
137+
? ::PyLong_FromLongLong(x)
138+
: ::PyInt_FromLong(static_cast<long>(x)), &PyInt_Type)
139+
BOOST_PYTHON_TO_PYTHON_BY_VALUE(
140+
unsigned BOOST_PYTHON_LONG_LONG,
141+
x > static_cast<unsigned BOOST_PYTHON_LONG_LONG>(
142+
(std::numeric_limits<long>::max)())
143+
? ::PyLong_FromUnsignedLongLong(x)
144+
: ::PyInt_FromLong(static_cast<long>(x)), &PyInt_Type)
145+
//
146+
# elif defined(HAVE_LONG_LONG) // using Python's macro instead of Boost's
147+
// - we don't seem to get the config right
148+
// all the time.
128149
BOOST_PYTHON_TO_PYTHON_BY_VALUE(signed BOOST_PYTHON_LONG_LONG, ::PyLong_FromLongLong(x), &PyLong_Type)
129150
BOOST_PYTHON_TO_PYTHON_BY_VALUE(unsigned BOOST_PYTHON_LONG_LONG, ::PyLong_FromUnsignedLongLong(x), &PyLong_Type)
130151
# endif

include/boost/python/converter/registry.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace registry
3030
BOOST_PYTHON_DECL void insert(to_python_function_t, type_info, PyTypeObject const* (*to_python_target_type)() = 0);
3131

3232
// Insert an lvalue from_python converter
33-
BOOST_PYTHON_DECL void insert(void* (*convert)(PyObject*), type_info, PyTypeObject const* (*expected_pytype)() = 0);
33+
BOOST_PYTHON_DECL void insert(convertible_function, type_info, PyTypeObject const* (*expected_pytype)() = 0);
3434

3535
// Insert an rvalue from_python converter
3636
BOOST_PYTHON_DECL void insert(

include/boost/python/exception_translator.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ template <class ExceptionType, class Translate>
1818
void register_exception_translator(Translate translate, boost::type<ExceptionType>* = 0)
1919
{
2020
detail::register_exception_handler(
21-
bind<bool>(detail::translate_exception<ExceptionType,Translate>(), _1, _2, translate)
21+
boost::bind<bool>(detail::translate_exception<ExceptionType,Translate>(), _1, _2, translate)
2222
);
2323
}
2424

include/boost/python/module_init.hpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# define MODULE_INIT_DWA20020722_HPP
77

88
# include <boost/python/detail/prefix.hpp>
9+
# include <boost/preprocessor/cat.hpp>
10+
# include <boost/preprocessor/stringize.hpp>
911

1012
# ifndef BOOST_PYTHON_MODULE_INIT
1113

@@ -18,41 +20,41 @@ BOOST_PYTHON_DECL PyObject* init_module(char const* name, void(*)());
1820
# if PY_VERSION_HEX >= 0x03000000
1921

2022
# define _BOOST_PYTHON_MODULE_INIT(name) \
21-
PyObject* PyInit_##name() \
23+
PyObject* BOOST_PP_CAT (PyInit_,name)() \
2224
{ \
2325
return boost::python::detail::init_module( \
24-
#name,&init_module_##name); \
26+
BOOST_PP_STRINGIZE(name),&BOOST_PP_CAT(init_module_,name)); \
2527
} \
26-
void init_module_##name()
28+
void BOOST_PP_CAT(init_module_,name)()
2729

2830
# else
2931

3032
# define _BOOST_PYTHON_MODULE_INIT(name) \
31-
void init##name() \
33+
void BOOST_PP_CAT(init,name)() \
3234
{ \
3335
boost::python::detail::init_module( \
34-
#name,&init_module_##name); \
36+
BOOST_PP_STRINGIZE(name),&BOOST_PP_CAT(init_module_,name)); \
3537
} \
36-
void init_module_##name()
38+
void BOOST_PP_CAT(init_module_,name)()
3739

3840
# endif
3941

4042
# if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(BOOST_PYTHON_STATIC_MODULE)
4143

4244
# define BOOST_PYTHON_MODULE_INIT(name) \
43-
void init_module_##name(); \
45+
void BOOST_PP_CAT(init_module_,name)(); \
4446
extern "C" __declspec(dllexport) _BOOST_PYTHON_MODULE_INIT(name)
4547

4648
# elif BOOST_PYTHON_USE_GCC_SYMBOL_VISIBILITY
4749

4850
# define BOOST_PYTHON_MODULE_INIT(name) \
49-
void init_module_##name(); \
51+
void BOOST_PP_CAT(init_module_,name)(); \
5052
extern "C" __attribute__ ((visibility("default"))) _BOOST_PYTHON_MODULE_INIT(name)
5153

5254
# else
5355

5456
# define BOOST_PYTHON_MODULE_INIT(name) \
55-
void init_module_##name(); \
57+
void BOOST_PP_CAT(init_module_,name)(); \
5658
extern "C" _BOOST_PYTHON_MODULE_INIT(name)
5759

5860
# endif

include/boost/python/object/make_instance.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
# include <boost/python/converter/registered.hpp>
1111
# include <boost/python/detail/decref_guard.hpp>
1212
# include <boost/python/detail/none.hpp>
13-
# include <boost/type_traits/is_class.hpp>
1413
# include <boost/type_traits/is_union.hpp>
15-
# include <boost/mpl/assert.hpp>
16-
# include <boost/mpl/or.hpp>
1714

1815
namespace boost { namespace python { namespace objects {
1916

src/converter/registry.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ namespace registry
243243
}
244244

245245
// Insert an rvalue from_python converter
246-
void insert(void* (*convertible)(PyObject*)
246+
void insert(convertible_function convertible
247247
, constructor_function construct
248248
, type_info key
249249
, PyTypeObject const* (*exp_pytype)())
@@ -261,7 +261,7 @@ namespace registry
261261
}
262262

263263
// Insert an rvalue from_python converter
264-
void push_back(void* (*convertible)(PyObject*)
264+
void push_back(convertible_function convertible
265265
, constructor_function construct
266266
, type_info key
267267
, PyTypeObject const* (*exp_pytype)())

test/Jamfile.v2

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ rule py-compile-fail ( sources * )
3737
return [ compile-fail $(sources) /boost/python//boost_python ] ;
3838
}
3939

40+
rule require-windows ( properties * )
41+
{
42+
if ! <target-os>windows in $(properties)
43+
{
44+
return <build>no ;
45+
}
46+
}
4047

4148
test-suite python
4249
:
@@ -184,10 +191,8 @@ bpl-test crossmod_opaque
184191
# bpl-test bienstman5 ;
185192
# }
186193

187-
# XXX disabled on release branch only,
188-
# XXX to avoid failures on platforms other than Windows
189-
# [ bpl-test calling_conventions ]
190-
# [ bpl-test calling_conventions_mf ]
194+
[ bpl-test calling_conventions : : <conditional>@require-windows ]
195+
[ bpl-test calling_conventions_mf : : <conditional>@require-windows ]
191196

192197
# --- unit tests of library components ---
193198

0 commit comments

Comments
 (0)