source: NonGTP/Boost/boost/python/arg_from_python.hpp @ 857

Revision 857, 2.0 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[857]1// Copyright David Abrahams 2002.
2// Distributed under the Boost Software License, Version 1.0. (See
3// accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5#ifndef ARG_FROM_PYTHON_DWA2002128_HPP
6# define ARG_FROM_PYTHON_DWA2002128_HPP
7
8# include <boost/python/detail/prefix.hpp>
9# include <boost/python/converter/arg_from_python.hpp>
10# if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) \
11    || BOOST_WORKAROUND(BOOST_INTEL_WIN, BOOST_TESTED_AT(800))
12# include <boost/type_traits/remove_cv.hpp>
13#endif
14
15namespace boost { namespace python {
16
17template <class T>
18struct arg_from_python
19    : converter::select_arg_from_python<
20# if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) \
21    || BOOST_WORKAROUND(BOOST_INTEL_WIN, BOOST_TESTED_AT(800))
22          typename boost::remove_cv<T>::type
23# else
24          T
25# endif
26      >::type
27{
28    typedef typename converter::select_arg_from_python<
29# if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) \
30    || BOOST_WORKAROUND(BOOST_INTEL_WIN, BOOST_TESTED_AT(800))
31          typename boost::remove_cv<T>::type
32# else
33          T
34# endif
35        >::type base;
36   
37    arg_from_python(PyObject*);
38};
39
40// specialization for PyObject*
41template <>
42struct arg_from_python<PyObject*>
43{
44    typedef PyObject* result_type;
45   
46    arg_from_python(PyObject* p) : m_source(p) {}
47    bool convertible() const { return true; }
48    PyObject* operator()() const { return m_source; }
49 private:
50    PyObject* m_source;
51};
52
53template <>
54struct arg_from_python<PyObject* const&>
55{
56    typedef PyObject* const& result_type;
57   
58    arg_from_python(PyObject* p) : m_source(p) {}
59    bool convertible() const { return true; }
60    PyObject*const& operator()() const { return m_source; }
61 private:
62    PyObject* m_source;
63};
64
65//
66// implementations
67//
68template <class T>
69inline arg_from_python<T>::arg_from_python(PyObject* source)
70    : base(source)
71{
72}
73
74}} // namespace boost::python
75
76#endif // ARG_FROM_PYTHON_DWA2002128_HPP
Note: See TracBrowser for help on using the repository browser.