summaryrefslogtreecommitdiffstats
path: root/Include/cpython
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2022-10-21 13:41:51 (GMT)
committerGitHub <noreply@github.com>2022-10-21 13:41:51 (GMT)
commit82ccbf69a842db25d8117f1c41b47aa5b4ed96ab (patch)
tree3a8bdfc3eb837106664433c2e385276fccf64c06 /Include/cpython
parent8367ca136ed7616cb1f71bd9f1ec98dbcfd35d98 (diff)
downloadcpython-82ccbf69a842db25d8117f1c41b47aa5b4ed96ab.zip
cpython-82ccbf69a842db25d8117f1c41b47aa5b4ed96ab.tar.gz
cpython-82ccbf69a842db25d8117f1c41b47aa5b4ed96ab.tar.bz2
gh-91051: allow setting a callback hook on PyType_Modified (GH-97875)
Diffstat (limited to 'Include/cpython')
-rw-r--r--Include/cpython/object.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/Include/cpython/object.h b/Include/cpython/object.h
index c80fc1d..900b523 100644
--- a/Include/cpython/object.h
+++ b/Include/cpython/object.h
@@ -224,6 +224,9 @@ struct _typeobject {
destructor tp_finalize;
vectorcallfunc tp_vectorcall;
+
+ /* bitset of which type-watchers care about this type */
+ char tp_watched;
};
/* This struct is used by the specializer
@@ -510,3 +513,11 @@ Py_DEPRECATED(3.11) typedef int UsingDeprecatedTrashcanMacro;
PyAPI_FUNC(int) _PyObject_VisitManagedDict(PyObject *obj, visitproc visit, void *arg);
PyAPI_FUNC(void) _PyObject_ClearManagedDict(PyObject *obj);
+
+#define TYPE_MAX_WATCHERS 8
+
+typedef int(*PyType_WatchCallback)(PyTypeObject *);
+PyAPI_FUNC(int) PyType_AddWatcher(PyType_WatchCallback callback);
+PyAPI_FUNC(int) PyType_ClearWatcher(int watcher_id);
+PyAPI_FUNC(int) PyType_Watch(int watcher_id, PyObject *type);
+PyAPI_FUNC(int) PyType_Unwatch(int watcher_id, PyObject *type);