| 174 | } |
| 175 | |
| 176 | static auto MakeCallback(boost::python::object callback) { |
| 177 | namespace py = boost::python; |
| 178 | // Make sure the callback is actually callable. |
| 179 | if (!PyCallable_Check(callback.ptr())) { |
| 180 | PyErr_SetString(PyExc_TypeError, "callback argument must be callable!"); |
| 181 | py::throw_error_already_set(); |
| 182 | } |
| 183 | |
| 184 | // We need to delete the callback while holding the GIL. |
| 185 | using Deleter = carla::PythonUtil::AcquireGILDeleter; |
| 186 | auto callback_ptr = carla::SharedPtr<py::object>{new py::object(callback), Deleter()}; |
| 187 | |
| 188 | // Make a lambda callback. |
| 189 | return [callback=std::move(callback_ptr)](auto message) { |
| 190 | carla::PythonUtil::AcquireGIL lock; |
| 191 | try { |
| 192 | py::call<void>(callback->ptr(), py::object(message)); |
| 193 | } catch (const py::error_already_set &) { |
| 194 | PyErr_Print(); |
| 195 | } |
| 196 | }; |
| 197 | } |
| 198 | |
| 199 | #include "Geom.cpp" |
| 200 | #include "Occupancy.cpp" |
no outgoing calls
no test coverage detected