diff options
author | say <say@yandex-team.com> | 2023-02-14 17:24:43 +0300 |
---|---|---|
committer | say <say@yandex-team.com> | 2023-02-14 17:24:43 +0300 |
commit | e0094c4ad6964e11564777bc0d859c68d8aa9de2 (patch) | |
tree | 5d2ad1a4df88da1f74385888891a2a5f9fbbc3ef /library/cpp/pybind/v2.cpp | |
parent | 65a08c9fdece8dba50da8beb4d7c81447211dd45 (diff) | |
download | ydb-e0094c4ad6964e11564777bc0d859c68d8aa9de2.tar.gz |
Migrate black linter on custom_lint pipeline
Diffstat (limited to 'library/cpp/pybind/v2.cpp')
-rw-r--r-- | library/cpp/pybind/v2.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/library/cpp/pybind/v2.cpp b/library/cpp/pybind/v2.cpp new file mode 100644 index 00000000000..edce0be7195 --- /dev/null +++ b/library/cpp/pybind/v2.cpp @@ -0,0 +1,43 @@ +#include "v2.h" +namespace NPyBind { + namespace Detail { + template <> + PyTypeObject* GetParentType<void>(const TPyModuleDefinition&) { + return nullptr; + } + + + template <bool InitEnabled> + void UpdateClassNamesInModule(TPyModuleDefinition& M, const TString& name, PyTypeObject* pythonType) { + if (!InitEnabled) { + return; + } + M.ClassName2Type[name] = pythonType; + } + + template <bool InitEnabled> + void UpdateGetContextInModule(TPyModuleDefinition& M, const TString& name, IGetContextBase* base) { + if (!InitEnabled) { + return; + } + M.Class2ContextGetter[name] = base; + } + + TPyModuleRegistry::TPyModuleRegistry() { +#if PY_MAJOR_VERSION >= 3 + NPrivate::AddFinalizationCallBack([this]() { + if (UnnamedModule) { + UnnamedModule.Clear(); + } + Name2Def.clear(); + }); +#endif + } + template void UpdateClassNamesInModule<false>(TPyModuleDefinition& M, const TString& name, PyTypeObject* pythonType); + template void UpdateClassNamesInModule<true>(TPyModuleDefinition& M, const TString& name, PyTypeObject* pythonType); + + + template void UpdateGetContextInModule<false>(TPyModuleDefinition& M, const TString& name, IGetContextBase* pythonType); + template void UpdateGetContextInModule<true>(TPyModuleDefinition& M, const TString& name, IGetContextBase* pythonType); + }//Detail +}//NPyBind |