Debian Codegraph @

Include/cpython/cellobject.h

raw
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 PyObject *res;
26 PyCellObject *cell;
27 assert(PyCell_Check(op));
28 cell = _Py_CAST(PyCellObject*, op);
29 Py_BEGIN_CRITICAL_SECTION(cell);
30 res = cell->ob_ref;
31 Py_END_CRITICAL_SECTION();
32 return res;
33 }
34 #define PyCell_GET(op) PyCell_GET(_PyObject_CAST(op))
35
36 static inline void PyCell_SET(PyObject *op, PyObject *value) {
37 PyCellObject *cell;
38 assert(PyCell_Check(op));
39 cell = _Py_CAST(PyCellObject*, op);
40 Py_BEGIN_CRITICAL_SECTION(cell);
41 cell->ob_ref = value;
42 Py_END_CRITICAL_SECTION();
43 }
44 #define PyCell_SET(op, value) PyCell_SET(_PyObject_CAST(op), (value))
45
46 #ifdef __cplusplus
47 }
48 #endif
49 #endif /* !Py_TUPLEOBJECT_H */
50 #endif /* Py_LIMITED_API */