| 30 | // From https://stackoverflow.com/questions/35957073/boost-python-returning-tuple-containing-custom-types |
| 31 | |
| 32 | template <typename T> boost::python::object TransferToPython(T *t) { |
| 33 | // Transfer ownership to a smart pointer, allowing for proper cleanup |
| 34 | // incase Boost.Python throws. |
| 35 | std::unique_ptr<T> ptr(t); |
| 36 | |
| 37 | // Use the manage_new_object generator to transfer ownership to Python. |
| 38 | typename boost::python::manage_new_object::apply<T *>::type converter; |
| 39 | |
| 40 | // Transfer ownership to the Python handler and release ownership |
| 41 | // from C++. |
| 42 | boost::python::handle<> handle(converter(*ptr)); |
| 43 | ptr.release(); |
| 44 | |
| 45 | return boost::python::object(handle); |
| 46 | } |
| 47 | |
| 48 | template<typename T> void GetArray(const boost::python::object &obj, std::vector<T> &a, |
| 49 | const u_int width = 1, const u_int stride = 0) { |
no test coverage detected