2004-06-01 23:22:42 +08:00
|
|
|
|
|
|
|
/* Generator object interface */
|
|
|
|
|
2010-12-04 04:14:31 +08:00
|
|
|
#ifndef Py_LIMITED_API
|
2004-06-01 23:22:42 +08:00
|
|
|
#ifndef Py_GENOBJECT_H
|
|
|
|
#define Py_GENOBJECT_H
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2004-06-27 23:43:12 +08:00
|
|
|
struct _frame; /* Avoid including frameobject.h */
|
|
|
|
|
2004-06-01 23:22:42 +08:00
|
|
|
typedef struct {
|
2012-01-14 14:08:08 +08:00
|
|
|
PyObject_HEAD
|
|
|
|
/* The gi_ prefix is intended to remind of generator-iterator. */
|
2004-06-01 23:22:42 +08:00
|
|
|
|
2012-01-14 14:08:08 +08:00
|
|
|
/* Note: gi_frame can be NULL if the generator is "finished" */
|
|
|
|
struct _frame *gi_frame;
|
2004-06-01 23:22:42 +08:00
|
|
|
|
2012-01-14 14:08:08 +08:00
|
|
|
/* True if generator is being executed. */
|
2012-03-11 06:43:12 +08:00
|
|
|
char gi_running;
|
2012-03-16 04:37:39 +08:00
|
|
|
|
2012-01-14 14:08:08 +08:00
|
|
|
/* The code object backing the generator */
|
|
|
|
PyObject *gi_code;
|
2004-06-01 23:22:42 +08:00
|
|
|
|
2012-01-14 14:08:08 +08:00
|
|
|
/* List of weak reference. */
|
|
|
|
PyObject *gi_weakreflist;
|
2004-06-01 23:22:42 +08:00
|
|
|
} PyGenObject;
|
|
|
|
|
|
|
|
PyAPI_DATA(PyTypeObject) PyGen_Type;
|
|
|
|
|
|
|
|
#define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type)
|
2007-12-19 10:45:37 +08:00
|
|
|
#define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type)
|
2004-06-01 23:22:42 +08:00
|
|
|
|
2004-06-27 23:43:12 +08:00
|
|
|
PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *);
|
2006-04-21 18:40:58 +08:00
|
|
|
PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *);
|
2012-06-17 13:15:49 +08:00
|
|
|
PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **);
|
2012-03-16 04:37:39 +08:00
|
|
|
PyObject *_PyGen_Send(PyGenObject *, PyObject *);
|
2013-08-06 05:26:40 +08:00
|
|
|
PyAPI_FUNC(void) _PyGen_Finalize(PyObject *self);
|
|
|
|
|
2004-06-01 23:22:42 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* !Py_GENOBJECT_H */
|
2010-12-04 04:14:31 +08:00
|
|
|
#endif /* Py_LIMITED_API */
|