1 /** 2 Mirror _genobject.h 3 4 Generator object interface 5 */ 6 module deimos.python.genobject; 7 8 import deimos.python.pyport; 9 import deimos.python.object; 10 import deimos.python.frameobject; 11 12 extern(C): 13 // Python-header-file: Include/genobject.h: 14 15 template _PyGenObject_HEAD(string prefix) { 16 mixin(" 17 mixin PyObject_HEAD; 18 PyFrameObject* " ~ prefix ~ "_frame; 19 char " ~ prefix ~ "_running; 20 PyObject* " ~ prefix ~ "_code; 21 PyObject* " ~ prefix ~ "_weakreflist; 22 PyObject* " ~ prefix ~ "_name; 23 PyObject* " ~ prefix ~ "_qualname; 24 "); 25 } 26 27 version(Python_3_5_Or_Later) { 28 struct PyGenObject { 29 mixin _PyGenObject_HEAD!("gi"); 30 } 31 }else{ 32 struct PyGenObject { 33 mixin PyObject_HEAD; 34 /** The gi_ prefix is intended to remind of generator-iterator. 35 36 Note: gi_frame can be NULL if the generator is "finished" 37 */ 38 PyFrameObject* gi_frame; 39 /** True if generator is being executed. */ 40 int gi_running; 41 version(Python_2_6_Or_Later){ 42 /** The code object backing the generator */ 43 /// Availability: >= 2.6 44 PyObject* gi_code; 45 } 46 /** List of weak reference. */ 47 PyObject* gi_weakreflist; 48 } 49 } 50 51 /// _ 52 mixin(PyAPI_DATA!"PyTypeObject PyGen_Type"); 53 54 // D translations of C macros: 55 /// _ 56 int PyGen_Check()(PyObject* op) { 57 return PyObject_TypeCheck(op, &PyGen_Type); 58 } 59 /// _ 60 int PyGen_CheckExact()(PyObject* op) { 61 return Py_TYPE(op) == &PyGen_Type; 62 } 63 64 /// _ 65 PyObject* PyGen_New(PyFrameObject*); 66 67 version(Python_3_5_Or_Later) { 68 /// _ 69 PyObject* PyGen_NewWithQualName(PyFrameObject*, PyObject*, PyObject*); 70 } 71 72 /// _ 73 int PyGen_NeedsFinalizing(PyGenObject*); 74 75 version(Python_3_5_Or_Later) { 76 /// _ 77 int _PyGen_SetStopIterationValue(PyObject*); 78 }