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

* Generalized use of force_instantiate()

* Proper handling for numeric conversion overflows
* Moved internal converter names out of the way to prepare for user conversions
* Added comments
* Fixed a bug where None could be converted to the NULL target of a member function call, causing a crash.
* Wiped out and restarted todo.txt
* long long support
* Added more regression tests and checks for current limitations


[SVN r14094]
This commit is contained in:
Dave Abrahams
2002-06-06 20:24:39 +00:00
parent e2b4178f42
commit ac2746f680
36 changed files with 2899 additions and 2396 deletions

View File

@@ -0,0 +1,52 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef ARG_FROM_PYTHON_DWA2002128_HPP
# define ARG_FROM_PYTHON_DWA2002128_HPP
# include <boost/python/converter/arg_from_python.hpp>
namespace boost { namespace python {
template <class T>
struct arg_from_python
: converter::select_arg_from_python<T>::type
{
typedef typename converter::select_arg_from_python<T>::type base;
arg_from_python(PyObject*);
};
// specialization for PyObject*
template <>
struct arg_from_python<PyObject*>
{
typedef PyObject* result_type;
arg_from_python(PyObject*) {}
bool convertible() const { return true; }
PyObject* operator()(PyObject* source) const { return source; }
};
template <>
struct arg_from_python<PyObject* const&>
{
typedef PyObject* const& result_type;
arg_from_python(PyObject*) {}
bool convertible() const { return true; }
PyObject*const& operator()(PyObject*const& source) const { return source; }
};
//
// implementations
//
template <class T>
inline arg_from_python<T>::arg_from_python(PyObject* source)
: base(source)
{
}
}} // namespace boost::python
#endif // ARG_FROM_PYTHON_DWA2002128_HPP

View File

@@ -6,7 +6,8 @@
#ifndef CALL_DWA2002411_HPP
# define CALL_DWA2002411_HPP
# include <boost/python/converter/callback.hpp>
# include <boost/python/converter/arg_to_python.hpp>
# include <boost/python/converter/return_from_python.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/enum.hpp>
@@ -26,19 +27,19 @@ template <
class R \
BOOST_PP_COMMA_IF(nargs) BOOST_PP_ENUM_PARAMS(nargs, class A) \
> \
typename converter::callback_from_python<R>::result_type \
typename converter::return_from_python<R>::result_type \
call(PyObject* callable \
BOOST_PP_COMMA_IF(nargs) BOOST_PYTHON_ENUM_PARAMS2(nargs, (A,const& a)) \
, boost::type<R>* = 0 \
) \
{ \
converter::callback_from_python<R> converter; \
converter::return_from_python<R> converter; \
return converter( \
PyEval_CallFunction( \
callable \
, const_cast<char*>(BOOST_PYTHON_ARG_STRING(nargs)) \
BOOST_PP_COMMA_IF(nargs) \
BOOST_PP_ENUM(nargs,BOOST_PYTHON_CALLBACK_TO_PYTHON_GET,nil) \
BOOST_PP_ENUM(nargs,BOOST_PYTHON_ARG_TO_PYTHON_GET,nil) \
)); \
}

View File

@@ -6,7 +6,8 @@
#ifndef CALL_METHOD_DWA2002411_HPP
# define CALL_METHOD_DWA2002411_HPP
# include <boost/python/converter/callback.hpp>
# include <boost/python/converter/arg_to_python.hpp>
# include <boost/python/converter/return_from_python.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/enum.hpp>
@@ -26,20 +27,20 @@ template <
class R \
BOOST_PP_COMMA_IF(nargs) BOOST_PP_ENUM_PARAMS(nargs, class A) \
> \
typename converter::callback_from_python<R>::result_type \
typename converter::return_from_python<R>::result_type \
call_method(PyObject* self, char const* name \
BOOST_PP_COMMA_IF(nargs) BOOST_PYTHON_ENUM_PARAMS2(nargs, (A,const& a)) \
, boost::type<R>* = 0 \
) \
{ \
converter::callback_from_python<R> converter; \
converter::return_from_python<R> converter; \
return converter( \
PyEval_CallMethod( \
self \
, const_cast<char*>(name) \
, const_cast<char*>(BOOST_PYTHON_ARG_STRING(nargs)) \
BOOST_PP_COMMA_IF(nargs) \
BOOST_PP_ENUM(nargs,BOOST_PYTHON_CALLBACK_TO_PYTHON_GET,nil) \
BOOST_PP_ENUM(nargs,BOOST_PYTHON_ARG_TO_PYTHON_GET,nil) \
)); \
}

View File

@@ -0,0 +1,320 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef ARG_FROM_PYTHON_DWA2002127_HPP
# define ARG_FROM_PYTHON_DWA2002127_HPP
# include <boost/python/converter/find_from_python.hpp>
# include <boost/python/detail/wrap_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/converter/from_python_data.hpp>
# include <boost/mpl/select_type.hpp>
# include <boost/python/converter/registry.hpp>
# include <boost/python/converter/lvalue_from_python_chain.hpp>
# include <boost/python/converter/rvalue_from_python_chain.hpp>
# include <boost/python/detail/void_ptr.hpp>
# include <boost/python/back_reference.hpp>
namespace boost { namespace python
{
template <class T> struct arg_from_python;
}}
// This header defines Python->C++ function argument converters,
// parametrized on the argument type.
namespace boost { namespace python { namespace converter {
//
// lvalue converters
//
// These require that an lvalue of the type U is stored somewhere in
// the Python object being converted.
// Used when T == U*const&
template <class T>
struct pointer_cref_arg_from_python
{
typedef T result_type;
pointer_cref_arg_from_python(PyObject*);
T operator()(PyObject*) const;
bool convertible() const;
private: // storage for a U*
// needed because not all compilers will let us declare U* as the
// return type of operator() -- we return U*const& instead
typename detail::referent_storage<T>::type m_result;
};
// Base class for pointer and reference converters
struct arg_lvalue_from_python_base
{
public: // member functions
arg_lvalue_from_python_base(void* result);
bool convertible() const;
protected: // member functions
void*const& result() const;
private: // data members
void* m_result;
};
// Used when T == U*
template <class T>
struct pointer_arg_from_python : arg_lvalue_from_python_base
{
typedef T result_type;
pointer_arg_from_python(PyObject*);
T operator()(PyObject*) const;
};
// Used when T == U& and (T != V const& or T == W volatile&)
template <class T>
struct reference_arg_from_python : arg_lvalue_from_python_base
{
typedef T result_type;
reference_arg_from_python(PyObject*);
T operator()(PyObject*) const;
};
// ===================
//
// rvalue converters
//
// These require only that an object of type T can be created from
// the given Python object, but not that the T object exist
// somewhere in storage.
//
// Used when T is a plain value (non-pointer, non-reference) type or
// a (non-volatile) const reference to a plain value type.
template <class T>
struct arg_rvalue_from_python
{
typedef typename boost::add_reference<
typename boost::add_const<T>::type
>::type result_type;
arg_rvalue_from_python(PyObject*);
bool convertible() const;
result_type operator()(PyObject*);
private:
rvalue_data<result_type> m_data;
};
// ==================
// Converts to a (PyObject*,T) bundle, for when you need a reference
// back to the Python object
template <class T>
struct back_reference_arg_from_python
: boost::python::arg_from_python<typename T::type>
{
typedef T result_type;
back_reference_arg_from_python(PyObject*);
T operator()(PyObject*);
private:
typedef boost::python::arg_from_python<typename T::type> base;
};
// ==================
// This metafunction selects the appropriate arg_from_python converter
// type for an argument of type T.
template <class T>
struct select_arg_from_python
{
BOOST_STATIC_CONSTANT(
bool, ptr = is_pointer<T>::value);
BOOST_STATIC_CONSTANT(
bool, ptr_cref
= boost::python::detail::is_reference_to_pointer<T>::value
&& boost::python::detail::is_reference_to_const<T>::value
&& !boost::python::detail::is_reference_to_volatile<T>::value);
BOOST_STATIC_CONSTANT(
bool, ref =
boost::python::detail::is_reference_to_non_const<T>::value
|| boost::python::detail::is_reference_to_volatile<T>::value);
BOOST_STATIC_CONSTANT(
bool, back_ref =
boost::python::is_back_reference<T>::value);
typedef typename mpl::select_type<
ptr
, pointer_arg_from_python<T>
, typename mpl::select_type<
ptr_cref
, pointer_cref_arg_from_python<T>
, typename mpl::select_type<
ref
, reference_arg_from_python<T>
, typename mpl::select_type<
back_ref
, back_reference_arg_from_python<T>
, arg_rvalue_from_python<T>
>::type
>::type
>::type
>::type type;
};
// ==================
//
// implementations
//
// arg_lvalue_from_python_base
//
inline arg_lvalue_from_python_base::arg_lvalue_from_python_base(void* result)
: m_result(result)
{
}
inline bool arg_lvalue_from_python_base::convertible() const
{
return m_result != 0;
}
inline void*const& arg_lvalue_from_python_base::result() const
{
return m_result;
}
// pointer_cref_arg_from_python
//
namespace detail
{
// null_ptr_reference -- a function returning a reference to a null
// pointer of type U. Needed so that extractors for T*const& can
// convert Python's None.
template <class T>
struct null_ptr_owner
{
static T value;
};
template <class T> T null_ptr_owner<T>::value = 0;
template <class U>
inline U& null_ptr_reference(U&(*)())
{
return null_ptr_owner<U>::value;
}
}
template <class T>
inline pointer_cref_arg_from_python<T>::pointer_cref_arg_from_python(PyObject* p)
{
// T == U*const&: store a U* in the m_result storage. Nonzero
// indicates success. If find returns nonzero, it's a pointer to
// a U object.
python::detail::write_void_ptr_reference(
m_result.bytes
, p == Py_None ? p : find(p, lvalue_from_python_chain<T>::value)
, (T(*)())0);
}
template <class T>
inline bool pointer_cref_arg_from_python<T>::convertible() const
{
return python::detail::void_ptr_to_reference(m_result.bytes, (T(*)())0) != 0;
}
template <class T>
inline T pointer_cref_arg_from_python<T>::operator()(PyObject* p) const
{
return (p == Py_None) // None ==> 0
? detail::null_ptr_reference((T(*)())0)
// Otherwise, return a U*const& to the m_result storage.
: python::detail::void_ptr_to_reference(m_result.bytes, (T(*)())0);
}
// pointer_arg_from_python
//
template <class T>
inline pointer_arg_from_python<T>::pointer_arg_from_python(PyObject* p)
: arg_lvalue_from_python_base(
p == Py_None ? p : find(p, lvalue_from_python_chain<T>::value))
{
}
template <class T>
inline T pointer_arg_from_python<T>::operator()(PyObject* p) const
{
return (p == Py_None) ? 0 : T(result());
}
// reference_arg_from_python
//
template <class T>
inline reference_arg_from_python<T>::reference_arg_from_python(PyObject* p)
: arg_lvalue_from_python_base(find(p,lvalue_from_python_chain<T>::value))
{
}
template <class T>
inline T reference_arg_from_python<T>::operator()(PyObject*) const
{
return python::detail::void_ptr_to_reference(result(), (T(*)())0);
}
// arg_rvalue_from_python
//
template <class T>
inline arg_rvalue_from_python<T>::arg_rvalue_from_python(PyObject* obj)
: m_data(find(obj, rvalue_from_python_chain<T>::value))
{
}
template <class T>
inline bool arg_rvalue_from_python<T>::convertible() const
{
return m_data.stage1.convertible != 0;
}
template <class T>
inline typename arg_rvalue_from_python<T>::result_type
arg_rvalue_from_python<T>::operator()(PyObject* p)
{
if (m_data.stage1.construct != 0)
m_data.stage1.construct(p, &m_data.stage1);
return python::detail::void_ptr_to_reference(m_data.stage1.convertible, (result_type(*)())0);
}
// back_reference_arg_from_python
//
template <class T>
back_reference_arg_from_python<T>::back_reference_arg_from_python(PyObject* x)
: base(x)
{
}
template <class T>
inline T
back_reference_arg_from_python<T>::operator()(PyObject* x)
{
return T(x, base::operator()(x));
}
}}} // namespace boost::python::converter
#endif // ARG_FROM_PYTHON_DWA2002127_HPP

