Verified Commit cee2a3b5 authored by Justin Carpentier's avatar Justin Carpentier
Browse files

python/utils: add deprecation helpers

parent 23f8d5e7
//
// Copyright (c) 2020 INRIA
//
#ifndef __pinocchio_python_utils_deprecation_hpp__
#define __pinocchio_python_utils_deprecation_hpp__
#include <Python.h>
#include <boost/python.hpp>
#include <string>
namespace pinocchio
{
namespace python
{
template<class Policy = boost::python::default_call_policies>
struct deprecated_warning_policy : Policy
{
deprecated_warning_policy(const std::string & warning_message = "")
: Policy()
, m_warning_message(warning_message)
{}
template <class ArgumentPackage>
bool precall(ArgumentPackage const & args) const
{
PyErr_WarnEx(PyExc_UserWarning,m_warning_message.c_str(),1);
return static_cast<const Policy*>(this)->precall(args);
}
typedef typename Policy::result_converter result_converter;
typedef typename Policy::argument_package argument_package;
protected:
const std::string m_warning_message;
};
template<class Policy = boost::python::default_call_policies>
struct deprecated_member : deprecated_warning_policy<Policy>
{
deprecated_member(const std::string & warning_message
= "This class member has been marked as deprecated and will be removed in a future release.")
: deprecated_warning_policy<Policy>(warning_message)
{}
};
template<class Policy = boost::python::default_call_policies>
struct deprecated_function : deprecated_warning_policy<Policy>
{
deprecated_function(const std::string & warning_message
= "This function has been marked as deprecated and will be removed in a future release.")
: deprecated_warning_policy<Policy>(warning_message)
{}
};
}
}
#endif // ifndef __pinocchio_python_utils_deprecation_hpp__
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment