1 | |
2 | /* Generator object interface */ |
3 | |
4 | #ifndef Py_LIMITED_API |
5 | #ifndef Py_GENOBJECT_H |
6 | #define Py_GENOBJECT_H |
7 | #ifdef __cplusplus |
8 | extern "C" { |
9 | #endif |
10 | |
11 | struct _frame; /* Avoid including frameobject.h */ |
12 | |
13 | /* _PyGenObject_HEAD defines the initial segment of generator |
14 | and coroutine objects. */ |
15 | #define _PyGenObject_HEAD(prefix) \ |
16 | PyObject_HEAD \ |
17 | /* Note: gi_frame can be NULL if the generator is "finished" */ \ |
18 | struct _frame *prefix##_frame; \ |
19 | /* True if generator is being executed. */ \ |
20 | char prefix##_running; \ |
21 | /* The code object backing the generator */ \ |
22 | PyObject *prefix##_code; \ |
23 | /* List of weak reference. */ \ |
24 | PyObject *prefix##_weakreflist; \ |
25 | /* Name of the generator. */ \ |
26 | PyObject *prefix##_name; \ |
27 | /* Qualified name of the generator. */ \ |
28 | PyObject *prefix##_qualname; |
29 | |
30 | typedef struct { |
31 | /* The gi_ prefix is intended to remind of generator-iterator. */ |
32 | _PyGenObject_HEAD(gi) |
33 | } PyGenObject; |
34 | |
35 | PyAPI_DATA(PyTypeObject) PyGen_Type; |
36 | |
37 | #define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type) |
38 | #define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type) |
39 | |
40 | PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *); |
41 | PyAPI_FUNC(PyObject *) PyGen_NewWithQualName(struct _frame *, |
42 | PyObject *name, PyObject *qualname); |
43 | PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *); |
44 | PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **); |
45 | PyObject *_PyGen_Send(PyGenObject *, PyObject *); |
46 | PyObject *_PyGen_yf(PyGenObject *); |
47 | PyAPI_FUNC(void) _PyGen_Finalize(PyObject *self); |
48 | |
49 | #ifndef Py_LIMITED_API |
50 | typedef struct { |
51 | _PyGenObject_HEAD(cr) |
52 | } PyCoroObject; |
53 | |
54 | PyAPI_DATA(PyTypeObject) PyCoro_Type; |
55 | PyAPI_DATA(PyTypeObject) _PyCoroWrapper_Type; |
56 | |
57 | PyAPI_DATA(PyTypeObject) _PyAIterWrapper_Type; |
58 | PyObject *_PyAIterWrapper_New(PyObject *aiter); |
59 | |
60 | #define PyCoro_CheckExact(op) (Py_TYPE(op) == &PyCoro_Type) |
61 | PyObject *_PyCoro_GetAwaitableIter(PyObject *o); |
62 | PyAPI_FUNC(PyObject *) PyCoro_New(struct _frame *, |
63 | PyObject *name, PyObject *qualname); |
64 | #endif |
65 | |
66 | #undef _PyGenObject_HEAD |
67 | |
68 | #ifdef __cplusplus |
69 | } |
70 | #endif |
71 | #endif /* !Py_GENOBJECT_H */ |
72 | #endif /* Py_LIMITED_API */ |
73 | |