Home | History | Annotate | Download | only in clinic
      1 /*[clinic input]
      2 preserve
      3 [clinic start generated code]*/
      4 
      5 PyDoc_STRVAR(unicodedata_UCD_decimal__doc__,
      6 "decimal($self, chr, default=None, /)\n"
      7 "--\n"
      8 "\n"
      9 "Converts a Unicode character into its equivalent decimal value.\n"
     10 "\n"
     11 "Returns the decimal value assigned to the character chr as integer.\n"
     12 "If no such value is defined, default is returned, or, if not given,\n"
     13 "ValueError is raised.");
     14 
     15 #define UNICODEDATA_UCD_DECIMAL_METHODDEF    \
     16     {"decimal", (PyCFunction)unicodedata_UCD_decimal, METH_VARARGS, unicodedata_UCD_decimal__doc__},
     17 
     18 static PyObject *
     19 unicodedata_UCD_decimal_impl(PyObject *self, int chr,
     20                              PyObject *default_value);
     21 
     22 static PyObject *
     23 unicodedata_UCD_decimal(PyObject *self, PyObject *args)
     24 {
     25     PyObject *return_value = NULL;
     26     int chr;
     27     PyObject *default_value = NULL;
     28 
     29     if (!PyArg_ParseTuple(args, "C|O:decimal",
     30         &chr, &default_value)) {
     31         goto exit;
     32     }
     33     return_value = unicodedata_UCD_decimal_impl(self, chr, default_value);
     34 
     35 exit:
     36     return return_value;
     37 }
     38 
     39 PyDoc_STRVAR(unicodedata_UCD_digit__doc__,
     40 "digit($self, chr, default=None, /)\n"
     41 "--\n"
     42 "\n"
     43 "Converts a Unicode character into its equivalent digit value.\n"
     44 "\n"
     45 "Returns the digit value assigned to the character chr as integer.\n"
     46 "If no such value is defined, default is returned, or, if not given,\n"
     47 "ValueError is raised.");
     48 
     49 #define UNICODEDATA_UCD_DIGIT_METHODDEF    \
     50     {"digit", (PyCFunction)unicodedata_UCD_digit, METH_VARARGS, unicodedata_UCD_digit__doc__},
     51 
     52 static PyObject *
     53 unicodedata_UCD_digit_impl(PyObject *self, int chr, PyObject *default_value);
     54 
     55 static PyObject *
     56 unicodedata_UCD_digit(PyObject *self, PyObject *args)
     57 {
     58     PyObject *return_value = NULL;
     59     int chr;
     60     PyObject *default_value = NULL;
     61 
     62     if (!PyArg_ParseTuple(args, "C|O:digit",
     63         &chr, &default_value)) {
     64         goto exit;
     65     }
     66     return_value = unicodedata_UCD_digit_impl(self, chr, default_value);
     67 
     68 exit:
     69     return return_value;
     70 }
     71 
     72 PyDoc_STRVAR(unicodedata_UCD_numeric__doc__,
     73 "numeric($self, chr, default=None, /)\n"
     74 "--\n"
     75 "\n"
     76 "Converts a Unicode character into its equivalent numeric value.\n"
     77 "\n"
     78 "Returns the numeric value assigned to the character chr as float.\n"
     79 "If no such value is defined, default is returned, or, if not given,\n"
     80 "ValueError is raised.");
     81 
     82 #define UNICODEDATA_UCD_NUMERIC_METHODDEF    \
     83     {"numeric", (PyCFunction)unicodedata_UCD_numeric, METH_VARARGS, unicodedata_UCD_numeric__doc__},
     84 
     85 static PyObject *
     86 unicodedata_UCD_numeric_impl(PyObject *self, int chr,
     87                              PyObject *default_value);
     88 
     89 static PyObject *
     90 unicodedata_UCD_numeric(PyObject *self, PyObject *args)
     91 {
     92     PyObject *return_value = NULL;
     93     int chr;
     94     PyObject *default_value = NULL;
     95 
     96     if (!PyArg_ParseTuple(args, "C|O:numeric",
     97         &chr, &default_value)) {
     98         goto exit;
     99     }
    100     return_value = unicodedata_UCD_numeric_impl(self, chr, default_value);
    101 
    102 exit:
    103     return return_value;
    104 }
    105 
    106 PyDoc_STRVAR(unicodedata_UCD_category__doc__,
    107 "category($self, chr, /)\n"
    108 "--\n"
    109 "\n"
    110 "Returns the general category assigned to the character chr as string.");
    111 
    112 #define UNICODEDATA_UCD_CATEGORY_METHODDEF    \
    113     {"category", (PyCFunction)unicodedata_UCD_category, METH_O, unicodedata_UCD_category__doc__},
    114 
    115 static PyObject *
    116 unicodedata_UCD_category_impl(PyObject *self, int chr);
    117 
    118 static PyObject *
    119 unicodedata_UCD_category(PyObject *self, PyObject *arg)
    120 {
    121     PyObject *return_value = NULL;
    122     int chr;
    123 
    124     if (!PyArg_Parse(arg, "C:category", &chr)) {
    125         goto exit;
    126     }
    127     return_value = unicodedata_UCD_category_impl(self, chr);
    128 
    129 exit:
    130     return return_value;
    131 }
    132 
    133 PyDoc_STRVAR(unicodedata_UCD_bidirectional__doc__,
    134 "bidirectional($self, chr, /)\n"
    135 "--\n"
    136 "\n"
    137 "Returns the bidirectional class assigned to the character chr as string.\n"
    138 "\n"
    139 "If no such value is defined, an empty string is returned.");
    140 
    141 #define UNICODEDATA_UCD_BIDIRECTIONAL_METHODDEF    \
    142     {"bidirectional", (PyCFunction)unicodedata_UCD_bidirectional, METH_O, unicodedata_UCD_bidirectional__doc__},
    143 
    144 static PyObject *
    145 unicodedata_UCD_bidirectional_impl(PyObject *self, int chr);
    146 
    147 static PyObject *
    148 unicodedata_UCD_bidirectional(PyObject *self, PyObject *arg)
    149 {
    150     PyObject *return_value = NULL;
    151     int chr;
    152 
    153     if (!PyArg_Parse(arg, "C:bidirectional", &chr)) {
    154         goto exit;
    155     }
    156     return_value = unicodedata_UCD_bidirectional_impl(self, chr);
    157 
    158 exit:
    159     return return_value;
    160 }
    161 
    162 PyDoc_STRVAR(unicodedata_UCD_combining__doc__,
    163 "combining($self, chr, /)\n"
    164 "--\n"
    165 "\n"
    166 "Returns the canonical combining class assigned to the character chr as integer.\n"
    167 "\n"
    168 "Returns 0 if no combining class is defined.");
    169 
    170 #define UNICODEDATA_UCD_COMBINING_METHODDEF    \
    171     {"combining", (PyCFunction)unicodedata_UCD_combining, METH_O, unicodedata_UCD_combining__doc__},
    172 
    173 static int
    174 unicodedata_UCD_combining_impl(PyObject *self, int chr);
    175 
    176 static PyObject *
    177 unicodedata_UCD_combining(PyObject *self, PyObject *arg)
    178 {
    179     PyObject *return_value = NULL;
    180     int chr;
    181     int _return_value;
    182 
    183     if (!PyArg_Parse(arg, "C:combining", &chr)) {
    184         goto exit;
    185     }
    186     _return_value = unicodedata_UCD_combining_impl(self, chr);
    187     if ((_return_value == -1) && PyErr_Occurred()) {
    188         goto exit;
    189     }
    190     return_value = PyLong_FromLong((long)_return_value);
    191 
    192 exit:
    193     return return_value;
    194 }
    195 
    196 PyDoc_STRVAR(unicodedata_UCD_mirrored__doc__,
    197 "mirrored($self, chr, /)\n"
    198 "--\n"
    199 "\n"
    200 "Returns the mirrored property assigned to the character chr as integer.\n"
    201 "\n"
    202 "Returns 1 if the character has been identified as a \"mirrored\"\n"
    203 "character in bidirectional text, 0 otherwise.");
    204 
    205 #define UNICODEDATA_UCD_MIRRORED_METHODDEF    \
    206     {"mirrored", (PyCFunction)unicodedata_UCD_mirrored, METH_O, unicodedata_UCD_mirrored__doc__},
    207 
    208 static int
    209 unicodedata_UCD_mirrored_impl(PyObject *self, int chr);
    210 
    211 static PyObject *
    212 unicodedata_UCD_mirrored(PyObject *self, PyObject *arg)
    213 {
    214     PyObject *return_value = NULL;
    215     int chr;
    216     int _return_value;
    217 
    218     if (!PyArg_Parse(arg, "C:mirrored", &chr)) {
    219         goto exit;
    220     }
    221     _return_value = unicodedata_UCD_mirrored_impl(self, chr);
    222     if ((_return_value == -1) && PyErr_Occurred()) {
    223         goto exit;
    224     }
    225     return_value = PyLong_FromLong((long)_return_value);
    226 
    227 exit:
    228     return return_value;
    229 }
    230 
    231 PyDoc_STRVAR(unicodedata_UCD_east_asian_width__doc__,
    232 "east_asian_width($self, chr, /)\n"
    233 "--\n"
    234 "\n"
    235 "Returns the east asian width assigned to the character chr as string.");
    236 
    237 #define UNICODEDATA_UCD_EAST_ASIAN_WIDTH_METHODDEF    \
    238     {"east_asian_width", (PyCFunction)unicodedata_UCD_east_asian_width, METH_O, unicodedata_UCD_east_asian_width__doc__},
    239 
    240 static PyObject *
    241 unicodedata_UCD_east_asian_width_impl(PyObject *self, int chr);
    242 
    243 static PyObject *
    244 unicodedata_UCD_east_asian_width(PyObject *self, PyObject *arg)
    245 {
    246     PyObject *return_value = NULL;
    247     int chr;
    248 
    249     if (!PyArg_Parse(arg, "C:east_asian_width", &chr)) {
    250         goto exit;
    251     }
    252     return_value = unicodedata_UCD_east_asian_width_impl(self, chr);
    253 
    254 exit:
    255     return return_value;
    256 }
    257 
    258 PyDoc_STRVAR(unicodedata_UCD_decomposition__doc__,
    259 "decomposition($self, chr, /)\n"
    260 "--\n"
    261 "\n"
    262 "Returns the character decomposition mapping assigned to the character chr as string.\n"
    263 "\n"
    264 "An empty string is returned in case no such mapping is defined.");
    265 
    266 #define UNICODEDATA_UCD_DECOMPOSITION_METHODDEF    \
    267     {"decomposition", (PyCFunction)unicodedata_UCD_decomposition, METH_O, unicodedata_UCD_decomposition__doc__},
    268 
    269 static PyObject *
    270 unicodedata_UCD_decomposition_impl(PyObject *self, int chr);
    271 
    272 static PyObject *
    273 unicodedata_UCD_decomposition(PyObject *self, PyObject *arg)
    274 {
    275     PyObject *return_value = NULL;
    276     int chr;
    277 
    278     if (!PyArg_Parse(arg, "C:decomposition", &chr)) {
    279         goto exit;
    280     }
    281     return_value = unicodedata_UCD_decomposition_impl(self, chr);
    282 
    283 exit:
    284     return return_value;
    285 }
    286 
    287 PyDoc_STRVAR(unicodedata_UCD_normalize__doc__,
    288 "normalize($self, form, unistr, /)\n"
    289 "--\n"
    290 "\n"
    291 "Return the normal form \'form\' for the Unicode string unistr.\n"
    292 "\n"
    293 "Valid values for form are \'NFC\', \'NFKC\', \'NFD\', and \'NFKD\'.");
    294 
    295 #define UNICODEDATA_UCD_NORMALIZE_METHODDEF    \
    296     {"normalize", (PyCFunction)unicodedata_UCD_normalize, METH_VARARGS, unicodedata_UCD_normalize__doc__},
    297 
    298 static PyObject *
    299 unicodedata_UCD_normalize_impl(PyObject *self, const char *form,
    300                                PyObject *input);
    301 
    302 static PyObject *
    303 unicodedata_UCD_normalize(PyObject *self, PyObject *args)
    304 {
    305     PyObject *return_value = NULL;
    306     const char *form;
    307     PyObject *input;
    308 
    309     if (!PyArg_ParseTuple(args, "sO!:normalize",
    310         &form, &PyUnicode_Type, &input)) {
    311         goto exit;
    312     }
    313     return_value = unicodedata_UCD_normalize_impl(self, form, input);
    314 
    315 exit:
    316     return return_value;
    317 }
    318 
    319 PyDoc_STRVAR(unicodedata_UCD_name__doc__,
    320 "name($self, chr, default=None, /)\n"
    321 "--\n"
    322 "\n"
    323 "Returns the name assigned to the character chr as a string.\n"
    324 "\n"
    325 "If no name is defined, default is returned, or, if not given,\n"
    326 "ValueError is raised.");
    327 
    328 #define UNICODEDATA_UCD_NAME_METHODDEF    \
    329     {"name", (PyCFunction)unicodedata_UCD_name, METH_VARARGS, unicodedata_UCD_name__doc__},
    330 
    331 static PyObject *
    332 unicodedata_UCD_name_impl(PyObject *self, int chr, PyObject *default_value);
    333 
    334 static PyObject *
    335 unicodedata_UCD_name(PyObject *self, PyObject *args)
    336 {
    337     PyObject *return_value = NULL;
    338     int chr;
    339     PyObject *default_value = NULL;
    340 
    341     if (!PyArg_ParseTuple(args, "C|O:name",
    342         &chr, &default_value)) {
    343         goto exit;
    344     }
    345     return_value = unicodedata_UCD_name_impl(self, chr, default_value);
    346 
    347 exit:
    348     return return_value;
    349 }
    350 
    351 PyDoc_STRVAR(unicodedata_UCD_lookup__doc__,
    352 "lookup($self, name, /)\n"
    353 "--\n"
    354 "\n"
    355 "Look up character by name.\n"
    356 "\n"
    357 "If a character with the given name is found, return the\n"
    358 "corresponding character.  If not found, KeyError is raised.");
    359 
    360 #define UNICODEDATA_UCD_LOOKUP_METHODDEF    \
    361     {"lookup", (PyCFunction)unicodedata_UCD_lookup, METH_O, unicodedata_UCD_lookup__doc__},
    362 
    363 static PyObject *
    364 unicodedata_UCD_lookup_impl(PyObject *self, const char *name,
    365                             Py_ssize_clean_t name_length);
    366 
    367 static PyObject *
    368 unicodedata_UCD_lookup(PyObject *self, PyObject *arg)
    369 {
    370     PyObject *return_value = NULL;
    371     const char *name;
    372     Py_ssize_clean_t name_length;
    373 
    374     if (!PyArg_Parse(arg, "s#:lookup", &name, &name_length)) {
    375         goto exit;
    376     }
    377     return_value = unicodedata_UCD_lookup_impl(self, name, name_length);
    378 
    379 exit:
    380     return return_value;
    381 }
    382 /*[clinic end generated code: output=5313ce129da87b2f input=a9049054013a1b77]*/
    383