diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /library/python/symbols/module/module.cpp | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
download | ydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/python/symbols/module/module.cpp')
-rw-r--r-- | library/python/symbols/module/module.cpp | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/library/python/symbols/module/module.cpp b/library/python/symbols/module/module.cpp index fc3fd8dc0f..92bc7f4d67 100644 --- a/library/python/symbols/module/module.cpp +++ b/library/python/symbols/module/module.cpp @@ -1,62 +1,62 @@ #include <Python.h> -#include <library/python/symbols/registry/syms.h> - +#include <library/python/symbols/registry/syms.h> + #include <util/generic/string.h> -#define CAP(x) SYM_2(x, x) - -BEGIN_SYMS("_capability") -#if defined(_musl_) -CAP("musl") -#endif -#if defined(_linux_) -CAP("linux") -#endif -#if defined(_darwin_) -CAP("darwin") -#endif -CAP("_sentinel") -END_SYMS() - -#undef CAP - -using namespace NPrivate; - -namespace { - template <class T> - struct TCB: public ICB { - inline TCB(T& t) - : CB(&t) - { - } - - void Apply(const char* mod, const char* name, void* sym) override { - (*CB)(mod, name, sym); - } - - T* CB; - }; - - template <class T> - static inline TCB<T> MakeTCB(T& t) { - return t; - } -} - +#define CAP(x) SYM_2(x, x) + +BEGIN_SYMS("_capability") +#if defined(_musl_) +CAP("musl") +#endif +#if defined(_linux_) +CAP("linux") +#endif +#if defined(_darwin_) +CAP("darwin") +#endif +CAP("_sentinel") +END_SYMS() + +#undef CAP + +using namespace NPrivate; + +namespace { + template <class T> + struct TCB: public ICB { + inline TCB(T& t) + : CB(&t) + { + } + + void Apply(const char* mod, const char* name, void* sym) override { + (*CB)(mod, name, sym); + } + + T* CB; + }; + + template <class T> + static inline TCB<T> MakeTCB(T& t) { + return t; + } +} + static void DictSetStringPtr(PyObject* dict, const char* name, void* value) { PyObject* p = PyLong_FromVoidPtr(value); PyDict_SetItemString(dict, name, p); Py_DECREF(p); } - + static PyObject* InitSyms(PyObject* m) { if (!m) return NULL; PyObject* d = PyDict_New(); if (!d) return NULL; - + auto f = [&](const char* mod, const char* name, void* sym) { DictSetStringPtr(d, (TString(mod) + "|" + TString(name)).c_str(), sym); }; @@ -69,7 +69,7 @@ static PyObject* InitSyms(PyObject* m) { m = NULL; Py_DECREF(d); return m; -} +} #if PY_MAJOR_VERSION >= 3 static struct PyModuleDef module = { |