LCOV - code coverage report
Current view: top level - Modules/clinic - _weakref.c.h (source / functions) Hit Total Coverage
Test: CPython 3.12 LCOV report [commit 5e6661bce9] Lines: 0 33 0.0 %
Date: 2023-03-20 08:15:36 Functions: 0 3 0.0 %
Branches: 0 20 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*[clinic input]
       2                 :            : preserve
       3                 :            : [clinic start generated code]*/
       4                 :            : 
       5                 :            : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
       6                 :            : #  include "pycore_gc.h"            // PyGC_Head
       7                 :            : #  include "pycore_runtime.h"       // _Py_ID()
       8                 :            : #endif
       9                 :            : 
      10                 :            : 
      11                 :            : PyDoc_STRVAR(_weakref_getweakrefcount__doc__,
      12                 :            : "getweakrefcount($module, object, /)\n"
      13                 :            : "--\n"
      14                 :            : "\n"
      15                 :            : "Return the number of weak references to \'object\'.");
      16                 :            : 
      17                 :            : #define _WEAKREF_GETWEAKREFCOUNT_METHODDEF    \
      18                 :            :     {"getweakrefcount", (PyCFunction)_weakref_getweakrefcount, METH_O, _weakref_getweakrefcount__doc__},
      19                 :            : 
      20                 :            : static Py_ssize_t
      21                 :            : _weakref_getweakrefcount_impl(PyObject *module, PyObject *object);
      22                 :            : 
      23                 :            : static PyObject *
      24                 :          0 : _weakref_getweakrefcount(PyObject *module, PyObject *object)
      25                 :            : {
      26                 :          0 :     PyObject *return_value = NULL;
      27                 :            :     Py_ssize_t _return_value;
      28                 :            : 
      29                 :          0 :     _return_value = _weakref_getweakrefcount_impl(module, object);
      30   [ #  #  #  # ]:          0 :     if ((_return_value == -1) && PyErr_Occurred()) {
      31                 :          0 :         goto exit;
      32                 :            :     }
      33                 :          0 :     return_value = PyLong_FromSsize_t(_return_value);
      34                 :            : 
      35                 :          0 : exit:
      36                 :          0 :     return return_value;
      37                 :            : }
      38                 :            : 
      39                 :            : PyDoc_STRVAR(_weakref__remove_dead_weakref__doc__,
      40                 :            : "_remove_dead_weakref($module, dct, key, /)\n"
      41                 :            : "--\n"
      42                 :            : "\n"
      43                 :            : "Atomically remove key from dict if it points to a dead weakref.");
      44                 :            : 
      45                 :            : #define _WEAKREF__REMOVE_DEAD_WEAKREF_METHODDEF    \
      46                 :            :     {"_remove_dead_weakref", _PyCFunction_CAST(_weakref__remove_dead_weakref), METH_FASTCALL, _weakref__remove_dead_weakref__doc__},
      47                 :            : 
      48                 :            : static PyObject *
      49                 :            : _weakref__remove_dead_weakref_impl(PyObject *module, PyObject *dct,
      50                 :            :                                    PyObject *key);
      51                 :            : 
      52                 :            : static PyObject *
      53                 :          0 : _weakref__remove_dead_weakref(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
      54                 :            : {
      55                 :          0 :     PyObject *return_value = NULL;
      56                 :            :     PyObject *dct;
      57                 :            :     PyObject *key;
      58                 :            : 
      59   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("_remove_dead_weakref", nargs, 2, 2)) {
                   #  # ]
      60                 :          0 :         goto exit;
      61                 :            :     }
      62         [ #  # ]:          0 :     if (!PyDict_Check(args[0])) {
      63                 :          0 :         _PyArg_BadArgument("_remove_dead_weakref", "argument 1", "dict", args[0]);
      64                 :          0 :         goto exit;
      65                 :            :     }
      66                 :          0 :     dct = args[0];
      67                 :          0 :     key = args[1];
      68                 :          0 :     return_value = _weakref__remove_dead_weakref_impl(module, dct, key);
      69                 :            : 
      70                 :          0 : exit:
      71                 :          0 :     return return_value;
      72                 :            : }
      73                 :            : 
      74                 :            : PyDoc_STRVAR(_weakref_getweakrefs__doc__,
      75                 :            : "getweakrefs($module, object, /)\n"
      76                 :            : "--\n"
      77                 :            : "\n"
      78                 :            : "Return a list of all weak reference objects pointing to \'object\'.");
      79                 :            : 
      80                 :            : #define _WEAKREF_GETWEAKREFS_METHODDEF    \
      81                 :            :     {"getweakrefs", (PyCFunction)_weakref_getweakrefs, METH_O, _weakref_getweakrefs__doc__},
      82                 :            : 
      83                 :            : PyDoc_STRVAR(_weakref_proxy__doc__,
      84                 :            : "proxy($module, object, callback=None, /)\n"
      85                 :            : "--\n"
      86                 :            : "\n"
      87                 :            : "Create a proxy object that weakly references \'object\'.\n"
      88                 :            : "\n"
      89                 :            : "\'callback\', if given, is called with a reference to the\n"
      90                 :            : "proxy when \'object\' is about to be finalized.");
      91                 :            : 
      92                 :            : #define _WEAKREF_PROXY_METHODDEF    \
      93                 :            :     {"proxy", _PyCFunction_CAST(_weakref_proxy), METH_FASTCALL, _weakref_proxy__doc__},
      94                 :            : 
      95                 :            : static PyObject *
      96                 :            : _weakref_proxy_impl(PyObject *module, PyObject *object, PyObject *callback);
      97                 :            : 
      98                 :            : static PyObject *
      99                 :          0 : _weakref_proxy(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     100                 :            : {
     101                 :          0 :     PyObject *return_value = NULL;
     102                 :            :     PyObject *object;
     103                 :          0 :     PyObject *callback = NULL;
     104                 :            : 
     105   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("proxy", nargs, 1, 2)) {
                   #  # ]
     106                 :          0 :         goto exit;
     107                 :            :     }
     108                 :          0 :     object = args[0];
     109         [ #  # ]:          0 :     if (nargs < 2) {
     110                 :          0 :         goto skip_optional;
     111                 :            :     }
     112                 :          0 :     callback = args[1];
     113                 :          0 : skip_optional:
     114                 :          0 :     return_value = _weakref_proxy_impl(module, object, callback);
     115                 :            : 
     116                 :          0 : exit:
     117                 :          0 :     return return_value;
     118                 :            : }
     119                 :            : /*[clinic end generated code: output=28265e89d583273d input=a9049054013a1b77]*/

Generated by: LCOV version 1.14