diff options
Diffstat (limited to 'Modules/clinic/_weakref.c.h')
-rw-r--r-- | Modules/clinic/_weakref.c.h | 48 |
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]*/ |