mirror of
https://github.com/boostorg/python.git
synced 2026-01-23 05:42:30 +00:00
Use PP lib
[SVN r13463]
This commit is contained in:
49
include/boost/python/call.hpp
Normal file
49
include/boost/python/call.hpp
Normal file
@@ -0,0 +1,49 @@
|
||||
// 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 CALL_DWA2002411_HPP
|
||||
# define CALL_DWA2002411_HPP
|
||||
|
||||
# include <boost/python/converter/callback.hpp>
|
||||
# include <boost/python/detail/preprocessor.hpp>
|
||||
# include <boost/preprocessor/comma_if.hpp>
|
||||
# include <boost/preprocessor/enum.hpp>
|
||||
# include <boost/preprocessor/enum_params.hpp>
|
||||
# include <boost/preprocessor/repeat.hpp>
|
||||
# include <boost/preprocessor/cat.hpp>
|
||||
# include <boost/type.hpp>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
# ifndef BOOST_PYTHON_GENERATE_CODE
|
||||
# include <boost/python/preprocessed/call.hpp>
|
||||
# endif
|
||||
|
||||
# define BOOST_PYTHON_CALL_FUNCTION(nargs,ignored) \
|
||||
template < \
|
||||
class R \
|
||||
BOOST_PP_COMMA_IF(nargs) BOOST_PP_ENUM_PARAMS(nargs, class A) \
|
||||
> \
|
||||
typename converter::callback_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; \
|
||||
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_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_CALL_FUNCTION,data)
|
||||
|
||||
}} // namespace boost::python
|
||||
|
||||
#endif // CALL_DWA2002411_HPP
|
||||
50
include/boost/python/call_method.hpp
Normal file
50
include/boost/python/call_method.hpp
Normal file
@@ -0,0 +1,50 @@
|
||||
// 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 CALL_METHOD_DWA2002411_HPP
|
||||
# define CALL_METHOD_DWA2002411_HPP
|
||||
|
||||
# include <boost/python/converter/callback.hpp>
|
||||
# include <boost/python/detail/preprocessor.hpp>
|
||||
# include <boost/preprocessor/comma_if.hpp>
|
||||
# include <boost/preprocessor/enum.hpp>
|
||||
# include <boost/preprocessor/enum_params.hpp>
|
||||
# include <boost/preprocessor/repeat.hpp>
|
||||
# include <boost/preprocessor/cat.hpp>
|
||||
# include <boost/type.hpp>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
# ifndef BOOST_PYTHON_GENERATE_CODE
|
||||
# include <boost/python/preprocessed/call_method.hpp>
|
||||
# endif
|
||||
|
||||
# define BOOST_PYTHON_CALL_METHOD_FUNCTION(nargs,ignored) \
|
||||
template < \
|
||||
class R \
|
||||
BOOST_PP_COMMA_IF(nargs) BOOST_PP_ENUM_PARAMS(nargs, class A) \
|
||||
> \
|
||||
typename converter::callback_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; \
|
||||
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_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_CALL_METHOD_FUNCTION,data)
|
||||
|
||||
}} // namespace boost::python
|
||||
|
||||
#endif // CALL_METHOD_DWA2002411_HPP
|
||||
@@ -17,6 +17,7 @@
|
||||
# include <boost/python/to_python_indirect.hpp>
|
||||
# include <boost/python/detail/none.hpp>
|
||||
# include <boost/python/ptr.hpp>
|
||||
# include <boost/python/errors.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace converter {
|
||||
|
||||
@@ -132,6 +133,33 @@ template <class T>
|
||||
struct callback_from_python
|
||||
: detail::select_callback_from_python<T>::type
|
||||
{
|
||||
typedef T result_type;
|
||||
};
|
||||
|
||||
struct void_result
|
||||
{
|
||||
private:
|
||||
void_result() {}
|
||||
void operator=(void_result const&);
|
||||
|
||||
// I would prefer to make this completely untouchable, but few
|
||||
// compilers support template friends
|
||||
# if 0
|
||||
void_result(void_result const&);
|
||||
# endif
|
||||
friend struct callback_from_python<void>;
|
||||
};
|
||||
|
||||
// Specialization as a convenience for call and call_method
|
||||
template <>
|
||||
struct callback_from_python<void>
|
||||
{
|
||||
typedef void_result result_type;
|
||||
result_type operator()(PyObject* x) const
|
||||
{
|
||||
Py_DECREF(expect_non_null(x));
|
||||
return result_type();
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
@@ -144,6 +172,14 @@ struct callback_to_python
|
||||
callback_to_python(T const& x);
|
||||
};
|
||||
|
||||
// Convenience macros for call<> and call_method<> code generation
|
||||
# define BOOST_PYTHON_CALLBACK_TO_PYTHON_GET(index,ignored) \
|
||||
converter::callback_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
|
||||
//
|
||||
|
||||
@@ -91,6 +91,8 @@ namespace boost { namespace python { namespace detail {
|
||||
|
||||
#define BOOST_PYTHON_ENUM_PARAMS2(N, Pair) BOOST_PP_ENUM(N, BOOST_PYTHON_NUMBER_PAIR, Pair)
|
||||
|
||||
# define BOOST_PYTHON_PROJECT_1ST(a1,a2) a1
|
||||
# define BOOST_PYTHON_PROJECT_2ND(a1,a2) a2
|
||||
|
||||
}}} // namespace boost::python::detail
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ struct pointer_holder_back_reference : instance_holder
|
||||
BOOST_PP_COMMA_IF(nargs) \
|
||||
BOOST_PYTHON_ENUM_PARAMS2(nargs, (A,a))) \
|
||||
: m_p(new held_type( \
|
||||
p, \
|
||||
p BOOST_PP_COMMA_IF(nargs) \
|
||||
BOOST_PP_ENUM(nargs, BOOST_PYTHON_UNFORWARD, nil) \
|
||||
)) \
|
||||
{ \
|
||||
|
||||
@@ -1,98 +1,101 @@
|
||||
// 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.
|
||||
//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 CALL_PP_DWA2002411_HPP
|
||||
# define CALL_PP_DWA2002411_HPP
|
||||
#define CALL_PP_DWA2002411_HPP
|
||||
|
||||
call(PyObject*self)
|
||||
:m_result(
|
||||
PyEval_CallFunction(self,const_cast<char*>("(" ")")))
|
||||
template<class R>
|
||||
typename converter::callback_from_python<R>::result_type call(PyObject*callable,boost::type<R>* =0)
|
||||
{
|
||||
|
||||
converter::callback_from_python<R>converter;
|
||||
return converter(
|
||||
PyEval_CallFunction(callable,const_cast<char*>("(" ")")));
|
||||
}
|
||||
template<class A0>
|
||||
call(PyObject*self,A0 const&a0)
|
||||
:m_result(
|
||||
PyEval_CallFunction(self,const_cast<char*>("(" "O" ")"),
|
||||
converter::callback_to_python<A0>(a0).get()))
|
||||
template<class R,class A0>
|
||||
typename converter::callback_from_python<R>::result_type call(PyObject*callable,A0 const&a0,boost::type<R>* =0)
|
||||
{
|
||||
|
||||
converter::callback_from_python<R>converter;
|
||||
return converter(
|
||||
PyEval_CallFunction(callable,const_cast<char*>("(" "O" ")"),
|
||||
converter::callback_to_python<A0>(a0).get()));
|
||||
}
|
||||
template<class A0,class A1>
|
||||
call(PyObject*self,A0 const&a0,A1 const&a1)
|
||||
:m_result(
|
||||
PyEval_CallFunction(self,const_cast<char*>("(" "O" "O" ")"),
|
||||
template<class R,class A0,class A1>
|
||||
typename converter::callback_from_python<R>::result_type call(PyObject*callable,A0 const&a0,A1 const&a1,boost::type<R>* =0)
|
||||
{
|
||||
converter::callback_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::callback_to_python<A1>(a1).get()));
|
||||
}
|
||||
template<class A0,class A1,class A2>
|
||||
call(PyObject*self,A0 const&a0,A1 const&a1,A2 const&a2)
|
||||
:m_result(
|
||||
PyEval_CallFunction(self,const_cast<char*>("(" "O" "O" "O" ")"),
|
||||
template<class R,class A0,class A1,class A2>
|
||||
typename converter::callback_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;
|
||||
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::callback_to_python<A2>(a2).get()));
|
||||
}
|
||||
template<class A0,class A1,class A2,class A3>
|
||||
call(PyObject*self,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3)
|
||||
:m_result(
|
||||
PyEval_CallFunction(self,const_cast<char*>("(" "O" "O" "O" "O" ")"),
|
||||
template<class R,class A0,class A1,class A2,class A3>
|
||||
typename converter::callback_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;
|
||||
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::callback_to_python<A3>(a3).get()));
|
||||
}
|
||||
template<class A0,class A1,class A2,class A3,class A4>
|
||||
call(PyObject*self,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4)
|
||||
:m_result(
|
||||
PyEval_CallFunction(self,const_cast<char*>("(" "O" "O" "O" "O" "O" ")"),
|
||||
template<class R,class A0,class A1,class A2,class A3,class A4>
|
||||
typename converter::callback_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;
|
||||
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::callback_to_python<A4>(a4).get()));
|
||||
}
|
||||
template<class A0,class A1,class A2,class A3,class A4,class A5>
|
||||
call(PyObject*self,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5)
|
||||
:m_result(
|
||||
PyEval_CallFunction(self,const_cast<char*>("(" "O" "O" "O" "O" "O" "O" ")"),
|
||||
template<class R,class A0,class A1,class A2,class A3,class A4,class A5>
|
||||
typename converter::callback_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;
|
||||
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::callback_to_python<A5>(a5).get()));
|
||||
}
|
||||
template<class A0,class A1,class A2,class A3,class A4,class A5,class A6>
|
||||
call(PyObject*self,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,A6 const&a6)
|
||||
:m_result(
|
||||
PyEval_CallFunction(self,const_cast<char*>("(" "O" "O" "O" "O" "O" "O" "O" ")"),
|
||||
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 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;
|
||||
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::callback_to_python<A6>(a6).get()));
|
||||
}
|
||||
template<class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7>
|
||||
call(PyObject*self,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A5 const&a5,A6 const&a6,A7 const&a7)
|
||||
:m_result(
|
||||
PyEval_CallFunction(self,const_cast<char*>("(" "O" "O" "O" "O" "O" "O" "O" "O" ")"),
|
||||
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 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;
|
||||
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(),
|
||||
@@ -100,14 +103,14 @@ call(PyObject*self,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A
|
||||
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<A7>(a7).get()));
|
||||
}
|
||||
template<class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8>
|
||||
call(PyObject*self,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)
|
||||
:m_result(
|
||||
PyEval_CallFunction(self,const_cast<char*>("(" "O" "O" "O" "O" "O" "O" "O" "O" "O" ")"),
|
||||
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 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;
|
||||
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(),
|
||||
@@ -116,10 +119,8 @@ call(PyObject*self,A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3,A4 const&a4,A
|
||||
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<A8>(a8).get()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // CALL_PP_DWA2002411_HPP
|
||||
#endif//CALL_PP_DWA2002411_HPP
|
||||
|
||||
147
include/boost/python/preprocessed/call_method.hpp
Normal file
147
include/boost/python/preprocessed/call_method.hpp
Normal file
@@ -0,0 +1,147 @@
|
||||
//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 CALL_METHOD_PP_DWA2002411_HPP
|
||||
# define CALL_METHOD_PP_DWA2002411_HPP
|
||||
|
||||
template<class R>typename
|
||||
converter::callback_from_python<R>::result_type
|
||||
call_method(PyObject*self,char const*name,boost::type<R>* =0)
|
||||
{
|
||||
|
||||
converter::callback_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
|
||||
call_method(PyObject*self,char const*name,A0 const&a0,boost::type<R>* =0)
|
||||
{
|
||||
|
||||
converter::callback_from_python<R>converter;
|
||||
return converter(
|
||||
PyEval_CallMethod(self,const_cast<char*>(name),const_cast<char*>("(" "O" ")"),
|
||||
converter::callback_to_python<A0>(a0).get()));
|
||||
}
|
||||
template<class R,class A0,class A1>typename
|
||||
converter::callback_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;
|
||||
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()));
|
||||
}
|
||||
template<class R,class A0,class A1,class A2>typename
|
||||
converter::callback_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;
|
||||
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()));
|
||||
}
|
||||
template<class R,class A0,class A1,class A2,class A3>typename
|
||||
converter::callback_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;
|
||||
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()));
|
||||
}
|
||||
template<class R,class A0,class A1,class A2,class A3,class A4>typename
|
||||
converter::callback_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;
|
||||
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()));
|
||||
}
|
||||
template<class R,class A0,class A1,class A2,class A3,class A4,class A5>typename
|
||||
converter::callback_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;
|
||||
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()));
|
||||
}
|
||||
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
|
||||
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;
|
||||
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()));
|
||||
}
|
||||
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
|
||||
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;
|
||||
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()));
|
||||
}
|
||||
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
|
||||
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;
|
||||
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()));
|
||||
}
|
||||
|
||||
|
||||
#endif//
|
||||
CALL_METHOD_PP_DWA2002411_HPP
|
||||
@@ -1,13 +1,13 @@
|
||||
// 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.
|
||||
//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 POINTER_HOLDER_BACK_REFERENCE_DWA2002411_HPP
|
||||
# define POINTER_HOLDER_BACK_REFERENCE_DWA2002411_HPP
|
||||
#define POINTER_HOLDER_BACK_REFERENCE_DWA2002411_HPP
|
||||
|
||||
pointer_holder_back_reference(PyObject*p)
|
||||
:m_p(new held_type(p,))
|
||||
:m_p(new held_type(p))
|
||||
{
|
||||
void const*x=&instance_finder<held_type>::registration;
|
||||
(void)x;
|
||||
@@ -111,5 +111,6 @@ template<class A0,class A1,class A2,class A3,class A4,class A5,class A6,class A7
|
||||
void const*x=&instance_finder<held_type>::registration;
|
||||
(void)x;
|
||||
}
|
||||
|
||||
|
||||
#endif // POINTER_HOLDER_BACK_REFERENCE_DWA2002411_HPP
|
||||
#endif//POINTER_HOLDER_BACK_REFERENCE_DWA2002411_HPP
|
||||
|
||||
@@ -4,23 +4,24 @@
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
#include <boost/python/module.hpp>
|
||||
#include <boost/python/returning.hpp>
|
||||
//#include <boost/python/returning.hpp>
|
||||
#include <boost/python/class.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/python/ptr.hpp>
|
||||
#include <boost/python/return_value_policy.hpp>
|
||||
#include <boost/python/reference_existing_object.hpp>
|
||||
#include <boost/python/call.hpp>
|
||||
|
||||
using namespace boost::python;
|
||||
|
||||
int apply_int_int(PyObject* f, int x)
|
||||
{
|
||||
return returning<int>::call(f, x);
|
||||
return call<int>(f, x);
|
||||
}
|
||||
|
||||
void apply_void_int(PyObject* f, int x)
|
||||
{
|
||||
returning<void>::call(f, x);
|
||||
call<void>(f, x);
|
||||
}
|
||||
|
||||
struct X
|
||||
@@ -42,52 +43,52 @@ struct X
|
||||
|
||||
X apply_X_X(PyObject* f, X x)
|
||||
{
|
||||
return returning<X>::call(f, x);
|
||||
return call<X>(f, x);
|
||||
}
|
||||
|
||||
void apply_void_X_ref(PyObject* f, X& x)
|
||||
{
|
||||
returning<void>::call(f, boost::ref(x));
|
||||
call<void>(f, boost::ref(x));
|
||||
}
|
||||
|
||||
X& apply_X_ref_pyobject(PyObject* f, PyObject* obj)
|
||||
{
|
||||
return returning<X&>::call(f, obj);
|
||||
return call<X&>(f, obj);
|
||||
}
|
||||
|
||||
X* apply_X_ptr_pyobject(PyObject* f, PyObject* obj)
|
||||
{
|
||||
return returning<X*>::call(f, obj);
|
||||
return call<X*>(f, obj);
|
||||
}
|
||||
|
||||
void apply_void_X_cref(PyObject* f, X const& x)
|
||||
{
|
||||
returning<void>::call(f, boost::cref(x));
|
||||
call<void>(f, boost::cref(x));
|
||||
}
|
||||
|
||||
void apply_void_X_ptr(PyObject* f, X* x)
|
||||
{
|
||||
returning<void>::call(f, ptr(x));
|
||||
call<void>(f, ptr(x));
|
||||
}
|
||||
|
||||
void apply_void_X_deep_ptr(PyObject* f, X* x)
|
||||
{
|
||||
returning<void>::call(f, x);
|
||||
call<void>(f, x);
|
||||
}
|
||||
|
||||
char const* apply_cstring_cstring(PyObject* f, char const* s)
|
||||
{
|
||||
return returning <char const*>::call(f, s);
|
||||
return call<char const*>(f, s);
|
||||
}
|
||||
|
||||
char const* apply_cstring_pyobject(PyObject* f, PyObject* s)
|
||||
{
|
||||
return returning <char const*>::call(f, s);
|
||||
return call<char const*>(f, s);
|
||||
}
|
||||
|
||||
char apply_char_char(PyObject* f, char c)
|
||||
{
|
||||
return returning <char>::call(f, c);
|
||||
return call<char>(f, c);
|
||||
}
|
||||
|
||||
int X::counter;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// to its suitability for any purpose.
|
||||
#include <boost/python/class.hpp>
|
||||
#include <boost/python/module.hpp>
|
||||
#include <boost/python/returning.hpp>
|
||||
#include <boost/python/call_method.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/utility.hpp>
|
||||
|
||||
@@ -55,7 +55,7 @@ struct abstract_callback : abstract
|
||||
|
||||
int f(Y const& y)
|
||||
{
|
||||
return returning<int>::call_method(self, "f", boost::ref(y));
|
||||
return call_method<int>(self, "f", boost::ref(y));
|
||||
}
|
||||
|
||||
PyObject* self;
|
||||
@@ -73,7 +73,7 @@ struct concrete_callback : concrete
|
||||
|
||||
int f(Y const& y)
|
||||
{
|
||||
return returning<int>::call_method(self, "f", boost::ref(y));
|
||||
return call_method<int>(self, "f", boost::ref(y));
|
||||
}
|
||||
|
||||
int f_impl(Y const& y)
|
||||
|
||||
Reference in New Issue
Block a user