File indexing completed on 2025-12-11 10:35:18
0001
0002
0003
0004
0005 #ifndef Py_GREENLETOBJECT_H
0006 #define Py_GREENLETOBJECT_H
0007
0008
0009 #include <Python.h>
0010
0011 #ifdef __cplusplus
0012 extern "C" {
0013 #endif
0014
0015
0016 #define GREENLET_VERSION "1.0.0"
0017
0018 #ifndef GREENLET_MODULE
0019 #define implementation_ptr_t void*
0020 #endif
0021
0022 typedef struct _greenlet {
0023 PyObject_HEAD
0024 PyObject* weakreflist;
0025 PyObject* dict;
0026 implementation_ptr_t pimpl;
0027 } PyGreenlet;
0028
0029 #define PyGreenlet_Check(op) (op && PyObject_TypeCheck(op, &PyGreenlet_Type))
0030
0031
0032
0033
0034
0035 #define PyGreenlet_API_pointers 12
0036
0037 #define PyGreenlet_Type_NUM 0
0038 #define PyExc_GreenletError_NUM 1
0039 #define PyExc_GreenletExit_NUM 2
0040
0041 #define PyGreenlet_New_NUM 3
0042 #define PyGreenlet_GetCurrent_NUM 4
0043 #define PyGreenlet_Throw_NUM 5
0044 #define PyGreenlet_Switch_NUM 6
0045 #define PyGreenlet_SetParent_NUM 7
0046
0047 #define PyGreenlet_MAIN_NUM 8
0048 #define PyGreenlet_STARTED_NUM 9
0049 #define PyGreenlet_ACTIVE_NUM 10
0050 #define PyGreenlet_GET_PARENT_NUM 11
0051
0052 #ifndef GREENLET_MODULE
0053
0054 static void** _PyGreenlet_API = NULL;
0055
0056 # define PyGreenlet_Type \
0057 (*(PyTypeObject*)_PyGreenlet_API[PyGreenlet_Type_NUM])
0058
0059 # define PyExc_GreenletError \
0060 ((PyObject*)_PyGreenlet_API[PyExc_GreenletError_NUM])
0061
0062 # define PyExc_GreenletExit \
0063 ((PyObject*)_PyGreenlet_API[PyExc_GreenletExit_NUM])
0064
0065
0066
0067
0068
0069
0070 # define PyGreenlet_New \
0071 (*(PyGreenlet * (*)(PyObject * run, PyGreenlet * parent)) \
0072 _PyGreenlet_API[PyGreenlet_New_NUM])
0073
0074
0075
0076
0077
0078
0079 # define PyGreenlet_GetCurrent \
0080 (*(PyGreenlet * (*)(void)) _PyGreenlet_API[PyGreenlet_GetCurrent_NUM])
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091 # define PyGreenlet_Throw \
0092 (*(PyObject * (*)(PyGreenlet * self, \
0093 PyObject * typ, \
0094 PyObject * val, \
0095 PyObject * tb)) \
0096 _PyGreenlet_API[PyGreenlet_Throw_NUM])
0097
0098
0099
0100
0101
0102
0103 # define PyGreenlet_Switch \
0104 (*(PyObject * \
0105 (*)(PyGreenlet * greenlet, PyObject * args, PyObject * kwargs)) \
0106 _PyGreenlet_API[PyGreenlet_Switch_NUM])
0107
0108
0109
0110
0111
0112
0113 # define PyGreenlet_SetParent \
0114 (*(int (*)(PyGreenlet * greenlet, PyGreenlet * nparent)) \
0115 _PyGreenlet_API[PyGreenlet_SetParent_NUM])
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126 # define PyGreenlet_GetParent \
0127 (*(PyGreenlet* (*)(PyGreenlet*)) \
0128 _PyGreenlet_API[PyGreenlet_GET_PARENT_NUM])
0129
0130
0131
0132
0133 # define PyGreenlet_GET_PARENT PyGreenlet_GetParent
0134
0135 # define PyGreenlet_MAIN \
0136 (*(int (*)(PyGreenlet*)) \
0137 _PyGreenlet_API[PyGreenlet_MAIN_NUM])
0138
0139 # define PyGreenlet_STARTED \
0140 (*(int (*)(PyGreenlet*)) \
0141 _PyGreenlet_API[PyGreenlet_STARTED_NUM])
0142
0143 # define PyGreenlet_ACTIVE \
0144 (*(int (*)(PyGreenlet*)) \
0145 _PyGreenlet_API[PyGreenlet_ACTIVE_NUM])
0146
0147
0148
0149
0150
0151
0152
0153
0154 # define PyGreenlet_Import() \
0155 { \
0156 _PyGreenlet_API = (void**)PyCapsule_Import("greenlet._C_API", 0); \
0157 }
0158
0159 #endif
0160
0161 #ifdef __cplusplus
0162 }
0163 #endif
0164 #endif