Skip to content
Snippets Groups Projects
Commit 3d606ea2 authored by Maxence Naud's avatar Maxence Naud Committed by Maxence Naud
Browse files

update deprecation with pybind override

parent 4b2ea1c2
No related branches found
No related tags found
No related merge requests found
Pipeline #66437 passed
......@@ -43,19 +43,36 @@ static std::string camelToSnakeCase(const std::string &camelCase) {
#define DEPRECATED_PYBIND(oldName, newName) \
/* Under PYBIND, if Python is initialized, convert names to snake_case */ \
if (Py_IsInitialized()) { \
deprecatedFuncNameStr = toSnakeCase(deprecatedFuncNameStr); \
newFuncNameStr = toSnakeCase(newFuncNameStr); \
deprecatedFuncNameStr = camelToSnakeCase(oldName); \
newFuncNameStr = camelToSnakeCase(newName); \
}
#else
#define DEPRECATED_PYBIND(oldName, newName) {}
#endif
#define DEPRECATED_PYBIND(oldName, newName) do {} while (0)
#endif // PYBIND
// For the C++ interface without Python overrides.
#define DEPRECATED(newFuncName) \
do { \
std::string deprecatedFuncNameStr(__func__); \
std::string newFuncNameStr(newFuncName); \
DEPRECATED_PYBIND(oldName, newName); \
Aidge::Log::warn("'{}()' is deprecated, please use '{}()' instead", deprecatedFuncNameStr, newFuncNameStr); \
DEPRECATED_PYBIND(deprecatedFuncNameStr, newFuncName); \
Aidge::Log::warn("'{}()' is deprecated, please use '{}()' instead", \
deprecatedFuncNameStr, newFuncNameStr); \
} while (0)
// For the case when you want to provide Python-specific override names.
// If PYBIND is detected (and Python is initialized), then the names will be
// replaced as follows:
// deprecatedFuncNameStr = camelToSnakeCase(pybindNewOverridedName)
// newFuncNameStr = camelToSnakeCase(pybindOldOverridedName)
#define DEPRECATED_WITH_PYBIND_OVERRIDES(newFuncName, pybindNewOverridedName, pybindOldOverridedName) \
do { \
std::string deprecatedFuncNameStr(__func__); \
std::string newFuncNameStr(newFuncName); \
/* Swap the order of the override names here */ \
DEPRECATED_PYBIND(pybindNewOverridedName, pybindOldOverridedName); \
Aidge::Log::warn("'{}()' is deprecated, please use '{}()' instead", \
deprecatedFuncNameStr, newFuncNameStr); \
} while (0)
#endif // AIDGE_UTILS_DEPRECATED_H_
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment