stdexcept.cpp
Go to the documentation of this file.
1 #include <pybind11/pybind11.h>
2 #include <pybind11/stl.h>
3 
4 #include <functional>
5 #include <iterator>
6 #include <memory>
7 #include <sstream> // __str__
8 #include <stdexcept>
9 #include <string>
10 
11 #ifndef BINDER_PYBIND11_TYPE_CASTER
12 #define BINDER_PYBIND11_TYPE_CASTER
13 PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>)
14 PYBIND11_DECLARE_HOLDER_TYPE(T, T*)
15 PYBIND11_MAKE_OPAQUE(std::shared_ptr<void>)
16 #endif
17 
18 // std::runtime_error file:stdexcept line:219
19 struct PyCallBack_std_runtime_error : public std::runtime_error
20 {
21  using std::runtime_error::runtime_error;
22 
23  const char* what() const throw() override
24  {
25  pybind11::gil_scoped_acquire gil;
26  pybind11::function overload = pybind11::get_overload(
27  static_cast<const std::runtime_error*>(this), "what");
28  if (overload)
29  {
30  auto o =
31  overload.operator()<pybind11::return_value_policy::reference>();
32  if (pybind11::detail::cast_is_temporary_value_reference<
33  const char*>::value)
34  {
35 // pybind11 <=2.4: overload_caster_t, otherwise: override_caster_t
36 #if (PYBIND11_MAJOR_VERSION == 2 && PYBIND11_MINOR_VERSION <= 4)
37  static pybind11::detail::overload_caster_t<const char*> caster;
38 #else
39  static pybind11::detail::override_caster_t<const char*> caster;
40 #endif
41  return pybind11::detail::cast_ref<const char*>(
42  std::move(o), caster);
43  }
44  else
45  return pybind11::detail::cast_safe<const char*>(std::move(o));
46  }
47  return runtime_error::what();
48  }
49 };
50 
52  std::function<pybind11::module&(std::string const& namespace_)>& M)
53 {
54  { // std::runtime_error file:stdexcept line:219
55  pybind11::class_<
56  std::runtime_error, std::shared_ptr<std::runtime_error>,
57  PyCallBack_std_runtime_error, std::exception>
58  cl(M("std"), "runtime_error", "");
59  cl.def(pybind11::init<const std::string&>(), pybind11::arg("__arg"));
60 
61  cl.def(pybind11::init<const char*>(), pybind11::arg(""));
62 
63  cl.def(pybind11::init([](PyCallBack_std_runtime_error const& o) {
64  return new PyCallBack_std_runtime_error(o);
65  }));
66  cl.def(pybind11::init([](std::runtime_error const& o) {
67  return new std::runtime_error(o);
68  }));
69  cl.def(
70  "assign",
71  (class std::runtime_error &
72  (std::runtime_error::*)(const class std::runtime_error&)) &
73  std::runtime_error::operator=,
74  "C++: std::runtime_error::operator=(const class std::runtime_error "
75  "&) --> class std::runtime_error &",
76  pybind11::return_value_policy::automatic, pybind11::arg(""));
77  cl.def(
78  "what",
79  (const char* (std::runtime_error::*)() const) &
80  std::runtime_error::what,
81  "C++: std::runtime_error::what() const --> const char *",
82  pybind11::return_value_policy::automatic);
83  }
84 }
void bind_std_stdexcept(std::function< pybind11::module &(std::string const &namespace_)> &M)
Definition: stdexcept.cpp:51
const char * what() const override
Definition: stdexcept.cpp:23


mvsim
Author(s):
autogenerated on Tue Jul 4 2023 03:08:21