exception.cpp
Go to the documentation of this file.
1 #include <exception>
2 #include <sstream> // __str__
3 
4 #include <pybind11/pybind11.h>
5 #include <functional>
6 #include <string>
7 #include <pybind11/stl.h>
8 
9 
10 #ifndef BINDER_PYBIND11_TYPE_CASTER
11  #define BINDER_PYBIND11_TYPE_CASTER
12  PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>);
14  PYBIND11_MAKE_OPAQUE(std::shared_ptr<void>);
15 #endif
16 
17 // std::exception file:bits/exception.h line:60
18 struct PyCallBack_std_exception : public std::exception {
19  using std::exception::exception;
20 
21  const char * what() const noexcept override {
22  pybind11::gil_scoped_acquire gil;
23  pybind11::function overload = pybind11::get_overload(static_cast<const std::exception *>(this), "what");
24  if (overload) {
25  auto o = overload.operator()<pybind11::return_value_policy::reference>();
26  if (pybind11::detail::cast_is_temporary_value_reference<const char *>::value) {
27  static pybind11::detail::overload_caster_t<const char *> caster;
28  return pybind11::detail::cast_ref<const char *>(std::move(o), caster);
29  }
30  else return pybind11::detail::cast_safe<const char *>(std::move(o));
31  }
32  return exception::what();
33  }
34 };
35 
36 void bind_std_exception(std::function< pybind11::module &(std::string const &namespace_) > &M)
37 {
38  { // std::exception file:bits/exception.h line:60
39  pybind11::class_<std::exception, std::shared_ptr<std::exception>, PyCallBack_std_exception> cl(M("std"), "exception", "");
40  cl.def( pybind11::init( [](){ return new std::exception(); }, [](){ return new PyCallBack_std_exception(); } ) );
41  cl.def( pybind11::init( [](PyCallBack_std_exception const &o){ return new PyCallBack_std_exception(o); } ) );
42  cl.def( pybind11::init( [](std::exception const &o){ return new std::exception(o); } ) );
43  cl.def("assign", (class std::exception & (std::exception::*)(const class std::exception &)) &std::exception::operator=, "C++: std::exception::operator=(const class std::exception &) --> class std::exception &", pybind11::return_value_policy::automatic, pybind11::arg(""));
44  cl.def("what", (const char * (std::exception::*)() const) &std::exception::what, "C++: std::exception::what() const --> const char *", pybind11::return_value_policy::automatic);
45  }
46 }
PYBIND11_MAKE_OPAQUE(std::shared_ptr< void >)
void bind_std_exception(std::function< pybind11::module &(std::string const &namespace_) > &M)
Definition: exception.cpp:36
const char * what() const noexceptoverride
Definition: exception.cpp:21
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr< T >)


mvsim
Author(s):
autogenerated on Fri May 7 2021 03:05:51