Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/python/object/class_wrapper.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright David Abrahams 2001.
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 CLASS_WRAPPER_DWA20011221_HPP
0006 # define CLASS_WRAPPER_DWA20011221_HPP
0007 
0008 # include <boost/python/to_python_converter.hpp>
0009 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
0010 # include <boost/python/converter/pytype_function.hpp>
0011 #endif
0012 # include <boost/ref.hpp>
0013 
0014 namespace boost { namespace python { namespace objects { 
0015 
0016 //
0017 // These two classes adapt the static execute function of a class
0018 // MakeInstance execute() function returning a new PyObject*
0019 // reference. The first one is used for class copy constructors, and
0020 // the second one is used to handle smart pointers.
0021 //
0022 
0023 template <class Src, class MakeInstance>
0024 struct class_cref_wrapper
0025     : to_python_converter<Src,class_cref_wrapper<Src,MakeInstance> ,true>
0026 {
0027     static PyObject* convert(Src const& x)
0028     {
0029         return MakeInstance::execute(boost::ref(x));
0030     }
0031 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
0032     static PyTypeObject const *get_pytype() { return converter::registered_pytype_direct<Src>::get_pytype(); }
0033 #endif
0034 };
0035 
0036 template <class Src, class MakeInstance>
0037 struct class_value_wrapper
0038     : to_python_converter<Src,class_value_wrapper<Src,MakeInstance> ,true>
0039 {
0040     static PyObject* convert(Src x)
0041     {
0042         return MakeInstance::execute(x);
0043     }
0044 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
0045     static PyTypeObject const *get_pytype() { return MakeInstance::get_pytype(); }
0046 #endif
0047 };
0048 
0049 }}} // namespace boost::python::objects
0050 
0051 #endif // CLASS_WRAPPER_DWA20011221_HPP