Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ build/
test.py
a.py
vgcore*

# Other Visual Studio stuff.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use a local only Visual Studio project folder and don't want to accidentally commit those files so I ignored them here.

pcbuild/
20 changes: 20 additions & 0 deletions include/pyawaitable/_pyawaitable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef PYAWAITABLE__PYAWAITABLE_H
#define PYAWAITABLE__PYAWAITABLE_H

#include <Python.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdarg.h>

#include "array.h"
#include "awaitableobject.h"
#include "backport.h"
#include "genwrapper.h"
#include "coro.h"
#include "values.h"
#include "with.h"

#define PYAWAITABLE_BEING_BUILT
#include <pyawaitable.h>

#endif
3 changes: 0 additions & 3 deletions include/pyawaitable/array.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#ifndef PYAWAITABLE_ARRAY_H
#define PYAWAITABLE_ARRAY_H

#include <Python.h>
#include <stdlib.h>

#define pyawaitable_array_DEFAULT_SIZE 16

/*
Expand Down
5 changes: 0 additions & 5 deletions include/pyawaitable/awaitableobject.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#ifndef PYAWAITABLE_AWAITABLE_H
#define PYAWAITABLE_AWAITABLE_H

#include <Python.h>
#include <stdbool.h>

#include <pyawaitable/array.h>

typedef int (*awaitcallback)(PyObject *, PyObject *);
typedef int (*awaitcallback_err)(PyObject *, PyObject *);
typedef int (*defer_callback)(PyObject *);
Expand Down
5 changes: 2 additions & 3 deletions include/pyawaitable/backport.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#ifndef PYAWAITABLE_BACKPORT_H
#define PYAWAITABLE_BACKPORT_H

#include <Python.h>

#ifndef _PyObject_Vectorcall
/* assume after Python 3.11 that PyObject_Vectorcall is always available even in the (stable) limited API. */
#if !defined(_PyObject_Vectorcall) && PY_VERSION_HEX < 0x030C0000
#define PYAWAITABLE_NEEDS_VECTORCALL
PyObject *_PyObject_VectorcallBackport(
PyObject *obj,
Expand Down
2 changes: 0 additions & 2 deletions include/pyawaitable/coro.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef PYAWAITABLE_CORO_H
#define PYAWAITABLE_CORO_H

#include <Python.h>

extern PyMethodDef pyawaitable_methods[];
extern PyAsyncMethods pyawaitable_async_methods;

Expand Down
3 changes: 0 additions & 3 deletions include/pyawaitable/genwrapper.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#ifndef PYAWAITABLE_GENWRAPPER_H
#define PYAWAITABLE_GENWRAPPER_H

#include <Python.h>
#include <pyawaitable/awaitableobject.h>

extern PyTypeObject _PyAwaitableGenWrapperType;

typedef struct _GenWrapperObject
Expand Down
2 changes: 0 additions & 2 deletions include/pyawaitable/values.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef PYAWAITABLE_VALUES_H
#define PYAWAITABLE_VALUES_H

#include <Python.h> // PyObject, Py_ssize_t

#define SAVE(name) int name(PyObject * awaitable, Py_ssize_t nargs, ...)
#define UNPACK(name) int name(PyObject * awaitable, ...)
#define SET(name, tp) \
Expand Down
3 changes: 0 additions & 3 deletions include/pyawaitable/with.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#ifndef PYAWAITABLE_WITH_H
#define PYAWAITABLE_WITH_H

#include <Python.h> // PyObject
#include <pyawaitable//awaitableobject.h> // awaitcallback, awaitcallback_err

int
pyawaitable_async_with_impl(
PyObject *aw,
Expand Down
2 changes: 1 addition & 1 deletion src/_pyawaitable/array.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <pyawaitable/array.h>
#include <pyawaitable/_pyawaitable.h>

static inline void
call_deallocator_maybe(pyawaitable_array *array, Py_ssize_t index)
Expand Down
9 changes: 1 addition & 8 deletions src/_pyawaitable/awaitable.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
#include <Python.h>
#include <stdlib.h>

#include <pyawaitable/array.h>
#include <pyawaitable/awaitableobject.h>
#include <pyawaitable/backport.h>
#include <pyawaitable/coro.h>
#include <pyawaitable/genwrapper.h>
#include <pyawaitable/_pyawaitable.h>

PyDoc_STRVAR(
awaitable_doc,
Expand Down
3 changes: 1 addition & 2 deletions src/_pyawaitable/backport.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <Python.h>
#include <pyawaitable/backport.h>
#include <pyawaitable/_pyawaitable.h>

#ifdef PYAWAITABLE_NEEDS_VECTORCALL
PyObject *
Expand Down
6 changes: 1 addition & 5 deletions src/_pyawaitable/coro.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#include <Python.h>
#include <pyawaitable/backport.h>
#include <pyawaitable/awaitableobject.h>
#include <pyawaitable/genwrapper.h>
#include <pyawaitable/coro.h>
#include <pyawaitable/_pyawaitable.h>

static PyObject *
awaitable_send_with_arg(PyObject *self, PyObject *value)
Expand Down
6 changes: 1 addition & 5 deletions src/_pyawaitable/genwrapper.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#include <Python.h>
#include <pyawaitable/backport.h>
#include <pyawaitable/awaitableobject.h>
#include <pyawaitable/genwrapper.h>
#include <stdlib.h>
#include <pyawaitable/_pyawaitable.h>
#define DONE(cb) \
do { cb->done = true; \
Py_CLEAR(cb->coro); \
Expand Down
7 changes: 1 addition & 6 deletions src/_pyawaitable/mod.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
#include <pyawaitable.h>
#include <pyawaitable/awaitableobject.h>
#include <pyawaitable/coro.h>
#include <pyawaitable/values.h>
#include <pyawaitable/genwrapper.h>
#include <pyawaitable/with.h>
#include <pyawaitable/_pyawaitable.h>
#define ADD_TYPE(tp) \
do \
{ \
Expand Down
8 changes: 1 addition & 7 deletions src/_pyawaitable/values.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
#include <Python.h>
#include <stdarg.h>

#include <pyawaitable/awaitableobject.h>
#include <pyawaitable/backport.h>
#include <pyawaitable/array.h>
#include <pyawaitable/values.h>
#include <pyawaitable/_pyawaitable.h>

#define NOTHING

Expand Down
5 changes: 1 addition & 4 deletions src/_pyawaitable/with.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#include <Python.h>
#include <pyawaitable/backport.h>
#include <pyawaitable/awaitableobject.h>
#include <pyawaitable/values.h>
#include <pyawaitable/_pyawaitable.h>

static int
async_with_inner(PyObject *aw, PyObject *res)
Expand Down
2 changes: 2 additions & 0 deletions src/pyawaitable/pyawaitable.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ typedef struct _pyawaitable_abi
defer_callback cb);
} PyAwaitableABI;

#ifndef PYAWAITABLE_BEING_BUILT
#ifdef PYAWAITABLE_THIS_FILE_INIT
PyAwaitableABI *pyawaitable_abi = NULL;
#else
Expand Down Expand Up @@ -160,5 +161,6 @@ pyawaitable_vendor_init(PyObject *mod)
);
return -1;
}
#endif

#endif
Loading