Skip to content
Snippets Groups Projects

[Add] Deprecation system

Merged Maxence Naud requested to merge feat_32-deprecation-system into dev
1 file
+ 23
6
Compare changes
  • Side-by-side
  • Inline
@@ -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
Loading