View File

@@ -0,0 +1,158 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef ARG_TO_PYTHON_DWA200265_HPP
# define ARG_TO_PYTHON_DWA200265_HPP
# include <boost/python/ptr.hpp>
# include <boost/python/converter/to_python_function.hpp>
# include <boost/python/converter/pointee_to_python_function.hpp>
# include <boost/python/converter/arg_to_python_base.hpp>
# include <boost/python/to_python_indirect.hpp>
namespace boost { namespace python { namespace converter {
namespace detail
{
BOOST_PYTHON_DECL void throw_no_class_registered();
template <class T>
struct reference_arg_to_python : arg_to_python_holder
{
reference_arg_to_python(T& x);
private:
static PyObject* get_object(T& x);
};
template <class T>
struct value_arg_to_python : arg_to_python_base
{
// Throw an exception if the conversion can't succeed
value_arg_to_python(T const&);
};
template <class Ptr>
struct pointer_deep_arg_to_python : arg_to_python_base
{
// Throw an exception if the conversion can't succeed
pointer_deep_arg_to_python(Ptr);
};
template <class Ptr>
struct pointer_shallow_arg_to_python : arg_to_python_holder
{
// Throw an exception if the conversion can't succeed
pointer_shallow_arg_to_python(Ptr);
private:
static PyObject* get_object(Ptr p);
};
template <class T>
struct select_arg_to_python
{
BOOST_STATIC_CONSTANT(
bool, ptr = is_pointer<T>::value);
BOOST_STATIC_CONSTANT(
bool, ref_wrapper = is_reference_wrapper<T>::value);
BOOST_STATIC_CONSTANT(
bool, ptr_wrapper = is_pointer_wrapper<T>::value);
typedef typename unwrap_reference<T>::type unwrapped_referent;
typedef typename unwrap_pointer<T>::type unwrapped_ptr;
typedef typename mpl::select_type<
ptr
, pointer_deep_arg_to_python<T>
, typename mpl::select_type<
ptr_wrapper
, pointer_shallow_arg_to_python<unwrapped_ptr>
, typename mpl::select_type<
ref_wrapper
, reference_arg_to_python<unwrapped_referent>
, value_arg_to_python<T>
>::type
>::type
>::type type;
};
}
template <class T>
struct arg_to_python
: detail::select_arg_to_python<T>::type
{
typedef typename detail::select_arg_to_python<T>::type base;
public: // member functions
// Throw an exception if the conversion can't succeed
arg_to_python(T const& x);
};
//
// Convenience macros for call<> and call_method<> code generation
//
# define BOOST_PYTHON_ARG_TO_PYTHON_GET(index,ignored) \
converter::arg_to_python<BOOST_PP_CAT(A,index)>( \
BOOST_PP_CAT(a,index)).get()
# define BOOST_PYTHON_ARG_STRING(nargs) \
"(" BOOST_PP_REPEAT(nargs,BOOST_PYTHON_PROJECT_2ND,"O") ")"
//
// implementations
//
namespace detail
{
template <class T>
inline value_arg_to_python<T>::value_arg_to_python(T const& x)
: arg_to_python_base(&x, to_python_function<T>::value)
{
}
template <class Ptr>
inline pointer_deep_arg_to_python<Ptr>::pointer_deep_arg_to_python(Ptr x)
: arg_to_python_base(x, pointee_to_python_function<Ptr>::value)
{
}
template <class T>
inline PyObject* reference_arg_to_python<T>::get_object(T& x)
{
to_python_indirect<T&,python::detail::make_reference_holder> convert;
if (!convert.convertible())
throw_no_class_registered();
return convert(x);
}
template <class T>
inline reference_arg_to_python<T>::reference_arg_to_python(T& x)
: arg_to_python_holder(get_object(x))
{
}
template <class Ptr>
inline pointer_shallow_arg_to_python<Ptr>::pointer_shallow_arg_to_python(Ptr x)
: arg_to_python_holder(get_object(x))
{}
template <class Ptr>
inline PyObject* pointer_shallow_arg_to_python<Ptr>::get_object(Ptr x)
{
to_python_indirect<Ptr,python::detail::make_reference_holder> convert;
if (!convert.convertible())
throw_no_class_registered();
return x ? convert(x) : python::detail::none();
}
}
template <class T>
inline arg_to_python<T>::arg_to_python(T const& x)
: base(x)
{}
}}} // namespace boost::python::converter
#endif // ARG_TO_PYTHON_DWA200265_HPP

View File

@@ -0,0 +1,53 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef ARG_TO_PYTHON_BASE_DWA200237_HPP
# define ARG_TO_PYTHON_BASE_DWA200237_HPP
# include <boost/python/converter/to_python_function_type.hpp>
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/reference.hpp>
namespace boost { namespace python { namespace converter {
namespace detail
{
struct arg_to_python_holder
{
arg_to_python_holder(PyObject* obj);
PyObject* get() const;
PyObject* get_incref() const;
private:
ref m_held;
};
struct BOOST_PYTHON_DECL arg_to_python_base : arg_to_python_holder
{
arg_to_python_base(void const volatile* source, to_python_function_t);
};
//
// implmentation
//
inline arg_to_python_holder::arg_to_python_holder(PyObject* obj)
: m_held(obj)
{
}
inline PyObject* arg_to_python_holder::get() const
{
return m_held.get();
}
inline PyObject* arg_to_python_holder::get_incref() const
{
PyObject* result = m_held.get();
Py_XINCREF(result);
return result;
}
}
}}} // namespace boost::python::converter
#endif // ARG_TO_PYTHON_BASE_DWA200237_HPP

View File

@@ -8,84 +8,105 @@
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/detail/none.hpp>
# include <boost/python/reference.hpp>
# include <boost/python/converter/callback_to_python_base.hpp>
# include <boost/python/converter/arg_to_python_base.hpp>
# include <string>
# include <complex>
// Since all we can use to decide how to convert an object to_python
// is its C++ type, there can be only one such converter for each
// type. Therefore, for built-in conversions we can bypass registry
// lookups using explicit specializations of arg_to_python and
// result_to_python.
namespace boost { namespace python {
namespace converter
{
template <class T> struct arg_to_python;
BOOST_PYTHON_DECL PyObject* do_return_to_python(char);
BOOST_PYTHON_DECL PyObject* do_return_to_python(char const*);
BOOST_PYTHON_DECL PyObject* do_return_to_python(PyObject*);
BOOST_PYTHON_DECL PyObject* do_arg_to_python(PyObject*);
}
// Provide specializations of to_python_value
template <class T> struct to_python_value;
namespace detail
{
// Since there's no registry lookup, always report the existence of
// a converter.
struct builtin_to_python
{
static bool convertible() { return true; }
};
}
namespace converter
{
template <class T> struct callback_to_python;
BOOST_PYTHON_DECL PyObject* do_call_to_python(char);
BOOST_PYTHON_DECL PyObject* do_call_to_python(char const*);
BOOST_PYTHON_DECL PyObject* do_call_to_python(PyObject*);
BOOST_PYTHON_DECL PyObject* do_callback_to_python(PyObject*);
}
# define BOOST_PYTHON_CALL_TO_PYTHON_BY_VALUE(T, expr) \
template <> struct to_python_value<T&> \
: detail::builtin_to_python \
{ \
PyObject* operator()(T const& x) const \
{ \
return (expr); \
} \
}; \
template <> struct to_python_value<T const&> \
: detail::builtin_to_python \
{ \
PyObject* operator()(T const& x) const \
{ \
return (expr); \
} \
// Use expr to create the PyObject corresponding to x
# define BOOST_PYTHON_RETURN_TO_PYTHON_BY_VALUE(T, expr) \
template <> struct to_python_value<T&> \
: detail::builtin_to_python \
{ \
inline PyObject* operator()(T const& x) const \
{ \
return (expr); \
} \
}; \
template <> struct to_python_value<T const&> \
: detail::builtin_to_python \
{ \
inline PyObject* operator()(T const& x) const \
{ \
return (expr); \
} \
};
# define BOOST_PYTHON_CALLBACK_TO_PYTHON_BY_VALUE(T, expr) \
namespace converter \
{ \
template <> struct callback_to_python< T > \
: detail::callback_to_python_holder \
{ \
callback_to_python(T const& x) \
: detail::callback_to_python_holder(expr) {} \
}; \
# define BOOST_PYTHON_ARG_TO_PYTHON_BY_VALUE(T, expr) \
namespace converter \
{ \
template <> struct arg_to_python< T > \
: detail::arg_to_python_holder \
{ \
arg_to_python(T const& x) \
: detail::arg_to_python_holder(expr) {} \
}; \
}
# define BOOST_PYTHON_TO_PYTHON_BY_VALUE(T, expr) \
BOOST_PYTHON_CALL_TO_PYTHON_BY_VALUE(T,expr) \
BOOST_PYTHON_CALLBACK_TO_PYTHON_BY_VALUE(T,expr)
// Specialize argument and return value converters for T using expr
# define BOOST_PYTHON_TO_PYTHON_BY_VALUE(T, expr) \
BOOST_PYTHON_RETURN_TO_PYTHON_BY_VALUE(T,expr) \
BOOST_PYTHON_ARG_TO_PYTHON_BY_VALUE(T,expr)
// Specialize converters for signed and unsigned T to Python Int
# define BOOST_PYTHON_TO_INT(T) \
BOOST_PYTHON_TO_PYTHON_BY_VALUE(signed T, PyInt_FromLong(x)) \
BOOST_PYTHON_TO_PYTHON_BY_VALUE(unsigned T, PyInt_FromLong(x))
// Bool is not signed.
BOOST_PYTHON_TO_PYTHON_BY_VALUE(bool, PyInt_FromLong(x))
// note: handles signed char and unsigned char, but not char (see below)
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))
# endif
# undef BOOST_TO_PYTHON_INT
BOOST_PYTHON_TO_PYTHON_BY_VALUE(char, converter::do_call_to_python(x))
BOOST_PYTHON_TO_PYTHON_BY_VALUE(char const*, converter::do_call_to_python(x))
BOOST_PYTHON_TO_PYTHON_BY_VALUE(char, converter::do_return_to_python(x))
BOOST_PYTHON_TO_PYTHON_BY_VALUE(char const*, converter::do_return_to_python(x))
BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::string, PyString_FromString(x.c_str()))
BOOST_PYTHON_TO_PYTHON_BY_VALUE(float, PyFloat_FromDouble(x))
BOOST_PYTHON_TO_PYTHON_BY_VALUE(double, PyFloat_FromDouble(x))
BOOST_PYTHON_TO_PYTHON_BY_VALUE(long double, PyFloat_FromDouble(x))
BOOST_PYTHON_CALL_TO_PYTHON_BY_VALUE(PyObject*, converter::do_call_to_python(x))
BOOST_PYTHON_CALLBACK_TO_PYTHON_BY_VALUE(PyObject*, converter::do_callback_to_python(x))
BOOST_PYTHON_RETURN_TO_PYTHON_BY_VALUE(PyObject*, converter::do_return_to_python(x))
BOOST_PYTHON_ARG_TO_PYTHON_BY_VALUE(PyObject*, converter::do_arg_to_python(x))
BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::complex<float>, PyComplex_FromDoubles(x.real(), x.imag()))
BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::complex<double>, PyComplex_FromDoubles(x.real(), x.imag()))
BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::complex<long double>, PyComplex_FromDoubles(x.real(), x.imag()))

View File

@@ -16,7 +16,7 @@ namespace boost { namespace python { namespace converter {
// Given T == U*cv&, T == U*, or T == U&, lvalue_from_python_chain<T>
// declares a "templated global reference" to the lvalue from_python
// converter chain for U. The optional bool second argument callback,
// converter chain for U. The optional bool second argument is_return,
// when true, removes special treatment for T == U*cv& so that the
// converter for U* is found.
namespace detail
@@ -43,12 +43,12 @@ namespace detail
ref_lvalue_from_python_chain<T>::value
= registry::lvalue_converters(type_id<T>());
template <class T, bool callback>
template <class T, bool is_return>
struct select_lvalue_from_python_chain
{
BOOST_STATIC_CONSTANT(
bool, ptr
= !callback && boost::python::detail::is_reference_to_pointer<T>::value
= !is_return && boost::python::detail::is_reference_to_pointer<T>::value
|| is_pointer<T>::value);
typedef typename add_reference<typename add_cv<T>::type>::type normalized;
@@ -61,9 +61,9 @@ namespace detail
};
}
template <class T, bool callback = false>
template <class T, bool is_return = false>
struct lvalue_from_python_chain
: detail::select_lvalue_from_python_chain<T,callback>::type
: detail::select_lvalue_from_python_chain<T,is_return>::type
{
};

View File

@@ -0,0 +1,134 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef RETURN_FROM_PYTHON_DWA200265_HPP
# define RETURN_FROM_PYTHON_DWA200265_HPP
# include <boost/python/converter/callback_from_python_base.hpp>
namespace boost { namespace python { namespace converter {
namespace detail
{
template <class T>
struct return_pointer_from_python
{
return_pointer_from_python();
T operator()(PyObject*) const;
};
template <class T>
struct return_reference_from_python
{
return_reference_from_python();
T operator()(PyObject*) const;
};
template <class T>
struct return_rvalue_from_python
{
return_rvalue_from_python();
T const& operator()(PyObject*);
private:
rvalue_data<T> m_data;
};
template <class T>
struct select_return_from_python
{
BOOST_STATIC_CONSTANT(
bool, ptr = is_pointer<T>::value);
BOOST_STATIC_CONSTANT(
bool, ref = is_reference<T>::value);
typedef typename mpl::select_type<
ptr
, return_pointer_from_python<T>
, typename mpl::select_type<
ref
, return_reference_from_python<T>
, return_rvalue_from_python<T>
>::type
>::type type;
};
}
template <class T>
struct return_from_python
: detail::select_return_from_python<T>::type
{
typedef T result_type;
};
struct void_result
{
private:
void_result() {}
void operator=(void_result const&);
friend struct return_from_python<void>;
};
// Specialization as a convenience for call and call_method
template <>
struct return_from_python<void>
{
typedef void_result result_type;
result_type operator()(PyObject* x) const
{
Py_DECREF(expect_non_null(x));
return result_type();
}
};
//
// Implementations
//
namespace detail
{
template <class T>
inline return_rvalue_from_python<T>::return_rvalue_from_python()
: m_data(rvalue_from_python_chain<T>::value)
{
throw_if_not_registered(m_data.stage1);
}
template <class T>
inline T const& return_rvalue_from_python<T>::operator()(PyObject* obj)
{
return *(T*)convert_rvalue(obj, m_data.stage1, m_data.storage.bytes);
}
template <class T>
inline return_reference_from_python<T>::return_reference_from_python()
{
detail::throw_if_not_registered(lvalue_from_python_chain<T,true>::value);
}
template <class T>
inline T return_reference_from_python<T>::operator()(PyObject* obj) const
{
return python::detail::void_ptr_to_reference(
callback_convert_reference(obj, lvalue_from_python_chain<T,true>::value)
, (T(*)())0);
}
template <class T>
inline return_pointer_from_python<T>::return_pointer_from_python()
{
detail::throw_if_not_registered(lvalue_from_python_chain<T,true>::value);
}
template <class T>
inline T return_pointer_from_python<T>::operator()(PyObject* obj) const
{
return T(callback_convert_pointer(obj, lvalue_from_python_chain<T,true>::value));
}
}
}}} // namespace boost::python::converter
#endif // RETURN_FROM_PYTHON_DWA200265_HPP

View File

@@ -23,7 +23,7 @@ namespace detail
{
static PyObject* get(Data Class::*pm, PyObject* args_, PyObject*, Policies const& policies)
{
from_python<Class*> c0(PyTuple_GET_ITEM(args_, 0));
arg_from_python<Class*> c0(PyTuple_GET_ITEM(args_, 0));
if (!c0.convertible()) return 0;
// find the result converter
@@ -42,12 +42,12 @@ namespace detail
static PyObject* set(Data Class::*pm, PyObject* args_, PyObject*, Policies const& policies)
{
// check that each of the arguments is convertible
from_python<Class*> c0(PyTuple_GET_ITEM(args_, 0));
arg_from_python<Class*> c0(PyTuple_GET_ITEM(args_, 0));
if (!c0.convertible()) return 0;
typedef typename add_const<Data>::type target1;
typedef typename add_reference<target1>::type target;
from_python<target> c1(PyTuple_GET_ITEM(args_, 1));
arg_from_python<target> c1(PyTuple_GET_ITEM(args_, 1));
if (!c1.convertible()) return 0;

View File

@@ -0,0 +1,18 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef FORCE_INSTANTIATE_DWA200265_HPP
# define FORCE_INSTANTIATE_DWA200265_HPP
namespace boost { namespace python { namespace detail {
// Allows us to force the argument to be instantiated without
// incurring unused variable warnings
template <class T>
inline void force_instantiate(T const&) {}
}}} // namespace boost::python::detail
#endif // FORCE_INSTANTIATE_DWA200265_HPP

View File

@@ -14,7 +14,7 @@
# include <boost/python/detail/wrap_python.hpp>
# include <boost/config.hpp>
# include <boost/python/detail/none.hpp>
# include <boost/python/from_python.hpp>
# include <boost/python/arg_from_python.hpp>
# include <boost/mpl/apply.hpp>
# include <boost/python/detail/preprocessor.hpp>
@@ -38,7 +38,7 @@ struct returning
# endif
# define BOOST_PYTHON_ARG_CONVERTIBLE(index,ignored) \
from_python<BOOST_PP_CAT(A,index)> \
arg_from_python<BOOST_PP_CAT(A,index)> \
BOOST_PP_CAT(c,index)(PyTuple_GET_ITEM(args_, index)); \
if (!BOOST_PP_CAT(c,index).convertible()) return 0;
@@ -54,7 +54,7 @@ struct returning
{ \
/* check that each of the arguments is convertible */ \
/* self argument is special */ \
from_python<A0 cv()*> c0(PyTuple_GET_ITEM(args_, 0)); \
arg_from_python<A0&> c0(PyTuple_GET_ITEM(args_, 0)); \
if (!c0.convertible()) return 0; \
\
/* Unroll a loop for the rest of them */ \
@@ -68,7 +68,7 @@ struct returning
if (!policies->precall(args_)) return 0; \
\
PyObject* result = cr( \
((BOOST_PYTHON_GET_ARG(0,nil))->*pmf)( \
((BOOST_PYTHON_GET_ARG(0,nil)).*pmf)( \
BOOST_PP_ENUM_SHIFTED(args,BOOST_PYTHON_GET_ARG,nil)) \
); \
\
@@ -125,7 +125,7 @@ static PyObject*call( \
{ \
/* check that each of the arguments is convertible */ \
/* self argument is special */ \
from_python<A0 cv()*>c0(PyTuple_GET_ITEM(args_,0)); \
arg_from_python<A0&>c0(PyTuple_GET_ITEM(args_,0)); \
if (!c0.convertible()) return 0; \
\
/* Unroll a loop for the rest of them */ \
@@ -133,7 +133,7 @@ static PyObject*call( \
\
if (!policies->precall(args_)) return 0; \
\
((c0(PyTuple_GET_ITEM(args_,0)))->*pmf)( \
((c0(PyTuple_GET_ITEM(args_,0))).*pmf)( \
BOOST_PP_ENUM_SHIFTED(args,BOOST_PYTHON_GET_ARG,nil) \
); \
\

View File

@@ -7,6 +7,8 @@
# define UNWIND_TYPE_DWA200222_HPP
# include <boost/python/detail/cv_category.hpp>
# include <boost/python/detail/indirect_traits.hpp>
# include <boost/type_traits/object_traits.hpp>
namespace boost { namespace python { namespace detail {

View File

@@ -1,3 +1,4 @@
#error obsolete
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
@@ -12,7 +13,7 @@ namespace boost { namespace python {
template <class T>
struct from_python
: converter::select_from_python<T>::type
: converter::select_arg_from_python<T>::type
{
typedef typename converter::select_from_python<T>::type base;
from_python(PyObject*);

View File

@@ -12,6 +12,7 @@
# include <boost/python/converter/registry.hpp>
# include <boost/python/object/find_instance.hpp>
# include <boost/python/object/inheritance.hpp>
# include <boost/python/detail/force_instantiate.hpp>
namespace boost { namespace python { namespace objects {
@@ -69,16 +70,13 @@ struct register_base_of
};
};
template <class T>
inline void force_instantiate(T const&) {}
// Brings into existence all converters associated with a class Bases
// is expected to be an mpl sequence of base types.
template <class Derived, class Bases>
inline void register_class_from_python(Derived* = 0, Bases* = 0)
{
// cause the static registration to be instantiated.
force_instantiate(instance_finder<Derived>::registration);
python::detail::force_instantiate(instance_finder<Derived>::registration);
// register all up/downcasts here
register_dynamic_id<Derived>();

View File

@@ -13,7 +13,7 @@
# include <boost/python/object/function.hpp>
# include <boost/python/reference.hpp>
# include <boost/type.hpp>
# include <boost/python/from_python.hpp>
# include <boost/python/arg_from_python.hpp>
# include <boost/mpl/apply.hpp>
# include <boost/bind.hpp>
# include <boost/bind/protect.hpp>
@@ -63,7 +63,7 @@ namespace detail
typedef iterator_range<Policies,Iterator> range_;
PyObject* py_self = PyTuple_GET_ITEM(args_, 0);
from_python<range_*> c0(py_self);
arg_from_python<range_*> c0(py_self);
range_* self = c0(py_self);
// Done iterating?
@@ -167,9 +167,9 @@ namespace detail
// Extract x from the first argument
PyObject* arg0 = PyTuple_GET_ITEM(args_, 0);
from_python<Target> c0(arg0);
arg_from_python<Target> c0(arg0);
if (!c0.convertible()) return 0;
typename from_python<Target>::result_type x = c0(arg0);
typename arg_from_python<Target>::result_type x = c0(arg0);
// Build and convert the iterator_range<>.
return cr(

View File

@@ -17,6 +17,7 @@
# include <boost/python/pointee.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/preprocessor/enum_params.hpp>
# include <boost/python/detail/force_instantiate.hpp>
namespace boost { namespace python { namespace objects {
@@ -66,19 +67,19 @@ struct pointer_holder_back_reference : instance_holder
# include <boost/python/preprocessed/ptr_holder_back_reference.hpp>
# endif
# define BOOST_PYTHON_CONSTRUCT_POINTER_HOLDER_BACK_REFERENCE(nargs, ignored) \
BOOST_PP_EXPR_IF(nargs, template <) \
BOOST_PP_ENUM_PARAMS(nargs, class A) \
BOOST_PP_EXPR_IF(nargs, >) \
pointer_holder_back_reference(PyObject* p \
BOOST_PP_COMMA_IF(nargs) \
BOOST_PYTHON_ENUM_PARAMS2(nargs, (A,a))) \
: m_p(new held_type( \
p BOOST_PP_COMMA_IF(nargs) \
BOOST_PP_ENUM(nargs, BOOST_PYTHON_UNFORWARD, nil) \
)) \
{ \
void const* x = &instance_finder<held_type>::registration; (void)x; \
# define BOOST_PYTHON_CONSTRUCT_POINTER_HOLDER_BACK_REFERENCE(nargs, ignored) \
BOOST_PP_EXPR_IF(nargs, template <) \
BOOST_PP_ENUM_PARAMS(nargs, class A) \
BOOST_PP_EXPR_IF(nargs, >) \
pointer_holder_back_reference(PyObject* p \
BOOST_PP_COMMA_IF(nargs) \
BOOST_PYTHON_ENUM_PARAMS2(nargs, (A,a))) \
: m_p(new held_type( \
p BOOST_PP_COMMA_IF(nargs) \
BOOST_PP_ENUM(nargs, BOOST_PYTHON_UNFORWARD, nil) \
)) \
{ \
python::detail::force_instantiate(instance_finder<held_type>::registration); \
}
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_CONSTRUCT_POINTER_HOLDER_BACK_REFERENCE,nil)

View File

@@ -14,6 +14,7 @@
# include <boost/python/object/forward.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/preprocessor/enum_params.hpp>
# include <boost/python/detail/force_instantiate.hpp>
namespace boost { namespace python { namespace objects {
@@ -54,19 +55,19 @@ struct value_holder_back_reference : instance_holder
# include <boost/python/preprocessed/value_holder_back_reference.hpp>
# endif
# define BOOST_PYTHON_CONSTRUCT_VALUE_HOLDER_BACK_REFERENCE(nargs, ignored) \
BOOST_PP_EXPR_IF(nargs, template <) \
BOOST_PP_ENUM_PARAMS(nargs, class A) \
BOOST_PP_EXPR_IF(nargs, >) \
value_holder_back_reference(PyObject* p \
BOOST_PP_COMMA_IF(nargs) \
BOOST_PYTHON_ENUM_PARAMS2(nargs, (A,a))) \
: m_held( \
p BOOST_PP_COMMA_IF(nargs) \
BOOST_PP_ENUM(nargs, BOOST_PYTHON_UNFORWARD, nil) \
) \
{ \
void const* x = &instance_finder<BackReferenceType>::registration; (void)x; \
# define BOOST_PYTHON_CONSTRUCT_VALUE_HOLDER_BACK_REFERENCE(nargs, ignored) \
BOOST_PP_EXPR_IF(nargs, template <) \
BOOST_PP_ENUM_PARAMS(nargs, class A) \
BOOST_PP_EXPR_IF(nargs, >) \
value_holder_back_reference(PyObject* p \
BOOST_PP_COMMA_IF(nargs) \
BOOST_PYTHON_ENUM_PARAMS2(nargs, (A,a))) \
: m_held( \
p BOOST_PP_COMMA_IF(nargs) \
BOOST_PP_ENUM(nargs, BOOST_PYTHON_UNFORWARD, nil) \
) \
{ \
python::detail::force_instantiate(instance_finder<BackReferenceType>::registration); \
}
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_CONSTRUCT_VALUE_HOLDER_BACK_REFERENCE,nil)

View File

@@ -7,9 +7,10 @@
# define OPERATORS2_DWA2002530_HPP
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/converter/callback.hpp>
# include <boost/python/converter/arg_to_python.hpp>
# include <boost/python/detail/operator_id.hpp>
# include <boost/python/detail/not_specified.hpp>
# include <boost/python/back_reference.hpp>
# include <boost/mpl/select_type.hpp>
# include <boost/python/self.hpp>
# include <boost/python/other.hpp>
@@ -26,7 +27,7 @@ namespace detail
template <class T>
PyObject* convert_result(T const& x)
{
return converter::callback_to_python<T>(x).get_incref();
return converter::arg_to_python<T>(x).get_incref();
}
// Operator implementation template declarations. The nested apply

View File

@@ -11,268 +11,268 @@
// (replace-string "PyEval_CallFunction(" "\nPyEval_CallFunction(\n")
template<class R>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call(PyObject*callable,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallFunction(
callable,const_cast<char*>("(" ")")));
}
template<class R,class A0>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call(PyObject*callable,A0 const&a0,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallFunction(
callable,const_cast<char*>("(" "O" ")")
,converter::callback_to_python<A0>(a0).get()));
,converter::arg_to_python<A0>(a0).get()));
}
template<class R,class A0,class A1>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call(PyObject*callable,A0 const&a0,A1 const&a1,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallFunction(
callable,const_cast<char*>("(" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()));
}
template<class R,class A0,class A1,class A2>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call(PyObject*callable,A0 const&a0,A1 const&a1,A2 const&a2,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallFunction(
callable,const_cast<char*>("(" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()));
}
template<class R,class A0,class A1,class A2,class A3>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call(PyObject*callable,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallFunction(
callable,const_cast<char*>("(" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call(PyObject*callable,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallFunction(
callable,const_cast<char*>("(" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4,class A5>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call(PyObject*callable,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallFunction(
callable,const_cast<char*>("(" "O" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()
,converter::callback_to_python<A5>(a5).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()
,converter::arg_to_python<A5>(a5).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4,class A5,class A6>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call(PyObject*callable,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,A6 const&a6,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallFunction(
callable,const_cast<char*>("(" "O" "O" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()
,converter::callback_to_python<A5>(a5).get()
,converter::callback_to_python<A6>(a6).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()
,converter::arg_to_python<A5>(a5).get()
,converter::arg_to_python<A6>(a6).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call(PyObject*callable,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,A6 const&a6,A7 const&a7,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallFunction(
callable,const_cast<char*>("(" "O" "O" "O" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()
,converter::callback_to_python<A5>(a5).get()
,converter::callback_to_python<A6>(a6).get()
,converter::callback_to_python<A7>(a7).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()
,converter::arg_to_python<A5>(a5).get()
,converter::arg_to_python<A6>(a6).get()
,converter::arg_to_python<A7>(a7).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call(PyObject*callable,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,A6 const&a6,A7 const&a7,A8 const&a8,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallFunction(
callable,const_cast<char*>("(" "O" "O" "O" "O" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()
,converter::callback_to_python<A5>(a5).get()
,converter::callback_to_python<A6>(a6).get()
,converter::callback_to_python<A7>(a7).get()
,converter::callback_to_python<A8>(a8).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()
,converter::arg_to_python<A5>(a5).get()
,converter::arg_to_python<A6>(a6).get()
,converter::arg_to_python<A7>(a7).get()
,converter::arg_to_python<A8>(a8).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call(PyObject*callable,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,A6 const&a6,A7 const&a7,A8 const&a8,A9 const&a9,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallFunction(
callable,const_cast<char*>("(" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()
,converter::callback_to_python<A5>(a5).get()
,converter::callback_to_python<A6>(a6).get()
,converter::callback_to_python<A7>(a7).get()
,converter::callback_to_python<A8>(a8).get()
,converter::callback_to_python<A9>(a9).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()
,converter::arg_to_python<A5>(a5).get()
,converter::arg_to_python<A6>(a6).get()
,converter::arg_to_python<A7>(a7).get()
,converter::arg_to_python<A8>(a8).get()
,converter::arg_to_python<A9>(a9).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9,class A10>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call(PyObject*callable,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,A6 const&a6,A7 const&a7,A8 const&a8,A9 const&a9,A10 const&a10,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallFunction(
callable,const_cast<char*>("(" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()
,converter::callback_to_python<A5>(a5).get()
,converter::callback_to_python<A6>(a6).get()
,converter::callback_to_python<A7>(a7).get()
,converter::callback_to_python<A8>(a8).get()
,converter::callback_to_python<A9>(a9).get()
,converter::callback_to_python<A10>(a10).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()
,converter::arg_to_python<A5>(a5).get()
,converter::arg_to_python<A6>(a6).get()
,converter::arg_to_python<A7>(a7).get()
,converter::arg_to_python<A8>(a8).get()
,converter::arg_to_python<A9>(a9).get()
,converter::arg_to_python<A10>(a10).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9,class A10,class A11>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call(PyObject*callable,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,A6 const&a6,A7 const&a7,A8 const&a8,A9 const&a9,A10 const&a10,A11 const&a11,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallFunction(
callable,const_cast<char*>("(" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()
,converter::callback_to_python<A5>(a5).get()
,converter::callback_to_python<A6>(a6).get()
,converter::callback_to_python<A7>(a7).get()
,converter::callback_to_python<A8>(a8).get()
,converter::callback_to_python<A9>(a9).get()
,converter::callback_to_python<A10>(a10).get()
,converter::callback_to_python<A11>(a11).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()
,converter::arg_to_python<A5>(a5).get()
,converter::arg_to_python<A6>(a6).get()
,converter::arg_to_python<A7>(a7).get()
,converter::arg_to_python<A8>(a8).get()
,converter::arg_to_python<A9>(a9).get()
,converter::arg_to_python<A10>(a10).get()
,converter::arg_to_python<A11>(a11).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9,class A10,class A11,class A12>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call(PyObject*callable,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,A6 const&a6,A7 const&a7,A8 const&a8,A9 const&a9,A10 const&a10,A11 const&a11,A12 const&a12,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallFunction(
callable,const_cast<char*>("(" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()
,converter::callback_to_python<A5>(a5).get()
,converter::callback_to_python<A6>(a6).get()
,converter::callback_to_python<A7>(a7).get()
,converter::callback_to_python<A8>(a8).get()
,converter::callback_to_python<A9>(a9).get()
,converter::callback_to_python<A10>(a10).get()
,converter::callback_to_python<A11>(a11).get()
,converter::callback_to_python<A12>(a12).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()
,converter::arg_to_python<A5>(a5).get()
,converter::arg_to_python<A6>(a6).get()
,converter::arg_to_python<A7>(a7).get()
,converter::arg_to_python<A8>(a8).get()
,converter::arg_to_python<A9>(a9).get()
,converter::arg_to_python<A10>(a10).get()
,converter::arg_to_python<A11>(a11).get()
,converter::arg_to_python<A12>(a12).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9,class A10,class A11,class A12,class A13>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call(PyObject*callable,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,A6 const&a6,A7 const&a7,A8 const&a8,A9 const&a9,A10 const&a10,A11 const&a11,A12 const&a12,A13 const&a13,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallFunction(
callable,const_cast<char*>("(" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()
,converter::callback_to_python<A5>(a5).get()
,converter::callback_to_python<A6>(a6).get()
,converter::callback_to_python<A7>(a7).get()
,converter::callback_to_python<A8>(a8).get()
,converter::callback_to_python<A9>(a9).get()
,converter::callback_to_python<A10>(a10).get()
,converter::callback_to_python<A11>(a11).get()
,converter::callback_to_python<A12>(a12).get()
,converter::callback_to_python<A13>(a13).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()
,converter::arg_to_python<A5>(a5).get()
,converter::arg_to_python<A6>(a6).get()
,converter::arg_to_python<A7>(a7).get()
,converter::arg_to_python<A8>(a8).get()
,converter::arg_to_python<A9>(a9).get()
,converter::arg_to_python<A10>(a10).get()
,converter::arg_to_python<A11>(a11).get()
,converter::arg_to_python<A12>(a12).get()
,converter::arg_to_python<A13>(a13).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9,class A10,class A11,class A12,class A13,class A14>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call(PyObject*callable,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,A6 const&a6,A7 const&a7,A8 const&a8,A9 const&a9,A10 const&a10,A11 const&a11,A12 const&a12,A13 const&a13,A14 const&a14,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallFunction(
callable,const_cast<char*>("(" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()
,converter::callback_to_python<A5>(a5).get()
,converter::callback_to_python<A6>(a6).get()
,converter::callback_to_python<A7>(a7).get()
,converter::callback_to_python<A8>(a8).get()
,converter::callback_to_python<A9>(a9).get()
,converter::callback_to_python<A10>(a10).get()
,converter::callback_to_python<A11>(a11).get()
,converter::callback_to_python<A12>(a12).get()
,converter::callback_to_python<A13>(a13).get()
,converter::callback_to_python<A14>(a14).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()
,converter::arg_to_python<A5>(a5).get()
,converter::arg_to_python<A6>(a6).get()
,converter::arg_to_python<A7>(a7).get()
,converter::arg_to_python<A8>(a8).get()
,converter::arg_to_python<A9>(a9).get()
,converter::arg_to_python<A10>(a10).get()
,converter::arg_to_python<A11>(a11).get()
,converter::arg_to_python<A12>(a12).get()
,converter::arg_to_python<A13>(a13).get()
,converter::arg_to_python<A14>(a14).get()));
}
#endif // CALL_PP_DWA2002411_HPP

View File

@@ -11,267 +11,267 @@
// (replace-string "PyEval_CallMethod(" "\nPyEval_CallMethod(\n")
template<class R>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call_method(PyObject*self,char const*name,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallMethod(
self,const_cast<char*>(name),const_cast<char*>("(" ")")));
}
template<class R,class A0>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call_method(PyObject*self,char const*name,A0 const&a0,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallMethod(
self,const_cast<char*>(name),const_cast<char*>("(" "O" ")")
,converter::callback_to_python<A0>(a0).get()));
,converter::arg_to_python<A0>(a0).get()));
}
template<class R,class A0,class A1>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call_method(PyObject*self,char const*name,A0 const&a0,A1 const&a1,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallMethod(
self,const_cast<char*>(name),const_cast<char*>("(" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()));
}
template<class R,class A0,class A1,class A2>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call_method(PyObject*self,char const*name,A0 const&a0,A1 const&a1,A2 const&a2,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallMethod(
self,const_cast<char*>(name),const_cast<char*>("(" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()));
}
template<class R,class A0,class A1,class A2,class A3>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call_method(PyObject*self,char const*name,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallMethod(
self,const_cast<char*>(name),const_cast<char*>("(" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call_method(PyObject*self,char const*name,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallMethod(
self,const_cast<char*>(name),const_cast<char*>("(" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4,class A5>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call_method(PyObject*self,char const*name,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallMethod(
self,const_cast<char*>(name),const_cast<char*>("(" "O" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()
,converter::callback_to_python<A5>(a5).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()
,converter::arg_to_python<A5>(a5).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4,class A5,class A6>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call_method(PyObject*self,char const*name,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,A6 const&a6,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallMethod(
self,const_cast<char*>(name),const_cast<char*>("(" "O" "O" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()
,converter::callback_to_python<A5>(a5).get()
,converter::callback_to_python<A6>(a6).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()
,converter::arg_to_python<A5>(a5).get()
,converter::arg_to_python<A6>(a6).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call_method(PyObject*self,char const*name,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,A6 const&a6,A7 const&a7,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallMethod(
self,const_cast<char*>(name),const_cast<char*>("(" "O" "O" "O" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()
,converter::callback_to_python<A5>(a5).get()
,converter::callback_to_python<A6>(a6).get()
,converter::callback_to_python<A7>(a7).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()
,converter::arg_to_python<A5>(a5).get()
,converter::arg_to_python<A6>(a6).get()
,converter::arg_to_python<A7>(a7).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call_method(PyObject*self,char const*name,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,A6 const&a6,A7 const&a7,A8 const&a8,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallMethod(
self,const_cast<char*>(name),const_cast<char*>("(" "O" "O" "O" "O" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()
,converter::callback_to_python<A5>(a5).get()
,converter::callback_to_python<A6>(a6).get()
,converter::callback_to_python<A7>(a7).get()
,converter::callback_to_python<A8>(a8).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()
,converter::arg_to_python<A5>(a5).get()
,converter::arg_to_python<A6>(a6).get()
,converter::arg_to_python<A7>(a7).get()
,converter::arg_to_python<A8>(a8).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call_method(PyObject*self,char const*name,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,A6 const&a6,A7 const&a7,A8 const&a8,A9 const&a9,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallMethod(
self,const_cast<char*>(name),const_cast<char*>("(" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()
,converter::callback_to_python<A5>(a5).get()
,converter::callback_to_python<A6>(a6).get()
,converter::callback_to_python<A7>(a7).get()
,converter::callback_to_python<A8>(a8).get()
,converter::callback_to_python<A9>(a9).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()
,converter::arg_to_python<A5>(a5).get()
,converter::arg_to_python<A6>(a6).get()
,converter::arg_to_python<A7>(a7).get()
,converter::arg_to_python<A8>(a8).get()
,converter::arg_to_python<A9>(a9).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9,class A10>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call_method(PyObject*self,char const*name,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,A6 const&a6,A7 const&a7,A8 const&a8,A9 const&a9,A10 const&a10,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallMethod(
self,const_cast<char*>(name),const_cast<char*>("(" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()
,converter::callback_to_python<A5>(a5).get()
,converter::callback_to_python<A6>(a6).get()
,converter::callback_to_python<A7>(a7).get()
,converter::callback_to_python<A8>(a8).get()
,converter::callback_to_python<A9>(a9).get()
,converter::callback_to_python<A10>(a10).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()
,converter::arg_to_python<A5>(a5).get()
,converter::arg_to_python<A6>(a6).get()
,converter::arg_to_python<A7>(a7).get()
,converter::arg_to_python<A8>(a8).get()
,converter::arg_to_python<A9>(a9).get()
,converter::arg_to_python<A10>(a10).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9,class A10,class A11>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call_method(PyObject*self,char const*name,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,A6 const&a6,A7 const&a7,A8 const&a8,A9 const&a9,A10 const&a10,A11 const&a11,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallMethod(
self,const_cast<char*>(name),const_cast<char*>("(" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()
,converter::callback_to_python<A5>(a5).get()
,converter::callback_to_python<A6>(a6).get()
,converter::callback_to_python<A7>(a7).get()
,converter::callback_to_python<A8>(a8).get()
,converter::callback_to_python<A9>(a9).get()
,converter::callback_to_python<A10>(a10).get()
,converter::callback_to_python<A11>(a11).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()
,converter::arg_to_python<A5>(a5).get()
,converter::arg_to_python<A6>(a6).get()
,converter::arg_to_python<A7>(a7).get()
,converter::arg_to_python<A8>(a8).get()
,converter::arg_to_python<A9>(a9).get()
,converter::arg_to_python<A10>(a10).get()
,converter::arg_to_python<A11>(a11).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9,class A10,class A11,class A12>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call_method(PyObject*self,char const*name,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,A6 const&a6,A7 const&a7,A8 const&a8,A9 const&a9,A10 const&a10,A11 const&a11,A12 const&a12,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallMethod(
self,const_cast<char*>(name),const_cast<char*>("(" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()
,converter::callback_to_python<A5>(a5).get()
,converter::callback_to_python<A6>(a6).get()
,converter::callback_to_python<A7>(a7).get()
,converter::callback_to_python<A8>(a8).get()
,converter::callback_to_python<A9>(a9).get()
,converter::callback_to_python<A10>(a10).get()
,converter::callback_to_python<A11>(a11).get()
,converter::callback_to_python<A12>(a12).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()
,converter::arg_to_python<A5>(a5).get()
,converter::arg_to_python<A6>(a6).get()
,converter::arg_to_python<A7>(a7).get()
,converter::arg_to_python<A8>(a8).get()
,converter::arg_to_python<A9>(a9).get()
,converter::arg_to_python<A10>(a10).get()
,converter::arg_to_python<A11>(a11).get()
,converter::arg_to_python<A12>(a12).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9,class A10,class A11,class A12,class A13>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call_method(PyObject*self,char const*name,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,A6 const&a6,A7 const&a7,A8 const&a8,A9 const&a9,A10 const&a10,A11 const&a11,A12 const&a12,A13 const&a13,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallMethod(
self,const_cast<char*>(name),const_cast<char*>("(" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()
,converter::callback_to_python<A5>(a5).get()
,converter::callback_to_python<A6>(a6).get()
,converter::callback_to_python<A7>(a7).get()
,converter::callback_to_python<A8>(a8).get()
,converter::callback_to_python<A9>(a9).get()
,converter::callback_to_python<A10>(a10).get()
,converter::callback_to_python<A11>(a11).get()
,converter::callback_to_python<A12>(a12).get()
,converter::callback_to_python<A13>(a13).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()
,converter::arg_to_python<A5>(a5).get()
,converter::arg_to_python<A6>(a6).get()
,converter::arg_to_python<A7>(a7).get()
,converter::arg_to_python<A8>(a8).get()
,converter::arg_to_python<A9>(a9).get()
,converter::arg_to_python<A10>(a10).get()
,converter::arg_to_python<A11>(a11).get()
,converter::arg_to_python<A12>(a12).get()
,converter::arg_to_python<A13>(a13).get()));
}
template<class R,class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9,class A10,class A11,class A12,class A13,class A14>
typename converter::callback_from_python<R>::result_type
typename converter::return_from_python<R>::result_type
call_method(PyObject*self,char const*name,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,A6 const&a6,A7 const&a7,A8 const&a8,A9 const&a9,A10 const&a10,A11 const&a11,A12 const&a12,A13 const&a13,A14 const&a14,boost::type<R>* =0)
{
converter::callback_from_python<R>converter;
converter::return_from_python<R>converter;
return converter(
PyEval_CallMethod(
self,const_cast<char*>(name),const_cast<char*>("(" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" "O" ")")
,converter::callback_to_python<A0>(a0).get()
,converter::callback_to_python<A1>(a1).get()
,converter::callback_to_python<A2>(a2).get()
,converter::callback_to_python<A3>(a3).get()
,converter::callback_to_python<A4>(a4).get()
,converter::callback_to_python<A5>(a5).get()
,converter::callback_to_python<A6>(a6).get()
,converter::callback_to_python<A7>(a7).get()
,converter::callback_to_python<A8>(a8).get()
,converter::callback_to_python<A9>(a9).get()
,converter::callback_to_python<A10>(a10).get()
,converter::callback_to_python<A11>(a11).get()
,converter::callback_to_python<A12>(a12).get()
,converter::callback_to_python<A13>(a13).get()
,converter::callback_to_python<A14>(a14).get()));
,converter::arg_to_python<A0>(a0).get()
,converter::arg_to_python<A1>(a1).get()
,converter::arg_to_python<A2>(a2).get()
,converter::arg_to_python<A3>(a3).get()
,converter::arg_to_python<A4>(a4).get()
,converter::arg_to_python<A5>(a5).get()
,converter::arg_to_python<A6>(a6).get()
,converter::arg_to_python<A7>(a7).get()
,converter::arg_to_python<A8>(a8).get()
,converter::arg_to_python<A9>(a9).get()
,converter::arg_to_python<A10>(a10).get()
,converter::arg_to_python<A11>(a11).get()
,converter::arg_to_python<A12>(a12).get()
,converter::arg_to_python<A13>(a13).get()
,converter::arg_to_python<A14>(a14).get()));
}
#endif// CALL_METHOD_PP_DWA2002411_HPP

View File

@@ -15,8 +15,8 @@ pointer_holder_back_reference(PyObject*p)
:m_p(new held_type(
p))
{
void const*x=&instance_finder<held_type>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<held_type>::registration);
}
template<class A0>
pointer_holder_back_reference(PyObject*p,A0 a0)
@@ -24,8 +24,8 @@ pointer_holder_back_reference(PyObject*p,A0 a0)
p
,(typename unforward<A0>::type)(a0)))
{
void const*x=&instance_finder<held_type>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<held_type>::registration);
}
template<class A0,class A1>
pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1)
@@ -34,8 +34,8 @@ pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1)
,(typename unforward<A0>::type)(a0)
,(typename unforward<A1>::type)(a1)))
{
void const*x=&instance_finder<held_type>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<held_type>::registration);
}
template<class A0,class A1,class A2>
pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2)
@@ -45,8 +45,8 @@ pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2)
,(typename unforward<A1>::type)(a1)
,(typename unforward<A2>::type)(a2)))
{
void const*x=&instance_finder<held_type>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<held_type>::registration);
}
template<class A0,class A1,class A2,class A3>
pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3)
@@ -57,8 +57,8 @@ pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3)
,(typename unforward<A2>::type)(a2)
,(typename unforward<A3>::type)(a3)))
{
void const*x=&instance_finder<held_type>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<held_type>::registration);
}
template<class A0,class A1,class A2,class A3,class A4>
pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4)
@@ -70,8 +70,8 @@ pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4)
,(typename unforward<A3>::type)(a3)
,(typename unforward<A4>::type)(a4)))
{
void const*x=&instance_finder<held_type>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<held_type>::registration);
}
template<class A0,class A1,class A2,class A3,class A4,class A5>
pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5)
@@ -84,8 +84,8 @@ pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5)
,(typename unforward<A4>::type)(a4)
,(typename unforward<A5>::type)(a5)))
{
void const*x=&instance_finder<held_type>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<held_type>::registration);
}
template<class A0,class A1,class A2,class A3,class A4,class A5,class A6>
pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6)
@@ -99,8 +99,8 @@ pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6
,(typename unforward<A5>::type)(a5)
,(typename unforward<A6>::type)(a6)))
{
void const*x=&instance_finder<held_type>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<held_type>::registration);
}
template<class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7>
pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7)
@@ -115,8 +115,8 @@ pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6
,(typename unforward<A6>::type)(a6)
,(typename unforward<A7>::type)(a7)))
{
void const*x=&instance_finder<held_type>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<held_type>::registration);
}
template<class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8>
pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8)
@@ -132,8 +132,8 @@ pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6
,(typename unforward<A7>::type)(a7)
,(typename unforward<A8>::type)(a8)))
{
void const*x=&instance_finder<held_type>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<held_type>::registration);
}
template<class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9>
pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9)
@@ -150,8 +150,8 @@ pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6
,(typename unforward<A8>::type)(a8)
,(typename unforward<A9>::type)(a9)))
{
void const*x=&instance_finder<held_type>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<held_type>::registration);
}
template<class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9,class A10>
pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9,A10 a10)
@@ -169,8 +169,8 @@ pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6
,(typename unforward<A9>::type)(a9)
,(typename unforward<A10>::type)(a10)))
{
void const*x=&instance_finder<held_type>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<held_type>::registration);
}
template<class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9,class A10,class A11>
pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9,A10 a10,A11 a11)
@@ -189,8 +189,8 @@ pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6
,(typename unforward<A10>::type)(a10)
,(typename unforward<A11>::type)(a11)))
{
void const*x=&instance_finder<held_type>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<held_type>::registration);
}
template<class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9,class A10,class A11,class A12>
pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9,A10 a10,A11 a11,A12 a12)
@@ -210,8 +210,8 @@ pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6
,(typename unforward<A11>::type)(a11)
,(typename unforward<A12>::type)(a12)))
{
void const*x=&instance_finder<held_type>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<held_type>::registration);
}
template<class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9,class A10,class A11,class A12,class A13>
pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9,A10 a10,A11 a11,A12 a12,A13 a13)
@@ -232,8 +232,8 @@ pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6
,(typename unforward<A12>::type)(a12)
,(typename unforward<A13>::type)(a13)))
{
void const*x=&instance_finder<held_type>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<held_type>::registration);
}
template<class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9,class A10,class A11,class A12,class A13,class A14>
pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9,A10 a10,A11 a11,A12 a12,A13 a13,A14 a14)
@@ -255,7 +255,7 @@ pointer_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6
,(typename unforward<A13>::type)(a13)
,(typename unforward<A14>::type)(a14)))
{
void const*x=&instance_finder<held_type>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<held_type>::registration);
}
#endif//POINTER_HOLDER_BACK_REFERENCE_DWA2002411_HPP

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -13,16 +13,16 @@
value_holder_back_reference(PyObject*p)
:m_held(p)
{
void const*x=&instance_finder<BackReferenceType>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<BackReferenceType>::registration);
}
template<class A0>
value_holder_back_reference(PyObject*p,A0 a0)
:m_held(p
,(typename unforward<A0>::type)(a0))
{
void const*x=&instance_finder<BackReferenceType>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<BackReferenceType>::registration);
}
template<class A0,class A1>
value_holder_back_reference(PyObject*p,A0 a0,A1 a1)
@@ -30,8 +30,8 @@ value_holder_back_reference(PyObject*p,A0 a0,A1 a1)
,(typename unforward<A0>::type)(a0)
,(typename unforward<A1>::type)(a1))
{
void const*x=&instance_finder<BackReferenceType>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<BackReferenceType>::registration);
}
template<class A0,class A1,class A2>
value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2)
@@ -40,8 +40,8 @@ value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2)
,(typename unforward<A1>::type)(a1)
,(typename unforward<A2>::type)(a2))
{
void const*x=&instance_finder<BackReferenceType>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<BackReferenceType>::registration);
}
template<class A0,class A1,class A2,class A3>
value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3)
@@ -51,8 +51,8 @@ value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3)
,(typename unforward<A2>::type)(a2)
,(typename unforward<A3>::type)(a3))
{
void const*x=&instance_finder<BackReferenceType>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<BackReferenceType>::registration);
}
template<class A0,class A1,class A2,class A3,class A4>
value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4)
@@ -63,8 +63,8 @@ value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4)
,(typename unforward<A3>::type)(a3)
,(typename unforward<A4>::type)(a4))
{
void const*x=&instance_finder<BackReferenceType>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<BackReferenceType>::registration);
}
template<class A0,class A1,class A2,class A3,class A4,class A5>
value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5)
@@ -76,8 +76,8 @@ value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5)
,(typename unforward<A4>::type)(a4)
,(typename unforward<A5>::type)(a5))
{
void const*x=&instance_finder<BackReferenceType>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<BackReferenceType>::registration);
}
template<class A0,class A1,class A2,class A3,class A4,class A5,class A6>
value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6)
@@ -90,8 +90,8 @@ value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6
,(typename unforward<A5>::type)(a5)
,(typename unforward<A6>::type)(a6))
{
void const*x=&instance_finder<BackReferenceType>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<BackReferenceType>::registration);
}
template<class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7>
value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7)
@@ -105,8 +105,8 @@ value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6
,(typename unforward<A6>::type)(a6)
,(typename unforward<A7>::type)(a7))
{
void const*x=&instance_finder<BackReferenceType>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<BackReferenceType>::registration);
}
template<class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8>
value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8)
@@ -121,8 +121,8 @@ value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6
,(typename unforward<A7>::type)(a7)
,(typename unforward<A8>::type)(a8))
{
void const*x=&instance_finder<BackReferenceType>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<BackReferenceType>::registration);
}
template<class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9>
value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9)
@@ -138,8 +138,8 @@ value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6
,(typename unforward<A8>::type)(a8)
,(typename unforward<A9>::type)(a9))
{
void const*x=&instance_finder<BackReferenceType>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<BackReferenceType>::registration);
}
template<class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9,class A10>
value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9,A10 a10)
@@ -156,8 +156,8 @@ value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6
,(typename unforward<A9>::type)(a9)
,(typename unforward<A10>::type)(a10))
{
void const*x=&instance_finder<BackReferenceType>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<BackReferenceType>::registration);
}
template<class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9,class A10,class A11>
value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9,A10 a10,A11 a11)
@@ -175,8 +175,8 @@ value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6
,(typename unforward<A10>::type)(a10)
,(typename unforward<A11>::type)(a11))
{
void const*x=&instance_finder<BackReferenceType>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<BackReferenceType>::registration);
}
template<class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9,class A10,class A11,class A12>
value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9,A10 a10,A11 a11,A12 a12)
@@ -195,8 +195,8 @@ value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6
,(typename unforward<A11>::type)(a11)
,(typename unforward<A12>::type)(a12))
{
void const*x=&instance_finder<BackReferenceType>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<BackReferenceType>::registration);
}
template<class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9,class A10,class A11,class A12,class A13>
value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9,A10 a10,A11 a11,A12 a12,A13 a13)
@@ -216,8 +216,8 @@ value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6
,(typename unforward<A12>::type)(a12)
,(typename unforward<A13>::type)(a13))
{
void const*x=&instance_finder<BackReferenceType>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<BackReferenceType>::registration);
}
template<class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9,class A10,class A11,class A12,class A13,class A14>
value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9,A10 a10,A11 a11,A12 a12,A13 a13,A14 a14)
@@ -238,8 +238,8 @@ value_holder_back_reference(PyObject*p,A0 a0,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6
,(typename unforward<A13>::type)(a13)
,(typename unforward<A14>::type)(a14))
{
void const*x=&instance_finder<BackReferenceType>::registration;
(void)x;
python::detail::force_instantiate(
instance_finder<BackReferenceType>::registration);
}
#endif // VALUE_HOLDER_BACK_REFERENCE_DWA2002411_HPP

