summaryrefslogtreecommitdiffhomepage
path: root/src/python/nxt_python.h
diff options
context:
space:
mode:
authorAndrei Belov <defan@nginx.com>2020-10-08 19:19:31 +0300
committerAndrei Belov <defan@nginx.com>2020-10-08 19:19:31 +0300
commitd586ac9fdc4a86c142b06a75dde4cdacad5b52f6 (patch)
tree9817282396f9d2cf5333050e4b5bf807d3617e40 /src/python/nxt_python.h
parent9be35d9b7418c041e5177f273c20f0fd2d3f00ad (diff)
parentad516735a65fe109773b60e26214a071411f1734 (diff)
downloadunit-d586ac9fdc4a86c142b06a75dde4cdacad5b52f6.tar.gz
unit-d586ac9fdc4a86c142b06a75dde4cdacad5b52f6.tar.bz2
Merged with the default branch.1.20.0-1
Diffstat (limited to 'src/python/nxt_python.h')
-rw-r--r--src/python/nxt_python.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/python/nxt_python.h b/src/python/nxt_python.h
new file mode 100644
index 00000000..3211026b
--- /dev/null
+++ b/src/python/nxt_python.h
@@ -0,0 +1,60 @@
+
+/*
+ * Copyright (C) NGINX, Inc.
+ */
+
+#ifndef _NXT_PYTHON_H_INCLUDED_
+#define _NXT_PYTHON_H_INCLUDED_
+
+
+#include <Python.h>
+#include <nxt_main.h>
+#include <nxt_unit.h>
+
+
+#if PY_MAJOR_VERSION == 3
+#define NXT_PYTHON_BYTES_TYPE "bytestring"
+
+#define PyString_FromStringAndSize(str, size) \
+ PyUnicode_DecodeLatin1((str), (size), "strict")
+#define PyString_AS_STRING PyUnicode_DATA
+
+#else
+#define NXT_PYTHON_BYTES_TYPE "string"
+
+#define PyBytes_FromStringAndSize PyString_FromStringAndSize
+#define PyBytes_Check PyString_Check
+#define PyBytes_GET_SIZE PyString_GET_SIZE
+#define PyBytes_AS_STRING PyString_AS_STRING
+#define PyUnicode_InternInPlace PyString_InternInPlace
+#define PyUnicode_AsUTF8 PyString_AS_STRING
+#endif
+
+#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 5
+#define NXT_HAVE_ASGI 1
+#endif
+
+extern PyObject *nxt_py_application;
+
+typedef struct {
+ nxt_str_t string;
+ PyObject **object_p;
+} nxt_python_string_t;
+
+
+nxt_int_t nxt_python_init_strings(nxt_python_string_t *pstr);
+void nxt_python_done_strings(nxt_python_string_t *pstr);
+
+void nxt_python_print_exception(void);
+
+nxt_int_t nxt_python_wsgi_init(nxt_task_t *task, nxt_unit_init_t *init);
+int nxt_python_wsgi_run(nxt_unit_ctx_t *ctx);
+void nxt_python_wsgi_done(void);
+
+int nxt_python_asgi_check(PyObject *obj);
+nxt_int_t nxt_python_asgi_init(nxt_task_t *task, nxt_unit_init_t *init);
+nxt_int_t nxt_python_asgi_run(nxt_unit_ctx_t *ctx);
+void nxt_python_asgi_done(void);
+
+
+#endif /* _NXT_PYTHON_H_INCLUDED_ */