diff options
Diffstat (limited to 'src/python/nxt_python.h')
-rw-r--r-- | src/python/nxt_python.h | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/python/nxt_python.h b/src/python/nxt_python.h index 3211026b..b581dd46 100644 --- a/src/python/nxt_python.h +++ b/src/python/nxt_python.h @@ -11,6 +11,8 @@ #include <nxt_main.h> #include <nxt_unit.h> +#define NXT_PYTHON_VER(maj, min) ((maj << 24) | (min << 16)) + #if PY_MAJOR_VERSION == 3 #define NXT_PYTHON_BYTES_TYPE "bytestring" @@ -28,9 +30,10 @@ #define PyBytes_AS_STRING PyString_AS_STRING #define PyUnicode_InternInPlace PyString_InternInPlace #define PyUnicode_AsUTF8 PyString_AS_STRING +#define PyUnicode_GET_LENGTH PyUnicode_GET_SIZE #endif -#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 5 +#if PY_VERSION_HEX >= NXT_PYTHON_VER(3, 5) #define NXT_HAVE_ASGI 1 #endif @@ -41,20 +44,25 @@ typedef struct { PyObject **object_p; } nxt_python_string_t; +typedef struct { + int (*ctx_data_alloc)(void **pdata); + void (*ctx_data_free)(void *data); + int (*startup)(void *data); + int (*run)(nxt_unit_ctx_t *ctx); + int (*ready)(nxt_unit_ctx_t *ctx); + void (*done)(void); +} nxt_python_proto_t; + -nxt_int_t nxt_python_init_strings(nxt_python_string_t *pstr); +int 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_wsgi_init(nxt_unit_init_t *init, nxt_python_proto_t *proto); 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); +int nxt_python_asgi_init(nxt_unit_init_t *init, nxt_python_proto_t *proto); #endif /* _NXT_PYTHON_H_INCLUDED_ */ |