View File

@@ -10,6 +10,7 @@
# include <boost/python/object/pointer_holder.hpp>
# include <boost/python/object/class_object.hpp>
# include <boost/python/detail/unwind_type.hpp>
# include <boost/python/detail/none.hpp>
# include <boost/shared_ptr.hpp>
# include <memory>

View File

@@ -66,7 +66,7 @@ namespace
};
// A SlotPolicy for extracting integer types from Python objects
struct int_rvalue_from_python
struct int_rvalue_from_python_base
{
static unaryfunc* get_slot(PyObject* obj)
{
@@ -84,20 +84,96 @@ namespace
return &number_methods->nb_int;
}
static long extract(PyObject* intermediate)
};
template <class T>
struct int_rvalue_from_python : int_rvalue_from_python_base
{
static T extract(PyObject* intermediate)
{
if (PyFloat_Check(intermediate))
{
return numeric_cast<long>(PyFloat_AS_DOUBLE(intermediate));
}
else
return numeric_cast<T>(
PyFloat_Check(intermediate)
? PyFloat_AS_DOUBLE(intermediate)
: PyInt_AS_LONG(intermediate)
);
}
};
#ifdef BOOST_HAS_LONG_LONG
// A SlotPolicy for extracting long long types from Python objects
struct long_long_rvalue_from_python_base
{
static unaryfunc* get_slot(PyObject* obj)
{
PyNumberMethods* number_methods = obj->ob_type->tp_as_number;
if (number_methods == 0)
return 0;
// For floating and integer types, return the identity
// conversion slot to avoid creating a new object. We'll
// handle that in the extract function
if (PyInt_Check(obj))
return &number_methods->nb_int;
if (PyFloat_Check(obj))
return &number_methods->nb_float;
if (PyInstance_Check(obj) && !PyObject_HasAttrString(obj, "__long__"))
return 0;
return &number_methods->nb_long;
}
};
struct long_long_rvalue_from_python : long_long_rvalue_from_python_base
{
static long long extract(PyObject* intermediate)
{
if (PyInt_Check(intermediate))
{
return PyInt_AS_LONG(intermediate);
}
if (PyFloat_Check(intermediate))
{
return numeric_cast<long long>(PyFloat_AS_DOUBLE(intermediate));
}
else
{
long long result = PyLong_AsLongLong(intermediate);
if (PyErr_Occurred())
throw_error_already_set();
return result;
}
}
};
struct unsigned_long_long_rvalue_from_python : long_long_rvalue_from_python_base
{
static unsigned long long extract(PyObject* intermediate)
{
if (PyInt_Check(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));
}
else
{
unsigned long long result = PyLong_AsUnsignedLongLong(intermediate);
if (PyErr_Occurred())
throw_error_already_set();
return result;
}
}
};
#endif
// identity_unaryfunc/py_object_identity -- manufacture a unaryfunc
// "slot" which just returns its argument. Used for bool
@@ -177,9 +253,10 @@ namespace
};
// identity_unaryfunc/non_null -- manufacture a unaryfunc "slot"
// which just returns its argument. Used for bool conversions, since
// all Python objects are directly convertible to bool
// to_complex_unaryfunc/py_object_to_complex -- manufacture a
// unaryfunc "slot" which calls its argument's __complex__
// method. We have this because there's no type object nb_complex
// slot.
extern "C" PyObject* to_complex_unaryfunc(PyObject* x)
{
return PyObject_CallMethod(x, "__complex__", const_cast<char*>("()"));
@@ -233,22 +310,22 @@ namespace
};
}
BOOST_PYTHON_DECL PyObject* do_call_to_python(char x)
BOOST_PYTHON_DECL PyObject* do_return_to_python(char x)
{
return PyString_FromStringAndSize(&x, 1);
}
BOOST_PYTHON_DECL PyObject* do_call_to_python(char const* x)
BOOST_PYTHON_DECL PyObject* do_return_to_python(char const* x)
{
return x ? PyString_FromString(x) : boost::python::detail::none();
}
BOOST_PYTHON_DECL PyObject* do_call_to_python(PyObject* x)
BOOST_PYTHON_DECL PyObject* do_return_to_python(PyObject* x)
{
return x ? x : boost::python::detail::none();
}
BOOST_PYTHON_DECL PyObject* do_callback_to_python(PyObject* x)
BOOST_PYTHON_DECL PyObject* do_arg_to_python(PyObject* x)
{
if (x == 0)
return boost::python::detail::none();
@@ -257,7 +334,7 @@ BOOST_PYTHON_DECL PyObject* do_callback_to_python(PyObject* x)
return x;
}
#define REGISTER_INT_CONVERTERS(U) slot_rvalue_from_python<U,int_rvalue_from_python>()
#define REGISTER_INT_CONVERTERS(U) slot_rvalue_from_python<U,int_rvalue_from_python<U> >()
#define REGISTER_INT_CONVERTERS2(U) REGISTER_INT_CONVERTERS(signed U); REGISTER_INT_CONVERTERS(unsigned U)
void initialize_builtin_converters()
@@ -270,7 +347,12 @@ void initialize_builtin_converters()
REGISTER_INT_CONVERTERS2(short);
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>();
# endif
// floating types
slot_rvalue_from_python<float,float_rvalue_from_python>();
slot_rvalue_from_python<double,float_rvalue_from_python>();

