| 1 | /* Cell object interface */ |
|---|---|
| 2 | |
| 3 | #ifndef Py_LIMITED_API |
| 4 | #ifndef Py_CELLOBJECT_H |
| 5 | #define Py_CELLOBJECT_H |
| 6 | #ifdef __cplusplus |
| 7 | extern "C"{ |
| 8 | #endif |
| 9 | |
| 10 | typedef struct { |
| 11 | PyObject_HEAD |
| 12 | /* Content of the cell or NULL when empty */ |
| 13 | PyObject *ob_ref; |
| 14 | } PyCellObject; |
| 15 | |
| 16 | PyAPI_DATA(PyTypeObject) PyCell_Type; |
| 17 | |
| 18 | #define PyCell_Check(op) Py_IS_TYPE((op), &PyCell_Type) |
| 19 | |
| 20 | PyAPI_FUNC(PyObject *) PyCell_New(PyObject *); |
| 21 | PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *); |
| 22 | PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *); |
| 23 | |
| 24 | static inline PyObject* PyCell_GET(PyObject *op) { |
| 25 | PyCellObject *cell; |
| 26 | assert(PyCell_Check(op)); |
| 27 | cell = _Py_CAST(PyCellObject*, op); |
| 28 | return cell->ob_ref; |
| 29 | } |
| 30 | #define PyCell_GET(op) PyCell_GET(_PyObject_CAST(op)) |
| 31 | |
| 32 | static inline void PyCell_SET(PyObject *op, PyObject *value) { |
| 33 | PyCellObject *cell; |
| 34 | assert(PyCell_Check(op)); |
| 35 | cell = _Py_CAST(PyCellObject*, op); |
| 36 | cell->ob_ref = value; |
| 37 | } |
| 38 | #define PyCell_SET(op, value) PyCell_SET(_PyObject_CAST(op), (value)) |
| 39 | |
| 40 | #ifdef __cplusplus |
| 41 | } |
| 42 | #endif |
| 43 | #endif /* !Py_TUPLEOBJECT_H */ |
| 44 | #endif /* Py_LIMITED_API */ |
| 45 |
