|
|
|
|
|
|
|
|
#ifndef __Pyx_CppExn2PyErr |
|
|
#include <new> |
|
|
#include <typeinfo> |
|
|
#include <stdexcept> |
|
|
#include <ios> |
|
|
|
|
|
static void __Pyx_CppExn2PyErr() { |
|
|
|
|
|
|
|
|
try { |
|
|
if (PyErr_Occurred()) |
|
|
; |
|
|
else |
|
|
throw; |
|
|
} catch (const std::bad_alloc& exn) { |
|
|
PyErr_SetString(PyExc_MemoryError, exn.what()); |
|
|
} catch (const std::bad_cast& exn) { |
|
|
PyErr_SetString(PyExc_TypeError, exn.what()); |
|
|
} catch (const std::bad_typeid& exn) { |
|
|
PyErr_SetString(PyExc_TypeError, exn.what()); |
|
|
} catch (const std::domain_error& exn) { |
|
|
PyErr_SetString(PyExc_ValueError, exn.what()); |
|
|
} catch (const std::invalid_argument& exn) { |
|
|
PyErr_SetString(PyExc_ValueError, exn.what()); |
|
|
} catch (const std::ios_base::failure& exn) { |
|
|
|
|
|
|
|
|
PyErr_SetString(PyExc_IOError, exn.what()); |
|
|
} catch (const std::out_of_range& exn) { |
|
|
|
|
|
PyErr_SetString(PyExc_IndexError, exn.what()); |
|
|
} catch (const std::overflow_error& exn) { |
|
|
PyErr_SetString(PyExc_OverflowError, exn.what()); |
|
|
} catch (const std::range_error& exn) { |
|
|
PyErr_SetString(PyExc_ArithmeticError, exn.what()); |
|
|
} catch (const std::underflow_error& exn) { |
|
|
PyErr_SetString(PyExc_ArithmeticError, exn.what()); |
|
|
} catch (const std::exception& exn) { |
|
|
PyErr_SetString(PyExc_RuntimeError, exn.what()); |
|
|
} |
|
|
catch (...) |
|
|
{ |
|
|
PyErr_SetString(PyExc_RuntimeError, "Unknown exception"); |
|
|
} |
|
|
} |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
template <class T> |
|
|
auto __Pyx_pythran_to_python(T &&value) -> decltype(to_python( |
|
|
typename pythonic::returnable<typename std::remove_cv<typename std::remove_reference<T>::type>::type>::type{std::forward<T>(value)})) |
|
|
{ |
|
|
using returnable_type = typename pythonic::returnable<typename std::remove_cv<typename std::remove_reference<T>::type>::type>::type; |
|
|
return to_python(returnable_type{std::forward<T>(value)}); |
|
|
} |
|
|
|
|
|
#define __Pyx_PythranShapeAccessor(x) (pythonic::builtins::getattr(pythonic::types::attr::SHAPE{}, x)) |
|
|
|
|
|
|
|
|
|
|
|
#if CYTHON_USE_CPP_STD_MOVE |
|
|
#include <utility> |
|
|
#define __PYX_STD_MOVE_IF_SUPPORTED(x) std::move(x) |
|
|
#else |
|
|
#define __PYX_STD_MOVE_IF_SUPPORTED(x) x |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined (_MSC_VER) |
|
|
#if _MSC_VER >= 1910 |
|
|
#define __PYX_ENUM_CLASS_DECL enum |
|
|
#else |
|
|
#define __PYX_ENUM_CLASS_DECL |
|
|
#endif |
|
|
#else |
|
|
#define __PYX_ENUM_CLASS_DECL enum |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <utility> |
|
|
#if defined(CYTHON_USE_BOOST_OPTIONAL) |
|
|
|
|
|
|
|
|
#include <boost/optional.hpp> |
|
|
#define __Pyx_Optional_BaseType boost::optional |
|
|
#else |
|
|
#include <optional> |
|
|
|
|
|
|
|
|
template <typename T> |
|
|
using __Pyx_Optional_BaseType = std::optional<T>; |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T> |
|
|
class __Pyx_Optional_Type : private __Pyx_Optional_BaseType<T> { |
|
|
public: |
|
|
using __Pyx_Optional_BaseType<T>::__Pyx_Optional_BaseType; |
|
|
using __Pyx_Optional_BaseType<T>::has_value; |
|
|
using __Pyx_Optional_BaseType<T>::operator*; |
|
|
using __Pyx_Optional_BaseType<T>::operator->; |
|
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600) |
|
|
__Pyx_Optional_Type& operator=(const __Pyx_Optional_Type& rhs) { |
|
|
this->emplace(*rhs); |
|
|
return *this; |
|
|
} |
|
|
__Pyx_Optional_Type& operator=(__Pyx_Optional_Type&& rhs) { |
|
|
this->emplace(std::move(*rhs)); |
|
|
return *this; |
|
|
} |
|
|
template <typename U=T> |
|
|
__Pyx_Optional_Type& operator=(U&& rhs) { |
|
|
this->emplace(std::forward<U>(rhs)); |
|
|
return *this; |
|
|
} |
|
|
#else |
|
|
|
|
|
|
|
|
|
|
|
using __Pyx_Optional_BaseType<T>::operator=; |
|
|
#endif |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
#include <new> |
|
|
|
|
|
|
|
|
template<typename T> |
|
|
void __Pyx_default_placement_construct(T* x) { |
|
|
new (static_cast<void*>(x)) T(); |
|
|
} |
|
|
|