summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Include/cpython/listobject.h
diff options
context:
space:
mode:
authorthegeorg <[email protected]>2024-02-19 02:38:52 +0300
committerthegeorg <[email protected]>2024-02-19 02:50:43 +0300
commitd96fa07134c06472bfee6718b5cfd1679196fc99 (patch)
tree31ec344fa9d3ff8dc038692516b6438dfbdb8a2d /contrib/tools/python3/Include/cpython/listobject.h
parent452cf9e068aef7110e35e654c5d47eb80111ef89 (diff)
Sync contrib/tools/python3 layout with upstream
* Move src/ subdir contents to the top of the layout * Rename self-written lib -> lib2 to avoid CaseFolding warning from the VCS * Regenerate contrib/libs/python proxy-headers accordingly 4ccc62ac1511abcf0fed14ccade38e984e088f1e
Diffstat (limited to 'contrib/tools/python3/Include/cpython/listobject.h')
-rw-r--r--contrib/tools/python3/Include/cpython/listobject.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/contrib/tools/python3/Include/cpython/listobject.h b/contrib/tools/python3/Include/cpython/listobject.h
new file mode 100644
index 00000000000..8fa82122d8d
--- /dev/null
+++ b/contrib/tools/python3/Include/cpython/listobject.h
@@ -0,0 +1,47 @@
+#ifndef Py_CPYTHON_LISTOBJECT_H
+# error "this header file must not be included directly"
+#endif
+
+typedef struct {
+ PyObject_VAR_HEAD
+ /* Vector of pointers to list elements. list[0] is ob_item[0], etc. */
+ PyObject **ob_item;
+
+ /* ob_item contains space for 'allocated' elements. The number
+ * currently in use is ob_size.
+ * Invariants:
+ * 0 <= ob_size <= allocated
+ * len(list) == ob_size
+ * ob_item == NULL implies ob_size == allocated == 0
+ * list.sort() temporarily sets allocated to -1 to detect mutations.
+ *
+ * Items must normally not be NULL, except during construction when
+ * the list is not yet visible outside the function that builds it.
+ */
+ Py_ssize_t allocated;
+} PyListObject;
+
+PyAPI_FUNC(PyObject *) _PyList_Extend(PyListObject *, PyObject *);
+PyAPI_FUNC(void) _PyList_DebugMallocStats(FILE *out);
+
+/* Cast argument to PyListObject* type. */
+#define _PyList_CAST(op) \
+ (assert(PyList_Check(op)), _Py_CAST(PyListObject*, (op)))
+
+// Macros and static inline functions, trading safety for speed
+
+static inline Py_ssize_t PyList_GET_SIZE(PyObject *op) {
+ PyListObject *list = _PyList_CAST(op);
+ return Py_SIZE(list);
+}
+#define PyList_GET_SIZE(op) PyList_GET_SIZE(_PyObject_CAST(op))
+
+#define PyList_GET_ITEM(op, index) (_PyList_CAST(op)->ob_item[(index)])
+
+static inline void
+PyList_SET_ITEM(PyObject *op, Py_ssize_t index, PyObject *value) {
+ PyListObject *list = _PyList_CAST(op);
+ list->ob_item[index] = value;
+}
+#define PyList_SET_ITEM(op, index, value) \
+ PyList_SET_ITEM(_PyObject_CAST(op), (index), _PyObject_CAST(value))