HEX
Server: nginx/1.24.0
System: Linux DGT-WORDPRESS-VM-SERVER 6.14.0-1017-azure #17~24.04.1-Ubuntu SMP Mon Dec 1 20:10:50 UTC 2025 x86_64
User: ubuntu (1000)
PHP: 8.4.12
Disabled: NONE
Upload Files
File: //usr/include/Imath/PyImathDecorators.h
//
// SPDX-License-Identifier: BSD-3-Clause
// Copyright Contributors to the OpenEXR Project.
//

// clang-format off

#ifndef INCLUDED_PYIMATH_DECORATORS_H
#define INCLUDED_PYIMATH_DECORATORS_H

#define BOOST_BIND_GLOBAL_PLACEHOLDERS
#include <boost/python.hpp>

namespace PyImath
{

// These function add __copy__ and __deepcopy__ methods
// to python classes by simply wrapping the copy constructors
// This interface is needed for using these classes with
// the python copy module.

template <class T>
static T
copy(const T& x)
{
    return T(x);
}

template <class T>
static T
deepcopy(const T& x, boost::python::dict&)
{
    return copy(x);
}

template <class T, class X1, class X2, class X3>
boost::python::class_<T,X1,X2,X3>&
decoratecopy(boost::python::class_<T,X1,X2,X3>& cls)
{
    cls.def("__copy__",&copy<T>);
    cls.def("__deepcopy__",&deepcopy<T>);
    return cls;
}

} // namespace PyImath

#endif // INCLUDED_PYIMATH_DECORATORS_H