8#include <boost/python/class.hpp>
9#include <boost/python/dict.hpp>
10#include <boost/python/extract.hpp>
11#include <boost/python/import.hpp>
12#include <boost/python/manage_new_object.hpp>
14namespace PythonInterface {
24 return typename bp::manage_new_object::apply<T *>::type()(p);
31template <
typename Copyable> boost::python::object
generic__copy__(
const bp::object ©able) {
32 Copyable *newCopyable(
new Copyable(bp::extract<const Copyable &>(copyable)));
35 bp::extract<bp::dict>(result.attr(
"__dict__"))().update(copyable.attr(
"__dict__"));
44template <
typename Copyable> bp::object
generic__deepcopy__(
const bp::object ©able, bp::dict &memo) {
45 bp::object copyMod = bp::import(
"copy");
46 bp::object deepcopy = copyMod.attr(
"deepcopy");
48 Copyable *newCopyable(
new Copyable(bp::extract<const Copyable &>(copyable)));
52 auto copyableId = (std::ptrdiff_t)(copyable.ptr());
53 memo[copyableId] = result;
55 bp::extract<bp::dict>(result.attr(
"__dict__"))().update(
56 deepcopy(bp::extract<bp::dict>(copyable.attr(
"__dict__"))(), memo));
bp::object generic__deepcopy__(const bp::object ©able, bp::dict &memo)
Create a deep copy of type Copyable providing Copyable is newable and has a public copy constructor.
boost::python::object generic__copy__(const bp::object ©able)
Create a shallow copy of type Copyable providing Copyable is newable and has a public copy constructo...
PyObject * managingPyObject(T *p)
Create a new object handle around arg.
Helper class which provides the Collimation Length for SANS instruments.