Verified Commit 02f67edd authored by Justin Carpentier's avatar Justin Carpentier
Browse files

python: add deprecation feature

parent 97cefeeb
......@@ -42,6 +42,7 @@ SET(LIBRARY_NAME hppfcl)
SET(${LIBRARY_NAME}_HEADERS
fcl.hh
deprecation.hh
)
SET(ENABLE_PYTHON_DOXYGEN_AUTODOC TRUE CACHE BOOL "Enable automatic documentation of Python bindings from Doxygen documentation")
......
//
// Copyright (c) 2020-2021 INRIA
//
#ifndef HPP_FCL_PYTHON_UTILS_DEPRECATION_H
#define HPP_FCL_PYTHON_UTILS_DEPRECATION_H
#include <Python.h>
#include <boost/python.hpp>
#include <string>
namespace hpp {
namespace fcl {
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 HPP_FCL_PYTHON_UTILS_DEPRECATION_H
......@@ -89,6 +89,8 @@ void exposeMeshLoader ()
BOOST_PYTHON_MODULE(hppfcl)
{
bp::import("warnings");
exposeVersion();
exposeMaths();
exposeCollisionGeometries();
......
Supports Markdown
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