aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/pybind/v2.cpp
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.com>2023-10-03 11:19:48 +0300
committerthegeorg <thegeorg@yandex-team.com>2023-10-03 11:43:28 +0300
commitcda0c13f23f6b169fb0a49dc504b40a0aaecea09 (patch)
tree26476e92e5af2c856e017afb1df8f8dff42495bf /library/cpp/pybind/v2.cpp
parent4854116da9c5e3c95bb8440f2ea997c54b6e1a61 (diff)
downloadydb-cda0c13f23f6b169fb0a49dc504b40a0aaecea09.tar.gz
Move contrib/tools/jdk to build/platform/java/jdk/testing
Diffstat (limited to 'library/cpp/pybind/v2.cpp')
-rw-r--r--library/cpp/pybind/v2.cpp43
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