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

update deprecation with pybind override

parent 4cd6d30f
No related branches found
No related tags found
3 merge requests!414Update version 0.5.1 -> 0.6.0,!408[Add] Dropout Operator,!354[Add] Deprecation system
Pipeline #67224 passed
...@@ -43,19 +43,36 @@ static std::string camelToSnakeCase(const std::string &camelCase) { ...@@ -43,19 +43,36 @@ static std::string camelToSnakeCase(const std::string &camelCase) {
#define DEPRECATED_PYBIND(oldName, newName) \ #define DEPRECATED_PYBIND(oldName, newName) \
/* Under PYBIND, if Python is initialized, convert names to snake_case */ \ /* Under PYBIND, if Python is initialized, convert names to snake_case */ \
if (Py_IsInitialized()) { \ if (Py_IsInitialized()) { \
deprecatedFuncNameStr = toSnakeCase(deprecatedFuncNameStr); \ deprecatedFuncNameStr = camelToSnakeCase(oldName); \
newFuncNameStr = toSnakeCase(newFuncNameStr); \ newFuncNameStr = camelToSnakeCase(newName); \
} }
#else #else
#define DEPRECATED_PYBIND(oldName, newName) {} #define DEPRECATED_PYBIND(oldName, newName) do {} while (0)
#endif #endif // PYBIND
// For the C++ interface without Python overrides.
#define DEPRECATED(newFuncName) \ #define DEPRECATED(newFuncName) \
do { \ do { \
std::string deprecatedFuncNameStr(__func__); \ std::string deprecatedFuncNameStr(__func__); \
std::string newFuncNameStr(newFuncName); \ std::string newFuncNameStr(newFuncName); \
DEPRECATED_PYBIND(oldName, newName); \ DEPRECATED_PYBIND(deprecatedFuncNameStr, newFuncName); \
Aidge::Log::warn("'{}()' is deprecated, please use '{}()' instead", deprecatedFuncNameStr, newFuncNameStr); \ 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) } while (0)
#endif // AIDGE_UTILS_DEPRECATED_H_ #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