aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yson/node/pybind
diff options
context:
space:
mode:
authorinngonch <inngonch@yandex-team.ru>2022-02-10 16:49:19 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:19 +0300
commit259606d47f0a87d4980322c10899f41f246ad20c (patch)
tree9c52cc5f27477775816925ff9e39bd788042bef7 /library/cpp/yson/node/pybind
parent11c7da3bf8b14be64b7ddaf62ac657d4d2992b33 (diff)
downloadydb-259606d47f0a87d4980322c10899f41f246ad20c.tar.gz
Restoring authorship annotation for <inngonch@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/yson/node/pybind')
-rw-r--r--library/cpp/yson/node/pybind/node.cpp180
-rw-r--r--library/cpp/yson/node/pybind/node.h12
-rw-r--r--library/cpp/yson/node/pybind/ya.make26
3 files changed, 109 insertions, 109 deletions
diff --git a/library/cpp/yson/node/pybind/node.cpp b/library/cpp/yson/node/pybind/node.cpp
index 79beba3647..810815c357 100644
--- a/library/cpp/yson/node/pybind/node.cpp
+++ b/library/cpp/yson/node/pybind/node.cpp
@@ -1,59 +1,59 @@
-#include "node.h"
-
+#include "node.h"
+
#include <library/cpp/yson/node/node.h>
-
+
#include <library/cpp/pybind/cast.h>
-
-#include <Python.h>
-
-namespace NYT {
-
- PyObject* BuildPyObject(const TNode& node) {
- switch (node.GetType()) {
- case TNode::Bool:
- return NPyBind::BuildPyObject(node.AsBool());
- case TNode::Int64:
- return NPyBind::BuildPyObject(node.AsInt64());
- case TNode::Uint64:
- return NPyBind::BuildPyObject(node.AsUint64());
- case TNode::Double:
- return NPyBind::BuildPyObject(node.AsDouble());
- case TNode::String:
- return NPyBind::BuildPyObject(node.AsString());
- case TNode::List:
- return NPyBind::BuildPyObject(node.AsList());
- case TNode::Map:
- return NPyBind::BuildPyObject(node.AsMap());
- case TNode::Null:
- Py_RETURN_NONE;
- case TNode::Undefined:
- ythrow TNode::TTypeError() << "BuildPyObject called for undefined TNode";
- }
- }
-
-} // namespace NYT
-
-namespace NPyBind {
-
- template <>
- bool FromPyObject(PyObject* obj, NYT::TNode& res) {
- if (obj == Py_None) {
- res = NYT::TNode::CreateEntity();
- return true;
- }
- if (PyBool_Check(obj)) {
- res = false;
- return FromPyObject(obj, res.As<bool>());
- }
- if (PyFloat_Check(obj)) {
- res = 0.0;
- return FromPyObject(obj, res.As<double>());
- }
+
+#include <Python.h>
+
+namespace NYT {
+
+ PyObject* BuildPyObject(const TNode& node) {
+ switch (node.GetType()) {
+ case TNode::Bool:
+ return NPyBind::BuildPyObject(node.AsBool());
+ case TNode::Int64:
+ return NPyBind::BuildPyObject(node.AsInt64());
+ case TNode::Uint64:
+ return NPyBind::BuildPyObject(node.AsUint64());
+ case TNode::Double:
+ return NPyBind::BuildPyObject(node.AsDouble());
+ case TNode::String:
+ return NPyBind::BuildPyObject(node.AsString());
+ case TNode::List:
+ return NPyBind::BuildPyObject(node.AsList());
+ case TNode::Map:
+ return NPyBind::BuildPyObject(node.AsMap());
+ case TNode::Null:
+ Py_RETURN_NONE;
+ case TNode::Undefined:
+ ythrow TNode::TTypeError() << "BuildPyObject called for undefined TNode";
+ }
+ }
+
+} // namespace NYT
+
+namespace NPyBind {
+
+ template <>
+ bool FromPyObject(PyObject* obj, NYT::TNode& res) {
+ if (obj == Py_None) {
+ res = NYT::TNode::CreateEntity();
+ return true;
+ }
+ if (PyBool_Check(obj)) {
+ res = false;
+ return FromPyObject(obj, res.As<bool>());
+ }
+ if (PyFloat_Check(obj)) {
+ res = 0.0;
+ return FromPyObject(obj, res.As<double>());
+ }
#if PY_MAJOR_VERSION < 3
- if (PyString_Check(obj)) {
- res = TString();
- return FromPyObject(obj, res.As<TString>());
- }
+ if (PyString_Check(obj)) {
+ res = TString();
+ return FromPyObject(obj, res.As<TString>());
+ }
#else
if (PyUnicode_Check(obj)) {
res = TString();
@@ -64,42 +64,42 @@ namespace NPyBind {
return FromPyObject(obj, res.As<TString>());
}
#endif
- if (PyList_Check(obj)) {
- res = NYT::TNode::CreateList();
- return FromPyObject(obj, res.AsList());
- }
- if (PyDict_Check(obj)) {
- res = NYT::TNode::CreateMap();
- return FromPyObject(obj, res.AsMap());
- }
+ if (PyList_Check(obj)) {
+ res = NYT::TNode::CreateList();
+ return FromPyObject(obj, res.AsList());
+ }
+ if (PyDict_Check(obj)) {
+ res = NYT::TNode::CreateMap();
+ return FromPyObject(obj, res.AsMap());
+ }
#if PY_MAJOR_VERSION < 3
- if (PyInt_Check(obj)) {
- auto valAsLong = PyInt_AsLong(obj);
- if (valAsLong == -1 && PyErr_Occurred()) {
- return false;
- }
- res = valAsLong;
- return true;
- }
+ if (PyInt_Check(obj)) {
+ auto valAsLong = PyInt_AsLong(obj);
+ if (valAsLong == -1 && PyErr_Occurred()) {
+ return false;
+ }
+ res = valAsLong;
+ return true;
+ }
#endif
- if (PyLong_Check(obj)) {
- int overflow = 0;
- auto valAsLong = PyLong_AsLongAndOverflow(obj, &overflow);
- if (!overflow) {
- if (valAsLong == -1 && PyErr_Occurred()) {
- return false;
- }
- res = valAsLong;
- return true;
- }
- auto valAsULong = PyLong_AsUnsignedLong(obj);
- if (valAsULong == static_cast<decltype(valAsULong)>(-1) && PyErr_Occurred()) {
- return false;
- }
- res = valAsULong;
- return true;
- }
- return false;
- }
-
-} // namespace NPyBind
+ if (PyLong_Check(obj)) {
+ int overflow = 0;
+ auto valAsLong = PyLong_AsLongAndOverflow(obj, &overflow);
+ if (!overflow) {
+ if (valAsLong == -1 && PyErr_Occurred()) {
+ return false;
+ }
+ res = valAsLong;
+ return true;
+ }
+ auto valAsULong = PyLong_AsUnsignedLong(obj);
+ if (valAsULong == static_cast<decltype(valAsULong)>(-1) && PyErr_Occurred()) {
+ return false;
+ }
+ res = valAsULong;
+ return true;
+ }
+ return false;
+ }
+
+} // namespace NPyBind
diff --git a/library/cpp/yson/node/pybind/node.h b/library/cpp/yson/node/pybind/node.h
index 65f7236de6..ca2e2d1a6c 100644
--- a/library/cpp/yson/node/pybind/node.h
+++ b/library/cpp/yson/node/pybind/node.h
@@ -1,9 +1,9 @@
-#pragma once
-
+#pragma once
+
#include <Python.h>
#include <library/cpp/yson/node/node.h>
-
-namespace NYT {
- PyObject* BuildPyObject(const TNode& val);
-}
+
+namespace NYT {
+ PyObject* BuildPyObject(const TNode& val);
+}
diff --git a/library/cpp/yson/node/pybind/ya.make b/library/cpp/yson/node/pybind/ya.make
index 97b7583e96..2111f6e31c 100644
--- a/library/cpp/yson/node/pybind/ya.make
+++ b/library/cpp/yson/node/pybind/ya.make
@@ -1,16 +1,16 @@
PY23_NATIVE_LIBRARY()
-
-OWNER(
- inngonch
- g:yt
-)
-
-PEERDIR(
+
+OWNER(
+ inngonch
+ g:yt
+)
+
+PEERDIR(
library/cpp/pybind
library/cpp/yson/node
-)
-SRCS(
- node.cpp
-)
-
-END()
+)
+SRCS(
+ node.cpp
+)
+
+END()