cellobject.h 1.1 KB

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