LCOV - code coverage report
Current view: top level - Objects/clinic - complexobject.c.h (source / functions) Hit Total Coverage
Test: CPython lcov report Lines: 34 37 91.9 %
Date: 2022-07-07 18:19:46 Functions: 5 5 100.0 %

          Line data    Source code
       1             : /*[clinic input]
       2             : preserve
       3             : [clinic start generated code]*/
       4             : 
       5             : PyDoc_STRVAR(complex_conjugate__doc__,
       6             : "conjugate($self, /)\n"
       7             : "--\n"
       8             : "\n"
       9             : "Return the complex conjugate of its argument. (3-4j).conjugate() == 3+4j.");
      10             : 
      11             : #define COMPLEX_CONJUGATE_METHODDEF    \
      12             :     {"conjugate", (PyCFunction)complex_conjugate, METH_NOARGS, complex_conjugate__doc__},
      13             : 
      14             : static PyObject *
      15             : complex_conjugate_impl(PyComplexObject *self);
      16             : 
      17             : static PyObject *
      18           1 : complex_conjugate(PyComplexObject *self, PyObject *Py_UNUSED(ignored))
      19             : {
      20           1 :     return complex_conjugate_impl(self);
      21             : }
      22             : 
      23             : PyDoc_STRVAR(complex___getnewargs____doc__,
      24             : "__getnewargs__($self, /)\n"
      25             : "--\n"
      26             : "\n");
      27             : 
      28             : #define COMPLEX___GETNEWARGS___METHODDEF    \
      29             :     {"__getnewargs__", (PyCFunction)complex___getnewargs__, METH_NOARGS, complex___getnewargs____doc__},
      30             : 
      31             : static PyObject *
      32             : complex___getnewargs___impl(PyComplexObject *self);
      33             : 
      34             : static PyObject *
      35          54 : complex___getnewargs__(PyComplexObject *self, PyObject *Py_UNUSED(ignored))
      36             : {
      37          54 :     return complex___getnewargs___impl(self);
      38             : }
      39             : 
      40             : PyDoc_STRVAR(complex___format____doc__,
      41             : "__format__($self, format_spec, /)\n"
      42             : "--\n"
      43             : "\n"
      44             : "Convert to a string according to format_spec.");
      45             : 
      46             : #define COMPLEX___FORMAT___METHODDEF    \
      47             :     {"__format__", (PyCFunction)complex___format__, METH_O, complex___format____doc__},
      48             : 
      49             : static PyObject *
      50             : complex___format___impl(PyComplexObject *self, PyObject *format_spec);
      51             : 
      52             : static PyObject *
      53         112 : complex___format__(PyComplexObject *self, PyObject *arg)
      54             : {
      55         112 :     PyObject *return_value = NULL;
      56             :     PyObject *format_spec;
      57             : 
      58         112 :     if (!PyUnicode_Check(arg)) {
      59           0 :         _PyArg_BadArgument("__format__", "argument", "str", arg);
      60           0 :         goto exit;
      61             :     }
      62         112 :     if (PyUnicode_READY(arg) == -1) {
      63           0 :         goto exit;
      64             :     }
      65         112 :     format_spec = arg;
      66         112 :     return_value = complex___format___impl(self, format_spec);
      67             : 
      68         112 : exit:
      69         112 :     return return_value;
      70             : }
      71             : 
      72             : PyDoc_STRVAR(complex___complex____doc__,
      73             : "__complex__($self, /)\n"
      74             : "--\n"
      75             : "\n"
      76             : "Convert this value to exact type complex.");
      77             : 
      78             : #define COMPLEX___COMPLEX___METHODDEF    \
      79             :     {"__complex__", (PyCFunction)complex___complex__, METH_NOARGS, complex___complex____doc__},
      80             : 
      81             : static PyObject *
      82             : complex___complex___impl(PyComplexObject *self);
      83             : 
      84             : static PyObject *
      85         339 : complex___complex__(PyComplexObject *self, PyObject *Py_UNUSED(ignored))
      86             : {
      87         339 :     return complex___complex___impl(self);
      88             : }
      89             : 
      90             : PyDoc_STRVAR(complex_new__doc__,
      91             : "complex(real=0, imag=0)\n"
      92             : "--\n"
      93             : "\n"
      94             : "Create a complex number from a real part and an optional imaginary part.\n"
      95             : "\n"
      96             : "This is equivalent to (real + imag*1j) where imag defaults to 0.");
      97             : 
      98             : static PyObject *
      99             : complex_new_impl(PyTypeObject *type, PyObject *r, PyObject *i);
     100             : 
     101             : static PyObject *
     102        9571 : complex_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
     103             : {
     104        9571 :     PyObject *return_value = NULL;
     105             :     static const char * const _keywords[] = {"real", "imag", NULL};
     106             :     static _PyArg_Parser _parser = {NULL, _keywords, "complex", 0};
     107             :     PyObject *argsbuf[2];
     108             :     PyObject * const *fastargs;
     109        9571 :     Py_ssize_t nargs = PyTuple_GET_SIZE(args);
     110        9571 :     Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0;
     111        9571 :     PyObject *r = NULL;
     112        9571 :     PyObject *i = NULL;
     113             : 
     114        9571 :     fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 2, 0, argsbuf);
     115        9571 :     if (!fastargs) {
     116           1 :         goto exit;
     117             :     }
     118        9570 :     if (!noptargs) {
     119           5 :         goto skip_optional_pos;
     120             :     }
     121        9565 :     if (fastargs[0]) {
     122        9565 :         r = fastargs[0];
     123        9565 :         if (!--noptargs) {
     124        1018 :             goto skip_optional_pos;
     125             :         }
     126             :     }
     127        8547 :     i = fastargs[1];
     128        9570 : skip_optional_pos:
     129        9570 :     return_value = complex_new_impl(type, r, i);
     130             : 
     131        9571 : exit:
     132        9571 :     return return_value;
     133             : }
     134             : /*[clinic end generated code: output=6d85094ace15677e input=a9049054013a1b77]*/

Generated by: LCOV version 1.14