| Martin v. Löwis | e440e47 | 2004-06-01 15:22:42 +0000 | [diff] [blame] | 1 |  | 
 | 2 | /* Generator object interface */ | 
 | 3 |  | 
 | 4 | #ifndef Py_GENOBJECT_H | 
 | 5 | #define Py_GENOBJECT_H | 
 | 6 | #ifdef __cplusplus | 
 | 7 | extern "C" { | 
 | 8 | #endif | 
 | 9 |  | 
| Martin v. Löwis | 8d97e33 | 2004-06-27 15:43:12 +0000 | [diff] [blame] | 10 | struct _frame; /* Avoid including frameobject.h */ | 
 | 11 |  | 
| Martin v. Löwis | e440e47 | 2004-06-01 15:22:42 +0000 | [diff] [blame] | 12 | typedef struct { | 
 | 13 | 	PyObject_HEAD | 
 | 14 | 	/* The gi_ prefix is intended to remind of generator-iterator. */ | 
 | 15 |  | 
| Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 16 | 	/* Note: gi_frame can be NULL if the generator is "finished" */ | 
| Martin v. Löwis | 8d97e33 | 2004-06-27 15:43:12 +0000 | [diff] [blame] | 17 | 	struct _frame *gi_frame; | 
| Martin v. Löwis | e440e47 | 2004-06-01 15:22:42 +0000 | [diff] [blame] | 18 |  | 
 | 19 | 	/* True if generator is being executed. */ | 
 | 20 | 	int gi_running; | 
| Christian Heimes | af98da1 | 2008-01-27 15:18:18 +0000 | [diff] [blame] | 21 |      | 
 | 22 | 	/* The code object backing the generator */ | 
 | 23 | 	PyObject *gi_code; | 
| Martin v. Löwis | e440e47 | 2004-06-01 15:22:42 +0000 | [diff] [blame] | 24 |  | 
 | 25 | 	/* List of weak reference. */ | 
 | 26 | 	PyObject *gi_weakreflist; | 
 | 27 | } PyGenObject; | 
 | 28 |  | 
 | 29 | PyAPI_DATA(PyTypeObject) PyGen_Type; | 
 | 30 |  | 
 | 31 | #define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type) | 
| Christian Heimes | 90aa764 | 2007-12-19 02:45:37 +0000 | [diff] [blame] | 32 | #define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type) | 
| Martin v. Löwis | e440e47 | 2004-06-01 15:22:42 +0000 | [diff] [blame] | 33 |  | 
| Martin v. Löwis | 8d97e33 | 2004-06-27 15:43:12 +0000 | [diff] [blame] | 34 | PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *); | 
| Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 35 | PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *); | 
| Martin v. Löwis | e440e47 | 2004-06-01 15:22:42 +0000 | [diff] [blame] | 36 |  | 
 | 37 | #ifdef __cplusplus | 
 | 38 | } | 
 | 39 | #endif | 
 | 40 | #endif /* !Py_GENOBJECT_H */ |