mirror of
https://github.com/boostorg/python.git
synced 2026-02-02 21:12:15 +00:00
Attempted fix for long long handling
[SVN r14410]
This commit is contained in:
@@ -90,10 +90,12 @@ BOOST_PYTHON_TO_INT(char)
|
||||
BOOST_PYTHON_TO_INT(short)
|
||||
BOOST_PYTHON_TO_INT(int)
|
||||
BOOST_PYTHON_TO_INT(long)
|
||||
|
||||
# ifdef BOOST_HAS_LONG_LONG
|
||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(signed long long, PyLong_FromLongLong(x))
|
||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(unsigned long long, PyLong_FromUnsignedLongLong(x))
|
||||
|
||||
// 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 LONG_LONG, PyLong_FromLongLong(x))
|
||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(unsigned LONG_LONG, PyLong_FromUnsignedLongLong(x))
|
||||
# endif
|
||||
|
||||
# undef BOOST_TO_PYTHON_INT
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#ifndef TYPE_ID_DWA2002517_HPP
|
||||
# define TYPE_ID_DWA2002517_HPP
|
||||
|
||||
# include <boost/python/detail/wrap_python.hpp>
|
||||
# include <boost/python/detail/config.hpp>
|
||||
# include <boost/python/detail/msvc_typeinfo.hpp>
|
||||
# include <boost/operators.hpp>
|
||||
@@ -78,7 +79,9 @@ inline type_info type_id<T>(boost::type<T>*) \
|
||||
BOOST_PYTHON_SIGNED_INTEGRAL_TYPE_ID(short)
|
||||
BOOST_PYTHON_SIGNED_INTEGRAL_TYPE_ID(int)
|
||||
BOOST_PYTHON_SIGNED_INTEGRAL_TYPE_ID(long)
|
||||
# ifdef BOOST_HAS_LONG_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_SIGNED_INTEGRAL_TYPE_ID(long long)
|
||||
# endif
|
||||
# undef BOOST_PYTHON_SIGNED_INTEGRAL_TYPE_ID
|
||||
|
||||
@@ -98,7 +98,9 @@ namespace
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef BOOST_HAS_LONG_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
|
||||
// A SlotPolicy for extracting long long types from Python objects
|
||||
struct long_long_rvalue_from_python_base
|
||||
{
|
||||
@@ -126,7 +128,7 @@ namespace
|
||||
|
||||
struct long_long_rvalue_from_python : long_long_rvalue_from_python_base
|
||||
{
|
||||
static long long extract(PyObject* intermediate)
|
||||
static LONG_LONG extract(PyObject* intermediate)
|
||||
{
|
||||
if (PyInt_Check(intermediate))
|
||||
{
|
||||
@@ -134,11 +136,11 @@ namespace
|
||||
}
|
||||
if (PyFloat_Check(intermediate))
|
||||
{
|
||||
return numeric_cast<long long>(PyFloat_AS_DOUBLE(intermediate));
|
||||
return numeric_cast<LONG_LONG>(PyFloat_AS_DOUBLE(intermediate));
|
||||
}
|
||||
else
|
||||
{
|
||||
long long result = PyLong_AsLongLong(intermediate);
|
||||
LONG_LONG result = PyLong_AsLongLong(intermediate);
|
||||
|
||||
if (PyErr_Occurred())
|
||||
throw_error_already_set();
|
||||
@@ -150,19 +152,19 @@ namespace
|
||||
|
||||
struct unsigned_long_long_rvalue_from_python : long_long_rvalue_from_python_base
|
||||
{
|
||||
static unsigned long long extract(PyObject* intermediate)
|
||||
static unsigned LONG_LONG extract(PyObject* intermediate)
|
||||
{
|
||||
if (PyInt_Check(intermediate))
|
||||
{
|
||||
return numeric_cast<unsigned long long>(PyInt_AS_LONG(intermediate));
|
||||
return numeric_cast<unsigned LONG_LONG>(PyInt_AS_LONG(intermediate));
|
||||
}
|
||||
if (PyFloat_Check(intermediate))
|
||||
{
|
||||
return numeric_cast<unsigned long long>(PyFloat_AS_DOUBLE(intermediate));
|
||||
return numeric_cast<unsigned LONG_LONG>(PyFloat_AS_DOUBLE(intermediate));
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned long long result = PyLong_AsUnsignedLongLong(intermediate);
|
||||
unsigned LONG_LONG result = PyLong_AsUnsignedLongLong(intermediate);
|
||||
|
||||
if (PyErr_Occurred())
|
||||
throw_error_already_set();
|
||||
@@ -347,9 +349,11 @@ void initialize_builtin_converters()
|
||||
REGISTER_INT_CONVERTERS2(int);
|
||||
REGISTER_INT_CONVERTERS2(long);
|
||||
|
||||
# ifdef BOOST_HAS_LONG_LONG
|
||||
slot_rvalue_from_python<signed long long,long_long_rvalue_from_python>();
|
||||
slot_rvalue_from_python<unsigned long long,unsigned_long_long_rvalue_from_python>();
|
||||
// using Python's macro instead of Boost's - we don't seem to get the
|
||||
// config right all the time.
|
||||
# ifdef HAVE_LONG_LONG
|
||||
slot_rvalue_from_python<signed LONG_LONG,long_long_rvalue_from_python>();
|
||||
slot_rvalue_from_python<unsigned LONG_LONG,unsigned_long_long_rvalue_from_python>();
|
||||
# endif
|
||||
|
||||
// floating types
|
||||
|
||||
18
test/Jamfile
18
test/Jamfile
@@ -82,38 +82,38 @@ if $(TEST_BIENSTMAN_NON_BUGS)
|
||||
}
|
||||
|
||||
# --- unit tests of library components ---
|
||||
|
||||
local UNIT_TEST_PROPERTIES = [ difference $(PYTHON_PROPERTIES) : <define>BOOST_PYTHON_DYNAMIC_LIB ] <define>BOOST_PYTHON_STATIC_LIB ;
|
||||
|
||||
run indirect_traits_test.cpp ;
|
||||
run destroy_test.cpp ;
|
||||
run pointer_type_id_test.cpp ;
|
||||
run pointer_type_id_test.cpp : : : $(UNIT_TEST_PROPERTIES) ;
|
||||
run member_function_cast.cpp ;
|
||||
run bases.cpp ;
|
||||
run if_else.cpp ;
|
||||
run pointee.cpp ;
|
||||
run result.cpp ;
|
||||
compile string_literal.cpp ;
|
||||
compile borrowed.cpp : $(PYTHON_PROPERTIES) ;
|
||||
compile object_manager.cpp : $(PYTHON_PROPERTIES) ;
|
||||
compile borrowed.cpp : $(UNIT_TEST_PROPERTIES) ;
|
||||
compile object_manager.cpp : $(UNIT_TEST_PROPERTIES) ;
|
||||
|
||||
run upcast.cpp
|
||||
: # command-line args
|
||||
: # input files
|
||||
: [ difference $(PYTHON_PROPERTIES) : <define>BOOST_PYTHON_DYNAMIC_LIB ]
|
||||
<define>BOOST_PYTHON_STATIC_LIB
|
||||
: $(UNIT_TEST_PROPERTIES)
|
||||
;
|
||||
|
||||
run select_holder.cpp
|
||||
: # command-line args
|
||||
: # input files
|
||||
: [ difference $(PYTHON_PROPERTIES) : <define>BOOST_PYTHON_DYNAMIC_LIB ]
|
||||
<define>BOOST_PYTHON_STATIC_LIB
|
||||
: $(UNIT_TEST_PROPERTIES)
|
||||
;
|
||||
|
||||
|
||||
run select_from_python_test.cpp ../src/converter/type_id.cpp
|
||||
: # command-line args
|
||||
: # input files
|
||||
: [ difference $(PYTHON_PROPERTIES) : <define>BOOST_PYTHON_DYNAMIC_LIB ]
|
||||
<define>BOOST_PYTHON_STATIC_LIB
|
||||
: $(UNIT_TEST_PROPERTIES)
|
||||
;
|
||||
|
||||
if $(TEST_EXPECTED_FAILURES)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <boost/python/handle.hpp>
|
||||
#include <boost/python/cast.hpp>
|
||||
#include <boost/python/object.hpp>
|
||||
#include <boost/python/detail/wrap_python.hpp>
|
||||
|
||||
template <class T>
|
||||
struct by_value
|
||||
@@ -70,9 +71,11 @@ BOOST_PYTHON_MODULE_INIT(builtin_converters)
|
||||
.def("rewrap_value_unsigned_short", by_value<unsigned short>::rewrap)
|
||||
.def("rewrap_value_long", by_value<long>::rewrap)
|
||||
.def("rewrap_value_unsigned_long", by_value<unsigned long>::rewrap)
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
.def("rewrap_value_long_long", by_value<long long>::rewrap)
|
||||
.def("rewrap_value_unsigned_long_long", by_value<unsigned long long>::rewrap)
|
||||
// using Python's macro instead of Boost's - we don't seem to get the
|
||||
// config right all the time.
|
||||
#ifdef HAVE_LONG_LONG
|
||||
.def("rewrap_value_long_long", by_value<LONG_LONG>::rewrap)
|
||||
.def("rewrap_value_unsigned_long_long", by_value<unsigned LONG_LONG>::rewrap)
|
||||
#endif
|
||||
.def("rewrap_value_float", by_value<float>::rewrap)
|
||||
.def("rewrap_value_double", by_value<double>::rewrap)
|
||||
@@ -99,9 +102,11 @@ BOOST_PYTHON_MODULE_INIT(builtin_converters)
|
||||
.def("rewrap_const_reference_unsigned_short", by_const_reference<unsigned short>::rewrap)
|
||||
.def("rewrap_const_reference_long", by_const_reference<long>::rewrap)
|
||||
.def("rewrap_const_reference_unsigned_long", by_const_reference<unsigned long>::rewrap)
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
.def("rewrap_const_reference_long_long", by_const_reference<long long>::rewrap)
|
||||
.def("rewrap_const_reference_unsigned_long_long", by_const_reference<unsigned long long>::rewrap)
|
||||
// using Python's macro instead of Boost's - we don't seem to get the
|
||||
// config right all the time.
|
||||
#ifdef HAVE_LONG_LONG
|
||||
.def("rewrap_const_reference_long_long", by_const_reference<LONG_LONG>::rewrap)
|
||||
.def("rewrap_const_reference_unsigned_long_long", by_const_reference<unsigned LONG_LONG>::rewrap)
|
||||
#endif
|
||||
.def("rewrap_const_reference_float", by_const_reference<float>::rewrap)
|
||||
.def("rewrap_const_reference_double", by_const_reference<double>::rewrap)
|
||||
|
||||
Reference in New Issue
Block a user