1 /////////////// CppExceptionConversion.proto ///////////////
2 
3 #ifndef __Pyx_CppExn2PyErr
4 #include <new>
5 #include <typeinfo>
6 #include <stdexcept>
7 #include <ios>
8 
__Pyx_CppExn2PyErr()9 static void __Pyx_CppExn2PyErr() {
10   // Catch a handful of different errors here and turn them into the
11   // equivalent Python errors.
12   try {
13     if (PyErr_Occurred())
14       ; // let the latest Python exn pass through and ignore the current one
15     else
16       throw;
17   } catch (const std::bad_alloc& exn) {
18     PyErr_SetString(PyExc_MemoryError, exn.what());
19   } catch (const std::bad_cast& exn) {
20     PyErr_SetString(PyExc_TypeError, exn.what());
21   } catch (const std::bad_typeid& exn) {
22     PyErr_SetString(PyExc_TypeError, exn.what());
23   } catch (const std::domain_error& exn) {
24     PyErr_SetString(PyExc_ValueError, exn.what());
25   } catch (const std::invalid_argument& exn) {
26     PyErr_SetString(PyExc_ValueError, exn.what());
27   } catch (const std::ios_base::failure& exn) {
28     // Unfortunately, in standard C++ we have no way of distinguishing EOF
29     // from other errors here; be careful with the exception mask
30     PyErr_SetString(PyExc_IOError, exn.what());
31   } catch (const std::out_of_range& exn) {
32     // Change out_of_range to IndexError
33     PyErr_SetString(PyExc_IndexError, exn.what());
34   } catch (const std::overflow_error& exn) {
35     PyErr_SetString(PyExc_OverflowError, exn.what());
36   } catch (const std::range_error& exn) {
37     PyErr_SetString(PyExc_ArithmeticError, exn.what());
38   } catch (const std::underflow_error& exn) {
39     PyErr_SetString(PyExc_ArithmeticError, exn.what());
40   } catch (const std::exception& exn) {
41     PyErr_SetString(PyExc_RuntimeError, exn.what());
42   }
43   catch (...)
44   {
45     PyErr_SetString(PyExc_RuntimeError, "Unknown exception");
46   }
47 }
48 #endif
49 
50 /////////////// PythranConversion.proto ///////////////
51 
52 template <class T>
__Pyx_pythran_to_python(T && value)53 auto __Pyx_pythran_to_python(T &&value) -> decltype(to_python(
54       typename pythonic::returnable<typename std::remove_cv<typename std::remove_reference<T>::type>::type>::type{std::forward<T>(value)}))
55 {
56   using returnable_type = typename pythonic::returnable<typename std::remove_cv<typename std::remove_reference<T>::type>::type>::type;
57   return to_python(returnable_type{std::forward<T>(value)});
58 }
59 
60 #define __Pyx_PythranShapeAccessor(x) (pythonic::builtins::getattr(pythonic::types::attr::SHAPE{}, x))
61 
62 ////////////// MoveIfSupported.proto //////////////////
63 
64 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)
65   // move should be defined for these versions of MSVC, but __cplusplus isn't set usefully
66   #include <utility>
67   #define __PYX_STD_MOVE_IF_SUPPORTED(x) std::move(x)
68 #else
69   #define __PYX_STD_MOVE_IF_SUPPORTED(x) x
70 #endif
71 
72 ////////////// EnumClassDecl.proto //////////////////
73 
74 #if defined (_MSC_VER)
75   #if _MSC_VER >= 1910
76     #define __PYX_ENUM_CLASS_DECL enum
77   #else
78     #define __PYX_ENUM_CLASS_DECL
79   #endif
80 #else
81   #define __PYX_ENUM_CLASS_DECL enum
82 #endif
83 
84 ////////////// OptionalLocals.proto ////////////////
85 //@proto_block: utility_code_proto_before_types
86 
87 #if defined(CYTHON_USE_BOOST_OPTIONAL)
88     // fallback mode - std::optional is preferred but this gives
89     // people with a less up-to-date compiler a chance
90     #include <boost/optional.hpp>
91     #define __Pyx_Optional_Type boost::optional
92 #else
93     #include <optional>
94     // since std::optional is a C++17 features, a templated using declaration should be safe
95     // (although it could be replaced with a define)
96     template <typename T>
97     using __Pyx_Optional_Type = std::optional<T>;
98 #endif
99