Debian Codegraph @

Include/cpython/genobject.h

raw
1 /* Generator object interface */
2
3 #ifndef Py_LIMITED_API
4 #ifndef Py_GENOBJECT_H
5 #define Py_GENOBJECT_H
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9
10 /* --- Generators --------------------------------------------------------- */
11
12 /* _PyGenObject_HEAD defines the initial segment of generator
13 and coroutine objects. */
14 #define _PyGenObject_HEAD(prefix) \
15 PyObject_HEAD \
16 /* List of weak reference. */ \
17 PyObject *prefix##_weakreflist; \
18 /* Name of the generator. */ \
19 PyObject *prefix##_name; \
20 /* Qualified name of the generator. */ \
21 PyObject *prefix##_qualname; \
22 _PyErr_StackItem prefix##_exc_state; \
23 PyObject *prefix##_origin_or_finalizer; \
24 char prefix##_hooks_inited; \
25 char prefix##_closed; \
26 char prefix##_running_async; \
27 /* The frame */ \
28 int8_t prefix##_frame_state; \
29 PyObject *prefix##_iframe[1]; \
30
31 typedef struct {
32 /* The gi_ prefix is intended to remind of generator-iterator. */
33 _PyGenObject_HEAD(gi)
34 } PyGenObject;
35
36 PyAPI_DATA(PyTypeObject) PyGen_Type;
37
38 #define PyGen_Check(op) PyObject_TypeCheck((op), &PyGen_Type)
39 #define PyGen_CheckExact(op) Py_IS_TYPE((op), &PyGen_Type)
40
41 PyAPI_FUNC(PyObject *) PyGen_New(PyFrameObject *);
42 PyAPI_FUNC(PyObject *) PyGen_NewWithQualName(PyFrameObject *,
43 PyObject *name, PyObject *qualname);
44 PyAPI_FUNC(PyCodeObject *) PyGen_GetCode(PyGenObject *gen);
45
46
47 /* --- PyCoroObject ------------------------------------------------------- */
48
49 typedef struct {
50 _PyGenObject_HEAD(cr)
51 } PyCoroObject;
52
53 PyAPI_DATA(PyTypeObject) PyCoro_Type;
54
55 #define PyCoro_CheckExact(op) Py_IS_TYPE((op), &PyCoro_Type)
56 PyAPI_FUNC(PyObject *) PyCoro_New(PyFrameObject *,
57 PyObject *name, PyObject *qualname);
58
59
60 /* --- Asynchronous Generators -------------------------------------------- */
61
62 typedef struct {
63 _PyGenObject_HEAD(ag)
64 } PyAsyncGenObject;
65
66 PyAPI_DATA(PyTypeObject) PyAsyncGen_Type;
67 PyAPI_DATA(PyTypeObject) _PyAsyncGenASend_Type;
68
69 PyAPI_FUNC(PyObject *) PyAsyncGen_New(PyFrameObject *,
70 PyObject *name, PyObject *qualname);
71
72 #define PyAsyncGen_CheckExact(op) Py_IS_TYPE((op), &PyAsyncGen_Type)
73
74 #define PyAsyncGenASend_CheckExact(op) Py_IS_TYPE((op), &_PyAsyncGenASend_Type)
75
76
77 #undef _PyGenObject_HEAD
78
79 #ifdef __cplusplus
80 }
81 #endif
82 #endif /* !Py_GENOBJECT_H */
83 #endif /* Py_LIMITED_API */