diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
commit | 2d37894b1b037cf24231090eda8589bbb44fb6fc (patch) | |
tree | be835aa92c6248212e705f25388ebafcf84bc7a1 /library/python/symbols/module | |
parent | 718c552901d703c502ccbefdfc3c9028d608b947 (diff) | |
download | ydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/python/symbols/module')
-rw-r--r-- | library/python/symbols/module/module.cpp | 84 | ||||
-rw-r--r-- | library/python/symbols/module/ya.make | 10 |
2 files changed, 47 insertions, 47 deletions
diff --git a/library/python/symbols/module/module.cpp b/library/python/symbols/module/module.cpp index d3d511b779..92bc7f4d67 100644 --- a/library/python/symbols/module/module.cpp +++ b/library/python/symbols/module/module.cpp @@ -1,9 +1,9 @@ -#include <Python.h> - +#include <Python.h> + #include <library/python/symbols/registry/syms.h> -#include <util/generic/string.h> - +#include <util/generic/string.h> + #define CAP(x) SYM_2(x, x) BEGIN_SYMS("_capability") @@ -44,42 +44,42 @@ namespace { } } -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); - }; - - auto cb = MakeTCB(f); - - ForEachSymbol(cb); - - if (PyObject_SetAttrString(m, "syms", d)) - m = NULL; - Py_DECREF(d); - return m; +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); + }; + + auto cb = MakeTCB(f); + + ForEachSymbol(cb); + + if (PyObject_SetAttrString(m, "syms", d)) + m = NULL; + Py_DECREF(d); + return m; +} + +#if PY_MAJOR_VERSION >= 3 +static struct PyModuleDef module = { + PyModuleDef_HEAD_INIT, "syms", NULL, -1, NULL, NULL, NULL, NULL, NULL}; + +extern "C" PyObject* PyInit_syms() { + return InitSyms(PyModule_Create(&module)); +} +#else +extern "C" void initsyms() { + InitSyms(Py_InitModule("syms", NULL)); } - -#if PY_MAJOR_VERSION >= 3 -static struct PyModuleDef module = { - PyModuleDef_HEAD_INIT, "syms", NULL, -1, NULL, NULL, NULL, NULL, NULL}; - -extern "C" PyObject* PyInit_syms() { - return InitSyms(PyModule_Create(&module)); -} -#else -extern "C" void initsyms() { - InitSyms(Py_InitModule("syms", NULL)); -} -#endif +#endif diff --git a/library/python/symbols/module/ya.make b/library/python/symbols/module/ya.make index f84d3c268e..78e30f2547 100644 --- a/library/python/symbols/module/ya.make +++ b/library/python/symbols/module/ya.make @@ -1,11 +1,11 @@ -PY23_LIBRARY() +PY23_LIBRARY() OWNER(pg orivej) -NO_PYTHON_INCLUDES() - +NO_PYTHON_INCLUDES() + PEERDIR( - contrib/libs/python/Include + contrib/libs/python/Include ) SRCS( @@ -13,7 +13,7 @@ SRCS( ) PY_REGISTER( - library.python.symbols.module.syms + library.python.symbols.module.syms ) PY_SRCS( |