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