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
Thomas Wouters49fd7fa2006-04-21 10:40:58 +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;
Christian Heimesaf98da12008-01-27 15:18:18 +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 Heimes90aa7642007-12-19 02:45:37 +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 *);
Thomas Wouters49fd7fa2006-04-21 10:40:58 +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 */