summaryrefslogtreecommitdiffstats
path: root/Modules/clinic/_weakref.c.h
diff options
context:
space:
mode:
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>2022-03-07 09:57:45 (GMT)
committerGitHub <noreply@github.com>2022-03-07 09:57:45 (GMT)
commit5c06dba21b9767127f042b8a168703f06338c3f4 (patch)
tree9d0120fe1fea5512b8e875ecd7597d2c05f78e48 /Modules/clinic/_weakref.c.h
parent496c428de3318c9c5770937491b71dc3d3f18a6a (diff)
downloadcpython-5c06dba21b9767127f042b8a168703f06338c3f4.zip
cpython-5c06dba21b9767127f042b8a168703f06338c3f4.tar.gz
cpython-5c06dba21b9767127f042b8a168703f06338c3f4.tar.bz2
bpo-46937: convert remaining functions to AC in _weakref (GH-31705)
Diffstat (limited to 'Modules/clinic/_weakref.c.h')
-rw-r--r--Modules/clinic/_weakref.c.h48
1 files changed, 47 insertions, 1 deletions
diff --git a/Modules/clinic/_weakref.c.h b/Modules/clinic/_weakref.c.h
index c3a908f..02f0168 100644
--- a/Modules/clinic/_weakref.c.h
+++ b/Modules/clinic/_weakref.c.h
@@ -64,4 +64,50 @@ _weakref__remove_dead_weakref(PyObject *module, PyObject *const *args, Py_ssize_
exit:
return return_value;
}
-/*[clinic end generated code: output=c543dc2cd6ece975 input=a9049054013a1b77]*/
+
+PyDoc_STRVAR(_weakref_getweakrefs__doc__,
+"getweakrefs($module, object, /)\n"
+"--\n"
+"\n"
+"Return a list of all weak reference objects pointing to \'object\'.");
+
+#define _WEAKREF_GETWEAKREFS_METHODDEF \
+ {"getweakrefs", (PyCFunction)_weakref_getweakrefs, METH_O, _weakref_getweakrefs__doc__},
+
+PyDoc_STRVAR(_weakref_proxy__doc__,
+"proxy($module, object, callback=None, /)\n"
+"--\n"
+"\n"
+"Create a proxy object that weakly references \'object\'.\n"
+"\n"
+"\'callback\', if given, is called with a reference to the\n"
+"proxy when \'object\' is about to be finalized.");
+
+#define _WEAKREF_PROXY_METHODDEF \
+ {"proxy", (PyCFunction)(void(*)(void))_weakref_proxy, METH_FASTCALL, _weakref_proxy__doc__},
+
+static PyObject *
+_weakref_proxy_impl(PyObject *module, PyObject *object, PyObject *callback);
+
+static PyObject *
+_weakref_proxy(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
+{
+ PyObject *return_value = NULL;
+ PyObject *object;
+ PyObject *callback = NULL;
+
+ if (!_PyArg_CheckPositional("proxy", nargs, 1, 2)) {
+ goto exit;
+ }
+ object = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ callback = args[1];
+skip_optional:
+ return_value = _weakref_proxy_impl(module, object, callback);
+
+exit:
+ return return_value;
+}
+/*[clinic end generated code: output=5a10a1fa43722399 input=a9049054013a1b77]*/