Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:40

0001 // Copyright David Abrahams 2002.
0002 // Distributed under the Boost Software License, Version 1.0. (See
0003 // accompanying file LICENSE_1_0.txt or copy at
0004 // http://www.boost.org/LICENSE_1_0.txt)
0005 #ifndef ARG_FROM_PYTHON_DWA2002128_HPP
0006 # define ARG_FROM_PYTHON_DWA2002128_HPP
0007 
0008 # include <boost/python/detail/prefix.hpp>
0009 # include <boost/python/converter/arg_from_python.hpp>
0010 # if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) \
0011     || BOOST_WORKAROUND(BOOST_INTEL_WIN, BOOST_TESTED_AT(800))
0012 # include <boost/python/detail/type_traits.hpp>
0013 #endif
0014 
0015 namespace boost { namespace python { 
0016 
0017 template <class T>
0018 struct arg_from_python
0019     : converter::select_arg_from_python<
0020 # if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) \
0021     || BOOST_WORKAROUND(BOOST_INTEL_WIN, BOOST_TESTED_AT(800))
0022           typename detail::remove_cv<T>::type
0023 # else
0024           T
0025 # endif 
0026       >::type
0027 {
0028     typedef typename converter::select_arg_from_python<
0029 # if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) \
0030     || BOOST_WORKAROUND(BOOST_INTEL_WIN, BOOST_TESTED_AT(800))
0031           typename detail::remove_cv<T>::type
0032 # else
0033           T
0034 # endif 
0035         >::type base;
0036     
0037     arg_from_python(PyObject*);
0038 };
0039 
0040 // specialization for PyObject*
0041 template <>
0042 struct arg_from_python<PyObject*>
0043 {
0044     typedef PyObject* result_type;
0045     
0046     arg_from_python(PyObject* p) : m_source(p) {}
0047     bool convertible() const { return true; }
0048     PyObject* operator()() const { return m_source; }
0049  private:
0050     PyObject* m_source;
0051 };
0052 
0053 template <>
0054 struct arg_from_python<PyObject* const&>
0055 {
0056     typedef PyObject* const& result_type;
0057     
0058     arg_from_python(PyObject* p) : m_source(p) {}
0059     bool convertible() const { return true; }
0060     PyObject*const& operator()() const { return m_source; }
0061  private:
0062     PyObject* m_source;
0063 };
0064 
0065 //
0066 // implementations
0067 //
0068 template <class T>
0069 inline arg_from_python<T>::arg_from_python(PyObject* source)
0070     : base(source)
0071 {
0072 }
0073 
0074 }} // namespace boost::python
0075 
0076 #endif // ARG_FROM_PYTHON_DWA2002128_HPP