blob: 135561b701b025804016c6bf0c181e013214ff1d [file] [log] [blame]
Martin v. Löwise440e472004-06-01 15:22:42 +00001
2/* Generator object interface */
3
4#ifndef Py_GENOBJECT_H
5#define Py_GENOBJECT_H
6#ifdef __cplusplus
7extern "C" {
8#endif
9
Martin v. Löwis8d97e332004-06-27 15:43:12 +000010struct _frame; /* Avoid including frameobject.h */
11
Martin v. Löwise440e472004-06-01 15:22:42 +000012typedef struct {
13 PyObject_HEAD
14 /* The gi_ prefix is intended to remind of generator-iterator. */
15
Phillip J. Eby8920bf22006-04-12 19:07:15 +000016 /* Note: gi_frame can be NULL if the generator is "finished" */
Martin v. Löwis8d97e332004-06-27 15:43:12 +000017 struct _frame *gi_frame;
Martin v. Löwise440e472004-06-01 15:22:42 +000018
19 /* True if generator is being executed. */
20 int gi_running;
Georg Brandl0cdf9a32008-01-26 14:14:20 +000021
22 /* The code object backing the generator */
23 PyObject *gi_code;
Martin v. Löwise440e472004-06-01 15:22:42 +000024
25 /* List of weak reference. */
26 PyObject *gi_weakreflist;
27} PyGenObject;
28
29PyAPI_DATA(PyTypeObject) PyGen_Type;
30
31#define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type)
Christian Heimese93237d2007-12-19 02:37:44 +000032#define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type)
Martin v. Löwise440e472004-06-01 15:22:42 +000033
Martin v. Löwis8d97e332004-06-27 15:43:12 +000034PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *);
Phillip J. Eby2ba96612006-04-10 17:51:05 +000035PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *);
Martin v. Löwise440e472004-06-01 15:22:42 +000036
37#ifdef __cplusplus
38}
39#endif
40#endif /* !Py_GENOBJECT_H */