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 =
27  pybind11::get_overload(static_cast<const std::runtime_error*>(this), "what");
28  if (overload)
29  {
30  auto o = overload.operator()<pybind11::return_value_policy::reference>();
31  if (pybind11::detail::cast_is_temporary_value_reference<const char*>::value)
32  {
33 // pybind11 <=2.4: overload_caster_t, otherwise: override_caster_t
34 #if (PYBIND11_MAJOR_VERSION == 2 && PYBIND11_MINOR_VERSION <= 4)
35  static pybind11::detail::overload_caster_t<const char*> caster;
36 #else
37  static pybind11::detail::override_caster_t<const char*> caster;
38 #endif
39  return pybind11::detail::cast_ref<const char*>(std::move(o), caster);
40  }
41  else
42  return pybind11::detail::cast_safe<const char*>(std::move(o));
43  }
44  return runtime_error::what();
45  }
46 };
47 
48 void bind_std_stdexcept(std::function<pybind11::module&(std::string const& namespace_)>& M)
49 {
50  { // std::runtime_error file:stdexcept line:219
51  pybind11::class_<
52  std::runtime_error, std::shared_ptr<std::runtime_error>, PyCallBack_std_runtime_error,
53  std::exception>
54  cl(M("std"), "runtime_error", "");
55  cl.def(pybind11::init<const std::string&>(), pybind11::arg("__arg"));
56 
57  cl.def(pybind11::init<const char*>(), pybind11::arg(""));
58 
59  cl.def(pybind11::init([](PyCallBack_std_runtime_error const& o)
60  { return new PyCallBack_std_runtime_error(o); }));
61  cl.def(
62  pybind11::init([](std::runtime_error const& o) { return new std::runtime_error(o); }));
63  cl.def(
64  "assign",
65  (class std::runtime_error & (std::runtime_error::*)(const class std::runtime_error&)) &
66  std::runtime_error::operator=,
67  "C++: std::runtime_error::operator=(const class std::runtime_error "
68  "&) --> class std::runtime_error &",
69  pybind11::return_value_policy::automatic, pybind11::arg(""));
70  cl.def(
71  "what", (const char* (std::runtime_error::*)() const) & std::runtime_error::what,
72  "C++: std::runtime_error::what() const --> const char *",
73  pybind11::return_value_policy::automatic);
74  }
75 }
PyCallBack_std_runtime_error::what
const char * what() const override
Definition: stdexcept.cpp:23
PyCallBack_std_runtime_error
Definition: stdexcept.cpp:19
bind_std_stdexcept
void bind_std_stdexcept(std::function< pybind11::module &(std::string const &namespace_)> &M)
Definition: stdexcept.cpp:48


mvsim
Author(s):
autogenerated on Wed May 28 2025 02:13:08