blob: 65f1ecfd54958fd10b30ff9f68026573ab089f85 [file] [log] [blame]
Martin v. Löwise440e472004-06-01 15:22:42 +00001
2/* Generator object interface */
3
Martin v. Löwis4d0d4712010-12-03 20:14:31 +00004#ifndef Py_LIMITED_API
Martin v. Löwise440e472004-06-01 15:22:42 +00005#ifndef Py_GENOBJECT_H
6#define Py_GENOBJECT_H
7#ifdef __cplusplus
8extern "C" {
9#endif
10
Martin v. Löwis8d97e332004-06-27 15:43:12 +000011struct _frame; /* Avoid including frameobject.h */
12
Martin v. Löwise440e472004-06-01 15:22:42 +000013typedef struct {
Nick Coghlan76e1bb02012-01-14 16:08:08 +100014 PyObject_HEAD
15 /* The gi_ prefix is intended to remind of generator-iterator. */
Martin v. Löwise440e472004-06-01 15:22:42 +000016
Nick Coghlan76e1bb02012-01-14 16:08:08 +100017 /* Note: gi_frame can be NULL if the generator is "finished" */
18 struct _frame *gi_frame;
Martin v. Löwise440e472004-06-01 15:22:42 +000019
Nick Coghlan76e1bb02012-01-14 16:08:08 +100020 /* True if generator is being executed. */
Antoine Pitroub4a92372012-03-10 23:43:12 +010021 char gi_running;
Benjamin Peterson2afe6ae2012-03-15 15:37:39 -050022
Nick Coghlan76e1bb02012-01-14 16:08:08 +100023 /* The code object backing the generator */
24 PyObject *gi_code;
Martin v. Löwise440e472004-06-01 15:22:42 +000025
Nick Coghlan76e1bb02012-01-14 16:08:08 +100026 /* List of weak reference. */
27 PyObject *gi_weakreflist;
Martin v. Löwise440e472004-06-01 15:22:42 +000028} PyGenObject;
29
30PyAPI_DATA(PyTypeObject) PyGen_Type;
31
32#define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type)
Christian Heimes90aa7642007-12-19 02:45:37 +000033#define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type)
Martin v. Löwise440e472004-06-01 15:22:42 +000034
Martin v. Löwis8d97e332004-06-27 15:43:12 +000035PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *);
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000036PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *);
Nick Coghlanc40bc092012-06-17 15:15:49 +100037PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **);
Benjamin Peterson2afe6ae2012-03-15 15:37:39 -050038PyObject *_PyGen_Send(PyGenObject *, PyObject *);
Antoine Pitrou58720d62013-08-05 23:26:40 +020039PyAPI_FUNC(void) _PyGen_Finalize(PyObject *self);
40
Martin v. Löwise440e472004-06-01 15:22:42 +000041
42#ifdef __cplusplus
43}
44#endif
45#endif /* !Py_GENOBJECT_H */
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000046#endif /* Py_LIMITED_API */