LCOV - code coverage report
Current view: top level - Modules/clinic - unicodedata.c.h (source / functions) Hit Total Coverage
Test: CPython 3.12 LCOV report [commit 5e6661bce9] Lines: 0 219 0.0 %
Date: 2023-03-20 08:15:36 Functions: 0 13 0.0 %
Branches: 0 130 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(unicodedata_UCD_decimal__doc__,
      12                 :            : "decimal($self, chr, default=<unrepresentable>, /)\n"
      13                 :            : "--\n"
      14                 :            : "\n"
      15                 :            : "Converts a Unicode character into its equivalent decimal value.\n"
      16                 :            : "\n"
      17                 :            : "Returns the decimal value assigned to the character chr as integer.\n"
      18                 :            : "If no such value is defined, default is returned, or, if not given,\n"
      19                 :            : "ValueError is raised.");
      20                 :            : 
      21                 :            : #define UNICODEDATA_UCD_DECIMAL_METHODDEF    \
      22                 :            :     {"decimal", _PyCFunction_CAST(unicodedata_UCD_decimal), METH_FASTCALL, unicodedata_UCD_decimal__doc__},
      23                 :            : 
      24                 :            : static PyObject *
      25                 :            : unicodedata_UCD_decimal_impl(PyObject *self, int chr,
      26                 :            :                              PyObject *default_value);
      27                 :            : 
      28                 :            : static PyObject *
      29                 :          0 : unicodedata_UCD_decimal(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
      30                 :            : {
      31                 :          0 :     PyObject *return_value = NULL;
      32                 :            :     int chr;
      33                 :          0 :     PyObject *default_value = NULL;
      34                 :            : 
      35   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("decimal", nargs, 1, 2)) {
                   #  # ]
      36                 :          0 :         goto exit;
      37                 :            :     }
      38         [ #  # ]:          0 :     if (!PyUnicode_Check(args[0])) {
      39                 :          0 :         _PyArg_BadArgument("decimal", "argument 1", "a unicode character", args[0]);
      40                 :          0 :         goto exit;
      41                 :            :     }
      42         [ #  # ]:          0 :     if (PyUnicode_READY(args[0])) {
      43                 :          0 :         goto exit;
      44                 :            :     }
      45         [ #  # ]:          0 :     if (PyUnicode_GET_LENGTH(args[0]) != 1) {
      46                 :          0 :         _PyArg_BadArgument("decimal", "argument 1", "a unicode character", args[0]);
      47                 :          0 :         goto exit;
      48                 :            :     }
      49                 :          0 :     chr = PyUnicode_READ_CHAR(args[0], 0);
      50         [ #  # ]:          0 :     if (nargs < 2) {
      51                 :          0 :         goto skip_optional;
      52                 :            :     }
      53                 :          0 :     default_value = args[1];
      54                 :          0 : skip_optional:
      55                 :          0 :     return_value = unicodedata_UCD_decimal_impl(self, chr, default_value);
      56                 :            : 
      57                 :          0 : exit:
      58                 :          0 :     return return_value;
      59                 :            : }
      60                 :            : 
      61                 :            : PyDoc_STRVAR(unicodedata_UCD_digit__doc__,
      62                 :            : "digit($self, chr, default=<unrepresentable>, /)\n"
      63                 :            : "--\n"
      64                 :            : "\n"
      65                 :            : "Converts a Unicode character into its equivalent digit value.\n"
      66                 :            : "\n"
      67                 :            : "Returns the digit value assigned to the character chr as integer.\n"
      68                 :            : "If no such value is defined, default is returned, or, if not given,\n"
      69                 :            : "ValueError is raised.");
      70                 :            : 
      71                 :            : #define UNICODEDATA_UCD_DIGIT_METHODDEF    \
      72                 :            :     {"digit", _PyCFunction_CAST(unicodedata_UCD_digit), METH_FASTCALL, unicodedata_UCD_digit__doc__},
      73                 :            : 
      74                 :            : static PyObject *
      75                 :            : unicodedata_UCD_digit_impl(PyObject *self, int chr, PyObject *default_value);
      76                 :            : 
      77                 :            : static PyObject *
      78                 :          0 : unicodedata_UCD_digit(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
      79                 :            : {
      80                 :          0 :     PyObject *return_value = NULL;
      81                 :            :     int chr;
      82                 :          0 :     PyObject *default_value = NULL;
      83                 :            : 
      84   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("digit", nargs, 1, 2)) {
                   #  # ]
      85                 :          0 :         goto exit;
      86                 :            :     }
      87         [ #  # ]:          0 :     if (!PyUnicode_Check(args[0])) {
      88                 :          0 :         _PyArg_BadArgument("digit", "argument 1", "a unicode character", args[0]);
      89                 :          0 :         goto exit;
      90                 :            :     }
      91         [ #  # ]:          0 :     if (PyUnicode_READY(args[0])) {
      92                 :          0 :         goto exit;
      93                 :            :     }
      94         [ #  # ]:          0 :     if (PyUnicode_GET_LENGTH(args[0]) != 1) {
      95                 :          0 :         _PyArg_BadArgument("digit", "argument 1", "a unicode character", args[0]);
      96                 :          0 :         goto exit;
      97                 :            :     }
      98                 :          0 :     chr = PyUnicode_READ_CHAR(args[0], 0);
      99         [ #  # ]:          0 :     if (nargs < 2) {
     100                 :          0 :         goto skip_optional;
     101                 :            :     }
     102                 :          0 :     default_value = args[1];
     103                 :          0 : skip_optional:
     104                 :          0 :     return_value = unicodedata_UCD_digit_impl(self, chr, default_value);
     105                 :            : 
     106                 :          0 : exit:
     107                 :          0 :     return return_value;
     108                 :            : }
     109                 :            : 
     110                 :            : PyDoc_STRVAR(unicodedata_UCD_numeric__doc__,
     111                 :            : "numeric($self, chr, default=<unrepresentable>, /)\n"
     112                 :            : "--\n"
     113                 :            : "\n"
     114                 :            : "Converts a Unicode character into its equivalent numeric value.\n"
     115                 :            : "\n"
     116                 :            : "Returns the numeric value assigned to the character chr as float.\n"
     117                 :            : "If no such value is defined, default is returned, or, if not given,\n"
     118                 :            : "ValueError is raised.");
     119                 :            : 
     120                 :            : #define UNICODEDATA_UCD_NUMERIC_METHODDEF    \
     121                 :            :     {"numeric", _PyCFunction_CAST(unicodedata_UCD_numeric), METH_FASTCALL, unicodedata_UCD_numeric__doc__},
     122                 :            : 
     123                 :            : static PyObject *
     124                 :            : unicodedata_UCD_numeric_impl(PyObject *self, int chr,
     125                 :            :                              PyObject *default_value);
     126                 :            : 
     127                 :            : static PyObject *
     128                 :          0 : unicodedata_UCD_numeric(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
     129                 :            : {
     130                 :          0 :     PyObject *return_value = NULL;
     131                 :            :     int chr;
     132                 :          0 :     PyObject *default_value = NULL;
     133                 :            : 
     134   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("numeric", nargs, 1, 2)) {
                   #  # ]
     135                 :          0 :         goto exit;
     136                 :            :     }
     137         [ #  # ]:          0 :     if (!PyUnicode_Check(args[0])) {
     138                 :          0 :         _PyArg_BadArgument("numeric", "argument 1", "a unicode character", args[0]);
     139                 :          0 :         goto exit;
     140                 :            :     }
     141         [ #  # ]:          0 :     if (PyUnicode_READY(args[0])) {
     142                 :          0 :         goto exit;
     143                 :            :     }
     144         [ #  # ]:          0 :     if (PyUnicode_GET_LENGTH(args[0]) != 1) {
     145                 :          0 :         _PyArg_BadArgument("numeric", "argument 1", "a unicode character", args[0]);
     146                 :          0 :         goto exit;
     147                 :            :     }
     148                 :          0 :     chr = PyUnicode_READ_CHAR(args[0], 0);
     149         [ #  # ]:          0 :     if (nargs < 2) {
     150                 :          0 :         goto skip_optional;
     151                 :            :     }
     152                 :          0 :     default_value = args[1];
     153                 :          0 : skip_optional:
     154                 :          0 :     return_value = unicodedata_UCD_numeric_impl(self, chr, default_value);
     155                 :            : 
     156                 :          0 : exit:
     157                 :          0 :     return return_value;
     158                 :            : }
     159                 :            : 
     160                 :            : PyDoc_STRVAR(unicodedata_UCD_category__doc__,
     161                 :            : "category($self, chr, /)\n"
     162                 :            : "--\n"
     163                 :            : "\n"
     164                 :            : "Returns the general category assigned to the character chr as string.");
     165                 :            : 
     166                 :            : #define UNICODEDATA_UCD_CATEGORY_METHODDEF    \
     167                 :            :     {"category", (PyCFunction)unicodedata_UCD_category, METH_O, unicodedata_UCD_category__doc__},
     168                 :            : 
     169                 :            : static PyObject *
     170                 :            : unicodedata_UCD_category_impl(PyObject *self, int chr);
     171                 :            : 
     172                 :            : static PyObject *
     173                 :          0 : unicodedata_UCD_category(PyObject *self, PyObject *arg)
     174                 :            : {
     175                 :          0 :     PyObject *return_value = NULL;
     176                 :            :     int chr;
     177                 :            : 
     178         [ #  # ]:          0 :     if (!PyUnicode_Check(arg)) {
     179                 :          0 :         _PyArg_BadArgument("category", "argument", "a unicode character", arg);
     180                 :          0 :         goto exit;
     181                 :            :     }
     182         [ #  # ]:          0 :     if (PyUnicode_READY(arg)) {
     183                 :          0 :         goto exit;
     184                 :            :     }
     185         [ #  # ]:          0 :     if (PyUnicode_GET_LENGTH(arg) != 1) {
     186                 :          0 :         _PyArg_BadArgument("category", "argument", "a unicode character", arg);
     187                 :          0 :         goto exit;
     188                 :            :     }
     189                 :          0 :     chr = PyUnicode_READ_CHAR(arg, 0);
     190                 :          0 :     return_value = unicodedata_UCD_category_impl(self, chr);
     191                 :            : 
     192                 :          0 : exit:
     193                 :          0 :     return return_value;
     194                 :            : }
     195                 :            : 
     196                 :            : PyDoc_STRVAR(unicodedata_UCD_bidirectional__doc__,
     197                 :            : "bidirectional($self, chr, /)\n"
     198                 :            : "--\n"
     199                 :            : "\n"
     200                 :            : "Returns the bidirectional class assigned to the character chr as string.\n"
     201                 :            : "\n"
     202                 :            : "If no such value is defined, an empty string is returned.");
     203                 :            : 
     204                 :            : #define UNICODEDATA_UCD_BIDIRECTIONAL_METHODDEF    \
     205                 :            :     {"bidirectional", (PyCFunction)unicodedata_UCD_bidirectional, METH_O, unicodedata_UCD_bidirectional__doc__},
     206                 :            : 
     207                 :            : static PyObject *
     208                 :            : unicodedata_UCD_bidirectional_impl(PyObject *self, int chr);
     209                 :            : 
     210                 :            : static PyObject *
     211                 :          0 : unicodedata_UCD_bidirectional(PyObject *self, PyObject *arg)
     212                 :            : {
     213                 :          0 :     PyObject *return_value = NULL;
     214                 :            :     int chr;
     215                 :            : 
     216         [ #  # ]:          0 :     if (!PyUnicode_Check(arg)) {
     217                 :          0 :         _PyArg_BadArgument("bidirectional", "argument", "a unicode character", arg);
     218                 :          0 :         goto exit;
     219                 :            :     }
     220         [ #  # ]:          0 :     if (PyUnicode_READY(arg)) {
     221                 :          0 :         goto exit;
     222                 :            :     }
     223         [ #  # ]:          0 :     if (PyUnicode_GET_LENGTH(arg) != 1) {
     224                 :          0 :         _PyArg_BadArgument("bidirectional", "argument", "a unicode character", arg);
     225                 :          0 :         goto exit;
     226                 :            :     }
     227                 :          0 :     chr = PyUnicode_READ_CHAR(arg, 0);
     228                 :          0 :     return_value = unicodedata_UCD_bidirectional_impl(self, chr);
     229                 :            : 
     230                 :          0 : exit:
     231                 :          0 :     return return_value;
     232                 :            : }
     233                 :            : 
     234                 :            : PyDoc_STRVAR(unicodedata_UCD_combining__doc__,
     235                 :            : "combining($self, chr, /)\n"
     236                 :            : "--\n"
     237                 :            : "\n"
     238                 :            : "Returns the canonical combining class assigned to the character chr as integer.\n"
     239                 :            : "\n"
     240                 :            : "Returns 0 if no combining class is defined.");
     241                 :            : 
     242                 :            : #define UNICODEDATA_UCD_COMBINING_METHODDEF    \
     243                 :            :     {"combining", (PyCFunction)unicodedata_UCD_combining, METH_O, unicodedata_UCD_combining__doc__},
     244                 :            : 
     245                 :            : static int
     246                 :            : unicodedata_UCD_combining_impl(PyObject *self, int chr);
     247                 :            : 
     248                 :            : static PyObject *
     249                 :          0 : unicodedata_UCD_combining(PyObject *self, PyObject *arg)
     250                 :            : {
     251                 :          0 :     PyObject *return_value = NULL;
     252                 :            :     int chr;
     253                 :            :     int _return_value;
     254                 :            : 
     255         [ #  # ]:          0 :     if (!PyUnicode_Check(arg)) {
     256                 :          0 :         _PyArg_BadArgument("combining", "argument", "a unicode character", arg);
     257                 :          0 :         goto exit;
     258                 :            :     }
     259         [ #  # ]:          0 :     if (PyUnicode_READY(arg)) {
     260                 :          0 :         goto exit;
     261                 :            :     }
     262         [ #  # ]:          0 :     if (PyUnicode_GET_LENGTH(arg) != 1) {
     263                 :          0 :         _PyArg_BadArgument("combining", "argument", "a unicode character", arg);
     264                 :          0 :         goto exit;
     265                 :            :     }
     266                 :          0 :     chr = PyUnicode_READ_CHAR(arg, 0);
     267                 :          0 :     _return_value = unicodedata_UCD_combining_impl(self, chr);
     268   [ #  #  #  # ]:          0 :     if ((_return_value == -1) && PyErr_Occurred()) {
     269                 :          0 :         goto exit;
     270                 :            :     }
     271                 :          0 :     return_value = PyLong_FromLong((long)_return_value);
     272                 :            : 
     273                 :          0 : exit:
     274                 :          0 :     return return_value;
     275                 :            : }
     276                 :            : 
     277                 :            : PyDoc_STRVAR(unicodedata_UCD_mirrored__doc__,
     278                 :            : "mirrored($self, chr, /)\n"
     279                 :            : "--\n"
     280                 :            : "\n"
     281                 :            : "Returns the mirrored property assigned to the character chr as integer.\n"
     282                 :            : "\n"
     283                 :            : "Returns 1 if the character has been identified as a \"mirrored\"\n"
     284                 :            : "character in bidirectional text, 0 otherwise.");
     285                 :            : 
     286                 :            : #define UNICODEDATA_UCD_MIRRORED_METHODDEF    \
     287                 :            :     {"mirrored", (PyCFunction)unicodedata_UCD_mirrored, METH_O, unicodedata_UCD_mirrored__doc__},
     288                 :            : 
     289                 :            : static int
     290                 :            : unicodedata_UCD_mirrored_impl(PyObject *self, int chr);
     291                 :            : 
     292                 :            : static PyObject *
     293                 :          0 : unicodedata_UCD_mirrored(PyObject *self, PyObject *arg)
     294                 :            : {
     295                 :          0 :     PyObject *return_value = NULL;
     296                 :            :     int chr;
     297                 :            :     int _return_value;
     298                 :            : 
     299         [ #  # ]:          0 :     if (!PyUnicode_Check(arg)) {
     300                 :          0 :         _PyArg_BadArgument("mirrored", "argument", "a unicode character", arg);
     301                 :          0 :         goto exit;
     302                 :            :     }
     303         [ #  # ]:          0 :     if (PyUnicode_READY(arg)) {
     304                 :          0 :         goto exit;
     305                 :            :     }
     306         [ #  # ]:          0 :     if (PyUnicode_GET_LENGTH(arg) != 1) {
     307                 :          0 :         _PyArg_BadArgument("mirrored", "argument", "a unicode character", arg);
     308                 :          0 :         goto exit;
     309                 :            :     }
     310                 :          0 :     chr = PyUnicode_READ_CHAR(arg, 0);
     311                 :          0 :     _return_value = unicodedata_UCD_mirrored_impl(self, chr);
     312   [ #  #  #  # ]:          0 :     if ((_return_value == -1) && PyErr_Occurred()) {
     313                 :          0 :         goto exit;
     314                 :            :     }
     315                 :          0 :     return_value = PyLong_FromLong((long)_return_value);
     316                 :            : 
     317                 :          0 : exit:
     318                 :          0 :     return return_value;
     319                 :            : }
     320                 :            : 
     321                 :            : PyDoc_STRVAR(unicodedata_UCD_east_asian_width__doc__,
     322                 :            : "east_asian_width($self, chr, /)\n"
     323                 :            : "--\n"
     324                 :            : "\n"
     325                 :            : "Returns the east asian width assigned to the character chr as string.");
     326                 :            : 
     327                 :            : #define UNICODEDATA_UCD_EAST_ASIAN_WIDTH_METHODDEF    \
     328                 :            :     {"east_asian_width", (PyCFunction)unicodedata_UCD_east_asian_width, METH_O, unicodedata_UCD_east_asian_width__doc__},
     329                 :            : 
     330                 :            : static PyObject *
     331                 :            : unicodedata_UCD_east_asian_width_impl(PyObject *self, int chr);
     332                 :            : 
     333                 :            : static PyObject *
     334                 :          0 : unicodedata_UCD_east_asian_width(PyObject *self, PyObject *arg)
     335                 :            : {
     336                 :          0 :     PyObject *return_value = NULL;
     337                 :            :     int chr;
     338                 :            : 
     339         [ #  # ]:          0 :     if (!PyUnicode_Check(arg)) {
     340                 :          0 :         _PyArg_BadArgument("east_asian_width", "argument", "a unicode character", arg);
     341                 :          0 :         goto exit;
     342                 :            :     }
     343         [ #  # ]:          0 :     if (PyUnicode_READY(arg)) {
     344                 :          0 :         goto exit;
     345                 :            :     }
     346         [ #  # ]:          0 :     if (PyUnicode_GET_LENGTH(arg) != 1) {
     347                 :          0 :         _PyArg_BadArgument("east_asian_width", "argument", "a unicode character", arg);
     348                 :          0 :         goto exit;
     349                 :            :     }
     350                 :          0 :     chr = PyUnicode_READ_CHAR(arg, 0);
     351                 :          0 :     return_value = unicodedata_UCD_east_asian_width_impl(self, chr);
     352                 :            : 
     353                 :          0 : exit:
     354                 :          0 :     return return_value;
     355                 :            : }
     356                 :            : 
     357                 :            : PyDoc_STRVAR(unicodedata_UCD_decomposition__doc__,
     358                 :            : "decomposition($self, chr, /)\n"
     359                 :            : "--\n"
     360                 :            : "\n"
     361                 :            : "Returns the character decomposition mapping assigned to the character chr as string.\n"
     362                 :            : "\n"
     363                 :            : "An empty string is returned in case no such mapping is defined.");
     364                 :            : 
     365                 :            : #define UNICODEDATA_UCD_DECOMPOSITION_METHODDEF    \
     366                 :            :     {"decomposition", (PyCFunction)unicodedata_UCD_decomposition, METH_O, unicodedata_UCD_decomposition__doc__},
     367                 :            : 
     368                 :            : static PyObject *
     369                 :            : unicodedata_UCD_decomposition_impl(PyObject *self, int chr);
     370                 :            : 
     371                 :            : static PyObject *
     372                 :          0 : unicodedata_UCD_decomposition(PyObject *self, PyObject *arg)
     373                 :            : {
     374                 :          0 :     PyObject *return_value = NULL;
     375                 :            :     int chr;
     376                 :            : 
     377         [ #  # ]:          0 :     if (!PyUnicode_Check(arg)) {
     378                 :          0 :         _PyArg_BadArgument("decomposition", "argument", "a unicode character", arg);
     379                 :          0 :         goto exit;
     380                 :            :     }
     381         [ #  # ]:          0 :     if (PyUnicode_READY(arg)) {
     382                 :          0 :         goto exit;
     383                 :            :     }
     384         [ #  # ]:          0 :     if (PyUnicode_GET_LENGTH(arg) != 1) {
     385                 :          0 :         _PyArg_BadArgument("decomposition", "argument", "a unicode character", arg);
     386                 :          0 :         goto exit;
     387                 :            :     }
     388                 :          0 :     chr = PyUnicode_READ_CHAR(arg, 0);
     389                 :          0 :     return_value = unicodedata_UCD_decomposition_impl(self, chr);
     390                 :            : 
     391                 :          0 : exit:
     392                 :          0 :     return return_value;
     393                 :            : }
     394                 :            : 
     395                 :            : PyDoc_STRVAR(unicodedata_UCD_is_normalized__doc__,
     396                 :            : "is_normalized($self, form, unistr, /)\n"
     397                 :            : "--\n"
     398                 :            : "\n"
     399                 :            : "Return whether the Unicode string unistr is in the normal form \'form\'.\n"
     400                 :            : "\n"
     401                 :            : "Valid values for form are \'NFC\', \'NFKC\', \'NFD\', and \'NFKD\'.");
     402                 :            : 
     403                 :            : #define UNICODEDATA_UCD_IS_NORMALIZED_METHODDEF    \
     404                 :            :     {"is_normalized", _PyCFunction_CAST(unicodedata_UCD_is_normalized), METH_FASTCALL, unicodedata_UCD_is_normalized__doc__},
     405                 :            : 
     406                 :            : static PyObject *
     407                 :            : unicodedata_UCD_is_normalized_impl(PyObject *self, PyObject *form,
     408                 :            :                                    PyObject *input);
     409                 :            : 
     410                 :            : static PyObject *
     411                 :          0 : unicodedata_UCD_is_normalized(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
     412                 :            : {
     413                 :          0 :     PyObject *return_value = NULL;
     414                 :            :     PyObject *form;
     415                 :            :     PyObject *input;
     416                 :            : 
     417   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("is_normalized", nargs, 2, 2)) {
                   #  # ]
     418                 :          0 :         goto exit;
     419                 :            :     }
     420         [ #  # ]:          0 :     if (!PyUnicode_Check(args[0])) {
     421                 :          0 :         _PyArg_BadArgument("is_normalized", "argument 1", "str", args[0]);
     422                 :          0 :         goto exit;
     423                 :            :     }
     424         [ #  # ]:          0 :     if (PyUnicode_READY(args[0]) == -1) {
     425                 :          0 :         goto exit;
     426                 :            :     }
     427                 :          0 :     form = args[0];
     428         [ #  # ]:          0 :     if (!PyUnicode_Check(args[1])) {
     429                 :          0 :         _PyArg_BadArgument("is_normalized", "argument 2", "str", args[1]);
     430                 :          0 :         goto exit;
     431                 :            :     }
     432         [ #  # ]:          0 :     if (PyUnicode_READY(args[1]) == -1) {
     433                 :          0 :         goto exit;
     434                 :            :     }
     435                 :          0 :     input = args[1];
     436                 :          0 :     return_value = unicodedata_UCD_is_normalized_impl(self, form, input);
     437                 :            : 
     438                 :          0 : exit:
     439                 :          0 :     return return_value;
     440                 :            : }
     441                 :            : 
     442                 :            : PyDoc_STRVAR(unicodedata_UCD_normalize__doc__,
     443                 :            : "normalize($self, form, unistr, /)\n"
     444                 :            : "--\n"
     445                 :            : "\n"
     446                 :            : "Return the normal form \'form\' for the Unicode string unistr.\n"
     447                 :            : "\n"
     448                 :            : "Valid values for form are \'NFC\', \'NFKC\', \'NFD\', and \'NFKD\'.");
     449                 :            : 
     450                 :            : #define UNICODEDATA_UCD_NORMALIZE_METHODDEF    \
     451                 :            :     {"normalize", _PyCFunction_CAST(unicodedata_UCD_normalize), METH_FASTCALL, unicodedata_UCD_normalize__doc__},
     452                 :            : 
     453                 :            : static PyObject *
     454                 :            : unicodedata_UCD_normalize_impl(PyObject *self, PyObject *form,
     455                 :            :                                PyObject *input);
     456                 :            : 
     457                 :            : static PyObject *
     458                 :          0 : unicodedata_UCD_normalize(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
     459                 :            : {
     460                 :          0 :     PyObject *return_value = NULL;
     461                 :            :     PyObject *form;
     462                 :            :     PyObject *input;
     463                 :            : 
     464   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("normalize", nargs, 2, 2)) {
                   #  # ]
     465                 :          0 :         goto exit;
     466                 :            :     }
     467         [ #  # ]:          0 :     if (!PyUnicode_Check(args[0])) {
     468                 :          0 :         _PyArg_BadArgument("normalize", "argument 1", "str", args[0]);
     469                 :          0 :         goto exit;
     470                 :            :     }
     471         [ #  # ]:          0 :     if (PyUnicode_READY(args[0]) == -1) {
     472                 :          0 :         goto exit;
     473                 :            :     }
     474                 :          0 :     form = args[0];
     475         [ #  # ]:          0 :     if (!PyUnicode_Check(args[1])) {
     476                 :          0 :         _PyArg_BadArgument("normalize", "argument 2", "str", args[1]);
     477                 :          0 :         goto exit;
     478                 :            :     }
     479         [ #  # ]:          0 :     if (PyUnicode_READY(args[1]) == -1) {
     480                 :          0 :         goto exit;
     481                 :            :     }
     482                 :          0 :     input = args[1];
     483                 :          0 :     return_value = unicodedata_UCD_normalize_impl(self, form, input);
     484                 :            : 
     485                 :          0 : exit:
     486                 :          0 :     return return_value;
     487                 :            : }
     488                 :            : 
     489                 :            : PyDoc_STRVAR(unicodedata_UCD_name__doc__,
     490                 :            : "name($self, chr, default=<unrepresentable>, /)\n"
     491                 :            : "--\n"
     492                 :            : "\n"
     493                 :            : "Returns the name assigned to the character chr as a string.\n"
     494                 :            : "\n"
     495                 :            : "If no name is defined, default is returned, or, if not given,\n"
     496                 :            : "ValueError is raised.");
     497                 :            : 
     498                 :            : #define UNICODEDATA_UCD_NAME_METHODDEF    \
     499                 :            :     {"name", _PyCFunction_CAST(unicodedata_UCD_name), METH_FASTCALL, unicodedata_UCD_name__doc__},
     500                 :            : 
     501                 :            : static PyObject *
     502                 :            : unicodedata_UCD_name_impl(PyObject *self, int chr, PyObject *default_value);
     503                 :            : 
     504                 :            : static PyObject *
     505                 :          0 : unicodedata_UCD_name(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
     506                 :            : {
     507                 :          0 :     PyObject *return_value = NULL;
     508                 :            :     int chr;
     509                 :          0 :     PyObject *default_value = NULL;
     510                 :            : 
     511   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("name", nargs, 1, 2)) {
                   #  # ]
     512                 :          0 :         goto exit;
     513                 :            :     }
     514         [ #  # ]:          0 :     if (!PyUnicode_Check(args[0])) {
     515                 :          0 :         _PyArg_BadArgument("name", "argument 1", "a unicode character", args[0]);
     516                 :          0 :         goto exit;
     517                 :            :     }
     518         [ #  # ]:          0 :     if (PyUnicode_READY(args[0])) {
     519                 :          0 :         goto exit;
     520                 :            :     }
     521         [ #  # ]:          0 :     if (PyUnicode_GET_LENGTH(args[0]) != 1) {
     522                 :          0 :         _PyArg_BadArgument("name", "argument 1", "a unicode character", args[0]);
     523                 :          0 :         goto exit;
     524                 :            :     }
     525                 :          0 :     chr = PyUnicode_READ_CHAR(args[0], 0);
     526         [ #  # ]:          0 :     if (nargs < 2) {
     527                 :          0 :         goto skip_optional;
     528                 :            :     }
     529                 :          0 :     default_value = args[1];
     530                 :          0 : skip_optional:
     531                 :          0 :     return_value = unicodedata_UCD_name_impl(self, chr, default_value);
     532                 :            : 
     533                 :          0 : exit:
     534                 :          0 :     return return_value;
     535                 :            : }
     536                 :            : 
     537                 :            : PyDoc_STRVAR(unicodedata_UCD_lookup__doc__,
     538                 :            : "lookup($self, name, /)\n"
     539                 :            : "--\n"
     540                 :            : "\n"
     541                 :            : "Look up character by name.\n"
     542                 :            : "\n"
     543                 :            : "If a character with the given name is found, return the\n"
     544                 :            : "corresponding character.  If not found, KeyError is raised.");
     545                 :            : 
     546                 :            : #define UNICODEDATA_UCD_LOOKUP_METHODDEF    \
     547                 :            :     {"lookup", (PyCFunction)unicodedata_UCD_lookup, METH_O, unicodedata_UCD_lookup__doc__},
     548                 :            : 
     549                 :            : static PyObject *
     550                 :            : unicodedata_UCD_lookup_impl(PyObject *self, const char *name,
     551                 :            :                             Py_ssize_t name_length);
     552                 :            : 
     553                 :            : static PyObject *
     554                 :          0 : unicodedata_UCD_lookup(PyObject *self, PyObject *arg)
     555                 :            : {
     556                 :          0 :     PyObject *return_value = NULL;
     557                 :            :     const char *name;
     558                 :            :     Py_ssize_t name_length;
     559                 :            : 
     560         [ #  # ]:          0 :     if (!PyArg_Parse(arg, "s#:lookup", &name, &name_length)) {
     561                 :          0 :         goto exit;
     562                 :            :     }
     563                 :          0 :     return_value = unicodedata_UCD_lookup_impl(self, name, name_length);
     564                 :            : 
     565                 :          0 : exit:
     566                 :          0 :     return return_value;
     567                 :            : }
     568                 :            : /*[clinic end generated code: output=aaf601d28b352353 input=a9049054013a1b77]*/

Generated by: LCOV version 1.14