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