View File

@@ -4,7 +4,7 @@
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#include <boost/python/converter/callback_to_python_base.hpp>
#include <boost/python/converter/arg_to_python_base.hpp>
#include <boost/python/errors.hpp>
#include <boost/python/converter/find_from_python.hpp>
#include <boost/python/reference.hpp>
@@ -33,9 +33,9 @@ namespace detail
}
}
callback_to_python_base::callback_to_python_base(
arg_to_python_base::arg_to_python_base(
void const volatile* source, to_python_function_t converter)
: callback_to_python_holder(convert(source, converter))
: arg_to_python_holder(convert(source, converter))
{
}

View File

@@ -9,6 +9,7 @@
#endif
#include <boost/python/errors.hpp>
#include <boost/cast.hpp>
namespace boost { namespace python {
@@ -28,6 +29,10 @@ BOOST_PYTHON_DECL bool handle_exception_impl(function0<void> f)
{
PyErr_NoMemory();
}
catch(const bad_numeric_cast& x)
{
PyErr_SetString(PyExc_OverflowError, x.what());
}
catch(const std::exception& x)
{
PyErr_SetString(PyExc_RuntimeError, x.what());

View File

@@ -91,6 +91,11 @@ char apply_char_char(PyObject* f, char c)
return call<char>(f, c);
}
char const* apply_to_string_literal(PyObject* f)
{
return call<char const*>(f, "hello, world");
}
int X::counter;
BOOST_PYTHON_MODULE_INIT(callbacks_ext)
@@ -113,6 +118,7 @@ BOOST_PYTHON_MODULE_INIT(callbacks_ext)
.def("apply_cstring_cstring", apply_cstring_cstring)
.def("apply_cstring_pyobject", apply_cstring_pyobject)
.def("apply_char_char", apply_char_char)
.def("apply_to_string_literal", apply_to_string_literal)
.add(
class_<X>("X")

View File

@@ -11,6 +11,13 @@
>>> def identity(x):
... return x
Once we have array conversion support, this test will fail. Er,
succeed<wink>:
>>> try: apply_to_string_literal(identity)
... except: pass # expected
... else: print 'expected an exception!'
>>> x = apply_X_X(identity, X(42))
>>> x.value()
42

View File

@@ -79,12 +79,23 @@ are a complicated constructor and member function, respectively.
>>> c2.get_n()
0
a quick regression test for a bug where None could be converted
to the target of any member function. To see it, we need to
access the __dict__ directly, to bypass the type check supplied
by the Method property which wraps the method when accessed as an
attribute.
>>> try: A.__dict__['name'](None)
... except TypeError: pass
... else: print 'expected an exception!'
>>> a = A()
>>> b = B()
>>> c = C()
>>> d = D()
------
>>> take_a(a).name()
'A'

View File

@@ -1,4 +1,4 @@
#include <boost/python/converter/from_python.hpp>
#include <boost/python/converter/arg_from_python.hpp>
#include <boost/python/type_id.hpp>
#include <iostream>
@@ -28,128 +28,128 @@ int main()
ASSERT_SAME(
select_from_python<int>::type, rvalue_from_python<int>
select_arg_from_python<int>::type, arg_rvalue_from_python<int>
);
ASSERT_SAME(
select_from_python<int const>::type, rvalue_from_python<int const>
select_arg_from_python<int const>::type, arg_rvalue_from_python<int const>
);
ASSERT_SAME(
select_from_python<int volatile>::type, rvalue_from_python<int volatile>
select_arg_from_python<int volatile>::type, arg_rvalue_from_python<int volatile>
);
ASSERT_SAME(
select_from_python<int const volatile>::type, rvalue_from_python<int const volatile>
select_arg_from_python<int const volatile>::type, arg_rvalue_from_python<int const volatile>
);
ASSERT_SAME(
select_from_python<int*>::type, pointer_from_python<int*>
select_arg_from_python<int*>::type, pointer_arg_from_python<int*>
);
ASSERT_SAME(
select_from_python<int const*>::type, pointer_from_python<int const*>
select_arg_from_python<int const*>::type, pointer_arg_from_python<int const*>
);
ASSERT_SAME(
select_from_python<int volatile*>::type, pointer_from_python<int volatile*>
select_arg_from_python<int volatile*>::type, pointer_arg_from_python<int volatile*>
);
ASSERT_SAME(
select_from_python<int const volatile*>::type, pointer_from_python<int const volatile*>
select_arg_from_python<int const volatile*>::type, pointer_arg_from_python<int const volatile*>
);
ASSERT_SAME(
select_from_python<int&>::type, reference_from_python<int&>
select_arg_from_python<int&>::type, reference_arg_from_python<int&>
);
ASSERT_SAME(
select_from_python<int const&>::type, rvalue_from_python<int const&>
select_arg_from_python<int const&>::type, arg_rvalue_from_python<int const&>
);
ASSERT_SAME(
select_from_python<int volatile&>::type, reference_from_python<int volatile&>
select_arg_from_python<int volatile&>::type, reference_arg_from_python<int volatile&>
);
ASSERT_SAME(
select_from_python<int const volatile&>::type, reference_from_python<int const volatile&>
select_arg_from_python<int const volatile&>::type, reference_arg_from_python<int const volatile&>
);
ASSERT_SAME(
select_from_python<int*&>::type, reference_from_python<int*&>
select_arg_from_python<int*&>::type, reference_arg_from_python<int*&>
);
ASSERT_SAME(
select_from_python<int const*&>::type, reference_from_python<int const*&>
select_arg_from_python<int const*&>::type, reference_arg_from_python<int const*&>
);
ASSERT_SAME(
select_from_python<int volatile*&>::type, reference_from_python<int volatile*&>
select_arg_from_python<int volatile*&>::type, reference_arg_from_python<int volatile*&>
);
ASSERT_SAME(
select_from_python<int const volatile*&>::type, reference_from_python<int const volatile*&>
select_arg_from_python<int const volatile*&>::type, reference_arg_from_python<int const volatile*&>
);
ASSERT_SAME(
select_from_python<int* const&>::type, pointer_const_reference_from_python<int*const&>
select_arg_from_python<int* const&>::type, pointer_cref_arg_from_python<int*const&>
);
ASSERT_SAME(
select_from_python<int const* const&>::type, pointer_const_reference_from_python<int const*const&>
select_arg_from_python<int const* const&>::type, pointer_cref_arg_from_python<int const*const&>
);
ASSERT_SAME(
select_from_python<int volatile* const&>::type, pointer_const_reference_from_python<int volatile*const&>
select_arg_from_python<int volatile* const&>::type, pointer_cref_arg_from_python<int volatile*const&>
);
ASSERT_SAME(
select_from_python<int const volatile* const&>::type, pointer_const_reference_from_python<int const volatile*const&>
select_arg_from_python<int const volatile* const&>::type, pointer_cref_arg_from_python<int const volatile*const&>
);
ASSERT_SAME(
select_from_python<int*volatile&>::type, reference_from_python<int*volatile&>
select_arg_from_python<int*volatile&>::type, reference_arg_from_python<int*volatile&>
);
ASSERT_SAME(
select_from_python<int const*volatile&>::type, reference_from_python<int const*volatile&>
select_arg_from_python<int const*volatile&>::type, reference_arg_from_python<int const*volatile&>
);
ASSERT_SAME(
select_from_python<int volatile*volatile&>::type, reference_from_python<int volatile*volatile&>
select_arg_from_python<int volatile*volatile&>::type, reference_arg_from_python<int volatile*volatile&>
);
ASSERT_SAME(
select_from_python<int const volatile*volatile&>::type, reference_from_python<int const volatile*volatile&>
select_arg_from_python<int const volatile*volatile&>::type, reference_arg_from_python<int const volatile*volatile&>
);
ASSERT_SAME(
select_from_python<int*const volatile&>::type, reference_from_python<int*const volatile&>
select_arg_from_python<int*const volatile&>::type, reference_arg_from_python<int*const volatile&>
);
ASSERT_SAME(
select_from_python<int const*const volatile&>::type, reference_from_python<int const*const volatile&>
select_arg_from_python<int const*const volatile&>::type, reference_arg_from_python<int const*const volatile&>
);
ASSERT_SAME(
select_from_python<int volatile*const volatile&>::type, reference_from_python<int volatile*const volatile&>
select_arg_from_python<int volatile*const volatile&>::type, reference_arg_from_python<int volatile*const volatile&>
);
ASSERT_SAME(
select_from_python<int const volatile*const volatile&>::type, reference_from_python<int const volatile*const volatile&>
select_arg_from_python<int const volatile*const volatile&>::type, reference_arg_from_python<int const volatile*const volatile&>
);
return result;
}

View File

@@ -41,6 +41,10 @@ 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)
#endif
.def("rewrap_value_float", by_value<float>::rewrap)
.def("rewrap_value_double", by_value<double>::rewrap)
.def("rewrap_value_long_double", by_value<long double>::rewrap)
@@ -64,6 +68,10 @@ 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)
#endif
.def("rewrap_const_reference_float", by_const_reference<float>::rewrap)
.def("rewrap_const_reference_double", by_const_reference<double>::rewrap)
.def("rewrap_const_reference_long_double", by_const_reference<long double>::rewrap)

View File

@@ -1,5 +1,13 @@
"""
>>> from builtin_converters import *
# Synthesize idendity functions in case long long not supported
>>> if not 'rewrap_value_long_long' in dir():
... def rewrap_value_long_long(x): return long(x)
... def rewrap_value_unsigned_long_long(x): return long(x)
... def rewrap_const_reference_long_long(x): return long(x)
... def rewrap_const_reference_unsigned_long_long(x): return long(x)
>>> rewrap_value_bool(None)
0
>>> rewrap_value_bool(0)
@@ -30,6 +38,21 @@
42
>>> rewrap_value_unsigned_long(42)
42
>>> rewrap_value_long_long(42)
42L
>>> rewrap_value_unsigned_long_long(42)
42L
show that we have range checking.
>>> try: rewrap_value_unsigned_short(-42)
... except OverflowError: pass
... else: print 'expected an OverflowError!'
>>> try: rewrap_value_int(must_be_long)
... except OverflowError: pass
... else: print 'expected an OverflowError!'
>>> abs(rewrap_value_float(4.2) - 4.2) < .000001
1
@@ -86,6 +109,11 @@
42
>>> rewrap_const_reference_unsigned_long(42)
42
>>> rewrap_const_reference_long_long(42)
42L
>>> rewrap_const_reference_unsigned_long_long(42)
42L
>>> abs(rewrap_const_reference_float(4.2) - 4.2) < .000001
1
@@ -153,6 +181,14 @@ Check that classic classes also work
1
"""
# compute a long value that's too big for an int
# note that some day these may be integrated, so
big_int = 1
while (big_int << 1) > 0:
big_int <<= 1
must_be_long = long(big_int) << 1
def run(args = None):
import sys
import doctest

427
todo.txt
View File

@@ -1,426 +1,11 @@
Check for const reference parameters in all from_python functions in py.h, including implementations.
Better python and C++ exception handling/error reporting.
long long support
use Python generic numeric coercion in from_python() for C++ numeric types
Rename PyPtr to Reference.
Report Cygwin linker memory issues
__init__ stuff
Make abstract classes non-instantiable (?)
Call default __init__ functions automatically where applicable (?)
Support for Python LONG types in Objects.h
Throw TypeError after asserting when objects from objects.cpp detect a type mismatch.
Figure out how to package everything as a shared library.
Unicode string support
Add read-only wrapper for __dict__ attribute
Objects.h support for generic objects, Sequence objects, etc.
empty() member functions for objects.hpp
Wrap enums as a subclass of Python int
Testing
Python 2.0
object revival in __del__
More thorough tests of objects.h/cpp classes
Better reference-count checking
Write "inside the Python type system", a survey of typeobject.c in
Python source -- may go hand-in-hand with enum wrapping
Optimizations
Remove one level of indirection on type objects (no vtbl?).
Specializations of Caller<> for commmon combinations of argument types (?)
Replace uses of XXXable classes
Don't allocate instance __dict__ unless used.
Documentation:
Better overload resolution - choose best match
differences between Python classes and ExtensionClasses
additional capabilities of ExtensionClasses
slice adjustment
Implement type_info streaming for GCC
(http://mail.python.org/pipermail/c++-sig/2002-June/001277.html)
Why special attributes other than __doc__ and __name__ are immutable.
An example of the problems with the built-in Python classes.
>>> class A:
... def __getattr__(self, name):
... return 'A.__getattr__'
...
>>> class B(A): pass
...
>>> class C(B): pass
...
>>> C().x
'A.__getattr__'
>>> B.__bases__ = ()
>>> C().x
'A.__getattr__'
Smart pointers
#ifndef PY_NO_INLINE_FRIENDS_IN_NAMESPACE
namespace py {
#endif
template <class T>
struct VtkConverters
{
typedef py::PyExtensionClassConverters<T> Converters;
friend vtk_ptr<T>& from_python(PyObject* p, py::Type<vtk_ptr<T>&>)
{ return Converters::ptr_from_python(p, py::Type<vtk_ptr<T> >()); }
friend vtk_ptr<T>& from_python(PyObject* p, py::Type<vtk_ptr<T> >)
{ return Converters::ptr_from_python(p, py::Type<vtk_ptr<T> >()); }
friend const vtk_ptr<T>& from_python(PyObject* p, py::Type<const vtk_ptr<T>&>)
{ return Converters::ptr_from_python(p, py::Type<vtk_ptr<T> >()); }
friend PyObject* to_python(vtk_ptr<T> x)
{ return Converters::ptr_to_python(x); }
};
#ifndef PY_NO_INLINE_FRIENDS_IN_NAMESPACE
}
#endif
template <class T>
struct VtkWrapper : py::ClassWrapper<T>, py::VtkConverters<T>
{
typedef py::ClassWrapper<T> Base;
VtkWrapper(Module& module, const char* name)
: Base(module, name) {}
};
exception handling
Advanced Topics:
Advanced Type Conversion
adding conversions for fundamental types
generic conversions for template types (with partial spec).
Interacting with built-in Python objects and types from C++
dealing with non-const reference/pointer parameters
extending multiple-argument support using gen_all.py
Fancy wrapping tricks
templates
Yes. If you look at the examples in extclass_demo.cpp you'll see that I have
exposed several template instantiations (e.g. std::pair<int,int>) in Python.
Keep in mind, however, that you can only expose a template instantiation,
not a template. In other words, MyTemplate<Foo> can be exposed. MyTemplate
itself cannot.
Well, that's not strictly true. Wow, this is more complicated to explain
than I thought.
You can't make an ExtensionClass<MyTemplate>, since after all MyTemplate is
not a type. You can only expose a concrete type to Python.
What you *can* do (if your compiler supports partial ordering of function
templates - MSVC is broken and does not) is to write appropriate
from_python() and to_python() functions for converting a whole class of
template instantiations to/from Python. That won't let you create an
instance of MyTemplate<SomePythonType> from Python, but it will let you
pass/return arbitrary MyTemplate<SomeCplusplusType> instances to/from your
wrapped C++ functions.
template <class T>
MyTemplate<T> from_python(PyObject* x, py::Type<MyTemplate<T> >)
{
// code to convert x into a MyTemplate<T>... that part is up to you
}
template <class T>
PyObject* from_python(const MyTemplate<T>&)
{
// code to convert MyTemplate<T> into a PyObject*... that part is up to
you
}
For example, you could use this to convert Python lists to/from
std::vector<T> automatically.
Pointer return values
Case 1:
> I am now also able to wrap the problematic TextRecordIterator for Python.
> However, one of its function compiles with this warning:
>
> d:\py_cpp/caller.h(33) : warning C4800: 'const class Record *const '
> : forcing value to bool 'true' or 'false' (performance warning)
> d:\py_cpp/functions.h(54) : see reference to function template
> instantiation 'struct _object *__cdecl py::Caller::call(const class Record
> *const (__thiscall TextRecordIterator::*)(void),struct _object *,struct
> _object *)' being compiled
>
> If you look at the offending code, you'll see that we really do need to
> get back that pointer:
>
> const Record* const TextRecordIterator::Next() {
> if (fStatus != RecordIterator::SUCCESS) {
> return 0;
> } else {
> return &fData;
> }
> }
>
> The point of the TextRecordIterator is to hand over one reord after
> another. A bool wouldn't do us much good here :-)
>
> Do you have any suggestions for fixing this?
In general, py_cpp doesn't automatically convert pointer return values
to_python because pointers have too many potential meanings. Is it an
iterator? A pointer to a single element? An array? Is ownership being passed
to Python or is the pointer really just a reference? If the latter, what
happens when some C++ code deletes the referent. The only exception to this
rule is const char*, since it has a generally accepted interpretation (could
be trouble with some generic code, though!)
If you have wrapped the Record class, you could add this to namespace py:
PyObject* to_python(const Record* p) {
return to_python(*p);
}
Of course, this will cause the Record class to be copied. If you can't live
with that (Record would have to be /really/ heavyweight to make this
worthwhile), you can follow one of these dangerous approaches:
1. Use the technique I described with dangerous_array in
http://www.egroups.com/message/boost/6196. You do not have to expose Record
explicitly in this case. Instead the class you expose will be more of a
Record_proxy
2. Wrap Record in the usual way, then add the following to namespace py:
PyObject* to_python(const Record* p)
{
return ExtensionClass<Record>::ptr_to_python(const_cast<Record*>(p));
}
This will cause the Record* to be treated as though it were an owning smart
pointer, even though it's not. Be sure you don't use the reference for
anything from Python once the pointer becomes invalid, though. Don't worry
too much about the const-correctness issue: Const-correctness is completely
lost to Python anyway!
3. As above, but instead wrap const Record rather than plain Record. Then
you can avoid the const_cast, but you obviously can't def() any non-const
member functions of Record.
Case 2:
> I have yet another question. This is more a general wrapper question.
> Let me say that there is a function that returns a float* which most
> probably is an array. Similarly if I have a function that takes a
> float* as an argument, what is the best way of wrapping this?
I think you have correctly perceived that it doesn't make sense for me to
automatically convert all pointers, since the ownership semantics are so
blurry.
> 1) If the array is small it makes sense to convert it to either a
> tuple or list. What is the easiest way to do this?? I am looking
> for a way that makes one write the least code. :)
How can you tell the length of the array from a single pointer?
Once you've answered that question, you can expose a wrapper function which
returns an instance of the py::Tuple or py::List class from objects.h. If
you are using a List, for example, you could write something like this:
py::List wrap_f()
{
T* start = f();
py::List x;
for (T* p = start; p != start + length_constant; ++p)
x.push_back(py::to_python(*p));
return x;
}
> 2) If the array is large it may not make sense to use a list/tuple
> esp. if the values are used for computationally intense programs.
In this case you can do one of several somewhat dangerous things. Why
dangerous? Because python can not control the lifetime of the data, so the
data in the array may be destroyed or become invalid before the last
reference to it disappears. The basic approach is to make a small C++ class
which contains the pointer, and expose that:
// UNTESTED
template <class T>
struct dangerous_array
{
dangerous_array(T* start, T* end)
: m_start(start), m_end(end) {}
// exposed as "__len__"
std::size_t length() {
return m_end - m_start;
}
// exposed as "__getitem__"
T get_item(std::size_t n) {
check_range(n);
return start[n];
}
// exposed as "__setitem__" if the array is mutable
void set_item(std::size_t n, const T& x) {
check_range(n);
start[n] = x;
}
private:
void check_range(std::size_t n) {
if (n >= m_end - m_start) {
PyErr_SetString(PyExc_IndexError, "array index out of range");
throw py::ErrorAlreadySet;
}
}
T* m_start;
T* m_end;
};
A reasonably safe approach would be to make a wrapper function for each
function that returns a T*, and expose that instead. If you're too lazy and
you really like to live on the edge, though, you can write to_python(T*) in
terms of to_python(const dangerous_array<T>&), and you'll automatically
convert all T* return values to a wrapped dangerous_array.
> 3) For an arbitrary class "class_A", say, can py_cpp handle
> references to class_A &instance, or class_A *instance?? i.e. will it
> wrap function calls to such objects? This question is obviously
> related to the earlier questions.
Yes, iff class_A has been exposed to python with a ClassWrapper<class_A>.
See http://people.ne.mediaone.net/abrahams/downloads/under-the-hood.html for
a few details.
raw C++ arrays
You could expose a function like this one to get the desired effect:
#include <py_cpp/objects.h>
void set_len(UnitCell& x, py::Tuple tuple)
{
double len[3];
for (std::size_t i =0; i < 3; ++i)
len[i] = py::from_python(tuple[i].get(), py::Type<double>());
x.set_len(len);
}
Types that are already wrapped by other libraries
It's not documented yet, but you should be able to use a raw PyObject* or a
py::Ptr as one parameter to your C++ function. Then you can manipulate it as
any other generic Python object.
Alternatively, If the NTL gives you a C/C++ interface, you can also write
your own converter function:
some_ntl_type& from_python(PyObject* p, py::Type<some_NTL_type&>)
{
// an Example implementation. Basically, you need
// to extract the NTL type from the PyObject*.
if (p->ob_type != NTL_long_type) {
PyErr_SetString(PyExc_TypeErr, "NTL long required");
throw py::ArgumentError();
}
return *static_cast<some_NTL_type*>(p);
}
then the C++ functions you're wrapping can take a some_NTL_type& parameter
directly.
"Thin converting wrappers" for constructors
hijack some of the functionality
described in the section on Overridable Virtual Functions (even though you
don't have any virtual functions). I suggest this workaround:
struct UnitCellWrapper : UnitCell
{
UnitCellWrapper(PyObject* self, py::Tuple x, py::Tuple y)
: UnitCell(from_python(x[1], py::Type<double>()),
from_python(x[2], py::Type<double>()),
from_python(x[3], py::Type<double>()),
from_python(y[1], py::Type<double>()),
from_python(y[2], py::Type<double>()),
from_python(y[3], py::Type<double>()))
{}
}
py::ClassWrapper<UnitCell, UnitCellWrapper> unit_cell_class;
unit_cell_class.def(py::Constructor<py::Tuple, py::Tuple>());
...
returning references to wrapped objects
the importance of declaration order of ClassWrappers/ExtensionInstances
out parameters and non-const pointers
Calling back into Python:
// caveat: UNTESTED!
#include <py_cpp/pyptr.h>
#include <py_cpp/callback.h>
#include <py_cpp/py.h>
#include <Python.h>
int main()
{
try {
py::Ptr module(PyImport_ImportModule("weapons"));
const int strength = 10;
const char* manufacturer = "Vordon Empire";
py::Ptr a_blaster(py::Callback<py::Ptr>::call_method(
module.get(), "Blaster", strength, manufacturer));
py::Callback<void>::call_method(a_blaster.get(), "Fire");
int old_strength = py::Callback<int>::call_method(a_blaster.get(), "get_strength");
py::Callback<void>::call_method(a_blaster.get(), "set_strength", 5);
}
catch(...)
{
}
}
Miscellaneous
About the vc6 project and the debug build
About doctest.py
Boost remarks:
> > One of us is completely nuts ;->. How can I move the test
> > (is_prefix(enablers[i].name + 2, name + 2)) outside the loop if it
depends
> > on the loop index, i?
> >
> name += 2;
> for()
> {
> if (is_prefix(enablers[i].name + 2, name))
> }
I see now. I guess I should stop pussyfooting and either go for optimization
or clarity here, eh?
------
> Re: Dict
> Why abbreviate this? Code is read 5 or 6 times for every time its
> written. The few extra characters don't affect compile time or program
> speed. It's part of my personal goal of write what you mean, name them
what
> they are.
I completely agree. Abbrevs rub me the wrong way, 2 ;->
-------
Later:
keyword and varargs?
Put explicit Type<> arguments at the beginnings of overloads, to make them look more like template instance specifications.
Known bugs
can't handle 'const void' return values
Who returns 'const void'? I did it once, by mistake ;)