blob: ca8443203c79e5a7e9b9e07c83386a9a583abb89 [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;
21
22 /* List of weak reference. */
23 PyObject *gi_weakreflist;
24} PyGenObject;
25
26PyAPI_DATA(PyTypeObject) PyGen_Type;
27
28#define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type)
29#define PyGen_CheckExact(op) ((op)->ob_type == &PyGen_Type)
30
Martin v. Löwis8d97e332004-06-27 15:43:12 +000031PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *);
Phillip J. Eby2ba96612006-04-10 17:51:05 +000032PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *);
Martin v. Löwise440e472004-06-01 15:22:42 +000033
34#ifdef __cplusplus
35}
36#endif
37#endif /* !Py_GENOBJECT_H */