123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- #ifndef FROM_PYTHON_AUX_DATA_DWA2002128_HPP
- # define FROM_PYTHON_AUX_DATA_DWA2002128_HPP
- # include <boost/python/converter/constructor_function.hpp>
- # include <boost/python/detail/referent_storage.hpp>
- # include <boost/python/detail/destroy.hpp>
- # include <boost/python/detail/type_traits.hpp>
- # include <boost/align/align.hpp>
- # include <boost/static_assert.hpp>
- # include <cstddef>
- namespace boost { namespace python { namespace converter {
- struct rvalue_from_python_stage1_data
- {
- void* convertible;
- constructor_function construct;
- };
- template <class T>
- struct rvalue_from_python_storage
- {
- rvalue_from_python_stage1_data stage1;
-
- typename python::detail::referent_storage<
- typename boost::python::detail::add_lvalue_reference<T>::type
- >::type storage;
- };
- template <class T>
- struct rvalue_from_python_data : rvalue_from_python_storage<T>
- {
- # if (!defined(__MWERKS__) || __MWERKS__ >= 0x3000) \
- && (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 245) \
- && (!defined(__DECCXX_VER) || __DECCXX_VER > 60590014) \
- && !defined(BOOST_PYTHON_SYNOPSIS)
-
- BOOST_STATIC_ASSERT(BOOST_PYTHON_OFFSETOF(rvalue_from_python_storage<T>,stage1) == 0);
- # endif
-
-
- rvalue_from_python_data(rvalue_from_python_stage1_data const&);
-
-
-
- rvalue_from_python_data(void* convertible);
-
- ~rvalue_from_python_data();
- private:
- typedef typename boost::python::detail::add_lvalue_reference<
- typename boost::python::detail::add_cv<T>::type>::type ref_type;
- };
- template <class T>
- inline rvalue_from_python_data<T>::rvalue_from_python_data(rvalue_from_python_stage1_data const& _stage1)
- {
- this->stage1 = _stage1;
- }
- template <class T>
- inline rvalue_from_python_data<T>::rvalue_from_python_data(void* convertible)
- {
- this->stage1.convertible = convertible;
- }
- template <class T>
- inline rvalue_from_python_data<T>::~rvalue_from_python_data()
- {
- if (this->stage1.convertible == this->storage.bytes)
- {
- size_t allocated = sizeof(this->storage);
- void *ptr = this->storage.bytes;
- void *aligned_storage =
- ::boost::alignment::align(boost::python::detail::alignment_of<T>::value, 0, ptr, allocated);
- python::detail::destroy_referent<ref_type>(aligned_storage);
- }
- }
- }}}
- #endif
|