/* SWIG's default behavior for functions that return a reference to an object is to create a Python object that points to that object. This doesn't work well if the IMP object is not refcounted and the C++ object is deleted before it is used in Python (for example, algebra::Transformation3D::get_rotation() returns a const reference to its internal algebra::Rotation3D object; if the Transformation3D is destroyed before the Rotation3D is used, an invalid memory access will ensue). This typemap modifies the default behavior to instead copy the returned object (as if it were returned by value). It should *probably* only be used for simple types that do not use large amounts of memory, and only for returns of const references. (In other cases, it may make sense to make the type refcounted, or not to expose it to Python.) Example usage: %apply REFCOPY & { const Rotation3D & }; */ %typemap(out, noblock=1) REFCOPY & { %set_output(SWIG_NewPointerObj(%new_copy(*$1, $*ltype), $descriptor, SWIG_POINTER_OWN | %newpointer_flags)); }